All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: Add quirk to clear AMD strap_15B8 NO_SOFT_RESET dev2 f0
@ 2023-03-29 17:28 Basavaraj Natikar
  2023-03-29 18:56 ` Limonciello, Mario
  2023-04-06 21:30 ` Bjorn Helgaas
  0 siblings, 2 replies; 5+ messages in thread
From: Basavaraj Natikar @ 2023-03-29 17:28 UTC (permalink / raw)
  To: bhelgaas, tglx, mingo, bp, dave.hansen, hpa, x86, linux-pci
  Cc: mario.limonciello, thomas, Basavaraj Natikar

The AMD [1022:15b8] USB controller loses some internal functional
MSI-X context when transitioning from D0 to D3hot. BIOS normally
traps D0->D3hot and D3hot->D0 transitions so it can save and restore
that internal context, but some firmware in the field lacks due to
AMD_15B8_RCC_DEV2_EPF0_STRAP2 NO_SOFT_RESET bit is set.

Hence add quirk to clear AMD_15B8_RCC_DEV2_EPF0_STRAP2 NO_SOFT_RESET
bit before USB controller initialization during boot.

Reported-by: Thomas Glanzmann <thomas@glanzmann.de>
Link: https://lore.kernel.org/linux-usb/Y%2Fz9GdHjPyF2rNG3@glanzmann.de/T/#u
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
---
 arch/x86/pci/fixup.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
index 615a76d70019..bf5161dcf89e 100644
--- a/arch/x86/pci/fixup.c
+++ b/arch/x86/pci/fixup.c
@@ -7,6 +7,7 @@
 #include <linux/dmi.h>
 #include <linux/pci.h>
 #include <linux/vgaarb.h>
+#include <asm/amd_nb.h>
 #include <asm/hpet.h>
 #include <asm/pci_x86.h>
 
@@ -824,3 +825,23 @@ static void rs690_fix_64bit_dma(struct pci_dev *pdev)
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7910, rs690_fix_64bit_dma);
 
 #endif
+
+#ifdef CONFIG_AMD_NB
+
+#define AMD_15B8_RCC_DEV2_EPF0_STRAP2                                  0x10136008
+#define AMD_15B8_RCC_DEV2_EPF0_STRAP2_NO_SOFT_RESET_DEV2_F0_MASK       0x00000080L
+
+static void quirk_clear_strap_no_soft_reset_dev2_f0(struct pci_dev *dev)
+{
+	u32 data;
+
+	if (!amd_smn_read(0, AMD_15B8_RCC_DEV2_EPF0_STRAP2, &data)) {
+		data &= ~AMD_15B8_RCC_DEV2_EPF0_STRAP2_NO_SOFT_RESET_DEV2_F0_MASK;
+		if (amd_smn_write(0, AMD_15B8_RCC_DEV2_EPF0_STRAP2, data))
+			pci_err(dev, "Failed to write data 0x%x\n", data);
+	} else {
+		pci_err(dev, "Failed to read data\n");
+	}
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15b8, quirk_clear_strap_no_soft_reset_dev2_f0);
+#endif
-- 
2.25.1


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

* Re: [PATCH] PCI: Add quirk to clear AMD strap_15B8 NO_SOFT_RESET dev2 f0
  2023-03-29 17:28 [PATCH] PCI: Add quirk to clear AMD strap_15B8 NO_SOFT_RESET dev2 f0 Basavaraj Natikar
