Skip to content

Commit 2a63281

Browse files
Sandeep Singhgregkh
authored andcommitted
usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC
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. Cc: stable@vger.kernel.org #v4.19+ Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com> Signed-off-by: Sandeep Singh <sandeep.singh@amd.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20201028203124.375344-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a75e2d6 commit 2a63281

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

drivers/usb/host/xhci-pci.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#define SSIC_PORT_CFG2_OFFSET 0x30
2424
#define PROG_DONE (1 << 30)
2525
#define SSIC_PORT_UNUSED (1 << 31)
26+
#define SPARSE_DISABLE_BIT 17
27+
#define SPARSE_CNTL_ENABLE 0xC12C
2628

2729
/* Device for a quirk */
2830
#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
@@ -161,6 +163,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
161163
(pdev->device == 0x15e0 || pdev->device == 0x15e1))
162164
xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND;
163165

166+
if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x15e5)
167+
xhci->quirks |= XHCI_DISABLE_SPARSE;
168+
164169
if (pdev->vendor == PCI_VENDOR_ID_AMD)
165170
xhci->quirks |= XHCI_TRUST_TX_LENGTH;
166171

@@ -498,6 +503,15 @@ static void xhci_pme_quirk(struct usb_hcd *hcd)
498503
readl(reg);
499504
}
500505

506+
static void xhci_sparse_control_quirk(struct usb_hcd *hcd)
507+
{
508+
u32 reg;
509+
510+
reg = readl(hcd->regs + SPARSE_CNTL_ENABLE);
511+
reg &= ~BIT(SPARSE_DISABLE_BIT);
512+
writel(reg, hcd->regs + SPARSE_CNTL_ENABLE);
513+
}
514+
501515
static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
502516
{
503517
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
@@ -517,6 +531,9 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
517531
if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
518532
xhci_ssic_port_unused_quirk(hcd, true);
519533

534+
if (xhci->quirks & XHCI_DISABLE_SPARSE)
535+
xhci_sparse_control_quirk(hcd);
536+
520537
ret = xhci_suspend(xhci, do_wakeup);
521538
if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED))
522539
xhci_ssic_port_unused_quirk(hcd, false);

drivers/usb/host/xhci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,7 @@ struct xhci_hcd {
18771877
#define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35)
18781878
#define XHCI_RENESAS_FW_QUIRK BIT_ULL(36)
18791879
#define XHCI_SKIP_PHY_INIT BIT_ULL(37)
1880+
#define XHCI_DISABLE_SPARSE BIT_ULL(38)
18801881

18811882
unsigned int num_active_eps;
18821883
unsigned int limit_active_eps;

0 commit comments

Comments
 (0)