Skip to contentSkip to conversation

USB: Enable eUSB2 double isochronous bandwidth

PATCH In review Mathias Nyman 3 participants 9 messages Jun 16, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover USB: Enable eUSB2 double isochronous bandwidth

This series enables support for eUSB2 Double Isochronous IN Bandwidth uvc devices specified in 'USB 2.0 Double Isochronous IN Bandwidth' ECN.

In short it adds support for new integrated USB2 webcams that can send twice the data compared to conventional USB2 webcams.

These devices are identified by the device descriptor bcdUSB 0x0220 value. They have an additional eUSB2 Isochronous Endpoint Companion Descriptor, and a zero max packet size in regular isoc endpoint descriptor. Support for parsing that new descriptor was added in commit

c749f058b437 ("USB: core: Add eUSB2 descriptor and parsing in USB core")

This series adds support to uvc, usb core, and xhci to identify eUSB2 double isoc devices, and allow and set proper max packet, iso frame desc sizes, bytes per interval, and other values in URBs and xHCI endpoint contexts needed to support the double data rates for eUSB2 double isoc devices.

Patch 1/3 containing the xhci changes was previously sent as part of other xhci features, but was dropped.
It now contains the USB_SPEED_HIGH check disussed with Thinh Nguyen.

Thanks
Mathias

Amardeep Rai (2):
xhci: Add host support for eUSB2 double isochronous bandwidth devices
USB: core: support eUSB2 double bandwidth large isoc URB frames

Tao Q Tao (1):
media: uvcvideo: eUSB2 double isochronous bandwidth support

 drivers/media/usb/uvc/uvc_video.c |  5 +++
 drivers/usb/core/urb.c            | 18 +++++++--
 drivers/usb/host/xhci-caps.h      |  2 +
 drivers/usb/host/xhci-mem.c       | 62 ++++++++++++++++++++++++-------
 drivers/usb/host/xhci-ring.c      |  6 +--
 drivers/usb/host/xhci.c           | 16 +++++++-
 drivers/usb/host/xhci.h           | 20 ++++++++++
 7 files changed, 108 insertions(+), 21 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 xhci: Add host support for eUSB2 double isochronous bandwidth devices

From: Amardeep Rai <[email protected]>

Detect eUSB2 double isoc bw capable hosts and devices, and set the proper xhci endpoint context values such as 'Mult', 'Max Burst Size', and 'Max ESIT Payload' to enable the double isochronous bandwidth endpoints.

Intel xHC uses the endpoint context 'Mult' field for eUSB2 isoc endpoints even if hosts supporting Large ESIT Payload Capability should normally ignore the mult field.

---
 drivers/usb/host/xhci-caps.h |  2 ++
 drivers/usb/host/xhci-mem.c  | 62 ++++++++++++++++++++++++++++--------
 drivers/usb/host/xhci-ring.c |  6 ++--
 drivers/usb/host/xhci.c      | 16 +++++++++-
 drivers/usb/host/xhci.h      | 20 ++++++++++++
 5 files changed, 89 insertions(+), 17 deletions(-)
drivers/usb/host/xhci-caps.h +2 -0
index 4b8ff4815644..723a56052439 100644
@@ -89,3 +89,5 @@
 #define HCC2_GSC(p)             ((p) & (1 << 8))
 /* true: HC support Virtualization Based Trusted I/O Capability */
 #define HCC2_VTC(p)             ((p) & (1 << 9))
+/* true: HC support Double BW on a eUSB2 HS ISOC EP */
+#define HCC2_EUSB2_DIC(p)	((p) & (1 << 11))
drivers/usb/host/xhci-mem.c +49 -13

104 lines not on this page · raw message

