diff options
Diffstat (limited to 'drivers/gpu/drm/radeon')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_device.c | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_fence.c | 30 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_pm.c | 15 |
4 files changed, 38 insertions, 22 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index aae73141d63a..9b9422c4403a 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -231,7 +231,7 @@ void radeon_fence_process(struct radeon_device *rdev, int ring); | |||
231 | bool radeon_fence_signaled(struct radeon_fence *fence); | 231 | bool radeon_fence_signaled(struct radeon_fence *fence); |
232 | int radeon_fence_wait(struct radeon_fence *fence, bool interruptible); | 232 | int radeon_fence_wait(struct radeon_fence *fence, bool interruptible); |
233 | int radeon_fence_wait_next_locked(struct radeon_device *rdev, int ring); | 233 | int radeon_fence_wait_next_locked(struct radeon_device *rdev, int ring); |
234 | void radeon_fence_wait_empty_locked(struct radeon_device *rdev, int ring); | 234 | int radeon_fence_wait_empty_locked(struct radeon_device *rdev, int ring); |
235 | int radeon_fence_wait_any(struct radeon_device *rdev, | 235 | int radeon_fence_wait_any(struct radeon_device *rdev, |
236 | struct radeon_fence **fences, | 236 | struct radeon_fence **fences, |
237 | bool intr); | 237 | bool intr); |
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index e81d6cab9959..a6617b53a9c6 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c | |||
@@ -1164,6 +1164,7 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state) | |||
1164 | struct drm_crtc *crtc; | 1164 | struct drm_crtc *crtc; |
1165 | struct drm_connector *connector; | 1165 | struct drm_connector *connector; |
1166 | int i, r; | 1166 | int i, r; |
1167 | bool force_completion = false; | ||
1167 | 1168 | ||
1168 | if (dev == NULL || dev->dev_private == NULL) { | 1169 | if (dev == NULL || dev->dev_private == NULL) { |
1169 | return -ENODEV; | 1170 | return -ENODEV; |
@@ -1206,8 +1207,16 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state) | |||
1206 | 1207 | ||
1207 | mutex_lock(&rdev->ring_lock); | 1208 | mutex_lock(&rdev->ring_lock); |
1208 | /* wait for gpu to finish processing current batch */ | 1209 | /* wait for gpu to finish processing current batch */ |
1209 | for (i = 0; i < RADEON_NUM_RINGS; i++) | 1210 | for (i = 0; i < RADEON_NUM_RINGS; i++) { |
1210 | radeon_fence_wait_empty_locked(rdev, i); | 1211 | r = radeon_fence_wait_empty_locked(rdev, i); |
1212 | if (r) { | ||
1213 | /* delay GPU reset to resume */ | ||
1214 | force_completion = true; | ||
1215 | } | ||
1216 | } | ||
1217 | if (force_completion) { | ||
1218 | radeon_fence_driver_force_completion(rdev); | ||
1219 | } | ||
1211 | mutex_unlock(&rdev->ring_lock); | 1220 | mutex_unlock(&rdev->ring_lock); |
1212 | 1221 | ||
1213 | radeon_save_bios_scratch_regs(rdev); | 1222 | radeon_save_bios_scratch_regs(rdev); |
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c index a9b0fa5608eb..34356252567a 100644 --- a/drivers/gpu/drm/radeon/radeon_fence.c +++ b/drivers/gpu/drm/radeon/radeon_fence.c | |||
@@ -609,26 +609,20 @@ int radeon_fence_wait_next_locked(struct radeon_device *rdev, int ring) | |||
609 | * Returns 0 if the fences have passed, error for all other cases. | 609 | * Returns 0 if the fences have passed, error for all other cases. |
610 | * Caller must hold ring lock. | 610 | * Caller must hold ring lock. |
611 | */ | 611 | */ |
612 | void radeon_fence_wait_empty_locked(struct radeon_device *rdev, int ring) | 612 | int radeon_fence_wait_empty_locked(struct radeon_device *rdev, int ring) |
613 | { | 613 | { |
614 | uint64_t seq = rdev->fence_drv[ring].sync_seq[ring]; | 614 | uint64_t seq = rdev->fence_drv[ring].sync_seq[ring]; |
615 | int r; | ||
615 | 616 | ||
616 | while(1) { | 617 | r = radeon_fence_wait_seq(rdev, seq, ring, false, false); |
617 | int r; | 618 | if (r) { |
618 | r = radeon_fence_wait_seq(rdev, seq, ring, false, false); | ||
619 | if (r == -EDEADLK) { | 619 | if (r == -EDEADLK) { |
620 | mutex_unlock(&rdev->ring_lock); | 620 | return -EDEADLK; |
621 | r = radeon_gpu_reset(rdev); | ||
622 | mutex_lock(&rdev->ring_lock); | ||
623 | if (!r) | ||
624 | continue; | ||
625 | } | ||
626 | if (r) { | ||
627 | dev_err(rdev->dev, "error waiting for ring to become" | ||
628 | " idle (%d)\n", r); | ||
629 | } | 621 | } |
630 | return; | 622 | dev_err(rdev->dev, "error waiting for ring[%d] to become idle (%d)\n", |
623 | ring, r); | ||
631 | } | 624 | } |
625 | return 0; | ||
632 | } | 626 | } |
633 | 627 | ||
634 | /** | 628 | /** |
@@ -854,13 +848,17 @@ int radeon_fence_driver_init(struct radeon_device *rdev) | |||
854 | */ | 848 | */ |
855 | void radeon_fence_driver_fini(struct radeon_device *rdev) | 849 | void radeon_fence_driver_fini(struct radeon_device *rdev) |
856 | { | 850 | { |
857 | int ring; | 851 | int ring, r; |
858 | 852 | ||
859 | mutex_lock(&rdev->ring_lock); | 853 | mutex_lock(&rdev->ring_lock); |
860 | for (ring = 0; ring < RADEON_NUM_RINGS; ring++) { | 854 | for (ring = 0; ring < RADEON_NUM_RINGS; ring++) { |
861 | if (!rdev->fence_drv[ring].initialized) | 855 | if (!rdev->fence_drv[ring].initialized) |
862 | continue; | 856 | continue; |
863 | radeon_fence_wait_empty_locked(rdev, ring); | 857 | r = radeon_fence_wait_empty_locked(rdev, ring); |
858 | if (r) { | ||
859 | /* no need to trigger GPU reset as we are unloading */ | ||
860 | radeon_fence_driver_force_completion(rdev); | ||
861 | } | ||
864 | wake_up_all(&rdev->fence_queue); | 862 | wake_up_all(&rdev->fence_queue); |
865 | radeon_scratch_free(rdev, rdev->fence_drv[ring].scratch_reg); | 863 | radeon_scratch_free(rdev, rdev->fence_drv[ring].scratch_reg); |
866 | rdev->fence_drv[ring].initialized = false; | 864 | rdev->fence_drv[ring].initialized = false; |
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index aa14dbb7e4fb..0bfa656aa87d 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c | |||
@@ -234,7 +234,7 @@ static void radeon_set_power_state(struct radeon_device *rdev) | |||
234 | 234 | ||
235 | static void radeon_pm_set_clocks(struct radeon_device *rdev) | 235 | static void radeon_pm_set_clocks(struct radeon_device *rdev) |
236 | { | 236 | { |
237 | int i; | 237 | int i, r; |
238 | 238 | ||
239 | /* no need to take locks, etc. if nothing's going to change */ | 239 | /* no need to take locks, etc. if nothing's going to change */ |
240 | if ((rdev->pm.requested_clock_mode_index == rdev->pm.current_clock_mode_index) && | 240 | if ((rdev->pm.requested_clock_mode_index == rdev->pm.current_clock_mode_index) && |
@@ -248,8 +248,17 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev) | |||
248 | /* wait for the rings to drain */ | 248 | /* wait for the rings to drain */ |
249 | for (i = 0; i < RADEON_NUM_RINGS; i++) { | 249 | for (i = 0; i < RADEON_NUM_RINGS; i++) { |
250 | struct radeon_ring *ring = &rdev->ring[i]; | 250 | struct radeon_ring *ring = &rdev->ring[i]; |
251 | if (ring->ready) | 251 | if (!ring->ready) { |
252 | radeon_fence_wait_empty_locked(rdev, i); | 252 | continue; |
253 | } | ||
254 | r = radeon_fence_wait_empty_locked(rdev, i); | ||
255 | if (r) { | ||
256 | /* needs a GPU reset dont reset here */ | ||
257 | mutex_unlock(&rdev->ring_lock); | ||
258 | up_write(&rdev->pm.mclk_lock); | ||
259 | mutex_unlock(&rdev->ddev->struct_mutex); | ||
260 | return; | ||
261 | } | ||
253 | } | 262 | } |
254 | 263 | ||
255 | radeon_unmap_vram_bos(rdev); | 264 | radeon_unmap_vram_bos(rdev); |