From ae014242d9709974e3253c0e84406f1d8c1c15a1 Mon Sep 17 00:00:00 2001 From: Martin Peres Date: Thu, 8 Aug 2013 00:33:06 -0400 Subject: [PATCH 2/5] drm/nouveau/fan: restore the PWM value on resume when using the manual or auto mode If the fan was in manual or auto mode, we should restore the fan speed that was previously set when resuming. The initial pwm value is saved when loading the module. Signed-off-by: Martin Peres --- drivers/gpu/drm/nouveau/core/subdev/therm/base.c | 7 ++++++- drivers/gpu/drm/nouveau/core/subdev/therm/fan.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/base.c b/drivers/gpu/drm/nouveau/core/subdev/therm/base.c index 3e9d941..2ada3d7 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/base.c @@ -267,8 +267,13 @@ _nouveau_therm_init(struct nouveau_object *object) if (ret) return ret; - if (priv->suspend >= 0) + if (priv->suspend >= 0) { + /* restore the pwm value only when on manual or auto mode */ + if (priv->suspend > 0) + nouveau_therm_fan_set(therm, true, priv->fan->percent); + nouveau_therm_fan_mode(therm, priv->suspend); + } priv->sensor.program_alarms(therm); return 0; } diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c index c728380..6d411e1 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c @@ -233,6 +233,9 @@ nouveau_therm_fan_ctor(struct nouveau_therm *therm) } nv_info(therm, "FAN control: %s\n", priv->fan->type); + + /* read the current speed, it is useful when resuming */ + priv->fan->percent = nouveau_therm_fan_get(therm); /* attempt to detect a tachometer connection */ ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &priv->fan->tach); -- 1.8.3.4