drm/radeon: improve ring lockup detection code
Subsystems (2)
PATCH 1/2 drm/radeon: improve ring lockup detection code
From: Christian König <[email protected]>
Use atomics and jiffies_64, so that we don't need to have the ring mutex locked any more and avoid wrap arounds.
--- drivers/gpu/drm/radeon/radeon.h | 4 ++-- drivers/gpu/drm/radeon/radeon_ring.c | 21 +++++++++------------ 2 files changed, 11 insertions(+), 14 deletions(-)
drivers/gpu/drm/radeon/radeon.h +2 -2
@@ -802,8 +802,8 @@ struct radeon_ring {unsigned ring_size;unsigned ring_free_dw;int count_dw; -unsigned long last_activity; -unsigned last_rptr; +atomic_t last_rptr; +atomic64_t last_activity;uint64_t gpu_addr;uint32_t align_mask;uint32_t ptr_mask;
drivers/gpu/drm/radeon/radeon_ring.c +9 -12
@@ -485,8 +485,8 @@ void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *rinvoid radeon_ring_lockup_update (struct radeon_device *rdev,struct radeon_ring *ring) { - ring->last_rptr =radeon_ring_get_rptr (rdev, ring); - ring->last_activity = jiffies; +atomic_set (&ring->last_rptr,radeon_ring_get_rptr (rdev, ring)); +atomic64_set (&ring->last_activity, jiffies_64); }/**
@@ -498,22 +498,19 @@ void radeon_ring_lockup_update(struct radeon_device *rdev,bool radeon_ring_test_lockup (struct radeon_device *rdev,struct radeon_ring *ring) {uint32_t rptr =radeon_ring_get_rptr (rdev, ring); -unsigned long cjiffies, elapsed; +uint64_t last =atomic64_read (&ring->last_activity); +uint64_t elapsed; - cjiffies = jiffies; -if (!time_after (cjiffies, ring->last_activity)) { -/* likely a wrap around */ -radeon_ring_lockup_update (rdev, ring); -return false; - } -if (rptr != ring->last_rptr) { +if (rptr !=atomic_read (&ring->last_rptr)) {/* CP is still working no lockup */ radeon_ring_lockup_update (rdev, ring);return false; } - elapsed =jiffies_to_msecs (cjiffies - ring->last_activity); + + elapsed =jiffies_to_msecs (jiffies_64 - last);if (radeon_lockup_timeout && elapsed >= radeon_lockup_timeout) { -dev_err (rdev->dev,"GPU lockup CP stall for more than %lumsec\n" , elapsed); +dev_err (rdev->dev,"GPU lockup ring %d stall for more " +"than %Lumsec\n" , ring->idx, elapsed);return true; }/* give a chance to the GPU ... */
Signature · 6 lines
1.8.3.2 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 drm/radeon: cleanup the fence ring locking code
From: Christian König <[email protected]>
We no longer need to take the ring lock while checking for a gpu lockup, so just cleanup the code.
--- drivers/gpu/drm/radeon/radeon.h | 5 ++- drivers/gpu/drm/radeon/radeon_device.c | 4 +-- drivers/gpu/drm/radeon/radeon_fence.c | 59 ++++++------------------------- drivers/gpu/drm/radeon/radeon_pm.c | 4 +-- drivers/gpu/drm/radeon/radeon_ring.c | 2 +- drivers/gpu/drm/radeon/radeon_semaphore.c | 12 +++++-- 6 files changed, 25 insertions(+), 61 deletions(-)
drivers/gpu/drm/radeon/radeon.h +2 -3
@@ -360,9 +360,8 @@ int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence **fence, ivoid radeon_fence_process (struct radeon_device *rdev,int ring);bool radeon_fence_signaled (struct radeon_fence *fence);int radeon_fence_wait (struct radeon_fence *fence,bool interruptible); -int radeon_fence_wait_locked (struct radeon_fence *fence); -int radeon_fence_wait_next_locked (struct radeon_device *rdev,int ring); -int radeon_fence_wait_empty_locked (struct radeon_device *rdev,int ring); +int radeon_fence_wait_next (struct radeon_device *rdev,int ring); +int radeon_fence_wait_empty (struct radeon_device *rdev,int ring);int radeon_fence_wait_any (struct radeon_device *rdev,struct radeon_fence **fences,bool intr);
drivers/gpu/drm/radeon/radeon_device.c +1 -3
@@ -1445,10 +1445,9 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)/* evict vram memory */ radeon_bo_evict_vram (rdev); -mutex_lock (&rdev->ring_lock);/* wait for gpu to finish processing current batch */ for (i =0 ; i <RADEON_NUM_RINGS ; i++) { - r =radeon_fence_wait_empty_locked (rdev, i); + r =radeon_fence_wait_empty (rdev, i);if (r) {/* delay GPU reset to resume */ force_completion = true;
@@ -1457,7 +1456,6 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)if (force_completion) {radeon_fence_driver_force_completion (rdev); } -mutex_unlock (&rdev->ring_lock);radeon_save_bios_scratch_regs (rdev);
drivers/gpu/drm/radeon/radeon_fence.c +10 -49
137 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_pm.c +2 -2
@@ -260,7 +260,7 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)if (!ring->ready) {continue ; } - r =radeon_fence_wait_empty_locked (rdev, i); + r =radeon_fence_wait_empty (rdev, i);if (r) {/* needs a GPU reset dont reset here */ mutex_unlock (&rdev->ring_lock);
@@ -896,7 +896,7 @@ force:for (i =0 ; i <RADEON_NUM_RINGS ; i++) {struct radeon_ring *ring = &rdev->ring[i];if (ring->ready) -radeon_fence_wait_empty_locked (rdev, i); +radeon_fence_wait_empty (rdev, i); }/* program the new power state */
drivers/gpu/drm/radeon/radeon_ring.c +1 -1
@@ -382,7 +382,7 @@ int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *ring, unsiif (ndw < ring->ring_free_dw) {break ; } - r =radeon_fence_wait_next_locked (rdev, ring->idx); + r =radeon_fence_wait_next (rdev, ring->idx);if (r)return r; }
drivers/gpu/drm/radeon/radeon_semaphore.c +9 -3
@@ -147,7 +147,9 @@ int radeon_semaphore_sync_rings(struct radeon_device *rdev,if (++count >RADEON_NUM_SYNCS ) {/* not enough room, wait manually */ -radeon_fence_wait_locked (fence); + r =radeon_fence_wait (fence, false); +if (r) +return r;continue ; }
@@ -161,7 +163,9 @@ int radeon_semaphore_sync_rings(struct radeon_device *rdev,if (!radeon_semaphore_emit_signal (rdev, i, semaphore)) {/* signaling wasn't successful wait manually */ radeon_ring_undo (&rdev->ring[i]); -radeon_fence_wait_locked (fence); + r =radeon_fence_wait (fence, false); +if (r) +return r;continue ; }
@@ -169,7 +173,9 @@ int radeon_semaphore_sync_rings(struct radeon_device *rdev,if (!radeon_semaphore_emit_wait (rdev, ring, semaphore)) {/* waiting wasn't successful wait manually */ radeon_ring_undo (&rdev->ring[i]); -radeon_fence_wait_locked (fence); + r =radeon_fence_wait (fence, false); +if (r) +return r;continue ; }
Signature · 6 lines
1.8.3.2 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Christian König
From: Christian König <[email protected]>
Use atomics and
jiffies_64, so that we don't need to have the ring mutex locked any more and avoid wrap arounds.Signed-off-by Christian König <[email protected]>
Series is:
Quoted 72 lines
--- drivers/gpu/drm/radeon/radeon.h | 4 ++-- drivers/gpu/drm/radeon/radeon_ring.c | 21 +++++++++------------ 2 files changed, 11 insertions(+), 14 deletions(-)drivers/gpu/drm/radeon/radeon.h +2
-2@@ -802,8 +802,8 @@ struct radeon_ring {unsigned ring_size;unsigned ring_free_dw;int count_dw; -unsigned long last_activity; -unsigned last_rptr; +atomic_t last_rptr; +atomic64_t last_activity;uint64_t gpu_addr;uint32_t align_mask;uint32_t ptr_mask;drivers/gpu/drm/radeon/radeon_ring.c +9
-13@@ -485,8 +485,8 @@ void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *rinvoid radeon_ring_lockup_update (struct radeon_device *rdev,struct radeon_ring *ring) { - ring->last_rptr =radeon_ring_get_rptr (rdev, ring); - ring->last_activity = jiffies; +atomic_set (&ring->last_rptr,radeon_ring_get_rptr (rdev, ring)); +atomic64_set (&ring->last_activity, jiffies_64); }/** @@ -498,22 +498,19 @@ void radeon_ring_lockup_update(struct radeon_device *rdev,bool radeon_ring_test_lockup (struct radeon_device *rdev,struct radeon_ring *ring) {uint32_t rptr =radeon_ring_get_rptr (rdev, ring); -unsigned long cjiffies, elapsed; +uint64_t last =atomic64_read (&ring->last_activity); +uint64_t elapsed; - cjiffies = jiffies; -if (!time_after (cjiffies, ring->last_activity)) { -/* likely a wrap around */ -radeon_ring_lockup_update (rdev, ring); -return false; - } -if (rptr != ring->last_rptr) { +if (rptr !=atomic_read (&ring->last_rptr)) {/* CP is still working no lockup */ radeon_ring_lockup_update (rdev, ring);return false; } - elapsed =jiffies_to_msecs (cjiffies - ring->last_activity); + + elapsed =jiffies_to_msecs (jiffies_64 - last);if (radeon_lockup_timeout && elapsed >= radeon_lockup_timeout) { -dev_err (rdev->dev,"GPU lockup CP stall for more than %lumsec\n" , elapsed); +dev_err (rdev->dev,"GPU lockup ring %d stall for more " +"than %Lumsec\n" , ring->idx, elapsed);return true; }/* give a chance to the GPU ... */ --1.8.3.2
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel