Am Mittwoch, 31. Januar 2007 12:37 schrieb Jiri Kosina:
> On Wed, 31 Jan 2007, Oliver Neukum wrote:
> 
> > in hiddev_ioctl() IO is submitted with usbhid_submit_report() and waited 
> > for with usbhid_wait_io(), which uses the following condition:
> >     if (!wait_event_timeout(hid->wait, (!test_bit(HID_CTRL_RUNNING, 
> > &usbhid->iofl) &&
> >                                     !test_bit(HID_OUT_RUNNING, 
> > &usbhid->iofl)),
> >                                     10*HZ)) {
> > It seems to me that in the case of concurrent IO this condition will swallow
> > the wakeup and timeout. Or am I dense today?
> 
> Hi Oliver,
> 
> I don't currently see the scenario you are talking about, could you 
> elaborate a little bit more, please?
> 
> Every URB submission (both ctrl and out) is paired with wake_up() in its 
> completion handler. Before the wake_up() is issued, the HID_CTRL_RUNNING 
> or HID_OUT_RUNNING flag is cleared. As this is a "1:1 pairing", it's 
> guaranteed that there will once be a wake_up() called on the waitqueue

But it is not guaranteed that you will already be on the waitqueue.
The URB may complete before you call usbhid_wait_io(), then it'll
dependent on the flags.

> with both the flags unset (if a timeout doesn't happen sooner, which is 
> OK). If this "final" wake_up() is called before the usbhid_wait_io() is 
> called, this is also OK, because then the condition will evaluate to true 
> and the task won't event sleep on the waitqueue.

Who tells you that the flags will still be cleared? Somebody else may
have called usbhid_submit_report() by the time you check the flags.

        Regards
                Oliver

> 
> Thanks,
> 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to