drm: don't call the vblank tasklet with irqs disabled.
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Sun, 24 Aug 2008 07:00:00 +0000 (17:00 +1000)
committerDave Airlie <airlied@linux.ie>
Sun, 24 Aug 2008 20:35:21 +0000 (06:35 +1000)
If a specific tasklet shares data with irq context,
it needs to take a private irq-blocking spinlock within
the tasklet itself.

Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_irq.c
drivers/gpu/drm/drm_lock.c

index 089c015c01d148234fcd24abac9f935c9fd185ef..53f0e5af1cc82fd2379b8a48db2afe0ea8d60298 100644 (file)
@@ -400,27 +400,31 @@ static void drm_locked_tasklet_func(unsigned long data)
 {
        struct drm_device *dev = (struct drm_device *)data;
        unsigned long irqflags;
-
+       void (*tasklet_func)(struct drm_device *);
+       
        spin_lock_irqsave(&dev->tasklet_lock, irqflags);
+       tasklet_func = dev->locked_tasklet_func;
+       spin_unlock_irqrestore(&dev->tasklet_lock, irqflags);
 
-       if (!dev->locked_tasklet_func ||
+       if (!tasklet_func ||
            !drm_lock_take(&dev->lock,
                           DRM_KERNEL_CONTEXT)) {
-               spin_unlock_irqrestore(&dev->tasklet_lock, irqflags);
                return;
        }
 
        dev->lock.lock_time = jiffies;
        atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
 
-       dev->locked_tasklet_func(dev);
+       spin_lock_irqsave(&dev->tasklet_lock, irqflags);
+       tasklet_func = dev->locked_tasklet_func;
+       dev->locked_tasklet_func = NULL;
+       spin_unlock_irqrestore(&dev->tasklet_lock, irqflags);
+       
+       if (tasklet_func != NULL)
+               tasklet_func(dev);
 
        drm_lock_free(&dev->lock,
                      DRM_KERNEL_CONTEXT);
-
-       dev->locked_tasklet_func = NULL;
-
-       spin_unlock_irqrestore(&dev->tasklet_lock, irqflags);
 }
 
 /**
index 0998723cde7925b4c9988836b15ddd10e1566820..d78e0dc18245c3b67726006486829259fa1fb79c 100644 (file)
@@ -150,6 +150,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
 {
        struct drm_lock *lock = data;
        unsigned long irqflags;
+       void (*tasklet_func)(struct drm_device *);
 
        if (lock->context == DRM_KERNEL_CONTEXT) {
                DRM_ERROR("Process %d using kernel context %d\n",
@@ -158,14 +159,11 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
        }
 
        spin_lock_irqsave(&dev->tasklet_lock, irqflags);
-
-       if (dev->locked_tasklet_func) {
-               dev->locked_tasklet_func(dev);
-
-               dev->locked_tasklet_func = NULL;
-       }
-
+       tasklet_func = dev->locked_tasklet_func;
+       dev->locked_tasklet_func = NULL;
        spin_unlock_irqrestore(&dev->tasklet_lock, irqflags);
+       if (tasklet_func != NULL)
+               tasklet_func(dev);
 
        atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);