Skip to contentSkip to conversation

usb bug fixes

PATCH New Nikita Kiryanov 2 participants 4 messages Jul 29, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover usb bug fixes

This series contains two usb related bug fixes, one regarding the power cycling of hub ports, and the other- a memory leak in ehci-hcd.

Cc Marek Vasut <[email protected]>
Cc Igor Grinberg <[email protected]>

Nikita Kiryanov (2):
usb_hub: fix power cycling logic
ehci-hcd: fix memory leak in lowlevel init

 common/usb_hub.c            | 4 ++--
 drivers/usb/host/ehci-hcd.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/2 usb_hub: fix power cycling logic

When power cycling the hub ports, a misbehaving port will prevent all ports from being powered on because we quit at the first sign of trouble.

Skip problematic ports instead of failing the entire power on.

Cc Marek Vasut <[email protected]>
Cc Igor Grinberg <[email protected]>
---
 common/usb_hub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/usb_hub.c +2 -2
index 754d436..a11b401 100644
@@ -110,7 +110,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
 		ret = usb_get_port_status(dev, i + 1, portsts);
 		if (ret < 0) {
 			debug("port %d: get_port_status failed\n", i + 1);
-			return;
+			continue;
 		}
 
 		/*
@@ -125,7 +125,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
 		portstatus = le16_to_cpu(portsts->wPortStatus);
 		if (portstatus & (USB_PORT_STAT_POWER << 1)) {
 			debug("port %d: Port power change failed\n", i + 1);
-			return;
+			continue;
 		}
 	}
 
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH 2/2 ehci-hcd: fix memory leak in lowlevel init

In reply to Nikita Kiryanov

usb_lowlevel_init() allocates a new periodic_list each time it is invoked, without freeing the original list. Since it is initialized later on in the code, just reuse the first-allocated list in future invocations of usb_lowlevel_init.

Cc Marek Vasut <[email protected]>
Cc Igor Grinberg <[email protected]>
---
 drivers/usb/host/ehci-hcd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/ehci-hcd.c +3 -1
index 706cf0c..eab1046 100644
@@ -954,7 +954,9 @@ int usb_lowlevel_init(int index, void **controller)
 	 *         Split Transactions will be spread across microframes using
 	 *         S-mask and C-mask.
 	 */
-	ehcic[index].periodic_list = memalign(4096, 1024*4);
+	if (ehcic[index].periodic_list == NULL)
+		ehcic[index].periodic_list = memalign(4096, 1024 * 4);
+
 	if (!ehcic[index].periodic_list)
 		return -ENOMEM;
 	for (i = 0; i < 1024; i++) {
Signature · 1 line
1.8.1.2
Applied
#3 lore raw

cover usb bug fixes

In reply to Nikita Kiryanov

Dear Nikita Kiryanov,

Quoted 6 lines

This series contains two usb related bug fixes, one regarding the power cycling of hub ports, and the other- a memory leak in ehci-hcd.

Cc Marek Vasut <[email protected]>
Cc Igor Grinberg <[email protected]>
Quoted 7 lines

Nikita Kiryanov (2):
usb_hub: fix power cycling logic
ehci-hcd: fix memory leak in lowlevel init

 common/usb_hub.c            | 4 ++--
 drivers/usb/host/ehci-hcd.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

Applied both, thanks!

Best regards,
Marek Vasut