drm/nouveau: Make fences take a weak channel reference.
authorFrancisco Jerez <currojerez@riseup.net>
Mon, 18 Oct 2010 01:56:14 +0000 (03:56 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 3 Dec 2010 05:06:43 +0000 (15:06 +1000)
Fences didn't increment the channel reference count, and the fenced
channel could go away at any time. Fixes a potential race in
nouveau_fence_update().

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_fence.c

index 0a22955..e1ae9ba 100644 (file)
@@ -64,6 +64,7 @@ nouveau_fence_del(struct kref *ref)
        struct nouveau_fence *fence =
                container_of(ref, struct nouveau_fence, refcount);
 
+       nouveau_channel_ref(NULL, &fence->channel);
        kfree(fence);
 }
 
@@ -113,7 +114,7 @@ nouveau_fence_new(struct nouveau_channel *chan, struct nouveau_fence **pfence,
        if (!fence)
                return -ENOMEM;
        kref_init(&fence->refcount);
-       fence->channel = chan;
+       nouveau_channel_ref(chan, &fence->channel);
 
        if (emit)
                ret = nouveau_fence_emit(fence);