linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC
@ 2020-10-23 12:27 Sandeep Singh
  2020-10-23 12:33 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Sandeep Singh @ 2020-10-23 12:27 UTC (permalink / raw)
  To: mathias.nyman, gregkh, linux-usb, linux-kernel, sanket.goswami,
	Nehal-bakulchandra.Shah
  Cc: Shyam-sundar.S-k, Sandeep Singh, Sanket Goswami

From: Sandeep Singh <sandeep.singh@amd.com>

On some platform of AMD, S3 fails with HCE and SRE errors. To fix this,
need to disable a bit which is enable in sparse controller.

Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Sandeep Singh <sandeep.singh@amd.com>
---
 drivers/usb/host/xhci-pci.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index c26c06e5c88c..bf89172c43ca 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -23,6 +23,8 @@
 #define SSIC_PORT_CFG2_OFFSET	0x30
 #define PROG_DONE		(1 << 30)
 #define SSIC_PORT_UNUSED	(1 << 31)
+#define SPARSE_DISABLE_BIT	17
+#define SPARSE_CNTL_ENABLE	0xC12C
 
 /* Device for a quirk */
 #define PCI_VENDOR_ID_FRESCO_LOGIC	0x1b73
@@ -161,6 +163,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 	    (pdev->device == 0x15e0 || pdev->device == 0x15e1))
 		xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND;
 
+	if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x15e5)
+		xhci->quirks |= XHCI_DISABLE_SPARSE;
+
 	if (pdev->vendor == PCI_VENDOR_ID_AMD)
 		xhci->quirks |= XHCI_TRUST_TX_LENGTH;
 
@@ -498,6 +503,15 @@ static void xhci_pme_quirk(struct usb_hcd *hcd)
 	readl(reg);
 }
 
+static void xhci_sparse_control_quirk(struct usb_hcd *hcd)
+{
+	u32 reg;
+
+	reg = readl(hcd->regs + SPARSE_CNTL_ENABLE);
+	reg &= ~BIT(SPARSE_DISABLE_BIT);
+	writel(reg, hcd->regs + SPARSE_CNTL_ENABLE);
+}
+
 static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
 {
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
@@ -517,6 +531,9 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
 	if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
 		xhci_ssic_port_unused_quirk(hcd, true);
 
+	if (xhci->quirks & XHCI_DISABLE_SPARSE)
+		xhci_sparse_control_quirk(hcd);
+
 	ret = xhci_suspend(xhci, do_wakeup);
 	if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED))
 		xhci_ssic_port_unused_quirk(hcd, false);
-- 
2.25.1


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

* Re: [PATCH] usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC
  2020-10-23 12:27 [PATCH] usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC Sandeep Singh
@ 2020-10-23 12:33 ` Greg KH
  2020-10-23 12:40   ` Singh, Sandeep
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2020-10-23 12:33 UTC (permalink / raw)
  To: Sandeep Singh
  Cc: mathias.nyman, linux-usb, linux-kernel, sanket.goswami,
	Nehal-bakulchandra.Shah, Shyam-sundar.S-k

On Fri, Oct 23, 2020 at 05:57:13PM +0530, Sandeep Singh wrote:
> From: Sandeep Singh <sandeep.singh@amd.com>
> 
> On some platform of AMD, S3 fails with HCE and SRE errors. To fix this,
> need to disable a bit which is enable in sparse controller.
> 
> Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
> Signed-off-by: Sandeep Singh <sandeep.singh@amd.com>
> ---
>  drivers/usb/host/xhci-pci.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> index c26c06e5c88c..bf89172c43ca 100644
> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -23,6 +23,8 @@
>  #define SSIC_PORT_CFG2_OFFSET	0x30
>  #define PROG_DONE		(1 << 30)
>  #define SSIC_PORT_UNUSED	(1 << 31)
> +#define SPARSE_DISABLE_BIT	17
> +#define SPARSE_CNTL_ENABLE	0xC12C
>  
>  /* Device for a quirk */
>  #define PCI_VENDOR_ID_FRESCO_LOGIC	0x1b73
> @@ -161,6 +163,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
>  	    (pdev->device == 0x15e0 || pdev->device == 0x15e1))
>  		xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND;
>  
> +	if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x15e5)
> +		xhci->quirks |= XHCI_DISABLE_SPARSE;
> +
>  	if (pdev->vendor == PCI_VENDOR_ID_AMD)
>  		xhci->quirks |= XHCI_TRUST_TX_LENGTH;
>  
> @@ -498,6 +503,15 @@ static void xhci_pme_quirk(struct usb_hcd *hcd)
>  	readl(reg);
>  }
>  
> +static void xhci_sparse_control_quirk(struct usb_hcd *hcd)
> +{
> +	u32 reg;
> +
> +	reg = readl(hcd->regs + SPARSE_CNTL_ENABLE);
> +	reg &= ~BIT(SPARSE_DISABLE_BIT);
> +	writel(reg, hcd->regs + SPARSE_CNTL_ENABLE);
> +}
> +
>  static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
>  {
>  	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
> @@ -517,6 +531,9 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
>  	if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
>  		xhci_ssic_port_unused_quirk(hcd, true);
>  
> +	if (xhci->quirks & XHCI_DISABLE_SPARSE)
> +		xhci_sparse_control_quirk(hcd);
> +
>  	ret = xhci_suspend(xhci, do_wakeup);
>  	if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED))
>  		xhci_ssic_port_unused_quirk(hcd, false);
> -- 
> 2.25.1
> 

Does this build?  There is no XHCI_DISABLE_SPARSE in the kernel tree at
the moment...

greg k-h

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

* Re: [PATCH] usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC
  2020-10-23 12:33 ` Greg KH
@ 2020-10-23 12:40   ` Singh, Sandeep
  0 siblings, 0 replies; 3+ messages in thread
From: Singh, Sandeep @ 2020-10-23 12:40 UTC (permalink / raw)
  To: Greg KH, Sandeep Singh
  Cc: mathias.nyman, linux-usb, linux-kernel, sanket.goswami,
	Nehal-bakulchandra.Shah, Shyam-sundar.S-k

Hi Greg,

On 10/23/2020 6:03 PM, Greg KH wrote:
> [CAUTION: External Email]
>
> On Fri, Oct 23, 2020 at 05:57:13PM +0530, Sandeep Singh wrote:
>> From: Sandeep Singh <sandeep.singh@amd.com>
>>
>> On some platform of AMD, S3 fails with HCE and SRE errors. To fix this,
>> need to disable a bit which is enable in sparse controller.
>>
>> Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
>> Signed-off-by: Sandeep Singh <sandeep.singh@amd.com>
>> ---
>>   drivers/usb/host/xhci-pci.c | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
>> index c26c06e5c88c..bf89172c43ca 100644
>> --- a/drivers/usb/host/xhci-pci.c
>> +++ b/drivers/usb/host/xhci-pci.c
>> @@ -23,6 +23,8 @@
>>   #define SSIC_PORT_CFG2_OFFSET        0x30
>>   #define PROG_DONE            (1 << 30)
>>   #define SSIC_PORT_UNUSED     (1 << 31)
>> +#define SPARSE_DISABLE_BIT   17
>> +#define SPARSE_CNTL_ENABLE   0xC12C
>>
>>   /* Device for a quirk */
>>   #define PCI_VENDOR_ID_FRESCO_LOGIC   0x1b73
>> @@ -161,6 +163,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
>>            (pdev->device == 0x15e0 || pdev->device == 0x15e1))
>>                xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND;
>>
>> +     if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x15e5)
>> +             xhci->quirks |= XHCI_DISABLE_SPARSE;
>> +
>>        if (pdev->vendor == PCI_VENDOR_ID_AMD)
>>                xhci->quirks |= XHCI_TRUST_TX_LENGTH;
>>
>> @@ -498,6 +503,15 @@ static void xhci_pme_quirk(struct usb_hcd *hcd)
>>        readl(reg);
>>   }
>>
>> +static void xhci_sparse_control_quirk(struct usb_hcd *hcd)
>> +{
>> +     u32 reg;
>> +
>> +     reg = readl(hcd->regs + SPARSE_CNTL_ENABLE);
>> +     reg &= ~BIT(SPARSE_DISABLE_BIT);
>> +     writel(reg, hcd->regs + SPARSE_CNTL_ENABLE);
>> +}
>> +
>>   static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
>>   {
>>        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
>> @@ -517,6 +531,9 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
>>        if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
>>                xhci_ssic_port_unused_quirk(hcd, true);
>>
>> +     if (xhci->quirks & XHCI_DISABLE_SPARSE)
>> +             xhci_sparse_control_quirk(hcd);
>> +
>>        ret = xhci_suspend(xhci, do_wakeup);
>>        if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED))
>>                xhci_ssic_port_unused_quirk(hcd, false);
>> --
>> 2.25.1
>>
> Does this build?  There is no XHCI_DISABLE_SPARSE in the kernel tree at
> the moment...

  Sorry i missed adding xhci.h in this patch i will be sending v2 patch.

> greg k-h

Thanks

Sandeep


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

end of thread, other threads:[~2020-10-23 12:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23 12:27 [PATCH] usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC Sandeep Singh
2020-10-23 12:33 ` Greg KH
2020-10-23 12:40   ` Singh, Sandeep

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).