diff mbox

igt/gem_pread: Check for stolen memory support before pread/pwrite

Message ID 1458282828-31788-1-git-send-email-ankitprasad.r.sharma@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

ankitprasad.r.sharma@intel.com March 18, 2016, 6:33 a.m. UTC
From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>

This checks if the kernel supports creation of stolen backed objects
before doing a pread/pwrite 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 | 3 +--
 tests/gem_pread.c    | 3 +++
 tests/gem_pwrite.c   | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 4071260..9ff8c31 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -415,7 +415,6 @@  void gem_sync(int fd, uint32_t handle)
 	errno = 0;
 }
 
-
 bool gem_create__has_stolen_support(int fd)
 {
 	static int has_stolen_support = -1;
@@ -424,7 +423,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? */
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 42206d7..5d99b29 100644
--- a/tests/gem_pwrite.c
+++ b/tests/gem_pwrite.c
@@ -206,6 +206,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;
 
@@ -222,6 +223,7 @@  int main(int argc, char **argv)
 	}
 
 	for (c = cache; c->level != -1; c++) {
+		gem_require_stolen_support(fd);
 		igt_subtest_f("stolen-%s", c->name) {
 			gem_set_caching(fd, dst, c->level);
 			for (count = 1; count <= 1<<17; count <<= 1) {