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_sysfs.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c') 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, -- cgit v1.2.2