drm/nouveau: don't munge in drm_mm internals
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 18 Feb 2011 16:59:11 +0000 (17:59 +0100)
committerDave Airlie <airlied@redhat.com>
Wed, 23 Feb 2011 00:18:20 +0000 (10:18 +1000)
Nouveau was checking drm_mm internals on teardown to see whether the
memory manager was initialized. Hide these internals in a small
inline helper function.

Acked-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/nouveau/nouveau_object.c
drivers/gpu/drm/nouveau/nv50_instmem.c
drivers/gpu/drm/nouveau/nvc0_instmem.c
include/drm/drm_mm.h

index 30b6544467ca87032b014b0287497363eb6657b8..03adfe4c76653569a3a7aadcb72420cf3bd2464d 100644 (file)
@@ -909,7 +909,7 @@ nouveau_gpuobj_channel_takedown(struct nouveau_channel *chan)
        nouveau_vm_ref(NULL, &chan->vm, chan->vm_pd);
        nouveau_gpuobj_ref(NULL, &chan->vm_pd);
 
-       if (chan->ramin_heap.free_stack.next)
+       if (drm_mm_initialized(&chan->ramin_heap))
                drm_mm_takedown(&chan->ramin_heap);
        nouveau_gpuobj_ref(NULL, &chan->ramin);
 }
index ea0041810ae3a648959f533e3fbefcc17ca508d7..300285ae8e9e5e1ac9097e47ca6810abc490a9f8 100644 (file)
@@ -56,7 +56,7 @@ nv50_channel_del(struct nouveau_channel **pchan)
        nouveau_gpuobj_ref(NULL, &chan->ramfc);
        nouveau_vm_ref(NULL, &chan->vm, chan->vm_pd);
        nouveau_gpuobj_ref(NULL, &chan->vm_pd);
-       if (chan->ramin_heap.free_stack.next)
+       if (drm_mm_initialized(&chan->ramin_heap))
                drm_mm_takedown(&chan->ramin_heap);
        nouveau_gpuobj_ref(NULL, &chan->ramin);
        kfree(chan);
@@ -259,7 +259,7 @@ nv50_instmem_takedown(struct drm_device *dev)
        nouveau_gpuobj_ref(NULL, &dev_priv->bar3_vm->pgt[0].obj[0]);
        nouveau_vm_ref(NULL, &dev_priv->bar3_vm, NULL);
 
-       if (dev_priv->ramin_heap.free_stack.next)
+       if (drm_mm_initialized(&dev_priv->ramin_heap))
                drm_mm_takedown(&dev_priv->ramin_heap);
 
        dev_priv->engine.instmem.priv = NULL;
index c090917490543766bf75c0fc8f6ff9739608d646..82357d2df1f4c9f9f4c4a5a9eebf0f1e67cf8bbd 100644 (file)
@@ -67,7 +67,7 @@ nvc0_channel_del(struct nouveau_channel **pchan)
                return;
 
        nouveau_vm_ref(NULL, &chan->vm, NULL);
-       if (chan->ramin_heap.free_stack.next)
+       if (drm_mm_initialized(&chan->ramin_heap))
                drm_mm_takedown(&chan->ramin_heap);
        nouveau_gpuobj_ref(NULL, &chan->ramin);
        kfree(chan);
index e39177778601a983e6adff40775ae2cf77d3b2d4..0d791462f7b2234ddedb15957bc0673515e37cb4 100644 (file)
@@ -72,6 +72,11 @@ struct drm_mm {
        unsigned long scan_end;
 };
 
+static inline bool drm_mm_initialized(struct drm_mm *mm)
+{
+       return mm->free_stack.next;
+}
+
 /*
  * Basic range manager support (drm_mm.c)
  */