Skip to contentSkip to conversation

core: usb: ratelimit cabling message

PATCH In review Oliver Neukum 2 participants 3 messages Jun 5 – Jun 8 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 core: usb: ratelimit cabling message

If a cable is bad, it stays bad. There is no need to flood the log with messages about it. So go for a ratelimited version.

---
 drivers/usb/core/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/hub.c +1 -1
index 24960ba9caa9..5262e11c12cd 100644
@@ -3148,7 +3148,7 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
 		delay = HUB_LONG_RESET_TIME;
 	}
 
-	dev_err(&port_dev->dev, "Cannot enable. Maybe the USB cable is bad?\n");
+	dev_err_ratelimited(&port_dev->dev, "Cannot enable. Maybe the USB cable is bad?\n");
 
 done:
 	if (status == 0) {
Signature · 1 line
2.54.0
#1 lore raw
Quoted 14 lines · Oliver Neukum

If a cable is bad, it stays bad. There is no need to flood the log with messages about it. So go for a ratelimited version.

---
 drivers/usb/core/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/hub.c +0 -0
index 24960ba9caa9..5262e11c12cd 100644

drivers/usb/core/hub.c static int hub_port_reset(struct usb_hub *hub, int port1, · line 3151

Quoted 5 lines
drivers/usb/core/hub.c +1 -1
@@ -3148,7 +3148,7 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
 		delay = HUB_LONG_RESET_TIME;
 	}
 
-	dev_err(&port_dev->dev, "Cannot enable. Maybe the USB cable is bad?\n");
+	dev_err_ratelimited(&port_dev->dev, "Cannot enable. Maybe the USB cable is bad?\n");

What causes hub_port_reset() to fail repeatedly enough for this to become a flood? Is there no bug to be fixed there?

IME this message doesn't show more often than all the other noise from failing enumeration.

Quoted 6 lines
drivers/usb/core/hub.c +0 -0
 done:
 	if (status == 0) {
Signature · 1 line
2.54.0
#2 lore raw
Quoted 2 lines · Michal Pecio

What causes hub_port_reset() to fail repeatedly enough for this to become a flood? Is there no bug to be fixed there?

The cable is really quite bad. We are retrying forever. This message needs to be limited. Any other ideas?

Regards
Oliver