Skip to content

Commit bf80872

Browse files
pcercueinunojsa
authored andcommitted
Documentation: usb: Document FunctionFS DMABUF API
Add documentation for the three ioctls used to attach or detach externally-created DMABUFs, and to request transfers from/to previously attached DMABUFs. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20240130122340.54813-5-paul@crapouillou.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c5acd3c commit bf80872

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Documentation/usb/functionfs.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
How FunctionFS works
33
====================
44

5+
Overview
6+
========
7+
58
From kernel point of view it is just a composite function with some
69
unique behaviour. It may be added to an USB configuration only after
710
the user space driver has registered by writing descriptors and
@@ -66,3 +69,36 @@ have been written to their ep0's.
6669

6770
Conversely, the gadget is unregistered after the first USB function
6871
closes its endpoints.
72+
73+
DMABUF interface
74+
================
75+
76+
FunctionFS additionally supports a DMABUF based interface, where the
77+
userspace can attach DMABUF objects (externally created) to an endpoint,
78+
and subsequently use them for data transfers.
79+
80+
A userspace application can then use this interface to share DMABUF
81+
objects between several interfaces, allowing it to transfer data in a
82+
zero-copy fashion, for instance between IIO and the USB stack.
83+
84+
As part of this interface, three new IOCTLs have been added. These three
85+
IOCTLs have to be performed on a data endpoint (ie. not ep0). They are:
86+
87+
``FUNCTIONFS_DMABUF_ATTACH(int)``
88+
Attach the DMABUF object, identified by its file descriptor, to the
89+
data endpoint. Returns zero on success, and a negative errno value
90+
on error.
91+
92+
``FUNCTIONFS_DMABUF_DETACH(int)``
93+
Detach the given DMABUF object, identified by its file descriptor,
94+
from the data endpoint. Returns zero on success, and a negative
95+
errno value on error. Note that closing the endpoint's file
96+
descriptor will automatically detach all attached DMABUFs.
97+
98+
``FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)``
99+
Enqueue the previously attached DMABUF to the transfer queue.
100+
The argument is a structure that packs the DMABUF's file descriptor,
101+
the size in bytes to transfer (which should generally correspond to
102+
the size of the DMABUF), and a 'flags' field which is unused
103+
for now. Returns zero on success, and a negative errno value on
104+
error.

0 commit comments

Comments
 (0)