Skip to content

Commit 38530a3

Browse files
committed
drm/i915/selftests: Test RING_TIMESTAMP on gen4/5
Now that we actually know the cs timestamp frequency on gen4/5 let's run the corresponding test. On g4x/ilk we must read the udw of the 64bit timestamp register. Details in {g4x,gen5)_read_clock_frequency(). The one extra caveat is that on i965 (or at least CL, don't recall if I ever tested on BW) we must read the register twice to get an up to date value. For some unknown reason the first read tends to return a stale value. Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Lionel Landwerlin <[email protected]>
1 parent cf8a82d commit 38530a3

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

drivers/gpu/drm/i915/gt/selftest_gt_pm.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ static int cmp_u32(const void *A, const void *B)
3636
return 0;
3737
}
3838

39+
static u32 read_timestamp(struct intel_engine_cs *engine)
40+
{
41+
struct drm_i915_private *i915 = engine->i915;
42+
43+
/* On i965 the first read tends to give a stale value */
44+
ENGINE_READ_FW(engine, RING_TIMESTAMP);
45+
46+
if (GRAPHICS_VER(i915) == 5 || IS_G4X(i915))
47+
return ENGINE_READ_FW(engine, RING_TIMESTAMP_UDW);
48+
else
49+
return ENGINE_READ_FW(engine, RING_TIMESTAMP);
50+
}
51+
3952
static void measure_clocks(struct intel_engine_cs *engine,
4053
u32 *out_cycles, ktime_t *out_dt)
4154
{
@@ -45,13 +58,13 @@ static void measure_clocks(struct intel_engine_cs *engine,
4558

4659
for (i = 0; i < 5; i++) {
4760
local_irq_disable();
48-
cycles[i] = -ENGINE_READ_FW(engine, RING_TIMESTAMP);
61+
cycles[i] = -read_timestamp(engine);
4962
dt[i] = ktime_get();
5063

5164
udelay(1000);
5265

5366
dt[i] = ktime_sub(ktime_get(), dt[i]);
54-
cycles[i] += ENGINE_READ_FW(engine, RING_TIMESTAMP);
67+
cycles[i] += read_timestamp(engine);
5568
local_irq_enable();
5669
}
5770

@@ -78,25 +91,6 @@ static int live_gt_clocks(void *arg)
7891
if (GRAPHICS_VER(gt->i915) < 4) /* Any CS_TIMESTAMP? */
7992
return 0;
8093

81-
if (GRAPHICS_VER(gt->i915) == 5)
82-
/*
83-
* XXX CS_TIMESTAMP low dword is dysfunctional?
84-
*
85-
* Ville's experiments indicate the high dword still works,
86-
* but at a correspondingly reduced frequency.
87-
*/
88-
return 0;
89-
90-
if (GRAPHICS_VER(gt->i915) == 4)
91-
/*
92-
* XXX CS_TIMESTAMP appears gibberish
93-
*
94-
* Ville's experiments indicate that it mostly appears 'stuck'
95-
* in that we see the register report the same cycle count
96-
* for a couple of reads.
97-
*/
98-
return 0;
99-
10094
intel_gt_pm_get(gt);
10195
intel_uncore_forcewake_get(gt->uncore, FORCEWAKE_ALL);
10296

0 commit comments

Comments
 (0)