Since gen9 timestamp should be read from BLT ring (TIMESTAMP_BCSUNIT). On gen9 reading timestamp from RENDER_RING is still working but is deprecated with no guarantee to be supported in next steppings. This commit require whitelist TIMESTAMP_BCSUNIT in kernel. Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Signed-off-by: Andrzej Lawrynowicz <andrzej.lawrynowicz@xxxxxxxxx> --- tests/gem_reg_read.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/gem_reg_read.c b/tests/gem_reg_read.c index 79facc1..6fdbfcb 100644 --- a/tests/gem_reg_read.c +++ b/tests/gem_reg_read.c @@ -43,7 +43,10 @@ struct local_drm_i915_reg_read { #define REG_READ_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x31, struct local_drm_i915_reg_read) -#define RENDER_RING_TIMESTAMP 0x2358 +#define RENDER_RING_BASE 0x02000 +#define BLT_RING_BASE 0x22000 + +#define RING_TIMESTAMP(base) (base)+0x358 static int read_register(int fd, uint64_t offset, uint64_t * val) { @@ -73,12 +76,20 @@ static bool check_kernel_x86_64(void) return false; } +static uint64_t get_timestamp_offset(int fd) +{ + if (intel_gen(intel_get_drm_devid(fd)) < 9) + return RING_TIMESTAMP(RENDER_RING_BASE); + else + return RING_TIMESTAMP(BLT_RING_BASE); +} + static bool check_timestamp(int fd) { int ret; uint64_t val; - ret = read_register(fd, RENDER_RING_TIMESTAMP | 1, &val); + ret = read_register(fd, get_timestamp_offset(fd) | 1, &val); return ret == 0; } @@ -88,7 +99,7 @@ static int timer_query(int fd, uint64_t * val) uint64_t offset; int ret; - offset = RENDER_RING_TIMESTAMP; + offset = get_timestamp_offset(fd); if (has_proper_timestamp) offset |= 1; -- 2.10.2 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx