drm/nouveau/timer: allow alarms to be cancelled
authorBen Skeggs <bskeggs@redhat.com>
Thu, 25 Apr 2013 23:17:22 +0000 (09:17 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 26 Apr 2013 05:38:15 +0000 (15:38 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/core/subdev/timer/nv04.c

index 8e1bae4f12e89d9602a29ff5fb62da4e00b613f6..9469b8275675e3406f137f5cd7fa933178c6eabd 100644 (file)
@@ -96,11 +96,16 @@ nv04_timer_alarm(struct nouveau_timer *ptimer, u64 time,
 
        /* append new alarm to list, in soonest-alarm-first order */
        spin_lock_irqsave(&priv->lock, flags);
-       list_for_each_entry(list, &priv->alarms, head) {
-               if (list->timestamp > alarm->timestamp)
-                       break;
+       if (!time) {
+               if (!list_empty(&alarm->head))
+                       list_del(&alarm->head);
+       } else {
+               list_for_each_entry(list, &priv->alarms, head) {
+                       if (list->timestamp > alarm->timestamp)
+                               break;
+               }
+               list_add_tail(&alarm->head, &list->head);
        }
-       list_add_tail(&alarm->head, &list->head);
        spin_unlock_irqrestore(&priv->lock, flags);
 
        /* process pending alarms */