On 2026/09/23 21:18, Atanas Vladimirov wrote:
> On 2026-09-08 16:41, Atanas Vladimirov wrote:
> > On 2026-08-23 21:44, Atanas Vladimirov wrote:
> > > > Synopsis:       USB keyboard dies after Supermicro BMC reset; xhci(4)
> > > > endpoint halted
> > > > Category:       kernel
> > > > Environment:
> > >   System      : OpenBSD 8.0
> > >   Details     : OpenBSD 8.0-beta (GENERIC.MP) #108: Sat Aug 22
> > > 22:10:43 MDT 2026
> > >                   
> > > [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> > > 
> > >   Architecture: OpenBSD.amd64
> > >   Machine     : amd64
> > > > Description:
> > >   On a Supermicro X11SSL-F the USB keyboard and mouse emulated by
> > >   the on-board ASPEED AST2400 BMC stop responding after the BMC is
> > >   reset, and stay dead until the host is rebooted.  wskbd(4) and
> > >   wsmouse(4) receive no further events.  A GENERIC kernel prints
> > >   nothing at all when this happens.
> > > 
> > >   The same behaviour is present on every release tried, 7.4 through
> > >   -current, and on a Supermicro X10SLL-F as well.  A physical USB
> > >   keyboard on the same xhci0 keeps working; only the BMC-emulated
> > >   HID is affected.
> > > 
> > >   The controller is:
> > > 
> > >           xhci0 at pci0 dev 20 function 0 "Intel 100 Series xHCI"
> > >               rev 0x31: msi, xHCI 1.0
> > > 
> > >   and the emulated HID normally attaches behind the BMC's own hub:
> > > 
> > >           uhub1 at uhub0 port 9 "ATEN International product 0x7000"
> > >           uhidev2 at uhub1 port 1 "ATEN International product 0x2419"
> > >           ukbd1 at uhidev2, wskbd2 at ukbd1
> > >           uhidev3 at uhub1 port 1, ums1 at uhidev3
> > > 
> > >   With a kernel built with "option XHCI_DEBUG" the only diagnostic
> > >   is the HID's interrupt IN endpoint completing with a USB
> > >   Transaction Error:
> > > 
> > >           xhci0: txerr? code 4
> > > 
> > >   Per xHCI r1.1 section 4.10.2.6 a USB Transaction Error completion
> > >   leaves the endpoint in the Halted state.  The endpoint context
> > >   stays Halted in hardware until a Reset Endpoint command is
> > >   issued: further doorbell rings are ignored and no transfer event
> > >   is ever posted again.
> > > 
> > >   xhci_event_xfer_generic() in sys/dev/usb/xhci.c never issues that
> > >   command.  At $OpenBSD: xhci.c,v 1.136 2025/03/01 14:43:03 kirill
> > >   Exp $:
> > > 
> > >           case XHCI_CODE_TXERR:
> > >           case XHCI_CODE_SPLITERR:
> > >                   DPRINTF(("%s: txerr? code %d\n", DEVNAME(sc), code));
> > >                   xfer->status = USBD_IOERROR;
> > >                   break;
> > > 
> > >   After the switch the function only does "return (0)", so the
> > >   caller xhci_event_xfer() goes on to call xhci_xfer_done(xfer) and
> > >   usb_transfer_complete().  The transfer is completed with
> > >   USBD_IOERROR, but no Reset Endpoint command is sent and
> > >   xp->halted is never set.  From that point the pipe is dead: the
> > >   stack keeps queueing transfers onto an endpoint the controller
> > >   will not run, and each one is dropped with no indication.
> > > 
> > >   One further observation, which is why resetting the endpoint
> > >   alone is not sufficient on this hardware: after the BMC reset the
> > >   device does not come back in the same topology.  Instead of the
> > >   low-speed HID behind the ATEN hub it attaches directly to uhub0
> > >   at high speed, and that transient device's interrupt IN endpoint
> > >   keeps failing for several seconds.  With a change that only
> > >   resets the endpoint, the softintr path never converges:
> > > 
> > >           xhci0: txerr? code 4
> > >           xhci0: xhci_cmd_reset_ep_async dev 4 dci 3
> > >           xhci0: xhci_cmd_set_tr_deq_async dev 4 dci 3
> > >           ... forever ...
> > > 
> > >   Only tearing the port down and re-enumerating it recovers the
> > >   device.
> > > > How-To-Repeat:
> > >   1. Boot an amd64 GENERIC.MP snapshot on a Supermicro X11SSL-F
> > >      (or X10SLL-F) with the BMC iKVM keyboard and mouse enabled.
> > >            (I beleive that other Supermicro models are affected as
> > > well)
> > >   2. Confirm the emulated HID attached, and that ukbd(4)/wskbd(4)
> > >      and ums(4)/wsmouse(4) claimed it:
> > > 
> > >           # usbdevs -v
> > > 
> > >   3. Type on the iKVM keyboard at the console.  Keystrokes arrive.
> > >   4. Reset the BMC - use the Reset button in the BMC web interface.
> > >   5. Wait for the BMC to come back and for the HID to re-attach.
> > >   6. Type on the iKVM keyboard again.  No keystrokes arrive, the
> > >      emulated mouse is dead as well, and nothing is printed on the
> > >      console.
> > >   7. Reboot the host.  The keyboard works again.  A BMC-emulated
> > >      device cannot be unplugged, so this is the only recovery.
> > >   8. To see the completion code, rebuild the kernel with
> > >      "option XHCI_DEBUG" and repeat steps 3 to 6.  The endpoint
> > >      reports "xhci0: txerr? code 4" and no transfer on that pipe
> > >      ever completes afterwards.
> > > > Fix:
> > >   The diff below counts consecutive USB Transaction Errors per pipe
> > >   and lets the TXERR/SPLITERR case fall through into the existing
> > >   STALL/BABBLE recovery, so the halted endpoint is always reset.
> > >   Past XHCI_TXERR_RETRIES it additionally calls
> > >   usb_needs_reattach(), so the hub explore task re-enumerates the
> > >   device instead of the pipe retrying forever.  Because
> > >   code != XHCI_CODE_STALL on the fallthrough it lands on
> > >   xp->halted = USBD_IOERROR, and it inherits the timeout_del(),
> > >   usb_rem_task(), xp->aborted_xfer assignment and the completion
> > >   chain unchanged.
> > > 
> > 
> > Hello,
> > 
> > Any thoughts/comments?
> > Or this is not something that worth fixing?
> > Please note that the proposed fix is just that, a proposal, nothing
> > more.
> > There could be something that I miss ....
> > 
> > Best wishes,
> > Atanas
> 
> I'm starting to think that I did something wrong with this bug report.
> No one is saying anything - even "This is all bullshit" would be much better
> :)

It's not bullshit, I have seen it on a whole bunch of machines on
Supermicro X10 platform after BMC firmware update, but there's so
much crappy USB hardware about it's hard to know if a change to fix
one is going to result in problems elsewhere. Only people seeing the
problematic behaviour really have an incentive to test though.

Nothing was printed before (unless XHCI_DEBUG) so it's possible
there are devices that were hitting tx errors but working again after
some more attempts and we wouldn't know it; in that situation they'd
likely get reattached with this change which could be worse.

This does feel like something that could be tried in snaps, then
committed if no major fallout, probably at some point early in the
release cycle (i.e. after we're done with 8.0). It would be good to
have a few test reports from various other hardware first though.

> Index: sys/dev/usb/xhci.c
> ===================================================================
> --- sys/dev/usb/xhci.c
> +++ sys/dev/usb/xhci.c
> @@ -70,6 +70,7 @@ struct xhci_pipe {
>       struct usbd_xfer        *pending_xfers[XHCI_MAX_XFER];
>       struct usbd_xfer        *aborted_xfer;
>       int                      halted;
> +     u_int                    txerr_count;
>       size_t                   free_trbs;
>       int                      skip;
>  #define TRB_PROCESSED_NO     0
> @@ -78,6 +79,8 @@ struct xhci_pipe {
>       uint8_t                  trb_processed[XHCI_MAX_XFER];
>  };
>  
> +#define XHCI_TXERR_RETRIES   3
> +
>  int  xhci_reset(struct xhci_softc *);
>  void xhci_suspend(struct xhci_softc *);
>  int  xhci_intr1(struct xhci_softc *);
> @@ -953,6 +956,7 @@ xhci_event_xfer_generic(struct xhci_softc *sc, struct 
> usbd_xfer *xfer,
>                           usbd_xfer_isread(xfer) ?
>                           BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
>               xfer->status = USBD_NORMAL_COMPLETION;
> +             xp->txerr_count = 0;
>               break;
>       case XHCI_CODE_SHORT_XFER:
>               /*
> @@ -977,12 +981,22 @@ xhci_event_xfer_generic(struct xhci_softc *sc, struct 
> usbd_xfer *xfer,
>                           usbd_xfer_isread(xfer) ?
>                           BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
>               xfer->status = USBD_NORMAL_COMPLETION;
> +             xp->txerr_count = 0;
>               break;
>       case XHCI_CODE_TXERR:
>       case XHCI_CODE_SPLITERR:
>               DPRINTF(("%s: txerr? code %d\n", DEVNAME(sc), code));

maybe print "txerr? code X retry X" with xp->txerr_count here?

> -             xfer->status = USBD_IOERROR;
> -             break;
> +             /*
> +              * A USB Transaction Error leaves the endpoint Halted
> +              * (xHCI r1.1 4.10.2.6), so reset it like a STALL to
> +              * let the stack restart the pipe on a clean endpoint.
> +              * If the endpoint keeps failing, additionally ask the
> +              * hub to re-enumerate the device instead of retrying
> +              * forever.
> +              */
> +             if (++xp->txerr_count > XHCI_TXERR_RETRIES)
> +                     usb_needs_reattach(xfer->device);

maybe a DPRINTF here too?

> +             /* FALLTHROUGH */
>       case XHCI_CODE_STALL:
>       case XHCI_CODE_BABBLE:
>               DPRINTF(("%s: babble code %d\n", DEVNAME(sc), code));
> @@ -1623,6 +1637,7 @@ xhci_pipe_init(struct xhci_softc *sc, struct usbd_pipe 
> *pipe)
>  
>       xp->free_trbs = xp->ring.ntrb;
>       xp->halted = 0;
> +     xp->txerr_count = 0;
>  
>       sdev->pipes[xp->dci - 1] = xp;

Reply via email to