Lines Matching full:fd
60 static void store(int fd, unsigned ring, int fence, uint32_t target, unsigned offset_value) in store() argument
64 const int gen = intel_gen(intel_get_drm_devid(fd)); in store()
82 obj[BATCH].handle = gem_create(fd, 4096); in store()
108 gem_write(fd, obj[BATCH].handle, 0, batch, sizeof(batch)); in store()
109 gem_execbuf(fd, &execbuf); in store()
110 gem_close(fd, obj[BATCH].handle); in store()
122 static void test_fence_busy(int fd, unsigned ring, unsigned flags) in test_fence_busy() argument
124 const int gen = intel_gen(intel_get_drm_devid(fd)); in test_fence_busy()
132 gem_quiescent_gpu(fd); in test_fence_busy()
140 obj.handle = gem_create(fd, 4096); in test_fence_busy()
146 batch = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE); in test_fence_busy()
147 gem_set_domain(fd, obj.handle, in test_fence_busy()
177 gem_execbuf_wr(fd, &execbuf); in test_fence_busy()
181 igt_assert(gem_bo_busy(fd, obj.handle)); in test_fence_busy()
193 struct pollfd pfd = { .fd = fence, .events = POLLIN }; in test_fence_busy()
201 igt_assert(!gem_bo_busy(fd, obj.handle)); in test_fence_busy()
206 gem_close(fd, obj.handle); in test_fence_busy()
208 gem_quiescent_gpu(fd); in test_fence_busy()
211 static void test_fence_busy_all(int fd, unsigned flags) in test_fence_busy_all() argument
213 const int gen = intel_gen(intel_get_drm_devid(fd)); in test_fence_busy_all()
222 gem_quiescent_gpu(fd); in test_fence_busy_all()
229 obj.handle = gem_create(fd, 4096); in test_fence_busy_all()
235 batch = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE); in test_fence_busy_all()
236 gem_set_domain(fd, obj.handle, in test_fence_busy_all()
266 for_each_engine(fd, engine) { in test_fence_busy_all()
271 gem_execbuf_wr(fd, &execbuf); in test_fence_busy_all()
288 igt_assert(gem_bo_busy(fd, obj.handle)); in test_fence_busy_all()
300 struct pollfd pfd = { .fd = all, .events = POLLIN }; in test_fence_busy_all()
308 igt_assert(!gem_bo_busy(fd, obj.handle)); in test_fence_busy_all()
313 gem_close(fd, obj.handle); in test_fence_busy_all()
315 gem_quiescent_gpu(fd); in test_fence_busy_all()
318 static void test_fence_await(int fd, unsigned ring, unsigned flags) in test_fence_await() argument
320 uint32_t scratch = gem_create(fd, 4096); in test_fence_await()
326 igt_require(gem_can_store_dword(fd, 0)); in test_fence_await()
328 out = gem_mmap__wc(fd, scratch, 0, 4096, PROT_WRITE); in test_fence_await()
329 gem_set_domain(fd, scratch, in test_fence_await()
332 spin = igt_spin_new(fd, in test_fence_await()
338 for_each_physical_engine(fd, engine) { in test_fence_await()
339 if (!gem_can_store_dword(fd, engine)) in test_fence_await()
343 store(fd, engine, spin->out_fence, scratch, i); in test_fence_await()
346 store(fd, engine, spin->out_fence, scratch, i); in test_fence_await()
364 gem_set_domain(fd, scratch, I915_GEM_DOMAIN_GTT, 0); in test_fence_await()
369 igt_spin_free(fd, spin); in test_fence_await()
370 gem_close(fd, scratch); in test_fence_await()
373 static void resubmit(int fd, uint32_t handle, unsigned int ring, int count) in resubmit() argument
382 gem_execbuf(fd, &execbuf); in resubmit()
389 static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) in __execbuf() argument
394 if (ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf)) in __execbuf()
401 static void test_parallel(int fd, unsigned int master) in test_parallel() argument
405 const int gen = intel_gen(intel_get_drm_devid(fd)); in test_parallel()
409 uint32_t scratch = gem_create(fd, 4096); in test_parallel()
410 uint32_t *out = gem_mmap__wc(fd, scratch, 0, 4096, PROT_READ); in test_parallel()
419 plug = igt_cork_plug(&c, fd); in test_parallel()
424 spin = igt_spin_new(fd, .engine = master, .dependency = plug); in test_parallel()
425 resubmit(fd, spin->handle, master, 16); in test_parallel()
438 obj[BATCH].handle = gem_create(fd, 4096); in test_parallel()
492 gem_write(fd, obj[BATCH].handle, 0, batch, sizeof(batch)); in test_parallel()
493 gem_execbuf_wr(fd, &execbuf); in test_parallel()
500 for_each_physical_engine(fd, engine) { in test_parallel()
508 obj[BATCH].handle = gem_create(fd, 4096); in test_parallel()
526 gem_write(fd, obj[BATCH].handle, 0, batch, sizeof(batch)); in test_parallel()
527 gem_execbuf(fd, &execbuf); in test_parallel()
529 igt_assert(gem_bo_busy(fd, spin->handle)); in test_parallel()
538 igt_assert(gem_bo_busy(fd, handle[i])); in test_parallel()
543 gem_close(fd, plug); in test_parallel()
553 while (gem_bo_busy(fd, handle[i])) in test_parallel()
557 gem_close(fd, handle[i]); in test_parallel()
560 gem_close(fd, obj[SCRATCH].handle); in test_parallel()
563 igt_assert(gem_bo_busy(fd, handle[0])); in test_parallel()
564 out = gem_mmap__wc(fd, handle[0], 0, 4096, PROT_WRITE); in test_parallel()
567 gem_close(fd, handle[0]); in test_parallel()
570 static uint32_t batch_create(int fd) in batch_create() argument
575 handle = gem_create(fd, 4096); in batch_create()
576 gem_write(fd, handle, 0, &bbe, sizeof(bbe)); in batch_create()
591 static void test_keep_in_fence(int fd, unsigned int engine, unsigned int flags) in test_keep_in_fence() argument
595 .handle = batch_create(fd), in test_keep_in_fence()
607 spin = igt_spin_new(fd, .engine = engine); in test_keep_in_fence()
609 gem_execbuf_wr(fd, &execbuf); in test_keep_in_fence()
625 int err = __execbuf(fd, &execbuf); in test_keep_in_fence()
651 gem_close(fd, obj.handle); in test_keep_in_fence()
654 igt_spin_free(fd, spin); in test_keep_in_fence()
655 gem_quiescent_gpu(fd); in test_keep_in_fence()
659 static void test_long_history(int fd, long ring_size, unsigned flags) in test_long_history() argument
672 if (!gem_uses_full_ppgtt(fd)) in test_long_history()
676 for_each_physical_engine(fd, engine) in test_long_history()
680 gem_quiescent_gpu(fd); in test_long_history()
683 obj[1].handle = gem_create(fd, sz); in test_long_history()
684 gem_write(fd, obj[1].handle, sz - sizeof(bbe), &bbe, sizeof(bbe)); in test_long_history()
691 gem_execbuf_wr(fd, &execbuf); in test_long_history()
697 obj[0].handle = igt_cork_plug(&c, fd); in test_long_history()
700 execbuf.rsvd1 = gem_context_create(fd); in test_long_history()
706 if (__gem_execbuf_wr(fd, &execbuf)) in test_long_history()
721 gem_context_destroy(fd, execbuf.rsvd1); in test_long_history()
730 gem_sync(fd, obj[1].handle); in test_long_history()
740 if (__gem_execbuf_wr(fd, &execbuf)) in test_long_history()
747 gem_sync(fd, obj[1].handle); in test_long_history()
748 gem_close(fd, obj[1].handle); in test_long_history()
749 gem_close(fd, obj[0].handle); in test_long_history()
757 static bool has_submit_fence(int fd) in has_submit_fence() argument
766 ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)); in has_submit_fence()
772 static bool has_syncobj(int fd) in has_syncobj() argument
775 ioctl(fd, DRM_IOCTL_GET_CAP, &cap); in has_syncobj()
779 static bool exec_has_fence_array(int fd) in exec_has_fence_array() argument
788 ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)); in exec_has_fence_array()
794 static void test_invalid_fence_array(int fd) in test_invalid_fence_array() argument
804 obj.handle = gem_create(fd, 4096); in test_invalid_fence_array()
805 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_invalid_fence_array()
809 gem_execbuf(fd, &execbuf); in test_invalid_fence_array()
812 gem_execbuf(fd, &execbuf); in test_invalid_fence_array()
817 igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL); in test_invalid_fence_array()
822 igt_assert_eq(__gem_execbuf(fd, &execbuf), -EFAULT); in test_invalid_fence_array()
826 igt_assert_eq(__gem_execbuf(fd, &execbuf), -ENOENT); in test_invalid_fence_array()
831 igt_assert_eq(__gem_execbuf(fd, &execbuf), -ENOENT); in test_invalid_fence_array()
834 igt_assert_eq(__gem_execbuf(fd, &execbuf), -ENOENT); in test_invalid_fence_array()
837 igt_assert_eq(__gem_execbuf(fd, &execbuf), -EFAULT); in test_invalid_fence_array()
842 static uint32_t __syncobj_create(int fd) in __syncobj_create() argument
850 igt_ioctl(fd, LOCAL_IOCTL_SYNCOBJ_CREATE, &arg); in __syncobj_create()
855 static uint32_t syncobj_create(int fd) in syncobj_create() argument
859 igt_assert_neq((ret = __syncobj_create(fd)), 0); in syncobj_create()
864 static int __syncobj_destroy(int fd, uint32_t handle) in __syncobj_destroy() argument
874 if (igt_ioctl(fd, LOCAL_IOCTL_SYNCOBJ_DESTROY, &arg)) in __syncobj_destroy()
881 static void syncobj_destroy(int fd, uint32_t handle) in syncobj_destroy() argument
883 igt_assert_eq(__syncobj_destroy(fd, handle), 0); in syncobj_destroy()
886 static int __syncobj_to_sync_file(int fd, uint32_t handle) in __syncobj_to_sync_file() argument
891 int32_t fd; in __syncobj_to_sync_file() member
899 if (igt_ioctl(fd, LOCAL_IOCTL_SYNCOBJ_HANDLE_TO_FD, &arg)) in __syncobj_to_sync_file()
900 arg.fd = -errno; in __syncobj_to_sync_file()
903 return arg.fd; in __syncobj_to_sync_file()
906 static int syncobj_to_sync_file(int fd, uint32_t handle) in syncobj_to_sync_file() argument
910 igt_assert_lte(0, (ret = __syncobj_to_sync_file(fd, handle))); in syncobj_to_sync_file()
915 static int __syncobj_from_sync_file(int fd, uint32_t handle, int sf) in __syncobj_from_sync_file() argument
920 int32_t fd; in __syncobj_from_sync_file() member
928 arg.fd = sf; in __syncobj_from_sync_file()
930 if (igt_ioctl(fd, LOCAL_IOCTL_SYNCOBJ_FD_TO_HANDLE, &arg)) in __syncobj_from_sync_file()
937 static void syncobj_from_sync_file(int fd, uint32_t handle, int sf) in syncobj_from_sync_file() argument
939 igt_assert_eq(__syncobj_from_sync_file(fd, handle, sf), 0); in syncobj_from_sync_file()
942 static int __syncobj_export(int fd, uint32_t handle, int *syncobj) in __syncobj_export() argument
947 int32_t fd; in __syncobj_export() member
956 if (igt_ioctl(fd, LOCAL_IOCTL_SYNCOBJ_HANDLE_TO_FD, &arg)) in __syncobj_export()
960 *syncobj = arg.fd; in __syncobj_export()
964 static int syncobj_export(int fd, uint32_t handle) in syncobj_export() argument
968 igt_assert_eq(__syncobj_export(fd, handle, &syncobj), 0); in syncobj_export()
973 static int __syncobj_import(int fd, int syncobj, uint32_t *handle) in __syncobj_import() argument
978 int32_t fd; in __syncobj_import() member
985 arg.fd = syncobj; in __syncobj_import()
988 if (igt_ioctl(fd, LOCAL_IOCTL_SYNCOBJ_FD_TO_HANDLE, &arg)) in __syncobj_import()
996 static uint32_t syncobj_import(int fd, int syncobj) in syncobj_import() argument
1000 igt_assert_eq(__syncobj_import(fd, syncobj, &handle), 0); in syncobj_import()
1006 static bool syncobj_busy(int fd, uint32_t handle) in syncobj_busy() argument
1011 sf = syncobj_to_sync_file(fd, handle); in syncobj_busy()
1018 static void test_syncobj_unused_fence(int fd) in test_syncobj_unused_fence() argument
1024 .handle = syncobj_create(fd), in test_syncobj_unused_fence()
1026 igt_spin_t *spin = igt_spin_new(fd); in test_syncobj_unused_fence()
1029 igt_assert_eq(__syncobj_to_sync_file(fd, 0), -ENOENT); in test_syncobj_unused_fence()
1039 obj.handle = gem_create(fd, 4096); in test_syncobj_unused_fence()
1040 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_unused_fence()
1042 gem_execbuf(fd, &execbuf); in test_syncobj_unused_fence()
1045 igt_assert_eq(__syncobj_to_sync_file(fd, fence.handle), -EINVAL); in test_syncobj_unused_fence()
1046 igt_assert(gem_bo_busy(fd, obj.handle)); in test_syncobj_unused_fence()
1048 gem_close(fd, obj.handle); in test_syncobj_unused_fence()
1049 syncobj_destroy(fd, fence.handle); in test_syncobj_unused_fence()
1051 igt_spin_free(fd, spin); in test_syncobj_unused_fence()
1054 static void test_syncobj_invalid_wait(int fd) in test_syncobj_invalid_wait() argument
1060 .handle = syncobj_create(fd), in test_syncobj_invalid_wait()
1071 obj.handle = gem_create(fd, 4096); in test_syncobj_invalid_wait()
1072 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_invalid_wait()
1076 igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL); in test_syncobj_invalid_wait()
1078 gem_close(fd, obj.handle); in test_syncobj_invalid_wait()
1079 syncobj_destroy(fd, fence.handle); in test_syncobj_invalid_wait()
1082 static void test_syncobj_invalid_flags(int fd) in test_syncobj_invalid_flags() argument
1088 .handle = syncobj_create(fd), in test_syncobj_invalid_flags()
1099 obj.handle = gem_create(fd, 4096); in test_syncobj_invalid_flags()
1100 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_invalid_flags()
1104 igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL); in test_syncobj_invalid_flags()
1106 gem_close(fd, obj.handle); in test_syncobj_invalid_flags()
1107 syncobj_destroy(fd, fence.handle); in test_syncobj_invalid_flags()
1110 static void test_syncobj_signal(int fd) in test_syncobj_signal() argument
1116 .handle = syncobj_create(fd), in test_syncobj_signal()
1118 igt_spin_t *spin = igt_spin_new(fd); in test_syncobj_signal()
1130 obj.handle = gem_create(fd, 4096); in test_syncobj_signal()
1131 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_signal()
1134 gem_execbuf(fd, &execbuf); in test_syncobj_signal()
1136 igt_assert(gem_bo_busy(fd, obj.handle)); in test_syncobj_signal()
1137 igt_assert(syncobj_busy(fd, fence.handle)); in test_syncobj_signal()
1139 igt_spin_free(fd, spin); in test_syncobj_signal()
1141 gem_sync(fd, obj.handle); in test_syncobj_signal()
1142 igt_assert(!gem_bo_busy(fd, obj.handle)); in test_syncobj_signal()
1143 igt_assert(!syncobj_busy(fd, fence.handle)); in test_syncobj_signal()
1145 gem_close(fd, obj.handle); in test_syncobj_signal()
1146 syncobj_destroy(fd, fence.handle); in test_syncobj_signal()
1149 static void test_syncobj_wait(int fd) in test_syncobj_wait() argument
1155 .handle = syncobj_create(fd), in test_syncobj_wait()
1166 gem_quiescent_gpu(fd); in test_syncobj_wait()
1168 spin = igt_spin_new(fd); in test_syncobj_wait()
1175 obj.handle = gem_create(fd, 4096); in test_syncobj_wait()
1176 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_wait()
1183 gem_execbuf(fd, &execbuf); in test_syncobj_wait()
1184 igt_assert(gem_bo_busy(fd, spin->handle)); in test_syncobj_wait()
1186 gem_close(fd, obj.handle); in test_syncobj_wait()
1187 obj.handle = gem_create(fd, 4096); in test_syncobj_wait()
1188 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_wait()
1191 for_each_engine(fd, engine) { in test_syncobj_wait()
1192 obj.handle = gem_create(fd, 4096); in test_syncobj_wait()
1193 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_wait()
1200 gem_execbuf(fd, &execbuf); in test_syncobj_wait()
1201 gem_sync(fd, obj.handle); in test_syncobj_wait()
1202 igt_assert(gem_bo_busy(fd, spin->handle)); in test_syncobj_wait()
1204 igt_assert(gem_bo_busy(fd, spin->handle)); in test_syncobj_wait()
1211 gem_execbuf(fd, &execbuf); in test_syncobj_wait()
1213 igt_assert(gem_bo_busy(fd, obj.handle)); in test_syncobj_wait()
1216 syncobj_destroy(fd, fence.handle); in test_syncobj_wait()
1219 igt_assert(gem_bo_busy(fd, handle[i])); in test_syncobj_wait()
1221 igt_spin_free(fd, spin); in test_syncobj_wait()
1224 gem_sync(fd, handle[i]); in test_syncobj_wait()
1225 gem_close(fd, handle[i]); in test_syncobj_wait()
1229 static void test_syncobj_export(int fd) in test_syncobj_export() argument
1235 .handle = syncobj_create(fd), in test_syncobj_export()
1238 igt_spin_t *spin = igt_spin_new(fd); in test_syncobj_export()
1246 export[n] = syncobj_export(fd, fence.handle); in test_syncobj_export()
1256 obj.handle = gem_create(fd, 4096); in test_syncobj_export()
1257 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_export()
1260 gem_execbuf(fd, &execbuf); in test_syncobj_export()
1262 igt_assert(syncobj_busy(fd, fence.handle)); in test_syncobj_export()
1263 igt_assert(gem_bo_busy(fd, obj.handle)); in test_syncobj_export()
1266 uint32_t import = syncobj_import(fd, export[n]); in test_syncobj_export()
1267 igt_assert(syncobj_busy(fd, import)); in test_syncobj_export()
1268 syncobj_destroy(fd, import); in test_syncobj_export()
1271 igt_spin_free(fd, spin); in test_syncobj_export()
1273 gem_sync(fd, obj.handle); in test_syncobj_export()
1274 igt_assert(!gem_bo_busy(fd, obj.handle)); in test_syncobj_export()
1275 igt_assert(!syncobj_busy(fd, fence.handle)); in test_syncobj_export()
1277 gem_close(fd, obj.handle); in test_syncobj_export()
1278 syncobj_destroy(fd, fence.handle); in test_syncobj_export()
1281 uint32_t import = syncobj_import(fd, export[n]); in test_syncobj_export()
1282 igt_assert(!syncobj_busy(fd, import)); in test_syncobj_export()
1283 syncobj_destroy(fd, import); in test_syncobj_export()
1288 static void test_syncobj_repeat(int fd) in test_syncobj_repeat() argument
1296 igt_spin_t *spin = igt_spin_new(fd); in test_syncobj_repeat()
1300 fence->handle = syncobj_create(fd); in test_syncobj_repeat()
1301 export = syncobj_export(fd, fence->handle); in test_syncobj_repeat()
1303 fence[i].handle = syncobj_import(fd, export); in test_syncobj_repeat()
1314 obj.handle = gem_create(fd, 4096); in test_syncobj_repeat()
1315 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_repeat()
1320 gem_execbuf(fd, &execbuf); in test_syncobj_repeat()
1323 igt_assert(syncobj_busy(fd, fence[i].handle)); in test_syncobj_repeat()
1326 igt_assert(gem_bo_busy(fd, obj.handle)); in test_syncobj_repeat()
1328 gem_execbuf(fd, &execbuf); in test_syncobj_repeat()
1331 igt_assert(syncobj_busy(fd, fence[i].handle)); in test_syncobj_repeat()
1332 igt_assert(gem_bo_busy(fd, obj.handle)); in test_syncobj_repeat()
1334 igt_spin_free(fd, spin); in test_syncobj_repeat()
1336 gem_sync(fd, obj.handle); in test_syncobj_repeat()
1337 gem_close(fd, obj.handle); in test_syncobj_repeat()
1340 igt_assert(!syncobj_busy(fd, fence[i].handle)); in test_syncobj_repeat()
1341 syncobj_destroy(fd, fence[i].handle); in test_syncobj_repeat()
1346 static void test_syncobj_import(int fd) in test_syncobj_import() argument
1351 igt_spin_t *spin = igt_spin_new(fd); in test_syncobj_import()
1352 uint32_t sync = syncobj_create(fd); in test_syncobj_import()
1366 obj.handle = gem_create(fd, 4096); in test_syncobj_import()
1367 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_import()
1369 gem_execbuf_wr(fd, &execbuf); in test_syncobj_import()
1373 syncobj_from_sync_file(fd, sync, fence); in test_syncobj_import()
1376 igt_assert(gem_bo_busy(fd, obj.handle)); in test_syncobj_import()
1377 igt_assert(syncobj_busy(fd, sync)); in test_syncobj_import()
1379 igt_spin_free(fd, spin); in test_syncobj_import()
1381 gem_sync(fd, obj.handle); in test_syncobj_import()
1382 igt_assert(!gem_bo_busy(fd, obj.handle)); in test_syncobj_import()
1383 igt_assert(!syncobj_busy(fd, sync)); in test_syncobj_import()
1385 gem_close(fd, obj.handle); in test_syncobj_import()
1386 syncobj_destroy(fd, sync); in test_syncobj_import()
1389 static void test_syncobj_channel(int fd) in test_syncobj_channel() argument
1411 obj.handle = gem_create(fd, 4096); in test_syncobj_channel()
1412 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in test_syncobj_channel()
1422 fence.handle = syncobj_create(fd); in test_syncobj_channel()
1425 gem_execbuf(fd, &execbuf); in test_syncobj_channel()
1450 gem_execbuf(fd, &execbuf); in test_syncobj_channel()
1475 gem_execbuf(fd, &execbuf); in test_syncobj_channel()
1493 gem_execbuf(fd, &execbuf); in test_syncobj_channel()
1507 gem_sync(fd, obj.handle); in test_syncobj_channel()
1508 gem_close(fd, obj.handle); in test_syncobj_channel()
1511 syncobj_destroy(fd, syncobj[i]); in test_syncobj_channel()