linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Ohci-hcd: fix endless loop
@ 2004-11-25 18:17 Colin Leroy
  2004-11-26 16:38 ` [linux-usb-devel] " David Brownell
  0 siblings, 1 reply; 5+ messages in thread
From: Colin Leroy @ 2004-11-25 18:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Benjamin Herrenschmidt, Greg KH

Hi, 

Following patch fixes an endless loop that happens after having
slept and resumed my iBook with a linux-wlan-ng controller plugged in,
removed the stick and plugged it back (getting "IRQ lossage" message).

Signed-off-by: Colin Leroy <colin@colino.net>
--- a/drivers/usb/host/ohci-hcd.c	2004-11-25 19:00:25.000000000 +0100
+++ b/drivers/usb/host/ohci-hcd.c	2004-11-25 19:08:59.000000000 +0100
@@ -375,6 +375,11 @@
 		spin_unlock_irqrestore (&ohci->lock, flags);
 		set_current_state (TASK_UNINTERRUPTIBLE);
 		schedule_timeout (1);
+		if (limit-- < -1000) {
+			ohci_warn (ohci, "Couldn't recover\n");
+			ohci_restart(ohci);
+			goto bail;
+		}
 		goto rescan;
 	case ED_IDLE:		/* fully unlinked */
 		if (list_empty (&ed->td_list)) {
@@ -396,6 +401,7 @@
 	dev->ep [epnum] = NULL;
 done:
 	spin_unlock_irqrestore (&ohci->lock, flags);
+bail:
 	return;
 }
 

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

* Re: [linux-usb-devel] [PATCH] Ohci-hcd: fix endless loop
  2004-11-25 18:17 [PATCH] Ohci-hcd: fix endless loop Colin Leroy
@ 2004-11-26 16:38 ` David Brownell
  2004-11-26 16:54   ` Colin Leroy
  2004-11-26 22:07   ` Benjamin Herrenschmidt
  0 siblings, 2 replies; 5+ messages in thread
From: David Brownell @ 2004-11-26 16:38 UTC (permalink / raw)
  To: linux-usb-devel
  Cc: Colin Leroy, linux-kernel, Benjamin Herrenschmidt, Greg KH

On Thursday 25 November 2004 10:17, Colin Leroy wrote:
> Hi, 
> 
> Following patch fixes an endless loop that happens after having
> slept and resumed my iBook with a linux-wlan-ng controller plugged in,
> removed the stick and plugged it back (getting "IRQ lossage" message).

The infinite loop means that something trashed the stack, yes?

The "limit-- < -1000" test below should never be able to succeed
unless the previous "limit-- == 0" test got trashed by having
something obliterate the stack.  Possibly the driver for that WLAN
adapter.  Once that happens, all kinds of things will misbehave...

If you got the "IRQ INTR_SF lossage" diagnostic, there's clearly
some problem with IRQ handling after the resume ... is the iBook
firmware (or hardware) doing wierd stuff so that the normal PCI
IRQ calls stopped working?

And for that matter, "limit" is unsigned, so you must be getting
(and ignoring) some compiler warnings too.

This is not a good patch; not accepted.

- Dave


> Signed-off-by: Colin Leroy <colin@colino.net>
> --- a/drivers/usb/host/ohci-hcd.c	2004-11-25 19:00:25.000000000 +0100
> +++ b/drivers/usb/host/ohci-hcd.c	2004-11-25 19:08:59.000000000 +0100
> @@ -375,6 +375,11 @@
>  		spin_unlock_irqrestore (&ohci->lock, flags);
>  		set_current_state (TASK_UNINTERRUPTIBLE);
>  		schedule_timeout (1);
> +		if (limit-- < -1000) {
> +			ohci_warn (ohci, "Couldn't recover\n");
> +			ohci_restart(ohci);
> +			goto bail;
> +		}
>  		goto rescan;
>  	case ED_IDLE:		/* fully unlinked */
>  		if (list_empty (&ed->td_list)) {
> @@ -396,6 +401,7 @@
>  	dev->ep [epnum] = NULL;
>  done:
>  	spin_unlock_irqrestore (&ohci->lock, flags);
> +bail:
>  	return;
>  }
>  
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now. 
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> linux-usb-devel@lists.sourceforge.net
> To unsubscribe, use the last form field at:
> https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
> 

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

* Re: [linux-usb-devel] [PATCH] Ohci-hcd: fix endless loop
  2004-11-26 16:38 ` [linux-usb-devel] " David Brownell
@ 2004-11-26 16:54   ` Colin Leroy
  2004-11-26 17:21     ` David Brownell
  2004-11-26 22:07   ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 5+ messages in thread
From: Colin Leroy @ 2004-11-26 16:54 UTC (permalink / raw)
  To: David Brownell
  Cc: linux-usb-devel, linux-kernel, Benjamin Herrenschmidt, Greg KH

On 26 Nov 2004 at 08h11, David Brownell wrote:

Hi, 

> The infinite loop means that something trashed the stack, yes?
> 
> The "limit-- < -1000" test below should never be able to succeed
> unless the previous "limit-- == 0" test got trashed by having
> something obliterate the stack. 

Sure? the (limit -- == 0) gotoes higher to test again.
from what I understand the loop goes back to rescan 1000 times, then once 
to sanitize, then to back to rescan again infinetely...
I may be wrong but I don't think there's a stack corruption there.

> If you got the "IRQ INTR_SF lossage" diagnostic, there's clearly
> some problem with IRQ handling after the resume ... is the iBook
> firmware (or hardware) doing wierd stuff so that the normal PCI
> IRQ calls stopped working?

No, the rest of the computer worked fine.

> And for that matter, "limit" is unsigned, so you must be getting
> (and ignoring) some compiler warnings too.

Yes, noticed and sent a second patch.

-- 
Colin

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

* Re: [linux-usb-devel] [PATCH] Ohci-hcd: fix endless loop
  2004-11-26 16:54   ` Colin Leroy
@ 2004-11-26 17:21     ` David Brownell
  0 siblings, 0 replies; 5+ messages in thread
From: David Brownell @ 2004-11-26 17:21 UTC (permalink / raw)
  To: linux-usb-devel
  Cc: Colin Leroy, linux-kernel, Benjamin Herrenschmidt, Greg KH

On Friday 26 November 2004 08:54, Colin Leroy wrote:
> On 26 Nov 2004 at 08h11, David Brownell wrote:
> 
> Hi, 
> 
> > The infinite loop means that something trashed the stack, yes?
> > 
> > The "limit-- < -1000" test below should never be able to succeed
> > unless the previous "limit-- == 0" test got trashed by having
> > something obliterate the stack. 
> 
> Sure? the (limit -- == 0) gotoes higher to test again.
> from what I understand the loop goes back to rescan 1000 times, then once 
> to sanitize, then to back to rescan again infinetely...
> I may be wrong but I don't think there's a stack corruption there.

The "limit" isn't tested a 1001st time, since the ED state
changed.

For that matter, any time that the IRQ lossage appears,
there's always been something that damaged the IRQ setup.

- Dave


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

* Re: [linux-usb-devel] [PATCH] Ohci-hcd: fix endless loop
  2004-11-26 16:38 ` [linux-usb-devel] " David Brownell
  2004-11-26 16:54   ` Colin Leroy
@ 2004-11-26 22:07   ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2004-11-26 22:07 UTC (permalink / raw)
  To: David Brownell; +Cc: Linux-USB, Colin Leroy, Linux Kernel list, Greg KH


> If you got the "IRQ INTR_SF lossage" diagnostic, there's clearly
> some problem with IRQ handling after the resume ... is the iBook
> firmware (or hardware) doing wierd stuff so that the normal PCI
> IRQ calls stopped working?

The iBook hardware isn't doing anything special, the controller is just
coming back out of the blue. If it's the NEC one, it's just a normal NEC
EHCI+OHCI coming out of D3cold, if it's the KeyLargo Apple one, it comes
from some special state which  is similar to D2.

Ben.



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

end of thread, other threads:[~2004-11-27  6:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-25 18:17 [PATCH] Ohci-hcd: fix endless loop Colin Leroy
2004-11-26 16:38 ` [linux-usb-devel] " David Brownell
2004-11-26 16:54   ` Colin Leroy
2004-11-26 17:21     ` David Brownell
2004-11-26 22:07   ` Benjamin Herrenschmidt

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