linux/include
Steinar H. Gunderson 377e6b874e BACKPORT: USB: Add support for usbfs zerocopy.
Add a new interface for userspace to preallocate memory that can be
used with usbfs. This gives two primary benefits:

 - Zerocopy; data no longer needs to be copied between the userspace
   and the kernel, but can instead be read directly by the driver from
   userspace's buffers. This works for all kinds of transfers (even if
   nonsensical for control and interrupt transfers); isochronous also
   no longer need to memset() the buffer to zero to avoid leaking kernel data.

 - Once the buffers are allocated, USB transfers can no longer fail due to
   memory fragmentation; previously, long-running programs could run into
   problems finding a large enough contiguous memory chunk, especially on
   embedded systems or at high rates.

Memory is allocated by using mmap() against the usbfs file descriptor,
and similarly deallocated by munmap(). Once memory has been allocated,
using it as pointers to a bulk or isochronous operation means you will
automatically get zerocopy behavior. Note that this also means you cannot
modify outgoing data until the transfer is complete. The same holds for
data on the same cache lines as incoming data; DMA modifying them at the
same time could lead to your changes being overwritten.

There's a new capability USBDEVFS_CAP_MMAP that userspace can query to see
if the running kernel supports this functionality, if just trying mmap() is
not acceptable.

Largely based on a patch by Markus Rechberger with some updates. The original
patch can be found at:

  http://sundtek.de/support/devio_mmap_v0.4.diff

Change-Id: I22f101b6e1a1fb027288f1c345da1750c39396c9
Signed-off-by: Steinar H. Gunderson <sesse@google.com>
Signed-off-by: Markus Rechberger <mrechberger@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit f7d34b445a)
2018-11-27 19:47:04 +08:00
..
acpi
asm-generic Merge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android 2018-10-03 15:00:28 +05:30
clocksource
crypto Merge branch 'linux-linaro-lsk-v4.4-android' of git://git.linaro.org/kernel/linux-linaro-stable.git 2018-10-10 19:37:13 +08:00
drm UPSTREAM: drm/dsi: Implement DCS set/get display brightness 2018-10-08 16:32:58 +08:00
dt-bindings dt-bindings: suspend: rk3328: add sleep mode config defines 2018-11-23 17:44:13 +08:00
keys
kvm
linux mfd: rk618: Fix subdevices name 2018-11-27 15:09:00 +08:00
math-emu
media camera: rockchip: merge modification of rv1108 isp11 2018-07-25 14:52:52 +08:00
memory
misc
net Merge branch 'linux-linaro-lsk-v4.4-android' of git://git.linaro.org/kernel/linux-linaro-stable.git 2018-10-10 19:37:13 +08:00
pcmcia
ras
rdma IB/core: Make testing MR flags for writability a static inline function 2018-08-15 17:42:06 +02:00
rxrpc
scsi
soc PM / devfreq: rockchip_dmc: add support for rk1808 2018-11-16 15:09:32 +08:00
sound ASoC: rockchip: vad: add snd_pcm_vad_memcpy 2018-08-24 14:55:33 +08:00
target
trace LSK 18.06 v4.4-android 2018-07-06 20:12:54 +08:00
uapi BACKPORT: USB: Add support for usbfs zerocopy. 2018-11-27 19:47:04 +08:00
video Merge branch 'linux-linaro-lsk-v4.4-android' of git://git.linaro.org/kernel/linux-linaro-stable.git 2018-10-10 19:37:13 +08:00
xen
Kbuild