Commit a8282f01 authored by Ben Skeggs's avatar Ben Skeggs Committed by Greg Kroah-Hartman

drm/nouveau/tmr: fully separate alarm execution/pending lists

commit b4e382ca upstream.

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: default avatarBen Skeggs <bskeggs@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a7e7ade1
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
struct nvkm_alarm { struct nvkm_alarm {
struct list_head head; struct list_head head;
struct list_head exec;
u64 timestamp; u64 timestamp;
void (*func)(struct nvkm_alarm *); void (*func)(struct nvkm_alarm *);
}; };
......
...@@ -50,7 +50,8 @@ nvkm_timer_alarm_trigger(struct nvkm_timer *tmr) ...@@ -50,7 +50,8 @@ nvkm_timer_alarm_trigger(struct nvkm_timer *tmr)
/* Move to completed list. We'll drop the lock before /* Move to completed list. We'll drop the lock before
* executing the callback so it can reschedule itself. * executing the callback so it can reschedule itself.
*/ */
list_move_tail(&alarm->head, &exec); list_del_init(&alarm->head);
list_add(&alarm->exec, &exec);
} }
/* Shut down interrupt if no more pending alarms. */ /* Shut down interrupt if no more pending alarms. */
...@@ -59,8 +60,8 @@ nvkm_timer_alarm_trigger(struct nvkm_timer *tmr) ...@@ -59,8 +60,8 @@ nvkm_timer_alarm_trigger(struct nvkm_timer *tmr)
spin_unlock_irqrestore(&tmr->lock, flags); spin_unlock_irqrestore(&tmr->lock, flags);
/* Execute completed callbacks. */ /* Execute completed callbacks. */
list_for_each_entry_safe(alarm, atemp, &exec, head) { list_for_each_entry_safe(alarm, atemp, &exec, exec) {
list_del_init(&alarm->head); list_del(&alarm->exec);
alarm->func(alarm); alarm->func(alarm);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment