From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Konrad Dybcio <konradybcio@kernel.org>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiazi Liu <jiazi.liu1984@gmail.com>,
Wesley Cheng <quic_wcheng@quicinc.com>,
Felipe Balbi <balbi@kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
"sashiko-bot@kernel.org" <sashiko-bot@kernel.org>
Subject: Re: [PATCH v2 4/4] usb: dwc3: gadget: cancel err_recovery_work after usb_del_gadget
Date: Sat, 5 Dec 2026 00:59:16 +0000 [thread overview]
Message-ID: <axNhaUSvnruFU12A@vbox> (raw)
In-Reply-To: <20261126-topic-usb_dwc3_fixups-v2-4-c0cc2b75c518@oss.qualcomm.com>
On Thu, Nov 26, 2026, Konrad Dybcio wrote:
> From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>
> dwc3_gadget_exit() cancels err_recovery_work before usb_del_gadget(),
> but the work can still be queued while the gadget is being unbound:
>
> - The gadget IRQ is only freed in dwc3_gadget_stop(), which runs from
> usb_del_gadget() when the gadget driver is unbound. An interrupt
> before that point can queue the work from dwc3_check_event_buf().
> - The unbind path calls pullup(0), which stops the endpoints. An
> End Transfer timeout there also queues the work, from
> __dwc3_stop_active_transfer().
>
> Either can requeue the work after the cancel, so it may run after the
> endpoints have been freed.
>
> Move cancel_work_sync() to after usb_del_gadget(). Once it returns,
> the IRQ is freed, so no interrupt can queue the work again. The
> pullup(0) path has also completed by then, so the End Transfer timeout
> cannot queue it either.
>
> Fixes: 1ff77cbefe5a ("usb: dwc3: gadget: fix IRQ storm on invalid event buffer count")
> Fixes: 61575534fb05 ("usb: dwc3: gadget: Recover from End Transfer timeout")
> Reported-by: sashiko-bot@kernel.org
> Closes: https://urldefense.com/v3/__https://lore.kernel.org/all/sashiko-outbox-229992@kernel.org/__;!!A4F2R9G_pg!Y2yquvTqBaUdAl6U_OKaw083ZjrfAq5hbtRTz3CRASJuwjK-rTF62vhKOZaX9ORvFVhZv7a7GuG6HYwMjDAuMwO7FEg$
> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/gadget.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 8f40e8dfa3f2..3c20f2ef6457 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -5047,9 +5047,9 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
> if (!dwc->gadget)
> return;
>
> - cancel_work_sync(&dwc->err_recovery_work);
> dwc3_enable_susphy(dwc, true);
> usb_del_gadget(dwc->gadget);
> + cancel_work_sync(&dwc->err_recovery_work);
> dwc3_gadget_free_endpoints(dwc);
> usb_put_gadget(dwc->gadget);
> dma_free_coherent(dwc->sysdev, DWC3_BOUNCE_SIZE, dwc->bounce,
>
> --
> 2.56.1
>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Thanks,
Thinh
next prev parent reply other threads:[~2026-12-05 0:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 13:01 [PATCH v2 0/4] DWC3 concurrency fixes Konrad Dybcio
2026-11-26 13:01 ` [PATCH v2 1/4] usb: dwc3: gadget: serialize connection bitfield writes Konrad Dybcio
2026-12-04 20:43 ` Thinh Nguyen
2026-11-26 13:01 ` [PATCH v2 2/4] usb: dwc3: gadget: clear softconnect on stop and failed pullup Konrad Dybcio
2026-11-26 13:22 ` sashiko-bot
2026-12-05 0:19 ` Thinh Nguyen
2026-11-26 13:01 ` [PATCH v2 3/4] usb: dwc3: gadget: serialize resume against error recovery Konrad Dybcio
2026-11-26 13:22 ` sashiko-bot
2026-12-05 0:51 ` Thinh Nguyen
2026-11-26 13:01 ` [PATCH v2 4/4] usb: dwc3: gadget: cancel err_recovery_work after usb_del_gadget Konrad Dybcio
2026-11-26 13:15 ` sashiko-bot
2026-12-05 0:59 ` Thinh Nguyen [this message]
2026-11-26 13:22 ` [PATCH v2 0/4] DWC3 concurrency fixes sashiko-bot
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=axNhaUSvnruFU12A@vbox \
--to=thinh.nguyen@synopsys.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jiazi.liu1984@gmail.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=quic_wcheng@quicinc.com \
--cc=sashiko-bot@kernel.org \
/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