Skip to contentSkip to conversation

drm/nouveau/clk: fix tstate to pstate calculation

PATCH In review Wei Ni 2 participants 2 messages Jun 16, 2015 – Jun 17, 2015 1 message not in the archive

lore
Share & tools
lore

Wei Ni

author
#0 lore raw

PATCH v2 1/1 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.

---
v2: create patch based on http://cgit.freedesktop.org/~darktama/nouveau/

 drm/nouveau/nvkm/subdev/clk/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drm/nouveau/nvkm/subdev/clk/base.c +1 -1
index 39a83d82e0cd..77a0ab5ca3b0 100644
@@ -214,7 +214,7 @@ nvkm_pstate_work(struct work_struct *work)
 	pstate = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc;
 	if (clk->state_nr && pstate != -1) {
 		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);
 	} else {
 		pstate = clk->pstate = -1;
Signature · 6 lines
1.9.1

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#2 lore raw
In reply to a message not in the archive
Quoted 11 lines · Wei Ni

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.

---
v2: create patch based on http://cgit.freedesktop.org/~darktama/nouveau/

For future reference, it doesn't matter to me which tree it's based on, theres a script in that repo under scripts/ that can apply either form easily. So, use whichever is easiest for you :)

I've merged the patch.

Thanks,
Ben.

Quoted 20 lines
 drm/nouveau/nvkm/subdev/clk/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drm/nouveau/nvkm/subdev/clk/base.c +1 -2
index 39a83d82e0cd..77a0ab5ca3b0 100644
@@ -214,7 +214,7 @@ nvkm_pstate_work(struct work_struct *work)
        pstate = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc;
        if (clk->state_nr && pstate != -1) {
                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);
        } else {
                pstate = clk->pstate = -1;
--

1.9.1

Quoted 4 lines

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau