linux/include/uapi/linux/usb
Neill Kapron 0f0ea552cd usb: gadget: f_fs: Introduce rw_proxy file descriptors
Currently, FunctionFS exposes each USB endpoint as a separate,
unidirectional file descriptor (e.g., `ep1` for IN, `ep2` for OUT).
While this mirrors the underlying hardware structure, it forces
userspace daemons implementing bidirectional protocols to manage
multiple file descriptors. When dealing with legacy protocols which
require exposing a single, bi-directional fd to userspace, this becomes
problematic.

This patch introduces the `FUNCTIONFS_RW_PROXY_EPS` UAPI flag. When
passed in the descriptor header during initialization, FunctionFS
provisions a "rw_proxy" bidirectional file descriptor (e.g., `ep1_rw`)
alongside every pair of IN/OUT endpoints.

Implementation details:
- RW proxy files act as a pure VFS alias, proxying operations
  directly to the base ffs_epfile instances. A `read()` proxies to
  the OUT endpoint's file, and a `write()` proxies to the IN file.
- Because operations are proxied natively, they reuse the underlying
  base endpoint's lock (`epfile->mutex`) and tracking state. This
  serializes concurrent I/O, preventing buffer corruption or races
  even if userspace mixes transfers across both the rw_proxy and base files
  while allowing full-duplex synchronous operations to occur concurrently
  without serializing on a single lock.
- Control operations (like IOCTLs) and intentional stalls (via
  reverse-direction I/O) must still be issued on the base endpoints, as the
  rw_proxy returns `-ENOTTY` for IOCTLs and cannot trigger stalls.

Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Neill Kapron <nkapron@google.com>
Link: https://patch.msgid.link/20260619040609.4010746-5-nkapron@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-07-10 15:00:47 +02:00
..
audio.h
cdc-wdm.h
cdc.h uapi: cdc.h: cleanly provide for more interfaces and countries 2025-11-21 15:12:12 +01:00
ch9.h USB: uapi: add BULK_MAX_PACKET_UPDATE 2026-03-30 16:55:36 +02:00
ch11.h USB: Remove remnants of Wireless USB and UWB 2023-08-09 14:17:06 +02:00
charger.h
functionfs.h usb: gadget: f_fs: Introduce rw_proxy file descriptors 2026-07-10 15:00:47 +02:00
g_hid.h USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL 2024-08-22 17:25:59 +08:00
g_printer.h
g_uvc.h usb: gadget: uvc: default the ctrl request interface offsets 2022-10-22 13:22:40 +02:00
gadgetfs.h USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL 2024-08-22 17:25:59 +08:00
midi.h
raw_gadget.h usb: raw-gadget: report suspend, resume, reset, and disconnect events 2023-10-27 12:58:16 +02:00
tmc.h
video.h media: uvcvideo: implement UVC v1.5 ROI 2025-03-03 18:23:36 +01:00