[Nouveau] [RFC PATCH 18/29] clk: Only do partial reclocks as required
Karol Herbst
karolherbst at gmail.com
Fri Sep 15 17:11:18 UTC 2017
Signed-off-by: Karol Herbst <karolherbst at gmail.com>
---
drm/nouveau/nvkm/subdev/clk/base.c | 26 ++++++++++++++++++--------
drm/nouveau/nvkm/subdev/volt/base.c | 3 +++
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c
index 72ca5e0c..a154a425 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -171,7 +171,7 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
struct nvkm_therm *therm = device->therm;
struct nvkm_volt *volt = device->volt;
struct nvkm_cstate *cstate;
- int ret;
+ int ret = 0;
if (cstatei == NVKM_CLK_CSTATE_DEFAULT)
return 0;
@@ -183,6 +183,12 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
cstate = &pstate->base;
}
+ // if the cstate matches, just update the voltage
+ if (clk->cstate && clk->cstate == cstate)
+ return nvkm_volt_set_id(volt, clk->cstate->voltage,
+ clk->pstate->base.voltage, clk->temp,
+ 0);
+
if (therm) {
ret = nvkm_therm_cstate(therm, pstate->fanspeed, +1);
if (ret && ret != -ENODEV) {
@@ -284,6 +290,11 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstateid)
if (pstateid == NVKM_CLK_PSTATE_DEFAULT)
return 0;
+ if (clk->pstate && clk->pstate->pstate == pstateid) {
+ pstate = clk->pstate;
+ goto cstate;
+ }
+
list_for_each_entry(pstate, &clk->states, head) {
if (pstate->pstate == pstateid)
break;
@@ -308,6 +319,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstateid)
ram->func->tidy(ram);
}
+cstate:
if (clk->throttled)
cstate = list_first_entry(&pstate->list, struct nvkm_cstate, head)->id;
else
@@ -321,7 +333,7 @@ nvkm_clk_update_work(struct work_struct *work)
{
struct nvkm_clk *clk = container_of(work, typeof(*clk), work);
struct nvkm_subdev *subdev = &clk->subdev;
- int pstate;
+ int pstate, ret;
if (!atomic_xchg(&clk->waiting, 0))
return;
@@ -341,12 +353,10 @@ nvkm_clk_update_work(struct work_struct *work)
clk->pwrsrc, clk->ustate_ac, clk->ustate_dc,
clk->astate, clk->exp_cstateid, clk->temp);
- 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",
- pstate, ret);
- }
+ ret = nvkm_pstate_prog(clk, pstate);
+ if (ret) {
+ nvkm_error(subdev, "error setting pstate %d: %d\n",
+ pstate, ret);
}
wake_up_all(&clk->wait);
diff --git a/drm/nouveau/nvkm/subdev/volt/base.c b/drm/nouveau/nvkm/subdev/volt/base.c
index e344901c..56a0f379 100644
--- a/drm/nouveau/nvkm/subdev/volt/base.c
+++ b/drm/nouveau/nvkm/subdev/volt/base.c
@@ -162,6 +162,9 @@ nvkm_volt_set_id(struct nvkm_volt *volt, u8 id, u8 min_id, u8 temp,
{
int ret;
+ if (!volt)
+ return -ENODEV;
+
if (volt->func->set_id)
return volt->func->set_id(volt, id, condition);
--
2.14.1
More information about the Nouveau
mailing list