[20/32] therm: Cancel the timer only in fini

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

Details

Message ID 20171117000436.2432-21-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.
We will need a always running therm daemon to adjust the voltage/clocks on
the fly.

Signed-off-by: Karol Herbst <karolherbst@gmail.com>
Reviewed-by: Martin Peres <martin.peres@free.fr>
---
 drm/nouveau/nvkm/subdev/therm/base.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drm/nouveau/nvkm/subdev/therm/base.c b/drm/nouveau/nvkm/subdev/therm/base.c
index 3e1767a0..c978008e 100644
--- a/drm/nouveau/nvkm/subdev/therm/base.c
+++ b/drm/nouveau/nvkm/subdev/therm/base.c
@@ -107,7 +107,6 @@  nvkm_therm_update(struct nvkm_therm *therm, int mode)
 	struct nvkm_clk *clk = subdev->device->clk;
 	unsigned long flags;
 	bool immd = true;
-	bool poll = true;
 	int duty = -1;
 	int temp;
 
@@ -121,11 +120,9 @@  nvkm_therm_update(struct nvkm_therm *therm, int mode)
 
 	switch (mode) {
 	case NVKM_THERM_CTRL_MANUAL:
-		nvkm_timer_alarm(tmr, 0, &therm->alarm);
 		duty = nvkm_therm_fan_get(therm);
 		if (duty < 0)
 			duty = 100;
-		poll = false;
 		break;
 	case NVKM_THERM_CTRL_AUTO:
 		switch(therm->fan->bios.fan_mode) {
@@ -147,11 +144,10 @@  nvkm_therm_update(struct nvkm_therm *therm, int mode)
 		break;
 	case NVKM_THERM_CTRL_NONE:
 	default:
-		nvkm_timer_alarm(tmr, 0, &therm->alarm);
-		poll = false;
+		break;
 	}
 
-	if (poll)
+	if (list_empty(&therm->alarm.head))
 		nvkm_timer_alarm(tmr, 1000000000ULL, &therm->alarm);
 	spin_unlock_irqrestore(&therm->lock, flags);
 
@@ -318,6 +314,11 @@  static int
 nvkm_therm_fini(struct nvkm_subdev *subdev, bool suspend)
 {
 	struct nvkm_therm *therm = nvkm_therm(subdev);
+	struct nvkm_timer *tmr = subdev->device->timer;
+
+	/* cancel the timer */
+	if (!list_empty(&therm->alarm.head))
+		nvkm_timer_alarm(tmr, 0, &therm->alarm);
 
 	if (therm->func->fini)
 		therm->func->fini(therm);