public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drmtest: remove unused argument from gem_mmap__cpu
@ 2013-11-08 20:50 Paulo Zanoni
  2013-11-08 20:50 ` [PATCH 2/2] drmtest: assert operations inside gem_mmap__cpu Paulo Zanoni
  0 siblings, 1 reply; 2+ messages in thread
From: Paulo Zanoni @ 2013-11-08 20:50 UTC (permalink / raw)
  To: intel-gfx; +Cc: Paulo Zanoni

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

That's just misleading.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 lib/drmtest.c                |  2 +-
 lib/drmtest.h                |  2 +-
 tests/gem_cs_tlb.c           |  3 +--
 tests/gem_evict_everything.c |  3 +--
 tests/gem_fence_thrash.c     |  2 +-
 tests/gem_gtt_speed.c        | 10 +++++-----
 tests/gem_pwrite_pread.c     |  8 ++++----
 7 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index d8fc60f..636ba26 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -557,7 +557,7 @@ void *gem_mmap__gtt(int fd, uint32_t handle, int size, int prot)
 	return ptr;
 }
 
-void *gem_mmap__cpu(int fd, uint32_t handle, int size, int prot)
+void *gem_mmap__cpu(int fd, uint32_t handle, int size)
 {
 	struct drm_i915_gem_mmap mmap_arg;
 
diff --git a/lib/drmtest.h b/lib/drmtest.h
index a9fd0bc..7f335b5 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -77,7 +77,7 @@ uint32_t gem_create(int fd, int size);
 void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
 
 void *gem_mmap__gtt(int fd, uint32_t handle, int size, int prot);
-void *gem_mmap__cpu(int fd, uint32_t handle, int size, int prot);
+void *gem_mmap__cpu(int fd, uint32_t handle, int size);
 #define gem_mmap gem_mmap__gtt
 
 uint64_t gem_aperture_size(int fd);
diff --git a/tests/gem_cs_tlb.c b/tests/gem_cs_tlb.c
index 6f1fd5b..b0bbebb 100644
--- a/tests/gem_cs_tlb.c
+++ b/tests/gem_cs_tlb.c
@@ -113,8 +113,7 @@ static void run_on_ring(int fd, unsigned ring_id, const char *ring_name)
 		igt_progress(buf, split, BATCH_SIZE/8 - 1);
 
 		handle_new = gem_create(fd, BATCH_SIZE);
-		batch_ptr = gem_mmap__cpu(fd, handle_new, BATCH_SIZE,
-					  PROT_READ | PROT_WRITE);
+		batch_ptr = gem_mmap__cpu(fd, handle_new, BATCH_SIZE);
 		batch_ptr[split*2] = MI_BATCH_BUFFER_END;
 
 		for (i = split*2 + 2; i < BATCH_SIZE/8; i++)
diff --git a/tests/gem_evict_everything.c b/tests/gem_evict_everything.c
index 762aef1..347509c 100644
--- a/tests/gem_evict_everything.c
+++ b/tests/gem_evict_everything.c
@@ -196,8 +196,7 @@ static void forked_evictions(int fd, int size, int count,
 
 			for (l = 0; l < count && (flags & MEMORY_PRESSURE); l++) {
 				uint32_t *base = gem_mmap__cpu(realfd, bo[l],
-							       size,
-							       PROT_READ | PROT_WRITE);
+							       size);
 				memset(base, 0, size);
 				munmap(base, size);
 			}
diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index bff73dd..8e16f21 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -68,7 +68,7 @@ bo_create (int fd, int tiling)
 	handle = gem_create(fd, OBJECT_SIZE);
 
 	/* dirty cpu caches a bit ... */
-	ptr = gem_mmap__cpu(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+	ptr = gem_mmap__cpu(fd, handle, OBJECT_SIZE);
 	igt_assert(ptr);
 	memset(ptr, 0, OBJECT_SIZE);
 	munmap(ptr, OBJECT_SIZE);
diff --git a/tests/gem_gtt_speed.c b/tests/gem_gtt_speed.c
index 459bdab..6ced4b8 100644
--- a/tests/gem_gtt_speed.c
+++ b/tests/gem_gtt_speed.c
@@ -88,7 +88,7 @@ int main(int argc, char **argv)
 				       I915_GEM_DOMAIN_CPU);
 
 			{
-				uint32_t *base = gem_mmap__cpu(fd, handle, size, PROT_READ | PROT_WRITE);
+				uint32_t *base = gem_mmap__cpu(fd, handle, size);
 				volatile uint32_t *ptr = base;
 				int x = 0;
 
@@ -103,7 +103,7 @@ int main(int argc, char **argv)
 				/* mmap read */
 				gettimeofday(&start, NULL);
 				for (loop = 0; loop < 1000; loop++) {
-					base = gem_mmap__cpu(fd, handle, size, PROT_READ | PROT_WRITE);
+					base = gem_mmap__cpu(fd, handle, size);
 					ptr = base;
 					x = 0;
 
@@ -122,7 +122,7 @@ int main(int argc, char **argv)
 				/* mmap write */
 				gettimeofday(&start, NULL);
 				for (loop = 0; loop < 1000; loop++) {
-					base = gem_mmap__cpu(fd, handle, size, PROT_READ | PROT_WRITE);
+					base = gem_mmap__cpu(fd, handle, size);
 					ptr = base;
 
 					for (i = 0; i < size/sizeof(*ptr); i++)
@@ -136,7 +136,7 @@ int main(int argc, char **argv)
 
 				gettimeofday(&start, NULL);
 				for (loop = 0; loop < 1000; loop++) {
-					base = gem_mmap__cpu(fd, handle, size, PROT_READ | PROT_WRITE);
+					base = gem_mmap__cpu(fd, handle, size);
 					memset(base, 0, size);
 					munmap(base, size);
 				}
@@ -145,7 +145,7 @@ int main(int argc, char **argv)
 				       size/1024, elapsed(&start, &end, loop));
 
 				gettimeofday(&start, NULL);
-				base = gem_mmap__cpu(fd, handle, size, PROT_READ | PROT_WRITE);
+				base = gem_mmap__cpu(fd, handle, size);
 				for (loop = 0; loop < 1000; loop++)
 					memset(base, 0, size);
 				munmap(base, size);
diff --git a/tests/gem_pwrite_pread.c b/tests/gem_pwrite_pread.c
index 1ae0820..072d323 100644
--- a/tests/gem_pwrite_pread.c
+++ b/tests/gem_pwrite_pread.c
@@ -180,8 +180,8 @@ static void as_cpu_mmap(int fd, uint32_t src, uint32_t dst, void *buf, int len,
 
 	gem_write(fd, exec[2].handle, 0, batch, execbuf.batch_len);
 
-	src_ptr = gem_mmap__cpu(fd, src, OBJECT_SIZE, PROT_WRITE);
-	dst_ptr = gem_mmap__cpu(fd, dst, OBJECT_SIZE, PROT_READ);
+	src_ptr = gem_mmap__cpu(fd, src, OBJECT_SIZE);
+	dst_ptr = gem_mmap__cpu(fd, dst, OBJECT_SIZE);
 
 	while (loops--) {
 		gem_set_domain(fd, src,
@@ -309,8 +309,8 @@ static void test_as_cpu_mmap(int fd, uint32_t src, uint32_t dst, int len)
 
 	gem_write(fd, exec[2].handle, 0, batch, execbuf.batch_len);
 
-	src_ptr = gem_mmap__cpu(fd, src, OBJECT_SIZE, PROT_WRITE);
-	dst_ptr = gem_mmap__cpu(fd, dst, OBJECT_SIZE, PROT_READ);
+	src_ptr = gem_mmap__cpu(fd, src, OBJECT_SIZE);
+	dst_ptr = gem_mmap__cpu(fd, dst, OBJECT_SIZE);
 
 	gem_set_domain(fd, src, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
 	for (i = 0; i < len/4; i++)
-- 
1.8.3.1

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

* [PATCH 2/2] drmtest: assert operations inside gem_mmap__cpu
  2013-11-08 20:50 [PATCH 1/2] drmtest: remove unused argument from gem_mmap__cpu Paulo Zanoni
@ 2013-11-08 20:50 ` Paulo Zanoni
  0 siblings, 0 replies; 2+ messages in thread
From: Paulo Zanoni @ 2013-11-08 20:50 UTC (permalink / raw)
  To: intel-gfx; +Cc: Paulo Zanoni

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

All the callers seem to rely on the correct behavior of gem_mmap__cpu,
so add some assertions to catch the unexpected cases. This way we
won't need to worry about adding assertions to all the callers.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 lib/drmtest.c            | 4 ++--
 tests/gem_fence_thrash.c | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 636ba26..6ac9354 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -564,8 +564,8 @@ void *gem_mmap__cpu(int fd, uint32_t handle, int size)
 	mmap_arg.handle = handle;
 	mmap_arg.offset = 0;
 	mmap_arg.size = size;
-	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP, &mmap_arg))
-		return NULL;
+	do_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &mmap_arg);
+	igt_assert(mmap_arg.addr_ptr);
 
 	return (void *)(uintptr_t)mmap_arg.addr_ptr;
 }
diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index 8e16f21..ced9b13 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -69,7 +69,6 @@ bo_create (int fd, int tiling)
 
 	/* dirty cpu caches a bit ... */
 	ptr = gem_mmap__cpu(fd, handle, OBJECT_SIZE);
-	igt_assert(ptr);
 	memset(ptr, 0, OBJECT_SIZE);
 	munmap(ptr, OBJECT_SIZE);
 
-- 
1.8.3.1

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

end of thread, other threads:[~2013-11-08 20:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-08 20:50 [PATCH 1/2] drmtest: remove unused argument from gem_mmap__cpu Paulo Zanoni
2013-11-08 20:50 ` [PATCH 2/2] drmtest: assert operations inside gem_mmap__cpu Paulo Zanoni

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