tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Support for USBD_FORCE_SHORT_XFER for xhci



On Sun, Aug 31, 2025 at 10:42 AM sc dying <sc.dying%gmail.com@localhost> wrote:
> If an error occurs on sending zero-length packet, or transfer is
> stopped on ZLP, normal transfer and ZLP generates transfer event each.
> xhci_event_transfer() would call usb_transfer_complete for same xfer,
> actually, second event will be ignored since first event dequeues
> xfer->ux_pipe->up_queue and event handler simply quits if pipe
> is empty.

Event handler should skip first normal transfer event and
wait for second ZLP event, however, struct TRB has no flags
to deal with it.

I try to add TRB flags field to struct xhci_ring like
xr_cookies array. When xhci_ring_put puts TRBs on ring, mark the
last one as LAST.  [xhci-zlp.patch.2]
This is maybe safe, but possibly racy. When transfer is stopped,
all TRBs are cleared, however, Transfer Event caused by Stop Endpoint
command is generated prior to Stop Endpoint command Completion Event.
Event hadler can peek at originaing TRB before TRBs are cleared.

I thought another patch checking Transfer Length == 0 instead of
trbflags, but it would introduce possible bugs. It works only when
a transfer consists of normal transfer and zero-length tranxfer.
This might be racy, too.  [xhci-zlp.patch.1]

Attachment: xhci-zlp.patch.2
Description: Binary data

Attachment: xhci-zlp.patch.1
Description: Binary data



Home | Main Index | Thread Index | Old Index