mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: add aelpg flag check in sysfs node
- When read from aelpg_param_read sysfs node and write to aelpg_param_store sysfs node is done it leads to system crash. - This issue is seen on safety build as power features are not enabled. - To avoid this crash, add aelpg platform flag check in aelpg_param_read and aelpg_param_store sysfs nodes. - Also, as AELPG depends on ELPG add can_elpg check before enabling/disabling aelpg through sysfs node. Bug 3582946 Change-Id: Iaf709db2b5dc0340390767f4b06a0ac06962ed77 Signed-off-by: Divya <dsinghatwari@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2690548 Reviewed-by: svcacv <svcacv@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Mahantesh Kumbar <mkumbar@nvidia.com> Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
@@ -617,7 +617,7 @@ static ssize_t aelpg_param_store(struct device *dev,
|
|||||||
struct gk20a *g = get_gk20a(dev);
|
struct gk20a *g = get_gk20a(dev);
|
||||||
int status = 0;
|
int status = 0;
|
||||||
union pmu_ap_cmd ap_cmd;
|
union pmu_ap_cmd ap_cmd;
|
||||||
int *paramlist = (int *)g->pmu->pg->aelpg_param;
|
int *paramlist = NULL;
|
||||||
u32 defaultparam[5] = {
|
u32 defaultparam[5] = {
|
||||||
APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US,
|
APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US,
|
||||||
APCTRL_MINIMUM_IDLE_FILTER_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
|
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*/
|
/* Get each parameter value from input string*/
|
||||||
sscanf(buf, "%d %d %d %d %d", ¶mlist[0], ¶mlist[1],
|
sscanf(buf, "%d %d %d %d %d", ¶mlist[0], ¶mlist[1],
|
||||||
¶mlist[2], ¶mlist[3], ¶mlist[4]);
|
¶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);
|
struct gk20a *g = get_gk20a(dev);
|
||||||
|
|
||||||
|
if (g->aelpg_enabled) {
|
||||||
return snprintf(buf, NVGPU_CPU_PAGE_SIZE,
|
return snprintf(buf, NVGPU_CPU_PAGE_SIZE,
|
||||||
"%d %d %d %d %d\n", g->pmu->pg->aelpg_param[0],
|
"%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[1], g->pmu->pg->aelpg_param[2],
|
||||||
g->pmu->pg->aelpg_param[3], g->pmu->pg->aelpg_param[4]);
|
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,
|
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)
|
if (kstrtoul(buf, 10, &val) < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!g->can_elpg) {
|
||||||
|
nvgpu_info(g, "Feature not supported");
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
err = gk20a_busy(g);
|
err = gk20a_busy(g);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
Reference in New Issue
Block a user