[igt-dev] [PATCH 3/7] lib/panfrost: Add a helper to create a job loop

Boris Brezillon boris.brezillon at collabora.com
Mon Jun 21 12:57:20 UTC 2021


Useful to trigger job timeouts and test the kernel driver timeout
handling logic.

Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
---
 lib/igt_panfrost.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 lib/igt_panfrost.h |  1 +
 2 files changed, 44 insertions(+)

diff --git a/lib/igt_panfrost.c b/lib/igt_panfrost.c
index 4bbb5ddf4076..988cd757c055 100644
--- a/lib/igt_panfrost.c
+++ b/lib/igt_panfrost.c
@@ -130,6 +130,49 @@ void igt_panfrost_bo_mmap(int fd, struct panfrost_bo *bo)
         igt_assert(bo->map);
 }
 
+struct panfrost_submit *igt_panfrost_job_loop(int fd)
+{
+        struct panfrost_submit *submit;
+        struct mali_job_descriptor_header header = {
+                .job_type = JOB_TYPE_SET_VALUE,
+                .job_barrier = 1,
+                .unknown_flags = 5,
+                .job_index = 1,
+                .job_descriptor_size = 1,
+        };
+        struct mali_payload_set_value payload = {
+                .unknown = 3,
+        };
+        uint32_t *bos;
+
+        submit = malloc(sizeof(*submit));
+	memset(submit, 0, sizeof(*submit));
+
+        submit->submit_bo = igt_panfrost_gem_new(fd, ALIGN(sizeof(header) + sizeof(payload), 64) * 2);
+        igt_panfrost_bo_mmap(fd, submit->submit_bo);
+
+        payload.out = header.next_job_64 = submit->submit_bo->offset + ALIGN(sizeof(header) + sizeof(payload), 64);
+        memcpy(submit->submit_bo->map, &header, sizeof(header));
+        memcpy(submit->submit_bo->map + sizeof(header), &payload, sizeof(payload));
+        payload.out = header.next_job_64 = submit->submit_bo->offset;
+        memcpy(submit->submit_bo->map + ALIGN(sizeof(header) + sizeof(payload), 64), &header, sizeof(header));
+        memcpy(submit->submit_bo->map + ALIGN(sizeof(header) + sizeof(payload), 64) + sizeof(header), &payload, sizeof(payload));
+
+        submit->args = malloc(sizeof(*submit->args));
+        memset(submit->args, 0, sizeof(*submit->args));
+        submit->args->jc = submit->submit_bo->offset;
+
+        bos = malloc(sizeof(*bos) * 1);
+        bos[0] = submit->submit_bo->handle;
+
+        submit->args->bo_handles = to_user_pointer(bos);
+        submit->args->bo_handle_count = 1;
+
+        igt_assert_eq(drmSyncobjCreate(fd, DRM_SYNCOBJ_CREATE_SIGNALED, &submit->args->out_sync), 0);
+
+        return submit;
+}
+
 struct panfrost_submit *igt_panfrost_trivial_job(int fd, bool do_crash, int width, int height, uint32_t color)
 {
         struct panfrost_submit *submit;
diff --git a/lib/igt_panfrost.h b/lib/igt_panfrost.h
index cc7998dcb4bf..22bf4c7bad9d 100644
--- a/lib/igt_panfrost.h
+++ b/lib/igt_panfrost.h
@@ -48,6 +48,7 @@ struct panfrost_bo *igt_panfrost_gem_new(int fd, size_t size);
 void igt_panfrost_free_bo(int fd, struct panfrost_bo *bo);
 
 struct panfrost_submit *igt_panfrost_trivial_job(int fd, bool do_crash, int width, int height, uint32_t color);
+struct panfrost_submit *igt_panfrost_job_loop(int fd);
 void igt_panfrost_free_job(int fd, struct panfrost_submit *submit);
 
 /* IOCTL wrappers */
-- 
2.31.1



More information about the igt-dev mailing list