habanalabs: add command buffer module
This patch adds the command buffer (CB) module, which allows the user to create and destroy CBs and to map them to the user's process address-space. A command buffer is a memory blocks that reside in DMA-able address-space and is physically contiguous so it can be accessed by the device without MMU translation. The command buffer memory is allocated using the coherent DMA API. When creating a new CB, the IOCTL returns a handle of it, and the user-space process needs to use that handle to mmap the buffer to get a VA in the user's address-space. Before destroying (freeing) a CB, the user must unmap the CB's VA using the CB handle. Each CB has a reference counter, which tracks its usage in command submissions and also its mmaps (only a single mmap is allowed). The driver maintains a pool of pre-allocated CBs in order to reduce latency during command submissions. In case the pool is empty, the driver will go to the slow-path of allocating a new CB, i.e. calling dma_alloc_coherent. Reviewed-by:Mike Rapoport <rppt@linux.ibm.com> Signed-off-by:
Oded Gabbay <oded.gabbay@gmail.com> Signed-off-by:
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing
- drivers/misc/habanalabs/Makefile 2 additions, 1 deletiondrivers/misc/habanalabs/Makefile
- drivers/misc/habanalabs/command_buffer.c 433 additions, 0 deletionsdrivers/misc/habanalabs/command_buffer.c
- drivers/misc/habanalabs/device.c 42 additions, 1 deletiondrivers/misc/habanalabs/device.c
- drivers/misc/habanalabs/goya/goya.c 28 additions, 0 deletionsdrivers/misc/habanalabs/goya/goya.c
- drivers/misc/habanalabs/habanalabs.h 86 additions, 0 deletionsdrivers/misc/habanalabs/habanalabs.h
- drivers/misc/habanalabs/habanalabs_drv.c 2 additions, 0 deletionsdrivers/misc/habanalabs/habanalabs_drv.c
- drivers/misc/habanalabs/habanalabs_ioctl.c 99 additions, 0 deletionsdrivers/misc/habanalabs/habanalabs_ioctl.c
- include/uapi/misc/habanalabs.h 46 additions, 0 deletionsinclude/uapi/misc/habanalabs.h
Loading
Please register or sign in to comment