intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
@ 2016-06-03  8:51 ankitprasad.r.sharma
  2016-06-03  8:51 ` [PATCH 2/3] igt/gem_stolen: Fix for no_mmap subtest ankitprasad.r.sharma
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: ankitprasad.r.sharma @ 2016-06-03  8:51 UTC (permalink / raw)
  To: intel-gfx; +Cc: akash.goel, Ankitprasad Sharma

From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>

This patch verifies if the contents of the stolen backed object were
preserved across hibernation. This is to validate kernel changes related
to moving stolen-backed objects to shmem on hibernation.

v2: Added comment, Use igt_assert_eq() instead of igt_assert(), Made loops
more readable (Tvrtko)

v3: Corrected assertion (Tvrtko)

Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 tests/gem_stolen.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/tests/gem_stolen.c b/tests/gem_stolen.c
index 07fdd39..3a3cf81 100644
--- a/tests/gem_stolen.c
+++ b/tests/gem_stolen.c
@@ -290,6 +290,98 @@ static void stolen_fill_purge_test(int fd)
 		gem_close(fd, handle[i]);
 }
 
+static void stolen_hibernate(int fd)
+{
+	drm_intel_bo *bo;
+	drm_intel_bo *src, *dest;
+	int obj_count = 0, i = 0;
+	int ret, j;
+	uint32_t handle[MAX_OBJECTS], src_handle;
+	uint32_t *virt;
+
+	gem_require_stolen_support(fd);
+
+	src_handle = gem_create(fd, SIZE);
+	src = gem_handle_to_libdrm_bo(bufmgr, fd,
+				     "bo", src_handle);
+	igt_assert(src != NULL);
+
+	ret = drm_intel_gem_bo_map_gtt(src);
+	igt_assert_eq(ret, 0);
+
+	virt = src->virtual;
+	for (j = 0; j < SIZE/DWORD_SIZE; j++) {
+		igt_assert_eq(virt[j], 0);
+		virt[j] = j;
+	}
+
+	drm_intel_bo_unmap(src);
+	/* Exhaust Stolen space */
+	for (i = 0; i < MAX_OBJECTS; i++) {
+		handle[i] = __gem_create_stolen(fd, SIZE);
+		if (!handle[i])
+			break;
+
+		bo = gem_handle_to_libdrm_bo(bufmgr, fd,
+					     "verify_bo", handle[i]);
+		igt_assert(bo != NULL);
+		ret = drm_intel_gem_bo_map_gtt(bo);
+		igt_assert_eq(ret, 0);
+
+		virt = bo->virtual;
+		for (j = 0; j < SIZE/DWORD_SIZE; j++)
+			igt_assert_eq(virt[j], 0);
+
+		drm_intel_bo_unmap(bo);
+		drm_intel_bo_unreference(bo);
+
+		obj_count++;
+	}
+
+	/* Assert if atleast one object is allocated from stolen, that
+	 * is good enough to verify the content preservation across
+	 * hibernation.
+	 */
+	igt_assert(obj_count > 0);
+
+	/* Copy data to all stolen backed objects */
+	for (i = 0; i < obj_count; i++) {
+		dest = gem_handle_to_libdrm_bo(bufmgr, fd,
+					       "dst_bo", handle[i]);
+		igt_assert(dest != NULL);
+		/* Copy contents to stolen backed objects via blt and
+		 * verify post-hibernation, this also helps in identifying
+		 * that the operation was completed before going to
+		 * hibernation.
+		 */
+		intel_copy_bo(batch, dest, src, SIZE);
+	}
+
+	drm_intel_bo_unreference(src);
+
+	igt_system_hibernate_autoresume();
+	/* Check if the object's memory contents are intact
+	 * across hibernation.
+	 */
+	for (i = 0; i < obj_count; i++) {
+		bo = gem_handle_to_libdrm_bo(bufmgr, fd,
+					     "verify_bo", handle[i]);
+		igt_assert(bo != NULL);
+		ret = drm_intel_gem_bo_map_gtt(bo);
+		igt_assert_eq(ret, 0);
+		virt = bo->virtual;
+		for (j = 0; j < SIZE/DWORD_SIZE; j++)
+			igt_assert_eq(virt[j], j);
+
+		drm_intel_bo_unmap(bo);
+		drm_intel_bo_unreference(bo);
+	}
+
+	gem_close(fd, src_handle);
+	for (i = 0; i < obj_count; i++)
+		gem_close(fd, handle[i]);
+}
+
 static void
 stolen_no_mmap(int fd)
 {
@@ -353,6 +445,9 @@ igt_main
 	igt_subtest("stolen-fill-purge")
 		stolen_fill_purge_test(fd);
 
+	igt_subtest("stolen-hibernate")
+		stolen_hibernate(fd);
+
 	igt_fixture {
 		intel_batchbuffer_free(batch);
 		drm_intel_bufmgr_destroy(bufmgr);
-- 
1.9.1

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

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

* [PATCH 2/3] igt/gem_stolen: Fix for no_mmap subtest
  2016-06-03  8:51 [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation ankitprasad.r.sharma
@ 2016-06-03  8:51 ` ankitprasad.r.sharma
  2016-06-03 10:53   ` Tvrtko Ursulin
  2016-06-03  8:51 ` [PATCH 3/3] igt/gem_stolen: Check for available stolen memory size ankitprasad.r.sharma
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: ankitprasad.r.sharma @ 2016-06-03  8:51 UTC (permalink / raw)
  To: intel-gfx; +Cc: akash.goel, Ankitprasad Sharma

From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>

no_mmap subtest is expected to fail, but calling gem_mmap__cpu
will assert the returned value itself, which makes test fail.
Replacing gem_mmap__cpu by __gem_mmap__cpu and checking the
returned value.

Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
---
 tests/gem_stolen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/gem_stolen.c b/tests/gem_stolen.c
index 3a3cf81..7d329dd 100644
--- a/tests/gem_stolen.c
+++ b/tests/gem_stolen.c
@@ -392,7 +392,7 @@ stolen_no_mmap(int fd)
 
 	handle = gem_create_stolen(fd, SIZE);
 
-	addr = gem_mmap__cpu(fd, handle, 0, SIZE, PROT_READ | PROT_WRITE);
+	addr = __gem_mmap__cpu(fd, handle, 0, SIZE, PROT_READ | PROT_WRITE);
 	igt_assert(addr == NULL);
 
 	gem_close(fd, handle);
-- 
1.9.1

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

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

* [PATCH 3/3] igt/gem_stolen: Check for available stolen memory size
  2016-06-03  8:51 [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation ankitprasad.r.sharma
  2016-06-03  8:51 ` [PATCH 2/3] igt/gem_stolen: Fix for no_mmap subtest ankitprasad.r.sharma
@ 2016-06-03  8:51 ` ankitprasad.r.sharma
  2016-06-03 10:58   ` Tvrtko Ursulin
  2016-06-03 10:52 ` [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation Tvrtko Ursulin
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: ankitprasad.r.sharma @ 2016-06-03  8:51 UTC (permalink / raw)
  To: intel-gfx; +Cc: akash.goel, Ankitprasad Sharma

From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>

Check for available stolen memory size before attempting to run
the stolen memory tests. This way we make sure that we do not
create objects from stolen memory without knowing the available size.

This checks if the kernel supports creation of stolen backed objects
before doing any operation on stolen backed objects.

Also correcting the CREATE_VERSION ioctl number in getparam ioctl,
due to kernel changes added in between.

Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
---
 lib/ioctl_wrappers.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 lib/ioctl_wrappers.h |  7 +++++--
 tests/gem_create.c   |  2 +-
 tests/gem_pread.c    |  3 +++
 tests/gem_pwrite.c   |  2 ++
 tests/gem_stolen.c   | 16 ++++++++--------
 6 files changed, 66 insertions(+), 12 deletions(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index f224091..e6120bb 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -455,7 +455,7 @@ bool gem_create__has_stolen_support(int fd)
 
 	if (has_stolen_support < 0) {
 		memset(&gp, 0, sizeof(gp));
-		gp.param = 36; /* CREATE_VERSION */
+		gp.param = 38; /* CREATE_VERSION */
 		gp.value = &val;
 
 		/* Do we have the extended gem_create_ioctl? */
@@ -1230,6 +1230,52 @@ bool gem_has_bsd2(int fd)
 		has_bsd2 = has_param(fd, LOCAL_I915_PARAM_HAS_BSD2);
 	return has_bsd2;
 }
+
+struct local_i915_gem_get_aperture {
+	__u64 aper_size;
+	__u64 aper_available_size;
+	__u64 version;
+	__u64 map_total_size;
+	__u64 stolen_total_size;
+};
+#define DRM_I915_GEM_GET_APERTURE	0x23
+#define LOCAL_IOCTL_I915_GEM_GET_APERTURE DRM_IOR  (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct local_i915_gem_get_aperture)
+/**
+ * gem_total_mappable_size:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query the kernel for the total mappable size.
+ *
+ * Returns: Total mappable address space size.
+ */
+uint64_t gem_total_mappable_size(int fd)
+{
+	struct local_i915_gem_get_aperture aperture;
+
+	memset(&aperture, 0, sizeof(aperture));
+	do_ioctl(fd, LOCAL_IOCTL_I915_GEM_GET_APERTURE, &aperture);
+
+	return aperture.map_total_size;
+}
+
+/**
+ * gem_total_stolen_size:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query the kernel for the total stolen size.
+ *
+ * Returns: Total stolen memory.
+ */
+uint64_t gem_total_stolen_size(int fd)
+{
+	struct local_i915_gem_get_aperture aperture;
+
+	memset(&aperture, 0, sizeof(aperture));
+	do_ioctl(fd, LOCAL_IOCTL_I915_GEM_GET_APERTURE, &aperture);
+
+	return aperture.stolen_total_size;
+}
+
 /**
  * gem_available_aperture_size:
  * @fd: open i915 drm file descriptor
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index f3bd23f..ae04b35 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -93,8 +93,9 @@ void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, un
  * Test macro to query whether support for allocating objects from stolen
  * memory is available. Automatically skips through igt_require() if not.
  */
-#define gem_require_stolen_support(fd) \
-			igt_require(gem_create__has_stolen_support(fd))
+#define gem_require_stolen_support(fd, size) \
+			igt_require(gem_create__has_stolen_support(fd) && \
+				    (gem_total_stolen_size(fd) > size))
 
 /**
  * gem_require_mmap_wc:
@@ -153,6 +154,8 @@ int gem_gtt_type(int fd);
 bool gem_uses_ppgtt(int fd);
 bool gem_uses_full_ppgtt(int fd);
 int gem_available_fences(int fd);
+uint64_t gem_total_mappable_size(int fd);
+uint64_t gem_total_stolen_size(int fd);
 uint64_t gem_available_aperture_size(int fd);
 uint64_t gem_aperture_size(int fd);
 uint64_t gem_global_aperture_size(int fd);
diff --git a/tests/gem_create.c b/tests/gem_create.c
index 25f75d4..b251216 100644
--- a/tests/gem_create.c
+++ b/tests/gem_create.c
@@ -78,7 +78,7 @@ static void invalid_flag_test(int fd)
 {
 	int ret;
 
-	gem_require_stolen_support(fd);
+	gem_require_stolen_support(fd, PAGE_SIZE);
 
 	create.handle = 0;
 	create.size = PAGE_SIZE;
diff --git a/tests/gem_pread.c b/tests/gem_pread.c
index afa072d..3da8bed 100644
--- a/tests/gem_pread.c
+++ b/tests/gem_pread.c
@@ -152,6 +152,7 @@ int main(int argc, char **argv)
 	}
 
 	igt_subtest("stolen-normal") {
+		gem_require_stolen_support(fd, OBJECT_SIZE);
 		for (count = 1; count <= 1<<17; count <<= 1) {
 			struct timeval start, end;
 
@@ -167,6 +168,7 @@ int main(int argc, char **argv)
 	}
 	for (c = cache; c->level != -1; c++) {
 		igt_subtest_f("stolen-%s", c->name) {
+			gem_require_stolen_support(fd, OBJECT_SIZE);
 			gem_set_caching(fd, src_stolen, c->level);
 
 			for (count = 1; count <= 1<<17; count <<= 1) {
@@ -190,6 +192,7 @@ int main(int argc, char **argv)
 	 * user space buffer
 	 */
 	igt_subtest("pagefault-pread") {
+		gem_require_stolen_support(fd, LARGE_OBJECT_SIZE);
 		large_stolen = gem_create_stolen(fd, LARGE_OBJECT_SIZE);
 		stolen_nopf_user = (uint32_t *) mmap(NULL, LARGE_OBJECT_SIZE,
 						PROT_WRITE,
diff --git a/tests/gem_pwrite.c b/tests/gem_pwrite.c
index a322f91..de720c5 100644
--- a/tests/gem_pwrite.c
+++ b/tests/gem_pwrite.c
@@ -280,6 +280,7 @@ int main(int argc, char **argv)
 	}
 
 	igt_subtest("stolen-normal") {
+		gem_require_stolen_support(fd, OBJECT_SIZE);
 		for (count = 1; count <= 1<<17; count <<= 1) {
 			struct timeval start, end;
 
@@ -297,6 +298,7 @@ int main(int argc, char **argv)
 
 	for (c = cache; c->level != -1; c++) {
 		igt_subtest_f("stolen-%s", c->name) {
+			gem_require_stolen_support(fd, OBJECT_SIZE);
 			gem_set_caching(fd, dst, c->level);
 			for (count = 1; count <= 1<<17; count <<= 1) {
 				struct timeval start, end;
diff --git a/tests/gem_stolen.c b/tests/gem_stolen.c
index 7d329dd..541585b 100644
--- a/tests/gem_stolen.c
+++ b/tests/gem_stolen.c
@@ -105,7 +105,7 @@ static void stolen_pwrite(int fd)
 	for (i = 0; i < SIZE/DWORD_SIZE; i++)
 		buf[i] = DATA;
 
-	gem_require_stolen_support(fd);
+	gem_require_stolen_support(fd, SIZE);
 
 	handle = gem_create_stolen(fd, SIZE);
 
@@ -135,7 +135,7 @@ static void stolen_pread(int fd)
 
 	CLEAR(buf);
 
-	gem_require_stolen_support(fd);
+	gem_require_stolen_support(fd, SIZE);
 
 	handle = gem_create_stolen(fd, SIZE);
 
@@ -165,7 +165,7 @@ static void copy_test(int fd)
 	drm_intel_bo *src, *dest;
 	uint32_t src_handle = 0, dest_handle = 0;
 
-	gem_require_stolen_support(fd);
+	gem_require_stolen_support(fd, SIZE);
 
 	src_handle = gem_create_stolen(fd, SIZE);
 	dest_handle = gem_create_stolen(fd, SIZE);
@@ -191,7 +191,7 @@ static void verify_object_clear(int fd)
 	uint32_t *virt;
 	int i, ret;
 
-	gem_require_stolen_support(fd);
+	gem_require_stolen_support(fd, SIZE);
 
 	handle = gem_create_stolen(fd, SIZE);
 
@@ -215,7 +215,7 @@ static void stolen_large_obj_alloc(int fd)
 {
 	uint32_t handle = 0;
 
-	gem_require_stolen_support(fd);
+	gem_require_stolen_support(fd, SIZE);
 	handle = __gem_create_stolen(fd, (unsigned long long) LARGE_SIZE + 4096);
 	igt_assert(!handle);
 }
@@ -230,7 +230,7 @@ static void stolen_fill_purge_test(int fd)
 	uint32_t *virt;
 	int retained;
 
-	gem_require_stolen_support(fd);
+	gem_require_stolen_support(fd, SIZE);
 
 	/* Exhaust Stolen space */
 	do {
@@ -299,7 +299,7 @@ static void stolen_hibernate(int fd)
 	uint32_t handle[MAX_OBJECTS], src_handle;
 	uint32_t *virt;
 
-	gem_require_stolen_support(fd);
+	gem_require_stolen_support(fd, SIZE);
 
 	src_handle = gem_create(fd, SIZE);
 	src = gem_handle_to_libdrm_bo(bufmgr, fd,
@@ -388,7 +388,7 @@ stolen_no_mmap(int fd)
 	void *addr;
 	uint32_t handle = 0;
 
-	gem_require_stolen_support(fd);
+	gem_require_stolen_support(fd, SIZE);
 
 	handle = gem_create_stolen(fd, SIZE);
 
-- 
1.9.1

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

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

* Re: [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
  2016-06-03  8:51 [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation ankitprasad.r.sharma
  2016-06-03  8:51 ` [PATCH 2/3] igt/gem_stolen: Fix for no_mmap subtest ankitprasad.r.sharma
  2016-06-03  8:51 ` [PATCH 3/3] igt/gem_stolen: Check for available stolen memory size ankitprasad.r.sharma
@ 2016-06-03 10:52 ` Tvrtko Ursulin
  2016-06-03 11:32 ` ✗ Ro.CI.BAT: failure for series starting with [1/3] " Patchwork
  2016-06-03 11:39 ` Patchwork
  4 siblings, 0 replies; 9+ messages in thread
From: Tvrtko Ursulin @ 2016-06-03 10:52 UTC (permalink / raw)
  To: ankitprasad.r.sharma, intel-gfx; +Cc: akash.goel


On 03/06/16 09:51, ankitprasad.r.sharma@intel.com wrote:
> From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
>
> This patch verifies if the contents of the stolen backed object were
> preserved across hibernation. This is to validate kernel changes related
> to moving stolen-backed objects to shmem on hibernation.
>
> v2: Added comment, Use igt_assert_eq() instead of igt_assert(), Made loops
> more readable (Tvrtko)
>
> v3: Corrected assertion (Tvrtko)
>
> Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   tests/gem_stolen.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 95 insertions(+)
>
> diff --git a/tests/gem_stolen.c b/tests/gem_stolen.c
> index 07fdd39..3a3cf81 100644
> --- a/tests/gem_stolen.c
> +++ b/tests/gem_stolen.c
> @@ -290,6 +290,98 @@ static void stolen_fill_purge_test(int fd)
>   		gem_close(fd, handle[i]);
>   }
>
> +static void stolen_hibernate(int fd)
> +{
> +	drm_intel_bo *bo;
> +	drm_intel_bo *src, *dest;
> +	int obj_count = 0, i = 0;
> +	int ret, j;
> +	uint32_t handle[MAX_OBJECTS], src_handle;
> +	uint32_t *virt;
> +
> +	gem_require_stolen_support(fd);
> +
> +	src_handle = gem_create(fd, SIZE);
> +	src = gem_handle_to_libdrm_bo(bufmgr, fd,
> +				     "bo", src_handle);
> +	igt_assert(src != NULL);
> +
> +	ret = drm_intel_gem_bo_map_gtt(src);
> +	igt_assert_eq(ret, 0);
> +
> +	virt = src->virtual;
> +	for (j = 0; j < SIZE/DWORD_SIZE; j++) {
> +		igt_assert_eq(virt[j], 0);
> +		virt[j] = j;
> +	}
> +
> +	drm_intel_bo_unmap(src);
> +	/* Exhaust Stolen space */
> +	for (i = 0; i < MAX_OBJECTS; i++) {
> +		handle[i] = __gem_create_stolen(fd, SIZE);
> +		if (!handle[i])
> +			break;
> +
> +		bo = gem_handle_to_libdrm_bo(bufmgr, fd,
> +					     "verify_bo", handle[i]);
> +		igt_assert(bo != NULL);
> +		ret = drm_intel_gem_bo_map_gtt(bo);
> +		igt_assert_eq(ret, 0);
> +
> +		virt = bo->virtual;
> +		for (j = 0; j < SIZE/DWORD_SIZE; j++)
> +			igt_assert_eq(virt[j], 0);
> +
> +		drm_intel_bo_unmap(bo);
> +		drm_intel_bo_unreference(bo);
> +
> +		obj_count++;
> +	}
> +
> +	/* Assert if atleast one object is allocated from stolen, that
> +	 * is good enough to verify the content preservation across
> +	 * hibernation.
> +	 */
> +	igt_assert(obj_count > 0);
> +
> +	/* Copy data to all stolen backed objects */
> +	for (i = 0; i < obj_count; i++) {
> +		dest = gem_handle_to_libdrm_bo(bufmgr, fd,
> +					       "dst_bo", handle[i]);
> +		igt_assert(dest != NULL);
> +		/* Copy contents to stolen backed objects via blt and
> +		 * verify post-hibernation, this also helps in identifying
> +		 * that the operation was completed before going to
> +		 * hibernation.
> +		 */
> +		intel_copy_bo(batch, dest, src, SIZE);
> +	}
> +
> +	drm_intel_bo_unreference(src);
> +
> +	igt_system_hibernate_autoresume();
> +	/* Check if the object's memory contents are intact
> +	 * across hibernation.
> +	 */
> +	for (i = 0; i < obj_count; i++) {
> +		bo = gem_handle_to_libdrm_bo(bufmgr, fd,
> +					     "verify_bo", handle[i]);
> +		igt_assert(bo != NULL);
> +		ret = drm_intel_gem_bo_map_gtt(bo);
> +		igt_assert_eq(ret, 0);
> +		virt = bo->virtual;
> +		for (j = 0; j < SIZE/DWORD_SIZE; j++)
> +			igt_assert_eq(virt[j], j);
> +
> +		drm_intel_bo_unmap(bo);
> +		drm_intel_bo_unreference(bo);
> +	}
> +
> +	gem_close(fd, src_handle);
> +	for (i = 0; i < obj_count; i++)
> +		gem_close(fd, handle[i]);
> +}
> +
>   static void
>   stolen_no_mmap(int fd)
>   {
> @@ -353,6 +445,9 @@ igt_main
>   	igt_subtest("stolen-fill-purge")
>   		stolen_fill_purge_test(fd);
>
> +	igt_subtest("stolen-hibernate")
> +		stolen_hibernate(fd);
> +
>   	igt_fixture {
>   		intel_batchbuffer_free(batch);
>   		drm_intel_bufmgr_destroy(bufmgr);
>

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

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

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

* Re: [PATCH 2/3] igt/gem_stolen: Fix for no_mmap subtest
  2016-06-03  8:51 ` [PATCH 2/3] igt/gem_stolen: Fix for no_mmap subtest ankitprasad.r.sharma
@ 2016-06-03 10:53   ` Tvrtko Ursulin
  0 siblings, 0 replies; 9+ messages in thread
From: Tvrtko Ursulin @ 2016-06-03 10:53 UTC (permalink / raw)
  To: ankitprasad.r.sharma, intel-gfx; +Cc: akash.goel


On 03/06/16 09:51, ankitprasad.r.sharma@intel.com wrote:
> From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
>
> no_mmap subtest is expected to fail, but calling gem_mmap__cpu
> will assert the returned value itself, which makes test fail.
> Replacing gem_mmap__cpu by __gem_mmap__cpu and checking the
> returned value.
>
> Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
> ---
>   tests/gem_stolen.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/gem_stolen.c b/tests/gem_stolen.c
> index 3a3cf81..7d329dd 100644
> --- a/tests/gem_stolen.c
> +++ b/tests/gem_stolen.c
> @@ -392,7 +392,7 @@ stolen_no_mmap(int fd)
>
>   	handle = gem_create_stolen(fd, SIZE);
>
> -	addr = gem_mmap__cpu(fd, handle, 0, SIZE, PROT_READ | PROT_WRITE);
> +	addr = __gem_mmap__cpu(fd, handle, 0, SIZE, PROT_READ | PROT_WRITE);
>   	igt_assert(addr == NULL);
>
>   	gem_close(fd, handle);
>

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

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

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

* Re: [PATCH 3/3] igt/gem_stolen: Check for available stolen memory size
  2016-06-03  8:51 ` [PATCH 3/3] igt/gem_stolen: Check for available stolen memory size ankitprasad.r.sharma
@ 2016-06-03 10:58   ` Tvrtko Ursulin
  2016-06-06  9:25     ` Ankitprasad Sharma
  0 siblings, 1 reply; 9+ messages in thread
From: Tvrtko Ursulin @ 2016-06-03 10:58 UTC (permalink / raw)
  To: ankitprasad.r.sharma, intel-gfx; +Cc: akash.goel


On 03/06/16 09:51, ankitprasad.r.sharma@intel.com wrote:
> From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
>
> Check for available stolen memory size before attempting to run
> the stolen memory tests. This way we make sure that we do not
> create objects from stolen memory without knowing the available size.
>
> This checks if the kernel supports creation of stolen backed objects
> before doing any operation on stolen backed objects.
>
> Also correcting the CREATE_VERSION ioctl number in getparam ioctl,
> due to kernel changes added in between.
>
> Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
> ---
>   lib/ioctl_wrappers.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>   lib/ioctl_wrappers.h |  7 +++++--
>   tests/gem_create.c   |  2 +-
>   tests/gem_pread.c    |  3 +++
>   tests/gem_pwrite.c   |  2 ++
>   tests/gem_stolen.c   | 16 ++++++++--------
>   6 files changed, 66 insertions(+), 12 deletions(-)
>
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index f224091..e6120bb 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -455,7 +455,7 @@ bool gem_create__has_stolen_support(int fd)
>
>   	if (has_stolen_support < 0) {
>   		memset(&gp, 0, sizeof(gp));
> -		gp.param = 36; /* CREATE_VERSION */
> +		gp.param = 38; /* CREATE_VERSION */
>   		gp.value = &val;
>
>   		/* Do we have the extended gem_create_ioctl? */
> @@ -1230,6 +1230,52 @@ bool gem_has_bsd2(int fd)
>   		has_bsd2 = has_param(fd, LOCAL_I915_PARAM_HAS_BSD2);
>   	return has_bsd2;
>   }
> +
> +struct local_i915_gem_get_aperture {
> +	__u64 aper_size;
> +	__u64 aper_available_size;
> +	__u64 version;
> +	__u64 map_total_size;
> +	__u64 stolen_total_size;
> +};
> +#define DRM_I915_GEM_GET_APERTURE	0x23
> +#define LOCAL_IOCTL_I915_GEM_GET_APERTURE DRM_IOR  (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct local_i915_gem_get_aperture)
> +/**
> + * gem_total_mappable_size:
> + * @fd: open i915 drm file descriptor
> + *
> + * Feature test macro to query the kernel for the total mappable size.

Minor: it is not a feature test nor a macro.

> + *
> + * Returns: Total mappable address space size.
> + */
> +uint64_t gem_total_mappable_size(int fd)
> +{
> +	struct local_i915_gem_get_aperture aperture;
> +
> +	memset(&aperture, 0, sizeof(aperture));
> +	do_ioctl(fd, LOCAL_IOCTL_I915_GEM_GET_APERTURE, &aperture);
> +
> +	return aperture.map_total_size;
> +}
> +
> +/**
> + * gem_total_stolen_size:
> + * @fd: open i915 drm file descriptor
> + *
> + * Feature test macro to query the kernel for the total stolen size.

Same here.

> + *
> + * Returns: Total stolen memory.
> + */
> +uint64_t gem_total_stolen_size(int fd)
> +{
> +	struct local_i915_gem_get_aperture aperture;
> +
> +	memset(&aperture, 0, sizeof(aperture));
> +	do_ioctl(fd, LOCAL_IOCTL_I915_GEM_GET_APERTURE, &aperture);
> +
> +	return aperture.stolen_total_size;
> +}
> +
>   /**
>    * gem_available_aperture_size:
>    * @fd: open i915 drm file descriptor
> diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
> index f3bd23f..ae04b35 100644
> --- a/lib/ioctl_wrappers.h
> +++ b/lib/ioctl_wrappers.h
> @@ -93,8 +93,9 @@ void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, un
>    * Test macro to query whether support for allocating objects from stolen
>    * memory is available. Automatically skips through igt_require() if not.
>    */
> -#define gem_require_stolen_support(fd) \
> -			igt_require(gem_create__has_stolen_support(fd))
> +#define gem_require_stolen_support(fd, size) \
> +			igt_require(gem_create__has_stolen_support(fd) && \
> +				    (gem_total_stolen_size(fd) > size))

Looks like a needless complication to pass in a size, this should only 
be about is it supported or not. How the test uses it is even stranger, 
it is not likely (or even possible) some platform will have a PAGE_SIZE 
of stolen but not OBJECT_SIZE or something. I suggest you just drop the 
size param.

>
>   /**
>    * gem_require_mmap_wc:
> @@ -153,6 +154,8 @@ int gem_gtt_type(int fd);
>   bool gem_uses_ppgtt(int fd);
>   bool gem_uses_full_ppgtt(int fd);
>   int gem_available_fences(int fd);
> +uint64_t gem_total_mappable_size(int fd);
> +uint64_t gem_total_stolen_size(int fd);
>   uint64_t gem_available_aperture_size(int fd);
>   uint64_t gem_aperture_size(int fd);
>   uint64_t gem_global_aperture_size(int fd);
> diff --git a/tests/gem_create.c b/tests/gem_create.c
> index 25f75d4..b251216 100644
> --- a/tests/gem_create.c
> +++ b/tests/gem_create.c
> @@ -78,7 +78,7 @@ static void invalid_flag_test(int fd)
>   {
>   	int ret;
>
> -	gem_require_stolen_support(fd);
> +	gem_require_stolen_support(fd, PAGE_SIZE);
>
>   	create.handle = 0;
>   	create.size = PAGE_SIZE;
> diff --git a/tests/gem_pread.c b/tests/gem_pread.c
> index afa072d..3da8bed 100644
> --- a/tests/gem_pread.c
> +++ b/tests/gem_pread.c
> @@ -152,6 +152,7 @@ int main(int argc, char **argv)
>   	}
>
>   	igt_subtest("stolen-normal") {
> +		gem_require_stolen_support(fd, OBJECT_SIZE);
>   		for (count = 1; count <= 1<<17; count <<= 1) {
>   			struct timeval start, end;
>
> @@ -167,6 +168,7 @@ int main(int argc, char **argv)
>   	}
>   	for (c = cache; c->level != -1; c++) {
>   		igt_subtest_f("stolen-%s", c->name) {
> +			gem_require_stolen_support(fd, OBJECT_SIZE);
>   			gem_set_caching(fd, src_stolen, c->level);
>
>   			for (count = 1; count <= 1<<17; count <<= 1) {
> @@ -190,6 +192,7 @@ int main(int argc, char **argv)
>   	 * user space buffer
>   	 */
>   	igt_subtest("pagefault-pread") {
> +		gem_require_stolen_support(fd, LARGE_OBJECT_SIZE);
>   		large_stolen = gem_create_stolen(fd, LARGE_OBJECT_SIZE);
>   		stolen_nopf_user = (uint32_t *) mmap(NULL, LARGE_OBJECT_SIZE,
>   						PROT_WRITE,
> diff --git a/tests/gem_pwrite.c b/tests/gem_pwrite.c
> index a322f91..de720c5 100644
> --- a/tests/gem_pwrite.c
> +++ b/tests/gem_pwrite.c
> @@ -280,6 +280,7 @@ int main(int argc, char **argv)
>   	}
>
>   	igt_subtest("stolen-normal") {
> +		gem_require_stolen_support(fd, OBJECT_SIZE);
>   		for (count = 1; count <= 1<<17; count <<= 1) {
>   			struct timeval start, end;
>
> @@ -297,6 +298,7 @@ int main(int argc, char **argv)
>
>   	for (c = cache; c->level != -1; c++) {
>   		igt_subtest_f("stolen-%s", c->name) {
> +			gem_require_stolen_support(fd, OBJECT_SIZE);
>   			gem_set_caching(fd, dst, c->level);
>   			for (count = 1; count <= 1<<17; count <<= 1) {
>   				struct timeval start, end;
> diff --git a/tests/gem_stolen.c b/tests/gem_stolen.c
> index 7d329dd..541585b 100644
> --- a/tests/gem_stolen.c
> +++ b/tests/gem_stolen.c
> @@ -105,7 +105,7 @@ static void stolen_pwrite(int fd)
>   	for (i = 0; i < SIZE/DWORD_SIZE; i++)
>   		buf[i] = DATA;
>
> -	gem_require_stolen_support(fd);
> +	gem_require_stolen_support(fd, SIZE);
>
>   	handle = gem_create_stolen(fd, SIZE);
>
> @@ -135,7 +135,7 @@ static void stolen_pread(int fd)
>
>   	CLEAR(buf);
>
> -	gem_require_stolen_support(fd);
> +	gem_require_stolen_support(fd, SIZE);
>
>   	handle = gem_create_stolen(fd, SIZE);
>
> @@ -165,7 +165,7 @@ static void copy_test(int fd)
>   	drm_intel_bo *src, *dest;
>   	uint32_t src_handle = 0, dest_handle = 0;
>
> -	gem_require_stolen_support(fd);
> +	gem_require_stolen_support(fd, SIZE);
>
>   	src_handle = gem_create_stolen(fd, SIZE);
>   	dest_handle = gem_create_stolen(fd, SIZE);
> @@ -191,7 +191,7 @@ static void verify_object_clear(int fd)
>   	uint32_t *virt;
>   	int i, ret;
>
> -	gem_require_stolen_support(fd);
> +	gem_require_stolen_support(fd, SIZE);
>
>   	handle = gem_create_stolen(fd, SIZE);
>
> @@ -215,7 +215,7 @@ static void stolen_large_obj_alloc(int fd)
>   {
>   	uint32_t handle = 0;
>
> -	gem_require_stolen_support(fd);
> +	gem_require_stolen_support(fd, SIZE);
>   	handle = __gem_create_stolen(fd, (unsigned long long) LARGE_SIZE + 4096);
>   	igt_assert(!handle);
>   }
> @@ -230,7 +230,7 @@ static void stolen_fill_purge_test(int fd)
>   	uint32_t *virt;
>   	int retained;
>
> -	gem_require_stolen_support(fd);
> +	gem_require_stolen_support(fd, SIZE);
>
>   	/* Exhaust Stolen space */
>   	do {
> @@ -299,7 +299,7 @@ static void stolen_hibernate(int fd)
>   	uint32_t handle[MAX_OBJECTS], src_handle;
>   	uint32_t *virt;
>
> -	gem_require_stolen_support(fd);
> +	gem_require_stolen_support(fd, SIZE);
>
>   	src_handle = gem_create(fd, SIZE);
>   	src = gem_handle_to_libdrm_bo(bufmgr, fd,
> @@ -388,7 +388,7 @@ stolen_no_mmap(int fd)
>   	void *addr;
>   	uint32_t handle = 0;
>
> -	gem_require_stolen_support(fd);
> +	gem_require_stolen_support(fd, SIZE);
>
>   	handle = gem_create_stolen(fd, SIZE);
>
>

Regards,

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

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

* ✗ Ro.CI.BAT: failure for series starting with [1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
  2016-06-03  8:51 [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation ankitprasad.r.sharma
                   ` (2 preceding siblings ...)
  2016-06-03 10:52 ` [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation Tvrtko Ursulin
@ 2016-06-03 11:32 ` Patchwork
  2016-06-03 11:39 ` Patchwork
  4 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2016-06-03 11:32 UTC (permalink / raw)
  To: ankitprasad.r.sharma; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
URL   : https://patchwork.freedesktop.org/series/8210/
State : failure

== Summary ==

Applying: igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
Patch failed at 0001 igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

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

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

* ✗ Ro.CI.BAT: failure for series starting with [1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
  2016-06-03  8:51 [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation ankitprasad.r.sharma
                   ` (3 preceding siblings ...)
  2016-06-03 11:32 ` ✗ Ro.CI.BAT: failure for series starting with [1/3] " Patchwork
@ 2016-06-03 11:39 ` Patchwork
  4 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2016-06-03 11:39 UTC (permalink / raw)
  To: ankitprasad.r.sharma; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
URL   : https://patchwork.freedesktop.org/series/8210/
State : failure

== Summary ==

Applying: igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
fatal: sha1 information is lacking or useless (tests/gem_stolen.c).
error: could not build fake ancestor
Patch failed at 0001 igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

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

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

* Re: [PATCH 3/3] igt/gem_stolen: Check for available stolen memory size
  2016-06-03 10:58   ` Tvrtko Ursulin
@ 2016-06-06  9:25     ` Ankitprasad Sharma
  0 siblings, 0 replies; 9+ messages in thread
From: Ankitprasad Sharma @ 2016-06-06  9:25 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx, akash.goel

On Fri, 2016-06-03 at 11:58 +0100, Tvrtko Ursulin wrote:
> On 03/06/16 09:51, ankitprasad.r.sharma@intel.com wrote:
> > From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
> >
> > Check for available stolen memory size before attempting to run
> > the stolen memory tests. This way we make sure that we do not
> > create objects from stolen memory without knowing the available size.
> >
> > This checks if the kernel supports creation of stolen backed objects
> > before doing any operation on stolen backed objects.
> >
> > Also correcting the CREATE_VERSION ioctl number in getparam ioctl,
> > due to kernel changes added in between.
> >
> > Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
> > ---
> >   lib/ioctl_wrappers.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
> >   lib/ioctl_wrappers.h |  7 +++++--
> >   tests/gem_create.c   |  2 +-
> >   tests/gem_pread.c    |  3 +++
> >   tests/gem_pwrite.c   |  2 ++
> >   tests/gem_stolen.c   | 16 ++++++++--------
> >   6 files changed, 66 insertions(+), 12 deletions(-)
> >
> > diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> > index f224091..e6120bb 100644
> > --- a/lib/ioctl_wrappers.c
> > +++ b/lib/ioctl_wrappers.c
> > @@ -455,7 +455,7 @@ bool gem_create__has_stolen_support(int fd)
> >
> >   	if (has_stolen_support < 0) {
> >   		memset(&gp, 0, sizeof(gp));
> > -		gp.param = 36; /* CREATE_VERSION */
> > +		gp.param = 38; /* CREATE_VERSION */
> >   		gp.value = &val;
> >
> >   		/* Do we have the extended gem_create_ioctl? */
> > @@ -1230,6 +1230,52 @@ bool gem_has_bsd2(int fd)
> >   		has_bsd2 = has_param(fd, LOCAL_I915_PARAM_HAS_BSD2);
> >   	return has_bsd2;
> >   }
> > +
> > +struct local_i915_gem_get_aperture {
> > +	__u64 aper_size;
> > +	__u64 aper_available_size;
> > +	__u64 version;
> > +	__u64 map_total_size;
> > +	__u64 stolen_total_size;
> > +};
> > +#define DRM_I915_GEM_GET_APERTURE	0x23
> > +#define LOCAL_IOCTL_I915_GEM_GET_APERTURE DRM_IOR  (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct local_i915_gem_get_aperture)
> > +/**
> > + * gem_total_mappable_size:
> > + * @fd: open i915 drm file descriptor
> > + *
> > + * Feature test macro to query the kernel for the total mappable size.
> 
> Minor: it is not a feature test nor a macro.
I have just added this to maintain consistency among other helper
functions. You want me to change it?

Thanks,
Ankit

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

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

end of thread, other threads:[~2016-06-06  9:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-03  8:51 [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation ankitprasad.r.sharma
2016-06-03  8:51 ` [PATCH 2/3] igt/gem_stolen: Fix for no_mmap subtest ankitprasad.r.sharma
2016-06-03 10:53   ` Tvrtko Ursulin
2016-06-03  8:51 ` [PATCH 3/3] igt/gem_stolen: Check for available stolen memory size ankitprasad.r.sharma
2016-06-03 10:58   ` Tvrtko Ursulin
2016-06-06  9:25     ` Ankitprasad Sharma
2016-06-03 10:52 ` [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation Tvrtko Ursulin
2016-06-03 11:32 ` ✗ Ro.CI.BAT: failure for series starting with [1/3] " Patchwork
2016-06-03 11:39 ` Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).