From: "Lothar Waßmann" <LW@KARO-electronics.de>
To: "Petr Beneš" <Petr.Benes@ysoft.com>
Cc: Mattijs Korpershoek <mkorpershoek@kernel.org>,
"u-boot@lists.denx.de" <u-boot@lists.denx.de>
Subject: Re: Regression in f_fastboot due to commit 6a92e9827650 ("usb: ci_udc: Check ci_ep->desc before use")
Date: Wed, 15 Jul 2026 07:23:13 +0200 [thread overview]
Message-ID: <20260715072313.44c3f2b1.LW@KARO-electronics.de> (raw)
In-Reply-To: <DB9PR04MB8219B75AE3A1D4D750B7C3B880FD2@DB9PR04MB8219.eurprd04.prod.outlook.com>
Hi,
On Fri, 10 Jul 2026 21:27:48 +0000 Petr Beneš wrote:
> Hello Lothar and Mattijs,
>
> I hope web outlook doesn't render my response unreadable.
> ________________________________________
> From: Mattijs Korpershoek <mkorpershoek@kernel.org>
> Sent: Thursday, July 9, 2026 17:15
> To: Lothar Waßmann; u-boot@lists.denx.de
> Cc: Petr Beneš
> Subject: Re: Regression in f_fastboot due to commit 6a92e9827650 ("usb: ci_udc: Check ci_ep->desc before use")
>
> Hi Lothar,
>
> On Wed, Jul 08, 2026 at 07:12, Lothar Waßmann <LW@KARO-electronics.de> wrote:
>
> > Hi,
> >
> > commit 6a92e9827650 ("usb: ci_udc: Check ci_ep->desc before use") has
> > the side effect that an empty buffer is being passed on to
> > rx_handler_command() in drivers/usb/gadget/f_fastboot.c upon
> > termination of a fastboot session which leads to a
> > 'command not recognized' error message being printed on the console.
>
> Thank you for reporting this.
>
> >
> > Obviously without the commit the offending USB request had been silently
> > dropped but is now delivered to the upper levels.
>
> Well, it was not silently dropped in case of the ethernet gadget, it was silently corrupting memory.
>
> >
> > I'm not sure what the correct fix would be.
> > Should the fastboot driver ignore the empty command buffer or should
> > the "Moreover, the patch gets rid of possible outstanding requests
> > if the endpoint's state changes to disabled." part of the commit be
> > reverted?
>
> Hmm, maybe I got it wrong. The endpoint got disabled, so what should happen with requests?
>
> linux/usb/gadget.h reads:
>
> * @complete: Function called when request completes, so this request and
> * its buffer may be re-used.
> * Reads terminate with a short packet, or when the buffer fills,
> * whichever comes first. When writes terminate, some data bytes
> * will usually still be in flight (often in a hardware fifo).
> * Errors (for reads or writes) stop the queue from advancing
> * until the completion function returns, so that any transfers
> * invalidated by the error may first be dequeued.
>
> Petr, did you observe similar behaviour with the ums gadget?
>
> I didn't see any wrongdoing of the ethernet gadget.
> >
> >
I found a solution for the problem. The ci_udc driver checks the req
status for -EINPROGRESS in several places, but does never initialize the
status to that value.
This patch alleviates the problem:
Index: a/drivers/usb/gadget/ci_udc.c
===================================================================
--- a/drivers/usb/gadget/ci_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -530,6 +530,9 @@ static void ci_ep_submit_next_request(st
head = ci_get_qh(num, in);
ci_req = list_first_entry(&ci_ep->queue, struct ci_req, queue);
+
+ ci_req->req.status = -EINPROGRESS;
+
len = ci_req->req.length;
head->next = (unsigned long)item;
@@ -753,6 +756,9 @@ static void handle_ep_complete(struct ci
ci_ep_submit_next_request(ci_ep);
ci_req->req.actual = ci_req->req.length - len;
+ if (ci_req->req.status == -EINPROGRESS)
+ ci_req->req.status = 0;
+
ci_debounce(ci_req, in);
DBG("ept%d %s req %p, complete %x\n",
This is similar to how the Linux driver behaves.
I tested with fastboot and mass-storage gadget.
Lothar Waßmann
prev parent reply other threads:[~2026-07-15 5:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 5:12 Regression in f_fastboot due to commit 6a92e9827650 ("usb: ci_udc: Check ci_ep->desc before use") Lothar Waßmann
2026-07-09 15:15 ` Mattijs Korpershoek
2026-07-10 21:27 ` Petr Beneš
2026-07-15 5:23 ` Lothar Waßmann [this message]
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=20260715072313.44c3f2b1.LW@KARO-electronics.de \
--to=lw@karo-electronics.de \
--cc=Petr.Benes@ysoft.com \
--cc=mkorpershoek@kernel.org \
--cc=u-boot@lists.denx.de \
/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