Skip to content

usb: misc: add a USB Billboard Device Class driver - #2263

Merged
RyanTheTide merged 4 commits into
mainfrom
drvgap/usb-billboard-v2
Nov 29, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
drvgap/usb-billboard-v2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What: A small usb-billboard class driver: binds the USB Billboard interface that every Alt Mode dock and adapter exposes (unbound today), shows its capability descriptor in sysfs, and warns when a mode was attempted but not entered. The latest commit removes the sysfs group in disconnect while intfdata is still set (review finding: NULL dereference on unbind during a read).
Tested: J473 (M2 mini) at 5cdb7b2 (dsw2): a real Billboard device behind the USB-C monitor binds (3-1.4:1.0, Billboard 1.21, one alt mode configured, vconn 1W). 20 unbind/bind cycles while a loop keeps reading billboard/version: still bound, 0 oops/WARN. J473 at f7205f4 (dsw1): bind + all sysfs values read. Shared USB regression (include/uapi/linux/usb/ch9.h): J615 (dsw1), M1 Pro and J473 (dsw2) boot with USB devices enumerated, 0 failed units, 0 WARN/BUG. (DRVGAP's earlier Neo row: dock Billboard 0bda:5418 bind/unbind/rebind, sysfs = lsusb -v.)
Risk: two-way · all Macs (new module, binds USB class 0x11 only; uapi ch9.h gains descriptor structs)
Not yet: physically unplugging the device during a read (the sysfs unbind loop is the stand-in)

Evidence
Original description

Problem

Every USB-C dock, adapter or display that offers an Alternate Mode exposes a USB Billboard device (class 0x11), and Linux has no driver for the class. These devices sit unbound in every dock (lsusb -t shows Driver=[none]). When a dock's DisplayPort path fails, nothing says so, although the Billboard reports exactly that. Example: the Realtek 0bda:5418 Billboard behind the RTS5411 hub of a Plugable UD-ULTC4K dock.

Change

A small class driver, usb-billboard. It binds to the Billboard interface and reads the Billboard Capability descriptor (and any Billboard AUM Capability descriptors) from the BOS the core already holds. Then it:

  • exposes the descriptor in sysfs under <interface>/billboard/ (one flat group), readable without root (ABI doc included)
  • logs one line per mode at bind time, as a warning when the device reports a mode as attempted but not entered, or as an unspecified error.

The descriptor structs go into uapi ch9.h. The driver sends nothing to the device beyond string descriptors. It does not depend on the SoC or board: it binds to any Billboard on any machine. CONFIG_USB_BILLBOARD=m is added to asahi.config.

This follows Niklas Neronin's 2024 debugfs-only posting, which was never merged. Review there asked for the data outside debugfs and for the structs in uapi; this version does both. It also fixes that posting's bmConfigured decode, which shifted by the mode index instead of twice the index.

Testing

  • Module built out of tree against the 7.3.0-40 config (clang 22, W=1): 0 warnings. checkpatch --strict: 0 errors.

  • uapi block: gcc -std=c99 -pedantic -Werror clean, plus static asserts on the layout (capability 44 bytes + 4 per mode, AUM capability 8 bytes, bcdVersion at offset 40).

  • Hardware, MacBook Neo (T8140, 7.3.0-40), dock Billboard 0bda:5418 behind an RTS5411 hub (Billboard 1.21, one DisplayPort mode): the module built from this branch binds it (lsusb -t shows Driver=usb-billboard), and every sysfs value matches lsusb -v: vconn_power 1W, version 1.21, num_modes 1, preferred_mode 0, additional_failure_info 0x00, altmode0 svid ff01, mode 1, vdo 0x000c0045, state configured. dmesg: one info line, alternate mode 0: SVID ff01 DisplayPort mode 1: configured. sysfs unbind removes billboard/, bind restores it, rmmod is clean, 0 failed units, 0 SELinux denials. The first run found the per-mode groups landing beside billboard/ (sysfs groups cannot nest); the second commit fixes that and the rerun shows everything under billboard/ with no stray directories.

Still to run

  • Build in a full kernel with CONFIG_USB_BILLBOARD=m (next unified test kernel).
  • A Billboard that reports a failed mode, to see the warning path on hardware (the current dock enters DisplayPort).
sysfs layout
billboard/num_modes                 bNumberOfAlternateModes
billboard/preferred_mode            bPreferredAlternateMode
billboard/vconn_power               1W .. 6W | not-required | reserved
billboard/version                   bcdVersion, e.g. 1.21
billboard/additional_failure_info   hex
billboard/additional_info_url       string or empty
billboard/altmode<N>_svid           hex, e.g. ff01
billboard/altmode<N>_mode           bAlternateMode
billboard/altmode<N>_vdo            only when an AUM capability exists
billboard/altmode<N>_state          configured | not-attempted | failed | error
billboard/altmode<N>_description    string or empty

USB-C docks, adapters and displays that offer Alternate Modes expose a
USB 2.0 Billboard device (class 0x11). Its BOS carries a Billboard
Capability descriptor listing every mode the device container supports
(SVID, mode index, optional string) and a two-bit bmConfigured result per
mode telling the host whether the mode was entered, plus optional
Billboard AUM Capability descriptors with each mode's VDO. Linux has no
driver for the class, so these devices sit unbound in every dock (lsusb
-t shows Driver=[none]) and a dock whose DisplayPort path failed says
nothing.

Bind to the Billboard interface and:
 - expose the descriptor in sysfs under <interface>/billboard/
   (num_modes, preferred_mode, vconn_power, version,
   additional_failure_info, additional_info_url, and altmode<N>/ with
   svid, mode, vdo, state, description), readable without root;
 - log one line per mode at bind time, at warning level for modes the
   device reports as attempted-but-not-entered or as an unspecified error.

The descriptor layouts go into the uapi ch9.h so user space can share
them. The capability is copied at probe, since a device reset replaces
udev->bos. Nothing is sent to the device beyond the string descriptors
the core already reads.

This follows the 2024 debugfs posting by Niklas Neronin; review asked
for the data outside debugfs and for the structs in uapi, which this
does. It also fixes that posting's bmConfigured decode, which shifted
by the mode index instead of twice the index.

Tested on a Realtek RTS5411 dock billboard (0bda:5418, Billboard 1.21,
one DisplayPort mode, configured).

Link: https://lore.kernel.org/linux-usb/[email protected]/
Suggested-by: Niklas Neronin <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
Sysfs attribute groups cannot nest, so the per-mode "altmode<N>" groups
landed next to "billboard" on the interface instead of inside it. Build
one "billboard" group holding the device-wide attributes and
altmode<N>_{svid,mode,vdo,state,description} for each mode, and update
the ABI document to match.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 1.

  1. Unbinding the driver while a sysfs file is being read can cause a NULL dereference. The device-wide attributes get their state with usb_get_intfdata() (drivers/usb/misc/usb-billboard.c:116,125,137,152,163,172). The group is added with devm_device_add_group() (:262), so devres removes it only in device_unbind_cleanup(). That runs after usb_unbind_interface() has already called usb_set_intfdata(intf, NULL) (drivers/usb/core/driver.c, end of usb_unbind_interface). A cat billboard/version that races an unplug or unbind then dereferences bb == NULL at bb->cap. The per-mode attributes are safe because they use container_of. Fix: create the group with device_add_group() in probe and remove it in billboard_disconnect() (:405) before returning. Alternatively, give the device-wide attributes the same embedded container_of back-pointer the per-mode ones already use, so none of them read intfdata.

  2. Nit: f7205f4 only fixes f94a3f9, whose message still describes altmode<N>/ subdirectories. Squash the two into one commit, so the log describes the layout that actually ships.

Everything else I checked is sound. BOS walking is bounded by wTotalLength and bLength (:284-288). The mode count is validated against bLength before aum[] is indexed (:352-359). The bmConfigured decode uses two bits per mode (:108). The capability is copied, so a reset that replaces udev->bos does no harm (:367). Strings are freed after the group (:307-321). The uapi structs are packed with sizes of 44 + 4n and 8 bytes. The driver has no SoC or board dependency.

HW row: a full kernel from this head with CONFIG_USB_BILLBOARD=m, on the Neo or any lab Mac with the RTS5411 dock. Bind the driver, then run a loop of cat billboard/* against 50 unbind/bind cycles and one physical unplug while reading, with no oops. The sysfs values should still match lsusb -v. The run should show 0 AVC, 0 failed units and no new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

…leared

The device-wide attributes (version, num_modes, vconn_power, ...) look up
their state with usb_get_intfdata(). The billboard group was added with
devm_device_add_group(), so devres removed it only in
device_unbind_cleanup(), after usb_unbind_interface() had already called
usb_set_intfdata(intf, NULL). A read of billboard/version racing an unbind
or an unplug could therefore dereference a NULL struct usb_billboard.

Add the group with device_add_group() and remove it in
billboard_disconnect(), which runs while the interface data is still set.
Sysfs removal waits for show() calls already running, so once disconnect
returns no reader can see the cleared pointer, and the devres-managed
state (the struct, the attribute array, the names and the strings) is
freed only after the files are gone. The driver core's dev_groups do not
fit here because the group is built per device: its file names depend on
the number of modes the device reports.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Added 5cdb7b2: remove the billboard sysfs group in disconnect, while intfdata is still set (devres removed it only after usb_unbind_interface() cleared intfdata, so a racing read of billboard/version could dereference NULL). arm64 object build clean. Still owed: unplug-while-reading row on a Billboard device.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 8465e83 once the required checks and remaining validation clear.

Checked: Billboard 1.2.2 table 3-5 and Appendix A specify the 0x11/0/0 interface tuple, and the VCONN and two-bit mode-state tables agree with the decoder. The match is class-wide. The driver removes the sysfs group during disconnect, while interface data is live, and group removal drains active readers before devres cleanup. Reviewed the descriptor layouts, optional per-mode files and ABI docs. No DT change. The forward merge does not touch the driver or its integration files. The J473 receipt covers active sysfs readers across 20 rebinds, with shared USB smoke on J316s and J473. Keep hosted checks and the physical disconnect row visible.

Spec: https://www.usb.org/document-library/billboard-device-class-spec-revision-122-and-adopters-agreement

@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 28, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at 8465e832: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text, pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 8465e832, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · all Macs (new module, binds USB class 0x11 only; uapi ch9.h gains descriptor structs)

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at 8465e832. App approved, rows J473, new-driver-binds-Billboard-only. Merges 1 h from now under the 6-point rule once hosted CI is green, unless you object.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging under the 6-point rule (Ryan 09:29, permanent), at 8465e832. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J473;new-driver-binds-Billboard-only. (5) There's no blocking review. (6) Dj was pinged here 355 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit 2cee796 into main Nov 29, 2026
26 of 31 checks passed
@RyanTheTide
RyanTheTide deleted the drvgap/usb-billboard-v2 branch November 29, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant