drm/sis: clean up reclaim_buffers
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 25 Oct 2011 21:42:59 +0000 (23:42 +0200)
committerDave Airlie <airlied@redhat.com>
Fri, 20 Jul 2012 02:49:17 +0000 (22:49 -0400)
Like for via.

v2: Actually drop the idlelock again if taken.

v3: Fixup.

v4: Fixup the "has master" vs. "is master" confusion the refactor
introduced.

v5: Drop the idlelock in the early return path.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/sis/sis_drv.c
drivers/gpu/drm/sis/sis_mm.c

index dd14cd1a0033e5a91d948c08a92e81772926674e..7f119870147c04cee307eaded5e6bf1abfba2bff 100644 (file)
@@ -105,10 +105,9 @@ static struct drm_driver driver = {
        .load = sis_driver_load,
        .unload = sis_driver_unload,
        .open = sis_driver_open,
+       .preclose = sis_reclaim_buffers_locked,
        .postclose = sis_driver_postclose,
        .dma_quiescent = sis_idle,
-       .reclaim_buffers = NULL,
-       .reclaim_buffers_idlelocked = sis_reclaim_buffers_locked,
        .lastclose = sis_lastclose,
        .ioctls = sis_ioctls,
        .fops = &sis_driver_fops,
index dd4a316c3d746b974c462294817b0321c1629af2..5acc396ef93cef85d337aee2207df32c425ec68c 100644 (file)
@@ -321,14 +321,20 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,
        struct sis_file_private *file_priv = file->driver_priv;
        struct sis_memblock *entry, *next;
 
+       if (!(file->minor->master && file->master->lock.hw_lock))
+               return;
+
+       drm_idlelock_take(&file->master->lock);
+
        mutex_lock(&dev->struct_mutex);
        if (list_empty(&file_priv->obj_list)) {
                mutex_unlock(&dev->struct_mutex);
+               drm_idlelock_release(&file->master->lock);
+
                return;
        }
 
-       if (dev->driver->dma_quiescent)
-               dev->driver->dma_quiescent(dev);
+       sis_idle(dev);
 
 
        list_for_each_entry_safe(entry, next, &file_priv->obj_list,
@@ -343,6 +349,9 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,
                kfree(entry);
        }
        mutex_unlock(&dev->struct_mutex);
+
+       drm_idlelock_release(&file->master->lock);
+
        return;
 }