gpu: nvgpu: sysfs node to read PMU state
Mahantesh Kumbar [Wed, 25 Jan 2017 10:00:45 +0000 (15:00 +0530)]
sysfs node to know PMU state whether PMU
boot completed & its ready with state
"pmu->pmu_state == PMU_STATE_STARTED" to
process command request.

issue: enable/disable request for ELPG/AELPG
through sysfs node during init stage of boot process
causing PMU halt error due to unknown state of
PMU at boot time.

Fix: Provided node to read PMU state if ready then
send commands else wait till gets ready.

Bug 1865815

Change-Id: Idad4c5390fffafbe591658b85942e8c6c6d3afc8
Signed-off-by: Mahantesh Kumbar <mkumbar@nvidia.com>
Reviewed-on: http://git-master/r/1296823
Reviewed-by: David Dastous St Hilaire <ddastoussthi@nvidia.com>
Tested-by: David Dastous St Hilaire <ddastoussthi@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Vinayak Pane <vpane@nvidia.com>

drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c

index 78b0778..db01aa7 100644 (file)
@@ -416,6 +416,24 @@ static ssize_t gk20a_load_show(struct device *dev,
 }
 static DEVICE_ATTR(load, S_IRUGO, gk20a_load_show, NULL);
 
+static ssize_t pmu_state_read(struct device *device,
+       struct device_attribute *attr, char *buf)
+{
+       struct platform_device *ndev = to_platform_device(device);
+       struct gk20a *g = get_gk20a(ndev);
+       struct pmu_gk20a *pmu = &g->pmu;
+       int status = 0;
+
+       if (g->power_on)
+               status = (pmu->pmu_ready &&
+                       (pmu->pmu_state == PMU_STATE_STARTED))
+                       ? 1 : 0;
+
+       return sprintf(buf, "%d\n", status);
+}
+
+static DEVICE_ATTR(pmu_state, S_IRUSR|S_IRGRP|S_IROTH, pmu_state_read, NULL);
+
 static ssize_t elpg_enable_store(struct device *device,
        struct device_attribute *attr, const char *buf, size_t count)
 {
@@ -768,6 +786,7 @@ void gk20a_remove_sysfs(struct device *dev)
        device_remove_file(dev, &dev_attr_blcg_enable);
        device_remove_file(dev, &dev_attr_slcg_enable);
        device_remove_file(dev, &dev_attr_ptimer_scale_factor);
+       device_remove_file(dev, &dev_attr_pmu_state);
        device_remove_file(dev, &dev_attr_elpg_enable);
        device_remove_file(dev, &dev_attr_emc3d_ratio);
        device_remove_file(dev, &dev_attr_fmax_at_vmin_safe);
@@ -801,6 +820,7 @@ void gk20a_create_sysfs(struct platform_device *dev)
        error |= device_create_file(&dev->dev, &dev_attr_blcg_enable);
        error |= device_create_file(&dev->dev, &dev_attr_slcg_enable);
        error |= device_create_file(&dev->dev, &dev_attr_ptimer_scale_factor);
+       error |= device_create_file(&dev->dev, &dev_attr_pmu_state);
        error |= device_create_file(&dev->dev, &dev_attr_elpg_enable);
        error |= device_create_file(&dev->dev, &dev_attr_emc3d_ratio);
        error |= device_create_file(&dev->dev, &dev_attr_fmax_at_vmin_safe);