Re: [PATCH v3 1/3] usb: dwc2: gadget: restart descriptor DMA isochronous OUT endpoints after BNA

From: Vadim Yuzifovich

Date: Sat Dec 05 2026 - 08:02:59 EST


On Tue, Dec 01, 2026 at 03:04:39PM +0000, sashiko-bot@xxxxxxxxxx wrote:
> - [High] usb: dwc2: premature DAINTMSK unmasking in
> dwc2_gadget_restart_isoc_out_ddma()
> - [Medium] usb: dwc2: synchronous request completion inside
> dwc2_hsotg_ep_queue()

Both are right, and they have the same cause: the restart of a stopped
endpoint ran from dwc2_hsotg_ep_queue(). In v4 the queue call only
unmasks the endpoint. The core raises BNA again for the packet it
holds, or OUTTKNEPDIS for the next OUT token when it holds none, and
that handler restarts the endpoint in interrupt context. So no request
completes inside usb_ep_queue(), and the endpoint is never unmasked
while a giveback has the lock dropped outside the interrupt handler.

> - [High] usb: dwc2: infinite completion loop on stale DMADONE
> descriptors after BNA

Also right. It needs the BNA without the XferCompl of the descriptor
before it, since XferCompl is handled first and refills the slot, which
is why it never showed on the board. v4 marks a descriptor host busy
again when its request is given back, so the loop stops at the first
descriptor the core has not written since.

> - [Medium] usb: dwc2: race with dwc2_hsotg_ep_disable() when dropping
> lock on BNA giveback

Right as well. v4 has dwc2_hsotg_ep_disable() and
dwc2_hsotg_disconnect() bump a count in the endpoint, and every path
that dropped the lock for a giveback checks it afterwards and stops if
the endpoint was disabled meanwhile. A USBACTEP check, which I had
first, would miss an endpoint disabled and enabled again while the lock
was dropped.

On the SG2002, with a UAC1 stream from the host and a test hook that
holds back the function's requests: 100 rounds of starving the
endpoint, with 250 stops and 250 restarts, all from the interrupt
handler, and 200 interrupt holds of 3 to 40 ms with 304 restarts.
Capture went on after each, with no interrupt storm and no port reset.

Testing v4 also showed that an endpoint stopped with nothing queued
kept the held packet, and the packets that followed, at the head of
the shared Rx FIFO, so EP0 and bulk OUT stalled until a request came.
v4 NAKs the stopped endpoint and drops what it holds into a scratch
buffer, also when the endpoint is disabled. The details are in the v4
cover letter:

https://lore.kernel.org/r/20261205130225.341741-1-vadim@xxxxxxx

Vadim