This patch supports bulk_maxburst. Without this change
we are not able to achieve performance for super speed plus device.
Without this fix, we confirmed through lecroy that it is sending
packets with NumP always equal to 1.
Signed-off-by: Srikanth Chary Chennoju <srikanth.chary-chennoju@amd.com>
---
drivers/usb/gadget/function/f_sourcesink.c | 14 ++++++++++++++
drivers/usb/gadget/function/g_zero.h | 2 ++
2 files changed, 16 insertions(+)
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index ec5fd25020fd..84f3b3bc7669 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -45,6 +45,7 @@ struct f_sourcesink {
unsigned isoc_maxpacket;
unsigned isoc_mult;
unsigned isoc_maxburst;
+ unsigned bulk_maxburst;
unsigned buflen;
unsigned bulk_qlen;
unsigned iso_qlen;
@@ -328,6 +329,10 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f)
source_sink_intf_alt0.bInterfaceNumber = id;
source_sink_intf_alt1.bInterfaceNumber = id;
+ /* sanity check the bulk module parameters */
+ if (ss->bulk_maxburst > 15)
+ ss->bulk_maxburst = 15;
+
/* allocate bulk endpoints */
ss->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc);
if (!ss->in_ep) {
@@ -341,6 +346,14 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f)
if (!ss->out_ep)
goto autoconf_fail;
+ /*
+ * Fill in the SS bulk descriptors from the module parameters.
+ * We assume that the user knows what they are doing and won't
+ * give parameters that their UDC doesn't support.
+ */
+ ss_source_comp_desc.bMaxBurst = ss->bulk_maxburst;
+ ss_sink_comp_desc.bMaxBurst = ss->bulk_maxburst;
+
/* sanity check the isoc module parameters */
if (ss->isoc_interval < 1)
ss->isoc_interval = 1;
@@ -852,6 +865,7 @@ static struct usb_function *source_sink_alloc_func(
ss->isoc_maxpacket = ss_opts->isoc_maxpacket;
ss->isoc_mult = ss_opts->isoc_mult;
ss->isoc_maxburst = ss_opts->isoc_maxburst;
+ ss->bulk_maxburst = ss_opts->bulk_maxburst;
ss->buflen = ss_opts->bulk_buflen;
ss->bulk_qlen = ss_opts->bulk_qlen;
ss->iso_qlen = ss_opts->iso_qlen;
diff --git a/drivers/usb/gadget/function/g_zero.h b/drivers/usb/gadget/function/g_zero.h
index 98b8462ad538..3f327e37f398 100644
--- a/drivers/usb/gadget/function/g_zero.h
+++ b/drivers/usb/gadget/function/g_zero.h
@@ -20,6 +20,7 @@ struct usb_zero_options {
unsigned isoc_maxpacket;
unsigned isoc_mult;
unsigned isoc_maxburst;
+ unsigned bulk_maxburst;
unsigned bulk_buflen;
unsigned qlen;
unsigned ss_bulk_qlen;
@@ -33,6 +34,7 @@ struct f_ss_opts {
unsigned isoc_maxpacket;
unsigned isoc_mult;
unsigned isoc_maxburst;
+ unsigned bulk_maxburst;
unsigned bulk_buflen;
unsigned bulk_qlen;
unsigned iso_qlen;
--
2.25.1
On Fri, Jul 04, 2025 at 05:10:12PM +0530, Srikanth Chary Chennoju wrote: > This patch supports bulk_maxburst. Without this change > we are not able to achieve performance for super speed plus device. > Without this fix, we confirmed through lecroy that it is sending > packets with NumP always equal to 1. > > Signed-off-by: Srikanth Chary Chennoju <srikanth.chary-chennoju@amd.com> > --- > drivers/usb/gadget/function/f_sourcesink.c | 14 ++++++++++++++ > drivers/usb/gadget/function/g_zero.h | 2 ++ > 2 files changed, 16 insertions(+) > > diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c > index ec5fd25020fd..84f3b3bc7669 100644 > --- a/drivers/usb/gadget/function/f_sourcesink.c > +++ b/drivers/usb/gadget/function/f_sourcesink.c > @@ -341,6 +346,14 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f) > if (!ss->out_ep) > goto autoconf_fail; > > + /* > + * Fill in the SS bulk descriptors from the module parameters. > + * We assume that the user knows what they are doing and won't > + * give parameters that their UDC doesn't support. > + */ That's not such a great assumption; people make mistakes like this quite a lot. If checking and adjusting the parameters isn't terribly difficult, you should do it. Alan Stern
© 2016 - 2025 Red Hat, Inc.