aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2010-04-28 12:13:06 -0400
committerDave Airlie <airlied@redhat.com>2010-05-18 04:21:29 -0400
commitf81f202402640c27b38e1452dcb4d3e447043f48 (patch)
tree7f081e491e256d792c7b9c5e9df817894227fe05 /drivers/gpu
parent612e06ce9c78840c3a1a207dfbe489a059d87c28 (diff)
radeon: Try harder to ensure we reclock in vblank
The vblank interrupt on r600 doesn't seem to be especially reliable, so perform some sanity checks before the actual reclock. Signed-off-by: Matthew Garrett <mjg@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/radeon/r500_reg.h2
-rw-r--r--drivers/gpu/drm/radeon/r600.c26
-rw-r--r--drivers/gpu/drm/radeon/radeon.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c11
4 files changed, 39 insertions, 1 deletions
diff --git a/drivers/gpu/drm/radeon/r500_reg.h b/drivers/gpu/drm/radeon/r500_reg.h
index f5adf42a9d15..93c9a2bbccf8 100644
--- a/drivers/gpu/drm/radeon/r500_reg.h
+++ b/drivers/gpu/drm/radeon/r500_reg.h
@@ -351,6 +351,7 @@
351#define AVIVO_D1CRTC_BLANK_CONTROL 0x6084 351#define AVIVO_D1CRTC_BLANK_CONTROL 0x6084
352#define AVIVO_D1CRTC_INTERLACE_CONTROL 0x6088 352#define AVIVO_D1CRTC_INTERLACE_CONTROL 0x6088
353#define AVIVO_D1CRTC_INTERLACE_STATUS 0x608c 353#define AVIVO_D1CRTC_INTERLACE_STATUS 0x608c
354#define AVIVO_D1CRTC_STATUS_POSITION 0x60a0
354#define AVIVO_D1CRTC_FRAME_COUNT 0x60a4 355#define AVIVO_D1CRTC_FRAME_COUNT 0x60a4
355#define AVIVO_D1CRTC_STEREO_CONTROL 0x60c4 356#define AVIVO_D1CRTC_STEREO_CONTROL 0x60c4
356 357
@@ -489,6 +490,7 @@
489#define AVIVO_D2CRTC_BLANK_CONTROL 0x6884 490#define AVIVO_D2CRTC_BLANK_CONTROL 0x6884
490#define AVIVO_D2CRTC_INTERLACE_CONTROL 0x6888 491#define AVIVO_D2CRTC_INTERLACE_CONTROL 0x6888
491#define AVIVO_D2CRTC_INTERLACE_STATUS 0x688c 492#define AVIVO_D2CRTC_INTERLACE_STATUS 0x688c
493#define AVIVO_D2CRTC_STATUS_POSITION 0x68a0
492#define AVIVO_D2CRTC_FRAME_COUNT 0x68a4 494#define AVIVO_D2CRTC_FRAME_COUNT 0x68a4
493#define AVIVO_D2CRTC_STEREO_CONTROL 0x68c4 495#define AVIVO_D2CRTC_STEREO_CONTROL 0x68c4
494 496
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 1696cc277d8b..d3a79e0a9125 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -289,8 +289,34 @@ void r600_set_power_state(struct radeon_device *rdev, bool static_switch)
289 } 289 }
290 290
291 } else { 291 } else {
292 u32 position;
293 u32 vbl;
294
292 radeon_sync_with_vblank(rdev); 295 radeon_sync_with_vblank(rdev);
293 296
297 if (!radeon_pm_in_vbl(rdev))
298 return;
299
300 if (rdev->pm.active_crtcs & (1 << 0)) {
301 vbl = RREG32(AVIVO_D1CRTC_V_BLANK_START_END);
302 position = RREG32(AVIVO_D1CRTC_STATUS_POSITION);
303 position &= 0xfff;
304 vbl &= 0xfff;
305
306 if (position < vbl && position > 1)
307 return;
308 }
309
310 if (rdev->pm.active_crtcs & (1 << 1)) {
311 vbl = RREG32(AVIVO_D2CRTC_V_BLANK_START_END);
312 position = RREG32(AVIVO_D2CRTC_STATUS_POSITION);
313 position &= 0xfff;
314 vbl &= 0xfff;
315
316 if (position < vbl && position > 1)
317 return;
318 }
319
294 if (sclk != rdev->pm.current_sclk) { 320 if (sclk != rdev->pm.current_sclk) {
295 radeon_pm_debug_check_in_vbl(rdev, false); 321 radeon_pm_debug_check_in_vbl(rdev, false);
296 radeon_set_engine_clock(rdev, sclk); 322 radeon_set_engine_clock(rdev, sclk);
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index bed84b316bba..93ac88eb6b3a 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -175,6 +175,7 @@ void radeon_pm_fini(struct radeon_device *rdev);
175void radeon_pm_compute_clocks(struct radeon_device *rdev); 175void radeon_pm_compute_clocks(struct radeon_device *rdev);
176void radeon_combios_get_power_modes(struct radeon_device *rdev); 176void radeon_combios_get_power_modes(struct radeon_device *rdev);
177void radeon_atombios_get_power_modes(struct radeon_device *rdev); 177void radeon_atombios_get_power_modes(struct radeon_device *rdev);
178bool radeon_pm_in_vbl(struct radeon_device *rdev);
178bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish); 179bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish);
179void radeon_sync_with_vblank(struct radeon_device *rdev); 180void radeon_sync_with_vblank(struct radeon_device *rdev);
180 181
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 134b19537d11..88163e043fcf 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -387,7 +387,7 @@ void radeon_pm_compute_clocks(struct radeon_device *rdev)
387 mutex_unlock(&rdev->pm.mutex); 387 mutex_unlock(&rdev->pm.mutex);
388} 388}
389 389
390bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish) 390bool radeon_pm_in_vbl(struct radeon_device *rdev)
391{ 391{
392 u32 stat_crtc = 0; 392 u32 stat_crtc = 0;
393 bool in_vbl = true; 393 bool in_vbl = true;
@@ -446,6 +446,15 @@ bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish)
446 in_vbl = false; 446 in_vbl = false;
447 } 447 }
448 } 448 }
449
450 return in_vbl;
451}
452
453bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish)
454{
455 u32 stat_crtc = 0;
456 bool in_vbl = radeon_pm_in_vbl(rdev);
457
449 if (in_vbl == false) 458 if (in_vbl == false)
450 DRM_INFO("not in vbl for pm change %08x at %s\n", stat_crtc, 459 DRM_INFO("not in vbl for pm change %08x at %s\n", stat_crtc,
451 finish ? "exit" : "entry"); 460 finish ? "exit" : "entry");