drm/nouveau: allow nouveau_fence_ref() to be a noop
authorBen Skeggs <bskeggs@redhat.com>
Wed, 13 Nov 2013 00:23:46 +0000 (10:23 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 14 Nov 2013 04:55:06 +0000 (14:55 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_fence.c
drivers/gpu/drm/nouveau/nouveau_gem.c

index 949ab0cbc4aba904c9d692c15c998b19b9589a3c..129aceed407deec24d55634a03b76933bbf18910 100644 (file)
@@ -98,12 +98,7 @@ nv10_bo_put_tile_region(struct drm_device *dev, struct nouveau_drm_tile *tile,
 
        if (tile) {
                spin_lock(&drm->tile.lock);
-               if (fence) {
-                       /* Mark it as pending. */
-                       tile->fence = fence;
-                       nouveau_fence_ref(fence);
-               }
-
+               tile->fence = nouveau_fence_ref(fence);
                tile->used = false;
                spin_unlock(&drm->tile.lock);
        }
@@ -1462,14 +1457,12 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
 void
 nouveau_bo_fence(struct nouveau_bo *nvbo, struct nouveau_fence *fence)
 {
+       struct nouveau_fence *new_fence = nouveau_fence_ref(fence);
        struct nouveau_fence *old_fence = NULL;
 
-       if (likely(fence))
-               nouveau_fence_ref(fence);
-
        spin_lock(&nvbo->bo.bdev->fence_lock);
        old_fence = nvbo->bo.sync_obj;
-       nvbo->bo.sync_obj = fence;
+       nvbo->bo.sync_obj = new_fence;
        spin_unlock(&nvbo->bo.bdev->fence_lock);
 
        nouveau_fence_unref(&old_fence);
index 34b82711e7c810d96d624d7a7ec362c7f633e285..40cf52e6d6d21ffb818f70b2b01be3b5f5e02b95 100644 (file)
@@ -306,7 +306,8 @@ nouveau_fence_unref(struct nouveau_fence **pfence)
 struct nouveau_fence *
 nouveau_fence_ref(struct nouveau_fence *fence)
 {
-       kref_get(&fence->kref);
+       if (fence)
+               kref_get(&fence->kref);
        return fence;
 }
 
index 418a6177a65330a5074a16565cce9a40784f3c01..c60f65a815d3e74b1c998b0bf24bee9d600c8390 100644 (file)
@@ -106,8 +106,7 @@ nouveau_gem_object_unmap(struct nouveau_bo *nvbo, struct nouveau_vma *vma)
 
        if (mapped) {
                spin_lock(&nvbo->bo.bdev->fence_lock);
-               if (nvbo->bo.sync_obj)
-                       fence = nouveau_fence_ref(nvbo->bo.sync_obj);
+               fence = nouveau_fence_ref(nvbo->bo.sync_obj);
                spin_unlock(&nvbo->bo.bdev->fence_lock);
        }
 
@@ -438,8 +437,7 @@ validate_sync(struct nouveau_channel *chan, struct nouveau_bo *nvbo)
        int ret = 0;
 
        spin_lock(&nvbo->bo.bdev->fence_lock);
-       if (nvbo->bo.sync_obj)
-               fence = nouveau_fence_ref(nvbo->bo.sync_obj);
+       fence = nouveau_fence_ref(nvbo->bo.sync_obj);
        spin_unlock(&nvbo->bo.bdev->fence_lock);
 
        if (fence) {