Re: [PATCH 4/4] usb: gadget: dummy_hcd: set no_sg_constraint on the host controller
Alan Stern <[email protected]>
| Newsgroups | org.kernel.vger.linux-usb,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Aug 07, 2026 at 09:54:38AM +0200, Igor Skalkin wrote: > dummy_hcd copies data in software and has no hardware DMA alignment > requirement. Set no_sg_constraint = 1 so the USB core does not reject > SG URBs whose non-final segments are not a multiple of the endpoint > maxpacket size. It is true that dummy_hcd's software implementation has no inherent DMA alignment requirement. But dummy_hcd is meant as a testing tool; it emulates real controllers some of which _do_ have alignment requirements. > 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. This is the appropriate response when emulating, for example, an EHCI controller. A better solution to the problem would be to set no_sg_constraint at runtime, according to whether the connection speed is SuperSpeed or faster. Alan Stern > Assisted-by: OpenCode:claude-sonnet-5 > Signed-off-by: Igor Skalkin <[email protected]> > --- > drivers/usb/gadget/udc/dummy_hcd.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c > index 7597c9e9fa66..2cfb1d035b34 100644 > --- a/drivers/usb/gadget/udc/dummy_hcd.c > +++ b/drivers/usb/gadget/udc/dummy_hcd.c > @@ -2550,6 +2550,7 @@ static int dummy_setup(struct usb_hcd *hcd) > > dum = *((void **)dev_get_platdata(hcd->self.controller)); > hcd->self.sg_tablesize = ~0; > + hcd->self.no_sg_constraint = 1; > if (usb_hcd_is_primary_hcd(hcd)) { > dum->hs_hcd = hcd_to_dummy_hcd(hcd); > dum->hs_hcd->dum = dum; > -- > 2.49.0 >