From 7040f3be1efec904c3ba5729a5a532d03346a161 Mon Sep 17 00:00:00 2001 From: Daniele Ceraolo Spurio Date: Thu, 22 Feb 2018 09:35:06 -0800 Subject: lib/igt_dummyload: add igt_cork The "cork" bo (imported bo with attached fence) and fence is used in several tests to stall execution. Moving it to a common place makes the codebase cleaner. Note that the actual test updates is done in follow up patches as it is simpler to do in one go after one more common function is added in the next patch. v2: don't use new/free naming, don't use dynamic alloc (Chris) v3: add sw_sync common functions. (Chris) v4: squash sw_sync and vgem cork structs into one. (Chris) v5: use anonymous enum in cork struct. (Chris) v6: reset cork after unplugging. (Chris) Signed-off-by: Daniele Ceraolo Spurio Signed-off-by: Antonio Argenziano Cc: Chris Wilson Cc: Daniele Ceraolo Spurio Reviewed-by: Chris Wilson --- lib/igt_dummyload.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'lib/igt_dummyload.h') diff --git a/lib/igt_dummyload.h b/lib/igt_dummyload.h index ffa7e351..4103e4ab 100644 --- a/lib/igt_dummyload.h +++ b/lib/igt_dummyload.h @@ -61,4 +61,36 @@ void igt_spin_batch_free(int fd, igt_spin_t *spin); void igt_terminate_spin_batches(void); +enum igt_cork_type { + CORK_SYNC_FD = 1, + CORK_VGEM_HANDLE +}; + +struct igt_cork_vgem { + int device; + uint32_t fence; +}; + +struct igt_cork_sw_sync { + int timeline; +}; + +struct igt_cork { + enum igt_cork_type type; + + union { + int fd; + + struct igt_cork_vgem vgem; + struct igt_cork_sw_sync sw_sync; + }; +}; + +#define IGT_CORK(name, cork_type) struct igt_cork name = { .type = cork_type, .fd = -1} +#define IGT_CORK_HANDLE(name) IGT_CORK(name, CORK_VGEM_HANDLE) +#define IGT_CORK_FENCE(name) IGT_CORK(name, CORK_SYNC_FD) + +uint32_t igt_cork_plug(struct igt_cork *cork, int fd); +void igt_cork_unplug(struct igt_cork *cork); + #endif /* __IGT_DUMMYLOAD_H__ */ -- cgit v1.2.3