LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible()
@ 2023-05-24 19:07 Mario Limonciello
  2023-05-24 19:07 ` [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable Mario Limonciello
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Mario Limonciello @ 2023-05-24 19:07 UTC (permalink / raw
  To: Bjorn Helgaas, Mika Westerberg, Rafael J . Wysocki
  Cc: linux-pci, linux-kernel, S-k Shyam-sundar, Natikar Basavaraj,
	Deucher Alexander, linux-pm, Lukas Wunner, Mario Limonciello

All of the cases handled by pci_bridge_d3_possible() are specific
to these branches:
```
	case PCI_EXP_TYPE_ROOT_PORT:
	case PCI_EXP_TYPE_UPSTREAM:
	case PCI_EXP_TYPE_DOWNSTREAM:
```
Drop a level of indentation by returning false in the default case
instead.  No intended functional changes.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v3->v4:
 * New patch
---
 drivers/pci/pci.c | 68 +++++++++++++++++++++++------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 5ede93222bc1..d1fa040bcea7 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2978,48 +2978,48 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
 	case PCI_EXP_TYPE_ROOT_PORT:
 	case PCI_EXP_TYPE_UPSTREAM:
 	case PCI_EXP_TYPE_DOWNSTREAM:
-		if (pci_bridge_d3_disable)
-			return false;
+		break;
+	default:
+		return false;
+	}
 
-		/*
-		 * Hotplug ports handled by firmware in System Management Mode
-		 * may not be put into D3 by the OS (Thunderbolt on non-Macs).
-		 */
-		if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge))
-			return false;
+	if (pci_bridge_d3_disable)
+		return false;
 
-		if (pci_bridge_d3_force)
-			return true;
+	/*
+	 * Hotplug ports handled by firmware in System Management Mode
+	 * may not be put into D3 by the OS (Thunderbolt on non-Macs).
+	 */
+	if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge))
+		return false;
 
-		/* Even the oldest 2010 Thunderbolt controller supports D3. */
-		if (bridge->is_thunderbolt)
-			return true;
+	if (pci_bridge_d3_force)
+		return true;
 
-		/* Platform might know better if the bridge supports D3 */
-		if (platform_pci_bridge_d3(bridge))
-			return true;
+	/* Even the oldest 2010 Thunderbolt controller supports D3. */
+	if (bridge->is_thunderbolt)
+		return true;
 
-		/*
-		 * Hotplug ports handled natively by the OS were not validated
-		 * by vendors for runtime D3 at least until 2018 because there
-		 * was no OS support.
-		 */
-		if (bridge->is_hotplug_bridge)
-			return false;
+	/* Platform might know better if the bridge supports D3 */
+	if (platform_pci_bridge_d3(bridge))
+		return true;
 
-		if (dmi_check_system(bridge_d3_blacklist))
-			return false;
+	/*
+	 * Hotplug ports handled natively by the OS were not validated
+	 * by vendors for runtime D3 at least until 2018 because there
+	 * was no OS support.
+	 */
+	if (bridge->is_hotplug_bridge)
+		return false;
 
-		/*
-		 * It should be safe to put PCIe ports from 2015 or newer
-		 * to D3.
-		 */
-		if (dmi_get_bios_year() >= 2015)
-			return true;
-		break;
-	}
+	if (dmi_check_system(bridge_d3_blacklist))
+		return false;
 
-	return false;
+	/*
+	 * It should be safe to put PCIe ports from 2015 or newer
+	 * to D3.
+	 */
+	return dmi_get_bios_year() >= 2015;
 }
 
 static int pci_dev_check_d3cold(struct pci_dev *dev, void *data)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable
  2023-05-24 19:07 [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible() Mario Limonciello
@ 2023-05-24 19:07 ` Mario Limonciello
  2023-05-25 14:15   ` Rafael J. Wysocki
                     ` (2 more replies)
  2023-05-25 13:48 ` [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible() Rafael J. Wysocki
  2023-05-26 12:12 ` Mika Westerberg
  2 siblings, 3 replies; 9+ messages in thread
