[PATCH 04/18] drm/radeon: hold ring emission mutex for lockup detection

j.glisse at gmail.com j.glisse at gmail.com
Fri May 4 15:43:45 PDT 2012


From: Christian König <deathsimple at vodafone.de>

We are locking the ring emission mutex anyway, so
there is no harm in doing it a bit earlier and
prevent multiple resets to happen at the same time.

Signed-off-by: Christian König <deathsimple at vodafone.de>
---
 drivers/gpu/drm/radeon/radeon_fence.c |   10 +++++-----
 drivers/gpu/drm/radeon/radeon_ring.c  |    2 --
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index 1610601..99c31b2 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -258,8 +258,11 @@ static int radeon_wait_seq(struct radeon_device *rdev, u64 target_seq,
 			if (seq != atomic64_read(&rdev->fence_drv[ring].last_seq)) {
 				continue;
 			}
+
+			mutex_lock(&rdev->ring_lock);
 			/* test if somebody else has already decided that this is a lockup */
 			if (last_activity != rdev->fence_drv[ring].last_activity) {
+				mutex_unlock(&rdev->ring_lock);
 				continue;
 			}
 
@@ -273,15 +276,12 @@ static int radeon_wait_seq(struct radeon_device *rdev, u64 target_seq,
 					rdev->fence_drv[i].last_activity = jiffies;
 				}
 
-				/* change last activity so nobody else think there is a lockup */
-				for (i = 0; i < RADEON_NUM_RINGS; ++i) {
-					rdev->fence_drv[i].last_activity = jiffies;
-				}
-
 				/* mark the ring as not ready any more */
 				rdev->ring[ring].ready = false;
+				mutex_unlock(&rdev->ring_lock);
 				return -EDEADLK;
 			}
+			mutex_unlock(&rdev->ring_lock);
 		}
 	}
 	return 0;
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 4ae222b..8b7f00e 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -408,7 +408,6 @@ void radeon_ring_force_activity(struct radeon_device *rdev, struct radeon_ring *
 {
 	int r;
 
-	mutex_lock(&rdev->ring_lock);
 	radeon_ring_free_size(rdev, ring);
 	if (ring->rptr == ring->wptr) {
 		r = radeon_ring_alloc(rdev, ring, 1);
@@ -417,7 +416,6 @@ void radeon_ring_force_activity(struct radeon_device *rdev, struct radeon_ring *
 			radeon_ring_commit(rdev, ring);
 		}
 	}
-	mutex_unlock(&rdev->ring_lock);
 }
 
 void radeon_ring_lockup_update(struct radeon_ring *ring)
-- 
1.7.7.6



More information about the dri-devel mailing list