From: sashiko-bot@kernel.org
To: "Vladyslav Tymoshchuk" <tvlad744@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v3] usb: dwc3: Notify the glue of role changes from the mode switch work
Date: Wed, 11 Nov 2026 09:18:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-208679@kernel.org> (raw)
In-Reply-To: <20261111090122.134-1-tvlad744@gmail.com>
> dwc3_usb_role_switch_set() and dwc3_drd_notifier() call the glue's
> pre_set_role() synchronously, from the context of whoever changes the
> role, while the mode switch itself runs from drd_work on a freezable
> workqueue. Not every caller is frozen during system sleep: the UCSI
> connector work, for one, runs on the non-freezable system workqueue.
>
> On SM8750, when the USB cable is unplugged while the system is in
> s2idle, the UCSI connector work for the change runs before the devices
> have resumed. It switches the role to USB_ROLE_NONE, and
> dwc3_qcom_set_role_notifier() accesses QSCRATCH while the glue clocks
> are still off. The access does not complete and the SoC resets.
> pm_runtime_resume_and_get() does not prevent this: runtime PM is
> disabled at that point and the device is still marked active, so it
> returns success without resuming anything.
>
> Record the role and call pre_set_role() from __dwc3_set_mode() instead,
> so that the glue is not called while the system is suspended. The mode
> alone can't carry this: USB_ROLE_NONE maps to the default mode, so a
> switch between it and that role leaves the mode unchanged, and the glue
> still has to be told. Make the call before the checks that skip the
> mode switch, and only when a role was recorded, as the mode can also
> change without one from debugfs and from dwc3_setup_role_switch().
>
> Role changes that come in while the work is frozen collapse into the
> last one, which is the state the hardware has to end up in.
>
> Fixes: 21188e8d6d75 ("usb: dwc3: qcom: Implement glue callbacks to facilitate runtime suspend")
> Cc: stable@vger.kernel.org
> Suggested-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
> Signed-off-by: Vladyslav Tymoshchuk <tvlad744@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111090122.134-1-tvlad744@gmail.com?part=1
next prev parent reply other threads:[~2026-11-11 9:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 9:01 [PATCH v3] usb: dwc3: Notify the glue of role changes from the mode switch work Vladyslav Tymoshchuk
2026-11-11 9:18 ` sashiko-bot [this message]
2026-11-12 1:59 ` 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-208679@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tvlad744@gmail.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