summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Nibade <dnibade@nvidia.com>2015-08-20 10:16:16 -0400
committerTerje Bergstrom <tbergstrom@nvidia.com>2015-11-03 17:14:10 -0500
commit8d279dbac10b8521aa7eaeb7640c01d21ce044f2 (patch)
tree5eb84906f3870727fcf519781fbdb088dd0ed0eb
parent4b5c08f4c0cf12076a208c640a46447a536308e8 (diff)
gpu: nvgpu: IOCTL to disable timeouts
Add IOCTL NVGPU_DBG_GPU_IOCTL_TIMEOUT to support disabling/re-enabling scheduler timeout from user space If user space application is closed without re-enabling the timeouts, kernel will restore the timeouts' state while releasing the debug session This is needed for debugging purpose Bug 1514061 Change-Id: I32efb47ad09d793f3e7fd8f0aaa9720c8bc91272 Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: http://git-master/r/788176 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c69
-rw-r--r--drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h5
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h1
-rw-r--r--include/uapi/linux/nvgpu.h14
4 files changed, 84 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
index 4a175a3c..1c351d9e 100644
--- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
@@ -91,6 +91,7 @@ static int gk20a_dbg_gpu_do_dev_open(struct inode *inode,
91 dbg_session->g = g; 91 dbg_session->g = g;
92 dbg_session->is_profiler = is_profiler; 92 dbg_session->is_profiler = is_profiler;
93 dbg_session->is_pg_disabled = false; 93 dbg_session->is_pg_disabled = false;
94 dbg_session->is_timeout_disabled = false;
94 /* For vgpu, all power-gating features are currently disabled 95 /* For vgpu, all power-gating features are currently disabled
95 * in the server. Set is_pg_disable to true to reflect this 96 * in the server. Set is_pg_disable to true to reflect this
96 * on the client side. */ 97 * on the client side. */
@@ -264,6 +265,46 @@ void gk20a_dbg_gpu_post_events(struct channel_gk20a *ch)
264static int dbg_set_powergate(struct dbg_session_gk20a *dbg_s, 265static int dbg_set_powergate(struct dbg_session_gk20a *dbg_s,
265 __u32 powermode); 266 __u32 powermode);
266 267
268static int nvgpu_dbg_timeout_enable(struct dbg_session_gk20a *dbg_s,
269 int timeout_mode)
270{
271 struct gk20a *g = dbg_s->g;
272 int err = 0;
273
274 gk20a_dbg(gpu_dbg_gpu_dbg, "Timeouts mode requested : %d",
275 timeout_mode);
276
277 switch (timeout_mode) {
278 case NVGPU_DBG_GPU_IOCTL_TIMEOUT_ENABLE:
279 if (dbg_s->is_timeout_disabled &&
280 --g->dbg_timeout_disabled_refcount == 0) {
281 g->timeouts_enabled = true;
282 }
283 dbg_s->is_timeout_disabled = false;
284 break;
285
286 case NVGPU_DBG_GPU_IOCTL_TIMEOUT_DISABLE:
287 if ((dbg_s->is_timeout_disabled == false) &&
288 (g->dbg_timeout_disabled_refcount++ == 0)) {
289 g->timeouts_enabled = false;
290 }
291 dbg_s->is_timeout_disabled = true;
292 break;
293
294 default:
295 gk20a_err(dev_from_gk20a(g),
296 "unrecognized dbg gpu timeout mode : 0x%x",
297 timeout_mode);
298 err = -EINVAL;
299 break;
300 }
301
302 gk20a_dbg(gpu_dbg_gpu_dbg, "Timeouts enabled : %s",
303 g->timeouts_enabled ? "Yes" : "No");
304
305 return err;
306}
307
267static int dbg_unbind_channel_gk20a(struct dbg_session_gk20a *dbg_s) 308static int dbg_unbind_channel_gk20a(struct dbg_session_gk20a *dbg_s)
268{ 309{
269 struct channel_gk20a *ch_gk20a = dbg_s->ch; 310 struct channel_gk20a *ch_gk20a = dbg_s->ch;
@@ -305,12 +346,13 @@ int gk20a_dbg_gpu_dev_release(struct inode *inode, struct file *filp)
305 if (dbg_s->ch) 346 if (dbg_s->ch)
306 dbg_unbind_channel_gk20a(dbg_s); 347 dbg_unbind_channel_gk20a(dbg_s);
307 348
308 /* Powergate enable is called here as possibility of dbg_session 349 /* Powergate/Timeout enable is called here as possibility of dbg_session
309 * which called powergate disable ioctl, to be killed without calling 350 * which called powergate/timeout disable ioctl, to be killed without
310 * powergate enable ioctl 351 * calling powergate/timeout enable ioctl
311 */ 352 */
312 mutex_lock(&g->dbg_sessions_lock); 353 mutex_lock(&g->dbg_sessions_lock);
313 dbg_set_powergate(dbg_s, NVGPU_DBG_GPU_POWERGATE_MODE_ENABLE); 354 dbg_set_powergate(dbg_s, NVGPU_DBG_GPU_POWERGATE_MODE_ENABLE);
355 nvgpu_dbg_timeout_enable(dbg_s, NVGPU_DBG_GPU_IOCTL_TIMEOUT_ENABLE);
314 mutex_unlock(&g->dbg_sessions_lock); 356 mutex_unlock(&g->dbg_sessions_lock);
315 357
316 kfree(dbg_s); 358 kfree(dbg_s);
@@ -391,6 +433,22 @@ static int gk20a_dbg_pc_sampling(struct dbg_session_gk20a *dbg_s,
391 return g->ops.gr.update_pc_sampling ? 433 return g->ops.gr.update_pc_sampling ?
392 g->ops.gr.update_pc_sampling(ch, args->enable) : -EINVAL; 434 g->ops.gr.update_pc_sampling(ch, args->enable) : -EINVAL;
393} 435}
436
437static int nvgpu_dbg_gpu_ioctl_timeout(struct dbg_session_gk20a *dbg_s,
438 struct nvgpu_dbg_gpu_timeout_args *args)
439{
440 int err;
441 struct gk20a *g = get_gk20a(dbg_s->pdev);
442
443 gk20a_dbg_fn("powergate mode = %d", args->enable);
444
445 mutex_lock(&g->dbg_sessions_lock);
446 err = nvgpu_dbg_timeout_enable(dbg_s, args->enable);
447 mutex_unlock(&g->dbg_sessions_lock);
448
449 return err;
450}
451
394long gk20a_dbg_gpu_dev_ioctl(struct file *filp, unsigned int cmd, 452long gk20a_dbg_gpu_dev_ioctl(struct file *filp, unsigned int cmd,
395 unsigned long arg) 453 unsigned long arg)
396{ 454{
@@ -468,6 +526,11 @@ long gk20a_dbg_gpu_dev_ioctl(struct file *filp, unsigned int cmd,
468 (struct nvgpu_dbg_gpu_pc_sampling_args *)buf); 526 (struct nvgpu_dbg_gpu_pc_sampling_args *)buf);
469 break; 527 break;
470 528
529 case NVGPU_DBG_GPU_IOCTL_TIMEOUT:
530 err = nvgpu_dbg_gpu_ioctl_timeout(dbg_s,
531 (struct nvgpu_dbg_gpu_timeout_args *)buf);
532 break;
533
471 default: 534 default:
472 gk20a_err(dev_from_gk20a(g), 535 gk20a_err(dev_from_gk20a(g),
473 "unrecognized dbg gpu ioctl cmd: 0x%x", 536 "unrecognized dbg gpu ioctl cmd: 0x%x",
diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h
index 27084c0d..fc1f2982 100644
--- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Tegra GK20A GPU Debugger Driver 2 * Tegra GK20A GPU Debugger Driver
3 * 3 *
4 * Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2013-2015, 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,
@@ -53,6 +53,9 @@ struct dbg_session_gk20a {
53 /* power enabled or disabled */ 53 /* power enabled or disabled */
54 bool is_pg_disabled; 54 bool is_pg_disabled;
55 55
56 /* timeouts enabled or disabled */
57 bool is_timeout_disabled;
58
56 /* 59 /*
57 * There can be different versions of the whitelists 60 * There can be different versions of the whitelists
58 * between both global and per-context sets; as well 61 * between both global and per-context sets; as well
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 328bb73b..e106c479 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -532,6 +532,7 @@ struct gk20a {
532 struct mutex dbg_sessions_lock; 532 struct mutex dbg_sessions_lock;
533 int dbg_sessions; /* number attached */ 533 int dbg_sessions; /* number attached */
534 int dbg_powergating_disabled_refcount; /*refcount for pg disable */ 534 int dbg_powergating_disabled_refcount; /*refcount for pg disable */
535 int dbg_timeout_disabled_refcount; /*refcount for timeout disable */
535 536
536 void (*remove_support)(struct platform_device *); 537 void (*remove_support)(struct platform_device *);
537 538
diff --git a/include/uapi/linux/nvgpu.h b/include/uapi/linux/nvgpu.h
index 6fdf4025..f55346db 100644
--- a/include/uapi/linux/nvgpu.h
+++ b/include/uapi/linux/nvgpu.h
@@ -547,8 +547,20 @@ struct nvgpu_dbg_gpu_pc_sampling_args {
547#define NVGPU_DBG_GPU_IOCTL_PC_SAMPLING \ 547#define NVGPU_DBG_GPU_IOCTL_PC_SAMPLING \
548 _IOW(NVGPU_DBG_GPU_IOCTL_MAGIC, 9, struct nvgpu_dbg_gpu_pc_sampling_args) 548 _IOW(NVGPU_DBG_GPU_IOCTL_MAGIC, 9, struct nvgpu_dbg_gpu_pc_sampling_args)
549 549
550/* Enable/Disable timeouts */
551#define NVGPU_DBG_GPU_IOCTL_TIMEOUT_ENABLE 1
552#define NVGPU_DBG_GPU_IOCTL_TIMEOUT_DISABLE 0
553
554struct nvgpu_dbg_gpu_timeout_args {
555 __u32 enable;
556 __u32 padding;
557};
558
559#define NVGPU_DBG_GPU_IOCTL_TIMEOUT \
560 _IOW(NVGPU_DBG_GPU_IOCTL_MAGIC, 10, struct nvgpu_dbg_gpu_timeout_args)
561
550#define NVGPU_DBG_GPU_IOCTL_LAST \ 562#define NVGPU_DBG_GPU_IOCTL_LAST \
551 _IOC_NR(NVGPU_DBG_GPU_IOCTL_PC_SAMPLING) 563 _IOC_NR(NVGPU_DBG_GPU_IOCTL_TIMEOUT)
552#define NVGPU_DBG_GPU_IOCTL_MAX_ARG_SIZE \ 564#define NVGPU_DBG_GPU_IOCTL_MAX_ARG_SIZE \
553 sizeof(struct nvgpu_dbg_gpu_perfbuf_map_args) 565 sizeof(struct nvgpu_dbg_gpu_perfbuf_map_args)
554 566