Skip to content

Commit 86dcbbd

Browse files
P33Mpopcornmix
authored andcommitted
drivers: usb: xhci: set HID bit in streaming endpoint contexts
The xHC may commence Host Initiated Data Moves for streaming endpoints - see USB3.2 spec s8.12.1.4.2.4. However, this behaviour is typically counterproductive as the submission of UAS URBs in {Status, Data, Command} order and 1 outstanding IO per stream ID means the device never enters Move Data after a HIMD for Status or Data stages with the same stream ID. For OUT transfers this is especially inefficient as the host will start transmitting multiple bulk packets as a burst, all of which get NAKed by the device - wasting bandwidth. Also, some buggy UAS adapters don't properly handle the EP flow control state this creates - e.g. RTL9210. Set Host Initiated Data Move Disable to always defer stream selection to the device. xHC implementations may treat this field as "don't care, forced to 1" anyway - xHCI 1.2 s4.12.1. Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
1 parent 87cfb00 commit 86dcbbd

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/usb/host/xhci-mem.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,14 @@ void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci,
744744
ep_ctx->ep_info &= cpu_to_le32(~EP_MAXPSTREAMS_MASK);
745745
ep_ctx->ep_info |= cpu_to_le32(EP_MAXPSTREAMS(max_primary_streams)
746746
| EP_HAS_LSA);
747+
748+
/*
749+
* Set Host Initiated Data Move Disable to always defer stream
750+
* selection to the device. xHC implementations may treat this
751+
* field as "don't care, forced to 1" anyway - xHCI 1.2 s4.12.1.
752+
*/
753+
ep_ctx->ep_info2 |= EP_HID;
754+
747755
ep_ctx->deq = cpu_to_le64(stream_info->ctx_array_dma);
748756
}
749757

drivers/usb/host/xhci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ struct xhci_ep_ctx {
465465
#define CTX_TO_EP_MAXPSTREAMS(p) (((p) & EP_MAXPSTREAMS_MASK) >> 10)
466466
/* Endpoint is set up with a Linear Stream Array (vs. Secondary Stream Array) */
467467
#define EP_HAS_LSA BIT(15)
468+
/* Host initiated data move disable in info2 */
469+
#define EP_HID BIT(7)
468470
/* hosts with LEC=1 use bits 31:24 as ESIT high bits. */
469471
#define CTX_TO_MAX_ESIT_PAYLOAD_HI(p) (((p) >> 24) & 0xff)
470472

0 commit comments

Comments
 (0)