usb: dwc3: meson-g12a: disable VBUS regulator on remove
Subsystems (3)
PATCH 1/1 usb: dwc3: meson-g12a: disable VBUS regulator on remove
dwc3_meson_g12a_probe() enables priv->vbus when the optional regulator is present, but dwc3_meson_g12a_remove() does not perform the matching regulator_disable(). The probe error path already disables the regulator before rearming the reset control.
Disable priv->vbus in the remove path before reset_control_rearm() to match the cleanup performed by the probe error path.
--- drivers/usb/dwc3/dwc3-meson-g12a.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/dwc3/dwc3-meson-g12a.c +3 -0
@@ -851,6 +851,9 @@ static void dwc3_meson_g12a_remove(struct platform_device *pdev)pm_runtime_put_noidle (dev);pm_runtime_set_suspended (dev); +if (priv->vbus) +regulator_disable (priv->vbus); +reset_control_rearm (priv->reset); clk_bulk_disable_unprepare(priv->drvdata->num_clks,
base-commit: f03c39de3a1307371a4032757cd1732e91087c7d
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] usb: dwc3: unbalanced regulator disable in remove path --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: dwc3: unbalanced regulator disable in remove path
--
commit d70a1dbc4058328dc13b49feab6a18162b728570
Author: Guangshuo Li <[email protected]>
usb: dwc3: meson-g12a: disable VBUS regulator on remove
This commit disables priv->vbus in the remove path before rearming the reset control to match the cleanup performed by the probe error path.
drivers/usb/dwc3/dwc3-meson-g12a.c static void dwc3_meson_g12a_remove(struct platform_device *pdev) · line 855
Quoted 10 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +2
-0@@ -851,6 +851,9 @@ static void dwc3_meson_g12a_remove(struct platform_device *pdev)pm_runtime_put_noidle (dev);pm_runtime_set_suspended (dev); +if (priv->vbus) +regulator_disable (priv->vbus);
[Severity: High]
Could this lead to an unbalanced regulator disable if the device is currently in device mode?
If the device is operating in OTG mode and transitions to PHY_MODE_USB_DEVICE, dwc3_meson_g12a_otg_mode_set() already actively disables the regulator:
dwc3_meson_g12a_otg_mode_set() {
...
if (mode == PHY_MODE_USB_DEVICE)
ret = regulator_disable(priv->vbus);
...
}If dwc3_meson_g12a_remove() is called while the device is still in device mode, wouldn't this unconditional regulator_disable() drop the enable count below zero?
Quoted 4 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +1
-0+reset_control_rearm (priv->reset); clk_bulk_disable_unprepare(priv->drvdata->num_clks,
Signature · 6 lines
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Quoted 9 lines · Guangshuo Li
dwc3_meson_g12a_probe()enablespriv->vbuswhen the optional regulator is present, butdwc3_meson_g12a_remove()does not perform the matchingregulator_disable(). The probe error path already disables the regulator before rearming the reset control.Disable
priv->vbusin the remove path beforereset_control_rearm()to match the cleanup performed by the probe error path.Fixes c99993376f72 ("usb: dwc3: Add Amlogic G12A DWC3 glue")
We should also include Cc stable.
Thanks,
Thinh
Quoted 24 lines
Signed-off-by Guangshuo Li <[email protected]>--- drivers/usb/dwc3/dwc3-meson-g12a.c | 3 +++ 1 file changed, 3 insertions(+)drivers/usb/dwc3/dwc3-meson-g12a.c +3
-0@@ -851,6 +851,9 @@ static void dwc3_meson_g12a_remove(struct platform_device *pdev)pm_runtime_put_noidle (dev);pm_runtime_set_suspended (dev); +if (priv->vbus) +regulator_disable (priv->vbus); +reset_control_rearm (priv->reset); clk_bulk_disable_unprepare(priv->drvdata->num_clks,base-commit:
f03c39de3a1307371a4032757cd1732e91087c7dSignature · 1 line
2.43.0
[email protected]
maintainerQuoted 6 lines · Thinh Nguyen
Quoted 5 lines · Guangshuo Li
dwc3_meson_g12a_probe()enablespriv->vbuswhen the optional regulator is present, butdwc3_meson_g12a_remove()does not perform the matchingregulator_disable(). The probe error path already disables the regulator before rearming the reset control.
Quoted 6 lines
Quoted 4 lines
Disable
priv->vbusin the remove path beforereset_control_rearm()to match the cleanup performed by the probe error path.Fixes c99993376f72 ("usb: dwc3: Add Amlogic G12A DWC3 glue")We should also include Cc stable.
Maybe if the sashiko results are fixed first, this is dropped from my review queue.
thanks,
greg k-h
Thinh Nguyen
maintainerQuoted 10 lines · On Fri, Oct 02, 2026, [email protected] wrote:
Quoted 9 lines · Thinh Nguyen
Quoted 8 lines · Guangshuo Li
dwc3_meson_g12a_probe()enablespriv->vbuswhen the optional regulator is present, butdwc3_meson_g12a_remove()does not perform the matchingregulator_disable(). The probe error path already disables the regulator before rearming the reset control.Disable
priv->vbusin the remove path beforereset_control_rearm()to match the cleanup performed by the probe error path.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Fixes c99993376f72 ("usb: dwc3: Add Amlogic G12A DWC3 glue")We should also include Cc stable.
Maybe if the sashiko results are fixed first, this is dropped from my review queue.
I need to get Sashiko to Cc me in the future...
Thanks for the catch,
Thinh