linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown
@ 2021-02-04  5:18 Aaron Ma
  2021-02-05  4:27 ` Kai-Heng Feng
  0 siblings, 1 reply; 9+ messages in thread
From: Aaron Ma @ 2021-02-04  5:18 UTC (permalink / raw)
  To: aaron.ma, gregkh, mathias.nyman, stern, lee.jones, peter.chen,
	linux-usb, linux-kernel

On AMD Renoir/Cezanne platforms, when set "Always on USB" to "On" in BIOS,
USB controller will consume more power than 0.03w.

Set it to D3cold when shutdown, S5 power consumption will be 0.03w lower.
The USB can charge other devices as before.
USB controller works fine after power on and reboot.

Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
---
 drivers/usb/host/xhci-pci.c | 8 ++++++++
 drivers/usb/host/xhci.h     | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 84da8406d5b4..a31be1ba927f 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -62,6 +62,7 @@
 #define PCI_DEVICE_ID_AMD_PROMONTORYA_3			0x43ba
 #define PCI_DEVICE_ID_AMD_PROMONTORYA_2			0x43bb
 #define PCI_DEVICE_ID_AMD_PROMONTORYA_1			0x43bc
+#define PCI_DEVICE_ID_AMD_RENOIR_USB31			0x1639
 #define PCI_DEVICE_ID_ASMEDIA_1042_XHCI			0x1042
 #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI		0x1142
 #define PCI_DEVICE_ID_ASMEDIA_1142_XHCI			0x1242
@@ -171,6 +172,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 	if (pdev->vendor == PCI_VENDOR_ID_AMD)
 		xhci->quirks |= XHCI_TRUST_TX_LENGTH;
 
+	if (pdev->vendor == PCI_VENDOR_ID_AMD &&
+		pdev->device == PCI_DEVICE_ID_AMD_RENOIR_USB31)
+		xhci->quirks |= XHCI_SHUTDOWN_D3COLD;
+
 	if ((pdev->vendor == PCI_VENDOR_ID_AMD) &&
 		((pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4) ||
 		(pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_3) ||
@@ -594,6 +599,9 @@ static void xhci_pci_shutdown(struct usb_hcd *hcd)
 	/* Yet another workaround for spurious wakeups at shutdown with HSW */
 	if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
 		pci_set_power_state(pdev, PCI_D3hot);
+
+	if (xhci->quirks & XHCI_SHUTDOWN_D3COLD)
+		pci_set_power_state(pdev, PCI_D3cold);
 }
 #endif /* CONFIG_PM */
 
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 25e57bc9c3cc..0684193da4bd 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1883,6 +1883,7 @@ struct xhci_hcd {
 #define XHCI_SKIP_PHY_INIT	BIT_ULL(37)
 #define XHCI_DISABLE_SPARSE	BIT_ULL(38)
 #define XHCI_SG_TRB_CACHE_SIZE_QUIRK	BIT_ULL(39)
+#define XHCI_SHUTDOWN_D3COLD	BIT_ULL(40)
 
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;
-- 
2.30.0


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

* Re: [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown
  2021-02-04  5:18 [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown Aaron Ma
@ 2021-02-05  4:27 ` Kai-Heng Feng
  2021-02-05  6:45   ` Aaron Ma
  0 siblings, 1 reply; 9+ messages in thread
From: Kai-Heng Feng @ 2021-02-05  4:27 UTC (permalink / raw)
  To: Aaron Ma
  Cc: Greg Kroah-Hartman, Mathias Nyman, Alan Stern, lee.jones,
	peter.chen, USB list, LKML

On Thu, Feb 4, 2021 at 1:20 PM Aaron Ma <aaron.ma@canonical.com> wrote:
>
> On AMD Renoir/Cezanne platforms, when set "Always on USB" to "On" in BIOS,
> USB controller will consume more power than 0.03w.
>
> Set it to D3cold when shutdown, S5 power consumption will be 0.03w lower.
> The USB can charge other devices as before.
> USB controller works fine after power on and reboot.

Can you please test the following patch, which should address the root cause:
https://lore.kernel.org/linux-acpi/20201201213019.1558738-1-furquan@google.com/

It also helps another AMD laptop on S5:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1912935

We don't need to put bandage on drivers one by one once the patch with
alternative approach is in upstream.

Kai-Heng

>
> Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
> ---
>  drivers/usb/host/xhci-pci.c | 8 ++++++++
>  drivers/usb/host/xhci.h     | 1 +
>  2 files changed, 9 insertions(+)
>
> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> index 84da8406d5b4..a31be1ba927f 100644
> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -62,6 +62,7 @@
>  #define PCI_DEVICE_ID_AMD_PROMONTORYA_3                        0x43ba
>  #define PCI_DEVICE_ID_AMD_PROMONTORYA_2                        0x43bb
>  #define PCI_DEVICE_ID_AMD_PROMONTORYA_1                        0x43bc
> +#define PCI_DEVICE_ID_AMD_RENOIR_USB31                 0x1639
>  #define PCI_DEVICE_ID_ASMEDIA_1042_XHCI                        0x1042
>  #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI               0x1142
>  #define PCI_DEVICE_ID_ASMEDIA_1142_XHCI                        0x1242
> @@ -171,6 +172,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
>         if (pdev->vendor == PCI_VENDOR_ID_AMD)
>                 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
>
> +       if (pdev->vendor == PCI_VENDOR_ID_AMD &&
> +               pdev->device == PCI_DEVICE_ID_AMD_RENOIR_USB31)
> +               xhci->quirks |= XHCI_SHUTDOWN_D3COLD;
> +
>         if ((pdev->vendor == PCI_VENDOR_ID_AMD) &&
>                 ((pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4) ||
>                 (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_3) ||
> @@ -594,6 +599,9 @@ static void xhci_pci_shutdown(struct usb_hcd *hcd)
>         /* Yet another workaround for spurious wakeups at shutdown with HSW */
>         if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
>                 pci_set_power_state(pdev, PCI_D3hot);
> +
> +       if (xhci->quirks & XHCI_SHUTDOWN_D3COLD)
> +               pci_set_power_state(pdev, PCI_D3cold);
>  }
>  #endif /* CONFIG_PM */
>
> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> index 25e57bc9c3cc..0684193da4bd 100644
> --- a/drivers/usb/host/xhci.h
> +++ b/drivers/usb/host/xhci.h
> @@ -1883,6 +1883,7 @@ struct xhci_hcd {
>  #define XHCI_SKIP_PHY_INIT     BIT_ULL(37)
>  #define XHCI_DISABLE_SPARSE    BIT_ULL(38)
>  #define XHCI_SG_TRB_CACHE_SIZE_QUIRK   BIT_ULL(39)
> +#define XHCI_SHUTDOWN_D3COLD   BIT_ULL(40)
>
>         unsigned int            num_active_eps;
>         unsigned int            limit_active_eps;
> --
> 2.30.0
>

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

* Re: [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown
  2021-02-05  4:27 ` Kai-Heng Feng
@ 2021-02-05  6:45   ` Aaron Ma
  2021-02-05  6:50     ` Kai-Heng Feng
  0 siblings, 1 reply; 9+ messages in thread
From: Aaron Ma @ 2021-02-05  6:45 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: Greg Kroah-Hartman, Mathias Nyman, Alan Stern, lee.jones,
	peter.chen, USB list, LKML


On 2/5/21 12:27 PM, Kai-Heng Feng wrote:
> Can you please test the following patch, which should address the root cause:
> https://lore.kernel.org/linux-acpi/20201201213019.1558738-1-furquan@google.com/
> 
> It also helps another AMD laptop on S5:
> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1912935
> 

No, this patch doesn't help on ThinkPad AMD platform.

Aaron

> We don't need to put bandage on drivers one by one once the patch with
> alternative approach is in upstream.
> 
> Kai-Heng

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

* Re: [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown
  2021-02-05  6:45   ` Aaron Ma
@ 2021-02-05  6:50     ` Kai-Heng Feng
  2021-02-09  8:37       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 9+ messages in thread
From: Kai-Heng Feng @ 2021-02-05  6:50 UTC (permalink / raw)
  To: Aaron Ma
  Cc: Greg Kroah-Hartman, Mathias Nyman, Alan Stern, Lee Jones,
	peter.chen, USB list, LKML

On Fri, Feb 5, 2021 at 2:45 PM Aaron Ma <aaron.ma@canonical.com> wrote:
>
>
> On 2/5/21 12:27 PM, Kai-Heng Feng wrote:
> > Can you please test the following patch, which should address the root cause:
> > https://lore.kernel.org/linux-acpi/20201201213019.1558738-1-furquan@google.com/
> >
> > It also helps another AMD laptop on S5:
> > https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1912935
> >
>
> No, this patch doesn't help on ThinkPad AMD platform.

Thanks for the confirmation!

Acked-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

>
> Aaron
>
> > We don't need to put bandage on drivers one by one once the patch with
> > alternative approach is in upstream.
> >
> > Kai-Heng

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

* Re: [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown
  2021-02-05  6:50     ` Kai-Heng Feng
@ 2021-02-09  8:37       ` Greg Kroah-Hartman
  2021-02-10 13:13         ` Mathias Nyman
  0 siblings, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2021-02-09  8:37 UTC (permalink / raw)
  To: Kai-Heng Feng, Mathias Nyman
  Cc: Aaron Ma, Alan Stern, Lee Jones, peter.chen, USB list, LKML

On Fri, Feb 05, 2021 at 02:50:15PM +0800, Kai-Heng Feng wrote:
> On Fri, Feb 5, 2021 at 2:45 PM Aaron Ma <aaron.ma@canonical.com> wrote:
> >
> >
> > On 2/5/21 12:27 PM, Kai-Heng Feng wrote:
> > > Can you please test the following patch, which should address the root cause:
> > > https://lore.kernel.org/linux-acpi/20201201213019.1558738-1-furquan@google.com/
> > >
> > > It also helps another AMD laptop on S5:
> > > https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1912935
> > >
> >
> > No, this patch doesn't help on ThinkPad AMD platform.
> 
> Thanks for the confirmation!
> 
> Acked-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

Mathias, want me to take this in my tree now, or are you going to send
me more patches for 5.12-rc1?

thanks,

greg k-h

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

* Re: [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown
  2021-02-09  8:37       ` Greg Kroah-Hartman
@ 2021-02-10 13:13         ` Mathias Nyman
  2021-02-11 12:50           ` Greg Kroah-Hartman
  0 siblings, 1 reply; 9+ messages in thread
From: Mathias Nyman @ 2021-02-10 13:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Kai-Heng Feng
  Cc: Aaron Ma, Alan Stern, Lee Jones, peter.chen, USB list, LKML,
	Bjorn Helgaas, Linux PCI

On 9.2.2021 10.37, Greg Kroah-Hartman wrote:
> On Fri, Feb 05, 2021 at 02:50:15PM +0800, Kai-Heng Feng wrote:
>> On Fri, Feb 5, 2021 at 2:45 PM Aaron Ma <aaron.ma@canonical.com> wrote:
>>>
>>>
>>> On 2/5/21 12:27 PM, Kai-Heng Feng wrote:
>>>> Can you please test the following patch, which should address the root cause:
>>>> https://lore.kernel.org/linux-acpi/20201201213019.1558738-1-furquan@google.com/
>>>>
>>>> It also helps another AMD laptop on S5:
>>>> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1912935
>>>>
>>>
>>> No, this patch doesn't help on ThinkPad AMD platform.
>>
>> Thanks for the confirmation!
>>
>> Acked-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> 
> Mathias, want me to take this in my tree now, or are you going to send
> me more patches for 5.12-rc1?
> 

Nothing more for 5.12-rc1 from me.

Could this be a PCI quirk instead of xhci?
Maybe there is some PCI flag for this already, haven't checked yet.

We want a specific PCI device to go to PCI D3cold at PCI shutdown...

If not, then adding this to xhci is fine for me as well

Thanks
-Mathias 



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

* Re: [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown
  2021-02-10 13:13         ` Mathias Nyman
@ 2021-02-11 12:50           ` Greg Kroah-Hartman
  2021-02-19  8:07             ` Aaron Ma
  0 siblings, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2021-02-11 12:50 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: Kai-Heng Feng, Aaron Ma, Alan Stern, Lee Jones, peter.chen,
	USB list, LKML, Bjorn Helgaas, Linux PCI

On Wed, Feb 10, 2021 at 03:13:30PM +0200, Mathias Nyman wrote:
> On 9.2.2021 10.37, Greg Kroah-Hartman wrote:
> > On Fri, Feb 05, 2021 at 02:50:15PM +0800, Kai-Heng Feng wrote:
> >> On Fri, Feb 5, 2021 at 2:45 PM Aaron Ma <aaron.ma@canonical.com> wrote:
> >>>
> >>>
> >>> On 2/5/21 12:27 PM, Kai-Heng Feng wrote:
> >>>> Can you please test the following patch, which should address the root cause:
> >>>> https://lore.kernel.org/linux-acpi/20201201213019.1558738-1-furquan@google.com/
> >>>>
> >>>> It also helps another AMD laptop on S5:
> >>>> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1912935
> >>>>
> >>>
> >>> No, this patch doesn't help on ThinkPad AMD platform.
> >>
> >> Thanks for the confirmation!
> >>
> >> Acked-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> > 
> > Mathias, want me to take this in my tree now, or are you going to send
> > me more patches for 5.12-rc1?
> > 
> 
> Nothing more for 5.12-rc1 from me.
> 
> Could this be a PCI quirk instead of xhci?
> Maybe there is some PCI flag for this already, haven't checked yet.
> 
> We want a specific PCI device to go to PCI D3cold at PCI shutdown...

There probably is.  Kay-Heng, can you look into doing that instead?

thanks,

greg k-h

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

* Re: [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown
  2021-02-11 12:50           ` Greg Kroah-Hartman
@ 2021-02-19  8:07             ` Aaron Ma
  2021-02-22  5:56               ` Kai-Heng Feng
  0 siblings, 1 reply; 9+ messages in thread
From: Aaron Ma @ 2021-02-19  8:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mathias Nyman
  Cc: Kai-Heng Feng, Alan Stern, Lee Jones, peter.chen, USB list, LKML,
	Bjorn Helgaas, Linux PCI



On 2/11/21 8:50 PM, Greg Kroah-Hartman wrote:
> On Wed, Feb 10, 2021 at 03:13:30PM +0200, Mathias Nyman wrote:
>> On 9.2.2021 10.37, Greg Kroah-Hartman wrote:
>>> On Fri, Feb 05, 2021 at 02:50:15PM +0800, Kai-Heng Feng wrote:
>>>> On Fri, Feb 5, 2021 at 2:45 PM Aaron Ma <aaron.ma@canonical.com> wrote:
>>>>>
>>>>>
>>>>> On 2/5/21 12:27 PM, Kai-Heng Feng wrote:
>>>>>> Can you please test the following patch, which should address the root cause:
>>>>>> https://lore.kernel.org/linux-acpi/20201201213019.1558738-1-furquan@google.com/
>>>>>>
>>>>>> It also helps another AMD laptop on S5:
>>>>>> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1912935
>>>>>>
>>>>>
>>>>> No, this patch doesn't help on ThinkPad AMD platform.
>>>>
>>>> Thanks for the confirmation!
>>>>
>>>> Acked-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>>>
>>> Mathias, want me to take this in my tree now, or are you going to send
>>> me more patches for 5.12-rc1?
>>>
>>
>> Nothing more for 5.12-rc1 from me.
>>
>> Could this be a PCI quirk instead of xhci?
>> Maybe there is some PCI flag for this already, haven't checked yet.
>>
>> We want a specific PCI device to go to PCI D3cold at PCI shutdown...
> 
> There probably is.  Kay-Heng, can you look into doing that instead?
> 

There is no such PCI quirk, usually it calls driver to shutdown.

Regards,
Aaron

> thanks,
> 
> greg k-h
> 

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

* Re: [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown
  2021-02-19  8:07             ` Aaron Ma
@ 2021-02-22  5:56               ` Kai-Heng Feng
  0 siblings, 0 replies; 9+ messages in thread
From: Kai-Heng Feng @ 2021-02-22  5:56 UTC (permalink / raw)
  To: Aaron Ma
  Cc: Greg Kroah-Hartman, Mathias Nyman, Alan Stern, Lee Jones,
	peter.chen, USB list, LKML, Bjorn Helgaas, Linux PCI

On Fri, Feb 19, 2021 at 4:07 PM Aaron Ma <aaron.ma@canonical.com> wrote:
>
>
>
> On 2/11/21 8:50 PM, Greg Kroah-Hartman wrote:
> > On Wed, Feb 10, 2021 at 03:13:30PM +0200, Mathias Nyman wrote:
> >> On 9.2.2021 10.37, Greg Kroah-Hartman wrote:
> >>> On Fri, Feb 05, 2021 at 02:50:15PM +0800, Kai-Heng Feng wrote:
> >>>> On Fri, Feb 5, 2021 at 2:45 PM Aaron Ma <aaron.ma@canonical.com> wrote:
> >>>>>
> >>>>>
> >>>>> On 2/5/21 12:27 PM, Kai-Heng Feng wrote:
> >>>>>> Can you please test the following patch, which should address the root cause:
> >>>>>> https://lore.kernel.org/linux-acpi/20201201213019.1558738-1-furquan@google.com/
> >>>>>>
> >>>>>> It also helps another AMD laptop on S5:
> >>>>>> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1912935
> >>>>>>
> >>>>>
> >>>>> No, this patch doesn't help on ThinkPad AMD platform.
> >>>>
> >>>> Thanks for the confirmation!
> >>>>
> >>>> Acked-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> >>>
> >>> Mathias, want me to take this in my tree now, or are you going to send
> >>> me more patches for 5.12-rc1?
> >>>
> >>
> >> Nothing more for 5.12-rc1 from me.
> >>
> >> Could this be a PCI quirk instead of xhci?
> >> Maybe there is some PCI flag for this already, haven't checked yet.
> >>
> >> We want a specific PCI device to go to PCI D3cold at PCI shutdown...
> >
> > There probably is.  Kay-Heng, can you look into doing that instead?
> >
>
> There is no such PCI quirk, usually it calls driver to shutdown.

Let me work on it. There are other devices need to be in D3 for
shutdown, a generic approach across all devices will be better.

Kai-Heng

>
> Regards,
> Aaron
>
> > thanks,
> >
> > greg k-h
> >

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

end of thread, other threads:[~2021-02-22  5:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04  5:18 [PATCH] xhci-pci: Set AMD Renoir USB controller to D3 when shutdown Aaron Ma
2021-02-05  4:27 ` Kai-Heng Feng
2021-02-05  6:45   ` Aaron Ma
2021-02-05  6:50     ` Kai-Heng Feng
2021-02-09  8:37       ` Greg Kroah-Hartman
2021-02-10 13:13         ` Mathias Nyman
2021-02-11 12:50           ` Greg Kroah-Hartman
2021-02-19  8:07             ` Aaron Ma
2021-02-22  5:56               ` Kai-Heng Feng

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 NNTP newsgroup(s).