drm/radeon: make forcing ring activity a common function
authorChristian König <deathsimple@vodafone.de>
Wed, 2 May 2012 13:11:23 +0000 (15:11 +0200)
committerDave Airlie <airlied@redhat.com>
Thu, 3 May 2012 08:16:38 +0000 (09:16 +0100)
Nothing chipset or ring specific with it,
so also move it to radon_ring.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
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/r600.c
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_ring.c
drivers/gpu/drm/radeon/si.c

index 66f05bba8a420d9c4845030da0d008afcb271bef..ecc29bc1cbe3efaa890837816fe033e799e192c8 100644 (file)
@@ -2424,7 +2424,6 @@ bool evergreen_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *rin
        u32 srbm_status;
        u32 grbm_status;
        u32 grbm_status_se0, grbm_status_se1;
-       int r;
 
        srbm_status = RREG32(SRBM_STATUS);
        grbm_status = RREG32(GRBM_STATUS);
@@ -2435,14 +2434,7 @@ bool evergreen_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *rin
                return false;
        }
        /* force CP activities */
-       r = radeon_ring_lock(rdev, ring, 2);
-       if (!r) {
-               /* PACKET2 NOP */
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_unlock_commit(rdev, ring);
-       }
-       ring->rptr = RREG32(CP_RB_RPTR);
+       radeon_ring_force_activity(rdev, ring);
        return radeon_ring_test_lockup(rdev, ring);
 }
 
index 8404b2a2386d930771f3b97b36ffa58bac23f3d4..118463503e80bc823ad891d2d820c5f032cc9f62 100644 (file)
@@ -1397,7 +1397,6 @@ bool cayman_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
        u32 srbm_status;
        u32 grbm_status;
        u32 grbm_status_se0, grbm_status_se1;
-       int r;
 
        srbm_status = RREG32(SRBM_STATUS);
        grbm_status = RREG32(GRBM_STATUS);
@@ -1408,15 +1407,7 @@ bool cayman_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
                return false;
        }
        /* force CP activities */
-       r = radeon_ring_lock(rdev, ring, 2);
-       if (!r) {
-               /* PACKET2 NOP */
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_unlock_commit(rdev, ring);
-       }
-       /* XXX deal with CP0,1,2 */
-       ring->rptr = RREG32(ring->rptr_reg);
+       radeon_ring_force_activity(rdev, ring);
        return radeon_ring_test_lockup(rdev, ring);
 }
 
index ccf5e3b844d3f028ba21da719f1528494253b606..42d60abf2ebee0a5361b262d96b0c5530a8bfb5e 100644 (file)
@@ -2162,7 +2162,6 @@ int r100_mc_wait_for_idle(struct radeon_device *rdev)
 bool r100_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
 {
        u32 rbbm_status;
-       int r;
 
        rbbm_status = RREG32(R_000E40_RBBM_STATUS);
        if (!G_000E40_GUI_ACTIVE(rbbm_status)) {
@@ -2170,14 +2169,7 @@ bool r100_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
                return false;
        }
        /* force CP activities */
-       r = radeon_ring_lock(rdev, ring, 2);
-       if (!r) {
-               /* PACKET2 NOP */
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_unlock_commit(rdev, ring);
-       }
-       ring->rptr = RREG32(ring->rptr_reg);
+       radeon_ring_force_activity(rdev, ring);
        return radeon_ring_test_lockup(rdev, ring);
 }
 
index e207664bbdc794751046ece48aa2247b19aed7d3..04ec26916db48dea00282420ae8b73011d65b6eb 100644 (file)
@@ -380,7 +380,6 @@ void r300_gpu_init(struct radeon_device *rdev)
 bool r300_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
 {
        u32 rbbm_status;
-       int r;
 
        rbbm_status = RREG32(R_000E40_RBBM_STATUS);
        if (!G_000E40_GUI_ACTIVE(rbbm_status)) {
@@ -388,14 +387,7 @@ bool r300_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
                return false;
        }
        /* force CP activities */
-       r = radeon_ring_lock(rdev, ring, 2);
-       if (!r) {
-               /* PACKET2 NOP */
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_unlock_commit(rdev, ring);
-       }
-       ring->rptr = RREG32(RADEON_CP_RB_RPTR);
+       radeon_ring_force_activity(rdev, ring);
        return radeon_ring_test_lockup(rdev, ring);
 }
 
index 45d52ccc457a683662174c528ce51a4fca928597..87a2333c0c6b10ede2ee0842f8193c216e91b43e 100644 (file)
@@ -1350,7 +1350,6 @@ bool r600_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
        u32 srbm_status;
        u32 grbm_status;
        u32 grbm_status2;
-       int r;
 
        srbm_status = RREG32(R_000E50_SRBM_STATUS);
        grbm_status = RREG32(R_008010_GRBM_STATUS);
@@ -1360,14 +1359,7 @@ bool r600_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
                return false;
        }
        /* force CP activities */
-       r = radeon_ring_lock(rdev, ring, 2);
-       if (!r) {
-               /* PACKET2 NOP */
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_unlock_commit(rdev, ring);
-       }
-       ring->rptr = RREG32(ring->rptr_reg);
+       radeon_ring_force_activity(rdev, ring);
        return radeon_ring_test_lockup(rdev, ring);
 }
 
index 0784e4d57d28677bc87280ac0bcfab7af11a9fd7..82ffa6a05cc6760215919ce4cb98b18c891e258a 100644 (file)
@@ -817,6 +817,7 @@ void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *cp);
 void radeon_ring_unlock_commit(struct radeon_device *rdev, struct radeon_ring *cp);
 void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *cp);
 int radeon_ring_test(struct radeon_device *rdev, struct radeon_ring *cp);
+void radeon_ring_force_activity(struct radeon_device *rdev, struct radeon_ring *ring);
 void radeon_ring_lockup_update(struct radeon_ring *ring);
 bool radeon_ring_test_lockup(struct radeon_device *rdev, struct radeon_ring *ring);
 int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ring_size,
index 407d90aaa0c361a524eabac96cb62d51e40f1c5b..2eb4c6ed198aa7f82007c33db841c03f9396010d 100644 (file)
@@ -398,6 +398,22 @@ void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *rin
        mutex_unlock(&ring->mutex);
 }
 
+void radeon_ring_force_activity(struct radeon_device *rdev, struct radeon_ring *ring)
+{
+       int r;
+
+       mutex_lock(&ring->mutex);
+       radeon_ring_free_size(rdev, ring);
+       if (ring->rptr == ring->wptr) {
+               r = radeon_ring_alloc(rdev, ring, 1);
+               if (!r) {
+                       radeon_ring_write(ring, ring->nop);
+                       radeon_ring_commit(rdev, ring);
+               }
+       }
+       mutex_unlock(&ring->mutex);
+}
+
 void radeon_ring_lockup_update(struct radeon_ring *ring)
 {
        ring->last_rptr = ring->rptr;
index c2422f51420204111c2a9bd3f0e6de42c1787104..0bad5ff651d5b867bc0a0a3a07deafb98df7cabb 100644 (file)
@@ -2217,7 +2217,6 @@ bool si_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
        u32 srbm_status;
        u32 grbm_status, grbm_status2;
        u32 grbm_status_se0, grbm_status_se1;
-       int r;
 
        srbm_status = RREG32(SRBM_STATUS);
        grbm_status = RREG32(GRBM_STATUS);
@@ -2229,15 +2228,7 @@ bool si_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
                return false;
        }
        /* force CP activities */
-       r = radeon_ring_lock(rdev, ring, 2);
-       if (!r) {
-               /* PACKET2 NOP */
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_write(ring, 0x80000000);
-               radeon_ring_unlock_commit(rdev, ring);
-       }
-       /* XXX deal with CP0,1,2 */
-       ring->rptr = RREG32(ring->rptr_reg);
+       radeon_ring_force_activity(rdev, ring);
        return radeon_ring_test_lockup(rdev, ring);
 }