* [PATCH RESEND] usb: octeon-hcd: release the USB block when initialization fails
@ 2026-10-11 7:22 Orgad Shaneh
2026-10-11 7:27 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Orgad Shaneh @ 2026-10-11 7:22 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, linux-kernel
cvmx_usb_initialize() gets as far as selecting the reference clock,
enabling USBN_CLK_CTL and taking the PHY out of reset (steps 2b-2e)
before anything can go wrong, and its only caller frees the HCD and
returns without touching the hardware. Both of its error returns
therefore leave the USB block clocked and out of reset on a failed
probe.
Release it on the way out with cvmx_usb_shutdown(), which is the undo
the retry path a few lines above already uses. It cannot refuse with
-EBUSY here: the pipe lists it checks are initialised by
octeon_usb_probe() before cvmx_usb_initialize() is called, and no pipe
can have been opened yet.
Fixes: 22bce6d2b3fd ("usb: octeon-hcd: fail the probe when the USB core does not respond")
Assisted-by: LLM
Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
Resend of
https://lore.kernel.org/all/20260917072144.438023-1-orgads@gmail.com/
with no code change; the Assisted-by tag is now in the form
coding-assistants.rst documents.
The -EAGAIN return predates that commit; it has the same problem and is
fixed here as well.
Found by the Sashiko review bot on the v2 posting of the series that
added the -ENODEV path.
diff --git a/drivers/usb/host/octeon-hcd.c b/drivers/usb/host/octeon-hcd.c
--- a/drivers/usb/host/octeon-hcd.c
+++ b/drivers/usb/host/octeon-hcd.c
@@ -708,6 +708,7 @@
int channel;
int divisor;
int retries = 0;
+ int status;
union cvmx_usbcx_hcfg usbcx_hcfg;
union cvmx_usbnx_clk_ctl usbn_clk_ctl;
union cvmx_usbcx_gintsts usbc_gintsts;
@@ -872,7 +873,8 @@
if (usbcx_gahbcfg.u32 == 0xffffffff || usbcx_gahbcfg.u32 == 0) {
dev_err(dev, "USB core is not responding (GHWCFG3=0x%08x)\n",
usbcx_gahbcfg.u32);
- return -ENODEV;
+ status = -ENODEV;
+ goto err_shutdown;
}
usbcx_gahbcfg.u32 = 0;
@@ -961,14 +963,27 @@
dev_dbg(dev, "gintsts after reset: 0x%x\n", (int)usbc_gintsts.u32);
if (!usbc_gintsts.s.disconnint && !usbc_gintsts.s.prtint)
return 0;
- if (retries++ >= 5)
- return -EAGAIN;
+ if (retries++ >= 5) {
+ status = -EAGAIN;
+ goto err_shutdown;
+ }
dev_info(dev, "controller reset failed (gintsts=0x%x) - retrying\n",
(int)usbc_gintsts.u32);
msleep(50);
cvmx_usb_shutdown(usb);
msleep(50);
goto retry;
+
+err_shutdown:
+ /*
+ * Steps 2b-2e above selected the reference clock, enabled
+ * USBN_CLK_CTL and took the PHY out of reset, and the caller only
+ * frees the HCD, so hand the block back before giving up. The pipe
+ * lists cvmx_usb_shutdown() checks are initialised by the caller
+ * before it gets here, so it cannot refuse with -EBUSY.
+ */
+ cvmx_usb_shutdown(usb);
+ return status;
}
/**
--
2.47.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH RESEND] usb: octeon-hcd: release the USB block when initialization fails
2026-10-11 7:22 [PATCH RESEND] usb: octeon-hcd: release the USB block when initialization fails Orgad Shaneh
@ 2026-10-11 7:27 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-11 7:27 UTC (permalink / raw)
To: Orgad Shaneh; +Cc: linux-usb
> cvmx_usb_initialize() gets as far as selecting the reference clock,
> enabling USBN_CLK_CTL and taking the PHY out of reset (steps 2b-2e)
> before anything can go wrong, and its only caller frees the HCD and
> returns without touching the hardware. Both of its error returns
> therefore leave the USB block clocked and out of reset on a failed
> probe.
>
> Release it on the way out with cvmx_usb_shutdown(), which is the undo
> the retry path a few lines above already uses. It cannot refuse with
> -EBUSY here: the pipe lists it checks are initialised by
> octeon_usb_probe() before cvmx_usb_initialize() is called, and no pipe
> can have been opened yet.
>
> Fixes: 22bce6d2b3fd ("usb: octeon-hcd: fail the probe when the USB core does not respond")
> Assisted-by: LLM
> Signed-off-by: Orgad Shaneh <orgads@gmail.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261011072238.2381564-1-orgads@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-11 7:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-11 7:22 [PATCH RESEND] usb: octeon-hcd: release the USB block when initialization fails Orgad Shaneh
2026-10-11 7:27 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox