* [PATCH] usb: xhci: print xhci->xhc_state when queue_command failed
@ 2025-07-25 3:13 Su Hui
2025-07-25 4:43 ` Greg KH
2025-07-25 6:01 ` [PATCH v2] " Su Hui
0 siblings, 2 replies; 8+ messages in thread
From: Su Hui @ 2025-07-25 3:13 UTC (permalink / raw)
To: mathias.nyman, gregkh; +Cc: Su Hui, linux-usb, linux-kernel, kernel-janitors
When encounters some errors like these:
xhci_hcd 0000:4a:00.2: xHCI dying or halted, can't queue_command
xhci_hcd 0000:4a:00.2: FIXME: allocate a command ring segment
usb usb5-port6: couldn't allocate usb_device
It's hard to know whether xhc_state is dying or halted. So it's better
to print xhc_state's value which can help locate the resaon of the bug.
Signed-off-by: Su Hui <suhui@nfschina.com>
---
drivers/usb/host/xhci-ring.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 94c9c9271658..a1a628e849c0 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -4372,7 +4372,8 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
if ((xhci->xhc_state & XHCI_STATE_DYING) ||
(xhci->xhc_state & XHCI_STATE_HALTED)) {
- xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n");
+ xhci_dbg(xhci, "xHCI dying or halted, can't queue_command. state: %u\n",
+ xhci->xhc_state);
return -ESHUTDOWN;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] usb: xhci: print xhci->xhc_state when queue_command failed
2025-07-25 3:13 [PATCH] usb: xhci: print xhci->xhc_state when queue_command failed Su Hui
@ 2025-07-25 4:43 ` Greg KH
2025-07-25 5:11 ` Su Hui
2025-07-25 6:01 ` [PATCH v2] " Su Hui
1 sibling, 1 reply; 8+ messages in thread
From: Greg KH @ 2025-07-25 4:43 UTC (permalink / raw)
To: Su Hui; +Cc: mathias.nyman, linux-usb, linux-kernel, kernel-janitors
On Fri, Jul 25, 2025 at 11:13:09AM +0800, Su Hui wrote:
> When encounters some errors like these:
> xhci_hcd 0000:4a:00.2: xHCI dying or halted, can't queue_command
> xhci_hcd 0000:4a:00.2: FIXME: allocate a command ring segment
> usb usb5-port6: couldn't allocate usb_device
>
> It's hard to know whether xhc_state is dying or halted. So it's better
> to print xhc_state's value which can help locate the resaon of the bug.
>
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
> drivers/usb/host/xhci-ring.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index 94c9c9271658..a1a628e849c0 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -4372,7 +4372,8 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
>
> if ((xhci->xhc_state & XHCI_STATE_DYING) ||
> (xhci->xhc_state & XHCI_STATE_HALTED)) {
> - xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n");
> + xhci_dbg(xhci, "xHCI dying or halted, can't queue_command. state: %u\n",
> + xhci->xhc_state);
Don't you want to see this value in hex?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] usb: xhci: print xhci->xhc_state when queue_command failed
2025-07-25 4:43 ` Greg KH
@ 2025-07-25 5:11 ` Su Hui
0 siblings, 0 replies; 8+ messages in thread
From: Su Hui @ 2025-07-25 5:11 UTC (permalink / raw)
To: Greg KH; +Cc: mathias.nyman, linux-usb, linux-kernel, kernel-janitors, Su Hui
On 2025/7/25 12:43, Greg KH wrote:
> On Fri, Jul 25, 2025 at 11:13:09AM +0800, Su Hui wrote:
>> When encounters some errors like these:
>> xhci_hcd 0000:4a:00.2: xHCI dying or halted, can't queue_command
>> xhci_hcd 0000:4a:00.2: FIXME: allocate a command ring segment
>> usb usb5-port6: couldn't allocate usb_device
>>
>> It's hard to know whether xhc_state is dying or halted. So it's better
>> to print xhc_state's value which can help locate the resaon of the bug.
>>
>> Signed-off-by: Su Hui <suhui@nfschina.com>
>> ---
>> drivers/usb/host/xhci-ring.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
>> index 94c9c9271658..a1a628e849c0 100644
>> --- a/drivers/usb/host/xhci-ring.c
>> +++ b/drivers/usb/host/xhci-ring.c
>> @@ -4372,7 +4372,8 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
>>
>> if ((xhci->xhc_state & XHCI_STATE_DYING) ||
>> (xhci->xhc_state & XHCI_STATE_HALTED)) {
>> - xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n");
>> + xhci_dbg(xhci, "xHCI dying or halted, can't queue_command. state: %u\n",
>> + xhci->xhc_state);
> Don't you want to see this value in hex?
yes, hex is better, will update in v2 soon.
Su Hui
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] usb: xhci: print xhci->xhc_state when queue_command failed
2025-07-25 3:13 [PATCH] usb: xhci: print xhci->xhc_state when queue_command failed Su Hui
2025-07-25 4:43 ` Greg KH
@ 2025-07-25 6:01 ` Su Hui
2025-07-25 8:50 ` Greg KH
2025-07-25 10:03 ` Michał Pecio
1 sibling, 2 replies; 8+ messages in thread
From: Su Hui @ 2025-07-25 6:01 UTC (permalink / raw)
To: mathias.nyman, gregkh; +Cc: Su Hui, linux-usb, linux-kernel, kernel-janitors
When encounters some errors like these:
xhci_hcd 0000:4a:00.2: xHCI dying or halted, can't queue_command
xhci_hcd 0000:4a:00.2: FIXME: allocate a command ring segment
usb usb5-port6: couldn't allocate usb_device
It's hard to know whether xhc_state is dying or halted. So it's better
to print xhc_state's value which can help locate the resaon of the bug.
Signed-off-by: Su Hui <suhui@nfschina.com>
---
v2:
- Print xhci->xhc_state with hex style.
drivers/usb/host/xhci-ring.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 94c9c9271658..131e7530ec4a 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -4372,7 +4372,8 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
if ((xhci->xhc_state & XHCI_STATE_DYING) ||
(xhci->xhc_state & XHCI_STATE_HALTED)) {
- xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n");
+ xhci_dbg(xhci, "xHCI dying or halted, can't queue_command. state: 0x%x\n",
+ xhci->xhc_state);
return -ESHUTDOWN;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v2] usb: xhci: print xhci->xhc_state when queue_command failed
2025-07-25 6:01 ` [PATCH v2] " Su Hui
@ 2025-07-25 8:50 ` Greg KH
2025-07-25 10:03 ` Michał Pecio
1 sibling, 0 replies; 8+ messages in thread
From: Greg KH @ 2025-07-25 8:50 UTC (permalink / raw)
To: Su Hui; +Cc: mathias.nyman, linux-usb, linux-kernel, kernel-janitors
On Fri, Jul 25, 2025 at 02:01:18PM +0800, Su Hui wrote:
> When encounters some errors like these:
> xhci_hcd 0000:4a:00.2: xHCI dying or halted, can't queue_command
> xhci_hcd 0000:4a:00.2: FIXME: allocate a command ring segment
> usb usb5-port6: couldn't allocate usb_device
>
> It's hard to know whether xhc_state is dying or halted. So it's better
> to print xhc_state's value which can help locate the resaon of the bug.
>
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
> v2:
> - Print xhci->xhc_state with hex style.
>
> drivers/usb/host/xhci-ring.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index 94c9c9271658..131e7530ec4a 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -4372,7 +4372,8 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
>
> if ((xhci->xhc_state & XHCI_STATE_DYING) ||
> (xhci->xhc_state & XHCI_STATE_HALTED)) {
> - xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n");
> + xhci_dbg(xhci, "xHCI dying or halted, can't queue_command. state: 0x%x\n",
> + xhci->xhc_state);
> return -ESHUTDOWN;
> }
>
> --
> 2.30.2
>
Simple enough, let me take this now as I want to close my tree...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2] usb: xhci: print xhci->xhc_state when queue_command failed
2025-07-25 6:01 ` [PATCH v2] " Su Hui
2025-07-25 8:50 ` Greg KH
@ 2025-07-25 10:03 ` Michał Pecio
2025-07-25 11:32 ` Su Hui
1 sibling, 1 reply; 8+ messages in thread
From: Michał Pecio @ 2025-07-25 10:03 UTC (permalink / raw)
To: Su Hui; +Cc: mathias.nyman, gregkh, linux-usb, linux-kernel, kernel-janitors
Hi,
On Fri, 25 Jul 2025 14:01:18 +0800, Su Hui wrote:
> When encounters some errors like these:
> xhci_hcd 0000:4a:00.2: xHCI dying or halted, can't queue_command
> xhci_hcd 0000:4a:00.2: FIXME: allocate a command ring segment
> usb usb5-port6: couldn't allocate usb_device
>
> It's hard to know whether xhc_state is dying or halted.
Is it truly a problem? This is the only place which sets
XHCI_STATE_DYING that I found in the whole drivers/ tree:
xhci_err(xhci, "xHCI host controller not responding, assume dead\n");
xhci->xhc_state |= XHCI_STATE_DYING;
And AFAIK such state can only be exited by unbinding the driver.
Are there really cases when it's unclear if the HC is dying or not?
> So it's better to print xhc_state's value which can help locate the
> resaon of the bug.
Hmm, any chance you came across bugs that upstream should know about?
Regards,
Michal
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2] usb: xhci: print xhci->xhc_state when queue_command failed
2025-07-25 10:03 ` Michał Pecio
@ 2025-07-25 11:32 ` Su Hui
2025-07-26 9:11 ` Michał Pecio
0 siblings, 1 reply; 8+ messages in thread
From: Su Hui @ 2025-07-25 11:32 UTC (permalink / raw)
To: Michał Pecio
Cc: mathias.nyman, gregkh, Su Hui, linux-usb, linux-kernel,
kernel-janitors
On 2025/7/25 18:03, Michał Pecio wrote:
> Hi,
>
> On Fri, 25 Jul 2025 14:01:18 +0800, Su Hui wrote:
>> When encounters some errors like these:
>> xhci_hcd 0000:4a:00.2: xHCI dying or halted, can't queue_command
>> xhci_hcd 0000:4a:00.2: FIXME: allocate a command ring segment
>> usb usb5-port6: couldn't allocate usb_device
>>
>> It's hard to know whether xhc_state is dying or halted.
> Is it truly a problem? This is the only place which sets
> XHCI_STATE_DYING that I found in the whole drivers/ tree:
>
> xhci_err(xhci, "xHCI host controller not responding, assume dead\n");
> xhci->xhc_state |= XHCI_STATE_DYING;
>
> And AFAIK such state can only be exited by unbinding the driver.
> Are there really cases when it's unclear if the HC is dying or not?
Oh, my fault, I ignored this so obvious error message. :(.
Sorry for the noise, Maybe this patch should be removed.
>
>> So it's better to print xhc_state's value which can help locate the
>> resaon of the bug.
>>
>> Hmm, any chance you came across bugs that upstream should know about?
Actually, this bug is specific to the 5.4 version of the kernel and a
particular USB camera. I am working
to resolve this issue. When the xhci_hcd is initialized, the driver sets
xhc_state to "halted", but before
the xhci_hcd calls xhci_start, the hub starts Initializing. Hub
initialization failed due to xhc_state being
halted. Perhaps this issue is caused by hardware...
Su Hui
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] usb: xhci: print xhci->xhc_state when queue_command failed
2025-07-25 11:32 ` Su Hui
@ 2025-07-26 9:11 ` Michał Pecio
0 siblings, 0 replies; 8+ messages in thread
From: Michał Pecio @ 2025-07-26 9:11 UTC (permalink / raw)
To: Su Hui; +Cc: mathias.nyman, gregkh, linux-usb, linux-kernel, kernel-janitors
On Fri, 25 Jul 2025 19:32:37 +0800, Su Hui wrote:
> On 2025/7/25 18:03, Michał Pecio wrote:
> >> Hmm, any chance you came across bugs that upstream should know about?
> Actually, this bug is specific to the 5.4 version of the kernel and a
> particular USB camera. I am working
> to resolve this issue. When the xhci_hcd is initialized, the driver sets
> xhc_state to "halted", but before
> the xhci_hcd calls xhci_start, the hub starts Initializing. Hub
> initialization failed due to xhc_state being
> halted. Perhaps this issue is caused by hardware...
Trying to queue commands before the chip is ready sounds like a SW bug.
5.4 is ancient (and EOL soon), newer releases may have this bug fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-07-26 9:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 3:13 [PATCH] usb: xhci: print xhci->xhc_state when queue_command failed Su Hui
2025-07-25 4:43 ` Greg KH
2025-07-25 5:11 ` Su Hui
2025-07-25 6:01 ` [PATCH v2] " Su Hui
2025-07-25 8:50 ` Greg KH
2025-07-25 10:03 ` Michał Pecio
2025-07-25 11:32 ` Su Hui
2025-07-26 9:11 ` Michał Pecio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox