From 9975af6bd9de6861e2d16c625b0d58f42139b10d Mon Sep 17 00:00:00 2001 From: Shridhar Rasal Date: Thu, 16 Mar 2017 16:48:35 +0530 Subject: [PATCH] video: tegra: host: dla: add flag for GoS enable - add flag to check gos enabled status - As there is no clean way to get GoS enable status without invoking any GoS API, ignore error from retrieving GoS regions table. - However, update gos enable flag based on return status from GoS API. - Use this flag for retriving GoS syncpoint IOVA, this is required to avoid un-necessary calls to nvhost and nvmap. - __func__ is already included in DLA debug print wrapper API's, remove redundant parameters passing - Fix dumping num of prefences - In task submission, as network descriptor is mandatory to pass to engine, expect minimum one num of addresses per task. Jira DLA-326 Change-Id: I2483a606fd8454a92363cfbaf4462280e221e20c Signed-off-by: Shridhar Rasal Reviewed-on: http://git-master/r/1322085 Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Bharat Nihalani --- drivers/video/tegra/host/nvdla/nvdla.c | 15 ++++++++------- drivers/video/tegra/host/nvdla/nvdla.h | 2 ++ drivers/video/tegra/host/nvdla/nvdla_debug.c | 6 ++---- drivers/video/tegra/host/nvdla/nvdla_ioctl.c | 7 ++++++- drivers/video/tegra/host/nvdla/nvdla_queue.c | 13 ++++++++++--- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/drivers/video/tegra/host/nvdla/nvdla.c b/drivers/video/tegra/host/nvdla/nvdla.c index b7c55a76..fcbcfc4d 100644 --- a/drivers/video/tegra/host/nvdla/nvdla.c +++ b/drivers/video/tegra/host/nvdla/nvdla.c @@ -469,7 +469,7 @@ int nvhost_nvdla_finalize_poweron(struct platform_device *pdev) ret = nvhost_flcn_finalize_poweron(pdev); if (ret) { - nvdla_dbg_err(pdev, "%s: failed to poweron\n", __func__); + nvdla_dbg_err(pdev, "failed to poweron\n"); goto fail; } @@ -495,24 +495,25 @@ int nvhost_nvdla_finalize_poweron(struct platform_device *pdev) ret = nvdla_alloc_dump_region(pdev); if (ret) { - nvdla_dbg_err(pdev, "%s: fail alloc dump region\n", __func__); + nvdla_dbg_err(pdev, "fail alloc dump region\n"); goto fail_to_alloc_dump_reg; } ret = nvdla_alloc_trace_region(pdev); if (ret) { - nvdla_dbg_err(pdev, "%s: fail alloc trace region\n", __func__); + nvdla_dbg_err(pdev, "fail alloc trace region\n"); goto fail_to_alloc_trace; } ret = nvdla_send_gos_region(pdev); if (ret) { - nvdla_dbg_err(pdev, "%s: fail to set gos region\n", __func__); - goto fail_to_set_gos_region; + nvdla_dbg_err(pdev, "set gos region is failed\n"); + nvdla_dev->is_gos_enabled = false; } + nvdla_dev->is_gos_enabled = true; + return 0; -fail_to_set_gos_region: fail_to_alloc_trace: fail_to_alloc_dump_reg: fail_to_val_ver: @@ -626,7 +627,7 @@ static int nvdla_probe(struct platform_device *pdev) if (err) goto err_alloc_cmd_mem; - nvdla_dbg_info(pdev, "%s: pdata:%p\n", __func__, pdata); + nvdla_dbg_info(pdev, "pdata:%p initialized\n", pdata); return 0; err_alloc_cmd_mem: diff --git a/drivers/video/tegra/host/nvdla/nvdla.h b/drivers/video/tegra/host/nvdla/nvdla.h index dbeb25af..5b7d00ce 100644 --- a/drivers/video/tegra/host/nvdla/nvdla.h +++ b/drivers/video/tegra/host/nvdla/nvdla.h @@ -162,6 +162,7 @@ struct nvdla_cmd_data { * @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 */ struct nvdla_device { struct platform_device *pdev; @@ -176,6 +177,7 @@ struct nvdla_device { struct nvdla_cmd_mem cmd_mem; u32 trace_enable; u32 events_mask; + bool is_gos_enabled; }; /** diff --git a/drivers/video/tegra/host/nvdla/nvdla_debug.c b/drivers/video/tegra/host/nvdla/nvdla_debug.c index df94b8da..c1b73bb6 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_debug.c +++ b/drivers/video/tegra/host/nvdla/nvdla_debug.c @@ -341,8 +341,7 @@ static ssize_t debug_dla_eventmask_set(struct file *file, /* set event_mask config */ ret = dla_set_trace_event_mask(pdev, nvdla_dev->events_mask); if (ret) { - nvdla_dbg_err(pdev, - "%s: failed to set event mask.", __func__); + nvdla_dbg_err(pdev, "failed to set event mask."); goto set_event_mask_failed; } @@ -393,8 +392,7 @@ static ssize_t debug_dla_enable_trace_set(struct file *file, /* set trace_enable config */ ret = dla_set_trace_enable(pdev, nvdla_dev->trace_enable); if (ret) { - nvdla_dbg_err(pdev, - "%s: failed to enable trace events.", __func__); + nvdla_dbg_err(pdev, "failed to enable trace events."); goto set_trace_enable_failed; } diff --git a/drivers/video/tegra/host/nvdla/nvdla_ioctl.c b/drivers/video/tegra/host/nvdla/nvdla_ioctl.c index 05302135..3834cc9a 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_ioctl.c +++ b/drivers/video/tegra/host/nvdla/nvdla_ioctl.c @@ -385,6 +385,11 @@ static int nvdla_val_task_submit_input(struct nvdla_ioctl_submit_task *in_task) MAX_NUM_NVDLA_OUT_TASK_STATUS); return -EINVAL; } + if (in_task->num_addresses < 1) { + pr_err("num addresses[%u] should be min one\n", + in_task->num_addresses); + return -EINVAL; + } if (in_task->num_addresses > NVDLA_MAX_BUFFERS_PER_TASK) { pr_err("num addresses[%u] crossing expected[%d]\n", in_task->num_addresses, @@ -472,7 +477,7 @@ void nvdla_dump_task(struct nvdla_task *task) nvdla_dbg_info(pdev, "dumping input task [%p] parameters:", task); nvdla_dbg_info(pdev, "num_prefences[%u] num_postfences[%u]", - task->num_postfences, task->num_postfences); + task->num_prefences, task->num_postfences); nvdla_dbg_info(pdev, "num_in_status[%u] num_out_task_status[%u]", task->num_in_task_status, task->num_out_task_status); nvdla_dbg_info(pdev, "num_addresses[%u]", task->num_addresses); diff --git a/drivers/video/tegra/host/nvdla/nvdla_queue.c b/drivers/video/tegra/host/nvdla/nvdla_queue.c index 46026b1e..e04b52f1 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_queue.c +++ b/drivers/video/tegra/host/nvdla/nvdla_queue.c @@ -405,6 +405,8 @@ static int nvdla_fill_postactions(struct nvdla_task *task) struct nvhost_buffers *buffers = task->buffers; struct nvhost_queue *queue = task->queue; struct platform_device *pdev = queue->pool->pdev; + struct nvhost_device_data *pdata = platform_get_drvdata(pdev); + struct nvdla_device *nvdla_dev = pdata->private_data; struct dla_action_list *postactionl; uint16_t postactionlist_of; u8 *next, *start; @@ -448,7 +450,8 @@ static int nvdla_fill_postactions(struct nvdla_task *task) u32 gos_id, gos_offset; /* update GoS backing if available */ - if (!nvhost_syncpt_get_gos(pdev, queue->syncpt_id, + if (nvdla_dev->is_gos_enabled && + !nvhost_syncpt_get_gos(pdev, queue->syncpt_id, &gos_id, &gos_offset)) { u32 max; @@ -540,6 +543,8 @@ static int nvdla_fill_preactions(struct nvdla_task *task) struct nvhost_buffers *buffers = task->buffers; struct nvhost_queue *queue = task->queue; struct platform_device *pdev = queue->pool->pdev; + struct nvhost_device_data *pdata = platform_get_drvdata(pdev); + struct nvdla_device *nvdla_dev = pdata->private_data; struct nvhost_master *host = nvhost_get_host(pdev); struct nvhost_syncpt *sp = &host->syncpt; struct dla_action_list *preactionl; @@ -586,7 +591,8 @@ static int nvdla_fill_preactions(struct nvdla_task *task) } /* check if GoS backing available */ - if (!nvhost_syncpt_get_gos(pdev, id, &gos_id, + if (nvdla_dev->is_gos_enabled && + !nvhost_syncpt_get_gos(pdev, id, &gos_id, &gos_offset)) { nvdla_dbg_info(pdev, "pre i:%d syncfd_pt:[%u] gos_id[%u] gos_offset[%u] val[%u]", i, id, gos_id, @@ -617,7 +623,8 @@ static int nvdla_fill_preactions(struct nvdla_task *task) task->prefences[i].syncpoint_index, task->prefences[i].syncpoint_value); - if (!nvhost_syncpt_get_gos(pdev, + if (nvdla_dev->is_gos_enabled && + !nvhost_syncpt_get_gos(pdev, task->prefences[i].syncpoint_index, &gos_id, &gos_offset)) { nvdla_dbg_info(pdev, "pre i:%d syncpt:[%u] gos_id[%u] gos_offset[%u] val[%u]",