usb: retry reset if a device times out
Subsystems (2)
PATCH 1/1 usb: retry reset if a device times out
Some devices I got show an inability to operate right after power on if they are already connected. They are beyond recovery if the descriptors are requested multiple times. So in case of a timeout we rather bail early and reset again.
This patch is a rework of a patch that fell through the cracks.
http://www.spinics.net/lists/linux-usb/msg103263.html
--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/core/hub.c +6 -1
@@ -4496,7 +4496,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, r = -EPROTO ;break ; } -if (r ==0 ) +/* +* Some devices time out if they are powered on +* when already connected. They need a second +* reset. +*/ +if (r ==0 || r == -ETIMEDOUT )break ; } udev->descriptor.bMaxPacketSize0 =
Signature · 1 line
2.1.4
Quoted 23 lines · Oliver Neukum
Some devices I got show an inability to operate right after power on if they are already connected. They are beyond recovery if the descriptors are requested multiple times. So in case of a timeout we rather bail early and reset again.
This patch is a rework of a patch that fell through the cracks.
http://www.spinics.net/lists/linux-usb/msg103263.htmlSigned-off-by Oliver Neukum <[email protected]>--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/core/hub.c +0
-0@@ -4496,7 +4496,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, r = -EPROTO ;break ; }
drivers/usb/core/hub.c hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, · line 4507
Quoted 10 lines
drivers/usb/core/hub.c +6
-1-if (r ==0 ) +/* +* Some devices time out if they are powered on +* when already connected. They need a second +* reset. +*/ +if (r ==0 || r == -ETIMEDOUT )break ; } udev->descriptor.bMaxPacketSize0 =
Hmmm. Your device fails completely if there are multiple attempts without a reset in between, right?
What about devices which always time out the first control request after a reset? I can't be certain any such devices exist, but it wouldn't be surprising given the range of hardware bugs in USB devices.
Would it be safer to do this instead?
if (r == 0 || (r == -ETIMEDOUT && j = 0)) break;
Alan Stern
Quoted 43 lines · Alan Stern
Quoted 23 lines · Oliver Neukum
Some devices I got show an inability to operate right after power on if they are already connected. They are beyond recovery if the descriptors are requested multiple times. So in case of a timeout we rather bail early and reset again.
This patch is a rework of a patch that fell through the cracks.
http://www.spinics.net/lists/linux-usb/msg103263.htmlSigned-off-by Oliver Neukum <[email protected]>--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/core/hub.c +0
-0@@ -4496,7 +4496,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, r = -EPROTO ;break ; }drivers/usb/core/hub.c hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, · line 4507
Quoted 10 lines
drivers/usb/core/hub.c +6
-1-if (r ==0 ) +/* +* Some devices time out if they are powered on +* when already connected. They need a second +* reset. +*/ +if (r ==0 || r == -ETIMEDOUT )break ; } udev->descriptor.bMaxPacketSize0 =Hmmm. Your device fails completely if there are multiple attempts without a reset in between, right?
What about devices which always time out the first control request after a reset? I can't be certain any such devices exist, but it wouldn't be surprising given the range of hardware bugs in USB devices.
Quoted 5 lines
Would it be safer to do this instead?
if (r == 0 || (r == -ETIMEDOUT && j = 0)) break;
Indeed. Greg, I'll make an improved patch.
Regards
Oliver
Quoted 43 lines · Alan Stern
Quoted 23 lines · Oliver Neukum
Some devices I got show an inability to operate right after power on if they are already connected. They are beyond recovery if the descriptors are requested multiple times. So in case of a timeout we rather bail early and reset again.
This patch is a rework of a patch that fell through the cracks.
http://www.spinics.net/lists/linux-usb/msg103263.htmlSigned-off-by Oliver Neukum <[email protected]>--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/core/hub.c +0
-0@@ -4496,7 +4496,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, r = -EPROTO ;break ; }drivers/usb/core/hub.c hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, · line 4507
Quoted 10 lines
drivers/usb/core/hub.c +6
-1-if (r ==0 ) +/* +* Some devices time out if they are powered on +* when already connected. They need a second +* reset. +*/ +if (r ==0 || r == -ETIMEDOUT )break ; } udev->descriptor.bMaxPacketSize0 =Hmmm. Your device fails completely if there are multiple attempts without a reset in between, right?
What about devices which always time out the first control request after a reset? I can't be certain any such devices exist, but it wouldn't be surprising given the range of hardware bugs in USB devices.
Quoted 6 lines
Would it be safer to do this instead?
if (r == 0 || (r == -ETIMEDOUT && j = 0)) break;
Alan, you may want to skip the first timeout, but quit at the second timeout, right? If it is, the code may need to change like below:
if (r == 0 || (r == -ETIMEDOUT &&
j != 0))
Signature · 2 lines
Best Regards, Peter Chen
Quoted 46 lines · Peter Chen
Quoted 45 lines · Alan Stern
Quoted 23 lines · Oliver Neukum
Some devices I got show an inability to operate right after power on if they are already connected. They are beyond recovery if the descriptors are requested multiple times. So in case of a timeout we rather bail early and reset again.
This patch is a rework of a patch that fell through the cracks.
http://www.spinics.net/lists/linux-usb/msg103263.htmlSigned-off-by Oliver Neukum <[email protected]>--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/core/hub.c +0
-0@@ -4496,7 +4496,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, r = -EPROTO ;break ; }drivers/usb/core/hub.c hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, · line 4507
Quoted 10 lines
drivers/usb/core/hub.c +6
-1-if (r ==0 ) +/* +* Some devices time out if they are powered on +* when already connected. They need a second +* reset. +*/ +if (r ==0 || r == -ETIMEDOUT )break ; } udev->descriptor.bMaxPacketSize0 =Hmmm. Your device fails completely if there are multiple attempts without a reset in between, right?
What about devices which always time out the first control request after a reset? I can't be certain any such devices exist, but it wouldn't be surprising given the range of hardware bugs in USB devices.
Would it be safer to do this instead?
Quoted 7 lines
Quoted 4 lines
if (r == 0 || (r == -ETIMEDOUT && j = 0)) break;Alan, you may want to skip the first timeout, but quit at the second timeout, right? If it is, the code may need to change like below:
No. If it times out immediately you want a second reset. If it times out any time after that you want a retry of reading the descriptors.
Regards
Oliver
Quoted 52 lines · Oliver Neukum
Quoted 51 lines · Peter Chen
Quoted 49 lines · Alan Stern
Quoted 23 lines · Oliver Neukum
Some devices I got show an inability to operate right after power on if they are already connected. They are beyond recovery if the descriptors are requested multiple times. So in case of a timeout we rather bail early and reset again.
This patch is a rework of a patch that fell through the cracks.
http://www.spinics.net/lists/linux-usb/msg103263.htmlSigned-off-by Oliver Neukum <[email protected]>--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/core/hub.c +0
-0@@ -4496,7 +4496,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, r = -EPROTO ;break ; }drivers/usb/core/hub.c hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, · line 4507
Quoted 10 lines
drivers/usb/core/hub.c +6
-1-if (r ==0 ) +/* +* Some devices time out if they are powered on +* when already connected. They need a second +* reset. +*/ +if (r ==0 || r == -ETIMEDOUT )break ; } udev->descriptor.bMaxPacketSize0 =Hmmm. Your device fails completely if there are multiple attempts without a reset in between, right?
What about devices which always time out the first control request after a reset? I can't be certain any such devices exist, but it wouldn't be surprising given the range of hardware bugs in USB devices.
Would it be safer to do this instead?
if (r == 0 || (r == -ETIMEDOUT && j = 0)) break;
Quoted 6 lines
Quoted 2 lines
Alan, you may want to skip the first timeout, but quit at the second timeout, right? If it is, the code may need to change like below:
No. If it times out immediately you want a second reset. If it times out any time after that you want a retry of reading the descriptors.
But from what I see, Alan wants to cover the device which the first control request has failed due to timeout, but the second retry may succeed.
Signature · 2 lines
Best Regards, Peter Chen
Quoted 56 lines · Peter Chen
Quoted 55 lines · Oliver Neukum
Quoted 53 lines · Peter Chen
Quoted 43 lines · Alan Stern
Quoted 23 lines · Oliver Neukum
Some devices I got show an inability to operate right after power on if they are already connected. They are beyond recovery if the descriptors are requested multiple times. So in case of a timeout we rather bail early and reset again.
This patch is a rework of a patch that fell through the cracks.
http://www.spinics.net/lists/linux-usb/msg103263.htmlSigned-off-by Oliver Neukum <[email protected]>--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/core/hub.c +0
-0@@ -4496,7 +4496,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, r = -EPROTO ;break ; }drivers/usb/core/hub.c hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, · line 4507
Quoted 10 lines
drivers/usb/core/hub.c +6
-1-if (r ==0 ) +/* +* Some devices time out if they are powered on +* when already connected. They need a second +* reset. +*/ +if (r ==0 || r == -ETIMEDOUT )break ; } udev->descriptor.bMaxPacketSize0 =Hmmm. Your device fails completely if there are multiple attempts without a reset in between, right?
What about devices which always time out the first control request after a reset? I can't be certain any such devices exist, but it wouldn't be surprising given the range of hardware bugs in USB devices.
Quoted 6 lines
Would it be safer to do this instead?
if (r == 0 || (r == -ETIMEDOUT && j = 0)) break;Alan, you may want to skip the first timeout, but quit at the second timeout, right? If it is, the code may need to change like below:
Quoted 6 lines
Quoted 3 lines
No. If it times out immediately you want a second reset. If it times out any time after that you want a retry of reading the descriptors.
But from what I see, Alan wants to cover the device which the first control request has failed due to timeout, but the second retry may succeed.
Exactly. On the other hand we have devices which are "dazed" upon being powered and need a reset after the first time out. I think I see the problem now. The test is incorrect and should be r == -ETIMEDOUT && i == 0
as we need to check the outer loop
Regards
Oliver
Quoted 61 lines · Oliver Neukum
Quoted 60 lines · Peter Chen
Quoted 58 lines · Oliver Neukum
Quoted 46 lines · Peter Chen
Quoted 45 lines · Alan Stern
Quoted 23 lines · Oliver Neukum
Some devices I got show an inability to operate right after power on if they are already connected. They are beyond recovery if the descriptors are requested multiple times. So in case of a timeout we rather bail early and reset again.
This patch is a rework of a patch that fell through the cracks.
http://www.spinics.net/lists/linux-usb/msg103263.htmlSigned-off-by Oliver Neukum <[email protected]>--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/core/hub.c +0
-0@@ -4496,7 +4496,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, r = -EPROTO ;break ; }drivers/usb/core/hub.c hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, · line 4507
Quoted 10 lines
drivers/usb/core/hub.c +6
-1-if (r ==0 ) +/* +* Some devices time out if they are powered on +* when already connected. They need a second +* reset. +*/ +if (r ==0 || r == -ETIMEDOUT )break ; } udev->descriptor.bMaxPacketSize0 =Hmmm. Your device fails completely if there are multiple attempts without a reset in between, right?
What about devices which always time out the first control request after a reset? I can't be certain any such devices exist, but it wouldn't be surprising given the range of hardware bugs in USB devices.
Would it be safer to do this instead?
Quoted 7 lines
Quoted 4 lines
if (r == 0 || (r == -ETIMEDOUT && j = 0)) break;Alan, you may want to skip the first timeout, but quit at the second timeout, right? If it is, the code may need to change like below:
No. If it times out immediately you want a second reset. If it times out any time after that you want a retry of reading the descriptors.
Quoted 8 lines
Quoted 2 lines
But from what I see, Alan wants to cover the device which the first control request has failed due to timeout, but the second retry may succeed.
Exactly. On the other hand we have devices which are "dazed" upon being powered and need a reset after the first time out. I think I see the problem now. The test is incorrect and should be r ==
-ETIMEDOUT&& i == 0
as we need to check the outer loop
Right; I carelessly used the wrong loop variable. We should break out of the inner loop early if a timeout occurs during the first iteration of the outer loop.
Alan Stern
Quoted 72 lines · Alan Stern
Quoted 61 lines · Oliver Neukum
Quoted 60 lines · Peter Chen
Quoted 58 lines · Oliver Neukum
Quoted 46 lines · Peter Chen
Quoted 45 lines · Alan Stern
Quoted 23 lines · Oliver Neukum
Some devices I got show an inability to operate right after power on if they are already connected. They are beyond recovery if the descriptors are requested multiple times. So in case of a timeout we rather bail early and reset again.
This patch is a rework of a patch that fell through the cracks.
http://www.spinics.net/lists/linux-usb/msg103263.htmlSigned-off-by Oliver Neukum <[email protected]>--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/core/hub.c +0
-0@@ -4496,7 +4496,12 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, r = -EPROTO ;break ; }drivers/usb/core/hub.c hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, · line 4507
Quoted 10 lines
drivers/usb/core/hub.c +6
-1-if (r ==0 ) +/* +* Some devices time out if they are powered on +* when already connected. They need a second +* reset. +*/ +if (r ==0 || r == -ETIMEDOUT )break ; } udev->descriptor.bMaxPacketSize0 =Hmmm. Your device fails completely if there are multiple attempts without a reset in between, right?
What about devices which always time out the first control request after a reset? I can't be certain any such devices exist, but it wouldn't be surprising given the range of hardware bugs in USB devices.
Would it be safer to do this instead?
Quoted 7 lines
Quoted 4 lines
if (r == 0 || (r == -ETIMEDOUT && j = 0)) break;Alan, you may want to skip the first timeout, but quit at the second timeout, right? If it is, the code may need to change like below:
No. If it times out immediately you want a second reset. If it times out any time after that you want a retry of reading the descriptors.
Quoted 8 lines
Quoted 2 lines
But from what I see, Alan wants to cover the device which the first control request has failed due to timeout, but the second retry may succeed.
Exactly. On the other hand we have devices which are "dazed" upon being powered and need a reset after the first time out. I think I see the problem now. The test is incorrect and should be r ==
-ETIMEDOUT&& i == 0
as we need to check the outer loop
Quoted 4 lines
Right; I carelessly used the wrong loop variable. We should break out of the inner loop early if a timeout occurs during the first iteration of the outer loop.
I agree, that can reduce the waiting time from 15s to 5s for broken device or buggy controller if bus reset can recover.
Signature · 2 lines
Best Regards, Peter Chen