Re: klists and struct device semaphores

From: Alan Stern (stern_at_rowland.harvard.edu)
Date: 03/31/05

  • Next message: Dmitry Torokhov: "Re: [linux-pm] Re: swsusp 'disk' fails in bk-current - intel_agp at fault?"
    Date:	Thu, 31 Mar 2005 11:24:17 -0500 (EST)
    To: Patrick Mochel <mochel@digitalimplant.org>
    
    

    On Wed, 30 Mar 2005, Patrick Mochel wrote:

    > > Having thought it through, I believe all we need for USB support is this:
    > >
    > > Whenever usb_register() in the USB core calls driver_register()
    > > and the call filters down to driver_attach(), that routine
    > > should lock dev->parent->sem before calling driver_probe_device()
    > > (and unlock it afterward, of course).
    > >
    > > (For the corresponding remove pathway, where usb_deregister()
    > > calls driver_unregister(), it would be nice if __remove_driver()
    > > locked dev->parent->sem before calling device_release_driver().
    > > This is not really needed, however, since USB drivers aren't
    > > supposed to touch the device in their disconnect() method.)
    >
    >
    > Why can't you just lock it in ->probe() and ->remove() yourself?

    Aha! There you go... This explains why you need explicit locking rules.

    When probe() and remove() are called, the driver-model core already owns
    the device's lock. If the driver then tried to lock the parent, it would
    mean acquiring locks in the wrong order. This could easily lead to
    deadlock.

    Furthermore, it will often happen during probe() and remove() that the
    parent's lock is already owned by the USB core. So the driver _mustn't_
    try to lock it.

    Alan Stern

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Dmitry Torokhov: "Re: [linux-pm] Re: swsusp 'disk' fails in bk-current - intel_agp at fault?"

    Relevant Pages

    • Re: 2.6.7-rc1 breaks forcedeth
      ... > when you probe for it. ... Presuming things about a device's state upon entry to the driver has led ... registers hold a valid/useful value or ethernet NIC's DMA engine is ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH 1/2] pci: Block config access during BIST
      ... On Sat, 2004-11-20 at 12:42 +0000, Alan Cox wrote: ... >> locking or some something that can be fixed at the driver level. ... > Some of the Intel CPU's are very bad at lock handling so it is an issue. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: klists and struct device semaphores
      ... If the driver then tried to lock the parent, ... are probed they also want to probe and add their children. ... What I meant was that when the parent device's ->probemethod is called, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [linux-usb-devel] Re: [PATCH] oops in sd_shutdown
      ... this same problem could show upb in any other driver. ... > before calling either probe() or remove. ... Is the shutdown being called directly? ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [PATCH] PNPACPI
      ... don't lock the acpi device like in mm5 or it could lock it like in mm2. ... I have add extra check (CRS presence), so it shouldn't lock too much ... driver like in mm2. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)