On Thu, Apr 07, 2011 at 11:01:02AM -0400, Alan Stern wrote:
> On Thu, 7 Apr 2011, Roedel, Joerg wrote:
> 
> > So we could access the data structure without any locks if we want using
> > atomic_t for the probe_count and isoc_reqs members. But as I've seen
> > meanwhile the lock still needs to protect the access to the hardware in
> > the usb_amd_quirk_pll() function.
> > So its probably not worth the work, what do you think?
> 
> You might as well use the spinlock.

Yes, since we need it anyway for protecting the hardware-access we can
leave everything as is (with the fix).

> However, is there a good reason to zero out the amd_chipset members in
> usb_amd_dev_put()?  Can these things be added and removed dynamically?  
> If they can't then the data should remain valid indefinitely once it
> has been probed, and you could call pci_dev_put() at the end of
> usb_amd_find_chipset_info().

Well, in a real system it is indeed very unlikely that the chipset is
hotplugged. But for formal correctness it is right to hold a reference
to the pci_dev struct as long as we rely on a pointer to it.

> And if they can, is it valid to call pci_dev_put() in usb_amd_dev_put()  
> while holding a spinlock?  You might want to move those calls to the
> end of the function.

I just had a look, pci_dev_put seems to be invalid in atomic context
too.  If the reference count drops to 0 (which is very unlikely for the
chipset devices) the device and its kobject are released. This causes a
uevent to be sent to userspace which does GFP_KERNEL allocations and all
the stuff.
So for formal correctness the pci_dev_put calls need to be moved out of
the spinlock too.

Regards,

        Joerg

_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable

Reply via email to