Skip to content

Commit 5329a41

Browse files
P33Mpelwell
authored andcommitted
usb: dwc2: masquerade split-interrupt transfers
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. Originally devised by Hans Petter Selasky @ FreeBSD. (v2: dwc2 needs an un-masquerade prior to channel interrupt handling) Signed-off-by: Jonathan Bell <[email protected]>
1 parent 720694e commit 5329a41

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/usb/dwc2/hcd.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,18 @@ static void dwc2_hc_init(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan)
676676
hcchar |= HCCHAR_EPDIR;
677677
if (chan->speed == USB_SPEED_LOW)
678678
hcchar |= HCCHAR_LSPDDEV;
679+
680+
/*
681+
* Masquerading Interrupt split transfers as Control puts the transfer
682+
* into the non-periodic handler in the hub. This stops the hub
683+
* dropping complete-split data in the microframe after a CSPLIT
684+
* should have arrived, improving resilience to host IRQ latency.
685+
* Devices are none the wiser - the handshake tokens are the same.
686+
* The fakery is undone in dwc2_hc_n_intr().
687+
*/
688+
if (chan->do_split && chan->ep_type == USB_ENDPOINT_XFER_INT)
689+
chan->ep_type = USB_ENDPOINT_XFER_CONTROL;
690+
679691
hcchar |= chan->ep_type << HCCHAR_EPTYPE_SHIFT & HCCHAR_EPTYPE_MASK;
680692
hcchar |= chan->max_packet << HCCHAR_MPS_SHIFT & HCCHAR_MPS_MASK;
681693
dwc2_writel(hsotg, hcchar, HCCHAR(hc_num));

drivers/usb/dwc2/hcd_intr.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,6 +2048,9 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum)
20482048

20492049
chan->hcint = hcintraw;
20502050

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

0 commit comments

Comments
 (0)