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

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


Useful when we just want to make sure the scheduler has executed a
job (way simpler than creating actual jobs).

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

diff --git a/lib/igt_panfrost.c b/lib/igt_panfrost.c
index 988cd757c055..60995f4ed18d 100644
--- a/lib/igt_panfrost.c
+++ b/lib/igt_panfrost.c
@@ -173,6 +173,39 @@ struct panfrost_submit *igt_panfrost_job_loop(int fd)
         return submit;
 }
 
+struct panfrost_submit *igt_panfrost_null_job(int fd)
+{
+        struct panfrost_submit *submit;
+        struct mali_job_descriptor_header header = {
+                .job_type = JOB_TYPE_NULL,
+                .job_index = 1,
+                .job_descriptor_size = 1,
+        };
+        uint32_t *bos;
+
+        submit = malloc(sizeof(*submit));
+	memset(submit, 0, sizeof(*submit));
+
+        submit->submit_bo = igt_panfrost_gem_new(fd, sizeof(header));
+        igt_panfrost_bo_mmap(fd, submit->submit_bo);
+
+        memcpy(submit->submit_bo->map, &header, sizeof(header));
+
+        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 22bf4c7bad9d..953dd4b7dd47 100644
--- a/lib/igt_panfrost.h
+++ b/lib/igt_panfrost.h
@@ -49,6 +49,7 @@ 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);
+struct panfrost_submit *igt_panfrost_null_job(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