mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 0/3] usbgadget: add support for blocking USB mass storage gadget
Date: Mon, 15 Feb 2021 11:27:37 +0100
Message-ID: <20210215102740.30418-1-a.fatoum@pengutronix.de> (raw)

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

             reply	other threads:[~2021-02-15 10:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15 10:27 Ahmad Fatoum [this message]
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

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=20210215102740.30418-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git