From 034e23c197541e0e8ac6a4d95b1d3b6d1be885cd Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Fri, 17 Aug 2018 14:31:11 -0700 Subject: gpu: nvgpu: add gpu_powered_on sysfs Add sysfs to indicate if GPU has ever been powered on. This allows an application to avoid booting dGPU, when there is no need for it. For instance the fan controller can check this value, and refrain from booting the GPU, only to check the temperature. This will save power, and also avoid locking some registers which currently prevent from using VBIOS update tool. Bug 200408936 Change-Id: I6344001e91e9eee8762ff8b227ca6698d8c6786f Signed-off-by: Thomas Fleury Reviewed-on: https://git-master.nvidia.com/r/1802098 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/sysfs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers/gpu/nvgpu/os/linux/sysfs.c') diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index 5eef8bfa..9e48e45d 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c @@ -301,6 +301,17 @@ static DEVICE_ATTR(ptimer_src_freq, NULL); +static ssize_t gpu_powered_on_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct gk20a *g = get_gk20a(dev); + + return snprintf(buf, PAGE_SIZE, "%u\n", g->power_on); +} + +static DEVICE_ATTR(gpu_powered_on, S_IRUGO, gpu_powered_on_show, NULL); + #if defined(CONFIG_PM) static ssize_t railgate_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -1234,6 +1245,7 @@ void nvgpu_remove_sysfs(struct device *dev) device_remove_file(dev, &dev_attr_pd_max_batches); device_remove_file(dev, &dev_attr_gfxp_wfi_timeout_count); device_remove_file(dev, &dev_attr_gfxp_wfi_timeout_unit); + device_remove_file(dev, &dev_attr_gpu_powered_on); device_remove_file(dev, &dev_attr_comptag_mem_deduct); @@ -1288,6 +1300,7 @@ int nvgpu_create_sysfs(struct device *dev) error |= device_create_file(dev, &dev_attr_pd_max_batches); error |= device_create_file(dev, &dev_attr_gfxp_wfi_timeout_count); error |= device_create_file(dev, &dev_attr_gfxp_wfi_timeout_unit); + error |= device_create_file(dev, &dev_attr_gpu_powered_on); error |= device_create_file(dev, &dev_attr_comptag_mem_deduct); -- cgit v1.2.2