linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: f_fs: Wake up IO thread during disconnect
@ 2021-12-01 10:02 Wesley Cheng
  2021-12-01 16:41 ` John Keeping
  0 siblings, 1 reply; 5+ messages in thread
From: Wesley Cheng @ 2021-12-01 10:02 UTC (permalink / raw)
  To: balbi, gregkh; +Cc: linux-usb, linux-kernel, quic_jackp, Wesley Cheng

During device disconnect or composition unbind, applications should be
notified that the endpoints are no longer enabled, so that it can take
the proper actions to handle its IO threads.  Otherwise, they can be
left waiting for endpoints until EPs are re-enabled.

Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
---
 drivers/usb/gadget/function/f_fs.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 3c584da9118c..0b0747d96378 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -957,10 +957,12 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
 		if (file->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
-		ret = wait_event_interruptible(
-				epfile->ffs->wait, (ep = epfile->ep));
+		ret = wait_event_interruptible(epfile->ffs->wait,
+				(ep = epfile->ep) || !epfile->ffs->func);
 		if (ret)
 			return -EINTR;
+		if (!epfile->ffs->func)
+			return -ENODEV;
 	}
 
 	/* Do we halt? */
@@ -3292,6 +3294,7 @@ static int ffs_func_set_alt(struct usb_function *f,
 	if (alt == (unsigned)-1) {
 		ffs->func = NULL;
 		ffs_event_add(ffs, FUNCTIONFS_DISABLE);
+		wake_up_interruptible(&ffs->wait);
 		return 0;
 	}
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-03 11:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01 10:02 [PATCH] usb: gadget: f_fs: Wake up IO thread during disconnect Wesley Cheng
2021-12-01 16:41 ` John Keeping
2021-12-02 14:49   ` John Keeping
2021-12-03  7:33     ` Wesley Cheng
2021-12-03 11:30       ` John Keeping

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).