@ 2023-03-29 18:56 ` Limonciello, Mario
  2023-03-29 19:39   ` Thomas Glanzmann
  2023-04-06 21:30 ` Bjorn Helgaas
  1 sibling, 1 reply; 5+ messages in thread
From: Limonciello, Mario @ 2023-03-29 18:56 UTC (permalink / raw)
  To: Basavaraj Natikar, bhelgaas, tglx, mingo, bp, dave.hansen, hpa,
	x86, linux-pci
  Cc: thomas, Ghannam, Yazen

+Yazen

On 3/29/2023 12:28, Basavaraj Natikar wrote:
> The AMD [1022:15b8] USB controller loses some internal functional
> MSI-X context when transitioning from D0 to D3hot. BIOS normally
> traps D0->D3hot and D3hot->D0 transitions so it can save and restore
> that internal context, but some firmware in the field lacks due to
> AMD_15B8_RCC_DEV2_EPF0_STRAP2 NO_SOFT_RESET bit is set.
> 
> Hence add quirk to clear AMD_15B8_RCC_DEV2_EPF0_STRAP2 NO_SOFT_RESET
> bit before USB controller initialization during boot.
> 
> Reported-by: Thomas Glanzmann <thomas@glanzmann.de>

Thomas Glanzmann,

Can you please test this on your side?

Explicitly test it with amdgpu blacklisted or iGPU disabled in BIOS 
setup so that we can confirm that it is working and the amdgpu version 
of it isn't being used.

Thanks,

> Link: https://lore.kernel.org/linux-usb/Y%2Fz9GdHjPyF2rNG3@glanzmann.de/T/#u
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   arch/x86/pci/fixup.c | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
> 
> diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
> index 615a76d70019..bf5161dcf89e 100644
> --- a/arch/x86/pci/fixup.c
> +++ b/arch/x86/pci/fixup.c
> @@ -7,6 +7,7 @@
>   #include <linux/dmi.h>
>   #include <linux/pci.h>
>   #include <linux/vgaarb.h>
> +#include <asm/amd_nb.h>
>   #include <asm/hpet.h>
>   #include <asm/pci_x86.h>
>   
> @@ -824,3 +825,23 @@ static void rs690_fix_64bit_dma(struct pci_dev *pdev)
>   DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7910, rs690_fix_64bit_dma);
>   
>   #endif
> +
> +#ifdef CONFIG_AMD_NB
> +
> +#define AMD_15B8_RCC_DEV2_EPF0_STRAP2                                  0x10136008
> +#define AMD_15B8_RCC_DEV2_EPF0_STRAP2_NO_SOFT_RESET_DEV2_F0_MASK       0x00000080L
> +
> +static void quirk_clear_strap_no_soft_reset_dev2_f0(struct pci_dev *dev)
> +{
> +	u32 data;
> +
> +	if (!amd_smn_read(0, AMD_15B8_RCC_DEV2_EPF0_STRAP2, &data)) {
> +		data &= ~AMD_15B8_RCC_DEV2_EPF0_STRAP2_NO_SOFT_RESET_DEV2_F0_MASK;
> +		if (amd_smn_write(0, AMD_15B8_RCC_DEV2_EPF0_STRAP2, data))
> +			pci_err(dev, "Failed to write data 0x%x\n", data);
> +	} else {
> +		pci_err(dev, "Failed to read data\n");
> +	}
> +}
> +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15b8, quirk_clear_strap_no_soft_reset_dev2_f0);
> +#endif


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

* Re: [PATCH] PCI: Add quirk to clear AMD strap_15B8 NO_SOFT_RESET dev2 f0
  2023-03-29 18:56 ` Limonciello, Mario
@ 2023-03-29 19:39   ` Thomas Glanzmann
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Glanzmann @ 2023-03-29 19:39 UTC (permalink / raw)
  To: Limonciello, Mario
  Cc: Basavaraj Natikar, bhelgaas, tglx, mingo, bp, dave.hansen, hpa,
	x86, linux-pci, Ghannam, Yazen

Hello Mario,

* Limonciello, Mario <mario.limonciello@amd.com> [2023-03-29 20:56]:
> Can you please test this on your side?

> Explicitly test it with amdgpu blacklisted or iGPU disabled in BIOS setup so
> that we can confirm that it is working and the amdgpu version of it isn't
> being used.

I tested the same on top of v6.2.8 with amdgpu blacklisted. It works

Tested-by: Thomas Glanzmann <thomas@glanzmann.de>

Find here some additional information:

https://tg.st/u/dabb0ed77c14a8ec6e76d85f9f936977dca04c899d1773603c58350c9ce31768.txt

I tested by replugging mouse and keyboard in opposite ports which did
not work before.

Cheers,
        Thomas

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

* Re: [PATCH] PCI: Add quirk to clear AMD strap_15B8 NO_SOFT_RESET dev2 f0
  2023-03-29 17:28 [PATCH] PCI: Add quirk to clear AMD strap_15B8 NO_SOFT_RESET dev2 f0 Basavaraj Natikar
  2023-03-29 18:56 ` Limonciello, Mario
@ 2023-04-06 21:30 ` Bjorn Helgaas
  2023-04-07  4:09   ` Basavaraj Natikar
  1 sibling, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2023-04-06 21:30 UTC (permalink / raw)
  To: Basavaraj Natikar
  Cc: bhelgaas, tglx, mingo, bp, dave.hansen, hpa, x86, linux-pci,
	mario.limonciello, thomas

On Wed, Mar 29, 2023 at 10:58:59PM +0530, Basavaraj Natikar wrote:
> The AMD [1022:15b8] USB controller loses some internal functional
> MSI-X context when transitioning from D0 to D3hot. BIOS normally
> traps D0->D3hot and D3hot->D0 transitions so it can save and restore
> that internal context,

> but some firmware in the field lacks due to
> AMD_15B8_RCC_DEV2_EPF0_STRAP2 NO_SOFT_RESET bit is set.

This part doesn't have quite enough words in it.  Does the following
sound right?

  ... but some firmware in the field can't do this because it fails to
  clear the AMD_15B8_RCC_DEV2_EPF0_STRAP2 NO_SOFT_RESET bit.

If not, let me know and I can update it.

> Hence add quirk to clear AMD_15B8_RCC_DEV2_EPF0_STRAP2 NO_SOFT_RESET
> bit before USB controller initialization during boot.
> 
> Reported-by: Thomas Glanzmann <thomas@glanzmann.de>
> Link: https://lore.kernel.org/linux-usb/Y%2Fz9GdHjPyF2rNG3@glanzmann.de/T/#u
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>

Applied to for-linus for v6.3, thank you for all your work on this!

I updated the subject to:

  x86/PCI: Add quirk for AMD XHCI controller that loses MSI-X state in D3hot

so it has a little bit of context.

I also added a stable tag since I assume the same problem will occur
on older kernels.  Let me know if that's not appropriate.

Bjorn

> ---
>  arch/x86/pci/fixup.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
> index 615a76d70019..bf5161dcf89e 100644
> --- a/arch/x86/pci/fixup.c
> +++ b/arch/x86/pci/fixup.c
> @@ -7,6 +7,7 @@
>  #include <linux/dmi.h>
>  #include <linux/pci.h>
>  #include <linux/vgaarb.h>
> +#include <asm/amd_nb.h>
>  #include <asm/hpet.h>
>  #include <asm/pci_x86.h>
>  
> @@ -824,3 +825,23 @@ static void rs690_fix_64bit_dma(struct pci_dev *pdev)
>  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7910, rs690_fix_64bit_dma);
>  
>  #endif
> +
> +#ifdef CONFIG_AMD_NB
> +
> +#define AMD_15B8_RCC_DEV2_EPF0_STRAP2                                  0x10136008
> +#define AMD_15B8_RCC_DEV2_EPF0_STRAP2_NO_SOFT_RESET_DEV2_F0_MASK       0x00000080L
> +
> +static void quirk_clear_strap_no_soft_reset_dev2_f0(struct pci_dev *dev)
> +{
> +	u32 data;
> +
> +	if (!amd_smn_read(0, AMD_15B8_RCC_DEV2_EPF0_STRAP2, &data)) {
> +		data &= ~AMD_15B8_RCC_DEV2_EPF0_STRAP2_NO_SOFT_RESET_DEV2_F0_MASK;
> +		if (amd_smn_write(0, AMD_15B8_RCC_DEV2_EPF0_STRAP2, data))
> +			pci_err(dev, "Failed to write data 0x%x\n", data);
> +	} else {
> +		pci_err(dev, "Failed to read data\n");
> +	}
> +}
> +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15b8, quirk_clear_strap_no_soft_reset_dev2_f0);
> +#endif
> -- 
> 2.25.1
> 

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

* Re: [PATCH] PCI: Add quirk to clear AMD strap_15B8 NO_SOFT_RESET dev2 f0
  2023-04-06 21:30 ` Bjorn Helgaas
@ 2023-04-07  4:09   ` Basavaraj Natikar
  0 siblings, 0 replies; 5+ messages in thread
From: Basavaraj Natikar @ 2023-04-07  4:09 UTC (permalink / raw)
  To: Bjorn Helgaas, Basavaraj Natikar
  Cc: bhelgaas, tglx, mingo, bp, dave.hansen, hpa, x86, linux-pci,
	mario.limonciello, thomas


On 4/7/2023 3:00 AM, Bjorn Helgaas wrote:
> On Wed, Mar 29, 2023 at 10:58:59PM +0530, Basavaraj Natikar wrote:
>> The AMD [1022:15b8] USB controller loses some internal functional
>> MSI-X context when transitioning from D0 to D3hot. BIOS normally
>> traps D0->D3hot and D3hot->D0 transitions so it can save and restore
>> that internal context,
>> but some firmware in the field lacks due to
>> AMD_15B8_RCC_DEV2_EPF0_STRAP2 NO_SOFT_RESET bit is set.
> This part doesn't have quite enough words in it.  Does the following
> sound right?
>
>   ... but some firmware in the field can't do this because it fails to
>   clear the AMD_15B8_RCC_DEV2_EPF0_STRAP2 NO_SOFT_RESET bit.
>
> If not, let me know and I can update it.

Thank You for updating. Looks good to me

>
>> Hence add quirk to clear AMD_15B8_RCC_DEV2_EPF0_STRAP2 NO_SOFT_RESET
>> bit before USB controller initialization during boot.
>>
>> Reported-by: Thomas Glanzmann <thomas@glanzmann.de>
>> Link: https://lore.kernel.org/linux-usb/Y%2Fz9GdHjPyF2rNG3@glanzmann.de/T/#u
>> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
>> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> Applied to for-linus for v6.3, thank you for all your work on this!
>
> I updated the subject to:
>
>   x86/PCI: Add quirk for AMD XHCI controller that loses MSI-X state in D3hot
>
> so it has a little bit of context.
>
> I also added a stable tag since I assume the same problem will occur
> on older kernels.  Let me know if that's not appropriate.

Looks great. Thanks a lot Bjron for updating subject and adding to stable tag.

>
> Bjorn
>
>> ---
>>  arch/x86/pci/fixup.c | 21 +++++++++++++++++++++
>>  1 file changed, 21 insertions(+)
>>
>> diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
>> index 615a76d70019..bf5161dcf89e 100644
>> --- a/arch/x86/pci/fixup.c
>> +++ b/arch/x86/pci/fixup.c
>> @@ -7,6 +7,7 @@
>>  #include <linux/dmi.h>
>>  #include <linux/pci.h>
>>  #include <linux/vgaarb.h>
>> +#include <asm/amd_nb.h>
>>  #include <asm/hpet.h>
>>  #include <asm/pci_x86.h>
>>  
>> @@ -824,3 +825,23 @@ static void rs690_fix_64bit_dma(struct pci_dev *pdev)
>>  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7910, rs690_fix_64bit_dma);
>>  
>>  #endif
>> +
>> +#ifdef CONFIG_AMD_NB
>> +
>> +#define AMD_15B8_RCC_DEV2_EPF0_STRAP2                                  0x10136008
>> +#define AMD_15B8_RCC_DEV2_EPF0_STRAP2_NO_SOFT_RESET_DEV2_F0_MASK       0x00000080L
>> +
>> +static void quirk_clear_strap_no_soft_reset_dev2_f0(struct pci_dev *dev)
>> +{
>> +	u32 data;
>> +
>> +	if (!amd_smn_read(0, AMD_15B8_RCC_DEV2_EPF0_STRAP2, &data)) {
>> +		data &= ~AMD_15B8_RCC_DEV2_EPF0_STRAP2_NO_SOFT_RESET_DEV2_F0_MASK;
>> +		if (amd_smn_write(0, AMD_15B8_RCC_DEV2_EPF0_STRAP2, data))
>> +			pci_err(dev, "Failed to write data 0x%x\n", data);
>> +	} else {
>> +		pci_err(dev, "Failed to read data\n");
>> +	}
>> +}
>> +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15b8, quirk_clear_strap_no_soft_reset_dev2_f0);
>> +#endif
>> -- 
>> 2.25.1
>>


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

end of thread, other threads:[~2023-04-07  4:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 17:28 [PATCH] PCI: Add quirk to clear AMD strap_15B8 NO_SOFT_RESET dev2 f0 Basavaraj Natikar
2023-03-29 18:56 ` Limonciello, Mario
2023-03-29 19:39   ` Thomas Glanzmann
2023-04-06 21:30 ` Bjorn Helgaas
2023-04-07  4:09   ` Basavaraj Natikar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.