From: Daniel Almeida <daniel.almeida@collabora.com>
To: Colin Braun <colinbrauncl@gmail.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Alan Stern" <stern@rowland.harvard.edu>,
"Mathias Nyman" <mathias.nyman@intel.com>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-usb@vger.kernel.org, linux-media@vger.kernel.org,
"Colin Braun" <colin.braun.cl@gmail.com>
Subject: Re: [RFC PATCH 0/4] rust: usb: add usb request block abstractions and a user
Date: Mon, 13 Jul 2026 10:53:53 -0300 [thread overview]
Message-ID: <1E924102-5CC7-427A-9FD0-3B15BA1BEAEB@collabora.com> (raw)
In-Reply-To: <20260712-urb-abstraction-v1-v1-0-9fa011634ead@gmail.com>
Hi Colin!
> On 12 Jul 2026, at 18:07, Colin Braun <colinbrauncl@gmail.com> wrote:
>
> This series introduces initial abstractions to allow for the
> implementation of USB drivers in Rust.
>
> This is an RFC to demonstrate a rough idea on how the USB abstractions
> needed to create drivers in Rust could be implemented.
>
> The series is broken up into 4 parts:
>
> 1. USB chapter 9 standard descriptors and constants - Exposes the
> necessary structs and constants from include/uapi/linux/usb/ch9.h as
> a new ch9 submodule.
>
> 2. Interface and endpoint abstractions - Wraps the relevant C structs
> and functions defined in include/linux/usb.h, allowing drivers to
> safely query and configure interfaces and their endpoints.
>
> 3. USB Request Block (URB) abstractions - Creates a safe wrapper around
> the C `struct urb` to allow Rust drivers to communicate with devices.
>
> 4. An initial user of the new abstractions - A driver for the GV-USB2
> composite-usb video capture device.
>
> Patch 3 is the bulk and core of this series. By their asynchronous
> nature, creating a safe URB abstraction for drivers to use is tricky.
> The goals of the URB abstraction are:
>
> 1. No `unsafe` needed in driver code. This means providing a way for a
> driver to safely access private data sent with the URB.
> 2. Drivers are forced to handle the URB status in their completion
> callback before accessing the URB data.
> 3. Dropping an URB ensures it is not in-flight and frees its resources.
> 4. The URB can be safely resubmitted from the completion callback.
>
> The patch elaborates on how these goals are achieved in more detail.
>
> Although the URB abstractions do not include immediate support for bulk
> or interrupt URBs, I believe it creates a foundation conducive to
> future, safe abstractions for them.
>
> Patch 4 is first user of these USB abstractions. The initial
> implementation is very much bare-bones, only exposing audio data via
> debugfs. It is based on the in-tree STK1160 driver and an old,
> out-of-tree driver written by Isaac Lozano [1].
>
> [1] https://github.com/Isaac-Lozano/GV-USB2-Driver
>
> Signed-off-by: Colin Braun <colin.braun.cl@gmail.com>
> ---
> Colin Braun (4):
> rust: usb: add USB ch9 standard descriptors and constants
> rust: usb: add usb host interface and endpoint abstractions
> rust: usb: add urb abstraction with control and isochronous support
> media: add gv-usb2 audio capture driver
Have you talked to the media people about adding a Rust driver?
>
> drivers/media/usb/Kconfig | 1 +
> drivers/media/usb/Makefile | 1 +
> drivers/media/usb/gv-usb2/Kconfig | 9 +
> drivers/media/usb/gv-usb2/Makefile | 1 +
> drivers/media/usb/gv-usb2/driver.rs | 361 ++++++++++++++
> drivers/media/usb/gv-usb2/gv_usb2.rs | 16 +
> drivers/media/usb/gv-usb2/regs.rs | 25 +
> include/linux/usb.h | 4 +
> rust/kernel/usb.rs | 905 ++++++++++++++++++++++++++++++++++-
> rust/kernel/usb/ch9.rs | 295 ++++++++++++
> 10 files changed, 1613 insertions(+), 5 deletions(-)
> ---
> base-commit: 30e873dd61b044092dbc657c7c67a5d19adfd933
> change-id: 20260712-urb-abstraction-v1-020a67f16cff
>
> Best regards,
> --
> Colin Braun <colin.braun.cl@gmail.com>
>
>
next prev parent reply other threads:[~2026-07-13 13:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 21:07 Colin Braun
2026-07-12 21:07 ` [RFC PATCH 1/4] rust: usb: add USB ch9 standard descriptors and constants Colin Braun
2026-07-12 21:07 ` [RFC PATCH 2/4] rust: usb: add usb host interface and endpoint abstractions Colin Braun
2026-07-13 13:22 ` Danilo Krummrich
2026-07-13 20:03 ` Colin Braun
2026-07-13 20:09 ` Danilo Krummrich
2026-07-14 9:26 ` Oliver Neukum
2026-07-14 13:05 ` Danilo Krummrich
2026-07-14 16:26 ` Alan Stern
2026-07-14 17:53 ` Danilo Krummrich
2026-07-14 18:48 ` Oliver Neukum
2026-07-14 18:57 ` Danilo Krummrich
2026-07-14 19:25 ` Alan Stern
2026-07-15 0:27 ` Danilo Krummrich
2026-07-14 17:57 ` Oliver Neukum
2026-07-14 19:03 ` Alan Stern
2026-07-14 18:26 ` Miguel Ojeda
2026-07-12 21:08 ` [RFC PATCH 3/4] rust: usb: add urb abstraction with control and isochronous support Colin Braun
2026-07-12 21:08 ` [RFC PATCH 4/4] media: add gv-usb2 audio capture driver Colin Braun
2026-07-13 14:44 ` Danilo Krummrich
2026-07-13 21:08 ` Colin Braun
2026-07-13 13:22 ` [RFC PATCH 0/4] rust: usb: add usb request block abstractions and a user Danilo Krummrich
2026-07-13 20:10 ` Colin Braun
2026-07-13 13:53 ` Daniel Almeida [this message]
2026-07-13 20:32 ` Colin Braun
2026-07-15 2:35 ` Daniel Almeida
2026-07-15 5:43 ` Greg Kroah-Hartman
2026-07-15 19:57 ` Colin Braun
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=1E924102-5CC7-427A-9FD0-3B15BA1BEAEB@collabora.com \
--to=daniel.almeida@collabora.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=colin.braun.cl@gmail.com \
--cc=colinbrauncl@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mathias.nyman@intel.com \
--cc=mchehab@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox