Commit 68d82161 authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Ben Skeggs

drm/nouveau/pmu/gk20a: simplify code a bit

Some functions always succeed - change their return type to void and
remove the error-handling code in their caller.
Signed-off-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent d8711c5a
...@@ -43,9 +43,8 @@ struct gk20a_pmu { ...@@ -43,9 +43,8 @@ struct gk20a_pmu {
}; };
struct gk20a_pmu_dvfs_dev_status { struct gk20a_pmu_dvfs_dev_status {
unsigned long total; u32 total;
unsigned long busy; u32 busy;
int cur_state;
}; };
static int static int
...@@ -56,13 +55,12 @@ gk20a_pmu_dvfs_target(struct gk20a_pmu *pmu, int *state) ...@@ -56,13 +55,12 @@ gk20a_pmu_dvfs_target(struct gk20a_pmu *pmu, int *state)
return nvkm_clk_astate(clk, *state, 0, false); return nvkm_clk_astate(clk, *state, 0, false);
} }
static int static void
gk20a_pmu_dvfs_get_cur_state(struct gk20a_pmu *pmu, int *state) gk20a_pmu_dvfs_get_cur_state(struct gk20a_pmu *pmu, int *state)
{ {
struct nvkm_clk *clk = pmu->base.subdev.device->clk; struct nvkm_clk *clk = pmu->base.subdev.device->clk;
*state = clk->pstate; *state = clk->pstate;
return 0;
} }
static int static int
...@@ -90,20 +88,16 @@ gk20a_pmu_dvfs_get_target_state(struct gk20a_pmu *pmu, ...@@ -90,20 +88,16 @@ gk20a_pmu_dvfs_get_target_state(struct gk20a_pmu *pmu,
*state = level; *state = level;
if (level == cur_level) return (level != cur_level);
return 0;
else
return 1;
} }
static int static void
gk20a_pmu_dvfs_get_dev_status(struct gk20a_pmu *pmu, gk20a_pmu_dvfs_get_dev_status(struct gk20a_pmu *pmu,
struct gk20a_pmu_dvfs_dev_status *status) struct gk20a_pmu_dvfs_dev_status *status)
{ {
struct nvkm_device *device = pmu->base.subdev.device; struct nvkm_device *device = pmu->base.subdev.device;
status->busy = nvkm_rd32(device, 0x10a508 + (BUSY_SLOT * 0x10)); status->busy = nvkm_rd32(device, 0x10a508 + (BUSY_SLOT * 0x10));
status->total= nvkm_rd32(device, 0x10a508 + (CLK_SLOT * 0x10)); status->total= nvkm_rd32(device, 0x10a508 + (CLK_SLOT * 0x10));
return 0;
} }
static void static void
...@@ -127,7 +121,7 @@ gk20a_pmu_dvfs_work(struct nvkm_alarm *alarm) ...@@ -127,7 +121,7 @@ gk20a_pmu_dvfs_work(struct nvkm_alarm *alarm)
struct nvkm_timer *tmr = device->timer; struct nvkm_timer *tmr = device->timer;
struct nvkm_volt *volt = device->volt; struct nvkm_volt *volt = device->volt;
u32 utilization = 0; u32 utilization = 0;
int state, ret; int state;
/* /*
* The PMU is initialized before CLK and VOLT, so we have to make sure the * The PMU is initialized before CLK and VOLT, so we have to make sure the
...@@ -136,11 +130,7 @@ gk20a_pmu_dvfs_work(struct nvkm_alarm *alarm) ...@@ -136,11 +130,7 @@ gk20a_pmu_dvfs_work(struct nvkm_alarm *alarm)
if (!clk || !volt) if (!clk || !volt)
goto resched; goto resched;
ret = gk20a_pmu_dvfs_get_dev_status(pmu, &status); gk20a_pmu_dvfs_get_dev_status(pmu, &status);
if (ret) {
nvkm_warn(subdev, "failed to get device status\n");
goto resched;
}
if (status.total) if (status.total)
utilization = div_u64((u64)status.busy * 100, status.total); utilization = div_u64((u64)status.busy * 100, status.total);
...@@ -150,11 +140,7 @@ gk20a_pmu_dvfs_work(struct nvkm_alarm *alarm) ...@@ -150,11 +140,7 @@ gk20a_pmu_dvfs_work(struct nvkm_alarm *alarm)
nvkm_trace(subdev, "utilization = %d %%, avg_load = %d %%\n", nvkm_trace(subdev, "utilization = %d %%, avg_load = %d %%\n",
utilization, data->avg_load); utilization, data->avg_load);
ret = gk20a_pmu_dvfs_get_cur_state(pmu, &state); gk20a_pmu_dvfs_get_cur_state(pmu, &state);
if (ret) {
nvkm_warn(subdev, "failed to get current state\n");
goto resched;
}
if (gk20a_pmu_dvfs_get_target_state(pmu, &state, data->avg_load)) { if (gk20a_pmu_dvfs_get_target_state(pmu, &state, data->avg_load)) {
nvkm_trace(subdev, "set new state to %d\n", state); nvkm_trace(subdev, "set new state to %d\n", state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment