Re: USB issue on a TB4 controller?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 30.5.2023 15.40, Christian Schaubschläger wrote:
Sorry, wrong email format :-/

Christian


Am 30.05.23 um 14:38 schrieb Christian Schaubschläger:
Hi,

[    0.029711] Kernel command line: bzImage.efi thunderbolt.dyndbg=+p trace_event=xhci-hcd root=PARTUUID=1761F245-C668-41F5-90E4-5BBF2224097A rootwait  nomodeset ima_appraise=off
[    0.063715] Failed to enable trace event: xhci-hcd
Could be that it expects the driver to be built-in in that case.

Ah, that helps a lot, thanks! ;-)

Traces attached: one after a boot in OK state, one after a reboot in failed state, and one after reconnecting the dock's USB cable when it was in failed state before. After reconnecting the cable it works again.

Thanks and best regards,
Christian


Thanks

Looks like the hub (4-2) in the dock doesn't detect any activity on port4
where the NIC is.

Ok case:

[    2.627736] hub 4-2:1.0: 4 ports detected
[    2.628729] hub 4-2:1.0: power on to power good time: 0ms
[    2.630171] hub 4-2:1.0: enabling power on all ports
...
[    2.737142] usb 4-2-port3: status 0203 change 0010
[    2.737639] usb 4-2-port4: status 0203 change 0010
..
[    2.840430] hub 4-2:1.0: state 7 ports 4 chg 0018 evt 0000

Not ok:

[    2.622108] hub 4-2:1.0: 4 ports detected
[    2.622759] hub 4-2:1.0: power on to power good time: 0ms
[    2.623554] hub 4-2:1.0: enabling power on all ports
..
[    2.729001] usb 4-2-port3: status 0203 change 0010
...
[    2.832393] hub 4-2:1.0: state 7 ports 4 chg 0008 evt 0000


Maybe something goes wrong during link training between hub 4-2 and
the NIC at 4-2.4.

If the link immediately goes to a error state without causing a
connect change event for its port, then I guess  it's possible that hub
driver won't react to this port at all.
Attached is a patch that adds more debugging, adds a minimum
"power on to power good" delay, (as hub reports 0ms), and checks port link
states during hub initialization.

Does it help? Could you take logs with that patch applied.

Only dmesg with xhci and usbcore dynamic debug are needed.
xhci traces won't help as issue seems to be between the hub inthe dock and the NIC


diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 97a0f8faea6e..9cb238938afa 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1134,9 +1134,9 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
                if (status)
                        goto abort;
- if (udev || (portstatus & USB_PORT_STAT_CONNECTION))
-                       dev_dbg(&port_dev->dev, "status %04x change %04x\n",
-                                       portstatus, portchange);
+/*             if (udev || (portstatus & USB_PORT_STAT_CONNECTION)) */
+               dev_dbg(&port_dev->dev, "status %04x change %04x\n",
+                       portstatus, portchange);
/*
                 * After anything other than HUB_RESUME (i.e., initialization
@@ -1162,10 +1162,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
                }
/* Make sure a warm-reset request is handled by port_event */
-               if (type == HUB_RESUME &&
-                   hub_port_warm_reset_required(hub, port1, portstatus))
+               if ((type == HUB_RESUME || type == HUB_INIT2) &&
+                   hub_port_warm_reset_required(hub, port1, portstatus)) {
+                       dev_dbg(&port_dev->dev, "HUBDBG needs warm reset\n");
                        set_bit(port1, hub->event_bits);
-
+               }
                /*
                 * Add debounce if USB3 link is in polling/link training state.
                 * Link will automatically transition to Enabled state after
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index e23833562e4f..ad510dfe49e8 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -157,7 +157,7 @@ static inline unsigned hub_power_on_good_delay(struct usb_hub *hub)
        unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2;
if (!hub->hdev->parent) /* root hub */
-               return delay;
+               return max(delay, 100U);
        else /* Wait at least 100 msec for power to become stable */
                return max(delay, 100U);
 }


Thanks
Mathias
From 4f7cba98718ff1a6078f05c85a30c1036183f811 Mon Sep 17 00:00:00 2001
From: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
Date: Wed, 31 May 2023 12:24:27 +0300
Subject: [PATCH] usb: hub: add debugging and DS port link state checks during
 initialization

Force a 100ms minimum power on to power good delay for hubs to
let link trainig settle.
Show portstatus and change values for all ports during hub initialization
when debugging, not just for ports with a connect change.

Check link state for USB 3.x ports durinig hub initialization in case
any ports is stuck in SS.Inactive or compliance, and needs a warm reset
to recover. Setting the event bit for those port should be enough as port
event handler will warm reset ports in SS.Inactive or compliance state.

NOT FOR UPSTEAM, debug purpose only.

Signed-off-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
---
 drivers/usb/core/hub.c | 13 +++++++------
 drivers/usb/core/hub.h |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 97a0f8faea6e..9cb238938afa 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1134,9 +1134,9 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
 		if (status)
 			goto abort;
 
-		if (udev || (portstatus & USB_PORT_STAT_CONNECTION))
-			dev_dbg(&port_dev->dev, "status %04x change %04x\n",
-					portstatus, portchange);
+/*		if (udev || (portstatus & USB_PORT_STAT_CONNECTION)) */
+		dev_dbg(&port_dev->dev, "status %04x change %04x\n",
+			portstatus, portchange);
 
 		/*
 		 * After anything other than HUB_RESUME (i.e., initialization
@@ -1162,10 +1162,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
 		}
 
 		/* Make sure a warm-reset request is handled by port_event */
-		if (type == HUB_RESUME &&
-		    hub_port_warm_reset_required(hub, port1, portstatus))
+		if ((type == HUB_RESUME || type == HUB_INIT2) &&
+		    hub_port_warm_reset_required(hub, port1, portstatus)) {
+			dev_dbg(&port_dev->dev, "HUBDBG needs warm reset\n");
 			set_bit(port1, hub->event_bits);
-
+		}
 		/*
 		 * Add debounce if USB3 link is in polling/link training state.
 		 * Link will automatically transition to Enabled state after
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index e23833562e4f..ad510dfe49e8 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -157,7 +157,7 @@ static inline unsigned hub_power_on_good_delay(struct usb_hub *hub)
 	unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2;
 
 	if (!hub->hdev->parent)	/* root hub */
-		return delay;
+		return max(delay, 100U);
 	else /* Wait at least 100 msec for power to become stable */
 		return max(delay, 100U);
 }
-- 
2.25.1


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux