usb: dwc3-am62: shut down refclk on remove
Subsystems (2)
PATCH 1/1 usb: dwc3-am62: shut down refclk on remove
dwc3_ti_remove() relies on pm_runtime_put_sync() to invoke the runtime-suspend callback and disable the USB2 reference clock. The callback is not guaranteed to run: autosuspend may defer it, and a reference held by pm_runtime_forbid() keeps the usage count above zero. The following pm_runtime_disable() then cancels pending work while the clock remains enabled.
Balance only the reference acquired by remove without requesting a suspend, then disable runtime PM to drain any operation in progress. Disable the clock explicitly when the stable runtime status shows that the device was not already suspended. This also handles CONFIG_PM=n, where the runtime-PM calls are stubs, without double-disabling the clock after a failed resume.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/usb/dwc3/dwc3-am62.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-am62.c +3 -1
@@ -319,9 +319,11 @@ static void dwc3_ti_remove(struct platform_device *pdev) reg &= ~USBSS_MODE_VALID ;dwc3_ti_writel (am62,USBSS_MODE_CONTROL , reg); -pm_runtime_put_sync (dev); +pm_runtime_put_noidle (dev);pm_runtime_disable (dev);pm_runtime_dont_use_autosuspend (dev); +if (!pm_runtime_status_suspended (dev)) +clk_disable_unprepare (am62->usb2_refclk);pm_runtime_set_suspended (dev); }
Signature · 1 line
2.47.1
Quoted 45 lines · Myeonghun Pak
dwc3_ti_remove()relies onpm_runtime_put_sync()to invoke the runtime-suspend callback and disable the USB2 reference clock. The callback is not guaranteed to run: autosuspend may defer it, and a reference held bypm_runtime_forbid()keeps the usage count above zero. The followingpm_runtime_disable()then cancels pending work while the clock remains enabled.Balance only the reference acquired by remove without requesting a suspend, then disable runtime PM to drain any operation in progress. Disable the clock explicitly when the stable runtime status shows that the device was not already suspended. This also handles
CONFIG_PM=n, where the runtime-PM calls are stubs, without double-disabling the clock after a failed resume.This issue was identified during our ongoing static-analysis research while reviewing kernel code.
Fixes 6661befe4100 ("usb: dwc3-am62: fix module unload/reload behavior")Assisted-by OpenAI:GPT-5.6Co-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>--- drivers/usb/dwc3/dwc3-am62.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/usb/dwc3/dwc3-am62.c +3
-1@@ -319,9 +319,11 @@ static void dwc3_ti_remove(struct platform_device *pdev) reg &= ~USBSS_MODE_VALID ;dwc3_ti_writel (am62,USBSS_MODE_CONTROL , reg); -pm_runtime_put_sync (dev); +pm_runtime_put_noidle (dev);pm_runtime_disable (dev);pm_runtime_dont_use_autosuspend (dev); +if (!pm_runtime_status_suspended (dev)) +clk_disable_unprepare (am62->usb2_refclk);pm_runtime_set_suspended (dev); }Signature · 1 line
2.47.1
Please also add Cc stable.
Thanks,
Thinh