kernel/0074-drivers-usb-fix-getting-hub-descriptor-fail.patch
2025-01-23 12:53:06 -05:00

56 lines
1.5 KiB
Diff

From a1e78a18b999551d8283c16e7b4df4b6647917cf Mon Sep 17 00:00:00 2001
From: Shuang Liang <liangshuang@eswincomputing.com>
Date: Tue, 9 Jul 2024 09:38:51 +0800
Subject: [PATCH 074/128] drivers: usb: fix getting hub descriptor fail.
Fix the issue of hub not being able to read descriptor.
Signed-off-by: Shuang Liang <liangshuang@eswincomputing.com>
Signed-off-by: Pinkesh Vaghela <pinkesh.vaghela@einfochips.com>
---
drivers/usb/core/hub.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 0944cfae8b55..10ae308a141e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1407,6 +1407,7 @@ static int hub_configure(struct usb_hub *hub,
unsigned unit_load;
unsigned full_load;
unsigned maxchild;
+ int try_cnt = 0;
hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL);
if (!hub->buffer) {
@@ -1427,6 +1428,7 @@ static int hub_configure(struct usb_hub *hub,
goto fail;
}
+retry:
/* Request the entire hub descriptor.
* hub->descriptor can handle USB_MAXCHILDREN ports,
* but a (non-SS) hub can/will return fewer bytes here.
@@ -1446,9 +1448,15 @@ static int hub_configure(struct usb_hub *hub,
ret = -ENODEV;
goto fail;
} else if (hub->descriptor->bNbrPorts == 0) {
- message = "hub doesn't have any ports!";
- ret = -ENODEV;
- goto fail;
+ try_cnt++;
+ if (try_cnt < 10) {
+ mdelay(10);
+ goto retry;
+ } else {
+ message = "hub doesn't have any ports!";
+ ret = -ENODEV;
+ goto fail;
+ }
}
/*
--
2.47.0