lkml.org 
[lkml]   [2015]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: usb: gadget: f_fs: O_NONBLOCK waits MAX_SCHEDULE_TIMEOUT
Hi,

On 03/31/2015 08:53 PM, Baxter, Jim wrote:
> Hi,
>
> I have been looking at an issue where a phone that is the Function FS
> host sometimes locks up and causes the function:
> static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data
> *io_data) in drivers/usb/gadget/function/f_fs.c to timeout after
> MAX_SCHEDULE_TIMEOUT jiffies.
>
> We are opening the ffs connection with the O_NONBLOCK option and this
> timeout seems to be far too long.
>
> The code causing the wait is here (line 834):
>
> if (unlikely(ret < 0)) {
> /* nop */
> } else if (unlikely(
> wait_for_completion_interruptible(&done))) {
> ret = -EINTR;
> usb_ep_dequeue(ep->ep, req);
> } else {
>
> The function call wait_for_completion_interruptible(&done) equates to:
> wait_for_completion_interruptible_timeout(&done, MAX_SCHEDULE_TIMEOUT);
>
>
> I was wondering what to change to fix this, is it reasonable to use a
> very small timeout if it is O_NONBLOCK or is any blocking not allowed?
>
> I would appreciate any thoughts on how this should work?

FunctionFS is very specific, because read/write operations are directly
translated into USB requests, which are asynchronous, so you cannot use
O_NONBLOCK.

If you need non-blocking API you can use Asynchronous I/O (AIO). You can
find some examples in kernel sources (tools/usb/ffs-aio-example/).

Br,
Robert Baldyga


\
 
 \ /
  Last update: 2015-04-01 10:41    [W:0.127 / U:4.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site