drm/amdgpu: use kernel fence in amdgpu_test
authorChunming Zhou <david1.zhou@amd.com>
Mon, 3 Aug 2015 08:19:29 +0000 (16:19 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 17 Aug 2015 20:50:53 +0000 (16:50 -0400)
Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Christian K?nig <christian.koenig@amd.com>
Reviewed-by: Jammy Zhou <jammy.zhou@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c

index 251b1ebef72240523ff06174f2c2b82a956aa639..afb57de1652187cc8905ecae89aa59e3314add45 100644 (file)
@@ -238,49 +238,47 @@ void amdgpu_test_moves(struct amdgpu_device *adev)
 
 static int amdgpu_test_create_and_emit_fence(struct amdgpu_device *adev,
                                             struct amdgpu_ring *ring,
-                                            struct amdgpu_fence **fence)
+                                            struct fence **fence)
 {
        uint32_t handle = ring->idx ^ 0xdeafbeef;
        int r;
 
        if (ring == &adev->uvd.ring) {
-               struct fence *f = NULL;
                r = amdgpu_uvd_get_create_msg(ring, handle, NULL);
                if (r) {
                        DRM_ERROR("Failed to get dummy create msg\n");
                        return r;
                }
 
-               r = amdgpu_uvd_get_destroy_msg(ring, handle, &f);
+               r = amdgpu_uvd_get_destroy_msg(ring, handle, fence);
                if (r) {
                        DRM_ERROR("Failed to get dummy destroy msg\n");
                        return r;
                }
-               *fence = to_amdgpu_fence(f);
 
        } else if (ring == &adev->vce.ring[0] ||
                   ring == &adev->vce.ring[1]) {
-               struct fence *f = NULL;
                r = amdgpu_vce_get_create_msg(ring, handle, NULL);
                if (r) {
                        DRM_ERROR("Failed to get dummy create msg\n");
                        return r;
                }
 
-               r = amdgpu_vce_get_destroy_msg(ring, handle, &f);
+               r = amdgpu_vce_get_destroy_msg(ring, handle, fence);
                if (r) {
                        DRM_ERROR("Failed to get dummy destroy msg\n");
                        return r;
                }
-               *fence = to_amdgpu_fence(f);
        } else {
+               struct amdgpu_fence *a_fence = NULL;
                r = amdgpu_ring_lock(ring, 64);
                if (r) {
                        DRM_ERROR("Failed to lock ring A %d\n", ring->idx);
                        return r;
                }
-               amdgpu_fence_emit(ring, AMDGPU_FENCE_OWNER_UNDEFINED, fence);
+               amdgpu_fence_emit(ring, AMDGPU_FENCE_OWNER_UNDEFINED, &a_fence);
                amdgpu_ring_unlock_commit(ring);
+               *fence = &a_fence->base;
        }
        return 0;
 }
