[v4,12/37] clk: fixup cstate selection

Submitted by Karol Herbst on April 18, 2016, 7:13 p.m.

Details

Message ID 1461006851-5007-13-git-send-email-nouveau@karolherbst.de
State New
Headers show
Series "Volting/Clocking improvements for Fermi and newer" ( rev: 4 ) in Nouveau

Not browsing as part of any series.

Commit Message

Karol Herbst April 18, 2016, 7:13 p.m.
now the cstatei parameter can be used of the nvkm_cstate_prog function to
select a specific cstate.

-1 is a magic value, which will always select the highest currently possible
cstate

Signed-off-by: Karol Herbst <nouveau@karolherbst.de>
---
 drm/nouveau/nvkm/subdev/clk/base.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c
index 0eb4c16..fecf58f 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -85,7 +85,15 @@  nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
 	int ret;
 
 	if (!list_empty(&pstate->list)) {
-		cstate = list_entry(pstate->list.prev, typeof(*cstate), head);
+		if (cstatei == -1)
+			cstate = list_entry(pstate->list.prev, typeof(*cstate),
+					    head);
+		else {
+			list_for_each_entry(cstate, &pstate->list, head) {
+				if (cstate->cstate == cstatei)
+					break;
+			}
+		}
 	} else {
 		cstate = &pstate->base;
 	}
@@ -207,7 +215,7 @@  nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
 		ram->func->tidy(ram);
 	}
 
-	return nvkm_cstate_prog(clk, pstate, 0);
+	return nvkm_cstate_prog(clk, pstate, -1);
 }
 
 static void