From: Karol Herbst <karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH 4/9] clk: Hold information about the current cstate status
Date: Sun, 5 Mar 2017 17:35:02 +0100 [thread overview]
Message-ID: <20170305163507.2002-5-karolherbst@gmail.com> (raw)
In-Reply-To: <20170305163507.2002-1-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Later we will have situations where the expected and the current state
isn't the same.
Signed-off-by: Karol Herbst <karolherbst@gmail.com>
Reviewed-by: Martin Peres <martin.peres@free.fr>
---
drm/nouveau/include/nvkm/subdev/clk.h | 2 ++
drm/nouveau/nvkm/subdev/clk/base.c | 32 +++++++++++++++++++++++++-------
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/drm/nouveau/include/nvkm/subdev/clk.h b/drm/nouveau/include/nvkm/subdev/clk.h
index 37263b7f..0e0af704 100644
--- a/drm/nouveau/include/nvkm/subdev/clk.h
+++ b/drm/nouveau/include/nvkm/subdev/clk.h
@@ -101,6 +101,8 @@ 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) */
+ struct nvkm_cstate *cstate;
+ int exp_cstateid;
u8 temp;
bool allow_reclock;
diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c
index 0d4d9fdf..d37c13b7 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -146,9 +146,14 @@ static struct nvkm_cstate *
nvkm_cstate_get(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
{
struct nvkm_cstate *cstate;
- if (cstatei == NVKM_CLK_CSTATE_HIGHEST)
+ switch (cstatei) {
+ case NVKM_CLK_CSTATE_HIGHEST:
return list_last_entry(&pstate->list, typeof(*cstate), head);
- else {
+ case NVKM_CLK_CSTATE_BASE:
+ return &pstate->base;
+ case NVKM_CLK_CSTATE_DEFAULT:
+ return NULL;
+ default:
list_for_each_entry(cstate, &pstate->list, head) {
if (cstate->id == cstatei)
return cstate;
@@ -167,6 +172,9 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
struct nvkm_cstate *cstate;
int ret;
+ if (cstatei == NVKM_CLK_CSTATE_DEFAULT)
+ return 0;
+
if (!list_empty(&pstate->list)) {
cstate = nvkm_cstate_get(clk, pstate, cstatei);
cstate = nvkm_cstate_find_best(clk, pstate, cstate);
@@ -193,6 +201,7 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
ret = clk->func->calc(clk, cstate);
if (ret == 0) {
+ clk->cstate = cstate;
ret = clk->func->prog(clk);
clk->func->tidy(clk);
}
@@ -295,7 +304,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
ram->func->tidy(ram);
}
- return nvkm_cstate_prog(clk, pstate, NVKM_CLK_CSTATE_HIGHEST);
+ return nvkm_cstate_prog(clk, pstate, clk->exp_cstateid);
}
static void
@@ -313,9 +322,9 @@ nvkm_clk_update_work(struct work_struct *work)
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",
+ nvkm_trace(subdev, "P %d PWR %d U(AC) %d U(DC) %d A %d C %d T %d°C\n",
pstate, clk->pwrsrc, clk->ustate_ac, clk->ustate_dc,
- clk->astate, clk->temp);
+ clk->astate, clk->exp_cstateid, clk->temp);
pstate = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc;
if (clk->state_nr && pstate != -1) {
@@ -536,6 +545,7 @@ nvkm_clk_ustate(struct nvkm_clk *clk, int req, int pwr)
if (ret >= 0) {
if (ret -= 2, pwr) clk->ustate_ac = ret;
else clk->ustate_dc = ret;
+ clk->exp_cstateid = NVKM_CLK_CSTATE_HIGHEST;
return nvkm_clk_update(clk, true);
}
return ret;
@@ -548,6 +558,7 @@ nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait)
if ( rel) clk->astate += rel;
clk->astate = min(clk->astate, clk->state_nr - 1);
clk->astate = max(clk->astate, 0);
+ clk->exp_cstateid = NVKM_CLK_CSTATE_BASE;
return nvkm_clk_update(clk, wait);
}
@@ -618,6 +629,8 @@ nvkm_clk_init(struct nvkm_subdev *subdev)
clk->astate = clk->state_nr - 1;
clk->pstate = NULL;
+ clk->exp_cstateid = NVKM_CLK_CSTATE_DEFAULT;
+ clk->cstate = NULL;
clk->temp = 90; /* reasonable default value */
nvkm_clk_update(clk, true);
return 0;
@@ -701,15 +714,20 @@ nvkm_clk_ctor(const struct nvkm_clk_func *func, struct nvkm_device *device,
if (mode) {
clk->ustate_ac = nvkm_clk_nstate(clk, mode, arglen);
clk->ustate_dc = nvkm_clk_nstate(clk, mode, arglen);
+ clk->exp_cstateid = NVKM_CLK_CSTATE_HIGHEST;
}
mode = nvkm_stropt(device->cfgopt, "NvClkModeAC", &arglen);
- if (mode)
+ if (mode) {
clk->ustate_ac = nvkm_clk_nstate(clk, mode, arglen);
+ clk->exp_cstateid = NVKM_CLK_CSTATE_HIGHEST;
+ }
mode = nvkm_stropt(device->cfgopt, "NvClkModeDC", &arglen);
- if (mode)
+ if (mode) {
clk->ustate_dc = nvkm_clk_nstate(clk, mode, arglen);
+ clk->exp_cstateid = NVKM_CLK_CSTATE_HIGHEST;
+ }
clk->boost_mode = nvkm_longopt(device->cfgopt, "NvBoost",
NVKM_CLK_BOOST_NONE);
--
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 ` [PATCH 3/9] clk: Make pstate a pointer to nvkm_pstate Karol Herbst
[not found] ` <20170305163507.2002-4-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-06 23:25 ` Martin Peres
2017-03-05 16:35 ` Karol Herbst [this message]
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-5-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.