USB: error messages on DWC3 gadget endpoint dequeue

Rasmus Villemoes rasmus.villemoes at prevas.dk
Fri Sep 15 15:47:34 CEST 2023


On 15/09/2023 15.05, João Paulo Silva Gonçalves wrote:
> Hi Marek,
> 
> I was testing fastboot image download over usb for imx8mp (from usb
> recovery patch of verdin-imx8mp) and i am having error messages on
> endpoint request dequeue function of DWC3 gadget controller. However,
> download is working fine, so this message may not be an error. They are
> happening because fastboot tx before sending a new usb request dequeue
> the same request, maybe to be sure it does not send it twice. Can I
> just ignore these messages? Maybe change its log level to dbg instead
> of error? What do you think? The messages I am seeing are below and are
> the ones with "... was not queued to ep1in-bulk". 

We apply this internally (sorry if it's whitespace damaged), but I never
fully understood the problem nor how the referenced kernel thread was
resolved, which is why I haven't sent it upstream yet.

    dwc3: gadget: Handle dequeuing of non queued request gracefully

    Trying to dequeue an request that is currently not queued should be
a no-op
    and be handled gracefully.

    Checking on list/queue empty indicate whether the request is queue
or not.
    Handling this gracefully allows for race condition free synchronization
    between the complete callback being called to to a completed
transfer and
    trying to call usb_ep_dequeue() at the same time.

    Inspired by:
https://patchwork.kernel.org/project/linux-usb/patch/20191106144553.16956-1-alexandru.ardelean@analog.com/

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index eb416b832aa..378d19d8e99 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1113,6 +1113,9 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,

        spin_lock_irqsave(&dwc->lock, flags);

+       if (list_empty(&dep->request_list) && list_empty(&dep->req_queued))
+               goto out0;
+
        list_for_each_entry(r, &dep->request_list, list) {
                if (r == req)
                        break;

Rasmus



More information about the U-Boot mailing list