public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] i915/gem_mmap_gtt: Test mmap_offset lifetime
@ 2019-08-10 12:38 Chris Wilson
  2019-08-13 10:44 ` Abdiel Janulgue
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Wilson @ 2019-08-10 12:38 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev

Closing the object on another file should not affect the local
mmap_offset.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
 tests/i915/gem_mmap_gtt.c | 40 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index 6f3a9c36e..8eff91850 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -322,6 +322,44 @@ test_pf_nonblock(int i915)
 	igt_spin_free(i915, spin);
 }
 
+static void
+test_isolation(int i915)
+{
+	struct drm_i915_gem_mmap_gtt mmap_arg;
+	int A = gem_reopen_driver(i915);
+	int B = gem_reopen_driver(i915);
+	uint64_t offset_a, offset_b;
+	uint32_t a, b;
+	void *ptr;
+
+	a = gem_create(A, 4096);
+	b = gem_open(B, gem_flink(A, a));
+
+	mmap_arg.handle = a;
+	do_ioctl(A, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg);
+	offset_a = mmap_arg.offset;
+
+	mmap_arg.handle = b;
+	do_ioctl(B, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg);
+	offset_b = mmap_arg.offset;
+
+	igt_info("A: {fd:%d, handle:%d, offset:%"PRIx64"}\n",
+		 A, a, offset_a);
+	igt_info("B: {fd:%d, handle:%d, offset:%"PRIx64"}\n",
+		 B, b, offset_b);
+
+	close(B);
+
+	ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
+	igt_assert(ptr != MAP_FAILED);
+	munmap(ptr, 4096);
+
+	close(A);
+
+	ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
+	igt_assert(ptr == MAP_FAILED);
+}
+
 static void
 test_write_gtt(int fd)
 {
@@ -945,6 +983,8 @@ igt_main
 		test_write_cpu_read_gtt(fd);
 	igt_subtest("basic-wc")
 		test_wc(fd);
+	igt_subtest("isolation")
+		test_isolation(fd);
 	igt_subtest("pf-nonblock")
 		test_pf_nonblock(fd);
 
-- 
2.23.0.rc1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH i-g-t] i915/gem_mmap_gtt: Test mmap_offset lifetime
  2019-08-10 12:38 [PATCH i-g-t] i915/gem_mmap_gtt: Test mmap_offset lifetime Chris Wilson
@ 2019-08-13 10:44 ` Abdiel Janulgue
  0 siblings, 0 replies; 2+ messages in thread
From: Abdiel Janulgue @ 2019-08-13 10:44 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx; +Cc: igt-dev



On 10/08/2019 15.38, Chris Wilson wrote:
> Closing the object on another file should not affect the local
> mmap_offset.
> 

Thanks for this! It helped squeezed the bug out of mmap_offset.

Reviewed-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>


> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
> ---
>  tests/i915/gem_mmap_gtt.c | 40 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> index 6f3a9c36e..8eff91850 100644
> --- a/tests/i915/gem_mmap_gtt.c
> +++ b/tests/i915/gem_mmap_gtt.c
> @@ -322,6 +322,44 @@ test_pf_nonblock(int i915)
>  	igt_spin_free(i915, spin);
>  }
>  
> +static void
> +test_isolation(int i915)
> +{
> +	struct drm_i915_gem_mmap_gtt mmap_arg;
> +	int A = gem_reopen_driver(i915);
> +	int B = gem_reopen_driver(i915);
> +	uint64_t offset_a, offset_b;
> +	uint32_t a, b;
> +	void *ptr;
> +
> +	a = gem_create(A, 4096);
> +	b = gem_open(B, gem_flink(A, a));
> +
> +	mmap_arg.handle = a;
> +	do_ioctl(A, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg);
> +	offset_a = mmap_arg.offset;
> +
> +	mmap_arg.handle = b;
> +	do_ioctl(B, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg);
> +	offset_b = mmap_arg.offset;
> +
> +	igt_info("A: {fd:%d, handle:%d, offset:%"PRIx64"}\n",
> +		 A, a, offset_a);
> +	igt_info("B: {fd:%d, handle:%d, offset:%"PRIx64"}\n",
> +		 B, b, offset_b);
> +
> +	close(B);
> +
> +	ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
> +	igt_assert(ptr != MAP_FAILED);
> +	munmap(ptr, 4096);
> +
> +	close(A);
> +
> +	ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);
> +	igt_assert(ptr == MAP_FAILED);
> +}
> +
>  static void
>  test_write_gtt(int fd)
>  {
> @@ -945,6 +983,8 @@ igt_main
>  		test_write_cpu_read_gtt(fd);
>  	igt_subtest("basic-wc")
>  		test_wc(fd);
> +	igt_subtest("isolation")
> +		test_isolation(fd);
>  	igt_subtest("pf-nonblock")
>  		test_pf_nonblock(fd);
>  
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-13 10:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-10 12:38 [PATCH i-g-t] i915/gem_mmap_gtt: Test mmap_offset lifetime Chris Wilson
2019-08-13 10:44 ` Abdiel Janulgue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox