Skip to contentSkip to conversation

drm/radeon/kms: pm debugging check for vbl.

RFC PATCH In review Dave Airlie 3 participants 7 messages Feb 18, 2010 – Feb 23, 2010

Subsystems (2)
lore
Share & tools
lore

Dave Airlie

author maintainer
#0 lore raw

RFC PATCH 1/1 drm/radeon/kms: pm debugging check for vbl.

From: Dave Airlie <[email protected]>

This patch adds a check on avivo chips to see if we are in the VBL region for the active crtcs when we trigger the engine change.

I appear to have glitches locally on pm transistion (not sure all fixes are in yet) and this at least seems to be correct here, maybe others can test on systems with no glitches.

---
 drivers/gpu/drm/radeon/avivod.h    |    2 ++
 drivers/gpu/drm/radeon/radeon_pm.c |   27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/avivod.h +2 -0
index d4e6e6e..3c391e7 100644
@@ -30,11 +30,13 @@
 
 #define	D1CRTC_CONTROL					0x6080
 #define		CRTC_EN						(1 << 0)
+#define	D1CRTC_STATUS					0x609c
 #define	D1CRTC_UPDATE_LOCK				0x60E8
 #define	D1GRPH_PRIMARY_SURFACE_ADDRESS			0x6110
 #define	D1GRPH_SECONDARY_SURFACE_ADDRESS		0x6118
 
 #define	D2CRTC_CONTROL					0x6880
+#define	D2CRTC_STATUS					0x689c
 #define	D2CRTC_UPDATE_LOCK				0x68E8
 #define	D2GRPH_PRIMARY_SURFACE_ADDRESS			0x6910
 #define	D2GRPH_SECONDARY_SURFACE_ADDRESS		0x6918
drivers/gpu/drm/radeon/radeon_pm.c +27 -0
index b138618..f46d574 100644
@@ -22,6 +22,7 @@
  */
 #include "drmP.h"
 #include "radeon.h"
+#include "avivod.h"
 
 #define RADEON_IDLE_LOOP_MS 100
 #define RADEON_RECLOCK_DELAY_MS 200
@@ -293,6 +294,28 @@ void radeon_pm_compute_clocks(struct radeon_device *rdev)
 	mutex_unlock(&rdev->pm.mutex);
 }
 
+static bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish)
+{
+	u32 stat_crtc1 = 0, stat_crtc2 = 0;
+	bool in_vbl = true;
+
+	if (ASIC_IS_AVIVO(rdev)) {
+		if (rdev->pm.active_crtcs & (1 << 0)) {
+			stat_crtc1 = RREG32(D1CRTC_STATUS);
+			if (!(stat_crtc1 & 1))
+				in_vbl = false;
+		}
+		if (rdev->pm.active_crtcs & (1 << 1)) {
+			stat_crtc2 = RREG32(D2CRTC_STATUS);
+			if (!(stat_crtc2 & 1))
+				in_vbl = false;
+		}
+	}
+	if (in_vbl == false)
+		DRM_INFO("not in vbl for pm change %08x %08x at %s\n", stat_crtc1,
+			 stat_crtc2, finish ? "exit" : "entry");
+	return in_vbl;
+}
 static void radeon_pm_set_clocks_locked(struct radeon_device *rdev)
 {
 	/*radeon_fence_wait_last(rdev);*/
@@ -309,7 +332,11 @@ static void radeon_pm_set_clocks_locked(struct radeon_device *rdev)
 		DRM_ERROR("%s: PM_ACTION_NONE\n", __func__);
 		break;
 	}
+
+	/* check if we are in vblank */
+	radeon_pm_debug_check_in_vbl(rdev, false);
 	radeon_set_power_state(rdev);
+	radeon_pm_debug_check_in_vbl(rdev, true);
 	rdev->pm.planned_action = PM_ACTION_NONE;
 }
 
Signature · 10 lines
1.6.6


------------------------------------------------------------------------------
Download Intel&reg; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs 
proactively, and fine-tune applications for parallel performance. 
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
#1 lore raw

2010/2/18 Dave Airlie <[email protected]>:

Quoted 8 lines

From: Dave Airlie <[email protected]>

This patch adds a check on avivo chips to see if we are in the VBL region for the active crtcs when we trigger the engine change.

I appear to have glitches locally on pm transistion (not sure all fixes are in yet) and this at least seems to be correct here, maybe others can test on systems with no glitches.

Because we are totally out of sync with VBLANK. If we correctly sync with it, it's just a lucky case. Please check my
[PATCH] drm/radeon/kms: really wait for VBLANK in PM code and reply in thread where I posted it.

Quoted 5 lines

+       /* check if we are in vblank */
+       radeon_pm_debug_check_in_vbl(rdev, false); radeon_set_power_state(rdev);
+       radeon_pm_debug_check_in_vbl(rdev, true); rdev->pm.planned_action = PM_ACTION_NONE;

It adds some reading & printing steps before every reclock, while we really want it to happen as soon as possible. Maybe you could execute this only on some
#ifdef RADEON_PM_DEBUG
?

Signature · 13 lines
Rafał

------------------------------------------------------------------------------
Download Intel&reg; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs 
proactively, and fine-tune applications for parallel performance. 
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
author maintainer
#2 lore raw

2010/2/18 Rafał Miłecki <[email protected]>:

Quoted 6 lines

2010/2/18 Dave Airlie <[email protected]>:

Quoted 5 lines

From: Dave Airlie <[email protected]>

This patch adds a check on avivo chips to see if we are in the VBL region for the active crtcs when we trigger the engine change.

Quoted 8 lines
Quoted 3 lines

I appear to have glitches locally on pm transistion (not sure all fixes are in yet) and this at least seems to be correct here, maybe others can test on systems with no glitches.

Because we are totally out of sync with VBLANK. If we correctly sync with it, it's just a lucky case. Please check my
[PATCH] drm/radeon/kms: really wait for VBLANK in PM code and reply in thread where I posted it.

Yeah I'll put this in when I've ran it here, it looks sane.

Quoted 4 lines

It adds some reading & printing steps before every reclock, while we really want it to happen as soon as possible. Maybe you could execute this only on some
#ifdef RADEON_PM_DEBUG

I don't think it'll be a major overhead, though doing it under a debug would be fine, but it would be nice to make it into a WARN_ON so we could track where this actually happens for ppl with something like kerneloops.

Dave.

------------------------------------------------------------------------------
Download Intel&reg; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

author maintainer
#3 lore raw
Quoted 4 lines
Quoted 4 lines

It adds some reading & printing steps before every reclock, while we really want it to happen as soon as possible. Maybe you could execute this only on some

btw you won't get the print if you are in vblank, and if you aren't well the print
doesn't matter, I'm also thinking the engine change reads/writes a lot of regs, so two more might not matter so much.

Dave.

------------------------------------------------------------------------------
Download Intel&reg; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--

#4 lore raw
Quoted 9 lines · W dniu 18 lutego 2010 09:28 użytkownik Dave Airlie <[email protected]> napisał:
Quoted 4 lines
Quoted 4 lines

It adds some reading & printing steps before every reclock, while we really want it to happen as soon as possible. Maybe you could execute this only on some

btw you won't get the print if you are in vblank, and if you aren't well the print
doesn't matter, I'm also thinking the engine change reads/writes a lot of regs, so two more might not matter so much.

Yeah, maybe that's right.

While your idea of testing being in VBLANK is "sane" :) it could happen we start reclocking in VBLANK (first test will pass), we reclock out of VBLANK (not wanted, possible corruption), and we hit next VBLANK in second test.

In such situation (machine) I'm sure we will hit "false" in test anyway (sooner or later) but maybe we could improve in anyway somehow? To make sure it's sill the same VBLANK?

Signature · 13 lines
Rafał

------------------------------------------------------------------------------
Download Intel&reg; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs 
proactively, and fine-tune applications for parallel performance. 
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
author maintainer
#5 lore raw

2010/2/18 Rafał Miłecki <[email protected]>:

Quoted 13 lines
Quoted 9 lines · W dniu 18 lutego 2010 09:28 użytkownik Dave Airlie <[email protected]> napisał:
Quoted 4 lines
Quoted 4 lines

It adds some reading & printing steps before every reclock, while we really want it to happen as soon as possible. Maybe you could execute this only on some

btw you won't get the print if you are in vblank, and if you aren't well the print
doesn't matter, I'm also thinking the engine change reads/writes a lot of regs, so two more might not matter so much.

Yeah, maybe that's right.

Quoted 8 lines

While your idea of testing being in VBLANK is "sane" :) it could happen we start reclocking in VBLANK (first test will pass), we reclock out of VBLANK (not wanted, possible corruption), and we hit next VBLANK in second test.

In such situation (machine) I'm sure we will hit "false" in test anyway (sooner or later) but maybe we could improve in anyway somehow? To make sure it's sill the same VBLANK?

That could be possible, though if a reclock takes a full scanout to operate we've
got other issues as it would never be possible by the sounds of it.

The check on the way out could be toned down alright, its probably not as important,

btw I've still got problems even with that other patch applied, I get reclocking in
the middle of the frame,

Reverting 73a6d3fc104827db574e4bd206a025299fef0bb1 drm/radeon/kms: use wait queue (events) for VBLANK sync

still fixes it for me here.

Dave.

------------------------------------------------------------------------------
Download Intel&reg; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--

#6 lore raw

2010/2/18 Dave Airlie <[email protected]>:

Quoted 19 lines

2010/2/18 Rafał Miłecki <[email protected]>:

Quoted 18 lines
Quoted 9 lines · W dniu 18 lutego 2010 09:28 użytkownik Dave Airlie <[email protected]> napisał:
Quoted 4 lines
Quoted 4 lines

It adds some reading & printing steps before every reclock, while we really want it to happen as soon as possible. Maybe you could execute this only on some

btw you won't get the print if you are in vblank, and if you aren't well the print
doesn't matter, I'm also thinking the engine change reads/writes a lot of regs, so two more might not matter so much.

Yeah, maybe that's right.

While your idea of testing being in VBLANK is "sane" :) it could happen we start reclocking in VBLANK (first test will pass), we reclock out of VBLANK (not wanted, possible corruption), and we hit next VBLANK in second test.

Quoted 7 lines
Quoted 3 lines

In such situation (machine) I'm sure we will hit "false" in test anyway (sooner or later) but maybe we could improve in anyway somehow? To make sure it's sill the same VBLANK?

That could be possible, though if a reclock takes a full scanout to operate we've
got other issues as it would never be possible by the sounds of it.

I might be seeing something like this O_o

[  257.583603] [drm] not in vbl for pm change 00020002 00000000 at entry
[  257.583609] [drm] Setting: e: 22000 m: 30000 p: 16

(no warning at exit)

I have wait queue fix in place... I also see some unsynched reclocks. On a somewhat unrelated note the current clock selection code does not work well with the tables defined on my card (M76):

[  156.577741] ATOM BIOS: ASUS_F3Sa
[  156.577794] [drm] Clocks initialized !
[  156.577833] [drm] 5 Power State(s)
[  156.577871] [drm] State 0 Default (default)
[  156.577909] [drm]    16 PCIE Lanes
[  156.577946] [drm]    3 Clock Mode(s)
[  156.577984] [drm]            0 engine/memory: 220000/300000
[  156.578023] [drm]            1 engine/memory: 220000/300000
[  156.578063] [drm]            2 engine/memory: 220000/300000
[  156.578102] [drm] State 1 Performance
[  156.578139] [drm]    16 PCIE Lanes
[  156.578177] [drm]    3 Clock Mode(s)
[  156.578214] [drm]            0 engine/memory: 220000/252000
[  156.578253] [drm]            1 engine/memory: 220000/300000
[  156.578292] [drm]            2 engine/memory: 500000/400000
[  156.578332] [drm] State 2 Battery
[  156.578369] [drm]    16 PCIE Lanes
[  156.578406] [drm]    3 Clock Mode(s)
[  156.578444] [drm]            0 engine/memory: 220000/252000
[  156.578483] [drm]            1 engine/memory: 220000/252000
[  156.578522] [drm]            2 engine/memory: 220000/300000
[  156.578561] [drm] State 3 Performance
[  156.578599] [drm]    16 PCIE Lanes
[  156.578636] [drm]    3 Clock Mode(s)
[  156.578674] [drm]            0 engine/memory: 300000/400000
[  156.578713] [drm]            1 engine/memory: 300000/400000
[  156.578752] [drm]            2 engine/memory: 500000/400000
[  156.578791] [drm] State 4 Battery
[  156.578828] [drm]    16 PCIE Lanes
[  156.578866] [drm]    3 Clock Mode(s)
[  156.578903] [drm]            0 engine/memory: 220000/300000
[  156.578942] [drm]            1 engine/memory: 220000/300000
[  156.578981] [drm]            2 engine/memory: 220000/300000

radeon_pick_power_state with a mobility chip only uses battery and powersave states.

Luca

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel