aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorMartin Peres <martin.peres@labri.fr>2014-03-13 19:26:52 -0400
committerBen Skeggs <bskeggs@redhat.com>2014-03-26 00:08:24 -0400
commit61679fe153b2b9ea5b5e2ab93305419e85e99a9d (patch)
tree4ee9e9b60320cc6f97c5b0dde16a30542d2f3111 /drivers/gpu
parent6c3252bc83155ae69d78fefdc7458aa64d8a87db (diff)
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: Marcin Slusarz <marcin.slusarz@gmail.com> Tested-by: Timothée Ravier <tim@siosm.fr> Tested-by: Boris Fersing (IRC nick fersingb, no public email address) Signed-off-by: Martin Peres <martin.peres@free.fr> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/therm/fan.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c
index 95f6129eeede..29d4c417a5b3 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c
@@ -54,8 +54,10 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
54 54
55 /* check that we're not already at the target duty cycle */ 55 /* check that we're not already at the target duty cycle */
56 duty = fan->get(therm); 56 duty = fan->get(therm);
57 if (duty == target) 57 if (duty == target) {
58 goto done; 58 spin_unlock_irqrestore(&fan->lock, flags);
59 return 0;
60 }
59 61
60 /* smooth out the fanspeed increase/decrease */ 62 /* smooth out the fanspeed increase/decrease */
61 if (!immediate && duty >= 0) { 63 if (!immediate && duty >= 0) {
@@ -73,8 +75,15 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
73 75
74 nv_debug(therm, "FAN update: %d\n", duty); 76 nv_debug(therm, "FAN update: %d\n", duty);
75 ret = fan->set(therm, duty); 77 ret = fan->set(therm, duty);
76 if (ret) 78 if (ret) {
77 goto done; 79 spin_unlock_irqrestore(&fan->lock, flags);
80 return ret;
81 }
82
83 /* fan speed updated, drop the fan lock before grabbing the
84 * alarm-scheduling lock and risking a deadlock
85 */
86 spin_unlock_irqrestore(&fan->lock, flags);
78 87
79 /* schedule next fan update, if not at target speed already */ 88 /* schedule next fan update, if not at target speed already */
80 if (list_empty(&fan->alarm.head) && target != duty) { 89 if (list_empty(&fan->alarm.head) && target != duty) {
@@ -92,8 +101,6 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
92 ptimer->alarm(ptimer, delay * 1000 * 1000, &fan->alarm); 101 ptimer->alarm(ptimer, delay * 1000 * 1000, &fan->alarm);
93 } 102 }
94 103
95done:
96 spin_unlock_irqrestore(&fan->lock, flags);
97 return ret; 104 return ret;
98} 105}
99 106