On Fri, Aug 16, 2024 at 11:59:08AM +0200, Mark Kettenis wrote:
> > Date: Fri, 16 Aug 2024 15:21:17 +1000
> > From: Jonathan Gray <j...@jsg.id.au>
> > 
> > On Thu, Aug 15, 2024 at 11:04:32PM -0600, Theo de Raadt wrote:
> > > I'm no sure we should call it "BROKEN SUSPEND".
> > > It suspends, in our way.  It just has a bug in CRS for RESUME.
> > > 
> > > So maybe BROKEN_CRS?
> > 
> > NOCRS?
> 
> I wonder if we should also skip saving the state in that case.  The
> Linux code also has seem workarounds for that.  In that case the name
> of the flag should probably be XHCI_NOCSS.

we can also skip restore by not setting sc_saved_state

Index: sys/dev/usb/xhci.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/xhci.c,v
diff -u -p -r1.133 xhci.c
--- sys/dev/usb/xhci.c  15 Aug 2024 17:17:05 -0000      1.133
+++ sys/dev/usb/xhci.c  16 Aug 2024 10:53:27 -0000
@@ -620,6 +620,8 @@ xhci_suspend(struct xhci_softc *sc)
                return;
        }
 
+       if (sc->sc_flags & XHCI_NOCCS)
+               goto noccs;
        /*
         * Some Intel controllers will not power down completely
         * unless they have seen a save state command.  This in turn
@@ -643,6 +645,7 @@ xhci_suspend(struct xhci_softc *sc)
        }
 
        sc->sc_saved_state = 1;
+noccs:
 
        /* Disable interrupts. */
        XRWRITE4(sc, XHCI_IMOD(0), 0);
Index: sys/dev/usb/xhcivar.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/xhcivar.h,v
diff -u -p -r1.15 xhcivar.h
--- sys/dev/usb/xhcivar.h       15 Aug 2024 17:17:05 -0000      1.15
+++ sys/dev/usb/xhcivar.h       16 Aug 2024 10:52:11 -0000
@@ -121,6 +121,9 @@ struct xhci_softc {
 
        char                     sc_vendor[16]; /* Vendor string for root hub */
        int                      sc_id_vendor;  /* Vendor ID for root hub */
+       
+       int                      sc_flags;
+#define XHCI_NOCCS              0x01
 };
 
 int    xhci_init(struct xhci_softc *);
Index: sys/dev/pci/xhci_pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/xhci_pci.c,v
diff -u -p -r1.13 xhci_pci.c
--- sys/dev/pci/xhci_pci.c      24 May 2024 06:02:58 -0000      1.13
+++ sys/dev/pci/xhci_pci.c      16 Aug 2024 10:53:39 -0000
@@ -150,6 +164,11 @@ xhci_pci_attach(struct device *parent, s
                 if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_FRESCO_FL1000 ||
                     PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_FRESCO_FL1400)
                        pa->pa_flags &= ~PCI_FLAGS_MSI_ENABLED;
+               break;
+       case PCI_VENDOR_AMD:
+               if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_17_1X_XHCI_1 ||
+                   PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_17_1X_XHCI_2)
+                       psc->sc.sc_flags |= XHCI_NOCCS;
                break;
        }
 

Reply via email to