public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* ehci calling put_device from irq handler
@ 2006-01-18 21:29 Greg KH
  2006-01-18 21:54 ` [linux-usb-devel] " Alan Stern
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2006-01-18 21:29 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-usb-devel, linux-kernel

We can not call put_device() from irq context :(

I added a "might_sleep()" to the driver core and get the following from
the ehci driver.  Any thoughts?

thanks,

greg k-h


Debug: sleeping function called from invalid context at drivers/base/core.c:343
in_atomic():1, irqs_disabled():0
 [<c012006d>] __might_sleep+0x9e/0xa6
 [<c0270400>] put_device+0x1c/0x35
 [<f883ebde>] usb_hcd_giveback_urb+0x23/0x84 [usbcore]
 [<f8820f40>] ehci_urb_done+0x8d/0xcf [ehci_hcd]
 [<f8821138>] qh_completions+0x1b6/0x359 [ehci_hcd]
 [<f882208d>] scan_async+0x8a/0x13f [ehci_hcd]
 [<f8824e77>] ehci_work+0x59/0xd2 [ehci_hcd]
 [<f88255d7>] ehci_irq+0x185/0x336 [ehci_hcd]
 [<c0106a10>] do_gettimeofday+0x1e/0xbf
 [<c0127ae5>] getnstimeofday+0x14/0x2a
 [<c0139f6c>] ktime_get_ts+0x5e/0x66
 [<c0139ea3>] ktime_get+0x1b/0x43
 [<c013a521>] hrtimer_run_queues+0x50/0xf9
 [<f883ec6f>] usb_hcd_irq+0x30/0x68 [usbcore]
 [<c0144b18>] handle_IRQ_event+0x39/0x6d
 [<c0144bd4>] __do_IRQ+0x88/0xfc
 [<c0105789>] do_IRQ+0x19/0x24
 [<c0103b82>] common_interrupt+0x1a/0x20
 [<c01012a5>] mwait_idle+0x2a/0x34
 [<c0101103>] cpu_idle+0x7f/0xb4
 [<c041e898>] start_kernel+0x166/0x17f
 [<c041e2b6>] unknown_bootoption+0x0/0x1e0

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

* Re: [linux-usb-devel] ehci calling put_device from irq handler
  2006-01-18 21:29 ehci calling put_device from irq handler Greg KH
@ 2006-01-18 21:54 ` Alan Stern
  2006-01-18 22:13   ` Greg KH
  2006-01-18 22:18   ` David Brownell
  0 siblings, 2 replies; 4+ messages in thread
From: Alan Stern @ 2006-01-18 21:54 UTC (permalink / raw)
  To: Greg KH; +Cc: David Brownell, linux-usb-devel, linux-kernel

On Wed, 18 Jan 2006, Greg KH wrote:

> We can not call put_device() from irq context :(
> 
> I added a "might_sleep()" to the driver core and get the following from
> the ehci driver.  Any thoughts?

In principle the put_device and corresponding get_device calls aren't
needed.  We don't release a usb_device structure until after disabling all
its endpoints, and disabling an endpoint will wait until all the URBs for
that endpoint have completed.  So there's no reason to keep a reference to
the device structure for each URB.

I see that uhci-hcd is guilty of the same thing (reference acquired for 
each QH, released while holding a spinlock).  Probably each of the 
host controller drivers is.

Alan Stern


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

* Re: [linux-usb-devel] ehci calling put_device from irq handler
  2006-01-18 21:54 ` [linux-usb-devel] " Alan Stern
@ 2006-01-18 22:13   ` Greg KH
  2006-01-18 22:18   ` David Brownell
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2006-01-18 22:13 UTC (permalink / raw)
  To: Alan Stern; +Cc: David Brownell, linux-usb-devel, linux-kernel

On Wed, Jan 18, 2006 at 04:54:04PM -0500, Alan Stern wrote:
> On Wed, 18 Jan 2006, Greg KH wrote:
> 
> > We can not call put_device() from irq context :(
> > 
> > I added a "might_sleep()" to the driver core and get the following from
> > the ehci driver.  Any thoughts?
> 
> In principle the put_device and corresponding get_device calls aren't
> needed.  We don't release a usb_device structure until after disabling all
> its endpoints, and disabling an endpoint will wait until all the URBs for
> that endpoint have completed.  So there's no reason to keep a reference to
> the device structure for each URB.
> 
> I see that uhci-hcd is guilty of the same thing (reference acquired for 
> each QH, released while holding a spinlock).  Probably each of the 
> host controller drivers is.

Great, care to make up a patch to fix this?

:)

thanks,

greg k-h

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

* Re: [linux-usb-devel] ehci calling put_device from irq handler
  2006-01-18 21:54 ` [linux-usb-devel] " Alan Stern
  2006-01-18 22:13   ` Greg KH
@ 2006-01-18 22:18   ` David Brownell
  1 sibling, 0 replies; 4+ messages in thread
From: David Brownell @ 2006-01-18 22:18 UTC (permalink / raw)
  To: Alan Stern; +Cc: Greg KH, linux-usb-devel, linux-kernel

On Wednesday 18 January 2006 1:54 pm, Alan Stern wrote:
> On Wed, 18 Jan 2006, Greg KH wrote:
> 
> > We can not call put_device() from irq context :(
> > 
> > I added a "might_sleep()" to the driver core and get the following from
> > the ehci driver.  Any thoughts?
> 
> In principle the put_device and corresponding get_device calls aren't
> needed.  We don't release a usb_device structure until after disabling all
> its endpoints, and disabling an endpoint will wait until all the URBs for
> that endpoint have completed.  So there's no reason to keep a reference to
> the device structure for each URB.
> 
> I see that uhci-hcd is guilty of the same thing (reference acquired for 
> each QH, released while holding a spinlock).  Probably each of the 
> host controller drivers is.

I think it dated from the days before we had any mechanism for
disabling endpoints properly, and was (important!) insurance
against the inevitable "driver disconnect() didn't work right"
class of bugs.

So it should be safe to remove those calls now.

- Dave

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

end of thread, other threads:[~2006-01-18 22:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-18 21:29 ehci calling put_device from irq handler Greg KH
2006-01-18 21:54 ` [linux-usb-devel] " Alan Stern
2006-01-18 22:13   ` Greg KH
2006-01-18 22:18   ` David Brownell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox