All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl
@ 2017-10-04 10:22 Boris Brezillon
  2017-10-04 10:22 ` [PATCH i-g-t v2 1/3] igt: Add a helper function to mark BOs purgeable Boris Brezillon
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Boris Brezillon @ 2017-10-04 10:22 UTC (permalink / raw)
  To: Eric Anholt; +Cc: Intel GFX discussion

Hello,
    
This patchset adds VC4 specific tests to validate the
DRM_IOCTL_VC4_GEM_MADVISE ioctl.

Note that this series depends on kernel/libdrm code that has not been
accepted yet and is just provided to show reviewers how the ioctl can be
used and what to expect from it.
    
Please do not consider this for inclusion in IGT until the kernel and
libdrm part have been accepted.

Chris, I still haven't exposed a debugfs file to trigger a purge. I'd
like to sync with Eric before doing that.

Eric, I didn't add your "Queue up a big rendering job and mark BO
purgeable" test (still need to figure out how to do that :-)). That's
on my TODO list for a v3.
    
Thanks,
    
Boris

Boris Brezillon (3):
  igt: Add a helper function to mark BOs purgeable
  igt: Add igt_vc4_get_param() helper
  igt: Add VC4 purgeable BO tests

 lib/igt_vc4.c            |  27 +++++
 lib/igt_vc4.h            |   2 +
 tests/Makefile.sources   |   1 +
 tests/meson.build        |   1 +
 tests/vc4_purgeable_bo.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 296 insertions(+)
 create mode 100644 tests/vc4_purgeable_bo.c

-- 
2.11.0

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

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

* [PATCH i-g-t v2 1/3] igt: Add a helper function to mark BOs purgeable
  2017-10-04 10:22 [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
@ 2017-10-04 10:22 ` Boris Brezillon
  2017-10-04 10:22 ` [PATCH i-g-t v2 2/3] igt: Add igt_vc4_get_param() helper Boris Brezillon
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Boris Brezillon @ 2017-10-04 10:22 UTC (permalink / raw)
  To: Eric Anholt; +Cc: Intel GFX discussion

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
Changes in v2:
- none
---
 lib/igt_vc4.c | 12 ++++++++++++
 lib/igt_vc4.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c
index c4682f5688f1..b75c063204ec 100644
--- a/lib/igt_vc4.c
+++ b/lib/igt_vc4.c
@@ -128,3 +128,15 @@ igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot)
 	else
 		return ptr;
 }
+
+bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable)
+{
+	struct drm_vc4_gem_madvise arg = {
+		.handle = handle,
+		.madv = purgeable ? VC4_MADV_DONTNEED : VC4_MADV_WILLNEED,
+	};
+
+	do_ioctl(fd, DRM_IOCTL_VC4_GEM_MADVISE, &arg);
+
+	return arg.retained;
+}
diff --git a/lib/igt_vc4.h b/lib/igt_vc4.h
index e9252461c951..9f0fc59910f6 100644
--- a/lib/igt_vc4.h
+++ b/lib/igt_vc4.h
@@ -27,5 +27,6 @@
 uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval);
 int igt_vc4_create_bo(int fd, size_t size);
 void *igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot);
+bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable);
 
 #endif /* IGT_VC4_H */
-- 
2.11.0

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

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

* [PATCH i-g-t v2 2/3] igt: Add igt_vc4_get_param() helper
  2017-10-04 10:22 [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
  2017-10-04 10:22 ` [PATCH i-g-t v2 1/3] igt: Add a helper function to mark BOs purgeable Boris Brezillon
@ 2017-10-04 10:22 ` Boris Brezillon
  2017-10-04 10:22 ` [PATCH i-g-t v2 3/3] igt: Add VC4 purgeable BO tests Boris Brezillon
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Boris Brezillon @ 2017-10-04 10:22 UTC (permalink / raw)
  To: Eric Anholt; +Cc: Intel GFX discussion

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
Changes in v2:
- New patch
---
 lib/igt_vc4.c | 15 +++++++++++++++
 lib/igt_vc4.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c
index b75c063204ec..f98c16754c9c 100644
--- a/lib/igt_vc4.c
+++ b/lib/igt_vc4.c
@@ -129,6 +129,21 @@ igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot)
 		return ptr;
 }
 
+int igt_vc4_get_param(int fd, uint32_t param, uint64_t *val)
+{
+	struct drm_vc4_get_param arg = {
+		.param = param,
+	};
+	int ret;
+
+	ret = igt_ioctl(fd, DRM_IOCTL_VC4_GET_PARAM, &arg);
+	if (ret)
+		return ret;
+
+	*val = arg.value;
+	return 0;
+}
+
 bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable)
 {
 	struct drm_vc4_gem_madvise arg = {
diff --git a/lib/igt_vc4.h b/lib/igt_vc4.h
index 9f0fc59910f6..df65017fe397 100644
--- a/lib/igt_vc4.h
+++ b/lib/igt_vc4.h
@@ -27,6 +27,7 @@
 uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval);
 int igt_vc4_create_bo(int fd, size_t size);
 void *igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot);
+int igt_vc4_get_param(int fd, uint32_t param, uint64_t *val);
 bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable);
 
 #endif /* IGT_VC4_H */
-- 
2.11.0

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

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

* [PATCH i-g-t v2 3/3] igt: Add VC4 purgeable BO tests
  2017-10-04 10:22 [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
  2017-10-04 10:22 ` [PATCH i-g-t v2 1/3] igt: Add a helper function to mark BOs purgeable Boris Brezillon
  2017-10-04 10:22 ` [PATCH i-g-t v2 2/3] igt: Add igt_vc4_get_param() helper Boris Brezillon
@ 2017-10-04 10:22 ` Boris Brezillon
  2017-10-19 18:22   ` Eric Anholt
  2017-11-21 18:30   ` Eric Anholt
  2017-10-04 11:29 ` ✓ Fi.CI.BAT: success for igt: Add a testsuite to validate VC4 MADV ioctl (rev3) Patchwork
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 10+ messages in thread
From: Boris Brezillon @ 2017-10-04 10:22 UTC (permalink / raw)
  To: Eric Anholt; +Cc: Intel GFX discussion

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
Changes in v2:
- Add a rule to build vc4 purgeable tests when using Meson (suggested by
  Petri)
- Rework the subtests to avoid uncertainty (suggested by Chris)
- Add a subtest to make sure new BOs have their content retained by
  default (suggested by Chris)
- Make sure we are in a known state before starting a subtest even if
  the previous subtest failed (suggested by Chris)
- Reworked the tests to adjust to the new MADV behavior (WILLNEED no
  longer re-allocated the BO if it's been purged)
- Make the purgeable test dependent on the MADVISE feature (checked
  with the GET_PARAM ioctl)
---
 tests/Makefile.sources   |   1 +
 tests/meson.build        |   1 +
 tests/vc4_purgeable_bo.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 267 insertions(+)
 create mode 100644 tests/vc4_purgeable_bo.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 0adc28a014d2..c78ac9d27921 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -8,6 +8,7 @@ VC4_TESTS = \
 	vc4_create_bo \
 	vc4_dmabuf_poll \
 	vc4_lookup_fail \
+	vc4_purgeable_bo \
 	vc4_wait_bo \
 	vc4_wait_seqno \
 	$(NULL)
diff --git a/tests/meson.build b/tests/meson.build
index 1c619179fe6a..8f94e3c4385b 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -243,6 +243,7 @@ if libdrm_vc4.found()
 		'vc4_create_bo',
 		'vc4_dmabuf_poll',
 		'vc4_lookup_fail',
+		'vc4_purgeable_bo',
 		'vc4_wait_bo',
 		'vc4_wait_seqno',
 	]
diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
new file mode 100644
index 000000000000..b25581cc532e
--- /dev/null
+++ b/tests/vc4_purgeable_bo.c
@@ -0,0 +1,265 @@
+/*
+ * Copyright © 2017 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include "igt_vc4.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include "vc4_drm.h"
+
+struct igt_vc4_bo {
+	struct igt_list node;
+	int handle;
+	void *map;
+	size_t size;
+};
+
+static jmp_buf jmp;
+
+static void __attribute__((noreturn)) sigtrap(int sig)
+{
+	longjmp(jmp, sig);
+}
+
+static void igt_vc4_alloc_mmap_max_bo(int fd, struct igt_list *list,
+				      size_t size)
+{
+	struct igt_vc4_bo *bo;
+	struct drm_vc4_create_bo create = {
+		.size = size,
+	};
+
+	while (true) {
+		if (igt_ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create))
+			break;
+
+		bo = malloc(sizeof(*bo));
+		igt_assert(bo);
+		bo->handle = create.handle;
+		bo->size = create.size;
+		bo->map = igt_vc4_mmap_bo(fd, bo->handle, bo->size,
+					  PROT_READ | PROT_WRITE);
+		igt_list_add_tail(&bo->node, list);
+	}
+}
+
+static void igt_vc4_unmap_free_bo_pool(int fd, struct igt_list *list)
+{
+	struct igt_vc4_bo *bo;
+
+	while (!igt_list_empty(list)) {
+		bo = igt_list_first_entry(list, bo, node);
+		igt_assert(bo);
+		igt_list_del(&bo->node);
+		munmap(bo->map, bo->size);
+		gem_close(fd, bo->handle);
+		free(bo);
+	}
+}
+
+static void igt_vc4_trigger_purge(int fd)
+{
+	struct igt_list list;
+
+	igt_list_init(&list);
+
+	/* Try to allocate as much as we can to trigger a purge. */
+	igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
+	igt_assert(!igt_list_empty(&list));
+	igt_vc4_unmap_free_bo_pool(fd, &list);
+}
+
+static void igt_vc4_purgeable_subtest_prepare(int fd, struct igt_list *list)
+{
+	igt_vc4_unmap_free_bo_pool(fd, list);
+	igt_vc4_alloc_mmap_max_bo(fd, list, 64 * 1024);
+	igt_assert(!igt_list_empty(list));
+}
+
+igt_main
+{
+	struct igt_vc4_bo *bo;
+	struct igt_list list;
+	uint32_t *map;
+	int fd, ret;
+
+	igt_fixture {
+		uint64_t val = 0;
+
+		fd = drm_open_driver(DRIVER_VC4);
+		igt_vc4_get_param(fd, DRM_VC4_PARAM_SUPPORTS_MADVISE, &val);
+		igt_require(val);
+		igt_list_init(&list);
+	}
+
+	igt_subtest("mark-willneed") {
+		igt_vc4_purgeable_subtest_prepare(fd, &list);
+		igt_list_for_each(bo, &list, node)
+			igt_assert(igt_vc4_purgeable_bo(fd, bo->handle,
+							false));
+	}
+
+	igt_subtest("mark-purgeable") {
+		igt_vc4_purgeable_subtest_prepare(fd, &list);
+		igt_list_for_each(bo, &list, node)
+			igt_vc4_purgeable_bo(fd, bo->handle, true);
+
+		igt_list_for_each(bo, &list, node)
+			igt_vc4_purgeable_bo(fd, bo->handle, false);
+	}
+
+	igt_subtest("mark-purgeable-twice") {
+		igt_vc4_purgeable_subtest_prepare(fd, &list);
+		bo = igt_list_first_entry(&list, bo, node);
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+		igt_vc4_purgeable_bo(fd, bo->handle, false);
+	}
+
+	igt_subtest("mark-unpurgeable-twice") {
+		igt_vc4_purgeable_subtest_prepare(fd, &list);
+		bo = igt_list_first_entry(&list, bo, node);
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+		igt_vc4_purgeable_bo(fd, bo->handle, false);
+		igt_vc4_purgeable_bo(fd, bo->handle, false);
+	}
+
+	igt_subtest("access-purgeable-bo-mem") {
+		igt_vc4_purgeable_subtest_prepare(fd, &list);
+		bo = igt_list_first_entry(&list, bo, node);
+		map = (uint32_t *)bo->map;
+
+		/* Mark the BO as purgeable, but do not try to allocate a new
+		 * BO. This should leave the BO in a non-purged state unless
+		 * someone else tries to allocated a new BO.
+		 */
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+
+		/* Accessing a purgeable BO may generate a SIGBUS event if the
+		 * BO has been purged by the system in the meantime.
+		 */
+		signal(SIGSEGV, sigtrap);
+		signal(SIGBUS, sigtrap);
+		ret = setjmp(jmp);
+		if (!ret)
+			*map = 0xdeadbeef;
+		else
+			igt_assert(ret == SIGBUS);
+		signal(SIGBUS, SIG_DFL);
+		signal(SIGSEGV, SIG_DFL);
+	}
+
+	igt_subtest("access-purged-bo-mem") {
+		igt_vc4_purgeable_subtest_prepare(fd, &list);
+
+		/* Mark the first BO in our list as purgeable and try to
+		 * allocate a new one. This should trigger a purge and render
+		 * the first BO inaccessible.
+		 */
+		bo = igt_list_first_entry(&list, bo, node);
+		map = (uint32_t *)bo->map;
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+
+		/* Trigger a purge. */
+		igt_vc4_trigger_purge(fd);
+
+		/* Accessing a purged BO should generate a SIGBUS event. */
+		signal(SIGSEGV, sigtrap);
+		signal(SIGBUS, sigtrap);
+		ret = setjmp(jmp);
+		if (!ret)
+			*map = 0;
+		else
+			igt_assert(ret == SIGBUS);
+		signal(SIGBUS, SIG_DFL);
+		signal(SIGSEGV, SIG_DFL);
+		igt_vc4_purgeable_bo(fd, bo->handle, false);
+	}
+
+	igt_subtest("mark-unpurgeable-check-retained") {
+		igt_vc4_purgeable_subtest_prepare(fd, &list);
+		igt_list_for_each(bo, &list, node) {
+			map = (uint32_t *)bo->map;
+			*map = 0xdeadbeef;
+			igt_vc4_purgeable_bo(fd, bo->handle, true);
+		}
+
+		igt_list_for_each(bo, &list, node) {
+			map = (uint32_t *)bo->map;
+			if (igt_vc4_purgeable_bo(fd, bo->handle, false))
+				igt_assert(*map == 0xdeadbeef);
+		}
+	}
+
+	igt_subtest("mark-unpurgeable-purged") {
+		igt_vc4_purgeable_subtest_prepare(fd, &list);
+
+		igt_list_for_each(bo, &list, node)
+			igt_vc4_purgeable_bo(fd, bo->handle, true);
+
+		/* Trigger a purge. */
+		igt_vc4_trigger_purge(fd);
+
+		bo = igt_list_first_entry(&list, bo, node);
+		map = (uint32_t *)bo->map;
+
+		igt_assert(!igt_vc4_purgeable_bo(fd, bo->handle, false));
+
+		/* Purged BOs are unusable and any access to their
+		 * mmap-ed region should trigger a SIGBUS.
+		 */
+		signal(SIGSEGV, sigtrap);
+		signal(SIGBUS, sigtrap);
+		ret = setjmp(jmp);
+		if (!ret)
+			*map = 0;
+		else
+			igt_assert(ret == SIGBUS);
+		signal(SIGBUS, SIG_DFL);
+		signal(SIGSEGV, SIG_DFL);
+	}
+
+	igt_subtest("free-purged-bo") {
+		igt_vc4_purgeable_subtest_prepare(fd, &list);
+		bo = igt_list_first_entry(&list, bo, node);
+		igt_vc4_purgeable_bo(fd, bo->handle, true);
+
+		/* Trigger a purge. */
+		igt_vc4_trigger_purge(fd);
+
+		igt_list_del(&bo->node);
+		munmap(bo->map, bo->size);
+		gem_close(fd, bo->handle);
+		free(bo);
+	}
+
+	igt_fixture
+		close(fd);
+}
-- 
2.11.0

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

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

* ✓ Fi.CI.BAT: success for igt: Add a testsuite to validate VC4 MADV ioctl (rev3)
  2017-10-04 10:22 [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
                   ` (2 preceding siblings ...)
  2017-10-04 10:22 ` [PATCH i-g-t v2 3/3] igt: Add VC4 purgeable BO tests Boris Brezillon
@ 2017-10-04 11:29 ` Patchwork
  2017-10-04 11:30 ` [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl Chris Wilson
  2017-10-04 12:41 ` ✗ Fi.CI.IGT: warning for igt: Add a testsuite to validate VC4 MADV ioctl (rev3) Patchwork
  5 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2017-10-04 11:29 UTC (permalink / raw)
  To: Petri Latvala; +Cc: intel-gfx

== Series Details ==

Series: igt: Add a testsuite to validate VC4 MADV ioctl (rev3)
URL   : https://patchwork.freedesktop.org/series/30959/
State : success

== Summary ==

IGT patchset tested on top of latest successful build
7c9dccb596b6467899c993a7df5d32574c1b89b9 Fix compilation on some distros

with latest DRM-Tip kernel build CI_DRM_3171
d8f7188551f3 drm-tip: 2017y-10m-04d-08h-46m-00s UTC integration manifest

No testlist changes.

Test kms_busy:
        Subgroup basic-flip-b:
                dmesg-warn -> PASS       (fi-skl-6700hq) fdo#101518
        Subgroup basic-flip-c:
                dmesg-warn -> PASS       (fi-skl-6700k) fdo#103097
Test drv_module_reload:
        Subgroup basic-no-display:
                dmesg-warn -> PASS       (fi-cfl-s) k.org#196765 +1

fdo#101518 https://bugs.freedesktop.org/show_bug.cgi?id=101518
fdo#103097 https://bugs.freedesktop.org/show_bug.cgi?id=103097
k.org#196765 https://bugzilla.kernel.org/show_bug.cgi?id=196765

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:459s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:475s
fi-blb-e6850     total:289  pass:224  dwarn:1   dfail:0   fail:0   skip:64  time:401s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:575s
fi-bwr-2160      total:289  pass:184  dwarn:0   dfail:0   fail:0   skip:105 time:288s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:530s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:536s
fi-byt-j1900     total:289  pass:254  dwarn:1   dfail:0   fail:0   skip:34  time:546s
fi-byt-n2820     total:289  pass:250  dwarn:1   dfail:0   fail:0   skip:38  time:537s
fi-cfl-s         total:289  pass:256  dwarn:1   dfail:0   fail:0   skip:32  time:566s
fi-cnl-y         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:642s
fi-elk-e7500     total:289  pass:230  dwarn:0   dfail:0   fail:0   skip:59  time:442s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:596s
fi-hsw-4770      total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:440s
fi-hsw-4770r     total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:420s
fi-ilk-650       total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:471s
fi-ivb-3520m     total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:513s
fi-ivb-3770      total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:480s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:509s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:582s
fi-kbl-7567u     total:289  pass:265  dwarn:4   dfail:0   fail:0   skip:20  time:491s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:587s
fi-pnv-d510      total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:664s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:469s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:608s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:540s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:521s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:479s
fi-snb-2520m     total:289  pass:251  dwarn:0   dfail:0   fail:0   skip:38  time:585s
fi-snb-2600      total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:434s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_294/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl
  2017-10-04 10:22 [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
                   ` (3 preceding siblings ...)
  2017-10-04 11:29 ` ✓ Fi.CI.BAT: success for igt: Add a testsuite to validate VC4 MADV ioctl (rev3) Patchwork
@ 2017-10-04 11:30 ` Chris Wilson
  2017-10-04 12:41 ` ✗ Fi.CI.IGT: warning for igt: Add a testsuite to validate VC4 MADV ioctl (rev3) Patchwork
  5 siblings, 0 replies; 10+ messages in thread
From: Chris Wilson @ 2017-10-04 11:30 UTC (permalink / raw)
  To: Boris Brezillon, Eric Anholt; +Cc: Intel GFX discussion

Quoting Boris Brezillon (2017-10-04 11:22:18)
> Hello,
>     
> This patchset adds VC4 specific tests to validate the
> DRM_IOCTL_VC4_GEM_MADVISE ioctl.
> 
> Note that this series depends on kernel/libdrm code that has not been
> accepted yet and is just provided to show reviewers how the ioctl can be
> used and what to expect from it.
>     
> Please do not consider this for inclusion in IGT until the kernel and
> libdrm part have been accepted.
> 
> Chris, I still haven't exposed a debugfs file to trigger a purge. I'd
> like to sync with Eric before doing that.
> 
> Eric, I didn't add your "Queue up a big rendering job and mark BO
> purgeable" test (still need to figure out how to do that :-)). That's
> on my TODO list for a v3.
>     
> Thanks,
>     
> Boris
> 
> Boris Brezillon (3):
>   igt: Add a helper function to mark BOs purgeable
>   igt: Add igt_vc4_get_param() helper
>   igt: Add VC4 purgeable BO tests
> 
>  lib/igt_vc4.c            |  27 +++++
>  lib/igt_vc4.h            |   2 +
>  tests/Makefile.sources   |   1 +
>  tests/meson.build        |   1 +
>  tests/vc4_purgeable_bo.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 296 insertions(+)
>  create mode 100644 tests/vc4_purgeable_bo.c
> 
> -- 
> 2.11.0
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✗ Fi.CI.IGT: warning for igt: Add a testsuite to validate VC4 MADV ioctl (rev3)
  2017-10-04 10:22 [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
                   ` (4 preceding siblings ...)
  2017-10-04 11:30 ` [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl Chris Wilson
@ 2017-10-04 12:41 ` Patchwork
  5 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2017-10-04 12:41 UTC (permalink / raw)
  To: Petri Latvala; +Cc: intel-gfx

== Series Details ==

Series: igt: Add a testsuite to validate VC4 MADV ioctl (rev3)
URL   : https://patchwork.freedesktop.org/series/30959/
State : warning

== Summary ==

Test kms_busy:
        Subgroup extended-modeset-hang-oldfb-with-reset-render-B:
                pass       -> DMESG-WARN (shard-hsw) fdo#102249
Test kms_cursor_legacy:
        Subgroup cursorA-vs-flipA-atomic:
                skip       -> PASS       (shard-hsw)
        Subgroup pipe-F-forked-move:
                incomplete -> SKIP       (shard-hsw) fdo#102332 +1
Test kms_draw_crc:
        Subgroup draw-method-xrgb8888-mmap-cpu-untiled:
                skip       -> PASS       (shard-hsw)
Test kms_frontbuffer_tracking:
        Subgroup fbc-1p-primscrn-spr-indfb-draw-blt:
                skip       -> PASS       (shard-hsw)
Test gem_flink_race:
        Subgroup flink_close:
                pass       -> FAIL       (shard-hsw) fdo#102655
Test perf:
        Subgroup polling:
                pass       -> FAIL       (shard-hsw) fdo#102252
Test kms_flip:
        Subgroup vblank-vs-modeset-suspend:
                pass       -> DMESG-WARN (shard-hsw)

fdo#102249 https://bugs.freedesktop.org/show_bug.cgi?id=102249
fdo#102332 https://bugs.freedesktop.org/show_bug.cgi?id=102332
fdo#102655 https://bugs.freedesktop.org/show_bug.cgi?id=102655
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252

shard-hsw        total:2429 pass:1328 dwarn:7   dfail:0   fail:11  skip:1083 time:10230s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_294/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t v2 3/3] igt: Add VC4 purgeable BO tests
  2017-10-04 10:22 ` [PATCH i-g-t v2 3/3] igt: Add VC4 purgeable BO tests Boris Brezillon
@ 2017-10-19 18:22   ` Eric Anholt
  2017-11-21 18:30   ` Eric Anholt
  1 sibling, 0 replies; 10+ messages in thread
From: Eric Anholt @ 2017-10-19 18:22 UTC (permalink / raw)
  To: Boris Brezillon; +Cc: Intel GFX discussion


[-- Attachment #1.1: Type: text/plain, Size: 244 bytes --]

Boris Brezillon <boris.brezillon@free-electrons.com> writes:

> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

I got a build error without including <signal.h>.  Rebased branch with
that changed is "purgeable" in my tree.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

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

* Re: [PATCH i-g-t v2 3/3] igt: Add VC4 purgeable BO tests
  2017-10-04 10:22 ` [PATCH i-g-t v2 3/3] igt: Add VC4 purgeable BO tests Boris Brezillon
  2017-10-19 18:22   ` Eric Anholt
@ 2017-11-21 18:30   ` Eric Anholt
  2017-11-21 19:39     ` Boris Brezillon
  1 sibling, 1 reply; 10+ messages in thread
From: Eric Anholt @ 2017-11-21 18:30 UTC (permalink / raw)
  To: Boris Brezillon; +Cc: Intel GFX discussion


[-- Attachment #1.1: Type: text/plain, Size: 10477 bytes --]

Boris Brezillon <boris.brezillon@free-electrons.com> writes:

> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> Changes in v2:
> - Add a rule to build vc4 purgeable tests when using Meson (suggested by
>   Petri)
> - Rework the subtests to avoid uncertainty (suggested by Chris)
> - Add a subtest to make sure new BOs have their content retained by
>   default (suggested by Chris)
> - Make sure we are in a known state before starting a subtest even if
>   the previous subtest failed (suggested by Chris)
> - Reworked the tests to adjust to the new MADV behavior (WILLNEED no
>   longer re-allocated the BO if it's been purged)
> - Make the purgeable test dependent on the MADVISE feature (checked
>   with the GET_PARAM ioctl)

I've pushed a rebased version of your series as of
f9b0d7ac84b6579c5248357ab45b0a65b27c6e54 up to the "purgeable" branch of
my tree.  Something I noticed as I was reviewing, though...

> ---
>  tests/Makefile.sources   |   1 +
>  tests/meson.build        |   1 +
>  tests/vc4_purgeable_bo.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 267 insertions(+)
>  create mode 100644 tests/vc4_purgeable_bo.c
>
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 0adc28a014d2..c78ac9d27921 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -8,6 +8,7 @@ VC4_TESTS = \
>  	vc4_create_bo \
>  	vc4_dmabuf_poll \
>  	vc4_lookup_fail \
> +	vc4_purgeable_bo \
>  	vc4_wait_bo \
>  	vc4_wait_seqno \
>  	$(NULL)
> diff --git a/tests/meson.build b/tests/meson.build
> index 1c619179fe6a..8f94e3c4385b 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -243,6 +243,7 @@ if libdrm_vc4.found()
>  		'vc4_create_bo',
>  		'vc4_dmabuf_poll',
>  		'vc4_lookup_fail',
> +		'vc4_purgeable_bo',
>  		'vc4_wait_bo',
>  		'vc4_wait_seqno',
>  	]
> diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
> new file mode 100644
> index 000000000000..b25581cc532e
> --- /dev/null
> +++ b/tests/vc4_purgeable_bo.c
> @@ -0,0 +1,265 @@
> +/*
> + * Copyright © 2017 Broadcom
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include "igt.h"
> +#include "igt_vc4.h"
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <fcntl.h>
> +#include <inttypes.h>
> +#include <errno.h>
> +#include <sys/stat.h>
> +#include <sys/ioctl.h>
> +#include "vc4_drm.h"
> +
> +struct igt_vc4_bo {
> +	struct igt_list node;
> +	int handle;
> +	void *map;
> +	size_t size;
> +};
> +
> +static jmp_buf jmp;
> +
> +static void __attribute__((noreturn)) sigtrap(int sig)
> +{
> +	longjmp(jmp, sig);
> +}
> +
> +static void igt_vc4_alloc_mmap_max_bo(int fd, struct igt_list *list,
> +				      size_t size)
> +{
> +	struct igt_vc4_bo *bo;
> +	struct drm_vc4_create_bo create = {
> +		.size = size,
> +	};
> +
> +	while (true) {
> +		if (igt_ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create))
> +			break;
> +
> +		bo = malloc(sizeof(*bo));
> +		igt_assert(bo);
> +		bo->handle = create.handle;
> +		bo->size = create.size;
> +		bo->map = igt_vc4_mmap_bo(fd, bo->handle, bo->size,
> +					  PROT_READ | PROT_WRITE);
> +		igt_list_add_tail(&bo->node, list);
> +	}
> +}
> +
> +static void igt_vc4_unmap_free_bo_pool(int fd, struct igt_list *list)
> +{
> +	struct igt_vc4_bo *bo;
> +
> +	while (!igt_list_empty(list)) {
> +		bo = igt_list_first_entry(list, bo, node);
> +		igt_assert(bo);
> +		igt_list_del(&bo->node);
> +		munmap(bo->map, bo->size);
> +		gem_close(fd, bo->handle);
> +		free(bo);
> +	}
> +}
> +
> +static void igt_vc4_trigger_purge(int fd)
> +{
> +	struct igt_list list;
> +
> +	igt_list_init(&list);
> +
> +	/* Try to allocate as much as we can to trigger a purge. */
> +	igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
> +	igt_assert(!igt_list_empty(&list));
> +	igt_vc4_unmap_free_bo_pool(fd, &list);
> +}
> +
> +static void igt_vc4_purgeable_subtest_prepare(int fd, struct igt_list *list)
> +{
> +	igt_vc4_unmap_free_bo_pool(fd, list);
> +	igt_vc4_alloc_mmap_max_bo(fd, list, 64 * 1024);
> +	igt_assert(!igt_list_empty(list));
> +}
> +
> +igt_main
> +{
> +	struct igt_vc4_bo *bo;
> +	struct igt_list list;
> +	uint32_t *map;
> +	int fd, ret;
> +
> +	igt_fixture {
> +		uint64_t val = 0;
> +
> +		fd = drm_open_driver(DRIVER_VC4);
> +		igt_vc4_get_param(fd, DRM_VC4_PARAM_SUPPORTS_MADVISE, &val);
> +		igt_require(val);
> +		igt_list_init(&list);
> +	}
> +
> +	igt_subtest("mark-willneed") {
> +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> +		igt_list_for_each(bo, &list, node)
> +			igt_assert(igt_vc4_purgeable_bo(fd, bo->handle,
> +							false));
> +	}
> +
> +	igt_subtest("mark-purgeable") {
> +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> +		igt_list_for_each(bo, &list, node)
> +			igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +		igt_list_for_each(bo, &list, node)
> +			igt_vc4_purgeable_bo(fd, bo->handle, false);
> +	}
> +
> +	igt_subtest("mark-purgeable-twice") {
> +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> +		bo = igt_list_first_entry(&list, bo, node);
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> +	}
> +
> +	igt_subtest("mark-unpurgeable-twice") {
> +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> +		bo = igt_list_first_entry(&list, bo, node);
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> +	}
> +
> +	igt_subtest("access-purgeable-bo-mem") {
> +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> +		bo = igt_list_first_entry(&list, bo, node);
> +		map = (uint32_t *)bo->map;
> +
> +		/* Mark the BO as purgeable, but do not try to allocate a new
> +		 * BO. This should leave the BO in a non-purged state unless
> +		 * someone else tries to allocated a new BO.
> +		 */
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +		/* Accessing a purgeable BO may generate a SIGBUS event if the
> +		 * BO has been purged by the system in the meantime.
> +		 */
> +		signal(SIGSEGV, sigtrap);
> +		signal(SIGBUS, sigtrap);
> +		ret = setjmp(jmp);
> +		if (!ret)
> +			*map = 0xdeadbeef;
> +		else
> +			igt_assert(ret == SIGBUS);
> +		signal(SIGBUS, SIG_DFL);
> +		signal(SIGSEGV, SIG_DFL);
> +	}
> +
> +	igt_subtest("access-purged-bo-mem") {
> +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> +
> +		/* Mark the first BO in our list as purgeable and try to
> +		 * allocate a new one. This should trigger a purge and render
> +		 * the first BO inaccessible.
> +		 */
> +		bo = igt_list_first_entry(&list, bo, node);
> +		map = (uint32_t *)bo->map;
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +		/* Trigger a purge. */
> +		igt_vc4_trigger_purge(fd);
> +
> +		/* Accessing a purged BO should generate a SIGBUS event. */
> +		signal(SIGSEGV, sigtrap);
> +		signal(SIGBUS, sigtrap);
> +		ret = setjmp(jmp);
> +		if (!ret)
> +			*map = 0;
> +		else
> +			igt_assert(ret == SIGBUS);

If we didn't take a signal at all, I think this test would exit
successfully, when we don't want it to.  Maybe igt_assert(false) after
the *map = 0?  Do we need a volatile write in that case, to make sure
the compiler doesn't move *map=0 after igt_assert(false)?

> +		signal(SIGBUS, SIG_DFL);
> +		signal(SIGSEGV, SIG_DFL);
> +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> +	}
> +
> +	igt_subtest("mark-unpurgeable-check-retained") {
> +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> +		igt_list_for_each(bo, &list, node) {
> +			map = (uint32_t *)bo->map;
> +			*map = 0xdeadbeef;
> +			igt_vc4_purgeable_bo(fd, bo->handle, true);
> +		}
> +
> +		igt_list_for_each(bo, &list, node) {
> +			map = (uint32_t *)bo->map;
> +			if (igt_vc4_purgeable_bo(fd, bo->handle, false))
> +				igt_assert(*map == 0xdeadbeef);
> +		}
> +	}
> +
> +	igt_subtest("mark-unpurgeable-purged") {
> +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> +
> +		igt_list_for_each(bo, &list, node)
> +			igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +		/* Trigger a purge. */
> +		igt_vc4_trigger_purge(fd);
> +
> +		bo = igt_list_first_entry(&list, bo, node);
> +		map = (uint32_t *)bo->map;
> +
> +		igt_assert(!igt_vc4_purgeable_bo(fd, bo->handle, false));
> +
> +		/* Purged BOs are unusable and any access to their
> +		 * mmap-ed region should trigger a SIGBUS.
> +		 */
> +		signal(SIGSEGV, sigtrap);
> +		signal(SIGBUS, sigtrap);
> +		ret = setjmp(jmp);
> +		if (!ret)
> +			*map = 0;
> +		else
> +			igt_assert(ret == SIGBUS);
> +		signal(SIGBUS, SIG_DFL);
> +		signal(SIGSEGV, SIG_DFL);
> +	}
> +
> +	igt_subtest("free-purged-bo") {
> +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> +		bo = igt_list_first_entry(&list, bo, node);
> +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> +
> +		/* Trigger a purge. */
> +		igt_vc4_trigger_purge(fd);
> +
> +		igt_list_del(&bo->node);
> +		munmap(bo->map, bo->size);
> +		gem_close(fd, bo->handle);
> +		free(bo);
> +	}
> +
> +	igt_fixture
> +		close(fd);
> +}
> -- 
> 2.11.0

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

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

* Re: [PATCH i-g-t v2 3/3] igt: Add VC4 purgeable BO tests
  2017-11-21 18:30   ` Eric Anholt
@ 2017-11-21 19:39     ` Boris Brezillon
  0 siblings, 0 replies; 10+ messages in thread
From: Boris Brezillon @ 2017-11-21 19:39 UTC (permalink / raw)
  To: Eric Anholt; +Cc: Intel GFX discussion

On Tue, 21 Nov 2017 10:30:15 -0800
Eric Anholt <eric@anholt.net> wrote:

> Boris Brezillon <boris.brezillon@free-electrons.com> writes:
> 
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> > Changes in v2:
> > - Add a rule to build vc4 purgeable tests when using Meson (suggested by
> >   Petri)
> > - Rework the subtests to avoid uncertainty (suggested by Chris)
> > - Add a subtest to make sure new BOs have their content retained by
> >   default (suggested by Chris)
> > - Make sure we are in a known state before starting a subtest even if
> >   the previous subtest failed (suggested by Chris)
> > - Reworked the tests to adjust to the new MADV behavior (WILLNEED no
> >   longer re-allocated the BO if it's been purged)
> > - Make the purgeable test dependent on the MADVISE feature (checked
> >   with the GET_PARAM ioctl)  
> 
> I've pushed a rebased version of your series as of
> f9b0d7ac84b6579c5248357ab45b0a65b27c6e54 up to the "purgeable" branch of
> my tree.  Something I noticed as I was reviewing, though...
> 
> > ---
> >  tests/Makefile.sources   |   1 +
> >  tests/meson.build        |   1 +
> >  tests/vc4_purgeable_bo.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 267 insertions(+)
> >  create mode 100644 tests/vc4_purgeable_bo.c
> >
> > diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> > index 0adc28a014d2..c78ac9d27921 100644
> > --- a/tests/Makefile.sources
> > +++ b/tests/Makefile.sources
> > @@ -8,6 +8,7 @@ VC4_TESTS = \
> >  	vc4_create_bo \
> >  	vc4_dmabuf_poll \
> >  	vc4_lookup_fail \
> > +	vc4_purgeable_bo \
> >  	vc4_wait_bo \
> >  	vc4_wait_seqno \
> >  	$(NULL)
> > diff --git a/tests/meson.build b/tests/meson.build
> > index 1c619179fe6a..8f94e3c4385b 100644
> > --- a/tests/meson.build
> > +++ b/tests/meson.build
> > @@ -243,6 +243,7 @@ if libdrm_vc4.found()
> >  		'vc4_create_bo',
> >  		'vc4_dmabuf_poll',
> >  		'vc4_lookup_fail',
> > +		'vc4_purgeable_bo',
> >  		'vc4_wait_bo',
> >  		'vc4_wait_seqno',
> >  	]
> > diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
> > new file mode 100644
> > index 000000000000..b25581cc532e
> > --- /dev/null
> > +++ b/tests/vc4_purgeable_bo.c
> > @@ -0,0 +1,265 @@
> > +/*
> > + * Copyright © 2017 Broadcom
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a
> > + * copy of this software and associated documentation files (the "Software"),
> > + * to deal in the Software without restriction, including without limitation
> > + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including the next
> > + * paragraph) shall be included in all copies or substantial portions of the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> > + * IN THE SOFTWARE.
> > + */
> > +
> > +#include "igt.h"
> > +#include "igt_vc4.h"
> > +#include <unistd.h>
> > +#include <stdlib.h>
> > +#include <stdio.h>
> > +#include <string.h>
> > +#include <fcntl.h>
> > +#include <inttypes.h>
> > +#include <errno.h>
> > +#include <sys/stat.h>
> > +#include <sys/ioctl.h>
> > +#include "vc4_drm.h"
> > +
> > +struct igt_vc4_bo {
> > +	struct igt_list node;
> > +	int handle;
> > +	void *map;
> > +	size_t size;
> > +};
> > +
> > +static jmp_buf jmp;
> > +
> > +static void __attribute__((noreturn)) sigtrap(int sig)
> > +{
> > +	longjmp(jmp, sig);
> > +}
> > +
> > +static void igt_vc4_alloc_mmap_max_bo(int fd, struct igt_list *list,
> > +				      size_t size)
> > +{
> > +	struct igt_vc4_bo *bo;
> > +	struct drm_vc4_create_bo create = {
> > +		.size = size,
> > +	};
> > +
> > +	while (true) {
> > +		if (igt_ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create))
> > +			break;
> > +
> > +		bo = malloc(sizeof(*bo));
> > +		igt_assert(bo);
> > +		bo->handle = create.handle;
> > +		bo->size = create.size;
> > +		bo->map = igt_vc4_mmap_bo(fd, bo->handle, bo->size,
> > +					  PROT_READ | PROT_WRITE);
> > +		igt_list_add_tail(&bo->node, list);
> > +	}
> > +}
> > +
> > +static void igt_vc4_unmap_free_bo_pool(int fd, struct igt_list *list)
> > +{
> > +	struct igt_vc4_bo *bo;
> > +
> > +	while (!igt_list_empty(list)) {
> > +		bo = igt_list_first_entry(list, bo, node);
> > +		igt_assert(bo);
> > +		igt_list_del(&bo->node);
> > +		munmap(bo->map, bo->size);
> > +		gem_close(fd, bo->handle);
> > +		free(bo);
> > +	}
> > +}
> > +
> > +static void igt_vc4_trigger_purge(int fd)
> > +{
> > +	struct igt_list list;
> > +
> > +	igt_list_init(&list);
> > +
> > +	/* Try to allocate as much as we can to trigger a purge. */
> > +	igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
> > +	igt_assert(!igt_list_empty(&list));
> > +	igt_vc4_unmap_free_bo_pool(fd, &list);
> > +}
> > +
> > +static void igt_vc4_purgeable_subtest_prepare(int fd, struct igt_list *list)
> > +{
> > +	igt_vc4_unmap_free_bo_pool(fd, list);
> > +	igt_vc4_alloc_mmap_max_bo(fd, list, 64 * 1024);
> > +	igt_assert(!igt_list_empty(list));
> > +}
> > +
> > +igt_main
> > +{
> > +	struct igt_vc4_bo *bo;
> > +	struct igt_list list;
> > +	uint32_t *map;
> > +	int fd, ret;
> > +
> > +	igt_fixture {
> > +		uint64_t val = 0;
> > +
> > +		fd = drm_open_driver(DRIVER_VC4);
> > +		igt_vc4_get_param(fd, DRM_VC4_PARAM_SUPPORTS_MADVISE, &val);
> > +		igt_require(val);
> > +		igt_list_init(&list);
> > +	}
> > +
> > +	igt_subtest("mark-willneed") {
> > +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> > +		igt_list_for_each(bo, &list, node)
> > +			igt_assert(igt_vc4_purgeable_bo(fd, bo->handle,
> > +							false));
> > +	}
> > +
> > +	igt_subtest("mark-purgeable") {
> > +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> > +		igt_list_for_each(bo, &list, node)
> > +			igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +
> > +		igt_list_for_each(bo, &list, node)
> > +			igt_vc4_purgeable_bo(fd, bo->handle, false);
> > +	}
> > +
> > +	igt_subtest("mark-purgeable-twice") {
> > +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> > +		bo = igt_list_first_entry(&list, bo, node);
> > +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> > +	}
> > +
> > +	igt_subtest("mark-unpurgeable-twice") {
> > +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> > +		bo = igt_list_first_entry(&list, bo, node);
> > +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> > +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> > +	}
> > +
> > +	igt_subtest("access-purgeable-bo-mem") {
> > +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> > +		bo = igt_list_first_entry(&list, bo, node);
> > +		map = (uint32_t *)bo->map;
> > +
> > +		/* Mark the BO as purgeable, but do not try to allocate a new
> > +		 * BO. This should leave the BO in a non-purged state unless
> > +		 * someone else tries to allocated a new BO.
> > +		 */
> > +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +
> > +		/* Accessing a purgeable BO may generate a SIGBUS event if the
> > +		 * BO has been purged by the system in the meantime.
> > +		 */
> > +		signal(SIGSEGV, sigtrap);
> > +		signal(SIGBUS, sigtrap);
> > +		ret = setjmp(jmp);
> > +		if (!ret)
> > +			*map = 0xdeadbeef;
> > +		else
> > +			igt_assert(ret == SIGBUS);
> > +		signal(SIGBUS, SIG_DFL);
> > +		signal(SIGSEGV, SIG_DFL);
> > +	}
> > +
> > +	igt_subtest("access-purged-bo-mem") {
> > +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> > +
> > +		/* Mark the first BO in our list as purgeable and try to
> > +		 * allocate a new one. This should trigger a purge and render
> > +		 * the first BO inaccessible.
> > +		 */
> > +		bo = igt_list_first_entry(&list, bo, node);
> > +		map = (uint32_t *)bo->map;
> > +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +
> > +		/* Trigger a purge. */
> > +		igt_vc4_trigger_purge(fd);
> > +
> > +		/* Accessing a purged BO should generate a SIGBUS event. */
> > +		signal(SIGSEGV, sigtrap);
> > +		signal(SIGBUS, sigtrap);
> > +		ret = setjmp(jmp);
> > +		if (!ret)
> > +			*map = 0;
> > +		else
> > +			igt_assert(ret == SIGBUS);  
> 
> If we didn't take a signal at all, I think this test would exit
> successfully, when we don't want it to.  Maybe igt_assert(false) after
> the *map = 0?

Hm, I think we can get rid of the else and unconditionally execute
igt_assert(ret == SIGBUS).

> Do we need a volatile write in that case, to make sure
> the compiler doesn't move *map=0 after igt_assert(false)?

That's a good question. I'm not even sure making map a volatile
variable would guarantee ordering here.

> 
> > +		signal(SIGBUS, SIG_DFL);
> > +		signal(SIGSEGV, SIG_DFL);
> > +		igt_vc4_purgeable_bo(fd, bo->handle, false);
> > +	}
> > +
> > +	igt_subtest("mark-unpurgeable-check-retained") {
> > +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> > +		igt_list_for_each(bo, &list, node) {
> > +			map = (uint32_t *)bo->map;
> > +			*map = 0xdeadbeef;
> > +			igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +		}
> > +
> > +		igt_list_for_each(bo, &list, node) {
> > +			map = (uint32_t *)bo->map;
> > +			if (igt_vc4_purgeable_bo(fd, bo->handle, false))
> > +				igt_assert(*map == 0xdeadbeef);
> > +		}
> > +	}
> > +
> > +	igt_subtest("mark-unpurgeable-purged") {
> > +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> > +
> > +		igt_list_for_each(bo, &list, node)
> > +			igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +
> > +		/* Trigger a purge. */
> > +		igt_vc4_trigger_purge(fd);
> > +
> > +		bo = igt_list_first_entry(&list, bo, node);
> > +		map = (uint32_t *)bo->map;
> > +
> > +		igt_assert(!igt_vc4_purgeable_bo(fd, bo->handle, false));
> > +
> > +		/* Purged BOs are unusable and any access to their
> > +		 * mmap-ed region should trigger a SIGBUS.
> > +		 */
> > +		signal(SIGSEGV, sigtrap);
> > +		signal(SIGBUS, sigtrap);
> > +		ret = setjmp(jmp);
> > +		if (!ret)
> > +			*map = 0;
> > +		else
> > +			igt_assert(ret == SIGBUS);
> > +		signal(SIGBUS, SIG_DFL);
> > +		signal(SIGSEGV, SIG_DFL);
> > +	}
> > +
> > +	igt_subtest("free-purged-bo") {
> > +		igt_vc4_purgeable_subtest_prepare(fd, &list);
> > +		bo = igt_list_first_entry(&list, bo, node);
> > +		igt_vc4_purgeable_bo(fd, bo->handle, true);
> > +
> > +		/* Trigger a purge. */
> > +		igt_vc4_trigger_purge(fd);
> > +
> > +		igt_list_del(&bo->node);
> > +		munmap(bo->map, bo->size);
> > +		gem_close(fd, bo->handle);
> > +		free(bo);
> > +	}
> > +
> > +	igt_fixture
> > +		close(fd);
> > +}
> > -- 
> > 2.11.0  

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

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

end of thread, other threads:[~2017-11-21 19:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-04 10:22 [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl Boris Brezillon
2017-10-04 10:22 ` [PATCH i-g-t v2 1/3] igt: Add a helper function to mark BOs purgeable Boris Brezillon
2017-10-04 10:22 ` [PATCH i-g-t v2 2/3] igt: Add igt_vc4_get_param() helper Boris Brezillon
2017-10-04 10:22 ` [PATCH i-g-t v2 3/3] igt: Add VC4 purgeable BO tests Boris Brezillon
2017-10-19 18:22   ` Eric Anholt
2017-11-21 18:30   ` Eric Anholt
2017-11-21 19:39     ` Boris Brezillon
2017-10-04 11:29 ` ✓ Fi.CI.BAT: success for igt: Add a testsuite to validate VC4 MADV ioctl (rev3) Patchwork
2017-10-04 11:30 ` [PATCH i-g-t v2 0/3] igt: Add a testsuite to validate VC4 MADV ioctl Chris Wilson
2017-10-04 12:41 ` ✗ Fi.CI.IGT: warning for igt: Add a testsuite to validate VC4 MADV ioctl (rev3) Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.