nvdla: kmd: Expose full set of limits for task parameters

- Certain task parameter limits were not exposed to UMD / Users
- Expose these limits and rename to provide consistent KMD interface
across linux / qnx

Jira DLA-4467

Change-Id: Ibcf1de5f4d442d9b1f3fefaf71195bc6e58fff5c
Signed-off-by: Anup Mahindre <amahindre@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2546453
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2558254
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Anup Mahindre
2021-06-17 11:41:08 +05:30
committed by Laxman Dewangan
parent 584f8bd83d
commit 911977d5dd
4 changed files with 60 additions and 59 deletions

View File

@@ -118,16 +118,6 @@
*/ */
#define CMD_TIMEOUT_MSEC (1000) #define CMD_TIMEOUT_MSEC (1000)
/**
* Max number of fences supported
*/
#define MAX_NUM_NVDLA_PREFENCES 32
#define MAX_NUM_NVDLA_POSTFENCES 32
#define MAX_NUM_NVDLA_EMU_PREFENCES 16
#define MAX_NUM_NVDLA_EMU_POSTFENCES 16
#define MAX_NUM_NVDLA_IN_TASK_STATUS MAX_NUM_NVDLA_PREFENCES
#define MAX_NUM_NVDLA_OUT_TASK_STATUS MAX_NUM_NVDLA_POSTFENCES
#define MAX_NUM_NVDLA_OUT_TIMESTAMP 32
#define NUM_PROFILING_POSTACTION 1 #define NUM_PROFILING_POSTACTION 1
#define MAX_COMMANDS_PER_DEVICE 1 #define MAX_COMMANDS_PER_DEVICE 1
@@ -257,8 +247,8 @@ struct nvdla_device {
struct nvdla_emu_task { struct nvdla_emu_task {
struct nvdla_queue *queue; struct nvdla_queue *queue;
struct nvhost_syncpt *sp; struct nvhost_syncpt *sp;
struct nvdev_fence prefences[MAX_NUM_NVDLA_EMU_PREFENCES]; struct nvdev_fence prefences[MAX_NVDLA_EMU_PREFENCES_PER_TASK];
struct nvdev_fence postfences[MAX_NUM_NVDLA_EMU_POSTFENCES]; struct nvdev_fence postfences[MAX_NVDLA_EMU_POSTFENCES_PER_TASK];
u32 num_prefences; u32 num_prefences;
u32 num_postfences; u32 num_postfences;
u32 fence; u32 fence;
@@ -287,13 +277,13 @@ struct nvdla_task {
struct nvdla_queue *queue; struct nvdla_queue *queue;
struct nvdla_buffers *buffers; struct nvdla_buffers *buffers;
struct nvhost_syncpt *sp; struct nvhost_syncpt *sp;
struct nvdev_fence prefences[MAX_NUM_NVDLA_PREFENCES]; struct nvdev_fence prefences[MAX_NVDLA_PREFENCES_PER_TASK];
struct nvdev_fence postfences[MAX_NUM_NVDLA_POSTFENCES]; struct nvdev_fence postfences[MAX_NVDLA_POSTFENCES_PER_TASK];
struct nvdla_status_notify in_task_status[MAX_NUM_NVDLA_IN_TASK_STATUS]; struct nvdla_status_notify in_task_status[MAX_NVDLA_IN_STATUS_PER_TASK];
struct nvdla_status_notify sof_task_status[MAX_NUM_NVDLA_OUT_TASK_STATUS]; struct nvdla_status_notify sof_task_status[MAX_NVDLA_OUT_STATUS_PER_TASK];
struct nvdla_status_notify eof_task_status[MAX_NUM_NVDLA_OUT_TASK_STATUS]; struct nvdla_status_notify eof_task_status[MAX_NVDLA_OUT_STATUS_PER_TASK];
struct nvdla_mem_handle sof_timestamps[MAX_NUM_NVDLA_OUT_TIMESTAMP]; struct nvdla_mem_handle sof_timestamps[MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK];
struct nvdla_mem_handle eof_timestamps[MAX_NUM_NVDLA_OUT_TIMESTAMP]; struct nvdla_mem_handle eof_timestamps[MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK];
struct nvdla_mem_handle memory_handles[MAX_NVDLA_BUFFERS_PER_TASK]; struct nvdla_mem_handle memory_handles[MAX_NVDLA_BUFFERS_PER_TASK];
u8 num_prefences; u8 num_prefences;
u8 num_postfences; u8 num_postfences;
@@ -314,13 +304,13 @@ struct nvdla_task {
int pool_index; int pool_index;
struct dma_buf *memory_dmabuf[MAX_NVDLA_BUFFERS_PER_TASK]; struct dma_buf *memory_dmabuf[MAX_NVDLA_BUFFERS_PER_TASK];
struct dma_buf *prefences_sem_dmabuf[MAX_NUM_NVDLA_PREFENCES]; struct dma_buf *prefences_sem_dmabuf[MAX_NVDLA_PREFENCES_PER_TASK];
struct dma_buf *in_task_status_dmabuf[MAX_NUM_NVDLA_IN_TASK_STATUS]; struct dma_buf *in_task_status_dmabuf[MAX_NVDLA_IN_STATUS_PER_TASK];
struct dma_buf *postfences_sem_dmabuf[MAX_NUM_NVDLA_POSTFENCES]; struct dma_buf *postfences_sem_dmabuf[MAX_NVDLA_POSTFENCES_PER_TASK];
struct dma_buf *sof_task_status_dmabuf[MAX_NUM_NVDLA_OUT_TASK_STATUS]; struct dma_buf *sof_task_status_dmabuf[MAX_NVDLA_OUT_STATUS_PER_TASK];
struct dma_buf *eof_task_status_dmabuf[MAX_NUM_NVDLA_OUT_TASK_STATUS]; struct dma_buf *eof_task_status_dmabuf[MAX_NVDLA_OUT_STATUS_PER_TASK];
struct dma_buf *sof_timestamps_dmabuf[MAX_NUM_NVDLA_OUT_TIMESTAMP]; struct dma_buf *sof_timestamps_dmabuf[MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK];
struct dma_buf *eof_timestamps_dmabuf[MAX_NUM_NVDLA_OUT_TIMESTAMP]; struct dma_buf *eof_timestamps_dmabuf[MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK];
}; };
struct dla_mem_addr { struct dla_mem_addr {

View File

@@ -652,44 +652,44 @@ size_t nvdla_get_max_task_size(void)
static int nvdla_val_task_submit_input(struct nvdla_ioctl_submit_task *in_task) static int nvdla_val_task_submit_input(struct nvdla_ioctl_submit_task *in_task)
{ {
if (in_task->num_prefences > MAX_NUM_NVDLA_PREFENCES) { if (in_task->num_prefences > MAX_NVDLA_PREFENCES_PER_TASK) {
pr_err("num_prefences[%u] crossing expected[%d]\n", pr_err("num_prefences[%u] crossing expected[%d]\n",
in_task->num_prefences, MAX_NUM_NVDLA_PREFENCES); in_task->num_prefences, MAX_NVDLA_PREFENCES_PER_TASK);
return -EINVAL; return -EINVAL;
} }
if (in_task->num_postfences > MAX_NUM_NVDLA_POSTFENCES) { if (in_task->num_postfences > MAX_NVDLA_POSTFENCES_PER_TASK) {
pr_err("num_postfences[%u] crossing expected[%d]\n", pr_err("num_postfences[%u] crossing expected[%d]\n",
in_task->num_postfences, MAX_NUM_NVDLA_POSTFENCES); in_task->num_postfences, MAX_NVDLA_POSTFENCES_PER_TASK);
return -EINVAL; return -EINVAL;
} }
if (in_task->num_input_task_status > MAX_NUM_NVDLA_IN_TASK_STATUS) { if (in_task->num_input_task_status > MAX_NVDLA_IN_STATUS_PER_TASK) {
pr_err("in task status[%u] crossing expected[%d]\n", pr_err("in task status[%u] crossing expected[%d]\n",
in_task->num_input_task_status, in_task->num_input_task_status,
MAX_NUM_NVDLA_IN_TASK_STATUS); MAX_NVDLA_IN_STATUS_PER_TASK);
return -EINVAL; return -EINVAL;
} }
if (in_task->num_sof_task_status > MAX_NUM_NVDLA_OUT_TASK_STATUS) { if (in_task->num_sof_task_status > MAX_NVDLA_OUT_STATUS_PER_TASK) {
pr_err("sof task status[%u] crossing expected[%d]\n", pr_err("sof task status[%u] crossing expected[%d]\n",
in_task->num_sof_task_status, in_task->num_sof_task_status,
MAX_NUM_NVDLA_OUT_TASK_STATUS); MAX_NVDLA_OUT_STATUS_PER_TASK);
return -EINVAL; return -EINVAL;
} }
if (in_task->num_eof_task_status > MAX_NUM_NVDLA_OUT_TASK_STATUS) { if (in_task->num_eof_task_status > MAX_NVDLA_OUT_STATUS_PER_TASK) {
pr_err("eof task status[%u] crossing expected[%d]\n", pr_err("eof task status[%u] crossing expected[%d]\n",
in_task->num_eof_task_status, in_task->num_eof_task_status,
MAX_NUM_NVDLA_OUT_TASK_STATUS); MAX_NVDLA_OUT_STATUS_PER_TASK);
return -EINVAL; return -EINVAL;
} }
if (in_task->num_sof_timestamps > MAX_NUM_NVDLA_OUT_TIMESTAMP) { if (in_task->num_sof_timestamps > MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK) {
pr_err("sof timestamps[%u] crossing expected[%d]\n", pr_err("sof timestamps[%u] crossing expected[%d]\n",
in_task->num_sof_timestamps, in_task->num_sof_timestamps,
MAX_NUM_NVDLA_OUT_TIMESTAMP); MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK);
return -EINVAL; return -EINVAL;
} }
if (in_task->num_eof_timestamps > MAX_NUM_NVDLA_OUT_TIMESTAMP) { if (in_task->num_eof_timestamps > MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK) {
pr_err("eof timestamps[%u] crossing expected[%d]\n", pr_err("eof timestamps[%u] crossing expected[%d]\n",
in_task->num_eof_timestamps, in_task->num_eof_timestamps,
MAX_NUM_NVDLA_OUT_TIMESTAMP); MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK);
return -EINVAL; return -EINVAL;
} }
if (in_task->num_addresses < 1) { if (in_task->num_addresses < 1) {
@@ -867,7 +867,7 @@ static int nvdla_emu_task_submit(struct nvdla_private *priv, void *arg)
struct nvdla_submit_args *args = struct nvdla_submit_args *args =
(struct nvdla_submit_args *)arg; (struct nvdla_submit_args *)arg;
struct nvdla_ioctl_emu_submit_task __user *user_tasks; struct nvdla_ioctl_emu_submit_task __user *user_tasks;
struct nvdla_ioctl_emu_submit_task local_tasks[MAX_TASKS_PER_SUBMIT]; struct nvdla_ioctl_emu_submit_task local_tasks[MAX_NVDLA_TASKS_PER_SUBMIT];
struct platform_device *pdev; struct platform_device *pdev;
struct nvdla_queue *queue; struct nvdla_queue *queue;
struct nvdla_emu_task task; struct nvdla_emu_task task;
@@ -893,7 +893,7 @@ static int nvdla_emu_task_submit(struct nvdla_private *priv, void *arg)
return -EINVAL; return -EINVAL;
num_tasks = args->num_tasks; num_tasks = args->num_tasks;
if (num_tasks == 0 || num_tasks > MAX_TASKS_PER_SUBMIT) if (num_tasks == 0 || num_tasks > MAX_NVDLA_TASKS_PER_SUBMIT)
return -EINVAL; return -EINVAL;
nvdla_dbg_info(pdev, "num of emulator tasks [%d]", num_tasks); nvdla_dbg_info(pdev, "num of emulator tasks [%d]", num_tasks);
@@ -1022,7 +1022,7 @@ static int nvdla_submit(struct nvdla_private *priv, void *arg)
struct nvdla_submit_args *args = struct nvdla_submit_args *args =
(struct nvdla_submit_args *)arg; (struct nvdla_submit_args *)arg;
struct nvdla_ioctl_submit_task __user *user_tasks; struct nvdla_ioctl_submit_task __user *user_tasks;
struct nvdla_ioctl_submit_task local_tasks[MAX_TASKS_PER_SUBMIT]; struct nvdla_ioctl_submit_task local_tasks[MAX_NVDLA_TASKS_PER_SUBMIT];
struct platform_device *pdev; struct platform_device *pdev;
struct nvdla_queue *queue; struct nvdla_queue *queue;
struct nvdla_buffers *buffers; struct nvdla_buffers *buffers;
@@ -1048,7 +1048,7 @@ static int nvdla_submit(struct nvdla_private *priv, void *arg)
return -EINVAL; return -EINVAL;
num_tasks = args->num_tasks; num_tasks = args->num_tasks;
if (num_tasks == 0 || num_tasks > MAX_TASKS_PER_SUBMIT) if (num_tasks == 0 || num_tasks > MAX_NVDLA_TASKS_PER_SUBMIT)
return -EINVAL; return -EINVAL;
nvdla_dbg_info(pdev, "num of tasks [%d]", num_tasks); nvdla_dbg_info(pdev, "num of tasks [%d]", num_tasks);

View File

@@ -297,32 +297,32 @@ static void nvdla_task_syncpt_reset(struct nvhost_syncpt *syncpt,
static inline int nvdla_get_max_preaction_size(void) static inline int nvdla_get_max_preaction_size(void)
{ {
return (((MAX_NUM_NVDLA_PREFENCES + MAX_NUM_NVDLA_IN_TASK_STATUS + return (((MAX_NVDLA_PREFENCES_PER_TASK + MAX_NVDLA_IN_STATUS_PER_TASK +
MAX_NUM_NVDLA_OUT_TASK_STATUS + MAX_NVDLA_OUT_STATUS_PER_TASK +
MAX_NUM_NVDLA_OUT_TIMESTAMP) * MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK) *
sizeof(struct dla_action_opcode)) + sizeof(struct dla_action_opcode)) +
(MAX_NUM_NVDLA_PREFENCES * (MAX_NVDLA_PREFENCES_PER_TASK *
sizeof(struct dla_action_semaphore)) + sizeof(struct dla_action_semaphore)) +
((MAX_NUM_NVDLA_IN_TASK_STATUS + MAX_NUM_NVDLA_OUT_TASK_STATUS) * ((MAX_NVDLA_IN_STATUS_PER_TASK + MAX_NVDLA_OUT_STATUS_PER_TASK) *
sizeof(struct dla_action_task_status)) + sizeof(struct dla_action_task_status)) +
(MAX_NUM_NVDLA_OUT_TIMESTAMP * (MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK *
sizeof(struct dla_action_timestamp)) + sizeof(struct dla_action_timestamp)) +
sizeof(struct dla_action_opcode)); sizeof(struct dla_action_opcode));
} }
static inline int nvdla_get_max_postaction_size(void) static inline int nvdla_get_max_postaction_size(void)
{ {
return (((MAX_NUM_NVDLA_POSTFENCES + return (((MAX_NVDLA_POSTFENCES_PER_TASK +
MAX_NUM_NVDLA_OUT_TASK_STATUS + MAX_NVDLA_OUT_STATUS_PER_TASK +
MAX_NUM_NVDLA_OUT_TIMESTAMP + MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK +
NUM_PROFILING_POSTACTION) * NUM_PROFILING_POSTACTION) *
sizeof(struct dla_action_opcode)) + sizeof(struct dla_action_opcode)) +
(MAX_NUM_NVDLA_POSTFENCES * (MAX_NVDLA_POSTFENCES_PER_TASK *
sizeof(struct dla_action_semaphore)) + sizeof(struct dla_action_semaphore)) +
((MAX_NUM_NVDLA_OUT_TASK_STATUS + ((MAX_NVDLA_OUT_STATUS_PER_TASK +
NUM_PROFILING_POSTACTION) * NUM_PROFILING_POSTACTION) *
sizeof(struct dla_action_task_status)) + sizeof(struct dla_action_task_status)) +
(MAX_NUM_NVDLA_OUT_TIMESTAMP * (MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK *
sizeof(struct dla_action_timestamp)) + sizeof(struct dla_action_timestamp)) +
sizeof(struct dla_action_opcode)); sizeof(struct dla_action_opcode));
} }
@@ -1328,8 +1328,8 @@ static int nvdla_send_cmd_channel(struct platform_device *pdev,
uint32_t method_id = cmd_data->method_id; uint32_t method_id = cmd_data->method_id;
uint32_t method_data = cmd_data->method_data; uint32_t method_data = cmd_data->method_data;
bool wait = cmd_data->wait; bool wait = cmd_data->wait;
u32 syncpt_wait_ids[MAX_NUM_NVDLA_PREFENCES]; u32 syncpt_wait_ids[MAX_NVDLA_PREFENCES_PER_TASK];
u32 syncpt_wait_thresh[MAX_NUM_NVDLA_PREFENCES]; u32 syncpt_wait_thresh[MAX_NVDLA_PREFENCES_PER_TASK];
u32 cmdbuf[3]; u32 cmdbuf[3];
int err = 0, i; int err = 0, i;

View File

@@ -28,6 +28,17 @@
#define __user #define __user
#endif #endif
/**
* Limits exposed to userspace
*/
#define MAX_NVDLA_PREFENCES_PER_TASK 32
#define MAX_NVDLA_POSTFENCES_PER_TASK 32
#define MAX_NVDLA_EMU_PREFENCES_PER_TASK 16
#define MAX_NVDLA_EMU_POSTFENCES_PER_TASK 16
#define MAX_NVDLA_IN_STATUS_PER_TASK MAX_NVDLA_PREFENCES_PER_TASK
#define MAX_NVDLA_OUT_STATUS_PER_TASK MAX_NVDLA_POSTFENCES_PER_TASK
#define MAX_NVDLA_OUT_TIMESTAMPS_PER_TASK 32
/** /**
* struct nvdla_queue_stat_args strcture * struct nvdla_queue_stat_args strcture
* *
@@ -94,7 +105,7 @@ struct nvdla_pin_unpin_args {
struct nvdla_submit_args { struct nvdla_submit_args {
__u64 tasks; __u64 tasks;
__u16 num_tasks; __u16 num_tasks;
#define MAX_TASKS_PER_SUBMIT 16 #define MAX_NVDLA_TASKS_PER_SUBMIT 16
#define NVDLA_SUBMIT_FLAGS_ATOMIC (1 << 0) #define NVDLA_SUBMIT_FLAGS_ATOMIC (1 << 0)
#define NVDLA_SUBMIT_FLAGS_BYPASS_EXEC (1 << 1) #define NVDLA_SUBMIT_FLAGS_BYPASS_EXEC (1 << 1)
__u16 flags; __u16 flags;