From 36128676f539f48d0eca90e9700afb6236471a2c Mon Sep 17 00:00:00 2001 From: Ketan Patil Date: Thu, 20 Jan 2022 09:38:08 +0000 Subject: [PATCH] video: tegra: host: nvdla: Cleanup GOS functionality GOS functionality is getting deprecated, hence cleanup the corresponding code from nvdla. Bug 3478260 Bug 200722684 Change-Id: I5923804b817fa2ab0421b5e0fdaa1f95cf79cd2e Signed-off-by: Ketan Patil Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2657226 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/video/tegra/host/nvdla/nvdla.c | 86 ---------- drivers/video/tegra/host/nvdla/nvdla.h | 6 +- drivers/video/tegra/host/nvdla/nvdla_queue.c | 159 ++----------------- 3 files changed, 18 insertions(+), 233 deletions(-) diff --git a/drivers/video/tegra/host/nvdla/nvdla.c b/drivers/video/tegra/host/nvdla/nvdla.c index 19d548f4..391ea74e 100644 --- a/drivers/video/tegra/host/nvdla/nvdla.c +++ b/drivers/video/tegra/host/nvdla/nvdla.c @@ -33,7 +33,6 @@ #include "flcn/flcn.h" #include "flcn/hw_flcn.h" -#include "nvhost_gos.h" #include "t194/t194.h" #include "t23x/t23x.h" @@ -523,87 +522,6 @@ fail_to_alloc_debug_dump: return err; } -int nvdla_send_gos_region(struct platform_device *pdev) -{ - int i; - int err; - int num_grids; - struct flcn *m; - dma_addr_t *dla_grid; - struct nvdla_cmd_data cmd_data; - struct dla_region_gos *gos_region = NULL; - struct nvdla_cmd_mem_info gos_cmd_mem_info; - struct nvhost_device_data *pdata = platform_get_drvdata(pdev); - struct nvdla_device *nvdla_dev = pdata->private_data; - - nvdla_dbg_fn(pdev, ""); - - m = get_flcn(pdev); - if (!m) { - nvdla_dbg_err(pdev, "falcon is not booted!"); - err = -ENXIO; - goto falcon_not_booted; - } - - err = nvhost_syncpt_get_cv_dev_address_table(pdev, &num_grids, - &dla_grid); - if (err) { - nvdla_dbg_err(pdev, "failed to get grid[%d]", err); - nvdla_dev->is_gos_fetched = false; - goto fail_to_get_grid; - } - - if (num_grids > MAX_NUM_GRIDS) { - nvdla_dbg_err(pdev, "num_grid[%d] > than [%d]", num_grids, - MAX_NUM_GRIDS); - nvdla_dev->is_gos_fetched = false; - err = -EINVAL; - goto fail_to_get_grid; - } - nvdla_dev->is_gos_fetched = true; - - /* assign memory for GoS set command */ - err = nvdla_get_cmd_memory(pdev, &gos_cmd_mem_info); - if (err) { - nvdla_dbg_err(pdev, - "dma allocation failed for gos set command."); - goto alloc_gos_cmd_failed; - } - - /* set GoS region info */ - gos_region = (struct dla_region_gos *)(gos_cmd_mem_info.va); - gos_region->region = DLA_REGION_GOS; - gos_region->num_grids = num_grids; - gos_region->grid_size = MAX_GRID_SIZE; - for (i = 0; i < num_grids; i++) - gos_region->address[i] = dla_grid[i]; - speculation_barrier(); /* break_spec_p#5_1 */ - - /* set cmd info */ - cmd_data.method_id = DLA_CMD_SET_REGIONS; - cmd_data.method_data = ALIGNED_DMA(gos_cmd_mem_info.pa); - cmd_data.wait = true; - - /* send cmd to set gos region */ - err = nvdla_send_cmd(pdev, &cmd_data); - - /* release memory allocated for set GoS command */ - nvdla_put_cmd_memory(pdev, gos_cmd_mem_info.index); - - if (err != 0) { - nvdla_dbg_err(pdev, "failed to send set gos region command"); - goto gos_set_cmd_failed; - } - - nvdla_dbg_fn(pdev, "send set gos region done."); - -gos_set_cmd_failed: -alloc_gos_cmd_failed: -fail_to_get_grid: -falcon_not_booted: - return err; -} - /* power management API */ int nvhost_nvdla_finalize_poweron(struct platform_device *pdev) { @@ -654,10 +572,6 @@ int nvhost_nvdla_finalize_poweron(struct platform_device *pdev) goto fail_to_alloc_trace; } - /* Disable GOS until it is fixed in Kernel 4.14 */ - nvdla_dev->is_gos_enabled = false; - nvdla_dev->is_gos_fetched = true; - return 0; fail_to_alloc_trace: diff --git a/drivers/video/tegra/host/nvdla/nvdla.h b/drivers/video/tegra/host/nvdla/nvdla.h index 58a1b1ed..b0b5a257 100644 --- a/drivers/video/tegra/host/nvdla/nvdla.h +++ b/drivers/video/tegra/host/nvdla/nvdla.h @@ -3,7 +3,7 @@ * * Tegra Graphics Host NVDLA * - * Copyright (c) 2016-2021 NVIDIA Corporation. All rights reserved. + * Copyright (c) 2016-2022 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, @@ -183,7 +183,6 @@ enum nvdla_submit_mode { * @cmd_mem structure to hold command memory pool * @trace_enable to enable/disable the DLA firmware trace * @events_mask mask to set/reset the different DLA firmware trace event - * @is_gos_enabled flag to check if GoS enabled * @debug_dump_pa physical address of print buffer * @debug_dump_va virtual address of print buffer * @trace_dump_pa physical address of trace buffer @@ -206,8 +205,6 @@ struct nvdla_device { struct nvdla_cmd_mem cmd_mem; u32 trace_enable; u32 events_mask; - bool is_gos_enabled; - bool is_gos_fetched; dma_addr_t debug_dump_pa; u32 *debug_dump_va; dma_addr_t trace_dump_pa; @@ -421,6 +418,5 @@ int nvdla_emulator_submit(struct nvdla_queue *queue, struct nvdla_emu_task *task); void task_free(struct kref *ref); int nvdla_get_signal_fences(struct nvdla_queue *queue, void *in_task); -int nvdla_send_gos_region(struct platform_device *pdev); #endif /* End of __NVHOST_NVDLA_H__ */ diff --git a/drivers/video/tegra/host/nvdla/nvdla_queue.c b/drivers/video/tegra/host/nvdla/nvdla_queue.c index 2eb49891..9e0da46c 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_queue.c +++ b/drivers/video/tegra/host/nvdla/nvdla_queue.c @@ -26,8 +26,6 @@ #include "host1x/host1x.h" -#include "nvhost_gos.h" - #include "nvdla/nvdla.h" #include "nvdla/dla_queue.h" #include "nvdla/nvdla_debug.h" @@ -470,53 +468,16 @@ static u8 *add_timestamp_action(u8 *mem, uint8_t op, uint64_t addr) return mem + sizeof(struct dla_action_timestamp); } -static u8 *add_gos_action(u8 *mem, uint8_t op, uint8_t index, uint16_t offset, - uint32_t value) -{ - struct dla_action_gos *action; - - mem = add_opcode(mem, op); - - action = (struct dla_action_gos *)mem; - action->index = index; - action->offset = offset; - action->value = value; - - return mem + sizeof(struct dla_action_gos); -} - -static int nvdla_get_gos(struct platform_device *pdev, u32 syncpt_id, - u32 *gos_id, u32 *gos_offset) -{ - struct nvhost_device_data *pdata = platform_get_drvdata(pdev); - struct nvdla_device *nvdla_dev = pdata->private_data; - int err = 0; - - if (!nvdla_dev->is_gos_enabled) { - nvdla_dbg_info(pdev, "GoS is not enabled\n"); - err = -EINVAL; - goto gos_disabled; - } - - err = nvhost_syncpt_get_gos(pdev, syncpt_id, gos_id, gos_offset); - if (err) { - nvdla_dbg_err(pdev, - "Get GoS failed for syncpt[%d], err[%d]\n", syncpt_id, err); - } - -gos_disabled: - return err; -} - static int nvdla_add_fence_action_cb(struct nvhost_ctrl_sync_fence_info info, void *data) { - u32 gos_id, gos_offset, id, thresh; + u32 id, thresh; struct nvdla_add_fence_action_cb_args *args = data; struct nvdla_queue *queue = args->queue; u8 **next = args->mem; struct platform_device *pdev = queue->pool->pdev; struct nvhost_master *host = nvhost_get_host(pdev); struct nvhost_syncpt *sp = &host->syncpt; + dma_addr_t syncpt_addr; id = info.id; thresh = info.thresh; @@ -526,26 +487,13 @@ static int nvdla_add_fence_action_cb(struct nvhost_ctrl_sync_fence_info info, vo return -EINVAL; } - /* check if GoS backing available */ - if (!nvdla_get_gos(pdev, id, &gos_id, &gos_offset)) { - nvdla_dbg_info(pdev, "syncfd_pt:[%u] " - "gos_id[%u] gos_offset[%u] val[%u]", - id, gos_id, gos_offset, thresh); - *next = add_gos_action(*next, ACTION_GOS_GE, - gos_id, gos_offset, thresh); - } else { - dma_addr_t syncpt_addr; - - nvdla_dbg_info(pdev, - "GoS missing for syncfd [%d]", id); - syncpt_addr = nvhost_syncpt_address( - queue->vm_pdev, id); - nvdla_dbg_info(pdev, "syncfd_pt:[%u]" - "mss_dma_addr[%pad]", - id, &syncpt_addr); - *next = add_fence_action(*next, ACTION_SEM_GE, - syncpt_addr, thresh); - } + syncpt_addr = nvhost_syncpt_address( + queue->vm_pdev, id); + nvdla_dbg_info(pdev, "syncfd_pt:[%u]" + "mss_dma_addr[%pad]", + id, &syncpt_addr); + *next = add_fence_action(*next, ACTION_SEM_GE, + syncpt_addr, thresh); return 0; } @@ -615,45 +563,6 @@ fail_to_pin_mem: return err; } -static int nvdla_update_gos(struct platform_device *pdev) -{ - struct nvhost_device_data *pdata = platform_get_drvdata(pdev); - struct nvdla_device *nvdla_dev = pdata->private_data; - int err = 0; - - /* confirm if gos fetched, if not fetch through poweron */ - if (!nvdla_dev->is_gos_fetched) { - nvdla_dbg_info(pdev, "fetch GoS regions and send to ucode\n"); - err = nvhost_module_busy(pdev); - if (err) { - nvdla_dbg_info(pdev, "failed to poweron[%d]\n", - nvdla_dev->is_gos_fetched); - goto fail_to_poweron; - } - - /* - * confirm if gos fetched through previous poweron - * if not explicitly attempt to refetch - */ - if (!nvdla_dev->is_gos_fetched) { - err = nvdla_send_gos_region(pdev); - if (err) { - nvdla_dbg_err(pdev, "set gos region fail\n"); - nvdla_dev->is_gos_enabled = false; - nvhost_module_idle(pdev); - goto fail_to_send_gos; - } else { - nvdla_dev->is_gos_enabled = true; - } - } - nvhost_module_idle(pdev); - } - -fail_to_send_gos: -fail_to_poweron: - return err; -} - static int nvdla_fill_wait_fence_action(struct nvdla_task *task, struct nvdev_fence *fence, struct dma_buf **dma_buf, @@ -688,33 +597,19 @@ static int nvdla_fill_wait_fence_action(struct nvdla_task *task, break; } case NVDEV_FENCE_TYPE_SYNCPT: { - u32 gos_id, gos_offset; + dma_addr_t syncpt_addr; nvdla_dbg_info(pdev, "id[%d] val[%d]", fence->syncpoint_index, fence->syncpoint_value); - if (!nvdla_get_gos(pdev, fence->syncpoint_index, &gos_id, - &gos_offset)) { - nvdla_dbg_info(pdev, "syncpt:[%u] gos_id[%u] " - "gos_offset[%u] val[%u]", - fence->syncpoint_index, gos_id, gos_offset, - fence->syncpoint_value); - next = add_gos_action(next, ACTION_GOS_GE, - gos_id, gos_offset, - fence->syncpoint_value); - } else { - dma_addr_t syncpt_addr; - nvdla_dbg_info(pdev, "GoS missing"); + syncpt_addr = nvhost_syncpt_address( + queue->vm_pdev, fence->syncpoint_index); + nvdla_dbg_info(pdev, "syncpt:[%u] dma_addr[%pad]", + fence->syncpoint_index, &syncpt_addr); - syncpt_addr = nvhost_syncpt_address( - queue->vm_pdev, fence->syncpoint_index); - nvdla_dbg_info(pdev, "syncpt:[%u] dma_addr[%pad]", - fence->syncpoint_index, &syncpt_addr); - - next = add_fence_action(next, ACTION_SEM_GE, - syncpt_addr, fence->syncpoint_value); - } + next = add_fence_action(next, ACTION_SEM_GE, + syncpt_addr, fence->syncpoint_value); break; } @@ -767,24 +662,6 @@ static int nvdla_fill_signal_fence_action(struct nvdla_task *task, case NVDEV_FENCE_TYPE_SYNC_FD: case NVDEV_FENCE_TYPE_SYNCPT: { dma_addr_t syncpt_addr; - u32 gos_id, gos_offset; - - /* update GoS backing if available */ - if (!nvdla_get_gos(pdev, queue->syncpt_id, - &gos_id, &gos_offset)) { - u32 max; - - /* send incremented max */ - max = nvhost_syncpt_read_maxval(pdev, - queue->syncpt_id); - nvdla_dbg_info(pdev, "syncpt:[%u] gos_id[%u] " - "gos_offset[%u] val[%u]", - queue->syncpt_id, gos_id, gos_offset, - max + task->fence_counter + 1); - next = add_gos_action(next, ACTION_WRITE_GOS, - gos_id, gos_offset, - max + task->fence_counter + 1); - } /* For postaction also update MSS addr */ syncpt_addr = nvhost_syncpt_address(queue->vm_pdev, @@ -1080,7 +957,7 @@ static int nvdla_fill_preactions(struct nvdla_task *task) } } - /* fill input status after filling sem/syncpt/gos */ + /* fill input status after filling sem/syncpt */ for (i = 0; i < task->num_in_task_status; i++) { err = nvdla_fill_taskstatus_read_action(task, &task->in_task_status[i], @@ -1207,8 +1084,6 @@ int nvdla_fill_task_desc(struct nvdla_task *task, bool bypass_exec) task_desc->postactions = task_desc->preactions + sizeof(struct dla_action_list); - nvdla_update_gos(pdev); - /* reset fence counter */ task->fence_counter = 0;