summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu
diff options
context:
space:
mode:
authorsujeet baranwal <sbaranwal@nvidia.com>2014-08-07 20:04:18 -0400
committerDan Willemsen <dwillemsen@nvidia.com>2015-03-18 15:10:49 -0400
commit5db7a42055eb2239b5a3a597935c27ac0b920d3d (patch)
tree778d28ffd3e32200a6a3ff978c3ad02146281234 /drivers/gpu/nvgpu
parent42d37357f8b4d2f2433f43f951dcbc3978d9f949 (diff)
gpu: sysfs mode for allowing access to registers
Through this sysfs entry, the register space becomes accessible. This is be accessible root-only. Bug 1523403 Change-Id: Ia46f130a0cfd8324c5b675d19e7cbfba9dcb17ca Signed-off-by: sujeet baranwal <sbaranwal@nvidia.com> Reviewed-on: http://git-master/r/454198 Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h1
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c32
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.c7
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_ctxsw_prog_gk20a.h4
4 files changed, 43 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index a82ad254..3d93ccde 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -289,6 +289,7 @@ struct gk20a {
289 bool aelpg_enabled; 289 bool aelpg_enabled;
290 bool forced_idle; 290 bool forced_idle;
291 bool forced_reset; 291 bool forced_reset;
292 bool allow_all;
292 293
293#ifdef CONFIG_DEBUG_FS 294#ifdef CONFIG_DEBUG_FS
294 spinlock_t debugfs_lock; 295 spinlock_t debugfs_lock;
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c
index 97a0452c..7e0183ca 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c
@@ -439,6 +439,36 @@ static ssize_t aelpg_enable_read(struct device *device,
439static DEVICE_ATTR(aelpg_enable, ROOTRW, 439static DEVICE_ATTR(aelpg_enable, ROOTRW,
440 aelpg_enable_read, aelpg_enable_store); 440 aelpg_enable_read, aelpg_enable_store);
441 441
442
443static ssize_t allow_all_enable_read(struct device *device,
444 struct device_attribute *attr, char *buf)
445{
446 struct platform_device *ndev = to_platform_device(device);
447 struct gk20a *g = get_gk20a(ndev);
448 return sprintf(buf, "%d\n", g->allow_all ? 1 : 0);
449}
450
451static ssize_t allow_all_enable_store(struct device *device,
452 struct device_attribute *attr, const char *buf, size_t count)
453{
454 struct platform_device *ndev = to_platform_device(device);
455 struct gk20a *g = get_gk20a(ndev);
456 unsigned long val = 0;
457 int err;
458
459 if (kstrtoul(buf, 10, &val) < 0)
460 return -EINVAL;
461
462 err = gk20a_busy(g->dev);
463 g->allow_all = (val ? true : false);
464 gk20a_idle(g->dev);
465
466 return count;
467}
468
469static DEVICE_ATTR(allow_all, ROOTRW,
470 allow_all_enable_read, allow_all_enable_store);
471
442#ifdef CONFIG_PM_RUNTIME 472#ifdef CONFIG_PM_RUNTIME
443static ssize_t force_idle_store(struct device *device, 473static ssize_t force_idle_store(struct device *device,
444 struct device_attribute *attr, const char *buf, size_t count) 474 struct device_attribute *attr, const char *buf, size_t count)
@@ -509,6 +539,7 @@ void gk20a_remove_sysfs(struct device *dev)
509#endif 539#endif
510 device_remove_file(dev, &dev_attr_aelpg_param); 540 device_remove_file(dev, &dev_attr_aelpg_param);
511 device_remove_file(dev, &dev_attr_aelpg_enable); 541 device_remove_file(dev, &dev_attr_aelpg_enable);
542 device_remove_file(dev, &dev_attr_allow_all);
512 543
513 if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) 544 if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev))
514 sysfs_remove_link(&dev->kobj, dev_name(dev)); 545 sysfs_remove_link(&dev->kobj, dev_name(dev));
@@ -534,6 +565,7 @@ void gk20a_create_sysfs(struct platform_device *dev)
534#endif 565#endif
535 error |= device_create_file(&dev->dev, &dev_attr_aelpg_param); 566 error |= device_create_file(&dev->dev, &dev_attr_aelpg_param);
536 error |= device_create_file(&dev->dev, &dev_attr_aelpg_enable); 567 error |= device_create_file(&dev->dev, &dev_attr_aelpg_enable);
568 error |= device_create_file(&dev->dev, &dev_attr_allow_all);
537 569
538 if (g->host1x_dev && (dev->dev.parent != &g->host1x_dev->dev)) 570 if (g->host1x_dev && (dev->dev.parent != &g->host1x_dev->dev))
539 error |= sysfs_create_link(&g->host1x_dev->dev.kobj, 571 error |= sysfs_create_link(&g->host1x_dev->dev.kobj,
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
index d9ab99a4..874b8056 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
@@ -1713,8 +1713,13 @@ int gr_gk20a_load_golden_ctx_image(struct gk20a *g,
1713 virt_addr_hi = 1713 virt_addr_hi =
1714 u64_hi32(ch_ctx->global_ctx_buffer_va[PRIV_ACCESS_MAP_VA]); 1714 u64_hi32(ch_ctx->global_ctx_buffer_va[PRIV_ACCESS_MAP_VA]);
1715 1715
1716 if (g->allow_all)
1717 data = ctxsw_prog_main_image_priv_access_map_config_mode_allow_all_f();
1718 else
1719 data = ctxsw_prog_main_image_priv_access_map_config_mode_use_map_f();
1720
1716 gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_priv_access_map_config_o(), 0, 1721 gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_priv_access_map_config_o(), 0,
1717 ctxsw_prog_main_image_priv_access_map_config_mode_use_map_f()); 1722 data);
1718 gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_priv_access_map_addr_lo_o(), 0, 1723 gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_priv_access_map_addr_lo_o(), 0,
1719 virt_addr_lo); 1724 virt_addr_lo);
1720 gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_priv_access_map_addr_hi_o(), 0, 1725 gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_priv_access_map_addr_hi_o(), 0,
diff --git a/drivers/gpu/nvgpu/gk20a/hw_ctxsw_prog_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_ctxsw_prog_gk20a.h
index 747566f0..3d9095a8 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_ctxsw_prog_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_ctxsw_prog_gk20a.h
@@ -214,6 +214,10 @@ static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_v(u32 r)
214{ 214{
215 return (r >> 0) & 0x3; 215 return (r >> 0) & 0x3;
216} 216}
217static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_allow_all_f(void)
218{
219 return 0x0;
220}
217static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_use_map_f(void) 221static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_use_map_f(void)
218{ 222{
219 return 0x2; 223 return 0x2;