From: Mario Limonciello @ 2023-05-24 19:07 UTC (permalink / raw
  To: Bjorn Helgaas, Mika Westerberg, Rafael J . Wysocki
  Cc: linux-pci, linux-kernel, S-k Shyam-sundar, Natikar Basavaraj,
	Deucher Alexander, linux-pm, Lukas Wunner, Mario Limonciello,
	Iain Lane

Using a USB keyboard or mouse to wakeup the system from s2idle fails when
that XHCI device is connected to a USB-C port for an AMD USB4 router.

Due to commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
all PCIe ports go into D3 during s2idle.

When specific root ports are put into D3 over s2idle on some AMD platforms
it is not possible for the platform to properly identify wakeup sources.
This happens whether the root port goes into D3hot or D3cold.

Comparing registers between Linux and Windows 11 this behavior to put
these specific root ports into D3 at suspend is unique to Linux. On an
affected system Windows does not put those specific root ports into D3
over Modern Standby.

Windows doesn't put the root ports into D3 because root ports are not
power manageable.

Linux shouldn't assume root ports support D3 just because they're on a
machine newer than 2015, the ports should also be deemed power manageable.
Add an extra check explicitly for root ports to ensure D3 isn't selected
for these ports.

Fixes: 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
Reported-by: Iain Lane <iain@orangesquash.org.uk>
Closes: https://forums.lenovo.com/t5/Ubuntu/Z13-can-t-resume-from-suspend-with-external-USB-keyboard/m-p/5217121
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v3->v4:
 * Move after refactor
---
 drivers/pci/pci.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d1fa040bcea7..d293db963327 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3015,6 +3015,14 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
 	if (dmi_check_system(bridge_d3_blacklist))
 		return false;
 
+	/*
+	 * It's not safe to put root ports that don't support power
+	 * management into D3.
+	 */
+	if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT &&
+	    !platform_pci_power_manageable(bridge))
+		return false;
+
 	/*
 	 * It should be safe to put PCIe ports from 2015 or newer
 	 * to D3.
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible()
  2023-05-24 19:07 [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible() Mario Limonciello
  2023-05-24 19:07 ` [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable Mario Limonciello
@ 2023-05-25 13:48 ` Rafael J. Wysocki
  2023-05-26 12:12 ` Mika Westerberg
  2 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2023-05-25 13:48 UTC (permalink / raw
  To: Mario Limonciello
  Cc: Bjorn Helgaas, Mika Westerberg, Rafael J . Wysocki, linux-pci,
	linux-kernel, S-k Shyam-sundar, Natikar Basavaraj,
	Deucher Alexander, linux-pm, Lukas Wunner

On Wed, May 24, 2023 at 9:07 PM Mario Limonciello
<mario.limonciello@amd.com> wrote:
>
> All of the cases handled by pci_bridge_d3_possible() are specific
> to these branches:
> ```
>         case PCI_EXP_TYPE_ROOT_PORT:
>         case PCI_EXP_TYPE_UPSTREAM:
>         case PCI_EXP_TYPE_DOWNSTREAM:
> ```
> Drop a level of indentation by returning false in the default case
> instead.  No intended functional changes.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Acked-by: Rafael J. Wysocki <rafael@kernel.org>

> ---
> v3->v4:
>  * New patch
> ---
>  drivers/pci/pci.c | 68 +++++++++++++++++++++++------------------------
>  1 file changed, 34 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 5ede93222bc1..d1fa040bcea7 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -2978,48 +2978,48 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
>         case PCI_EXP_TYPE_ROOT_PORT:
>         case PCI_EXP_TYPE_UPSTREAM:
>         case PCI_EXP_TYPE_DOWNSTREAM:
> -               if (pci_bridge_d3_disable)
> -                       return false;
> +               break;
> +       default:
> +               return false;
> +       }
>
> -               /*
> -                * Hotplug ports handled by firmware in System Management Mode
> -                * may not be put into D3 by the OS (Thunderbolt on non-Macs).
> -                */
> -               if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge))
> -                       return false;
> +       if (pci_bridge_d3_disable)
> +               return false;
>
> -               if (pci_bridge_d3_force)
> -                       return true;
> +       /*
> +        * Hotplug ports handled by firmware in System Management Mode
> +        * may not be put into D3 by the OS (Thunderbolt on non-Macs).
> +        */
> +       if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge))
> +               return false;
>
> -               /* Even the oldest 2010 Thunderbolt controller supports D3. */
> -               if (bridge->is_thunderbolt)
> -                       return true;
> +       if (pci_bridge_d3_force)
> +               return true;
>
> -               /* Platform might know better if the bridge supports D3 */
> -               if (platform_pci_bridge_d3(bridge))
> -                       return true;
> +       /* Even the oldest 2010 Thunderbolt controller supports D3. */
> +       if (bridge->is_thunderbolt)
> +               return true;
>
> -               /*
> -                * Hotplug ports handled natively by the OS were not validated
> -                * by vendors for runtime D3 at least until 2018 because there
> -                * was no OS support.
> -                */
> -               if (bridge->is_hotplug_bridge)
> -                       return false;
> +       /* Platform might know better if the bridge supports D3 */
> +       if (platform_pci_bridge_d3(bridge))
> +               return true;
>
> -               if (dmi_check_system(bridge_d3_blacklist))
> -                       return false;
> +       /*
> +        * Hotplug ports handled natively by the OS were not validated
> +        * by vendors for runtime D3 at least until 2018 because there
> +        * was no OS support.
> +        */
> +       if (bridge->is_hotplug_bridge)
> +               return false;
>
> -               /*
> -                * It should be safe to put PCIe ports from 2015 or newer
> -                * to D3.
> -                */
> -               if (dmi_get_bios_year() >= 2015)
> -                       return true;
> -               break;
> -       }
> +       if (dmi_check_system(bridge_d3_blacklist))
> +               return false;
>
> -       return false;
> +       /*
> +        * It should be safe to put PCIe ports from 2015 or newer
> +        * to D3.
> +        */
> +       return dmi_get_bios_year() >= 2015;
>  }
>
>  static int pci_dev_check_d3cold(struct pci_dev *dev, void *data)
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable
  2023-05-24 19:07 ` [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable Mario Limonciello
@ 2023-05-25 14:15   ` Rafael J. Wysocki
  2023-05-25 14:21     ` Limonciello, Mario
  2023-05-25 16:03   ` Sathyanarayanan Kuppuswamy
  2023-05-26 12:17   ` Mika Westerberg
  2 siblings, 1 reply; 9+ messages in thread
From: Rafael J. Wysocki @ 2023-05-25 14:15 UTC (permalink / raw
  To: Mario Limonciello
  Cc: Bjorn Helgaas, Mika Westerberg, Rafael J . Wysocki, linux-pci,
	linux-kernel, S-k Shyam-sundar, Natikar Basavaraj,
	Deucher Alexander, linux-pm, Lukas Wunner, Iain Lane

On Wed, May 24, 2023 at 9:07 PM Mario Limonciello
<mario.limonciello@amd.com> wrote:
>
> Using a USB keyboard or mouse to wakeup the system from s2idle fails when
> that XHCI device is connected to a USB-C port for an AMD USB4 router.
>
> Due to commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
> all PCIe ports go into D3 during s2idle.
>
> When specific root ports are put into D3 over s2idle on some AMD platforms
> it is not possible for the platform to properly identify wakeup sources.
> This happens whether the root port goes into D3hot or D3cold.
>
> Comparing registers between Linux and Windows 11 this behavior to put
> these specific root ports into D3 at suspend is unique to Linux. On an
> affected system Windows does not put those specific root ports into D3
> over Modern Standby.
>
> Windows doesn't put the root ports into D3 because root ports are not
> power manageable.
>
> Linux shouldn't assume root ports support D3 just because they're on a
> machine newer than 2015, the ports should also be deemed power manageable.
> Add an extra check explicitly for root ports to ensure D3 isn't selected
> for these ports.

"D3 isn't selected for them if they are not power-manageable through
platform firmware."  Or similar.

With this addressed:

Acked-by: Rafael J. Wysocki <rafael@kernel.org>

>
> Fixes: 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
> Reported-by: Iain Lane <iain@orangesquash.org.uk>
> Closes: https://forums.lenovo.com/t5/Ubuntu/Z13-can-t-resume-from-suspend-with-external-USB-keyboard/m-p/5217121
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v3->v4:
>  * Move after refactor
> ---
>  drivers/pci/pci.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index d1fa040bcea7..d293db963327 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3015,6 +3015,14 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
>         if (dmi_check_system(bridge_d3_blacklist))
>                 return false;
>
> +       /*
> +        * It's not safe to put root ports that don't support power
> +        * management into D3.
> +        */
> +       if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT &&
> +           !platform_pci_power_manageable(bridge))
> +               return false;
> +
>         /*
>          * It should be safe to put PCIe ports from 2015 or newer
>          * to D3.
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable
  2023-05-25 14:15   ` Rafael J. Wysocki
@ 2023-05-25 14:21     ` Limonciello, Mario
  0 siblings, 0 replies; 9+ messages in thread
From: Limonciello, Mario @ 2023-05-25 14:21 UTC (permalink / raw
  To: Bjorn Helgaas
  Cc: Mika Westerberg, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, S-k, Shyam-sundar,
	Natikar, Basavaraj, Deucher, Alexander, linux-pm@vger.kernel.org,
	Lukas Wunner, Iain Lane, Rafael J. Wysocki

[AMD Official Use Only - General]

> -----Original Message-----
> From: Rafael J. Wysocki <rafael@kernel.org>
> Sent: Thursday, May 25, 2023 9:16 AM
> To: Limonciello, Mario <Mario.Limonciello@amd.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>; Mika Westerberg
> <mika.westerberg@linux.intel.com>; Rafael J . Wysocki <rafael@kernel.org>;
> linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org; S-k, Shyam-sundar
> <Shyam-sundar.S-k@amd.com>; Natikar, Basavaraj
> <Basavaraj.Natikar@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>; linux-pm@vger.kernel.org; Lukas Wunner
> <lukas@wunner.de>; Iain Lane <iain@orangesquash.org.uk>
> Subject: Re: [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are
> power manageable
>
> On Wed, May 24, 2023 at 9:07 PM Mario Limonciello
> <mario.limonciello@amd.com> wrote:
> >
> > Using a USB keyboard or mouse to wakeup the system from s2idle fails when
> > that XHCI device is connected to a USB-C port for an AMD USB4 router.
> >
> > Due to commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during
> suspend")
> > all PCIe ports go into D3 during s2idle.
> >
> > When specific root ports are put into D3 over s2idle on some AMD platforms
> > it is not possible for the platform to properly identify wakeup sources.
> > This happens whether the root port goes into D3hot or D3cold.
> >
> > Comparing registers between Linux and Windows 11 this behavior to put
> > these specific root ports into D3 at suspend is unique to Linux. On an
> > affected system Windows does not put those specific root ports into D3
> > over Modern Standby.
> >
> > Windows doesn't put the root ports into D3 because root ports are not
> > power manageable.
> >
> > Linux shouldn't assume root ports support D3 just because they're on a
> > machine newer than 2015, the ports should also be deemed power
> manageable.
> > Add an extra check explicitly for root ports to ensure D3 isn't selected
> > for these ports.
>
> "D3 isn't selected for them if they are not power-manageable through
> platform firmware."  Or similar.
>
> With this addressed:
>
> Acked-by: Rafael J. Wysocki <rafael@kernel.org>

Thanks!

If no other oppositions,  Bjorn, let me know if you want me to respin for
this or you can massage commit message yourself.

>
> >
> > Fixes: 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
> > Reported-by: Iain Lane <iain@orangesquash.org.uk>
> > Closes: https://forums.lenovo.com/t5/Ubuntu/Z13-can-t-resume-from-
> suspend-with-external-USB-keyboard/m-p/5217121
> > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> > ---
> > v3->v4:
> >  * Move after refactor
> > ---
> >  drivers/pci/pci.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > index d1fa040bcea7..d293db963327 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -3015,6 +3015,14 @@ bool pci_bridge_d3_possible(struct pci_dev
> *bridge)
> >         if (dmi_check_system(bridge_d3_blacklist))
> >                 return false;
> >
> > +       /*
> > +        * It's not safe to put root ports that don't support power
> > +        * management into D3.
> > +        */
> > +       if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT &&
> > +           !platform_pci_power_manageable(bridge))
> > +               return false;
> > +
> >         /*
> >          * It should be safe to put PCIe ports from 2015 or newer
> >          * to D3.
> > --
> > 2.34.1
> >

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable
  2023-05-24 19:07 ` [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable Mario Limonciello
  2023-05-25 14:15   ` Rafael J. Wysocki
@ 2023-05-25 16:03   ` Sathyanarayanan Kuppuswamy
  2023-05-25 16:10     ` Limonciello, Mario
  2023-05-26 12:17   ` Mika Westerberg
  2 siblings, 1 reply; 9+ messages in thread
From: Sathyanarayanan Kuppuswamy @ 2023-05-25 16:03 UTC (permalink / raw
  To: Mario Limonciello, Bjorn Helgaas, Mika Westerberg,
	Rafael J . Wysocki
  Cc: linux-pci, linux-kernel, S-k Shyam-sundar, Natikar Basavaraj,
	Deucher Alexander, linux-pm, Lukas Wunner, Iain Lane



On 5/24/23 12:07 PM, Mario Limonciello wrote:

This looks like a generic fix to me. So why talk about > 2015? IMO,
you can remove > 2015 from the title.

> Using a USB keyboard or mouse to wakeup the system from s2idle fails when
> that XHCI device is connected to a USB-C port for an AMD USB4 router.
> 
> Due to commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
> all PCIe ports go into D3 during s2idle.
> 
> When specific root ports are put into D3 over s2idle on some AMD platforms
> it is not possible for the platform to properly identify wakeup sources.
> This happens whether the root port goes into D3hot or D3cold.

I think Linux/Windows comparison is also not needed. But it is up to you.

> 
> Comparing registers between Linux and Windows 11 this behavior to put
> these specific root ports into D3 at suspend is unique to Linux. On an
> affected system Windows does not put those specific root ports into D3
> over Modern Standby.
> 
> Windows doesn't put the root ports into D3 because root ports are not
> power manageable.
> 
> Linux shouldn't assume root ports support D3 just because they're on a
> machine newer than 2015, the ports should also be deemed power manageable.
> Add an extra check explicitly for root ports to ensure D3 isn't selected
> for these ports.
> 

Other than above suggestions, rest looks good to me.

Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>

> Fixes: 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
> Reported-by: Iain Lane <iain@orangesquash.org.uk>
> Closes: https://forums.lenovo.com/t5/Ubuntu/Z13-can-t-resume-from-suspend-with-external-USB-keyboard/m-p/5217121
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v3->v4:
>  * Move after refactor
> ---
>  drivers/pci/pci.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index d1fa040bcea7..d293db963327 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3015,6 +3015,14 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
>  	if (dmi_check_system(bridge_d3_blacklist))
>  		return false;
>  
> +	/*
> +	 * It's not safe to put root ports that don't support power
> +	 * management into D3.
> +	 */
> +	if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT &&
> +	    !platform_pci_power_manageable(bridge))
> +		return false;
> +
>  	/*
>  	 * It should be safe to put PCIe ports from 2015 or newer
>  	 * to D3.

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable
  2023-05-25 16:03   ` Sathyanarayanan Kuppuswamy
@ 2023-05-25 16:10     ` Limonciello, Mario
  0 siblings, 0 replies; 9+ messages in thread
From: Limonciello, Mario @ 2023-05-25 16:10 UTC (permalink / raw
  To: Sathyanarayanan Kuppuswamy, Bjorn Helgaas, Mika Westerberg,
	Rafael J . Wysocki
  Cc: linux-pci, linux-kernel, S-k Shyam-sundar, Natikar Basavaraj,
	Deucher Alexander, linux-pm, Lukas Wunner, Iain Lane

On 5/25/2023 11:03 AM, Sathyanarayanan Kuppuswamy wrote:
>
> On 5/24/23 12:07 PM, Mario Limonciello wrote:
>
> This looks like a generic fix to me. So why talk about > 2015? IMO,
> you can remove > 2015 from the title.
The issue was caused by the >2015 heuristic.  If that's taken
out then it went away.  But yes; I agree with you.  If I need
to respin I'll remove this.
>> Using a USB keyboard or mouse to wakeup the system from s2idle fails when
>> that XHCI device is connected to a USB-C port for an AMD USB4 router.
>>
>> Due to commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
>> all PCIe ports go into D3 during s2idle.
>>
>> When specific root ports are put into D3 over s2idle on some AMD platforms
>> it is not possible for the platform to properly identify wakeup sources.
>> This happens whether the root port goes into D3hot or D3cold.
> I think Linux/Windows comparison is also not needed. But it is up to you.
I think up to Bjorn :)
>> Comparing registers between Linux and Windows 11 this behavior to put
>> these specific root ports into D3 at suspend is unique to Linux. On an
>> affected system Windows does not put those specific root ports into D3
>> over Modern Standby.
>>
>> Windows doesn't put the root ports into D3 because root ports are not
>> power manageable.
>>
>> Linux shouldn't assume root ports support D3 just because they're on a
>> machine newer than 2015, the ports should also be deemed power manageable.
>> Add an extra check explicitly for root ports to ensure D3 isn't selected
>> for these ports.
>>
> Other than above suggestions, rest looks good to me.
>
> Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Much appreciated!
>> Fixes: 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
>> Reported-by: Iain Lane <iain@orangesquash.org.uk>
>> Closes: https://forums.lenovo.com/t5/Ubuntu/Z13-can-t-resume-from-suspend-with-external-USB-keyboard/m-p/5217121
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> v3->v4:
>>   * Move after refactor
>> ---
>>   drivers/pci/pci.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index d1fa040bcea7..d293db963327 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -3015,6 +3015,14 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
>>   	if (dmi_check_system(bridge_d3_blacklist))
>>   		return false;
>>   
>> +	/*
>> +	 * It's not safe to put root ports that don't support power
>> +	 * management into D3.
>> +	 */
>> +	if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT &&
>> +	    !platform_pci_power_manageable(bridge))
>> +		return false;
>> +
>>   	/*
>>   	 * It should be safe to put PCIe ports from 2015 or newer
>>   	 * to D3.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible()
  2023-05-24 19:07 [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible() Mario Limonciello
  2023-05-24 19:07 ` [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable Mario Limonciello
  2023-05-25 13:48 ` [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible() Rafael J. Wysocki
@ 2023-05-26 12:12 ` Mika Westerberg
  2 siblings, 0 replies; 9+ messages in thread
From: Mika Westerberg @ 2023-05-26 12:12 UTC (permalink / raw
  To: Mario Limonciello
  Cc: Bjorn Helgaas, Rafael J . Wysocki, linux-pci, linux-kernel,
	S-k Shyam-sundar, Natikar Basavaraj, Deucher Alexander, linux-pm,
	Lukas Wunner

On Wed, May 24, 2023 at 02:07:25PM -0500, Mario Limonciello wrote:
> All of the cases handled by pci_bridge_d3_possible() are specific
> to these branches:
> ```
> 	case PCI_EXP_TYPE_ROOT_PORT:
> 	case PCI_EXP_TYPE_UPSTREAM:
> 	case PCI_EXP_TYPE_DOWNSTREAM:
> ```
> Drop a level of indentation by returning false in the default case
> instead.  No intended functional changes.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable
  2023-05-24 19:07 ` [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable Mario Limonciello
  2023-05-25 14:15   ` Rafael J. Wysocki
  2023-05-25 16:03   ` Sathyanarayanan Kuppuswamy
@ 2023-05-26 12:17   ` Mika Westerberg
  2 siblings, 0 replies; 9+ messages in thread
From: Mika Westerberg @ 2023-05-26 12:17 UTC (permalink / raw
  To: Mario Limonciello
  Cc: Bjorn Helgaas, Rafael J . Wysocki, linux-pci, linux-kernel,
	S-k Shyam-sundar, Natikar Basavaraj, Deucher Alexander, linux-pm,
	Lukas Wunner, Iain Lane

On Wed, May 24, 2023 at 02:07:26PM -0500, Mario Limonciello wrote:
> Using a USB keyboard or mouse to wakeup the system from s2idle fails when
> that XHCI device is connected to a USB-C port for an AMD USB4 router.

nit: I think the correct is "xHCI" but no need to spin a new version
just for that.

> Due to commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
> all PCIe ports go into D3 during s2idle.
> 
> When specific root ports are put into D3 over s2idle on some AMD platforms
> it is not possible for the platform to properly identify wakeup sources.
> This happens whether the root port goes into D3hot or D3cold.
> 
> Comparing registers between Linux and Windows 11 this behavior to put
> these specific root ports into D3 at suspend is unique to Linux. On an
> affected system Windows does not put those specific root ports into D3
> over Modern Standby.
> 
> Windows doesn't put the root ports into D3 because root ports are not
> power manageable.

Probably better is to say:

 Windows avoids putting Root Ports that are not power manageable (e.g do
 not have platform firmware support) into low power states.

but again no need to respin just for that.

> Linux shouldn't assume root ports support D3 just because they're on a
> machine newer than 2015, the ports should also be deemed power manageable.
> Add an extra check explicitly for root ports to ensure D3 isn't selected
> for these ports.
> 
> Fixes: 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
> Reported-by: Iain Lane <iain@orangesquash.org.uk>
> Closes: https://forums.lenovo.com/t5/Ubuntu/Z13-can-t-resume-from-suspend-with-external-USB-keyboard/m-p/5217121
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-05-26 12:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-24 19:07 [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible() Mario Limonciello
2023-05-24 19:07 ` [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable Mario Limonciello
2023-05-25 14:15   ` Rafael J. Wysocki
2023-05-25 14:21     ` Limonciello, Mario
2023-05-25 16:03   ` Sathyanarayanan Kuppuswamy
2023-05-25 16:10     ` Limonciello, Mario
2023-05-26 12:17   ` Mika Westerberg
2023-05-25 13:48 ` [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible() Rafael J. Wysocki
2023-05-26 12:12 ` Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).