igt/gem_close_race: Fix blit commands for BDW

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73958
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-01-29 22:59:57 +00:00
parent 5e21b434da
commit be22e10885

View File

@ -49,6 +49,7 @@
static char device[80]; static char device[80];
static uint32_t devid; static uint32_t devid;
static bool has_64bit_relocations;
static void selfcopy(int fd, uint32_t handle, int loops) static void selfcopy(int fd, uint32_t handle, int loops)
{ {
@ -57,32 +58,41 @@ static void selfcopy(int fd, uint32_t handle, int loops)
struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_execbuffer2 execbuf;
struct drm_i915_gem_pwrite gem_pwrite; struct drm_i915_gem_pwrite gem_pwrite;
struct drm_i915_gem_create create; struct drm_i915_gem_create create;
uint32_t buf[10]; uint32_t buf[12], *b = buf;
memset(reloc, 0, sizeof(reloc)); memset(reloc, 0, sizeof(reloc));
memset(gem_exec, 0, sizeof(gem_exec)); memset(gem_exec, 0, sizeof(gem_exec));
memset(&execbuf, 0, sizeof(execbuf)); memset(&execbuf, 0, sizeof(execbuf));
buf[0] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB; *b = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB;
buf[1] = 0xcc << 16 | 1 << 25 | 1 << 24 | (4*1024); if (has_64bit_relocations)
buf[2] = 0; *b += 2;
buf[3] = 512 << 16 | 1024; b++;
buf[4] = 0; *b++ = 0xcc << 16 | 1 << 25 | 1 << 24 | (4*1024);
reloc[0].offset = 4 * sizeof(uint32_t); *b++ = 0;
*b++ = 512 << 16 | 1024;
reloc[0].offset = (b - buf) * sizeof(*b);
reloc[0].target_handle = handle; reloc[0].target_handle = handle;
reloc[0].read_domains = I915_GEM_DOMAIN_RENDER; reloc[0].read_domains = I915_GEM_DOMAIN_RENDER;
reloc[0].write_domain = I915_GEM_DOMAIN_RENDER; reloc[0].write_domain = I915_GEM_DOMAIN_RENDER;
*b++ = 0;
if (has_64bit_relocations)
*b++ = 0;
buf[5] = 512 << 16; *b++ = 512 << 16;
buf[6] = 4*1024; *b++ = 4*1024;
buf[7] = 0;
reloc[1].offset = 7 * sizeof(uint32_t); reloc[1].offset = (b - buf) * sizeof(*b);
reloc[1].target_handle = handle; reloc[1].target_handle = handle;
reloc[1].read_domains = I915_GEM_DOMAIN_RENDER; reloc[1].read_domains = I915_GEM_DOMAIN_RENDER;
reloc[1].write_domain = 0; reloc[1].write_domain = 0;
*b++ = 0;
if (has_64bit_relocations)
*b++ = 0;
buf[8] = MI_BATCH_BUFFER_END; *b++ = MI_BATCH_BUFFER_END;
buf[9] = 0; *b++ = 0;
gem_exec[0].handle = handle; gem_exec[0].handle = handle;
@ -95,13 +105,13 @@ static void selfcopy(int fd, uint32_t handle, int loops)
execbuf.buffers_ptr = (uintptr_t)gem_exec; execbuf.buffers_ptr = (uintptr_t)gem_exec;
execbuf.buffer_count = 2; execbuf.buffer_count = 2;
execbuf.batch_len = sizeof(buf); execbuf.batch_len = (b - buf) * sizeof(*b);
if (HAS_BLT_RING(devid)) if (HAS_BLT_RING(devid))
execbuf.flags |= I915_EXEC_BLT; execbuf.flags |= I915_EXEC_BLT;
gem_pwrite.handle = gem_exec[1].handle; gem_pwrite.handle = gem_exec[1].handle;
gem_pwrite.offset = 0; gem_pwrite.offset = 0;
gem_pwrite.size = sizeof(buf); gem_pwrite.size = execbuf.batch_len;
gem_pwrite.data_ptr = (uintptr_t)buf; gem_pwrite.data_ptr = (uintptr_t)buf;
if (drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite) == 0) { if (drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite) == 0) {
while (loops--) while (loops--)
@ -218,6 +228,7 @@ igt_main
int fd = open(device, O_RDWR); int fd = open(device, O_RDWR);
igt_assert(fd != -1); igt_assert(fd != -1);
devid = intel_get_drm_devid(fd); devid = intel_get_drm_devid(fd);
has_64bit_relocations = intel_gen(devid) >= 8;
close(fd); close(fd);
} }