LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2/2] usbatm: Detect usb device shutdown and ignore failed urbs.
@ 2007-02-21 21:39 Simon Arlott
  2007-02-22 10:43 ` Duncan Sands
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Arlott @ 2007-02-21 21:39 UTC (permalink / raw)
  To: Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 855 bytes --]

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

Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
---
 drivers/usb/atm/usbatm.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 83cea01..1f5faee 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -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);
-- 
1.4.3.1


-- 
Simon Arlott


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 829 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] usbatm: Detect usb device shutdown and ignore failed urbs.
  2007-02-21 21:39 [PATCH 2/2] usbatm: Detect usb device shutdown and ignore failed urbs Simon Arlott
@ 2007-02-22 10:43 ` Duncan Sands
  2007-02-22 23:53   ` Pete Zaitcev
  0 siblings, 1 reply; 7+ messages in thread
From: Duncan Sands @ 2007-02-22 10:43 UTC (permalink / raw)
  To: Simon Arlott; +Cc: Linux Kernel Mailing List

> +		/* 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] usbatm: Detect usb device shutdown and ignore failed urbs.
  2007-02-22 10:43 ` Duncan Sands
@ 2007-02-22 23:53   ` Pete Zaitcev
  2007-02-23  9:36     ` Duncan Sands
  0 siblings, 1 reply; 7+ messages in thread
From: Pete Zaitcev @ 2007-02-22 23:53 UTC (permalink / raw)
  To: Duncan Sands
  Cc: Simon Arlott, Linux Kernel Mailing List, zaitcev, linux-usb-devel

On Thu, 22 Feb 2007 11:43:38 +0100, Duncan Sands <duncan.sands@math.u-psud.fr> wrote:

> > +		/* 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] usbatm: Detect usb device shutdown and ignore failed urbs.
  2007-02-22 23:53   ` Pete Zaitcev
@ 2007-02-23  9:36     ` Duncan Sands
  2007-02-23 16:16       ` [linux-usb-devel] " Alan Stern
  0 siblings, 1 reply; 7+ messages in thread
From: Duncan Sands @ 2007-02-23  9:36 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: Simon Arlott, Linux Kernel Mailing List, linux-usb-devel

Hi Pete,

On Friday 23 February 2007 00:53:18 Pete Zaitcev wrote:
> On Thu, 22 Feb 2007 11:43:38 +0100, Duncan Sands <duncan.sands@math.u-psud.fr> wrote:
> > > +		/* 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.

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-usb-devel] [PATCH 2/2] usbatm: Detect usb device shutdown and ignore failed urbs.
  2007-02-23  9:36     ` Duncan Sands
@ 2007-02-23 16:16       ` Alan Stern
  2007-02-23 17:05         ` Duncan Sands
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Stern @ 2007-02-23 16:16 UTC (permalink / raw)
  To: Duncan Sands
  Cc: Pete Zaitcev, Linux Kernel Mailing List, linux-usb-devel, Simon Arlott

On Fri, 23 Feb 2007, Duncan Sands wrote:

> 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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-usb-devel] [PATCH 2/2] usbatm: Detect usb device shutdown and ignore failed urbs.
  2007-02-23 16:16       ` [linux-usb-devel] " Alan Stern
@ 2007-02-23 17:05         ` Duncan Sands
  2007-02-23 18:11           ` Alan Stern
  0 siblings, 1 reply; 7+ messages in thread
From: Duncan Sands @ 2007-02-23 17:05 UTC (permalink / raw)
  To: Alan Stern
  Cc: Pete Zaitcev, Linux Kernel Mailing List, linux-usb-devel, Simon Arlott

On Friday 23 February 2007 17:16:24 Alan Stern wrote:
> On Fri, 23 Feb 2007, Duncan Sands wrote:
> 
> > 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.

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-usb-devel] [PATCH 2/2] usbatm: Detect usb device shutdown and ignore failed urbs.
  2007-02-23 17:05         ` Duncan Sands
@ 2007-02-23 18:11           ` Alan Stern
  0 siblings, 0 replies; 7+ messages in thread
From: Alan Stern @ 2007-02-23 18:11 UTC (permalink / raw)
  To: Duncan Sands
  Cc: Pete Zaitcev, Linux Kernel Mailing List, linux-usb-devel, Simon Arlott

On Fri, 23 Feb 2007, Duncan Sands wrote:

> 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.

>  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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-02-23 18:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-21 21:39 [PATCH 2/2] usbatm: Detect usb device shutdown and ignore failed urbs Simon Arlott
2007-02-22 10:43 ` Duncan Sands
2007-02-22 23:53   ` Pete Zaitcev
2007-02-23  9:36     ` Duncan Sands
2007-02-23 16:16       ` [linux-usb-devel] " Alan Stern
2007-02-23 17:05         ` Duncan Sands
2007-02-23 18:11           ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).