diff options
author | Seema Khowala <seemaj@nvidia.com> | 2017-10-30 17:15:51 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-05-18 22:54:33 -0400 |
commit | 982fcfa737be54fd0ab16792faf97a2741e34907 (patch) | |
tree | 6c45741a08156d43d2ea09a4136c104609989e42 /drivers/gpu/nvgpu/common | |
parent | ac687c95d383c3fb0165e6535893510409559a8e (diff) |
gpu: nvgpu: Add timeouts_disabled_refcount for enabling timeout
-timeouts will be enabled only when timeouts_disabled_refcount
will reach 0
-timeouts_enabled debugfs will change from u32 type to file type
to avoid race enabling/disabling timeout from debugfs and ioctl
-unify setting timeouts_enabled from debugfs and ioctl
Bug 1982434
Change-Id: I54bab778f1ae533872146dfb8d80deafd2a685c7
Signed-off-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1588690
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/debug.c | 58 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/driver_common.c | 13 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_dbg.c | 26 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vgpu/vgpu_linux.c | 3 |
4 files changed, 78 insertions, 22 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", |
diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c index 769f7e03..edc8aca8 100644 --- a/drivers/gpu/nvgpu/common/linux/driver_common.c +++ b/drivers/gpu/nvgpu/common/linux/driver_common.c | |||
@@ -96,12 +96,15 @@ static void nvgpu_init_timeout(struct gk20a *g) | |||
96 | { | 96 | { |
97 | struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g)); | 97 | struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g)); |
98 | 98 | ||
99 | g->gr_idle_timeout_default = NVGPU_DEFAULT_GR_IDLE_TIMEOUT; | 99 | g->timeouts_disabled_by_user = false; |
100 | if (nvgpu_platform_is_silicon(g)) | 100 | nvgpu_atomic_set(&g->timeouts_disabled_refcount, 0); |
101 | g->timeouts_enabled = true; | 101 | |
102 | else if (nvgpu_platform_is_fpga(g)) { | 102 | if (nvgpu_platform_is_silicon(g)) { |
103 | g->gr_idle_timeout_default = NVGPU_DEFAULT_GR_IDLE_TIMEOUT; | ||
104 | } else if (nvgpu_platform_is_fpga(g)) { | ||
103 | g->gr_idle_timeout_default = GK20A_TIMEOUT_FPGA; | 105 | g->gr_idle_timeout_default = GK20A_TIMEOUT_FPGA; |
104 | g->timeouts_enabled = true; | 106 | } else { |
107 | g->gr_idle_timeout_default = (u32)ULONG_MAX; | ||
105 | } | 108 | } |
106 | g->ch_wdt_timeout_ms = platform->ch_wdt_timeout_ms; | 109 | g->ch_wdt_timeout_ms = platform->ch_wdt_timeout_ms; |
107 | } | 110 | } |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_dbg.c b/drivers/gpu/nvgpu/common/linux/ioctl_dbg.c index 2aba2664..31e7e2cb 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_dbg.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_dbg.c | |||
@@ -228,7 +228,7 @@ static int nvgpu_dbg_gpu_ioctl_timeout(struct dbg_session_gk20a *dbg_s, | |||
228 | int err; | 228 | int err; |
229 | struct gk20a *g = dbg_s->g; | 229 | struct gk20a *g = dbg_s->g; |
230 | 230 | ||
231 | nvgpu_log_fn(g, "powergate mode = %d", args->enable); | 231 | nvgpu_log(g, gpu_dbg_fn, "timeout enable/disable = %d", args->enable); |
232 | 232 | ||
233 | nvgpu_mutex_acquire(&g->dbg_sessions_lock); | 233 | nvgpu_mutex_acquire(&g->dbg_sessions_lock); |
234 | err = nvgpu_dbg_timeout_enable(dbg_s, args->enable); | 234 | err = nvgpu_dbg_timeout_enable(dbg_s, args->enable); |
@@ -385,18 +385,14 @@ static int nvgpu_dbg_timeout_enable(struct dbg_session_gk20a *dbg_s, | |||
385 | 385 | ||
386 | switch (timeout_mode) { | 386 | switch (timeout_mode) { |
387 | case NVGPU_DBG_GPU_IOCTL_TIMEOUT_ENABLE: | 387 | case NVGPU_DBG_GPU_IOCTL_TIMEOUT_ENABLE: |
388 | if (dbg_s->is_timeout_disabled && | 388 | if (dbg_s->is_timeout_disabled == true) |
389 | --g->dbg_timeout_disabled_refcount == 0) { | 389 | nvgpu_atomic_dec(&g->timeouts_disabled_refcount); |
390 | g->timeouts_enabled = true; | ||
391 | } | ||
392 | dbg_s->is_timeout_disabled = false; | 390 | dbg_s->is_timeout_disabled = false; |
393 | break; | 391 | break; |
394 | 392 | ||
395 | case NVGPU_DBG_GPU_IOCTL_TIMEOUT_DISABLE: | 393 | case NVGPU_DBG_GPU_IOCTL_TIMEOUT_DISABLE: |
396 | if ((dbg_s->is_timeout_disabled == false) && | 394 | if (dbg_s->is_timeout_disabled == false) |
397 | (g->dbg_timeout_disabled_refcount++ == 0)) { | 395 | nvgpu_atomic_inc(&g->timeouts_disabled_refcount); |
398 | g->timeouts_enabled = false; | ||
399 | } | ||
400 | dbg_s->is_timeout_disabled = true; | 396 | dbg_s->is_timeout_disabled = true; |
401 | break; | 397 | break; |
402 | 398 | ||
@@ -408,9 +404,11 @@ static int nvgpu_dbg_timeout_enable(struct dbg_session_gk20a *dbg_s, | |||
408 | break; | 404 | break; |
409 | } | 405 | } |
410 | 406 | ||
411 | nvgpu_log(g, gpu_dbg_gpu_dbg, "Timeouts enabled : %s", | 407 | if (!err) |
412 | g->timeouts_enabled ? "Yes" : "No"); | 408 | nvgpu_log(g, gpu_dbg_gpu_dbg, "dbg is timeout disabled %s, " |
413 | 409 | "timeouts disabled refcount %d", | |
410 | dbg_s->is_timeout_disabled ? "true" : "false", | ||
411 | nvgpu_atomic_read(&g->timeouts_disabled_refcount)); | ||
414 | return err; | 412 | return err; |
415 | } | 413 | } |
416 | 414 | ||
@@ -1598,11 +1596,11 @@ static int nvgpu_ioctl_profiler_reserve(struct dbg_session_gk20a *dbg_s, | |||
1598 | static void nvgpu_dbg_gpu_ioctl_get_timeout(struct dbg_session_gk20a *dbg_s, | 1596 | static void nvgpu_dbg_gpu_ioctl_get_timeout(struct dbg_session_gk20a *dbg_s, |
1599 | struct nvgpu_dbg_gpu_timeout_args *args) | 1597 | struct nvgpu_dbg_gpu_timeout_args *args) |
1600 | { | 1598 | { |
1601 | int status; | 1599 | bool status; |
1602 | struct gk20a *g = dbg_s->g; | 1600 | struct gk20a *g = dbg_s->g; |
1603 | 1601 | ||
1604 | nvgpu_mutex_acquire(&g->dbg_sessions_lock); | 1602 | nvgpu_mutex_acquire(&g->dbg_sessions_lock); |
1605 | status = g->timeouts_enabled; | 1603 | status = nvgpu_is_timeouts_enabled(g); |
1606 | nvgpu_mutex_release(&g->dbg_sessions_lock); | 1604 | nvgpu_mutex_release(&g->dbg_sessions_lock); |
1607 | 1605 | ||
1608 | if (status) | 1606 | if (status) |
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/vgpu_linux.c b/drivers/gpu/nvgpu/common/linux/vgpu/vgpu_linux.c index 5d3598b5..c5572603 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/vgpu_linux.c +++ b/drivers/gpu/nvgpu/common/linux/vgpu/vgpu_linux.c | |||
@@ -424,7 +424,8 @@ int vgpu_probe(struct platform_device *pdev) | |||
424 | dma_set_max_seg_size(dev, UINT_MAX); | 424 | dma_set_max_seg_size(dev, UINT_MAX); |
425 | 425 | ||
426 | gk20a->gr_idle_timeout_default = NVGPU_DEFAULT_GR_IDLE_TIMEOUT; | 426 | gk20a->gr_idle_timeout_default = NVGPU_DEFAULT_GR_IDLE_TIMEOUT; |
427 | gk20a->timeouts_enabled = true; | 427 | gk20a->timeouts_disabled_by_user = false; |
428 | nvgpu_atomic_set(&gk20a->timeouts_disabled_refcount, 0); | ||
428 | 429 | ||
429 | vgpu_create_sysfs(dev); | 430 | vgpu_create_sysfs(dev); |
430 | gk20a_init_gr(gk20a); | 431 | gk20a_init_gr(gk20a); |