xhci: State explicitly when the controller is inaccessible

Message ID 20210518111640.243559-1-kai.heng.feng@canonical.com
State New
Headers show
Series
  • xhci: State explicitly when the controller is inaccessible
Related show

Commit Message

Kai-Heng Feng May 18, 2021, 11:16 a.m.
Sometimes the dmesg says "Controller not ready at resume" because CNR is
flagged. But what actually happens is that the whole USBSTS becomes
inaccessible, and the reason could be disabled PCI I/O space or faulty
firmware/hardware.

So state the reason explicitly to make the message more clear.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/usb/host/xhci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Mathias Nyman May 18, 2021, 12:21 p.m. | #1
On 18.5.2021 14.16, Kai-Heng Feng wrote:
> Sometimes the dmesg says "Controller not ready at resume" because CNR is
> flagged. But what actually happens is that the whole USBSTS becomes
> inaccessible, and the reason could be disabled PCI I/O space or faulty
> firmware/hardware.
> 
> So state the reason explicitly to make the message more clear.
> 
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>  drivers/usb/host/xhci.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index ca9385d22f68..0e6fbe1f4fcc 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -1117,8 +1117,9 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
>  		retval = xhci_handshake(&xhci->op_regs->status,
>  					STS_CNR, 0, 10 * 1000 * 1000);
>  		if (retval) {
> -			xhci_warn(xhci, "Controller not ready at resume %d\n",
> -				  retval);
> +			xhci_warn(xhci, "Controller is %s at resume %d\n",
> +				  retval == -ENODEV ? "inaccessible" :
> +				  "not ready", retval);

Old way did print out retval, and was greppable.
Not sure this is an improvement

-Mathias

Patch

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index ca9385d22f68..0e6fbe1f4fcc 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1117,8 +1117,9 @@  int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
 		retval = xhci_handshake(&xhci->op_regs->status,
 					STS_CNR, 0, 10 * 1000 * 1000);
 		if (retval) {
-			xhci_warn(xhci, "Controller not ready at resume %d\n",
-				  retval);
+			xhci_warn(xhci, "Controller is %s at resume %d\n",
+				  retval == -ENODEV ? "inaccessible" :
+				  "not ready", retval);
 			spin_unlock_irq(&xhci->lock);
 			return retval;
 		}