mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] usbgadget: add support for blocking USB mass storage gadget
@ 2021-02-15 10:27 Ahmad Fatoum
  2021-02-15 10:27 ` [PATCH 1/3] include: <linux/barebox-wrapper.h>: remove kthread 'replacements' Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2021-02-15 10:27 UTC (permalink / raw)
  To: barebox

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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2021-02-17 11:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 10:27 [PATCH 0/3] usbgadget: add support for blocking USB mass storage gadget Ahmad Fatoum
2021-02-15 10:27 ` [PATCH 1/3] include: <linux/barebox-wrapper.h>: remove kthread 'replacements' Ahmad Fatoum
2021-02-15 10:27 ` [PATCH 2/3] console: unconditionally run poller_call in ctrlc() Ahmad Fatoum
2021-02-15 10:27 ` [PATCH 3/3] usbgadget: add support for USB mass storage gadget Ahmad Fatoum
2021-02-17 11:48   ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox