The commit f7d34b445abc00e979b7 ("USB: Add support for usbfs zerocopy.") added support for zerocopy operations for an USB Host via devio.c The idea is to mmap buffers into user space, which are then filled with data (either by the kernel for reads or by the user for writes). Using these mmapped buffers avoids copying data between kernel space and user space. The patch proposed here, tries to do the same for a USB Gadget and a user space application using USB Gaget FunctionFS. Note: As long as you do not use mmap and/or libaio, FunctionFS should behave exactly as before. V2: The mmapped buffers are now associated with a "struct file *". This is achieved by adding another in-between "struct ffs_ep_listener", which is allocated per "struct file *". I believe I botched that up in the previous V1 proposal; It seems using a list of mmapped segments associated to a "struct file *" is the right approach? To limit the amount of memory user space processes might mmap, per default this is limited to 16 MiB per FunctionFS mount point. This limit can be modified at the time FunctionFS is mounted, by using the mount option "mmap_memory_mb=<value>", specifying the allowed mmap space in MiB. Example: mount -t functionfs -ommap_memory_mb=1 usb0 /usbfunc A value of 0 means there is NO LIMIT on the amount of memory a user space application might mmap in total. If you want to try out, I updated the demonstration code accordingly: https://github.com/trace32/test_usb_ffs so long Ingo Ingo Rohloff (1): usb: gadget: f_fs: Support zerocopy transfers via mmap. drivers/usb/gadget/function/f_fs.c | 268 ++++++++++++++++++++++++++++- drivers/usb/gadget/function/u_fs.h | 4 + 2 files changed, 266 insertions(+), 6 deletions(-) -- 2.17.1