drm/savage: clean up reclaim_buffers
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 25 Oct 2011 22:14:15 +0000 (00:14 +0200)
committerDave Airlie <airlied@redhat.com>
Fri, 20 Jul 2012 02:50:16 +0000 (22:50 -0400)
The reclaim_buffers function of the savage driver actually wants to run
with the hw_lock held - at least there are printks in the call-chain
to that effect. But the drm core only calls reclaim_buffers as used
by savage _after_ forcefully dropping the hwlock (in case it's still
hold by the closing fd).

So do the same idlelock dance as for the other dma drivers and hope
that papers over any issues.

v2: Don't let the idlelock linger around.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Tested-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/savage/savage_bci.c
drivers/gpu/drm/savage/savage_drv.c

index 6eb507a5d13002ab6e14225c47aeae125f3c5427..1efbb90758378ad3a34d02c74e1eaacb36490933 100644 (file)
@@ -1050,6 +1050,7 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
 {
        struct drm_device_dma *dma = dev->dma;
        drm_savage_private_t *dev_priv = dev->dev_private;
+       int release_idlelock = 0;
        int i;
 
        if (!dma)
@@ -1059,7 +1060,10 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
        if (!dma->buflist)
                return;
 
-       /*i830_flush_queue(dev); */
+       if (file_priv->master && file_priv->master->lock.hw_lock) {
+               drm_idlelock_take(&file_priv->master->lock);
+               release_idlelock = 1;
+       }
 
        for (i = 0; i < dma->buf_count; i++) {
                struct drm_buf *buf = dma->buflist[i];
@@ -1075,7 +1079,8 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
                }
        }
 
-       drm_core_reclaim_buffers(dev, file_priv);
+       if (release_idlelock)
+               drm_idlelock_release(&file_priv->master->lock);
 }
 
 struct drm_ioctl_desc savage_ioctls[] = {
index 89afe0b83643282ced1abf4ed62660c510008423..d31d4cca9a4c7425609cf92d9e8fcb5a512cc4f0 100644 (file)
@@ -52,9 +52,9 @@ static struct drm_driver driver = {
        .dev_priv_size = sizeof(drm_savage_buf_priv_t),
        .load = savage_driver_load,
        .firstopen = savage_driver_firstopen,
+       .preclose = savage_reclaim_buffers,
        .lastclose = savage_driver_lastclose,
        .unload = savage_driver_unload,
-       .reclaim_buffers = savage_reclaim_buffers,
        .ioctls = savage_ioctls,
        .dma_ioctl = savage_bci_buffers,
        .fops = &savage_driver_fops,