mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Igor Skalkin <igor.skalkin@oss.qualcomm.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	Seungjin Bae <eeodqql09@gmail.com>, Kees Cook <kees@kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Sebastian Urban <surban@surban.net>, Felipe Balbi <balbi@ti.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Igor Skalkin <igor.skalkin@oss.qualcomm.com>
Subject: [PATCH v2 2/2] usb: gadget: dummy_hcd: set no_sg_constraint only on the SuperSpeed bus
Date: Wed, 12 Aug 2026 10:19:10 +0200	[thread overview]
Message-ID: <20260812081910.6821-3-igor.skalkin@oss.qualcomm.com> (raw)
In-Reply-To: <20260812081910.6821-1-igor.skalkin@oss.qualcomm.com>

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@rowland.harvard.edu>
Assisted-by: OpenCode:claude-sonnet-5
Signed-off-by: Igor Skalkin <igor.skalkin@oss.qualcomm.com>
---
 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


  parent reply	other threads:[~2026-08-12  8:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07  7:54 [PATCH 0/4] usb: gadget: dummy_hcd: fixes found while testing virtio-usb Igor Skalkin
2026-08-07  7:54 ` [PATCH 1/4] usb: gadget: dummy_hcd: fix SuperSpeed ep0 maxpacket Igor Skalkin
2026-08-07 21:15   ` Alan Stern
2026-08-07  7:54 ` [PATCH 2/4] usb: gadget: dummy_hcd: fix false overflow on bounded IN Igor Skalkin
2026-08-07 21:19   ` Alan Stern
2026-08-07  7:54 ` [PATCH 3/4] usb: gadget: dummy_hcd: fix SG transfer handling across chunks Igor Skalkin
2026-08-07 21:31   ` Alan Stern
2026-08-07  7:54 ` [PATCH 4/4] usb: gadget: dummy_hcd: set no_sg_constraint on the host controller Igor Skalkin
2026-08-07 21:23   ` Alan Stern
2026-08-12  8:19 ` [PATCH v2 0/2] usb: gadget: dummy_hcd: fixes found while testing virtio-usb Igor Skalkin
2026-08-12  8:19   ` [PATCH v2 1/2] usb: gadget: dummy_hcd: fix SuperSpeed ep0 maxpacket Igor Skalkin
2026-08-12  8:19   ` Igor Skalkin [this message]
2026-08-12 14:03     ` [PATCH v2 2/2] usb: gadget: dummy_hcd: set no_sg_constraint only on the SuperSpeed bus Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260812081910.6821-3-igor.skalkin@oss.qualcomm.com \
    --to=igor.skalkin@oss.qualcomm.com \
    --cc=balbi@ti.com \
    --cc=bigeasy@linutronix.de \
    --cc=eeodqql09@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=surban@surban.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®