drm/radeon: only increment sync_seq when a fence is really emitted
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sat, 12 Dec 2015 16:42:25 +0000 (11:42 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 18 Dec 2015 22:29:49 +0000 (17:29 -0500)
In the rare situation where the kmalloc fails we're probably screwed anyway,
but let's try to be more robust about it.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Nicolai Hähnle <Nicolai.Haehnle@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_fence.c

index df09ca7c488949896f68ff1d78ad7e152f0fd9a5..05815c47b2464fee244efc8ebb1d56c3b4213cfc 100644 (file)
@@ -130,7 +130,7 @@ int radeon_fence_emit(struct radeon_device *rdev,
                      struct radeon_fence **fence,
                      int ring)
 {
-       u64 seq = ++rdev->fence_drv[ring].sync_seq[ring];
+       u64 seq;
 
        /* we are protected by the ring emission mutex */
        *fence = kmalloc(sizeof(struct radeon_fence), GFP_KERNEL);
@@ -138,7 +138,7 @@ int radeon_fence_emit(struct radeon_device *rdev,
                return -ENOMEM;
        }
        (*fence)->rdev = rdev;
-       (*fence)->seq = seq;
+       (*fence)->seq = seq = ++rdev->fence_drv[ring].sync_seq[ring];
        (*fence)->ring = ring;
        (*fence)->is_vm_update = false;
        fence_init(&(*fence)->base, &radeon_fence_ops,