diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index c6d055126..f7c8a0b90 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c @@ -617,7 +617,7 @@ static ssize_t aelpg_param_store(struct device *dev, struct gk20a *g = get_gk20a(dev); int status = 0; union pmu_ap_cmd ap_cmd; - int *paramlist = (int *)g->pmu->pg->aelpg_param; + int *paramlist = NULL; u32 defaultparam[5] = { APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US, APCTRL_MINIMUM_IDLE_FILTER_DEFAULT_US, @@ -626,6 +626,12 @@ static ssize_t aelpg_param_store(struct device *dev, APCTRL_CYCLES_PER_SAMPLE_MAX_DEFAULT }; + if (!g->aelpg_enabled) { + nvgpu_info(g, "AELPG not enabled"); + return count; + } + + paramlist = (int *)g->pmu->pg->aelpg_param; /* Get each parameter value from input string*/ sscanf(buf, "%d %d %d %d %d", ¶mlist[0], ¶mlist[1], ¶mlist[2], ¶mlist[3], ¶mlist[4]); @@ -659,10 +665,15 @@ static ssize_t aelpg_param_read(struct device *dev, { struct gk20a *g = get_gk20a(dev); - return snprintf(buf, NVGPU_CPU_PAGE_SIZE, - "%d %d %d %d %d\n", g->pmu->pg->aelpg_param[0], - g->pmu->pg->aelpg_param[1], g->pmu->pg->aelpg_param[2], - g->pmu->pg->aelpg_param[3], g->pmu->pg->aelpg_param[4]); + if (g->aelpg_enabled) { + return snprintf(buf, NVGPU_CPU_PAGE_SIZE, + "%d %d %d %d %d\n", g->pmu->pg->aelpg_param[0], + g->pmu->pg->aelpg_param[1], g->pmu->pg->aelpg_param[2], + g->pmu->pg->aelpg_param[3], g->pmu->pg->aelpg_param[4]); + } else { + nvgpu_info(g, "AELPG not enabled"); + } + return 0; } static DEVICE_ATTR(aelpg_param, ROOTRW, @@ -680,6 +691,11 @@ static ssize_t aelpg_enable_store(struct device *dev, if (kstrtoul(buf, 10, &val) < 0) return -EINVAL; + if (!g->can_elpg) { + nvgpu_info(g, "Feature not supported"); + return count; + } + err = gk20a_busy(g); if (err) { return err;