From: sashiko-bot@kernel.org
To: "Wang Haoran" <wanghr2026@mail.zgclab.edu.cn>
Cc: linux-usb@vger.kernel.org, linux-amlogic@lists.infradead.org,
neil.armstrong@linaro.org
Subject: Re: [PATCH] usb: dwc3: meson: g12a: disable vbus on removal
Date: Thu, 19 Nov 2026 08:26:58 +0000 [thread overview]
Message-ID: <sashiko-outbox-222669@kernel.org> (raw)
In-Reply-To: <1795076109480-15-f562c8e5@mail.zgclab.edu.cn>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: dwc3: meson-g12a: unbalanced vbus disable in
dwc3_meson_g12a_remove()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] usb: dwc3: meson-g12a: unclocked access in
dwc3_meson_g12a_irq_thread() [1]
--
commit c61c405ca43e5b0d976be117784027e8c9ce130d
Author: Wang Haoran <wanghr2026@mail.zgclab.edu.cn>
usb: dwc3: meson: g12a: disable vbus on removal
This commit disables the vbus regulator in dwc3_meson_g12a_remove() to
balance the regulator_enable() call in dwc3_meson_g12a_probe().
> diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
> index ca07e813fd64f..4d68b50722e76 100644
> --- a/drivers/usb/dwc3/dwc3-meson-g12a.c
> +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
> @@ -847,6 +847,9 @@ static void dwc3_meson_g12a_remove(struct platform_device *pdev)
> phy_exit(priv->phys[i]);
> }
>
> + if (priv->vbus)
> + regulator_disable(priv->vbus);
[Severity: Medium]
Can this cause an unbalanced regulator_disable() on priv->vbus when the
controller is removed while in device mode?
When dwc3_meson_g12a_otg_mode_set() switches to PHY_MODE_USB_DEVICE, it
already disables priv->vbus:
drivers/usb/dwc3/dwc3-meson-g12a.c:dwc3_meson_g12a_otg_mode_set() {
...
if (priv->vbus) {
if (mode == PHY_MODE_USB_DEVICE)
ret = regulator_disable(priv->vbus);
else
ret = regulator_enable(priv->vbus);
if (ret)
return ret;
}
priv->otg_phy_mode = mode;
...
}
Should this check priv->otg_phy_mode == PHY_MODE_USB_HOST before calling
regulator_disable(priv->vbus), matching dwc3_meson_g12a_suspend()?
> +
> pm_runtime_disable(dev);
> pm_runtime_put_noidle(dev);
> pm_runtime_set_suspended(dev);
[Severity: High]
This problem wasn't introduced by this patch, but can
dwc3_meson_g12a_irq_thread() read unclocked registers during driver removal
[1]?
The OTG interrupt is requested via devm_request_threaded_irq(), so it stays
enabled until devres cleanup runs after dwc3_meson_g12a_remove() returns,
while dwc3_meson_g12a_remove() disables the clocks via
clk_bulk_disable_unprepare() before returning:
CPU0 CPU1
dwc3_meson_g12a_remove()
...
clk_bulk_disable_unprepare()
dwc3_meson_g12a_irq_thread()
dwc3_meson_g12a_get_id()
regmap_read(priv->usb_glue_regmap, ...)
<-- unclocked register access
devres_release_all()
If an OTG interrupt fires in that window, reading priv->usb_glue_regmap with
the clocks disabled triggers an asynchronous external abort.
[1] https://sashiko.dev/#/bug/linux-901d8f75-b80e-43d7-b50d-1dc1755ce4f5
--
Sashiko AI review · https://sashiko.dev/#/patchset/1795076109480-15-f562c8e5@mail.zgclab.edu.cn?part=1
prev parent reply other threads:[~2026-11-19 8:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 8:15 [PATCH] usb: dwc3: meson: g12a: disable vbus on removal Wang Haoran
2026-11-19 8:26 ` sashiko-bot [this message]
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-222669@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wanghr2026@mail.zgclab.edu.cn \
/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