Re: [PATCH 2/8] USB: change locking for device-level autosuspend

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

 



On Mon, 11 Jan 2010, Oliver Neukum wrote:

> Am Montag, 11. Januar 2010 20:32:14 schrieb Alan Stern:
> 
> > I still don't understand.  First, why would usb_autosuspend_device(),
> > usb_autoresume_device(), or usb_try_autosuspend_device() do
> > copy_from_user()?  As a general rule, they don't have a meaningful user
> > context.  Second, why would the driver need to take the device lock?
> 
> I don't know, but quoting you (Documentation/usb/power-management.txt):
> 
> If a driver wants to block all suspend/resume calls during some
> critical section, the best way is to lock the device and call
> usb_autopm_get_interface() (and do the reverse at the end of the
> critical section).  Holding the device semaphore will block all
> external PM calls, and the usb_autopm_get_interface() will prevent any
> internal PM calls, even if it fails.  (Exercise: Why?)

Yes, but doing I/O isn't a critical section.  In general a driver
shouldn't need to lock its device while doing I/O.  The most notable
exception is when a reset is needed for error recovery, and we have a
special API for that: usb_lock_device_for_reset().

Can you provide a detailed outline of the deadlock scenario you're 
concerned about?  Maybe show how it would affect usb-storage?

Alan Stern

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