From e8d89fcbf9d72168de9aa7b10a69e345ca2e039a Mon Sep 17 00:00:00 2001 From: Shridhar Rasal Date: Thu, 29 Dec 2016 16:43:56 +0530 Subject: [PATCH] video: tegra: host: dla: add queue operations cmd - define and add ioctl to set queue operations like, suspend and resume. - on validating user argument, pass command to engine to suspend and resume. - on receiving this command, firmware just update queue status as sent and doesn't interrupt ongoing task or queue work. Jira DLA-218 Change-Id: I13f5d8822d920961277884c64534daaf64d812be Signed-off-by: Shridhar Rasal Reviewed-on: http://git-master/r/1278192 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Prashant Gaikwad GVS: Gerrit_Virtual_Submit --- drivers/video/tegra/host/nvdla/nvdla.h | 3 +- drivers/video/tegra/host/nvdla/nvdla_ioctl.c | 43 +++++++++++++++++++- drivers/video/tegra/host/nvdla/nvdla_queue.c | 34 +++++++++++++++- 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/drivers/video/tegra/host/nvdla/nvdla.h b/drivers/video/tegra/host/nvdla/nvdla.h index 34d1ec0d..9d178dd9 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 NVIDIA Corporation. All rights reserved. + * Copyright (c) 2016-2017 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, @@ -279,5 +279,6 @@ int nvdla_send_postfences(struct nvdla_task *task, int nvdla_get_cmd_memory(struct platform_device *pdev, struct nvdla_cmd_mem_info *cmd_mem_info); int nvdla_put_cmd_memory(struct platform_device *pdev, int index); +int nvdla_set_queue_state(struct nvhost_queue *queue, int cmd); #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 89f776ce..8290236c 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_ioctl.c +++ b/drivers/video/tegra/host/nvdla/nvdla_ioctl.c @@ -1,7 +1,7 @@ /* * NVDLA IOCTL for T194 * - * Copyright (c) 2016, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2016-2017, 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, @@ -54,6 +54,44 @@ struct nvdla_private { struct nvhost_buffers *buffers; }; +static int nvdla_set_queue(struct nvdla_private *priv, void *args) +{ + struct nvdla_queue_status_args *queue_arg = + (struct nvdla_queue_status_args *)args; + struct platform_device *pdev = priv->pdev; + struct nvhost_queue *queue = priv->queue; + int status = queue_arg->status; + int err = 0; + + if (!queue) { + nvdla_dbg_err(pdev, "invalid queue\n"); + err = -EINVAL; + goto inval_queue; + } + + /* allow to send only one command at a time */ + if (status != (status & -status)) { + nvdla_dbg_err(pdev, "incorrect queue cmd set[%d]\n", status); + err = -EINVAL; + goto inval_input; + } + + if (status & NVDLA_QUEUE_FLAGS_SUSPEND) { + err = nvdla_set_queue_state(queue, DLA_CMD_QUEUE_SUSPEND); + } else if (status & NVDLA_QUEUE_FLAGS_RESUME) { + err = nvdla_set_queue_state(queue, DLA_CMD_QUEUE_RESUME); + } else { + nvdla_dbg_err(pdev, "invalid queue cmd %d\n", status); + err = -EINVAL; + goto inval_cmd; + } + +inval_queue: +inval_input: +inval_cmd: + return err; +} + static int nvdla_pin(struct nvdla_private *priv, void *arg) { u32 *handles; @@ -476,6 +514,9 @@ static long nvdla_ioctl(struct file *file, unsigned int cmd, case NVDLA_IOCTL_SUBMIT: err = nvdla_submit(priv, (void *)buf); break; + case NVDLA_IOCTL_SET_QUEUE_STATUS: + err = nvdla_set_queue(priv, (void *)buf); + break; default: err = -ENOIOCTLCMD; break; diff --git a/drivers/video/tegra/host/nvdla/nvdla_queue.c b/drivers/video/tegra/host/nvdla/nvdla_queue.c index 5f35a18e..252057f6 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, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2016-2017, 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, @@ -787,6 +787,38 @@ fail_to_register: return err; } +int nvdla_set_queue_state(struct nvhost_queue *queue, int cmd) +{ + struct platform_device *pdev = queue->pool->pdev; + int err; + + nvdla_dbg_fn(pdev, ""); + + if ((cmd != DLA_CMD_QUEUE_SUSPEND) && + (cmd != DLA_CMD_QUEUE_RESUME)) { + nvdla_dbg_err(pdev, "invalid cmd %d", cmd); + return -EINVAL; + } + + /* get pm refcount */ + err = nvhost_module_busy(pdev); + if (err) { + nvdla_dbg_err(pdev, "failed to poweron, err: %d", err); + goto fail_to_poweron; + } + + err = nvdla_send_cmd(pdev, cmd, queue->id, true); + if (err) { + nvdla_dbg_err(pdev, "failed to suspend queue %d", err); + goto fail_to_suspend; + } + +fail_to_suspend: + nvhost_module_idle(pdev); +fail_to_poweron: + return err; +} + static int nvdla_queue_abort(struct nvhost_queue *queue) { int err;