[Nouveau] [PATCH 14/32] clk: Hold information about the current cstate status

Karol Herbst karolherbst at gmail.com
Fri Nov 17 00:04:18 UTC 2017


Later we will have situations where the expected and the current state
isn't the same.

Signed-off-by: Karol Herbst <karolherbst at gmail.com>
Reviewed-by: Martin Peres <martin.peres at free.fr>
Acked-by: Pierre Moreau <pierre.morrow at free.fr>
---
 drm/nouveau/include/nvkm/subdev/clk.h | 9 +++++----
 drm/nouveau/nvkm/subdev/clk/base.c    | 5 +++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drm/nouveau/include/nvkm/subdev/clk.h b/drm/nouveau/include/nvkm/subdev/clk.h
index ebaa57eb..310df485 100644
--- a/drm/nouveau/include/nvkm/subdev/clk.h
+++ b/drm/nouveau/include/nvkm/subdev/clk.h
@@ -6,11 +6,11 @@
 struct nvbios_pll;
 struct nvkm_pll_vals;
 
-#define NVKM_CLK_PSTATE_BOOT    -1 /* POSTed default */
+#define NVKM_CLK_PSTATE_BOOT -1 /* POSTed default */
 
-#define NVKM_CLK_CSTATE_DEFAULT -1 /* POSTed default */
-#define NVKM_CLK_CSTATE_BASE    -2 /* pstate base */
-#define NVKM_CLK_CSTATE_AUTO    -3 /* highest possible */
+#define NVKM_CLK_CSTATE_BOOT -1 /* POSTed default */
+#define NVKM_CLK_CSTATE_BASE -2 /* pstate base */
+#define NVKM_CLK_CSTATE_AUTO -3 /* highest possible */
 
 enum nv_clk_src {
 	nv_clk_src_crystal,
@@ -101,6 +101,7 @@ struct nvkm_clk {
 	int ustate_ac; /* user-requested (-1 disabled, -2 perfmon) */
 	int ustate_dc; /* user-requested (-1 disabled, -2 perfmon) */
 	int astate; /* perfmon adjustment (base) */
+	int cstate_id;
 	int temp;
 
 	bool allow_reclock;
diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c
index 85b9fb48..b2c1605e 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -167,6 +167,9 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
 	struct nvkm_cstate *cstate;
 	int ret;
 
+	if (cstate_id == NVKM_CLK_CSTATE_BOOT)
+		return 0;
+
 	if (!list_empty(&pstate->cstates)) {
 		cstate = nvkm_cstate_get(clk, pstate, cstate_id);
 		cstate = nvkm_cstate_find_best(clk, pstate, cstate);
@@ -196,6 +199,7 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
 		ret = clk->func->prog(clk);
 		clk->func->tidy(clk);
 	}
+	clk->cstate_id = cstate->id;
 
 	if (volt) {
 		ret = nvkm_volt_set_id(volt, cstate->voltage,
@@ -603,6 +607,7 @@ nvkm_clk_init(struct nvkm_subdev *subdev)
 
 	clk->astate = NVKM_CLK_PSTATE_BOOT;
 	clk->pstate_id = NVKM_CLK_PSTATE_BOOT;
+	clk->cstate_id = NVKM_CLK_CSTATE_BOOT;
 	clk->temp = 90; /* reasonable default value */
 	nvkm_clk_update(clk, true);
 	return 0;
-- 
2.15.0



More information about the Nouveau mailing list