summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
diff options
context:
space:
mode:
authorDeepak Nibade <dnibade@nvidia.com>2017-01-17 01:00:12 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-01-17 13:44:20 -0500
commit72f27f77472503ccaa840c1fc01efbf5df6075d0 (patch)
tree8f3bca57d94d383da6200fdf9c22d11e5ea5df1f /drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
parent4942cc4222ef2049f5596b87ae9007123cdcdedb (diff)
gpu: nvgpu: serialize debug session IOCTLs
Hold debug_s->ioctl_lock for all debug session IOCTLs to prevent multi-threaded user space IOCTL calls debug session IOCTL calls are not thread-safe and hence this serialization is required Bug 1832267 Change-Id: I847ac951601d4f0093546b592bdb8c8f00185317 Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: http://git-master/r/1286436 Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
index be9f7fc6..ac11e378 100644
--- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Tegra GK20A GPU Debugger/Profiler Driver 2 * Tegra GK20A GPU Debugger/Profiler Driver
3 * 3 *
4 * Copyright (c) 2013-2016, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2013-2017, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -117,6 +117,7 @@ static int gk20a_dbg_gpu_do_dev_open(struct inode *inode,
117 init_waitqueue_head(&dbg_session->dbg_events.wait_queue); 117 init_waitqueue_head(&dbg_session->dbg_events.wait_queue);
118 INIT_LIST_HEAD(&dbg_session->ch_list); 118 INIT_LIST_HEAD(&dbg_session->ch_list);
119 mutex_init(&dbg_session->ch_list_lock); 119 mutex_init(&dbg_session->ch_list_lock);
120 mutex_init(&dbg_session->ioctl_lock);
120 dbg_session->dbg_events.events_enabled = false; 121 dbg_session->dbg_events.events_enabled = false;
121 dbg_session->dbg_events.num_pending_events = 0; 122 dbg_session->dbg_events.num_pending_events = 0;
122 123
@@ -899,6 +900,9 @@ long gk20a_dbg_gpu_dev_ioctl(struct file *filp, unsigned int cmd,
899 gk20a_idle(g->dev); 900 gk20a_idle(g->dev);
900 } 901 }
901 902
903 /* protect from threaded user space calls */
904 mutex_lock(&dbg_s->ioctl_lock);
905
902 switch (cmd) { 906 switch (cmd) {
903 case NVGPU_DBG_GPU_IOCTL_BIND_CHANNEL: 907 case NVGPU_DBG_GPU_IOCTL_BIND_CHANNEL:
904 err = dbg_bind_channel_gk20a(dbg_s, 908 err = dbg_bind_channel_gk20a(dbg_s,
@@ -1003,6 +1007,8 @@ long gk20a_dbg_gpu_dev_ioctl(struct file *filp, unsigned int cmd,
1003 break; 1007 break;
1004 } 1008 }
1005 1009
1010 mutex_unlock(&dbg_s->ioctl_lock);
1011
1006 gk20a_dbg(gpu_dbg_gpu_dbg, "ret=%d", err); 1012 gk20a_dbg(gpu_dbg_gpu_dbg, "ret=%d", err);
1007 1013
1008 if ((err == 0) && (_IOC_DIR(cmd) & _IOC_READ)) 1014 if ((err == 0) && (_IOC_DIR(cmd) & _IOC_READ))