From de0808ea5bb3355f217a4fb0e42642d6a3a87b1b Mon Sep 17 00:00:00 2001 From: prsethi Date: Thu, 13 Oct 2022 17:00:57 +0000 Subject: [PATCH] gpu:nvgpu: fix below issue with ctrl nvs. - Move queue lock at correct place. - Free the allocated memory. Jira NVGPU-8622 Change-Id: Ia996d80498e53fb21ddf1f1202abd6fb8e3f6168 Signed-off-by: prsethi Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2791618 Reviewed-by: svc-mobile-coverity Reviewed-by: svcacv Reviewed-by: Debarshi Dutta Reviewed-by: Ankur Kishore GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/include/nvgpu/nvs.h | 2 +- drivers/gpu/nvgpu/os/linux/dmabuf_nvs.c | 1 + drivers/gpu/nvgpu/os/linux/ioctl_nvs.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvs.h b/drivers/gpu/nvgpu/include/nvgpu/nvs.h index 82e88197c..dadab78eb 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvs.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvs.h @@ -41,7 +41,7 @@ /* * Keep it to page size for now. Can be updated later. */ -#define NVS_QUEUE_DEFAULT_SIZE (64 * 1024) +#define NVS_QUEUE_DEFAULT_SIZE (64U * 1024U) struct gk20a; struct nvgpu_nvs_domain_ioctl; diff --git a/drivers/gpu/nvgpu/os/linux/dmabuf_nvs.c b/drivers/gpu/nvgpu/os/linux/dmabuf_nvs.c index 1ec083098..ac7bd18eb 100644 --- a/drivers/gpu/nvgpu/os/linux/dmabuf_nvs.c +++ b/drivers/gpu/nvgpu/os/linux/dmabuf_nvs.c @@ -85,6 +85,7 @@ static int nvs_release_user_mappings_locked(struct gk20a *g, struct nvgpu_nvs_li zap_vma_entries(g, vma); linux_buf->mapped_ref--; + nvgpu_kfree(g, current_entry); } return err; diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_nvs.c b/drivers/gpu/nvgpu/os/linux/ioctl_nvs.c index 9a04bb580..1c2d20087 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_nvs.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_nvs.c @@ -947,14 +947,14 @@ static int nvgpu_nvs_ctrl_fifo_destroy_queue(struct gk20a *g, } } + nvgpu_nvs_ctrl_fifo_lock_queues(g); + queue = nvgpu_nvs_ctrl_fifo_get_queue(g->sched_ctrl_fifo, num_queue, queue_direction, &mask); if (queue == NULL) { err = -EOPNOTSUPP; goto fail; } - nvgpu_nvs_ctrl_fifo_lock_queues(g); - if (!nvgpu_nvs_ctrl_fifo_user_is_subscribed_to_queue(user, queue)) { err = -EPERM; goto fail;