From: Karol Herbst <karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH 3/9] clk: Make pstate a pointer to nvkm_pstate
Date: Sun, 5 Mar 2017 17:35:01 +0100 [thread overview]
Message-ID: <20170305163507.2002-4-karolherbst@gmail.com> (raw)
In-Reply-To: <20170305163507.2002-1-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
We will access the current set cstate at least every second and this safes
us some CPU cycles looking them up every second.
Signed-off-by: Karol Herbst <karolherbst@gmail.com>
Reviewed-by: Martin Peres <martin.peres@free.fr>
---
drm/nouveau/include/nvkm/subdev/clk.h | 4 +++-
drm/nouveau/nvkm/engine/device/ctrl.c | 5 ++++-
drm/nouveau/nvkm/subdev/clk/base.c | 17 ++++++++++++-----
drm/nouveau/nvkm/subdev/pmu/gk20a.c | 18 +++++++-----------
4 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/drm/nouveau/include/nvkm/subdev/clk.h b/drm/nouveau/include/nvkm/subdev/clk.h
index 69942b14..37263b7f 100644
--- a/drm/nouveau/include/nvkm/subdev/clk.h
+++ b/drm/nouveau/include/nvkm/subdev/clk.h
@@ -10,6 +10,8 @@ struct nvkm_pll_vals;
#define NVKM_CLK_CSTATE_BASE -2 /* pstate base */
#define NVKM_CLK_CSTATE_HIGHEST -3 /* highest possible */
+#define NVKM_CLK_PSTATE_DEFAULT -1
+
enum nv_clk_src {
nv_clk_src_crystal,
nv_clk_src_href,
@@ -95,7 +97,7 @@ struct nvkm_clk {
struct nvkm_notify pwrsrc_ntfy;
int pwrsrc;
- int pstate; /* current */
+ struct nvkm_pstate *pstate; /* current */
int ustate_ac; /* user-requested (-1 disabled, -2 perfmon) */
int ustate_dc; /* user-requested (-1 disabled, -2 perfmon) */
int astate; /* perfmon adjustment (base) */
diff --git a/drm/nouveau/nvkm/engine/device/ctrl.c b/drm/nouveau/nvkm/engine/device/ctrl.c
index b0ece71a..da70626c 100644
--- a/drm/nouveau/nvkm/engine/device/ctrl.c
+++ b/drm/nouveau/nvkm/engine/device/ctrl.c
@@ -52,7 +52,10 @@ nvkm_control_mthd_pstate_info(struct nvkm_control *ctrl, void *data, u32 size)
args->v0.ustate_ac = clk->ustate_ac;
args->v0.ustate_dc = clk->ustate_dc;
args->v0.pwrsrc = clk->pwrsrc;
- args->v0.pstate = clk->pstate;
+ if (clk->pstate)
+ args->v0.pstate = clk->pstate->pstate;
+ else
+ args->v0.pstate = NVKM_CLK_PSTATE_DEFAULT;
} else {
args->v0.count = 0;
args->v0.ustate_ac = NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE;
diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c
index 07d530ed..0d4d9fdf 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -271,13 +271,16 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
struct nvkm_pstate *pstate;
int ret, idx = 0;
+ if (pstatei == NVKM_CLK_PSTATE_DEFAULT)
+ return 0;
+
list_for_each_entry(pstate, &clk->states, head) {
if (idx++ == pstatei)
break;
}
nvkm_debug(subdev, "setting performance state %d\n", pstatei);
- clk->pstate = pstatei;
+ clk->pstate = pstate;
nvkm_pcie_set_link(pci, pstate->pcie_speed, pstate->pcie_width);
@@ -306,8 +309,12 @@ nvkm_clk_update_work(struct work_struct *work)
return;
clk->pwrsrc = power_supply_is_system_supplied();
+ if (clk->pstate)
+ pstate = clk->pstate->pstate;
+ else
+ pstate = NVKM_CLK_PSTATE_DEFAULT;
nvkm_trace(subdev, "P %d PWR %d U(AC) %d U(DC) %d A %d T %d°C\n",
- clk->pstate, clk->pwrsrc, clk->ustate_ac, clk->ustate_dc,
+ pstate, clk->pwrsrc, clk->ustate_ac, clk->ustate_dc,
clk->astate, clk->temp);
pstate = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc;
@@ -315,11 +322,11 @@ nvkm_clk_update_work(struct work_struct *work)
pstate = (pstate < 0) ? clk->astate : pstate;
pstate = min(pstate, clk->state_nr - 1);
} else {
- pstate = clk->pstate = -1;
+ pstate = NVKM_CLK_PSTATE_DEFAULT;
}
nvkm_trace(subdev, "-> %d\n", pstate);
- if (pstate != clk->pstate) {
+ if (!clk->pstate || pstate != clk->pstate->pstate) {
int ret = nvkm_pstate_prog(clk, pstate);
if (ret) {
nvkm_error(subdev, "error setting pstate %d: %d\n",
@@ -610,7 +617,7 @@ nvkm_clk_init(struct nvkm_subdev *subdev)
return clk->func->init(clk);
clk->astate = clk->state_nr - 1;
- clk->pstate = -1;
+ clk->pstate = NULL;
clk->temp = 90; /* reasonable default value */
nvkm_clk_update(clk, true);
return 0;
diff --git a/drm/nouveau/nvkm/subdev/pmu/gk20a.c b/drm/nouveau/nvkm/subdev/pmu/gk20a.c
index 9ca0db79..43a9a74a 100644
--- a/drm/nouveau/nvkm/subdev/pmu/gk20a.c
+++ b/drm/nouveau/nvkm/subdev/pmu/gk20a.c
@@ -55,24 +55,22 @@ gk20a_pmu_dvfs_target(struct gk20a_pmu *pmu, int *state)
return nvkm_clk_astate(clk, *state, 0, false);
}
-static void
-gk20a_pmu_dvfs_get_cur_state(struct gk20a_pmu *pmu, int *state)
-{
- struct nvkm_clk *clk = pmu->base.subdev.device->clk;
-
- *state = clk->pstate;
-}
-
static int
gk20a_pmu_dvfs_get_target_state(struct gk20a_pmu *pmu,
int *state, int load)
{
struct gk20a_pmu_dvfs_data *data = pmu->data;
struct nvkm_clk *clk = pmu->base.subdev.device->clk;
+ struct nvkm_pstate *pstate = clk->pstate;
int cur_level, level;
+ if (!pstate) {
+ *state = 0;
+ return 1;
+ }
+
/* For GK20A, the performance level is directly mapped to pstate */
- level = cur_level = clk->pstate;
+ level = cur_level = clk->pstate->pstate;
if (load > data->p_load_max) {
level = min(clk->state_nr - 1, level + (clk->state_nr / 3));
@@ -142,8 +140,6 @@ gk20a_pmu_dvfs_work(struct nvkm_alarm *alarm)
nvkm_trace(subdev, "utilization = %d %%, avg_load = %d %%\n",
utilization, data->avg_load);
- gk20a_pmu_dvfs_get_cur_state(pmu, &state);
-
if (gk20a_pmu_dvfs_get_target_state(pmu, &state, data->avg_load)) {
nvkm_trace(subdev, "set new state to %d\n", state);
gk20a_pmu_dvfs_target(pmu, &state);
--
2.12.0
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
next prev parent reply other threads:[~2017-03-05 16:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-05 16:34 [PATCH 0/9] clk subdev updates Karol Herbst
[not found] ` <20170305163507.2002-1-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-05 16:34 ` [PATCH 1/9] clk: Rename nvkm_pstate_calc to nvkm_clk_update and export it Karol Herbst
[not found] ` <20170305163507.2002-2-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-06 23:09 ` Martin Peres
2017-03-05 16:35 ` [PATCH 2/9] clk: Remove dstate Karol Herbst
[not found] ` <20170305163507.2002-3-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-05 16:40 ` Ilia Mirkin
2017-03-05 16:35 ` Karol Herbst [this message]
[not found] ` <20170305163507.2002-4-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-06 23:25 ` [PATCH 3/9] clk: Make pstate a pointer to nvkm_pstate Martin Peres
2017-03-05 16:35 ` [PATCH 4/9] clk: Hold information about the current cstate status Karol Herbst
2017-03-05 16:35 ` [PATCH 5/9] clk: We should pass the pstate id around not the index in the list Karol Herbst
[not found] ` <20170305163507.2002-6-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-06 23:26 ` Martin Peres
2017-03-05 16:35 ` [PATCH 6/9] clk: Split out update code to nv40 Karol Herbst
2017-03-05 16:35 ` [PATCH 7/9] clk: Only do partial reclocks as required Karol Herbst
2017-03-05 16:35 ` [PATCH 8/9] clk: Set clocks to pre suspend state after suspend Karol Herbst
[not found] ` <20170305163507.2002-9-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-06 23:45 ` Martin Peres
2017-03-05 16:35 ` [PATCH 9/9] clk: Check pm_runtime status before reclocking Karol Herbst
[not found] ` <20170305163507.2002-10-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-06 23:46 ` Martin Peres
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170305163507.2002-4-karolherbst@gmail.com \
--to=karolherbst-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.