drm/nouveau/drm/nouveau/clk: fix tstate to pstate calculation

According to the tstate calculation in nvkm_clk_tstate(),
the range of tstate is from -(clk->state_nr - 1) to 0,
it mean the tstate is negative value. But in nvkm_pstate_work(),
it use (clk->state_nr - 1 - clk->tstate) to limit pstate,
it's not correct.
This patch fix it to use (clk->state_nr - 1 + clk->tstate) to
limit pstate.

Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
This commit is contained in:
Wei Ni 2015-06-16 17:35:12 +08:00 committed by Ben Skeggs
parent d4a312dc90
commit 85fa319d8a
1 changed files with 1 additions and 1 deletions
drivers/gpu/drm/nouveau/nvkm/subdev/clk

View File

@ -214,7 +214,7 @@ nvkm_pstate_work(struct work_struct *work)
pstate = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc; pstate = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc;
if (clk->state_nr && pstate != -1) { if (clk->state_nr && pstate != -1) {
pstate = (pstate < 0) ? clk->astate : pstate; pstate = (pstate < 0) ? clk->astate : pstate;
pstate = min(pstate, clk->state_nr - 1 - clk->tstate); pstate = min(pstate, clk->state_nr - 1 + clk->tstate);
pstate = max(pstate, clk->dstate); pstate = max(pstate, clk->dstate);
} else { } else {
pstate = clk->pstate = -1; pstate = clk->pstate = -1;