intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] igt/gem_stolen: Check for available stolen memory size
@ 2016-06-06  9:22 ankitprasad.r.sharma
  2016-06-06  9:59 ` Tvrtko Ursulin
  2016-06-06 10:45 ` ✗ Ro.CI.BAT: failure for " Patchwork
  0 siblings, 2 replies; 3+ messages in thread
From: ankitprasad.r.sharma @ 2016-06-06  9:22 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.

v2: Removed size argument for checking stolen memory availability (Tvrtko)

Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
---
 lib/ioctl_wrappers.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 lib/ioctl_wrappers.h |  5 ++++-
 tests/gem_pread.c    |  3 +++
 tests/gem_pwrite.c   |  2 ++
 4 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index f224091..818853e 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..0d42ba9 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -94,7 +94,8 @@ void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, un
  * memory is available. Automatically skips through igt_require() if not.
  */
 #define gem_require_stolen_support(fd) \
-			igt_require(gem_create__has_stolen_support(fd))
+			igt_require(gem_create__has_stolen_support(fd) && \
+				    (gem_total_stolen_size(fd) > 0))
 
 /**
  * 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_pread.c b/tests/gem_pread.c
index afa072d..f4cf472 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);
 		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);
 			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_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..8db5454 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);
 		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);
 			gem_set_caching(fd, dst, c->level);
 			for (count = 1; count <= 1<<17; count <<= 1) {
 				struct timeval start, end;
-- 
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] 3+ messages in thread

* Re: [PATCH] igt/gem_stolen: Check for available stolen memory size
  2016-06-06  9:22 [PATCH] igt/gem_stolen: Check for available stolen memory size ankitprasad.r.sharma
@ 2016-06-06  9:59 ` Tvrtko Ursulin
  2016-06-06 10:45 ` ✗ Ro.CI.BAT: failure for " Patchwork
  1 sibling, 0 replies; 3+ messages in thread
From: Tvrtko Ursulin @ 2016-06-06  9:59 UTC (permalink / raw)
  To: ankitprasad.r.sharma, intel-gfx; +Cc: akash.goel


On 06/06/16 10:22, 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.
>
> v2: Removed size argument for checking stolen memory availability (Tvrtko)
>
> Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
> ---
>   lib/ioctl_wrappers.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>   lib/ioctl_wrappers.h |  5 ++++-
>   tests/gem_pread.c    |  3 +++
>   tests/gem_pwrite.c   |  2 ++
>   4 files changed, 56 insertions(+), 2 deletions(-)
>
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index f224091..818853e 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..0d42ba9 100644
> --- a/lib/ioctl_wrappers.h
> +++ b/lib/ioctl_wrappers.h
> @@ -94,7 +94,8 @@ void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, un
>    * memory is available. Automatically skips through igt_require() if not.
>    */
>   #define gem_require_stolen_support(fd) \
> -			igt_require(gem_create__has_stolen_support(fd))
> +			igt_require(gem_create__has_stolen_support(fd) && \
> +				    (gem_total_stolen_size(fd) > 0))
>
>   /**
>    * 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_pread.c b/tests/gem_pread.c
> index afa072d..f4cf472 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);
>   		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);
>   			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_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..8db5454 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);
>   		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);
>   			gem_set_caching(fd, dst, c->level);
>   			for (count = 1; count <= 1<<17; count <<= 1) {
>   				struct timeval start, end;
>

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] 3+ messages in thread

* ✗ Ro.CI.BAT: failure for igt/gem_stolen: Check for available stolen memory size
  2016-06-06  9:22 [PATCH] igt/gem_stolen: Check for available stolen memory size ankitprasad.r.sharma
  2016-06-06  9:59 ` Tvrtko Ursulin
@ 2016-06-06 10:45 ` Patchwork
  1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2016-06-06 10:45 UTC (permalink / raw)
  To: ankitprasad.r.sharma; +Cc: intel-gfx

== Series Details ==

Series: igt/gem_stolen: Check for available stolen memory size
URL   : https://patchwork.freedesktop.org/series/8335/
State : failure

== Summary ==

Applying: igt/gem_stolen: Check for available stolen memory size
fatal: sha1 information is lacking or useless (lib/ioctl_wrappers.c).
error: could not build fake ancestor
Patch failed at 0001 igt/gem_stolen: Check for available stolen memory size
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] 3+ messages in thread

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-06  9:22 [PATCH] igt/gem_stolen: Check for available stolen memory size ankitprasad.r.sharma
2016-06-06  9:59 ` Tvrtko Ursulin
2016-06-06 10:45 ` ✗ Ro.CI.BAT: failure for " 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).