Skip to content

Commit b37d83a

Browse files
matnymangregkh
authored andcommitted
usb: Parse the new USB 3.1 SuperSpeedPlus Isoc endpoint companion descriptor
USB 3.1 devices can return a new SuperSpeedPlus isoc endpoint companion descriptor for a isochronous endpoint that requires more than 48K bytes per Service Interval. The new descriptor immediately follows the old USB 3.0 SuperSpeed Endpoint Companion and will provide a new BytesPerInterval value. It is parsed and stored in struct usb_host_endpoint with the other endpoint related descriptors, and should be used by USB3.1 capable hosts to reserve bus time in the schedule. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c8b1d89 commit b37d83a

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎drivers/usb/core/config.c‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ static int find_next_descriptor(unsigned char *buffer, int size,
4343
return buffer - buffer0;
4444
}
4545

46+
static void usb_parse_ssp_isoc_endpoint_companion(struct device *ddev,
47+
int cfgno, int inum, int asnum, struct usb_host_endpoint *ep,
48+
unsigned char *buffer, int size)
49+
{
50+
struct usb_ssp_isoc_ep_comp_descriptor *desc;
51+
52+
/*
53+
* The SuperSpeedPlus Isoc endpoint companion descriptor immediately
54+
* follows the SuperSpeed Endpoint Companion descriptor
55+
*/
56+
desc = (struct usb_ssp_isoc_ep_comp_descriptor *) buffer;
57+
if (desc->bDescriptorType != USB_DT_SSP_ISOC_ENDPOINT_COMP ||
58+
size < USB_DT_SSP_ISOC_EP_COMP_SIZE) {
59+
dev_warn(ddev, "Invalid SuperSpeedPlus isoc endpoint companion"
60+
"for config %d interface %d altsetting %d ep %d.\n",
61+
cfgno, inum, asnum, ep->desc.bEndpointAddress);
62+
return;
63+
}
64+
memcpy(&ep->ssp_isoc_ep_comp, desc, USB_DT_SSP_ISOC_EP_COMP_SIZE);
65+
}
66+
4667
static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
4768
int inum, int asnum, struct usb_host_endpoint *ep,
4869
unsigned char *buffer, int size)
@@ -54,6 +75,9 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
5475
* be the first thing immediately following the endpoint descriptor.
5576
*/
5677
desc = (struct usb_ss_ep_comp_descriptor *) buffer;
78+
buffer += desc->bLength;
79+
size -= desc->bLength;
80+
5781
if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP ||
5882
size < USB_DT_SS_EP_COMP_SIZE) {
5983
dev_warn(ddev, "No SuperSpeed endpoint companion for config %d "
@@ -112,6 +136,7 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
112136
cfgno, inum, asnum, ep->desc.bEndpointAddress);
113137
ep->ss_ep_comp.bmAttributes = 16;
114138
} else if (usb_endpoint_xfer_isoc(&ep->desc) &&
139+
!USB_SS_SSP_ISOC_COMP(desc->bmAttributes) &&
115140
USB_SS_MULT(desc->bmAttributes) > 3) {
116141
dev_warn(ddev, "Isoc endpoint has Mult of %d in "
117142
"config %d interface %d altsetting %d ep %d: "
@@ -121,6 +146,12 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
121146
ep->ss_ep_comp.bmAttributes = 2;
122147
}
123148

149+
/* Parse a possible SuperSpeedPlus isoc ep companion descriptor */
150+
if (usb_endpoint_xfer_isoc(&ep->desc) &&
151+
USB_SS_SSP_ISOC_COMP(desc->bmAttributes))
152+
usb_parse_ssp_isoc_endpoint_companion(ddev, cfgno, inum, asnum,
153+
ep, buffer, size);
154+
124155
if (usb_endpoint_xfer_isoc(&ep->desc))
125156
max_tx = (desc->bMaxBurst + 1) *
126157
(USB_SS_MULT(desc->bmAttributes)) *

‎include/linux/usb.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct ep_device;
5050
* struct usb_host_endpoint - host-side endpoint descriptor and queue
5151
* @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder
5252
* @ss_ep_comp: SuperSpeed companion descriptor for this endpoint
53+
* @ssp_isoc_ep_comp: SuperSpeedPlus isoc companion descriptor for this endpoint
5354
* @urb_list: urbs queued to this endpoint; maintained by usbcore
5455
* @hcpriv: for use by HCD; typically holds hardware dma queue head (QH)
5556
* with one or more transfer descriptors (TDs) per urb
@@ -65,6 +66,7 @@ struct ep_device;
6566
struct usb_host_endpoint {
6667
struct usb_endpoint_descriptor desc;
6768
struct usb_ss_ep_comp_descriptor ss_ep_comp;
69+
struct usb_ssp_isoc_ep_comp_descriptor ssp_isoc_ep_comp;
6870
struct list_head urb_list;
6971
void *hcpriv;
7072
struct ep_device *ep_dev; /* For sysfs info */

0 commit comments

Comments
 (0)