From 0870b7d47e17eb8b876bef9a63056d384e4022ae Mon Sep 17 00:00:00 2001 From: Shridhar Rasal Date: Fri, 9 Feb 2018 14:53:45 +0530 Subject: [PATCH] video: tegra: host: balance task ref counter kref object reference counters set refcount to 1 on init. Task references must be released after task submit done. Reference acquired for command submission, free'd through task complete notifier. Jira DLA-718 Change-Id: I7aecfa45f90e19531e4ac57eadd1a20d72ab2291 Signed-off-by: Shridhar Rasal Reviewed-on: https://git-master.nvidia.com/r/1654952 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Prashant Gaikwad Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/video/tegra/host/nvdla/nvdla.h | 1 + drivers/video/tegra/host/nvdla/nvdla_ioctl.c | 2 ++ drivers/video/tegra/host/nvdla/nvdla_queue.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/video/tegra/host/nvdla/nvdla.h b/drivers/video/tegra/host/nvdla/nvdla.h index 32e327ae..ff50e6ed 100644 --- a/drivers/video/tegra/host/nvdla/nvdla.h +++ b/drivers/video/tegra/host/nvdla/nvdla.h @@ -394,5 +394,6 @@ int nvdla_free_gcov_region(struct platform_device *pdev, bool update_region); int nvdla_emulator_submit(struct nvhost_queue *queue, struct nvdla_emu_task *task); +void task_free(struct kref *ref); #endif /* End of __NVHOST_NVDLA_H__ */ diff --git a/drivers/video/tegra/host/nvdla/nvdla_ioctl.c b/drivers/video/tegra/host/nvdla/nvdla_ioctl.c index a2e0996e..38e2cc07 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_ioctl.c +++ b/drivers/video/tegra/host/nvdla/nvdla_ioctl.c @@ -816,6 +816,7 @@ static int nvdla_submit(struct nvdla_private *priv, void *arg) err = nvdla_fill_task(queue, buffers, local_tasks + i, task); if (err) { nvdla_dbg_err(pdev, "failed to fill task[%d]", i + 1); + kref_put(&task->ref, task_free); goto fail_to_fill_task; } nvdla_dbg_info(pdev, "local task[%d] filled", i + 1); @@ -847,6 +848,7 @@ static int nvdla_submit(struct nvdla_private *priv, void *arg) goto fail_to_send_postfences; } nvdla_dbg_info(pdev, "postfences of task[%d] sent", i + 1); + kref_put(&task->ref, task_free); } nvdla_dbg_fn(pdev, "Task submitted, done!"); diff --git a/drivers/video/tegra/host/nvdla/nvdla_queue.c b/drivers/video/tegra/host/nvdla/nvdla_queue.c index 71af69b2..a34ce98c 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_queue.c +++ b/drivers/video/tegra/host/nvdla/nvdla_queue.c @@ -87,7 +87,7 @@ void nvdla_put_task_mem(struct nvdla_task *task) task = NULL; } -static void task_free(struct kref *ref) +void task_free(struct kref *ref) { struct nvdla_task *task = container_of(ref, struct nvdla_task, ref); struct platform_device *pdev = task->queue->pool->pdev;