habanalabs: use enum for CB allocation options

In the future there will be situations where queues can accept either
kernel allocated CBs or user allocated CBs, depending on different
states.

Therefore, instead of using a boolean variable of kernel/user allocated
CB, we need to use a bitmask to indicate that, which will allow to
combine the two options.

Add a flag to the uapi so the user will be able to indicate whether
the CB was allocated by kernel or by user. Of course the driver
validates that.

Signed-off-by: Tal Cohen <talcohen@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
This commit is contained in:
Tal Cohen
2020-06-03 09:25:27 +03:00
committed by Oded Gabbay
parent 3c68157fb8
commit 4bb1f2f3fb
5 changed files with 73 additions and 12 deletions

View File

@@ -490,6 +490,22 @@ union hl_cb_args {
struct hl_cb_out out;
};
/* HL_CS_CHUNK_FLAGS_ values
*
* HL_CS_CHUNK_FLAGS_USER_ALLOC_CB:
* Indicates if the CB was allocated and mapped by userspace.
* User allocated CB is a command buffer allocated by the user, via malloc
* (or similar). After allocating the CB, the user invokes memory ioctl
* to map the user memory into a device virtual address. The user provides
* this address via the cb_handle field. The interface provides the
* ability to create a large CBs, Which arent limited to
* HL_MAX_CB_SIZE. Therefore, it increases the PCI-DMA queues
* throughput. This CB allocation method also reduces the use of Linux
* DMA-able memory pool. Which are limited and used by other Linux
* sub-systems.
*/
#define HL_CS_CHUNK_FLAGS_USER_ALLOC_CB 0x1
/*
* This structure size must always be fixed to 64-bytes for backward
* compatibility