On Sun, 21 Dec 2014, vichy wrote:

> >> Then I try to use msleep(100) but I found hub_port_status will first
> >> mutex_lock(&hub->status_mutex); then calling get_port_status.
> >> That mean the deadlock may happen.
> >
> > No it doesn't.
> Why it doesn't? from the source, the get_port_status did called in
> critical section protected by hub->status_mutex.
> And msleep is not allowed in critical  section.

Yes it is.  Why do you think it isn't?

A critical section can be either atomic or non-atomic.  If it is
protected by a spinlock (or if it runs in an interrupt handler, or with
interrupts or preemption disabled) then it is atomic, but if it is only
protected by a mutex then it is non-atomic.

msleep is not allowed in atomic sections, but it _is_ allowed in 
non-atomic sections.  Even if the code is protected by a mutex.

Alan Stern

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

Reply via email to