From: sashiko-bot@kernel.org
To: "Elson Serrao" <elson.serrao@oss.qualcomm.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: dwc3: Increase no-IOC ENDTRANSFER delay
Date: Tue, 03 Nov 2026 18:39:19 +0000 [thread overview]
Message-ID: <sashiko-outbox-195852@kernel.org> (raw)
In-Reply-To: <20261103182953.3437202-1-elson.serrao@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: dwc3: unupdated 1 ms ENDTRANSFER delay in dwc3_remove_requests()
--
commit fee87ffa001e1c9181771b93176db403ea8ec8d4
Author: Elson Serrao <elson.serrao@oss.qualcomm.com>
usb: dwc3: Increase no-IOC ENDTRANSFER delay
This commit increases the fixed delay after issuing an ENDTRANSFER command
without CMDIOC from 1 ms to 2 ms in dwc3_send_gadget_ep_cmd() to prevent
SMMU faults when unmapping requests during teardown.
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index a76f669a796c2..a907fdfac8d71 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -445,7 +445,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
>
> if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_ENDTRANSFER &&
> !(cmd & DWC3_DEPCMD_CMDIOC))
> - mdelay(1);
> + mdelay(2);
[Severity: High]
Should the companion mdelay(1) in dwc3_remove_requests() also be increased
to 2 ms?
When __dwc3_gadget_ep_disable() tears down requests, commit 1338410c21a5
("usb: dwc3: gadget: Wait for End Transfer completion on ep disable")
changed it to pass interrupt = true:
drivers/usb/dwc3/gadget.c:__dwc3_gadget_ep_disable()
dwc3_remove_requests(dwc, dep, -ESHUTDOWN, true);
With interrupt = true, __dwc3_stop_active_transfer() issues ENDTRANSFER
with DWC3_DEPCMD_CMDIOC set and sets DWC3_EP_END_TRANSFER_PENDING, so
dwc3_send_gadget_ep_cmd() skips the !(cmd & DWC3_DEPCMD_CMDIOC) delay
above. Similarly, if dwc3_remove_requests() is called while an earlier
CMDIOC ENDTRANSFER (such as from dwc3_gadget_ep_dequeue()) is already
pending, dwc3_stop_active_transfer() returns early when it sees
DWC3_EP_END_TRANSFER_PENDING.
In both paths, on controllers without DWC3_GUCTL2_RST_ACTBITLATER (such as
DWC_usb31), dwc3_remove_requests() relies on its own delay before
synchronously unmapping request buffers via dwc3_gadget_giveback():
drivers/usb/dwc3/gadget.c:dwc3_remove_requests() {
dwc3_stop_active_transfer(dep, false, interrupt);
...
/* Give the controller time to stop accessing the request buffers */
if (dep->flags & DWC3_EP_END_TRANSFER_PENDING)
mdelay(1);
/* - giveback all requests to gadget driver */
while (!list_empty(&dep->started_list)) {
req = next_request(&dep->started_list);
dwc3_gadget_giveback(dep, req, status);
}
...
}
Leaving this delay at 1 ms means those teardown paths can still unmap DMA
buffers in started_list and cancelled_list before the controller finishes
processing ENDTRANSFER.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103182953.3437202-1-elson.serrao@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-11-03 18:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 18:29 [PATCH] usb: dwc3: Increase no-IOC ENDTRANSFER delay Elson Serrao
2026-11-03 18:39 ` sashiko-bot [this message]
2026-11-12 1:46 ` Thinh Nguyen
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=sashiko-outbox-195852@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=elson.serrao@oss.qualcomm.com \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.