drm/radeon: use central function for IB testing
authorChristian König <deathsimple@vodafone.de>
Wed, 2 May 2012 13:11:12 +0000 (15:11 +0200)
committerDave Airlie <airlied@redhat.com>
Thu, 3 May 2012 08:16:10 +0000 (09:16 +0100)
Removing all the different error messages and
having just one standard behaviour over all
chipset generations.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
14 files changed:
drivers/gpu/drm/radeon/evergreen.c
drivers/gpu/drm/radeon/ni.c
drivers/gpu/drm/radeon/r100.c
drivers/gpu/drm/radeon/r300.c
drivers/gpu/drm/radeon/r420.c
drivers/gpu/drm/radeon/r520.c
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_ring.c
drivers/gpu/drm/radeon/rs400.c
drivers/gpu/drm/radeon/rs600.c
drivers/gpu/drm/radeon/rs690.c
drivers/gpu/drm/radeon/rv515.c
drivers/gpu/drm/radeon/rv770.c

index eed7acefb492b90721b4155faf049590b742a7a7..8b7a01b8537421e3c551e590065f41cafa803ad6 100644 (file)
@@ -3376,12 +3376,9 @@ static int evergreen_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               DRM_ERROR("radeon: failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        r = r600_audio_init(rdev);
        if (r) {
index a48ca53fcd6ab80b270fe6a4f766f6b88a5a3605..01464289d32c45d7750b4f410cd2c9f20f8475bc 100644 (file)
@@ -1601,12 +1601,9 @@ static int cayman_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               DRM_ERROR("radeon: failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        r = radeon_vm_manager_start(rdev);
        if (r)
index a0b44a557bfd88be7537408fcb8846f8ed39f459..825f117744910e3c950f5a96dcf12a55ffcb711b 100644 (file)
@@ -3968,12 +3968,9 @@ static int r100_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        return 0;
 }
index a63f4324f0da1aa9b7bb74a3fae4fe460d3dfe38..26e0db87beb55c573c8f92e75cba6c5478628164 100644 (file)
@@ -1417,12 +1417,9 @@ static int r300_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        return 0;
 }
index f3fcaacfea01eb873583bf7728d5a8e27c5f1ec5..99137be7a3004253e15e11602a8b16eee585b342 100644 (file)
@@ -279,12 +279,9 @@ static int r420_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        return 0;
 }
index ebcc15b03c9f9223d738ec15cef74b64d699cc68..b5cf8375cd256aef8bd36cd4b60643facbdfb059 100644 (file)
@@ -207,12 +207,10 @@ static int r520_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
+
        return 0;
 }
 
index 222245d0138a073efe7f7c72425f3a6d0ebecd94..6070f9099507a90696b47ba873402dcd2c39e0c6 100644 (file)
@@ -2494,12 +2494,9 @@ int r600_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               DRM_ERROR("radeon: failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        return 0;
 }
index c76724be8b80f32270ec0940ca5f0717a75832d8..65855af290a6f827a75b94570607707b5d2d1aeb 100644 (file)
@@ -802,6 +802,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev);
 void radeon_ib_pool_fini(struct radeon_device *rdev);
 int radeon_ib_pool_start(struct radeon_device *rdev);
 int radeon_ib_pool_suspend(struct radeon_device *rdev);
+int radeon_ib_ring_tests(struct radeon_device *rdev);
 /* Ring access between begin & end cannot sleep */
 int radeon_ring_index(struct radeon_device *rdev, struct radeon_ring *cp);
 void radeon_ring_free_size(struct radeon_device *rdev, struct radeon_ring *cp);
index b6eb1d2a7679af1e58ac24316838b02733538339..1b020ef7fcdde58d56d984863e9c841c9ae11162 100644 (file)
@@ -267,6 +267,36 @@ int radeon_ib_pool_suspend(struct radeon_device *rdev)
        return radeon_sa_bo_manager_suspend(rdev, &rdev->ib_pool.sa_manager);
 }
 
+int radeon_ib_ring_tests(struct radeon_device *rdev)
+{
+       unsigned i;
+       int r;
+
+       for (i = 0; i < RADEON_NUM_RINGS; ++i) {
+               struct radeon_ring *ring = &rdev->ring[i];
+
+               if (!ring->ready)
+                       continue;
+
+               r = radeon_ib_test(rdev, i, ring);
+               if (r) {
+                       ring->ready = false;
+
+                       if (i == RADEON_RING_TYPE_GFX_INDEX) {
+                               /* oh, oh, that's really bad */
+                               DRM_ERROR("radeon: failed testing IB on GFX ring (%d).\n", r);
+                               rdev->accel_working = false;
+                               return r;
+
+                       } else {
+                               /* still not good, but we can live with it */
+                               DRM_ERROR("radeon: failed testing IB on ring %d (%d).\n", i, r);
+                       }
+               }
+       }
+       return 0;
+}
+
 /*
  * Ring.
  */
index 4cf381b3a6d81eee21fdc666d24001b4d75e34be..a464eb5e2df2c93306585579a5f5c60f43da10e0 100644 (file)
@@ -430,12 +430,9 @@ static int rs400_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        return 0;
 }
index 7fb3b1f2ed15e4d10dd1d3c8d9bf7bf99eb79137..25f9eef12c42a8caf6d05a0de3b37d5d6d6352a7 100644 (file)
@@ -918,12 +918,9 @@ static int rs600_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        return 0;
 }
index f2c3b9d75f188d0622a5cdb7c3ad697894546d70..3277ddecfe9fbd7755ba3c6bde888ebb7df68e36 100644 (file)
@@ -647,12 +647,9 @@ static int rs690_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        return 0;
 }
index d8d78fe179469009a4adbaebda77eee13fcd7802..7f08cedb533315f3c8102c8e1163141aede82068 100644 (file)
@@ -412,12 +412,10 @@ static int rv515_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
+
        return 0;
 }
 
index c62ae4be3845f02df5934304d3b90e7b8582588c..cacec0e20ae3457d0a6369d2a4854a0b828969cf 100644 (file)
@@ -1114,12 +1114,9 @@ static int rv770_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-       if (r) {
-               dev_err(rdev->dev, "IB test failed (%d).\n", r);
-               rdev->accel_working = false;
+       r = radeon_ib_ring_tests(rdev);
+       if (r)
                return r;
-       }
 
        return 0;
 }