"Theo de Raadt" <dera...@openbsd.org> writes:

>
> Index: sys/dev/pci/azalia.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/azalia.c,v
> diff -u -p -u -r1.287 azalia.c
> --- sys/dev/pci/azalia.c      17 May 2024 19:43:45 -0000      1.287
> +++ sys/dev/pci/azalia.c      8 Aug 2024 02:39:31 -0000
> @@ -1388,6 +1388,11 @@ azalia_suspend(azalia_t *az)
>       if (az->detached)
>               return 0;
>  
> +     /* stop interrupts and clear status registers */
> +     AZ_WRITE_4(az, INTCTL, 0);
> +     AZ_WRITE_2(az, STATESTS, HDA_STATESTS_SDIWAKE);
> +     AZ_WRITE_1(az, RIRBSTS, HDA_RIRBSTS_RINTFL | HDA_RIRBSTS_RIRBOIS);
> +
>       /* disable unsolicited responses */
>       AZ_WRITE_4(az, GCTL, AZ_READ_4(az, GCTL) & ~HDA_GCTL_UNSOL);

This seems to be working as intended. The interrupt complaints is gone.

I don't know if the rest of them are doing anything on my machine. I'm
still seeing the same symptoms and despite not running X, the second
zzz turns off the display and leaves the USB devices active. So I can
blind-type and reboot. Here's the updated dmesg tail:

acpi0: S3 unavailable, using S0
uhub0 detached
uhub1 detached
uhub2 detached
wskbd1: disconnecting from wsdisplay0
wskbd1 detached
ukbd0 detached
uhidev0 detached
wsmouse0 detached
ums0 detached
uhidev1 detached
wsmouse1 detached
ums1 detached
uhidev2 detached
fido0 detached
uhidev3 detached
uhid0 detached
uhidev4 detached
uhub4 detached
uhub3 detached
xhci3: save state timeout
suspend
resume 1
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
[drm] *ERROR* IB test failed on gfx_low (-60).
[drm] *ERROR* IB test failed on gfx_high (-60).
[drm] *ERROR* ib ring test failed (-60).
uhub2 at usb2 configuration 1 interface 0 "AMD xHCI root hub" rev 3.00/1.00 
addr 1
uhub3 at usb3 configuration 1 interface 0 "AMD xHCI root hub" rev 3.00/1.00 
addr 1
wakeup event: PWRBTN
uhub4 at uhub3 port 1 configuration 1 interface 0 "Texas Instruments product 
0x8442" rev 2.10/1.00 addr 2
uhidev0 at uhub4 port 1 configuration 1 interface 0 "P.I. Engineering PC 
Keyboard/Mouse to USB  Adapter" rev 1.10/3.10 addr 3
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 variable keys, 6 key codes
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0
uhidev1 at uhub4 port 1 configuration 1 interface 1 "P.I. Engineering PC 
Keyboard/Mouse to USB  Adapter" rev 1.10/3.10 addr 3
uhidev1: iclass 3/1
ums0 at uhidev1: 5 buttons, Z dir
wsmouse0 at ums0 mux 0
uhidev2 at uhub4 port 2 configuration 1 interface 0 "Microsoft Microsoft 
3-Button Mouse with IntelliEye(TM)" rev 1.10/3.00 addr 4
uhidev2: iclass 3/1
ums1 at uhidev2: 3 buttons, Z dir
wsmouse1 at ums1 mux 0
uhidev3 at uhub4 port 3 configuration 1 interface 0 "Yubico Yubico Gnubby 
(gnubby1)" rev 2.00/0.97 addr 5
uhidev3: iclass 3/0
fido0 at uhidev3: input=64, output=64, feature=0
uhidev4 at uhub4 port 5 configuration 1 interface 0 "Texas Instruments product 
0x82ff" rev 2.01/1.00 addr 6
uhidev4: iclass 3/0
uhid0 at uhidev4: input=255, output=255, feature=2
acpi0: S3 unavailable, using S0
uhub0 detached
uhub1 detached


>  
>
>
>
> Index: sys/dev/usb/usb.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/usb.c,v
> diff -u -p -u -r1.131 usb.c
> --- sys/dev/usb/usb.c 23 May 2024 03:21:09 -0000      1.131
> +++ sys/dev/usb/usb.c 8 Aug 2024 15:32:07 -0000
> @@ -901,13 +901,8 @@ usb_activate(struct device *self, int ac
>               break;
>       case DVACT_RESUME:
>               sc->sc_bus->dying = 0;
> -
> -             /*
> -              * Make sure the root hub is present before interrupts
> -              * get enabled.   As long as the bus is in polling mode
> -              * it is safe to call usbd_new_device() now since root
> -              * hub transfers do not need to sleep.
> -              */
> +             break;
> +     case DVACT_WAKEUP:
>               sc->sc_bus->use_polling++;
>               if (!usb_attach_roothub(sc))
>                       usb_needs_explore(sc->sc_bus->root_hub, 0);
>
>
>
> X-KPN-MessageId: 8f165ddd-5809-11ef-af74-005056994fde
> X-KPN-MID: 33|tJiC8tbSC7xTI514+UUM00suxOjbJDJU4KsuswXkL7dXpf25iA6Tey0p+AXeq6F
>  0pIkGD/LbynfQ9IcjQlHzaC+zoj25tUPOBQwRTzF6KhE=
> X-KPN-VerifiedSender: Yes
> X-CMASSUN: 33|x5a2Ur9I6Gm/bdbVhEWE9fFnBX86yObAIZ321Fg8oiENiL3NWGlhl365G5RlcX3
>  j5DhJbwqAlwG64TnGWVBb5g==
> Date: Sun, 11 Aug 2024 19:45:56 +0200
> From: Mark Kettenis <mark.kette...@xs4all.nl>
> To: hack...@openbsd.org
> Subject: xhci(4): restore saved state
> Sender: owner-hack...@openbsd.org
>
> So it turns out that the Meteor Lake xHCI controllers are unhappy if
> we don't restore the saved state.  To make sure we don't try to
> restore state that we haven't saved, set a variable in the softc when
> we successfully saved the state and only attempt to restore when that
> variable has been set.
>
> ok?
>
>
> Index: dev/usb/xhci.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/xhci.c,v
> diff -u -p -r1.132 xhci.c
> --- dev/usb/xhci.c    6 Aug 2024 17:30:04 -0000       1.132
> +++ dev/usb/xhci.c    11 Aug 2024 17:37:32 -0000
> @@ -415,6 +415,7 @@ xhci_config(struct xhci_softc *sc)
>  {
>       uint64_t paddr;
>       uint32_t hcr;
> +     int i;
>  
>       /* Make sure to program a number of device slots we can handle. */
>       if (sc->sc_noslot > USB_MAX_DEVICES)
> @@ -457,6 +458,22 @@ xhci_config(struct xhci_softc *sc)
>       DPRINTF(("%s: ERDP=%#x%#x\n", DEVNAME(sc),
>           XRREAD4(sc, XHCI_ERDP_HI(0)), XRREAD4(sc, XHCI_ERDP_LO(0))));
>  
> +     if (sc->sc_saved_state) {
> +             XOWRITE4(sc, XHCI_USBCMD, XHCI_CMD_CRS); /* Restore state */
> +             hcr = XOREAD4(sc, XHCI_USBSTS);
> +             for (i = 0; i < 100; i++) {
> +                     usb_delay_ms(&sc->sc_bus, 1);
> +                     hcr = XOREAD4(sc, XHCI_USBSTS) & XHCI_STS_RSS;
> +                     if (!hcr)
> +                             break;
> +             }
> +
> +             if (hcr)
> +                     printf("%s: restore state timeout\n", DEVNAME(sc));
> +
> +             sc->sc_saved_state = 0;
> +     }
> +
>       /* Enable interrupts. */
>       hcr = XRREAD4(sc, XHCI_IMAN(0));
>       XRWRITE4(sc, XHCI_IMAN(0), hcr | XHCI_IMAN_INTR_ENA);
> @@ -623,6 +640,8 @@ xhci_suspend(struct xhci_softc *sc)
>               xhci_reset(sc);
>               return;
>       }
> +
> +     sc->sc_saved_state = 1;
>  
>       /* Disable interrupts. */
>       XRWRITE4(sc, XHCI_IMOD(0), 0);
> Index: dev/usb/xhcivar.h
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/xhcivar.h,v
> diff -u -p -r1.14 xhcivar.h
> --- dev/usb/xhcivar.h 12 Dec 2022 19:18:25 -0000      1.14
> +++ dev/usb/xhcivar.h 11 Aug 2024 17:37:32 -0000
> @@ -89,6 +89,7 @@ struct xhci_softc {
>       bus_size_t               sc_size;
>  
>       int                      sc_dead;
> +     int                      sc_saved_state;
>  
>       bus_size_t               sc_oper_off;   /* Operational Register space */
>       bus_size_t               sc_runt_off;   /* Runtime */

Reply via email to