]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/nouveau/clk: Let nvkm_clk_tstate take a temperature value
authorKarol Herbst <karolherbst@gmail.com>
Sun, 17 Jul 2016 07:40:23 +0000 (09:40 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 12 Oct 2016 07:29:22 +0000 (17:29 +1000)
This way other subdevs can notify the clk subdev about temperature changes
without the need of clk to poll that value.

Also make this function safe to be called from an interrupt handler.

Signed-off-by: Karol Herbst <karolherbst@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/subdev/clk.h
drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c

index 70c8665756ca0c0e9350e744c385bb9bd97c181f..0cf3d86e399a6db3003f336b532ea704910c61bd 100644 (file)
@@ -94,8 +94,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) */
-       int tstate; /* thermal adjustment (max-) */
        int dstate; /* display adjustment (min+) */
+       u8  temp;
 
        bool allow_reclock;
 
@@ -111,7 +111,7 @@ int nvkm_clk_read(struct nvkm_clk *, enum nv_clk_src);
 int nvkm_clk_ustate(struct nvkm_clk *, int req, int pwr);
 int nvkm_clk_astate(struct nvkm_clk *, int req, int rel, bool wait);
 int nvkm_clk_dstate(struct nvkm_clk *, int req, int rel);
-int nvkm_clk_tstate(struct nvkm_clk *, int req, int rel);
+int nvkm_clk_tstate(struct nvkm_clk *, u8 temperature);
 
 int nv04_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
 int nv40_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
index 23cc04c37c07c90ff183c163d54ffeab9958f176..88a517c33842e8001649af7b7af085d370521820 100644 (file)
@@ -222,14 +222,14 @@ nvkm_pstate_work(struct work_struct *work)
                return;
        clk->pwrsrc = power_supply_is_system_supplied();
 
-       nvkm_trace(subdev, "P %d PWR %d U(AC) %d U(DC) %d A %d T %d D %d\n",
+       nvkm_trace(subdev, "P %d PWR %d U(AC) %d U(DC) %d A %d T %d°C D %d\n",
                   clk->pstate, clk->pwrsrc, clk->ustate_ac, clk->ustate_dc,
-                  clk->astate, clk->tstate, clk->dstate);
+                  clk->astate, clk->temp, clk->dstate);
 
        pstate = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc;
        if (clk->state_nr && pstate != -1) {
                pstate = (pstate < 0) ? clk->astate : pstate;
-               pstate = min(pstate, clk->state_nr - 1 + clk->tstate);
+               pstate = min(pstate, clk->state_nr - 1);
                pstate = max(pstate, clk->dstate);
        } else {
                pstate = clk->pstate = -1;
@@ -456,13 +456,12 @@ nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait)
 }
 
 int
-nvkm_clk_tstate(struct nvkm_clk *clk, int req, int rel)
+nvkm_clk_tstate(struct nvkm_clk *clk, u8 temp)
 {
-       if (!rel) clk->tstate  = req;
-       if ( rel) clk->tstate += rel;
-       clk->tstate = min(clk->tstate, 0);
-       clk->tstate = max(clk->tstate, -(clk->state_nr - 1));
-       return nvkm_pstate_calc(clk, true);
+       if (clk->temp == temp)
+               return 0;
+       clk->temp = temp;
+       return nvkm_pstate_calc(clk, false);
 }
 
 int
@@ -532,9 +531,9 @@ nvkm_clk_init(struct nvkm_subdev *subdev)
                return clk->func->init(clk);
 
        clk->astate = clk->state_nr - 1;
-       clk->tstate = 0;
        clk->dstate = 0;
        clk->pstate = -1;
+       clk->temp = 90; /* reasonable default value */
        nvkm_pstate_calc(clk, true);
        return 0;
 }