Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752248AbbDAIGt (ORCPT ); Wed, 1 Apr 2015 04:06:49 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:50640 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbbDAIGj (ORCPT ); Wed, 1 Apr 2015 04:06:39 -0400 X-AuditID: cbfec7f4-b7f126d000001e9a-94-551ba660240e Message-id: <551BA70B.1090706@samsung.com> Date: Wed, 01 Apr 2015 10:06:35 +0200 From: Robert Baldyga User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-version: 1.0 To: "Baxter, Jim" Cc: "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , "Zapolskiy, Vladimir" , "balbi@ti.com" Subject: Re: usb: gadget: f_fs: O_NONBLOCK waits MAX_SCHEDULE_TIMEOUT References: <551AED33.2040206@mentor.com> In-reply-to: <551AED33.2040206@mentor.com> Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGLMWRmVeSWpSXmKPExsVy+t/xy7oJy6RDDf7tM7A4eL/eom+1osXl XXPYLBYta2W2eHZgG5sDq8fur02MHsdvbGfy+LxJLoA5issmJTUnsyy1SN8ugSvjSNsDtoJ+ 7or9xxoYGxjfcnQxcnJICJhILHr6jgXCFpO4cG89WxcjF4eQwFJGife/WpggnI+MEv/OPmUF qeIV0JJYeqofrINFQFXidMsBMJtNQEdiy/cJjF2MHByiAhESty9zQpQLSvyYfA+sRERAU+Le 2/WsIDOZBa4xSqw/28MOkhAWcJXYumAOI4gtBFS0seM4M4jNCbTrzORLbCAzmQXUJaZMyQUJ MwvIS2xe85Z5AqPALCQrZiFUzUJStYCReRWjaGppckFxUnquoV5xYm5xaV66XnJ+7iZGSNh+ 2cG4+JjVIUYBDkYlHl7OaKlQIdbEsuLK3EOMEhzMSiK8xoukQ4V4UxIrq1KL8uOLSnNSiw8x MnFwSjUwakdOzWlbvSv6vv6x6xaM2aU3mRpMzHmc9174o+qvpvzG90WnqoyFIb9Fjczte6+c s023Fb9SF9zuU7R25dr0/Usj9dtMhZ6I3Z4qP33PHdmekLVdeh5bDiy5XnqkVOFm+s2dEWEV uyI/3yxd/n/HMi7TrY5fLzwXflX0cp5y4aG65Lc/d37WV2Ipzkg01GIuKk4EANsHQgk5AgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1626 Lines: 47 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/