Re: [Intel-gfx] [PATCH igt 4/5] igt/gem_exec_capture: Exercise readback of userptr

2018-03-01 Thread Michał Winiarski
On Wed, Feb 28, 2018 at 03:51:37PM +, Chris Wilson wrote:
> EXEC_OBJECT_CAPTURE extends the type of buffers we may read during error
> capture. Previously we knew that we would only see batch buffers (which
> limited the objects to being from gem_create()), but now we need to
> check that any buffer the user can create can be read. The first
> alternate buffer type is a userptr.
> 
> Signed-off-by: Chris Wilson 

Reviewed-by: Michał Winiarski 

-Michał

> ---
>  tests/gem_exec_capture.c | 35 ---
>  1 file changed, 32 insertions(+), 3 deletions(-)
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH igt 4/5] igt/gem_exec_capture: Exercise readback of userptr

2018-02-28 Thread Chris Wilson
EXEC_OBJECT_CAPTURE extends the type of buffers we may read during error
capture. Previously we knew that we would only see batch buffers (which
limited the objects to being from gem_create()), but now we need to
check that any buffer the user can create can be read. The first
alternate buffer type is a userptr.

Signed-off-by: Chris Wilson 
---
 tests/gem_exec_capture.c | 35 ---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/tests/gem_exec_capture.c b/tests/gem_exec_capture.c
index 43c443be..2dc06ce4 100644
--- a/tests/gem_exec_capture.c
+++ b/tests/gem_exec_capture.c
@@ -57,7 +57,7 @@ static void check_error_state(int dir, struct 
drm_i915_gem_exec_object2 *obj)
igt_assert(found);
 }
 
-static void capture(int fd, int dir, unsigned ring)
+static void __capture(int fd, int dir, unsigned ring, uint32_t target)
 {
const int gen = intel_gen(intel_get_drm_devid(fd));
struct drm_i915_gem_exec_object2 obj[4];
@@ -72,7 +72,7 @@ static void capture(int fd, int dir, unsigned ring)
 
memset(obj, 0, sizeof(obj));
obj[SCRATCH].handle = gem_create(fd, 4096);
-   obj[CAPTURE].handle = gem_create(fd, 4096);
+   obj[CAPTURE].handle = target;
obj[CAPTURE].flags = LOCAL_OBJECT_CAPTURE;
obj[NOCAPTURE].handle = gem_create(fd, 4096);
 
@@ -159,10 +159,32 @@ static void capture(int fd, int dir, unsigned ring)
 
gem_close(fd, obj[BATCH].handle);
gem_close(fd, obj[NOCAPTURE].handle);
-   gem_close(fd, obj[CAPTURE].handle);
gem_close(fd, obj[SCRATCH].handle);
 }
 
+static void capture(int fd, int dir, unsigned ring)
+{
+   uint32_t handle;
+
+   handle = gem_create(fd, 4096);
+   __capture(fd, dir, ring, handle);
+   gem_close(fd, handle);
+}
+
+static void userptr(int fd, int dir)
+{
+   uint32_t handle;
+   void *ptr;
+
+   igt_assert(posix_memalign(, 4096, 4096) == 0);
+   igt_require(__gem_userptr(fd, ptr, 4096, 0, 0, ) == 0);
+
+   __capture(fd, dir, 0, handle);
+
+   gem_close(fd, handle);
+   free(ptr);
+}
+
 static bool has_capture(int fd)
 {
drm_i915_getparam_t gp;
@@ -214,6 +236,13 @@ igt_main
}
}
 
+   /* And check we can read from different types of objects */
+
+   igt_subtest_f("userptr") {
+   igt_require(gem_can_store_dword(fd, 0));
+   userptr(fd, dir);
+   }
+
igt_fixture {
close(dir);
igt_disallow_hang(fd, hang);
-- 
2.16.2

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


[Intel-gfx] [PATCH igt 4/5] igt/gem_exec_capture: Exercise readback of userptr

2018-01-16 Thread Chris Wilson
EXEC_OBJECT_CAPTURE extends the type of buffers we may read during error
capture. Previously we knew that we would only see batch buffers (which
limited the objects to being from gem_create()), but now we need to
check that any buffer the user can create can be read. The first
alternate buffer type is a userptr.

Signed-off-by: Chris Wilson 
---
 tests/gem_exec_capture.c | 35 ---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/tests/gem_exec_capture.c b/tests/gem_exec_capture.c
index a73ece5da..1c7d1e7cb 100644
--- a/tests/gem_exec_capture.c
+++ b/tests/gem_exec_capture.c
@@ -56,7 +56,7 @@ static void check_error_state(int dir, struct 
drm_i915_gem_exec_object2 *obj)
igt_assert(found);
 }
 
-static void capture(int fd, int dir, unsigned ring)
+static void __capture(int fd, int dir, unsigned ring, uint32_t target)
 {
const int gen = intel_gen(intel_get_drm_devid(fd));
struct drm_i915_gem_exec_object2 obj[4];
@@ -71,7 +71,7 @@ static void capture(int fd, int dir, unsigned ring)
 
memset(obj, 0, sizeof(obj));
obj[SCRATCH].handle = gem_create(fd, 4096);
-   obj[CAPTURE].handle = gem_create(fd, 4096);
+   obj[CAPTURE].handle = target;
obj[CAPTURE].flags = LOCAL_OBJECT_CAPTURE;
obj[NOCAPTURE].handle = gem_create(fd, 4096);
 
@@ -156,10 +156,32 @@ static void capture(int fd, int dir, unsigned ring)
 
gem_close(fd, obj[BATCH].handle);
gem_close(fd, obj[NOCAPTURE].handle);
-   gem_close(fd, obj[CAPTURE].handle);
gem_close(fd, obj[SCRATCH].handle);
 }
 
+static void capture(int fd, int dir, unsigned ring)
+{
+   uint32_t handle;
+
+   handle = gem_create(fd, 4096);
+   __capture(fd, dir, ring, handle);
+   gem_close(fd, handle);
+}
+
+static void userptr(int fd, int dir)
+{
+   uint32_t handle;
+   void *ptr;
+
+   igt_assert(posix_memalign(, 4096, 4096) == 0);
+   igt_require(__gem_userptr(fd, ptr, 4096, 0, 0, ) == 0);
+
+   __capture(fd, dir, 0, handle);
+
+   gem_close(fd, handle);
+   free(ptr);
+}
+
 static bool has_capture(int fd)
 {
drm_i915_getparam_t gp;
@@ -204,6 +226,13 @@ igt_main
}
}
 
+   /* And check we can read from different types of objects */
+
+   igt_subtest_f("userptr") {
+   igt_require(gem_can_store_dword(fd, 0));
+   userptr(fd, dir);
+   }
+
igt_fixture {
close(dir);
igt_disallow_hang(fd, hang);
-- 
2.15.1

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