diff options
author | Anup Mahindre <amahindre@nvidia.com> | 2021-03-23 03:07:06 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2021-08-16 23:31:56 -0400 |
commit | d0cbf337d60aef7a6d96fc8c965e22c987f094a1 (patch) | |
tree | 50e07895d03e0df02368b072ffe08fd2a024fe5c | |
parent | 046cec39ee6bfcf8f8c6e6d64226175082077834 (diff) |
video: tegra: host: nvdla: Add support for internal buffers
- Add buffer type field to nvdla_mem_handle
- For internal buffers, skip pin and unpin operations and pass the
offset as final adress
- Also update error handling in nvdla_map_task_memory to match with
convention
Jira DLA-4376
JIRA DLA-4908
Bug 3352716
Change-Id: I662da30cb9c606d2f67b792f09e026af391c89d1
Signed-off-by: Anup Mahindre <amahindre@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2503708
(cherry picked from commit a2cc66a3f318394e65f6f126bbb7eaa5ccdae3e2)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2572190
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
-rw-r--r-- | drivers/video/tegra/host/nvdla/nvdla_queue.c | 20 | ||||
-rw-r--r-- | include/uapi/linux/nvhost_nvdla_ioctl.h | 9 |
2 files changed, 25 insertions, 4 deletions
diff --git a/drivers/video/tegra/host/nvdla/nvdla_queue.c b/drivers/video/tegra/host/nvdla/nvdla_queue.c index ccb182b24..db669a522 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_queue.c +++ b/drivers/video/tegra/host/nvdla/nvdla_queue.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * NVDLA queue and task management for T194 | 2 | * NVDLA queue and task management for T194 |
3 | * | 3 | * |
4 | * Copyright (c) 2016-2019, NVIDIA Corporation. All rights reserved. | 4 | * Copyright (c) 2016-2021, NVIDIA Corporation. All rights reserved. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms and conditions of the GNU General Public License, | 7 | * under the terms and conditions of the GNU General Public License, |
@@ -174,6 +174,11 @@ static int nvdla_unmap_task_memory(struct nvdla_task *task) | |||
174 | 174 | ||
175 | /* unpin address list */ | 175 | /* unpin address list */ |
176 | for (ii = 0; ii < task->num_addresses; ii++) { | 176 | for (ii = 0; ii < task->num_addresses; ii++) { |
177 | if (task->memory_handles[ii].type == | ||
178 | NVDLA_BUFFER_TYPE_INTERNAL) { | ||
179 | /* No unpinning required for internal buffers */ | ||
180 | continue; | ||
181 | } | ||
177 | if (task->memory_handles[ii].handle) { | 182 | if (task->memory_handles[ii].handle) { |
178 | nvdla_buffer_submit_unpin(task->buffers, | 183 | nvdla_buffer_submit_unpin(task->buffers, |
179 | &task->memory_dmabuf[ii], 1); | 184 | &task->memory_dmabuf[ii], 1); |
@@ -524,15 +529,24 @@ static int nvdla_map_task_memory(struct nvdla_task *task) | |||
524 | for (jj = 0; jj < task->num_addresses; jj++) { | 529 | for (jj = 0; jj < task->num_addresses; jj++) { |
525 | dma_addr_t dma_addr; | 530 | dma_addr_t dma_addr; |
526 | size_t dma_size; | 531 | size_t dma_size; |
527 | err = -EFAULT; | ||
528 | 532 | ||
529 | nvdla_dbg_info(pdev, "count[%d] handle[%u] offset[%u]", | 533 | nvdla_dbg_info(pdev, "count[%d] handle[%u] offset[%u]", |
530 | jj, | 534 | jj, |
531 | task->memory_handles[jj].handle, | 535 | task->memory_handles[jj].handle, |
532 | task->memory_handles[jj].offset); | 536 | task->memory_handles[jj].offset); |
533 | 537 | ||
534 | if (!task->memory_handles[jj].handle) | 538 | if (task->memory_handles[jj].type == |
539 | NVDLA_BUFFER_TYPE_INTERNAL) { | ||
540 | /* For internal buffers, offset is the final address */ | ||
541 | next = add_address(next, | ||
542 | task->memory_handles[jj].offset); | ||
543 | continue; | ||
544 | } | ||
545 | |||
546 | if (!task->memory_handles[jj].handle) { | ||
547 | err = -EFAULT; | ||
535 | goto fail_to_pin_mem; | 548 | goto fail_to_pin_mem; |
549 | } | ||
536 | 550 | ||
537 | task->memory_dmabuf[jj] = | 551 | task->memory_dmabuf[jj] = |
538 | dma_buf_get(task->memory_handles[jj].handle); | 552 | dma_buf_get(task->memory_handles[jj].handle); |
diff --git a/include/uapi/linux/nvhost_nvdla_ioctl.h b/include/uapi/linux/nvhost_nvdla_ioctl.h index b203fda63..bd427e789 100644 --- a/include/uapi/linux/nvhost_nvdla_ioctl.h +++ b/include/uapi/linux/nvhost_nvdla_ioctl.h | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Tegra NvDLA Driver | 4 | * Tegra NvDLA Driver |
5 | * | 5 | * |
6 | * Copyright (c) 2016-2020, NVIDIA CORPORATION. All rights reserved. | 6 | * Copyright (c) 2016-2021, NVIDIA CORPORATION. All rights reserved. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms and conditions of the GNU General Public License, | 9 | * under the terms and conditions of the GNU General Public License, |
@@ -127,11 +127,18 @@ struct nvdla_get_q_status_args { | |||
127 | * | 127 | * |
128 | * @handle handle to buffer allocated in userspace | 128 | * @handle handle to buffer allocated in userspace |
129 | * @offset offset in buffer | 129 | * @offset offset in buffer |
130 | * @type buffer heap type | ||
131 | * @reserved reserved for future use | ||
130 | * | 132 | * |
131 | */ | 133 | */ |
132 | struct nvdla_mem_handle { | 134 | struct nvdla_mem_handle { |
133 | __u32 handle; | 135 | __u32 handle; |
134 | __u32 offset; | 136 | __u32 offset; |
137 | #define NVDLA_BUFFER_TYPE_MC 0U | ||
138 | #define NVDLA_BUFFER_TYPE_CV 1U | ||
139 | #define NVDLA_BUFFER_TYPE_INTERNAL 2U | ||
140 | __u8 type; | ||
141 | __u8 reserved[3]; | ||
135 | }; | 142 | }; |
136 | 143 | ||
137 | /** | 144 | /** |