diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/debug.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/debug.c | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/debug.c b/drivers/gpu/nvgpu/common/linux/debug.c index e8c0417a..87b35dc1 100644 --- a/drivers/gpu/nvgpu/common/linux/debug.c +++ b/drivers/gpu/nvgpu/common/linux/debug.c | |||
@@ -279,6 +279,59 @@ static int gk20a_railgating_debugfs_init(struct gk20a *g) | |||
279 | 279 | ||
280 | return 0; | 280 | return 0; |
281 | } | 281 | } |
282 | static ssize_t timeouts_enabled_read(struct file *file, | ||
283 | char __user *user_buf, size_t count, loff_t *ppos) | ||
284 | { | ||
285 | char buf[3]; | ||
286 | struct gk20a *g = file->private_data; | ||
287 | |||
288 | if (nvgpu_is_timeouts_enabled(g)) | ||
289 | buf[0] = 'Y'; | ||
290 | else | ||
291 | buf[0] = 'N'; | ||
292 | buf[1] = '\n'; | ||
293 | buf[2] = 0x00; | ||
294 | return simple_read_from_buffer(user_buf, count, ppos, buf, 2); | ||
295 | } | ||
296 | |||
297 | static ssize_t timeouts_enabled_write(struct file *file, | ||
298 | const char __user *user_buf, size_t count, loff_t *ppos) | ||
299 | { | ||
300 | char buf[3]; | ||
301 | int buf_size; | ||
302 | bool timeouts_enabled; | ||
303 | struct gk20a *g = file->private_data; | ||
304 | |||
305 | buf_size = min(count, (sizeof(buf)-1)); | ||
306 | if (copy_from_user(buf, user_buf, buf_size)) | ||
307 | return -EFAULT; | ||
308 | |||
309 | if (strtobool(buf, &timeouts_enabled) == 0) { | ||
310 | nvgpu_mutex_acquire(&g->dbg_sessions_lock); | ||
311 | if (timeouts_enabled == false) { | ||
312 | /* requesting to disable timeouts */ | ||
313 | if (g->timeouts_disabled_by_user == false) { | ||
314 | nvgpu_atomic_inc(&g->timeouts_disabled_refcount); | ||
315 | g->timeouts_disabled_by_user = true; | ||
316 | } | ||
317 | } else { | ||
318 | /* requesting to enable timeouts */ | ||
319 | if (g->timeouts_disabled_by_user == true) { | ||
320 | nvgpu_atomic_dec(&g->timeouts_disabled_refcount); | ||
321 | g->timeouts_disabled_by_user = false; | ||
322 | } | ||
323 | } | ||
324 | nvgpu_mutex_release(&g->dbg_sessions_lock); | ||
325 | } | ||
326 | |||
327 | return count; | ||
328 | } | ||
329 | |||
330 | static const struct file_operations timeouts_enabled_fops = { | ||
331 | .open = simple_open, | ||
332 | .read = timeouts_enabled_read, | ||
333 | .write = timeouts_enabled_write, | ||
334 | }; | ||
282 | 335 | ||
283 | void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink) | 336 | void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink) |
284 | { | 337 | { |
@@ -323,10 +376,11 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink) | |||
323 | S_IRUGO|S_IWUSR, l->debugfs, | 376 | S_IRUGO|S_IWUSR, l->debugfs, |
324 | &g->gr_idle_timeout_default); | 377 | &g->gr_idle_timeout_default); |
325 | l->debugfs_timeouts_enabled = | 378 | l->debugfs_timeouts_enabled = |
326 | debugfs_create_bool("timeouts_enabled", | 379 | debugfs_create_file("timeouts_enabled", |
327 | S_IRUGO|S_IWUSR, | 380 | S_IRUGO|S_IWUSR, |
328 | l->debugfs, | 381 | l->debugfs, |
329 | &g->timeouts_enabled); | 382 | g, |
383 | &timeouts_enabled_fops); | ||
330 | 384 | ||
331 | l->debugfs_disable_bigpage = | 385 | l->debugfs_disable_bigpage = |
332 | debugfs_create_file("disable_bigpage", | 386 | debugfs_create_file("disable_bigpage", |