提交 61679fe1 编写于 作者: M Martin Peres 提交者: Ben Skeggs

drm/nouveau/pm/fan: drop the fan lock in fan_update() before rescheduling

This should fix a deadlock that has been reported to us where fan_update()
would hold the fan lock and try to grab the alarm_program_lock to reschedule
an update. On an other CPU, the alarm_program_lock would have been taken
before calling fan_update(), leading to a deadlock.

We should Cc: <stable@vger.kernel.org> # 3.9+
Reported-by: NMarcin Slusarz <marcin.slusarz@gmail.com>
Tested-by: NTimothée Ravier <tim@siosm.fr>
Tested-by: Boris Fersing (IRC nick fersingb, no public email address)
Signed-off-by: NMartin Peres <martin.peres@free.fr>
Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
上级 6c3252bc
...@@ -54,8 +54,10 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target) ...@@ -54,8 +54,10 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
/* check that we're not already at the target duty cycle */ /* check that we're not already at the target duty cycle */
duty = fan->get(therm); duty = fan->get(therm);
if (duty == target) if (duty == target) {
goto done; spin_unlock_irqrestore(&fan->lock, flags);
return 0;
}
/* smooth out the fanspeed increase/decrease */ /* smooth out the fanspeed increase/decrease */
if (!immediate && duty >= 0) { if (!immediate && duty >= 0) {
...@@ -73,8 +75,15 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target) ...@@ -73,8 +75,15 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
nv_debug(therm, "FAN update: %d\n", duty); nv_debug(therm, "FAN update: %d\n", duty);
ret = fan->set(therm, duty); ret = fan->set(therm, duty);
if (ret) if (ret) {
goto done; spin_unlock_irqrestore(&fan->lock, flags);
return ret;
}
/* fan speed updated, drop the fan lock before grabbing the
* alarm-scheduling lock and risking a deadlock
*/
spin_unlock_irqrestore(&fan->lock, flags);
/* schedule next fan update, if not at target speed already */ /* schedule next fan update, if not at target speed already */
if (list_empty(&fan->alarm.head) && target != duty) { if (list_empty(&fan->alarm.head) && target != duty) {
...@@ -92,8 +101,6 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target) ...@@ -92,8 +101,6 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
ptimer->alarm(ptimer, delay * 1000 * 1000, &fan->alarm); ptimer->alarm(ptimer, delay * 1000 * 1000, &fan->alarm);
} }
done:
spin_unlock_irqrestore(&fan->lock, flags);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册