usb: gadget: ffs: handle I/O completion in-order
authorJohn Keeping <john@metanate.com>
Tue, 12 Sep 2017 09:24:40 +0000 (10:24 +0100)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 28 Sep 2017 09:37:24 +0000 (12:37 +0300)
commitaddfc5823dbf3e6ed400e98e49c7e64b10e191d6
tree14a9eb490836ad46c806a6dccd4c900b8c35e2de
parent0a2ce62b61f2c76d0213edf4e37aaf54a8ddf295
usb: gadget: ffs: handle I/O completion in-order

By submitting completed transfers to the system workqueue there is no
guarantee that completion events will be queued up in the correct order,
as in multi-processor systems there is a thread running for each
processor and the work items are not bound to a particular core.

This means that several completions are in the queue at the same time,
they may be processed in parallel and complete out of order, resulting
in data appearing corrupt when read by userspace.

Create a single-threaded workqueue for FunctionFS so that data completed
requests is passed to userspace in the order in which they complete.

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/function/f_fs.c
drivers/usb/gadget/function/u_fs.h