drivers/usb/host/xhci-ring.c +3 -3
index e038ad3375dc..2f59e7a91dda 100644
@@ -3543,7 +3543,7 @@ static u32 xhci_td_remainder(struct xhci_hcd *xhci, int transferred,
 	if ((xhci->quirks & XHCI_MTK_HOST) && (xhci->hci_version < 0x100))
 		trb_buff_len = 0;
 
-	maxp = usb_endpoint_maxp(&urb->ep->desc);
+	maxp = xhci_usb_endpoint_maxp(urb->dev, urb->ep);
 	total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
 	/* Queueing functions don't count the current TRB into transferred */
@@ -3560,7 +3560,7 @@ static int xhci_align_td(struct xhci_hcd *xhci, struct urb *urb, u32 enqd_len,
 	u32 new_buff_len;
 	size_t len;
 
-	max_pkt = usb_endpoint_maxp(&urb->ep->desc);
+	max_pkt = xhci_usb_endpoint_maxp(urb->dev, urb->ep);
 	unalign = (enqd_len + *trb_buff_len) % max_pkt;
 
 	/* we got lucky, last normal TRB data on segment is packet aligned */
@@ -4131,7 +4131,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
 		addr = start_addr + urb->iso_frame_desc[i].offset;
 		td_len = urb->iso_frame_desc[i].length;
 		td_remain_len = td_len;
-		max_pkt = usb_endpoint_maxp(&urb->ep->desc);
+		max_pkt = xhci_usb_endpoint_maxp(urb->dev, urb->ep);
 		total_pkt_count = DIV_ROUND_UP(td_len, max_pkt);
 
 		/* A zero-length transfer still involves at least one packet. */
drivers/usb/host/xhci.c +15 -1
index 4e6dbd2375c3..c65e0e1fefcf 100644
@@ -1353,7 +1353,7 @@ static bool xhci_urb_temp_buffer_required(struct usb_hcd *hcd,
 	struct scatterlist *tail_sg;
 
 	tail_sg = urb->sg;
-	max_pkt = usb_endpoint_maxp(&urb->ep->desc);
+	max_pkt = xhci_usb_endpoint_maxp(urb->dev, urb->ep);
 
 	if (!urb->num_sgs)
 		return ret;
@@ -2941,6 +2941,20 @@ int xhci_stop_endpoint_sync(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, int
 }
 EXPORT_SYMBOL_GPL(xhci_stop_endpoint_sync);
 
+/*
+ * xhci_usb_endpoint_maxp - get endpoint max packet size
+ * @host_ep: USB host endpoint to be checked
+ *
+ * Returns max packet from the correct descriptor
+ */
+int xhci_usb_endpoint_maxp(struct usb_device *udev,
+			   struct usb_host_endpoint *host_ep)
+{
+	if (xhci_eusb2_is_isoc_bw_double(udev, host_ep))
+		return le16_to_cpu(host_ep->eusb2_isoc_ep_comp.wMaxPacketSize);
+	return usb_endpoint_maxp(&host_ep->desc);
+}
+
 /* Issue a configure endpoint command or evaluate context command
  * and wait for it to finish.
  */
drivers/usb/host/xhci.h +20 -0
index 49887a303e43..21cf1eacfc92 100644
@@ -1735,6 +1735,24 @@ static inline bool xhci_has_one_roothub(struct xhci_hcd *xhci)
 	       (!xhci->usb2_rhub.num_ports || !xhci->usb3_rhub.num_ports);
 }
 
+/*
+ * USB 2.0 specification, chapter 5.6.4 Isochronous Transfer Bus Access
+ * Constraint. A high speed endpoint can move up to 3072 bytes per microframe
+ * (or 192Mb/s).
+ */
+#define MAX_ISOC_XFER_SIZE_HS  3072
+
+static inline bool xhci_eusb2_is_isoc_bw_double(struct usb_device *udev,
+						struct usb_host_endpoint *ep)
+{
+	return le16_to_cpu(udev->descriptor.bcdUSB) == 0x220 &&
+		udev->speed == USB_SPEED_HIGH &&
+		usb_endpoint_xfer_isoc(&ep->desc) &&
+		le16_to_cpu(ep->desc.wMaxPacketSize) == 0 &&
+		le32_to_cpu(ep->eusb2_isoc_ep_comp.dwBytesPerInterval) >
+		MAX_ISOC_XFER_SIZE_HS;
+}
+
 #define xhci_dbg(xhci, fmt, args...) \
 	dev_dbg(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
 #define xhci_err(xhci, fmt, args...) \
@@ -1958,6 +1976,8 @@ void xhci_update_erst_dequeue(struct xhci_hcd *xhci,
 			      struct xhci_interrupter *ir,
 			      bool clear_ehb);
 void xhci_add_interrupter(struct xhci_hcd *xhci, unsigned int intr_num);
+int xhci_usb_endpoint_maxp(struct usb_device *udev,
+			   struct usb_host_endpoint *host_ep);
 
 /* xHCI roothub code */
 void xhci_set_link_state(struct xhci_hcd *xhci, struct xhci_port *port,
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 USB: core: support eUSB2 double bandwidth large isoc URB frames

In reply to Mathias Nyman

From: Amardeep Rai <[email protected]>

eUSB2 double isochronous in bandwidth devices support up to 6 transactions per microframe, and thus doubles the total bytes possible to receive per microframe.

Support larger URB isoc frame sizes for eUSB2 double isoc in endpoints.

---
 drivers/usb/core/urb.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/usb/core/urb.c +14 -4
index 5e52a35486af..911091b92fd7 100644
@@ -372,6 +372,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
 	struct usb_host_endpoint	*ep;
 	int				is_out;
 	unsigned int			allowed;
+	bool				is_eusb2_isoch_double;
 
 	if (!urb || !urb->complete)
 		return -EINVAL;
@@ -434,7 +435,12 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
 		return -ENODEV;
 
 	max = usb_endpoint_maxp(&ep->desc);
-	if (max <= 0) {
+	is_eusb2_isoch_double = dev->speed == USB_SPEED_HIGH &&
+				xfertype == USB_ENDPOINT_XFER_ISOC &&
+				usb_endpoint_dir_in(&ep->desc) &&
+				le16_to_cpu(dev->descriptor.bcdUSB == 0x220) &&
+				le16_to_cpu(ep->desc.wMaxPacketSize == 0);
+	if (max < 0 || (max == 0 && !is_eusb2_isoch_double)) {
 		dev_dbg(&dev->dev,
 			"bogus endpoint ep%d%s in %s (bad maxpacket %d)\n",
 			usb_endpoint_num(&ep->desc), is_out ? "out" : "in",
@@ -467,9 +473,13 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
 			max = le32_to_cpu(isoc_ep_comp->dwBytesPerInterval);
 		}
 
-		/* "high bandwidth" mode, 1-3 packets/uframe? */
-		if (dev->speed == USB_SPEED_HIGH)
-			max *= usb_endpoint_maxp_mult(&ep->desc);
+		/* High speed, 1-3 packets/uframe, max 6 for eUSB2 double bw */
+		if (dev->speed == USB_SPEED_HIGH) {
+			if (is_eusb2_isoch_double)
+				max = le32_to_cpu(ep->eusb2_isoc_ep_comp.dwBytesPerInterval);
+			else
+				max *= usb_endpoint_maxp_mult(&ep->desc);
+		}
 
 		if (urb->number_of_packets <= 0)
 			return -EINVAL;
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH 2/3] USB: core: support eUSB2 double bandwidth large isoc URB frames

Quoted 28 lines · Mathias Nyman

From: Amardeep Rai <[email protected]>

eUSB2 double isochronous in bandwidth devices support up to 6 transactions per microframe, and thus doubles the total bytes possible to receive per microframe.

Support larger URB isoc frame sizes for eUSB2 double isoc in endpoints.

---
 drivers/usb/core/urb.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/usb/core/urb.c +1 -0
index 5e52a35486af..911091b92fd7 100644
@@ -372,6 +372,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
 	struct usb_host_endpoint	*ep;
 	int				is_out;
 	unsigned int			allowed;
+	bool				is_eusb2_isoch_double;
 
 	if (!urb || !urb->complete)
 		return -EINVAL;

drivers/usb/core/urb.c int usb_submit_urb(struct urb *urb, gfp_t mem_flags) · line 443

Quoted 10 lines
drivers/usb/core/urb.c +6 -1
@@ -434,7 +435,12 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
 		return -ENODEV;
 
 	max = usb_endpoint_maxp(&ep->desc);
-	if (max <= 0) {
+	is_eusb2_isoch_double = dev->speed == USB_SPEED_HIGH &&
+				xfertype == USB_ENDPOINT_XFER_ISOC &&
+				usb_endpoint_dir_in(&ep->desc) &&
+				le16_to_cpu(dev->descriptor.bcdUSB == 0x220) &&
+				le16_to_cpu(ep->desc.wMaxPacketSize == 0);
+	if (max < 0 || (max == 0 && !is_eusb2_isoch_double)) {

Minor point: It's impossible to have max < 0 here, because usb_endpoint_maxp() always returns a non-negative value (the return value is &'ed with 0x07ff). That part of the test can be removed.

Alan Stern

#4 lore raw

Re: [PATCH 2/3] USB: core: support eUSB2 double bandwidth large isoc URB frames

Quoted 17 lines

drivers/usb/core/urb.c int usb_submit_urb(struct urb *urb, gfp_t mem_flags) · line 443

Quoted 12 lines
drivers/usb/core/urb.c +6 -1
@@ -434,7 +435,12 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
  		return -ENODEV;
 
  	max = usb_endpoint_maxp(&ep->desc);
-	if (max <= 0) {
+	is_eusb2_isoch_double = dev->speed == USB_SPEED_HIGH &&
+				xfertype == USB_ENDPOINT_XFER_ISOC &&
+				usb_endpoint_dir_in(&ep->desc) &&
+				le16_to_cpu(dev->descriptor.bcdUSB == 0x220) &&
+				le16_to_cpu(ep->desc.wMaxPacketSize == 0);
+	if (max < 0 || (max == 0 && !is_eusb2_isoch_double)) {

Minor point: It's impossible to have max < 0 here, because usb_endpoint_maxp() always returns a non-negative value (the return value is &'ed with 0x07ff). That part of the test can be removed.

Quoted 2 lines

Alan Stern

Thanks, will fix this for v2
-Mathias

#5 lore raw

PATCH 3/3 media: uvcvideo: eUSB2 double isochronous bandwidth support

In reply to Mathias Nyman

From: Tao Q Tao <[email protected]>

Add eUSB2 support to check total number of bytes, isochronous endpoint will transfer every service interval(SI).

---
 drivers/media/usb/uvc/uvc_video.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/media/usb/uvc/uvc_video.c +5 -0
index e3567aeb0007..a888f84208c6 100644
@@ -1906,6 +1906,11 @@ u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep)
 	case USB_SPEED_SUPER:
 	case USB_SPEED_SUPER_PLUS:
 		return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
+	case USB_SPEED_HIGH:
+		psize = usb_endpoint_maxp(&ep->desc);
+		if (psize == 0 && le16_to_cpu(dev->descriptor.bcdUSB) == 0x220)
+			return le32_to_cpu(ep->eusb2_isoc_ep_comp.dwBytesPerInterval);
+		fallthrough;
 	default:
 		psize = usb_endpoint_maxp(&ep->desc);
 		psize *= usb_endpoint_maxp_mult(&ep->desc);
Signature · 1 line
2.43.0
maintainer
#6 lore raw

Re: [PATCH 3/3] media: uvcvideo: eUSB2 double isochronous bandwidth support

Hi Mathias,

Thank you for the patch.

Quoted 19 lines · Mathias Nyman

From: Tao Q Tao <[email protected]>

Add eUSB2 support to check total number of bytes, isochronous endpoint will transfer every service interval(SI).

---
 drivers/media/usb/uvc/uvc_video.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/media/usb/uvc/uvc_video.c +0 -0
index e3567aeb0007..a888f84208c6 100644

drivers/media/usb/uvc/uvc_video.c u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep) · line 1913

Quoted 8 lines
drivers/media/usb/uvc/uvc_video.c +5 -0
@@ -1906,6 +1906,11 @@ u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep)
 	case USB_SPEED_SUPER:
 	case USB_SPEED_SUPER_PLUS:
 		return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
+	case USB_SPEED_HIGH:
+		psize = usb_endpoint_maxp(&ep->desc);
+		if (psize == 0 && le16_to_cpu(dev->descriptor.bcdUSB) == 0x220)
+			return le32_to_cpu(ep->eusb2_isoc_ep_comp.dwBytesPerInterval);
+		fallthrough;

Instead of adding yet another case here, and eventually in a bunch of other drivers, could we centralize retrieval of the maximum bpi value in a helper function provided by the USB core ?

Quoted 3 lines
drivers/media/usb/uvc/uvc_video.c +0 -0
 	default:
 		psize = usb_endpoint_maxp(&ep->desc);
 		psize *= usb_endpoint_maxp_mult(&ep->desc);
Signature · 3 lines
Regards,

Laurent Pinchart
#7 lore raw

Re: [PATCH 3/3] media: uvcvideo: eUSB2 double isochronous bandwidth support

Quoted 28 lines · Laurent Pinchart

Hi Mathias,

Thank you for the patch.

Quoted 23 lines · Mathias Nyman

From: Tao Q Tao <[email protected]>

Add eUSB2 support to check total number of bytes, isochronous endpoint will transfer every service interval(SI).

---
  drivers/media/usb/uvc/uvc_video.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/media/usb/uvc/uvc_video.c +1 -0
index e3567aeb0007..a888f84208c6 100644
@@ -1906,6 +1906,11 @@ u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep)
  	case USB_SPEED_SUPER:
  	case USB_SPEED_SUPER_PLUS:
  		return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
+	case USB_SPEED_HIGH:
Quoted 8 lines

drivers/media/usb/uvc/uvc_video.c u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep) · line 1913

Quoted 4 lines
drivers/media/usb/uvc/uvc_video.c +4 -0
+		psize = usb_endpoint_maxp(&ep->desc);
+		if (psize == 0 && le16_to_cpu(dev->descriptor.bcdUSB) == 0x220)
+			return le32_to_cpu(ep->eusb2_isoc_ep_comp.dwBytesPerInterval);
+		fallthrough;

Instead of adding yet another case here, and eventually in a bunch of other drivers, could we centralize retrieval of the maximum bpi value in a helper function provided by the USB core ?

Sounds reasonable to me.
I'm not sure if any other drivers will need it as this feature seems to be made specifically for integrated webcams, but things evolve.

Thanks
Mathias

maintainer
#8 lore raw

Re: [PATCH 3/3] media: uvcvideo: eUSB2 double isochronous bandwidth support

Quoted 34 lines · Mathias Nyman
Quoted 24 lines · Laurent Pinchart
Quoted 23 lines · Mathias Nyman

From: Tao Q Tao <[email protected]>

Add eUSB2 support to check total number of bytes, isochronous endpoint will transfer every service interval(SI).

---
  drivers/media/usb/uvc/uvc_video.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/media/usb/uvc/uvc_video.c +1 -0
index e3567aeb0007..a888f84208c6 100644
@@ -1906,6 +1906,11 @@ u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep)
  	case USB_SPEED_SUPER:
  	case USB_SPEED_SUPER_PLUS:
  		return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
+	case USB_SPEED_HIGH:
Quoted 8 lines

drivers/media/usb/uvc/uvc_video.c u16 uvc_endpoint_max_bpi(struct usb_device *dev, struct usb_host_endpoint *ep) · line 1913

Quoted 4 lines
drivers/media/usb/uvc/uvc_video.c +4 -0
+		psize = usb_endpoint_maxp(&ep->desc);
+		if (psize == 0 && le16_to_cpu(dev->descriptor.bcdUSB) == 0x220)
+			return le32_to_cpu(ep->eusb2_isoc_ep_comp.dwBytesPerInterval);
+		fallthrough;

Instead of adding yet another case here, and eventually in a bunch of other drivers, could we centralize retrieval of the maximum bpi value in a helper function provided by the USB core ?

Quoted 3 lines

Sounds reasonable to me.
I'm not sure if any other drivers will need it as this feature seems to be made specifically for integrated webcams, but things evolve.

Even if eUSB2 doesn't get used by other devices, I think centralizing the whole max bpi calculation will be useful to handle the different USB_SPEED_*.

Signature · 3 lines
Regards,

Laurent Pinchart