Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: xhci: return an error if the host is not halted
@ 2026-09-02 10:15 Henry Tseng
  2026-09-02 11:50 ` Michal Pecio
  0 siblings, 1 reply; 2+ messages in thread
From: Henry Tseng @ 2026-09-02 10:15 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman; +Cc: linux-usb, Henry Tseng

xhci_reset() returns 0 when the host is not halted, without ever writing
CMD_RESET. Every other path that fails to reset the host returns an
error, so callers that check the return value are told the reset
succeeded on the one path where it did not happen.

Return -EBUSY when the reset is aborted because the host is not halted.

Signed-off-by: Henry Tseng <henrytseng@qnap.com>
---
 drivers/usb/host/xhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index a9e47e178c28..2af6a7b91e55 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -195,7 +195,7 @@ int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us)
 
 	if ((state & STS_HALT) == 0) {
 		xhci_warn(xhci, "Host controller not halted, aborting reset.\n");
-		return 0;
+		return -EBUSY;
 	}
 
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Reset the HC");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: xhci: return an error if the host is not halted
  2026-09-02 10:15 [PATCH] usb: xhci: return an error if the host is not halted Henry Tseng
@ 2026-09-02 11:50 ` Michal Pecio
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Pecio @ 2026-09-02 11:50 UTC (permalink / raw)
  To: Henry Tseng; +Cc: Mathias Nyman, Greg Kroah-Hartman, linux-usb

On Wed,  2 Sep 2026 18:15:10 +0800, Henry Tseng wrote:
> xhci_reset() returns 0 when the host is not halted, without ever writing
> CMD_RESET. Every other path that fails to reset the host returns an
> error, so callers that check the return value are told the reset
> succeeded on the one path where it did not happen.
> 
> Return -EBUSY when the reset is aborted because the host is not halted.
> 
> Signed-off-by: Henry Tseng <henrytseng@qnap.com>
> ---
>  drivers/usb/host/xhci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index a9e47e178c28..2af6a7b91e55 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -195,7 +195,7 @@ int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us)
>  
>  	if ((state & STS_HALT) == 0) {
>  		xhci_warn(xhci, "Host controller not halted, aborting reset.\n");
> -		return 0;
> +		return -EBUSY;

That's probably how it should be, but I wonder how did you find this
bug and are you aware of any cases where it makes a difference?

There is apparently one caller (xhci_resume()) which cares about
xhci_reset() return value but not about the preceding xhci_halt().
 
>  	}
>  
>  	xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Reset the HC");
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-02 11:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02 10:15 [PATCH] usb: xhci: return an error if the host is not halted Henry Tseng
2026-09-02 11:50 ` Michal Pecio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox