From 5db7a42055eb2239b5a3a597935c27ac0b920d3d Mon Sep 17 00:00:00 2001 From: sujeet baranwal Date: Thu, 7 Aug 2014 17:04:18 -0700 Subject: 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 Reviewed-on: http://git-master/r/454198 Reviewed-by: Terje Bergstrom Tested-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/gk20a.h | 1 + drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | 32 +++++++++++++++++++++++++++ drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 7 +++++- drivers/gpu/nvgpu/gk20a/hw_ctxsw_prog_gk20a.h | 4 ++++ 4 files changed, 43 insertions(+), 1 deletion(-) (limited to 'drivers/gpu') 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 { bool aelpg_enabled; bool forced_idle; bool forced_reset; + bool allow_all; #ifdef CONFIG_DEBUG_FS 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, static DEVICE_ATTR(aelpg_enable, ROOTRW, aelpg_enable_read, aelpg_enable_store); + +static ssize_t allow_all_enable_read(struct device *device, + struct device_attribute *attr, char *buf) +{ + struct platform_device *ndev = to_platform_device(device); + struct gk20a *g = get_gk20a(ndev); + return sprintf(buf, "%d\n", g->allow_all ? 1 : 0); +} + +static ssize_t allow_all_enable_store(struct device *device, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct platform_device *ndev = to_platform_device(device); + struct gk20a *g = get_gk20a(ndev); + unsigned long val = 0; + int err; + + if (kstrtoul(buf, 10, &val) < 0) + return -EINVAL; + + err = gk20a_busy(g->dev); + g->allow_all = (val ? true : false); + gk20a_idle(g->dev); + + return count; +} + +static DEVICE_ATTR(allow_all, ROOTRW, + allow_all_enable_read, allow_all_enable_store); + #ifdef CONFIG_PM_RUNTIME static ssize_t force_idle_store(struct device *device, struct device_attribute *attr, const char *buf, size_t count) @@ -509,6 +539,7 @@ void gk20a_remove_sysfs(struct device *dev) #endif device_remove_file(dev, &dev_attr_aelpg_param); device_remove_file(dev, &dev_attr_aelpg_enable); + device_remove_file(dev, &dev_attr_allow_all); if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) sysfs_remove_link(&dev->kobj, dev_name(dev)); @@ -534,6 +565,7 @@ void gk20a_create_sysfs(struct platform_device *dev) #endif error |= device_create_file(&dev->dev, &dev_attr_aelpg_param); error |= device_create_file(&dev->dev, &dev_attr_aelpg_enable); + error |= device_create_file(&dev->dev, &dev_attr_allow_all); if (g->host1x_dev && (dev->dev.parent != &g->host1x_dev->dev)) 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, virt_addr_hi = u64_hi32(ch_ctx->global_ctx_buffer_va[PRIV_ACCESS_MAP_VA]); + if (g->allow_all) + data = ctxsw_prog_main_image_priv_access_map_config_mode_allow_all_f(); + else + data = ctxsw_prog_main_image_priv_access_map_config_mode_use_map_f(); + gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_priv_access_map_config_o(), 0, - ctxsw_prog_main_image_priv_access_map_config_mode_use_map_f()); + data); gk20a_mem_wr32(ctx_ptr + ctxsw_prog_main_image_priv_access_map_addr_lo_o(), 0, virt_addr_lo); 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) { return (r >> 0) & 0x3; } +static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_allow_all_f(void) +{ + return 0x0; +} static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_use_map_f(void) { return 0x2; -- cgit v1.2.2