[Nouveau] [PATCH 15/19] nouveau/subdev/clk: fixup cstate selection

Karol Herbst nouveau at karolherbst.de
Thu Mar 17 23:03:52 UTC 2016


From: Karol Herbst <git at karolherbst.de>

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 at karolherbst.de>
---
 drm/nouveau/nvkm/subdev/clk/base.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c
index b79644d..7998840 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -86,7 +86,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;
 	}
@@ -223,7 +231,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
-- 
2.7.3



More information about the Nouveau mailing list