• Paul Cercueil's avatar
    iio: core: Add new DMABUF interface infrastructure · 3e26d9f0
    Paul Cercueil authored
    Add the necessary infrastructure to the IIO core to support a new
    optional DMABUF based interface.
    
    With this new interface, DMABUF objects (externally created) can be
    attached to a IIO buffer, and subsequently used for data transfer.
    
    A userspace application can then use this interface to share DMABUF
    objects between several interfaces, allowing it to transfer data in a
    zero-copy fashion, for instance between IIO and the USB stack.
    
    The userspace application can also memory-map the DMABUF objects, and
    access the sample data directly. The advantage of doing this vs. the
    read() interface is that it avoids an extra copy of the data between the
    kernel and userspace. This is particularly userful for high-speed
    devices which produce several megabytes or even gigabytes of data per
    second.
    
    As part of the interface, 3 new IOCTLs have been added:
    
    IIO_BUFFER_DMABUF_ATTACH_IOCTL(int fd):
     Attach the DMABUF object identified by the given file descriptor to the
     buffer.
    
    IIO_BUFFER_DMABUF_DETACH_IOCTL(int fd):
     Detach the DMABUF object identified by the given file descriptor from
     the buffer. Note that closing the IIO buffer's file descriptor will
     automatically detach all previously attached DMABUF objects.
    
    IIO_BUFFER_DMABUF_ENQUEUE_IOCTL(struct iio_dmabuf *):
     Request a data transfer to/from the given DMABUF object. Its file
     descriptor, as well as the transfer size and flags are provided in the
     "iio_dmabuf" structure.
    
    These three IOCTLs have to be performed on the IIO buffer's file
    descriptor, obtained using the IIO_BUFFER_GET_FD_IOCTL() ioctl.
    Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
    Co-developed-by: default avatarNuno Sa <nuno.sa@analog.com>
    Signed-off-by: default avatarNuno Sa <nuno.sa@analog.com>
    Link: https://patch.msgid.link/20240620122726.41232-4-paul@crapouillou.netSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    3e26d9f0
Kconfig 3.39 KB