Skip to contentSkip to conversation

usbatm: Detect usb device shutdown and ignore failed urbs.

PATCH In review Simon Arlott 4 participants 7 messages Feb 21, 2007 – Feb 23, 2007

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

PATCH 2/2 usbatm: Detect usb device shutdown and ignore failed urbs.

Detect usb device shutdown and ignore failed urbs. This happens when the driver is unloaded or the device is unplugged.

---
 drivers/usb/atm/usbatm.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/usb/atm/usbatm.c +4 -0
index 83cea01..1f5faee 100644
@@ -274,6 +274,10 @@ static void usbatm_complete(struct urb *
 			(!(channel->usbatm->flags & UDSL_IGNORE_EILSEQ) ||
 			 urb->status != -EILSEQ ))
 	{
+		/* the module/device has probably been removed */
+		if (urb->status == -ESHUTDOWN)
+			return;
+
 		if (printk_ratelimit())
 			atm_warn(channel->usbatm, "%s: urb 0x%p failed (%d)!\n",
 				__func__, urb, urb->status);
Signature · 5 lines
1.4.3.1


-- 
Simon Arlott
#1 lore raw

drivers/usb/atm/usbatm.c static void usbatm_complete(struct urb * · line 283

Quoted 7 lines
drivers/usb/atm/usbatm.c +4 -0
+		/* the module/device has probably been removed */
+		if (urb->status == -ESHUTDOWN)
+			return;
+
 		if (printk_ratelimit())
 			atm_warn(channel->usbatm, "%s: urb 0x%p failed (%d)!\n",
 				__func__, urb, urb->status);

I would rather just suppress the warning in this case, and still do the delayed schedule of the tasklet, in case this error was spurious and we're not really about to be disconnected.

Ciao,

Duncan.

PS: I plan to work on the drivers this weekend.

#2 lore raw
Quoted 11 lines · Duncan Sands

drivers/usb/atm/usbatm.c static void usbatm_complete(struct urb * · line 283

Quoted 7 lines
drivers/usb/atm/usbatm.c +4 -0
+		/* the module/device has probably been removed */
+		if (urb->status == -ESHUTDOWN)
+			return;
+
 		if (printk_ratelimit())
 			atm_warn(channel->usbatm, "%s: urb 0x%p failed (%d)!\n",
 				__func__, urb, urb->status);

I would rather just suppress the warning in this case, and still do the delayed schedule of the tasklet, in case this error was spurious and we're not really about to be disconnected.

I disagree. If ESHUTDOWN is received, the endpoint is definitely gone. I can see why you might want to retry EPROTO, ELISEQ, etc. but this case is different.

-- Pete

#3 lore raw

Hi Pete,

Quoted 13 lines · On Friday 23 February 2007 00:53:18 Pete Zaitcev wrote:
Quoted 11 lines · Duncan Sands

drivers/usb/atm/usbatm.c static void usbatm_complete(struct urb * · line 283

Quoted 7 lines
drivers/usb/atm/usbatm.c +4 -0
+		/* the module/device has probably been removed */
+		if (urb->status == -ESHUTDOWN)
+			return;
+
 		if (printk_ratelimit())
 			atm_warn(channel->usbatm, "%s: urb 0x%p failed (%d)!\n",
 				__func__, urb, urb->status);

I would rather just suppress the warning in this case, and still do the delayed schedule of the tasklet, in case this error was spurious and we're not really about to be disconnected.

Quoted 3 lines

I disagree. If ESHUTDOWN is received, the endpoint is definitely gone. I can see why you might want to retry EPROTO, ELISEQ, etc. but this case is different.

if you get ESHUTDOWN, does that mean that you are about to be disconnected, i.e. the disconnect method is about to be called? Or is it possible for the device to just sit there disabled, but not disconnected?

Thanks,

Duncan.

#4 lore raw
Quoted 3 lines · Duncan Sands

if you get ESHUTDOWN, does that mean that you are about to be disconnected, i.e. the disconnect method is about to be called? Or is it possible for the device to just sit there disabled, but not disconnected?

It is possible to receive ESHUTDOWN without being disconnected. For instance, a race with suspend could cause it to happen (although if your driver is written correctly that race should never occur). Another more likely scenario is that you have an active URB while calling usb_set_interface(); the endpoints for the old altsetting get disabled and the URB returns with an ESHUTDOWN error.

Alan Stern

#5 lore raw
Quoted 6 lines · On Friday 23 February 2007 17:16:24 Alan Stern wrote:
Quoted 3 lines · Duncan Sands

if you get ESHUTDOWN, does that mean that you are about to be disconnected, i.e. the disconnect method is about to be called? Or is it possible for the device to just sit there disabled, but not disconnected?

Quoted 6 lines

It is possible to receive ESHUTDOWN without being disconnected. For instance, a race with suspend could cause it to happen (although if your driver is written correctly that race should never occur). Another more likely scenario is that you have an active URB while calling usb_set_interface(); the endpoints for the old altsetting get disabled and the URB returns with an ESHUTDOWN error.

Thanks Alan. The original question was: if an urb fails with an error, is there any point in resubmitting it after a delay (which is what the driver usually does) if the error was -ESHUTDOWN? It sounds like there is no point to it. And if the device is not disconnected, then it could even be harmful since the urb will be resubmitted endlessly... While on the topic, are there any other error codes for which an urb should not be resubmitted?

Thanks again,

Duncan.

#6 lore raw
Quoted 4 lines · Duncan Sands

Thanks Alan. The original question was: if an urb fails with an error, is there any point in resubmitting it after a delay (which is what the driver usually does) if the error was -ESHUTDOWN? It sounds like there is no point to it.

No, there isn't.

Quoted 4 lines

And if the device is not disconnected, then it could
even be harmful since the urb will be resubmitted endlessly... While on the topic, are there any other error codes for which an urb should not be resubmitted?

Let's see... ENOENT and ECONNRESET indicate the URB was unlinked, so you probably don't want to resubmit it. EPIPE indicates a problem on the device end, so you would want to fix the problem before resubmitting (at the very least you would want to clear the halt). EOVERFLOW is questionable; if the device sent too much data once then it might do so again. Ditto for EREMOTEIO (the device sent too little data). ENODEV means the device was removed, so you definitely don't want to resubmit.

Alan Stern