RE: [PATCH] USB host: Fix lockdep warning in AMD PLL quirk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Alan Stern [mailto:stern@xxxxxxxxxxxxxxxxxxx]
> Sent: Wednesday, April 06, 2011 11:16 PM
> To: Roedel, Joerg
> Cc: Greg Kroah-Hartman; Sarah Sharp; Xu, Andiry;
linux-usb@xxxxxxxxxxxxxxx;
> linux-kernel@xxxxxxxxxxxxxxx; stable@xxxxxxxxxx
> Subject: Re: [PATCH] USB host: Fix lockdep warning in AMD PLL quirk
> 
> On Wed, 6 Apr 2011, Joerg Roedel wrote:
> 
> > Booting 2.6.38 on my test machine produces a lockdep warning
> > from the usb_amd_find_chipset_info() function:
> >
> >  WARNING: at /data/lemmy/linux.trees.git/kernel/lockdep.c:2465
> lockdep_trace_alloc+0x95/0xc2()
> >  Hardware name: Snook
> >  Modules linked in:
> >  Pid: 959, comm: work_for_cpu Not tainted 2.6.39-rc2+ #22
> >  Call Trace:
> >   [<ffffffff8103c0d4>] warn_slowpath_common+0x80/0x98
> >   [<ffffffff812387e6>] ? T.492+0x24/0x26
> >   [<ffffffff8103c101>] warn_slowpath_null+0x15/0x17
> >   [<ffffffff81068667>] lockdep_trace_alloc+0x95/0xc2
> >   [<ffffffff810ed9ac>] slab_pre_alloc_hook+0x18/0x3b
> >   [<ffffffff810ef227>] kmem_cache_alloc_trace+0x25/0xba
> >   [<ffffffff812387e6>] T.492+0x24/0x26
> >   [<ffffffff81238816>] pci_get_subsys+0x2e/0x73
> >  sr0: scsi3-mmc drive: 48x/48x writer dvd-ram cd/rw xa/form2 cdda
tray
> >   [<ffffffff8123886c>] pci_get_device+0x11/0x13
> >   [<ffffffff814082a9>] usb_amd_find_chipset_info+0x3f/0x18a
> > ...
> >
> > It turns out that this function calls pci_get_device under a
spin_lock
> > with irqs disabled, but the pci_get_device function is only allowed
in
> > preemptible context.
> >
> > This patch fixes this by using temporary variables in the quirk
> > algorithm and commiting them later to the struct under the lock.
This
> > moves all pci_get_device() invocations out of the spin_lock and
fixes
> > the lockdep warning for me.
> >
> > Cc: stable@xxxxxxxxxx
> > Signed-off-by: Joerg Roedel <joerg.roedel@xxxxxxx>
> > ---
> >  drivers/usb/host/pci-quirks.c |   67
+++++++++++++++++++++++-----------
> ------
> >  1 files changed, 38 insertions(+), 29 deletions(-)
> >
> > diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-
> quirks.c
> > index 1d586d4..d3e5cf3 100644
> > --- a/drivers/usb/host/pci-quirks.c
> > +++ b/drivers/usb/host/pci-quirks.c
> > @@ -84,64 +84,73 @@ int usb_amd_find_chipset_info(void)
> >  {
> >  	u8 rev = 0;
> >  	unsigned long flags;
> > +	struct pci_dev *nb_dev, *smbus_dev;
> > +	int nb_type, sb_type;
> >
> >  	spin_lock_irqsave(&amd_lock, flags);
> > -
> >  	amd_chipset.probe_count++;
> >  	/* probe only once */
> >  	if (amd_chipset.probe_count > 1) {
> >  		spin_unlock_irqrestore(&amd_lock, flags);
> >  		return amd_chipset.probe_result;
> >  	}
> 
> The counter really should be a bool: Has the chipset already been
> probed or not?  After all, nobody cares how many times this routine
was
> called.
> 

The probe routine increases probe_count counter to remember how many
hosts calls it. Every host that calls probe routine in initialization
will call usb_amd_dev_put() in *hci_stop() and decrease probe_count, so
the last caller can safely free the resources.

Thanks,
Andiry
 


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux