aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2017-06-05 03:23:32 -0400
committerBen Skeggs <bskeggs@redhat.com>2017-06-06 00:04:07 -0400
commitb4e382ca7586a63b6c1e5221ce0863ff867c2df6 (patch)
treee2410363af583b24d212c6f116a868ae6f718fea
parent8fa4338acca96cbc231e4125229632e879476464 (diff)
drm/nouveau/tmr: fully separate alarm execution/pending lists
Reusing the list_head for both is a bad idea. Callback execution is done with the lock dropped so that alarms can be rescheduled from the callback, which means that with some unfortunate timing, lists can get corrupted. The execution list should not require its own locking, the single function that uses it can only be called from a single context. Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Cc: stable@vger.kernel.org
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/subdev/timer.h1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/timer/base.c7
2 files changed, 5 insertions, 3 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/timer.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/timer.h
index 6a567fe347b3..820a4805916f 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/timer.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/timer.h
@@ -4,6 +4,7 @@
4 4
5struct nvkm_alarm { 5struct nvkm_alarm {
6 struct list_head head; 6 struct list_head head;
7 struct list_head exec;
7 u64 timestamp; 8 u64 timestamp;
8 void (*func)(struct nvkm_alarm *); 9 void (*func)(struct nvkm_alarm *);
9}; 10};
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/timer/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/timer/base.c
index f2a86eae0a0d..2437f7d41ca2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/timer/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/timer/base.c
@@ -50,7 +50,8 @@ nvkm_timer_alarm_trigger(struct nvkm_timer *tmr)
50 /* Move to completed list. We'll drop the lock before 50 /* Move to completed list. We'll drop the lock before
51 * executing the callback so it can reschedule itself. 51 * executing the callback so it can reschedule itself.
52 */ 52 */
53 list_move_tail(&alarm->head, &exec); 53 list_del_init(&alarm->head);
54 list_add(&alarm->exec, &exec);
54 } 55 }
55 56
56 /* Shut down interrupt if no more pending alarms. */ 57 /* Shut down interrupt if no more pending alarms. */
@@ -59,8 +60,8 @@ nvkm_timer_alarm_trigger(struct nvkm_timer *tmr)
59 spin_unlock_irqrestore(&tmr->lock, flags); 60 spin_unlock_irqrestore(&tmr->lock, flags);
60 61
61 /* Execute completed callbacks. */ 62 /* Execute completed callbacks. */
62 list_for_each_entry_safe(alarm, atemp, &exec, head) { 63 list_for_each_entry_safe(alarm, atemp, &exec, exec) {
63 list_del_init(&alarm->head); 64 list_del(&alarm->exec);
64 alarm->func(alarm); 65 alarm->func(alarm);
65 } 66 }
66} 67}