[igt-dev] [Intel-gfx] [PATCH i-g-t] i915: Mark up some forgotten set-domain

Ville Syrjälä ville.syrjala at linux.intel.com
Mon Mar 25 06:32:04 UTC 2019


On Sun, Mar 24, 2019 at 02:14:25PM +0000, Chris Wilson wrote:
> It is the user's responsibility to manage their domains. In libdrm, when
> you mmap a pointer, it calls set-domain automatically, but igt requires
> the caller to manage it explicitly, so do so. The vast majority already
> do correct manage the domain as they use the pointer into the mmap, just
> a few have been missed over the years.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

> ---
>  tests/i915/gem_gtt_cpu_tlb.c          | 2 ++
>  tests/i915/gem_mmap_gtt.c             | 4 +++-
>  tests/i915/gem_tiled_fence_blits.c    | 2 ++
>  tests/i915/gem_tiled_pread_basic.c    | 1 +
>  tests/i915/gem_tiled_pread_pwrite.c   | 1 +
>  tests/i915/gem_tiled_wb.c             | 1 +
>  tests/i915/gem_tiled_wc.c             | 1 +
>  tests/i915/gen3_mixed_blits.c         | 2 ++
>  tests/i915/gen3_render_mixed_blits.c  | 2 ++
>  tests/i915/gen3_render_tiledx_blits.c | 2 ++
>  tests/i915/gen3_render_tiledy_blits.c | 2 ++
>  tests/i915/i915_suspend.c             | 4 ++++
>  12 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/i915/gem_gtt_cpu_tlb.c b/tests/i915/gem_gtt_cpu_tlb.c
> index 8ceef44c2..cf3c543df 100644
> --- a/tests/i915/gem_gtt_cpu_tlb.c
> +++ b/tests/i915/gem_gtt_cpu_tlb.c
> @@ -60,6 +60,7 @@ create_bo(int fd)
>  
>  	/* Fill the BO with dwords starting at start_val */
>  	data = gem_mmap__gtt(fd, handle, OBJ_SIZE, PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < OBJ_SIZE/4; i++)
>  		data[i] = i;
>  	munmap(data, OBJ_SIZE);
> @@ -83,6 +84,7 @@ igt_simple_main
>  
>  	/* touch one page */
>  	ptr = gem_mmap__gtt(fd, handle, OBJ_SIZE, PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	*ptr = 0xdeadbeef;
>  	munmap(ptr, OBJ_SIZE);
>  
> diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> index 9a00f4ea4..639de1902 100644
> --- a/tests/i915/gem_mmap_gtt.c
> +++ b/tests/i915/gem_mmap_gtt.c
> @@ -179,6 +179,7 @@ test_read_write(int fd, enum test_read_write order)
>  	handle = gem_create(fd, OBJECT_SIZE);
>  
>  	ptr = gem_mmap__gtt(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  
>  	if (order == READ_BEFORE_WRITE) {
>  		val = *(uint32_t *)ptr;
> @@ -202,9 +203,10 @@ test_read_write2(int fd, enum test_read_write order)
>  	handle = gem_create(fd, OBJECT_SIZE);
>  
>  	r = gem_mmap__gtt(fd, handle, OBJECT_SIZE, PROT_READ);
> -
>  	w = gem_mmap__gtt(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
>  
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
> +
>  	if (order == READ_BEFORE_WRITE) {
>  		val = *(uint32_t *)r;
>  		*(uint32_t *)w = val;
> diff --git a/tests/i915/gem_tiled_fence_blits.c b/tests/i915/gem_tiled_fence_blits.c
> index 2453bcc0b..aacd42b73 100644
> --- a/tests/i915/gem_tiled_fence_blits.c
> +++ b/tests/i915/gem_tiled_fence_blits.c
> @@ -58,6 +58,7 @@ static uint32_t create_bo(int fd, uint32_t start_val)
>  
>  	/* Fill the BO with dwords starting at start_val */
>  	ptr = gem_mmap__gtt(fd, handle, bo_size, PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (int i = 0; i < width * height; i++)
>  		ptr[i] = start_val++;
>  	munmap(ptr, bo_size);
> @@ -70,6 +71,7 @@ static void check_bo(int fd, uint32_t handle, uint32_t start_val)
>  	uint32_t *ptr;
>  
>  	ptr = gem_mmap__gtt(fd, handle, bo_size, PROT_READ);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, 0);
>  	igt_memcpy_from_wc(linear, ptr, bo_size);
>  	munmap(ptr, bo_size);
>  
> diff --git a/tests/i915/gem_tiled_pread_basic.c b/tests/i915/gem_tiled_pread_basic.c
> index 425bb07e7..1ac9eccdb 100644
> --- a/tests/i915/gem_tiled_pread_basic.c
> +++ b/tests/i915/gem_tiled_pread_basic.c
> @@ -74,6 +74,7 @@ create_bo(int fd)
>  	/* Fill the BO with dwords starting at start_val */
>  	data = gem_mmap__gtt(fd, handle, sizeof(linear),
>  			     PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < WIDTH*HEIGHT; i++)
>  		data[i] = i;
>  	munmap(data, sizeof(linear));
> diff --git a/tests/i915/gem_tiled_pread_pwrite.c b/tests/i915/gem_tiled_pread_pwrite.c
> index fcf0780af..0988a4e86 100644
> --- a/tests/i915/gem_tiled_pread_pwrite.c
> +++ b/tests/i915/gem_tiled_pread_pwrite.c
> @@ -82,6 +82,7 @@ create_bo_and_fill(int fd)
>  	/* Fill the BO with dwords starting at start_val */
>  	data = gem_mmap__gtt(fd, handle, sizeof(linear),
>  			     PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < WIDTH*HEIGHT; i++)
>  		data[i] = i;
>  	munmap(data, sizeof(linear));
> diff --git a/tests/i915/gem_tiled_wb.c b/tests/i915/gem_tiled_wb.c
> index 827c2d9d6..b7f352fc7 100644
> --- a/tests/i915/gem_tiled_wb.c
> +++ b/tests/i915/gem_tiled_wb.c
> @@ -72,6 +72,7 @@ create_bo(int fd)
>  	 * We then manually detile on reading back through the mmap(wc).
>  	 */
>  	data = gem_mmap__gtt(fd, handle, SIZE, PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < WIDTH*HEIGHT; i++)
>  		data[i] = i;
>  	munmap(data, SIZE);
> diff --git a/tests/i915/gem_tiled_wc.c b/tests/i915/gem_tiled_wc.c
> index 67ebbc940..845ec2280 100644
> --- a/tests/i915/gem_tiled_wc.c
> +++ b/tests/i915/gem_tiled_wc.c
> @@ -66,6 +66,7 @@ create_bo(int fd)
>  
>  	/* Fill the BO with dwords starting at start_val */
>  	data = gem_mmap__gtt(fd, handle, SIZE, PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < WIDTH*HEIGHT; i++)
>  		data[i] = i;
>  	munmap(data, SIZE);
> diff --git a/tests/i915/gen3_mixed_blits.c b/tests/i915/gen3_mixed_blits.c
> index 948f4e6a7..447d2e5db 100644
> --- a/tests/i915/gen3_mixed_blits.c
> +++ b/tests/i915/gen3_mixed_blits.c
> @@ -416,6 +416,7 @@ create_bo(int fd, uint32_t val, int tiling)
>  	/* Fill the BO with dwords starting at val */
>  	v = gem_mmap__gtt(fd, handle, WIDTH * HEIGHT * 4,
>  			  PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < WIDTH*HEIGHT; i++)
>  		v[i] = val++;
>  	munmap(v, WIDTH*HEIGHT*4);
> @@ -430,6 +431,7 @@ check_bo(int fd, uint32_t handle, uint32_t val)
>  	int i;
>  
>  	v = gem_mmap__gtt(fd, handle, WIDTH * HEIGHT * 4, PROT_READ);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, 0);
>  	for (i = 0; i < WIDTH*HEIGHT; i++) {
>  		igt_assert_f(v[i] == val,
>  			     "Expected 0x%08x, found 0x%08x "
> diff --git a/tests/i915/gen3_render_mixed_blits.c b/tests/i915/gen3_render_mixed_blits.c
> index afb53a598..6dd7392b5 100644
> --- a/tests/i915/gen3_render_mixed_blits.c
> +++ b/tests/i915/gen3_render_mixed_blits.c
> @@ -310,6 +310,7 @@ create_bo(int fd, uint32_t val, int tiling)
>  	/* Fill the BO with dwords starting at val */
>  	v = gem_mmap__gtt(fd, handle, WIDTH * HEIGHT * 4,
>  			  PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < WIDTH*HEIGHT; i++)
>  		v[i] = val++;
>  	munmap(v, WIDTH*HEIGHT*4);
> @@ -324,6 +325,7 @@ check_bo(int fd, uint32_t handle, uint32_t val)
>  	int i;
>  
>  	v = gem_mmap__gtt(fd, handle, WIDTH * HEIGHT * 4, PROT_READ);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, 0);
>  	for (i = 0; i < WIDTH*HEIGHT; i++) {
>  		igt_assert_f(v[i] == val,
>  			     "Expected 0x%08x, found 0x%08x "
> diff --git a/tests/i915/gen3_render_tiledx_blits.c b/tests/i915/gen3_render_tiledx_blits.c
> index e6246f2b0..7efef5893 100644
> --- a/tests/i915/gen3_render_tiledx_blits.c
> +++ b/tests/i915/gen3_render_tiledx_blits.c
> @@ -297,6 +297,7 @@ create_bo(int fd, uint32_t val)
>  	/* Fill the BO with dwords starting at val */
>  	v = gem_mmap__gtt(fd, handle, WIDTH * HEIGHT * 4,
>  			  PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < WIDTH*HEIGHT; i++)
>  		v[i] = val++;
>  	munmap(v, WIDTH*HEIGHT*4);
> @@ -311,6 +312,7 @@ check_bo(int fd, uint32_t handle, uint32_t val)
>  	int i;
>  
>  	v = gem_mmap__gtt(fd, handle, WIDTH * HEIGHT * 4, PROT_READ);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, 0);
>  	for (i = 0; i < WIDTH*HEIGHT; i++) {
>  		igt_assert_f(v[i] == val,
>  			     "Expected 0x%08x, found 0x%08x "
> diff --git a/tests/i915/gen3_render_tiledy_blits.c b/tests/i915/gen3_render_tiledy_blits.c
> index 17502ccb7..6d1d8bca4 100644
> --- a/tests/i915/gen3_render_tiledy_blits.c
> +++ b/tests/i915/gen3_render_tiledy_blits.c
> @@ -297,6 +297,7 @@ create_bo(int fd, uint32_t val)
>  	/* Fill the BO with dwords starting at val */
>  	v = gem_mmap__gtt(fd, handle, WIDTH * HEIGHT * 4,
>  			  PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < WIDTH*HEIGHT; i++)
>  		v[i] = val++;
>  	munmap(v, WIDTH*HEIGHT*4);
> @@ -311,6 +312,7 @@ check_bo(int fd, uint32_t handle, uint32_t val)
>  	int i;
>  
>  	v = gem_mmap__gtt(fd, handle, WIDTH * HEIGHT * 4, PROT_READ);
> +	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, 0);
>  	for (i = 0; i < WIDTH*HEIGHT; i++) {
>  		igt_assert_f(v[i] == val,
>  			     "Expected 0x%08x, found 0x%08x "
> diff --git a/tests/i915/i915_suspend.c b/tests/i915/i915_suspend.c
> index 0d49fdcb0..17c68cc17 100644
> --- a/tests/i915/i915_suspend.c
> +++ b/tests/i915/i915_suspend.c
> @@ -58,17 +58,21 @@ test_fence_restore(int fd, bool tiled2untiled, bool hibernate)
>  
>  	/* Access the buffer objects in the order we want to have the laid out. */
>  	ptr1 = gem_mmap__gtt(fd, handle1, OBJECT_SIZE, PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle1, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < OBJECT_SIZE/sizeof(uint32_t); i++)
>  		ptr1[i] = i;
>  
>  	ptr_tiled = gem_mmap__gtt(fd, handle_tiled, OBJECT_SIZE,
>  				  PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle_tiled,
> +		       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	if (tiled2untiled)
>  		gem_set_tiling(fd, handle_tiled, I915_TILING_X, 2048);
>  	for (i = 0; i < OBJECT_SIZE/sizeof(uint32_t); i++)
>  		ptr_tiled[i] = i;
>  
>  	ptr2 = gem_mmap__gtt(fd, handle2, OBJECT_SIZE, PROT_READ | PROT_WRITE);
> +	gem_set_domain(fd, handle2, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  	for (i = 0; i < OBJECT_SIZE/sizeof(uint32_t); i++)
>  		ptr2[i] = i;
>  
> -- 
> 2.20.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel


More information about the igt-dev mailing list