[igt-dev] [PATCH i-g-t v2 3/4] tests/i915/gem_mmap_offset: Add new API test for gem_mmap_offset

Zbigniew KempczyƄski zbigniew.kempczynski at intel.com
Wed Nov 20 10:50:15 UTC 2019


On Tue, Nov 19, 2019 at 10:13:37AM -0800, Vanshidhar Konda wrote:

<cut>
> > +			for (; i >= 0; i--) {
> > +				struct local_i915_gem_mmap_offset arg = {
> > +					.handle = handles[i],
> > +					.flags = LOCAL_I915_MMAP_OFFSET_WB,
> 
> May be we should use LOCAL_I915_MMAP_OFFSET_UC - it is possible that
> WB/WC is not supported on all memory regions.

You're right, we want to check object lookup, not PAT feature.
Will be fixed in v3. 
 
> > +				};
> > +
> > +				igt_debug("Trying MMAP IOCTL with handle %x\n",
> > +					  handles[i]);
> > +				igt_assert_eq(mmap_offset_ioctl(fd, &arg),
> > +					      -ENOENT);
> > +			}
> > +
> > +			gem_close(fd, real_handle);
> > +		}
> > +
> > +		igt_subtest_f("basic-%s", mr->region_name) {
> > +			struct local_i915_gem_mmap_offset arg;
> > +			uint8_t *expected;
> > +			uint8_t *buf;
> > +
> > +			gem_query_require_region(query_info, region);
> > +
> > +			arg.handle = gem_create_in_memory_regions(fd, obj_size,
> > +								  region);
> > +			arg.flags = LOCAL_I915_MMAP_OFFSET_WB;
> 
> See above comment about using MMAP_OFFSET_UC.

In this case I think better is to iterate over WB, WC then UC flags. 
I'll add appropriate code around this.
 
> > +
> > +			igt_assert_eq(mmap_offset_ioctl(fd, &arg), 0);
> > +			addr = mmap64(0, obj_size, PROT_READ | PROT_WRITE,
> > +				      MAP_SHARED, fd, arg.offset);
> > +			igt_assert(addr != MAP_FAILED);
> > +
> > +			igt_debug("Testing contents of newly created object.\n");
> > +			expected = calloc(obj_size, sizeof(*expected));
> > +			igt_assert_eq(memcmp(addr, expected, obj_size), 0);
> > +			free(expected);
> > +
> > +			igt_debug("Testing coherency of writes and mmap reads.\n");
> > +			buf = calloc(obj_size, sizeof(*buf));
> > +			memset(buf + 1024, 0x01, 1024);
> > +			gem_write(fd, arg.handle, 0, buf, obj_size);
> > +			igt_assert_eq(memcmp(buf, addr, obj_size), 0);
> 
> Is read/write to LMEM supposed to be coherent with CPU?

I will add appropriate sync code.

> 
> > +
> > +			igt_debug("Testing that mapping stays after close\n");
> > +			gem_close(fd, arg.handle);
> > +			igt_assert_eq(memcmp(buf, addr, obj_size), 0);
> > +			free(buf);
> > +
> > +			igt_debug("Testing unmapping\n");
> > +			munmap(addr, obj_size);
> > +		}
> > +
> > +		igt_subtest_f("short-mmap-%s", mr->region_name) {
> > +			uint32_t handle;
> > +
> > +			gem_query_require_region(query_info, region);
> > +
> > +			handle = gem_create_in_memory_regions(fd, obj_size,
> > +							      region);
> > +			igt_assert(obj_size > batch_size);
> > +
> > +			addr = gem_mmap__cpu(fd, handle, 0, batch_size,
> > +					     PROT_WRITE);
> 
> It is possible that this will fail if WB is not allowed on a memory
> region.

I will add fallback to WC / UC.

Zbigniew

> 
> > +			memset(addr, 0, batch_size);
> > +			munmap(addr, batch_size);
> > +
> > +			gem_close(fd, handle);
> > +		}
> > +	}
> > +
> > +	igt_fixture {
> > +		free(query_info);
> > +		close(fd);
> > +	}
> > +}
> > diff --git a/tests/meson.build b/tests/meson.build
> > index 755fc9e6..644b5504 100644
> > --- a/tests/meson.build
> > +++ b/tests/meson.build
> > @@ -174,6 +174,7 @@ i915_progs = [
> > 	'gem_media_vme',
> > 	'gem_mmap',
> > 	'gem_mmap_gtt',
> > +	'gem_mmap_offset',
> > 	'gem_mmap_offset_exhaustion',
> > 	'gem_mmap_wc',
> > 	'gem_partial_pwrite_pread',
> > -- 
> > 2.23.0
> > 
> > _______________________________________________
> > igt-dev mailing list
> > igt-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/igt-dev


More information about the igt-dev mailing list