@@ -289,7 +287,7 @@ void amdgpu_test_ring_sync(struct amdgpu_device *adev,
                           struct amdgpu_ring *ringA,
                           struct amdgpu_ring *ringB)
 {
-       struct amdgpu_fence *fence1 = NULL, *fence2 = NULL;
+       struct fence *fence1 = NULL, *fence2 = NULL;
        struct amdgpu_semaphore *semaphore = NULL;
        int r;
 
@@ -325,7 +323,7 @@ void amdgpu_test_ring_sync(struct amdgpu_device *adev,
 
        mdelay(1000);
 
-       if (amdgpu_fence_signaled(fence1)) {
+       if (fence_is_signaled(fence1)) {
                DRM_ERROR("Fence 1 signaled without waiting for semaphore.\n");
                goto out_cleanup;
        }
@@ -338,7 +336,7 @@ void amdgpu_test_ring_sync(struct amdgpu_device *adev,
        amdgpu_semaphore_emit_signal(ringB, semaphore);
        amdgpu_ring_unlock_commit(ringB);
 
-       r = amdgpu_fence_wait(fence1, false);
+       r = fence_wait(fence1, false);
        if (r) {
                DRM_ERROR("Failed to wait for sync fence 1\n");
                goto out_cleanup;
@@ -346,7 +344,7 @@ void amdgpu_test_ring_sync(struct amdgpu_device *adev,
 
        mdelay(1000);
 
-       if (amdgpu_fence_signaled(fence2)) {
+       if (fence_is_signaled(fence2)) {
                DRM_ERROR("Fence 2 signaled without waiting for semaphore.\n");
                goto out_cleanup;
        }
@@ -359,7 +357,7 @@ void amdgpu_test_ring_sync(struct amdgpu_device *adev,
        amdgpu_semaphore_emit_signal(ringB, semaphore);
        amdgpu_ring_unlock_commit(ringB);
 
-       r = amdgpu_fence_wait(fence2, false);
+       r = fence_wait(fence2, false);
        if (r) {
                DRM_ERROR("Failed to wait for sync fence 1\n");
                goto out_cleanup;
@@ -369,10 +367,10 @@ out_cleanup:
        amdgpu_semaphore_free(adev, &semaphore, NULL);
 
        if (fence1)
-               amdgpu_fence_unref(&fence1);
+               fence_put(fence1);
 
        if (fence2)
-               amdgpu_fence_unref(&fence2);
+               fence_put(fence2);
 
        if (r)
                printk(KERN_WARNING "Error while testing ring sync (%d).\n", r);
@@ -383,7 +381,7 @@ static void amdgpu_test_ring_sync2(struct amdgpu_device *adev,
                            struct amdgpu_ring *ringB,
                            struct amdgpu_ring *ringC)
 {
-       struct amdgpu_fence *fenceA = NULL, *fenceB = NULL;
+       struct fence *fenceA = NULL, *fenceB = NULL;
        struct amdgpu_semaphore *semaphore = NULL;
        bool sigA, sigB;
        int i, r;
@@ -419,11 +417,11 @@ static void amdgpu_test_ring_sync2(struct amdgpu_device *adev,
 
        mdelay(1000);
 
-       if (amdgpu_fence_signaled(fenceA)) {
+       if (fence_is_signaled(fenceA)) {
                DRM_ERROR("Fence A signaled without waiting for semaphore.\n");
                goto out_cleanup;
        }
-       if (amdgpu_fence_signaled(fenceB)) {
+       if (fence_is_signaled(fenceB)) {
                DRM_ERROR("Fence B signaled without waiting for semaphore.\n");
                goto out_cleanup;
        }
@@ -438,8 +436,8 @@ static void amdgpu_test_ring_sync2(struct amdgpu_device *adev,
 
        for (i = 0; i < 30; ++i) {
                mdelay(100);
-               sigA = amdgpu_fence_signaled(fenceA);
-               sigB = amdgpu_fence_signaled(fenceB);
+               sigA = fence_is_signaled(fenceA);
+               sigB = fence_is_signaled(fenceB);
                if (sigA || sigB)
                        break;
        }
@@ -464,12 +462,12 @@ static void amdgpu_test_ring_sync2(struct amdgpu_device *adev,
 
        mdelay(1000);
 
-       r = amdgpu_fence_wait(fenceA, false);
+       r = fence_wait(fenceA, false);
        if (r) {
                DRM_ERROR("Failed to wait for sync fence A\n");
                goto out_cleanup;
        }
-       r = amdgpu_fence_wait(fenceB, false);
+       r = fence_wait(fenceB, false);
        if (r) {
                DRM_ERROR("Failed to wait for sync fence B\n");
                goto out_cleanup;
@@ -479,10 +477,10 @@ out_cleanup:
        amdgpu_semaphore_free(adev, &semaphore, NULL);
 
        if (fenceA)
-               amdgpu_fence_unref(&fenceA);
+               fence_put(fenceA);
 
        if (fenceB)
-               amdgpu_fence_unref(&fenceB);
+               fence_put(fenceB);
 
        if (r)
                printk(KERN_WARNING "Error while testing ring sync (%d).\n", r);