[08/32] clk: Rename nvkm_clk.states to pstates

Submitted by Karol Herbst on Nov. 17, 2017, 12:04 a.m.

Details

Message ID 20171117000436.2432-9-karolherbst@gmail.com
State New
Headers show
Series "Updated State of my clk patches" ( rev: 1 ) in Nouveau

Not browsing as part of any series.

Commit Message

Karol Herbst Nov. 17, 2017, 12:04 a.m.
From: Karol Herbst <kherbst@redhat.com>

Those are pstates, so call them that way.

Signed-off-by: Karol Herbst <kherbst@redhat.com>
---
 drm/nouveau/include/nvkm/subdev/clk.h |  4 ++--
 drm/nouveau/nvkm/engine/device/ctrl.c |  6 +++---
 drm/nouveau/nvkm/subdev/clk/base.c    | 26 +++++++++++++-------------
 drm/nouveau/nvkm/subdev/pmu/gk20a.c   |  5 +++--
 4 files changed, 21 insertions(+), 20 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drm/nouveau/include/nvkm/subdev/clk.h b/drm/nouveau/include/nvkm/subdev/clk.h
index dcc93950..2f326554 100644
--- a/drm/nouveau/include/nvkm/subdev/clk.h
+++ b/drm/nouveau/include/nvkm/subdev/clk.h
@@ -88,8 +88,8 @@  struct nvkm_clk {
 	const struct nvkm_domain *domains;
 	struct nvkm_pstate bstate;
 
-	struct list_head states;
-	int state_nr;
+	struct list_head pstates;
+	int pstates_cnt;
 
 	struct work_struct work;
 	wait_queue_head_t wait;
diff --git a/drm/nouveau/nvkm/engine/device/ctrl.c b/drm/nouveau/nvkm/engine/device/ctrl.c
index e07948e6..279e442e 100644
--- a/drm/nouveau/nvkm/engine/device/ctrl.c
+++ b/drm/nouveau/nvkm/engine/device/ctrl.c
@@ -48,7 +48,7 @@  nvkm_control_mthd_pstate_info(struct nvkm_control *ctrl, void *data, u32 size)
 		return ret;
 
 	if (clk) {
-		args->v0.count = clk->state_nr;
+		args->v0.count = clk->pstates_cnt;
 		args->v0.ustate_ac = clk->ustate_ac;
 		args->v0.ustate_dc = clk->ustate_dc;
 		args->v0.pwrsrc = clk->pwrsrc;
@@ -87,7 +87,7 @@  nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)
 			return -ENODEV;
 		if (args->v0.state < NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT)
 			return -EINVAL;
-		if (args->v0.state >= clk->state_nr)
+		if (args->v0.state >= clk->pstates_cnt)
 			return -EINVAL;
 	} else
 		return ret;
@@ -103,7 +103,7 @@  nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)
 		return -EINVAL;
 
 	if (args->v0.state != NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT) {
-		list_for_each_entry(pstate, &clk->states, head) {
+		list_for_each_entry(pstate, &clk->pstates, head) {
 			if (i++ == args->v0.state)
 				break;
 		}
diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c
index 6229cb6a..ef6ad783 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -273,7 +273,7 @@  nvkm_pstate_prog(struct nvkm_clk *clk, int pstate_idx)
 	struct nvkm_pstate *pstate;
 	int ret, idx = 0;
 
-	list_for_each_entry(pstate, &clk->states, head) {
+	list_for_each_entry(pstate, &clk->pstates, head) {
 		if (idx++ == pstate_idx)
 			break;
 	}
@@ -313,9 +313,9 @@  nvkm_pstate_work(struct work_struct *work)
 		   clk->astate, clk->temp, clk->dstate);
 
 	pstate_idx = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc;
-	if (clk->state_nr && pstate_idx != NVKM_CLK_PSTATE_BOOT) {
+	if (clk->pstates_cnt && pstate_idx != NVKM_CLK_PSTATE_BOOT) {
 		pstate_idx = (pstate_idx < 0) ? clk->astate : pstate_idx;
-		pstate_idx = min(pstate_idx, clk->state_nr - 1);
+		pstate_idx = min(pstate_idx, clk->pstates_cnt - 1);
 		pstate_idx = max(pstate_idx, clk->dstate);
 	} else {
 		pstate_idx = clk->pstate_idx = NVKM_CLK_PSTATE_BOOT;
@@ -463,8 +463,8 @@  nvkm_pstate_new(struct nvkm_clk *clk, int idx)
 	}
 
 	nvkm_pstate_info(clk, pstate);
-	list_add_tail(&pstate->head, &clk->states);
-	clk->state_nr++;
+	list_add_tail(&pstate->head, &clk->pstates);
+	clk->pstates_cnt++;
 	return 0;
 }
 
@@ -481,7 +481,7 @@  nvkm_clk_ustate_update(struct nvkm_clk *clk, int req)
 		return -ENOSYS;
 
 	if (req != -1 && req != -2) {
-		list_for_each_entry(pstate, &clk->states, head) {
+		list_for_each_entry(pstate, &clk->pstates, head) {
 			if (pstate->id == req)
 				break;
 			i++;
@@ -536,7 +536,7 @@  nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait)
 {
 	if (!rel) clk->astate  = req;
 	if ( rel) clk->astate += rel;
-	clk->astate = min(clk->astate, clk->state_nr - 1);
+	clk->astate = min(clk->astate, clk->pstates_cnt - 1);
 	clk->astate = max(clk->astate, 0);
 	return nvkm_pstate_calc(clk, wait);
 }
@@ -555,7 +555,7 @@  nvkm_clk_dstate(struct nvkm_clk *clk, int req, int rel)
 {
 	if (!rel) clk->dstate  = req;
 	if ( rel) clk->dstate += rel;
-	clk->dstate = min(clk->dstate, clk->state_nr - 1);
+	clk->dstate = min(clk->dstate, clk->pstates_cnt - 1);
 	clk->dstate = max(clk->dstate, 0);
 	return nvkm_pstate_calc(clk, true);
 }
@@ -616,7 +616,7 @@  nvkm_clk_init(struct nvkm_subdev *subdev)
 	if (clk->func->init)
 		return clk->func->init(clk);
 
-	clk->astate = clk->state_nr - 1;
+	clk->astate = clk->pstates_cnt - 1;
 	clk->dstate = 0;
 	clk->pstate_idx = NVKM_CLK_PSTATE_BOOT;
 	clk->temp = 90; /* reasonable default value */
@@ -636,7 +636,7 @@  nvkm_clk_dtor(struct nvkm_subdev *subdev)
 	if (clk->func->pstates)
 		return clk;
 
-	list_for_each_entry_safe(pstate, temp, &clk->states, head) {
+	list_for_each_entry_safe(pstate, temp, &clk->pstates, head) {
 		nvkm_pstate_del(pstate);
 	}
 
@@ -671,7 +671,7 @@  nvkm_clk_ctor(const struct nvkm_clk_func *func, struct nvkm_device *device,
 	}
 
 	clk->func = func;
-	INIT_LIST_HEAD(&clk->states);
+	INIT_LIST_HEAD(&clk->pstates);
 	clk->domains = func->domains;
 	clk->ustate_ac = NVKM_CLK_PSTATE_BOOT;
 	clk->ustate_dc = NVKM_CLK_PSTATE_BOOT;
@@ -689,8 +689,8 @@  nvkm_clk_ctor(const struct nvkm_clk_func *func, struct nvkm_device *device,
 		} while (ret == 0);
 	} else {
 		for (idx = 0; idx < func->nr_pstates; idx++)
-			list_add_tail(&func->pstates[idx].head, &clk->states);
-		clk->state_nr = func->nr_pstates;
+			list_add_tail(&func->pstates[idx].head, &clk->pstates);
+		clk->pstates_cnt = func->nr_pstates;
 	}
 
 	ret = nvkm_notify_init(NULL, &device->event, nvkm_clk_pwrsrc, true,
diff --git a/drm/nouveau/nvkm/subdev/pmu/gk20a.c b/drm/nouveau/nvkm/subdev/pmu/gk20a.c
index 0c169215..f5abc664 100644
--- a/drm/nouveau/nvkm/subdev/pmu/gk20a.c
+++ b/drm/nouveau/nvkm/subdev/pmu/gk20a.c
@@ -75,12 +75,13 @@  gk20a_pmu_dvfs_get_target_state(struct gk20a_pmu *pmu,
 	level = cur_level = clk->pstate_idx;
 
 	if (load > data->p_load_max) {
-		level = min(clk->state_nr - 1, level + (clk->state_nr / 3));
+		level = min(clk->pstates_cnt - 1,
+			    level + (clk->pstates_cnt / 3));
 	} else {
 		level += ((load - data->p_load_target) * 10 /
 				data->p_load_target) / 2;
 		level = max(0, level);
-		level = min(clk->state_nr - 1, level);
+		level = min(clk->pstates_cnt - 1, level);
 	}
 
 	nvkm_trace(&pmu->base.subdev, "cur level = %d, new level = %d\n",