Re: [PATCH v2 2/2] usb: gadget: dummy_hcd: set no_sg_constraint only on the SuperSpeed bus

From: Alan Stern

Date: Wed Aug 12 2026 - 10:06:57 EST


On Wed, Aug 12, 2026 at 10:19:10AM +0200, Igor Skalkin wrote:
> dummy_hcd registers two separate root hubs/buses: a HighSpeed one
> emulating an EHCI-class controller, and a SuperSpeed one emulating an
> xHCI-class controller. usb_submit_urb() rejects SG URBs whose
> non-final segments are not a multiple of the endpoint maxpacket size,
> unless the bus has no_sg_constraint set.
>
> For SuperSpeed bulk endpoints maxpacket is 1024 bytes; usbtest
> generates SG lists with varying segment sizes (e.g. 512 bytes) that
> are valid transfers but not maxpacket-aligned, causing usb_submit_urb
> to return -EINVAL before the URB reaches the host controller.
>
> xHCI-class controllers have no such DMA alignment requirement, so set
> no_sg_constraint on the SS bus to match. Leave the HS bus unchanged:
> EHCI-class controllers do have this requirement in hardware, and
> dummy_hcd's HS roothub is meant to emulate that behaviour, so the
> constraint should stay enforced there.
>
> Suggested-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
> Assisted-by: OpenCode:claude-sonnet-5
> Signed-off-by: Igor Skalkin <igor.skalkin@xxxxxxxxxxxxxxxx>
> ---

Acked-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

> drivers/usb/gadget/udc/dummy_hcd.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
> index 29f671c7b319..0ae600159478 100644
> --- a/drivers/usb/gadget/udc/dummy_hcd.c
> +++ b/drivers/usb/gadget/udc/dummy_hcd.c
> @@ -2578,6 +2578,15 @@ static int dummy_setup(struct usb_hcd *hcd)
> dum->ss_hcd->dum = dum;
> hcd->speed = HCD_USB3;
> hcd->self.root_hub->speed = USB_SPEED_SUPER;
> +
> + /*
> + * xHCI-class SuperSpeed controllers have no maxpacket
> + * alignment requirement for non-final SG segments. Only
> + * relax the constraint on the SS bus; the HS bus keeps
> + * emulating the alignment requirement of EHCI-class
> + * controllers.
> + */
> + hcd->self.no_sg_constraint = 1;
> }
> return 0;
> }
> --
> 2.49.0
>