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>
Subject: Re: [PATCH v2 3/4] usb: dwc3: gadget: serialize resume against error recovery
Date: Sat, 5 Dec 2026 00:51:44 +0000 [thread overview]
Message-ID: <axNb5k_VJ8ZQp301@vbox> (raw)
In-Reply-To: <20261126-topic-usb_dwc3_fixups-v2-3-c0cc2b75c518@oss.qualcomm.com>
On Thu, Nov 26, 2026, Konrad Dybcio wrote:
> From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>
> dwc3_gadget_resume() calls dwc3_gadget_soft_connect() without taking
> connect_mutex, allowing it to race with err_recovery_work's disconnect
> and reconnect sequence.
>
> Take connect_mutex before checking gadget_driver and softconnect, and
> hold it through the soft-connect operation. This also serializes the
> state check against dwc3_gadget_stop().
>
> Preserve softconnect on resume failure so a later resume can retry the
> requested connection.
Is this paragraph meant to be here? This change doesn't preserve the
softconnect. Can you clarify this point?
>
> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/gadget.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index d7e22b559876..8f40e8dfa3f2 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -8,6 +8,7 @@
> * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> */
>
> +#include <linux/cleanup.h>
> #include <linux/kernel.h>
> #include <linux/delay.h>
> #include <linux/property.h>
> @@ -5081,6 +5082,8 @@ int dwc3_gadget_suspend(struct dwc3 *dwc)
>
> int dwc3_gadget_resume(struct dwc3 *dwc)
Should dwc3_gadget_suspend() take connect_mutex too?
> {
> + guard(mutex)(&dwc->connect_mutex);
> +
Can we use mutex_lock()/mutex_unlock() here to match the rest of the
file? Adding <linux/cleanup.h> and converting to guard() should be a
separate patch covering all the other places in the file.
Thanks,
Thinh
next prev parent reply other threads:[~2026-12-05 0:52 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 [this message]
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
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=axNb5k_VJ8ZQp301@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 \
/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