All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Keeping <john@metanate.com>
To: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jens Axboe <axboe@kernel.dk>, Jack Pham <jackp@codeaurora.org>,
	Peter Chen <peter.chen@nxp.com>,
	kernel test robot <lkp@intel.com>,
	Wei Ming Chen <jj251510319013@gmail.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Dean Anderson <dean@sensoray.com>,
	Andrew Gabbasov <andrew_gabbasov@mentor.com>
Subject: Re: [PATCH v3] usb: gadget: f_fs: Use stream_open() for endpoint files
Date: Mon, 15 Nov 2021 13:04:14 +0000	[thread overview]
Message-ID: <YZJazkgZWKCg52iZ@donbot> (raw)
In-Reply-To: <1636712682-1226-1-git-send-email-quic_pkondeti@quicinc.com>

On Fri, Nov 12, 2021 at 03:54:40PM +0530, Pavankumar Kondeti wrote:
> Function fs endpoint file operations are synchronized via an interruptible
> mutex wait. However we see threads that do ep file operations concurrently
> are getting blocked for the mutex lock in __fdget_pos(). This is an
> uninterruptible wait and we see hung task warnings and kernel panic
> if hung_task_panic systcl is enabled if host does not send/receive
> the data for long time.
> 
> The reason for threads getting blocked in __fdget_pos() is due to
> the file position protection introduced by the commit 9c225f2655e3
> ("vfs: atomic f_pos accesses as per POSIX"). Since function fs
> endpoint files does not have the notion of the file position, switch
> to the stream mode. This will bypass the file position mutex and
> threads will be blocked in interruptible state for the function fs
> mutex.
> 
> It should not affects user space as we are only changing the task state
> changes the task state from UNINTERRUPTIBLE to INTERRUPTIBLE while waiting
> for the USB transfers to be finished. However there is a slight change to
> the O_NONBLOCK behavior. Earlier threads that are using O_NONBLOCK are also
> getting blocked inside fdget_pos(). Now they reach to function fs and error
> code is returned. The non blocking behavior is actually honoured now.
> 
> Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>

It might be worth noting that this also changes pread & pwrite which
will now return ESPIPE instead of succeeding but ignoring the offset
argument.

Those operations have always been broken and I doubt anyone is using
them, but there is slightly more user visible change than just the task
state.

With that said, I think this is a good change, so:

Reviewed-by: John Keeping <john@metanate.com>

> ---
> v3:
> - Added more background and user space impact in the commit description
> 
> v2:
> - Removed Change-Id tag
> 
>  drivers/usb/gadget/function/f_fs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index e20c19a..3c584da 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -614,7 +614,7 @@ static int ffs_ep0_open(struct inode *inode, struct file *file)
>  	file->private_data = ffs;
>  	ffs_data_opened(ffs);
>  
> -	return 0;
> +	return stream_open(inode, file);
>  }
>  
>  static int ffs_ep0_release(struct inode *inode, struct file *file)
> @@ -1154,7 +1154,7 @@ ffs_epfile_open(struct inode *inode, struct file *file)
>  	file->private_data = epfile;
>  	ffs_data_opened(epfile->ffs);
>  
> -	return 0;
> +	return stream_open(inode, file);
>  }
>  
>  static int ffs_aio_cancel(struct kiocb *kiocb)
> -- 
> 2.7.4
> 

      reply	other threads:[~2021-11-15 13:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 11:11 [PATCH] usb: gadget: f_fs: Use stream_open() for endpoint files Pavankumar Kondeti
2021-11-11 11:38 ` Greg Kroah-Hartman
2021-11-11 12:06   ` Pavan Kondeti
2021-11-11 12:15     ` [PATCH v2] " Pavankumar Kondeti
2021-11-11 13:12       ` Greg Kroah-Hartman
2021-11-12  3:17         ` Pavan Kondeti
2021-11-12  6:48           ` Greg Kroah-Hartman
2021-11-12 10:24             ` [PATCH v3] " Pavankumar Kondeti
2021-11-15 13:04               ` John Keeping [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YZJazkgZWKCg52iZ@donbot \
    --to=john@metanate.com \
    --cc=andrew_gabbasov@mentor.com \
    --cc=axboe@kernel.dk \
    --cc=balbi@kernel.org \
    --cc=dean@sensoray.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=jackp@codeaurora.org \
    --cc=jj251510319013@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=peter.chen@nxp.com \
    --cc=quic_pkondeti@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.