On Thu, Aug 15, 2024 at 10:03:12PM -0400, Bryan Steele wrote:
> On Thu, Aug 15, 2024 at 11:17:06AM -0600, Mark Kettenis wrote:
> > CVSROOT:    /cvs
> > Module name:        src
> > Changes by: kette...@cvs.openbsd.org        2024/08/15 11:17:06
> > 
> > Modified files:
> >     sys/dev/usb    : xhci.c xhcivar.h 
> > 
> > Log message:
> > Upon resume, restore the saved state.  Newer Intel xHCI controller (e.g.
> > those on Meteor Lake) need this, otherwise the ports are dead after
> > resume.
> > 
> > ok mglocker@, deraadt@
> 
> This seems to break USB (e.g: webcam) on resume for my old AMD laptop:
> 
> xhci0 at pci2 dev 0 function 3 "AMD 17h/1xh xHCI" rev 0x00: msix, xHCI
> 1.10
> ...
> ugen0 detached
> uhub0 detached
> video0 detached
> uvideo0 detached
> uhub1 detached
> uhub0 at usb0 configuration 1 interface 0 "AMD xHCI root hub" rev
> 3.00/1.00 addr 1
> uhub1 at usb1 configuration 1 interface 0 "AMD xHCI root hub" rev
> 3.00/1.00 addr 1
> dwiic1: timed out waiting for stop intr
> uhub0: device problem, disabling port 2
> uhub1: device problem, disabling port 1
> wakeups: 0 1
> wakeup event: unknown
> 
> Reverting this change fixes it.

an issue with that specific generation

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a7d57abcc8a5bdeb53bbf8e87558e8e0a2c2a29d

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 04:49:05 -0000
@@ -463,7 +463,7 @@ xhci_config(struct xhci_softc *sc)
         * it here.  Otherwise some Intel controllers don't function
         * correctly after resume.
         */
-       if (sc->sc_saved_state) {
+       if (sc->sc_saved_state && (sc->sc_flags & XHCI_BROKEN_SUSPEND) == 0) {
                XOWRITE4(sc, XHCI_USBCMD, XHCI_CMD_CRS); /* Restore state */
                hcr = XOREAD4(sc, XHCI_USBSTS);
                for (i = 0; i < 100; i++) {
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 04:30:04 -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_BROKEN_SUSPEND     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 04:54:52 -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_BROKEN_SUSPEND;
                break;
        }
 

Reply via email to