From d0cbf337d60aef7a6d96fc8c965e22c987f094a1 Mon Sep 17 00:00:00 2001 From: Anup Mahindre Date: Tue, 23 Mar 2021 12:37:06 +0530 Subject: 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 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 Tested-by: mobile promotions Reviewed-by: Bharat Nihalani Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/video/tegra/host/nvdla/nvdla_queue.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'drivers') 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 @@ /* * NVDLA queue and task management for T194 * - * Copyright (c) 2016-2019, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2016-2021, NVIDIA Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * 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) /* unpin address list */ for (ii = 0; ii < task->num_addresses; ii++) { + if (task->memory_handles[ii].type == + NVDLA_BUFFER_TYPE_INTERNAL) { + /* No unpinning required for internal buffers */ + continue; + } if (task->memory_handles[ii].handle) { nvdla_buffer_submit_unpin(task->buffers, &task->memory_dmabuf[ii], 1); @@ -524,15 +529,24 @@ static int nvdla_map_task_memory(struct nvdla_task *task) for (jj = 0; jj < task->num_addresses; jj++) { dma_addr_t dma_addr; size_t dma_size; - err = -EFAULT; nvdla_dbg_info(pdev, "count[%d] handle[%u] offset[%u]", jj, task->memory_handles[jj].handle, task->memory_handles[jj].offset); - if (!task->memory_handles[jj].handle) + if (task->memory_handles[jj].type == + NVDLA_BUFFER_TYPE_INTERNAL) { + /* For internal buffers, offset is the final address */ + next = add_address(next, + task->memory_handles[jj].offset); + continue; + } + + if (!task->memory_handles[jj].handle) { + err = -EFAULT; goto fail_to_pin_mem; + } task->memory_dmabuf[jj] = dma_buf_get(task->memory_handles[jj].handle); -- cgit v1.2.2