aboutsummaryrefslogtreecommitdiff
path: root/include/uapi/linux/usbdevice_fs.h
diff options
context:
space:
mode:
authorGravatar Steinar H. Gunderson <sesse@google.com> 2016-02-03 22:58:26 +0100
committerGravatar Greg Kroah-Hartman <gregkh@linuxfoundation.org> 2016-02-14 17:11:48 -0800
commitf7d34b445abc00e979b7cf36b9580ac3d1a47cd8 (patch)
tree15c9c157610e3e999a5a8de14b610724ca7bac31 /include/uapi/linux/usbdevice_fs.h
parentusb: add HAS_IOMEM dependency to USB_ISP1362_HCD (diff)
downloadlinux-f7d34b445abc00e979b7cf36b9580ac3d1a47cd8.tar.gz
linux-f7d34b445abc00e979b7cf36b9580ac3d1a47cd8.tar.bz2
linux-f7d34b445abc00e979b7cf36b9580ac3d1a47cd8.zip
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 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>
Diffstat (limited to 'include/uapi/linux/usbdevice_fs.h')
-rw-r--r--include/uapi/linux/usbdevice_fs.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/uapi/linux/usbdevice_fs.h b/include/uapi/linux/usbdevice_fs.h
index 019ba1e0799a..ecbd17650e6c 100644
--- a/include/uapi/linux/usbdevice_fs.h
+++ b/include/uapi/linux/usbdevice_fs.h
@@ -134,6 +134,7 @@ struct usbdevfs_hub_portinfo {
#define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04
#define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08
#define USBDEVFS_CAP_REAP_AFTER_DISCONNECT 0x10
+#define USBDEVFS_CAP_MMAP 0x20
/* USBDEVFS_DISCONNECT_CLAIM flags & struct */