Skip to content

usb: dwc2: masquerade split-interrupt transfers #6936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: rpi-6.12.y
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions drivers/usb/dwc2/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,18 @@ static void dwc2_hc_init(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan)
hcchar |= HCCHAR_EPDIR;
if (chan->speed == USB_SPEED_LOW)
hcchar |= HCCHAR_LSPDDEV;

/*
* Masquerading Interrupt split transfers as Control puts the transfer
* into the non-periodic handler in the hub. This stops the hub
* dropping complete-split data in the microframe after a CSPLIT
* should have arrived, improving resilience to host IRQ latency.
* Devices are none the wiser - the handshake tokens are the same.
* The fakery is undone in dwc2_hc_n_intr().
*/
if (chan->do_split && chan->ep_type == USB_ENDPOINT_XFER_INT)
chan->ep_type = USB_ENDPOINT_XFER_CONTROL;

hcchar |= chan->ep_type << HCCHAR_EPTYPE_SHIFT & HCCHAR_EPTYPE_MASK;
hcchar |= chan->max_packet << HCCHAR_MPS_SHIFT & HCCHAR_MPS_MASK;
dwc2_writel(hsotg, hcchar, HCCHAR(hc_num));
Expand Down Expand Up @@ -2338,6 +2350,7 @@ static void dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg,
else
chan->xfer_buf = urb->setup_packet;
chan->xfer_len = 8;
chan->max_packet = 8;
break;

case DWC2_CONTROL_DATA:
Expand Down
3 changes: 3 additions & 0 deletions drivers/usb/dwc2/hcd_intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,9 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum)

chan->hcint = hcintraw;

/* Un-masquerade the transfer type */
if (chan->do_split)
chan->ep_type = chan->qh->ep_type;
/*
* If the channel was halted due to a dequeue, the qtd list might
* be empty or at least the first entry will not be the active qtd.
Expand Down