[PATCH 0/3] usbgadget: add support for blocking USB mass storage gadget
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Feb 15 05:27:37 EST 2021
The barebox model for USB gadgets is that the UDC gadget polling
is done in a poller. These are short sections of code that are
scheduled cooperatively whenever the main "thread" enters a delay loop.
When transfers are completed, callbacks are run, which trigger new
transfers and/or offload work into a workqueue.
The Linux driver for the USB mass storage gadget creates a state
machine thread. This threads runs as long as there's work to do and
then sleeps for new USB transfers to complete. As U-Boot doesn't
have a threading facility, the U-Boot driver based on it runs this
thread in a blocking loop.
This series adds this functionality to barebox as well. It can be used
by running e.g. ums /dev/mmc1(mmc),/dev/mmc2(sd). Until ctrl+C arrives,
this blocks anything else, except for pollers, from running.
The usual way to make this non-blocking, would be to break up the main
thread into chunks whereever it's sleeping and trigger a poller or
workqueue to continue, when new data arrives. Instead of reworking the
original code flow, I experimented with transforming pollers into actual
cooperative (green) threads. This will likely need some discussion to
decide on how to proceed with it, so this series adds the base, blocking,
funcionality.
Cheers,
Ahmad Fatoum (3):
include: <linux/barebox-wrapper.h>: remove kthread 'replacements'
console: unconditionally run poller_call in ctrlc()
usbgadget: add support for USB mass storage gadget
commands/Makefile | 1 +
commands/ums.c | 53 +
common/console.c | 4 +-
drivers/mtd/ubi/ubi-barebox.h | 2 -
drivers/usb/gadget/Kconfig | 11 +
drivers/usb/gadget/Makefile | 1 +
drivers/usb/gadget/f_mass_storage.c | 2936 +++++++++++++++++++++++++++
drivers/usb/gadget/storage_common.c | 173 ++
drivers/usb/gadget/storage_common.h | 245 +++
fs/ubifs/misc.h | 3 +
include/linux/barebox-wrapper.h | 4 -
include/scsi.h | 12 +
include/usb/mass_storage.h | 28 +
include/usb/storage.h | 87 +
14 files changed, 3552 insertions(+), 8 deletions(-)
create mode 100644 commands/ums.c
create mode 100644 drivers/usb/gadget/f_mass_storage.c
create mode 100644 drivers/usb/gadget/storage_common.c
create mode 100644 drivers/usb/gadget/storage_common.h
create mode 100644 include/usb/mass_storage.h
create mode 100644 include/usb/storage.h
--
2.29.2
More information about the barebox
mailing list