Skip to content

Commit 5dffc1b

Browse files
Ben Skeggsgregkh
authored andcommitted
drm/nouveau/tmr: fully separate alarm execution/pending lists
commit b4e382ca7586a63b6c1e5221ce0863ff867c2df6 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: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7427686 commit 5dffc1b

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

  • drivers/gpu/drm/nouveau

drivers/gpu/drm/nouveau/include/nvkm/subdev/timer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
struct nvkm_alarm {
66
struct list_head head;
7+
struct list_head exec;
78
u64 timestamp;
89
void (*func)(struct nvkm_alarm *);
910
};

drivers/gpu/drm/nouveau/nvkm/subdev/timer/base.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ nvkm_timer_alarm_trigger(struct nvkm_timer *tmr)
5050
/* Move to completed list. We'll drop the lock before
5151
* executing the callback so it can reschedule itself.
5252
*/
53-
list_move_tail(&alarm->head, &exec);
53+
list_del_init(&alarm->head);
54+
list_add(&alarm->exec, &exec);
5455
}
5556

5657
/* Shut down interrupt if no more pending alarms. */
@@ -59,8 +60,8 @@ nvkm_timer_alarm_trigger(struct nvkm_timer *tmr)
5960
spin_unlock_irqrestore(&tmr->lock, flags);
6061

6162
/* Execute completed callbacks. */
62-
list_for_each_entry_safe(alarm, atemp, &exec, head) {
63-
list_del_init(&alarm->head);
63+
list_for_each_entry_safe(alarm, atemp, &exec, exec) {
64+
list_del(&alarm->exec);
6465
alarm->func(alarm);
6566
}
6667
}

0 commit comments

Comments
 (0)