Lines Matching full:fd
71 int fd = drm_open_driver(DRIVER_INTEL); in sync_gpu() local
72 gem_quiescent_gpu(fd); in sync_gpu()
73 close(fd); in sync_gpu()
76 static int noop(int fd, uint32_t ctx, const struct intel_execution_engine *e) in noop() argument
84 exec.handle = gem_create(fd, 4096); in noop()
86 gem_write(fd, exec.handle, 0, &bbe, sizeof(bbe)); in noop()
94 ret = __gem_execbuf(fd, &eb); in noop()
96 gem_close(fd, exec.handle); in noop()
103 static int has_engine(int fd, in has_engine() argument
107 int handle = noop(fd, ctx, e); in has_engine()
110 gem_close(fd, handle); in has_engine()
116 int fd = drm_open_driver(DRIVER_INTEL); in check_context() local
118 gem_require_contexts(fd); in check_context()
119 igt_require(has_engine(fd, gem_context_create(fd), e)); in check_context()
121 close(fd); in check_context()
124 static int gem_reset_stats(int fd, int ctx_id, in gem_reset_stats() argument
131 if (drmIoctl(fd, GET_RESET_STATS_IOCTL, rs)) in gem_reset_stats()
138 static int gem_reset_status(int fd, int ctx_id) in gem_reset_status() argument
143 ret = gem_reset_stats(fd, ctx_id, &rs); in gem_reset_status()
159 static void inject_hang(int fd, uint32_t ctx, in inject_hang() argument
167 hang = igt_hang_ctx(fd, ctx, e->exec_id | e->flags, flags & BAN); in inject_hang()
169 igt_post_hang_ring(fd, hang); in inject_hang()
184 static int _assert_reset_status(int idx, int fd, int ctx, int status) in _assert_reset_status() argument
188 rs = gem_reset_status(fd, ctx); in _assert_reset_status()
207 #define assert_reset_status(idx, fd, ctx, status) \ argument
208 igt_assert(_assert_reset_status(idx, fd, ctx, status) == 0)
213 int fd[MAX_FD]; in test_rs() local
222 fd[i] = drm_open_driver(DRIVER_INTEL); in test_rs()
223 assert_reset_status(i, fd[i], 0, RS_NO_ERROR); in test_rs()
229 inject_hang(fd[i], 0, e, ASYNC); in test_rs()
231 igt_assert(noop(fd[i], 0, e) > 0); in test_rs()
237 assert_reset_status(i, fd[i], 0, rs_assumed_no_hang); in test_rs()
242 assert_reset_status(i, fd[i], 0, RS_NO_ERROR); in test_rs()
244 assert_reset_status(i, fd[i], 0, RS_BATCH_ACTIVE); in test_rs()
246 assert_reset_status(i, fd[i], 0, RS_NO_ERROR); in test_rs()
252 close(fd[i]); in test_rs()
261 int fd[MAX_FD]; in test_rs_ctx() local
273 fd[i] = drm_open_driver(DRIVER_INTEL); in test_rs_ctx()
274 igt_assert(fd[i]); in test_rs_ctx()
275 assert_reset_status(i, fd[i], 0, RS_NO_ERROR); in test_rs_ctx()
278 ctx[i][j] = gem_context_create(fd[i]); in test_rs_ctx()
281 assert_reset_status(i, fd[i], 0, RS_NO_ERROR); in test_rs_ctx()
285 assert_reset_status(i, fd[i], 0, RS_NO_ERROR); in test_rs_ctx()
288 assert_reset_status(i, fd[i], ctx[i][j], RS_NO_ERROR); in test_rs_ctx()
290 assert_reset_status(i, fd[i], 0, RS_NO_ERROR); in test_rs_ctx()
296 inject_hang(fd[i], ctx[i][j], e, ASYNC); in test_rs_ctx()
298 igt_assert(noop(fd[i], ctx[i][j], e) > 0); in test_rs_ctx()
306 assert_reset_status(i, fd[i], 0, RS_NO_ERROR); in test_rs_ctx()
311 assert_reset_status(i, fd[i], ctx[i][j], RS_NO_ERROR); in test_rs_ctx()
313 assert_reset_status(i, fd[i], ctx[i][j], RS_NO_ERROR); in test_rs_ctx()
315 assert_reset_status(i, fd[i], ctx[i][j], in test_rs_ctx()
318 assert_reset_status(i, fd[i], ctx[i][j], in test_rs_ctx()
321 assert_reset_status(i, fd[i], ctx[i][j], in test_rs_ctx()
327 assert_reset_status(i, fd[i], 0, RS_NO_ERROR); in test_rs_ctx()
328 close(fd[i]); in test_rs_ctx()
389 int fd, ban, retry = 10; in test_ban_ctx() local
393 fd = drm_open_driver(DRIVER_INTEL); in test_ban_ctx()
395 assert_reset_status(fd, fd, 0, RS_NO_ERROR); in test_ban_ctx()
397 ctx_good = gem_context_create(fd); in test_ban_ctx()
398 ctx_bad = gem_context_create(fd); in test_ban_ctx()
400 assert_reset_status(fd, fd, 0, RS_NO_ERROR); in test_ban_ctx()
401 assert_reset_status(fd, fd, ctx_good, RS_NO_ERROR); in test_ban_ctx()
402 assert_reset_status(fd, fd, ctx_bad, RS_NO_ERROR); in test_ban_ctx()
404 noop(fd, ctx_bad, e); in test_ban_ctx()
405 noop(fd, ctx_good, e); in test_ban_ctx()
407 assert_reset_status(fd, fd, ctx_good, RS_NO_ERROR); in test_ban_ctx()
408 assert_reset_status(fd, fd, ctx_bad, RS_NO_ERROR); in test_ban_ctx()
410 inject_hang(fd, ctx_bad, e, BAN | ASYNC); in test_ban_ctx()
413 noop(fd, ctx_good, e); in test_ban_ctx()
414 noop(fd, ctx_good, e); in test_ban_ctx()
417 inject_hang(fd, ctx_bad, e, BAN); in test_ban_ctx()
420 ban = noop(fd, ctx_bad, e); in test_ban_ctx()
426 gem_close(fd, ban); in test_ban_ctx()
431 igt_assert_lt(0, noop(fd, ctx_good, e)); in test_ban_ctx()
433 assert_reset_status(fd, fd, ctx_bad, RS_BATCH_ACTIVE); in test_ban_ctx()
434 igt_assert_eq(gem_reset_stats(fd, ctx_bad, &rs_bad), 0); in test_ban_ctx()
437 assert_reset_status(fd, fd, ctx_good, RS_NO_ERROR); in test_ban_ctx()
438 igt_assert_eq(gem_reset_stats(fd, ctx_good, &rs_good), 0); in test_ban_ctx()
441 close(fd); in test_ban_ctx()
471 static int get_reset_count(int fd, int ctx) in get_reset_count() argument
476 ret = gem_reset_stats(fd, ctx, &rs); in get_reset_count()
485 int fd = drm_open_driver(DRIVER_INTEL); in test_close_pending_ctx() local
486 uint32_t ctx = gem_context_create(fd); in test_close_pending_ctx()
488 assert_reset_status(fd, fd, ctx, RS_NO_ERROR); in test_close_pending_ctx()
490 inject_hang(fd, ctx, e, 0); in test_close_pending_ctx()
491 gem_context_destroy(fd, ctx); in test_close_pending_ctx()
492 igt_assert_eq(__gem_context_destroy(fd, ctx), -ENOENT); in test_close_pending_ctx()
494 close(fd); in test_close_pending_ctx()
499 int fd = drm_open_driver(DRIVER_INTEL); in test_close_pending() local
501 assert_reset_status(fd, fd, 0, RS_NO_ERROR); in test_close_pending()
503 inject_hang(fd, 0, e, 0); in test_close_pending()
504 close(fd); in test_close_pending()
507 static void noop_on_each_ring(int fd, const bool reverse) in noop_on_each_ring() argument
515 obj.handle = gem_create(fd, 4096); in noop_on_each_ring()
516 gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); in noop_on_each_ring()
527 __gem_execbuf(fd, &eb); in noop_on_each_ring()
532 __gem_execbuf(fd, &eb); in noop_on_each_ring()
536 gem_sync(fd, obj.handle); in noop_on_each_ring()
537 gem_close(fd, obj.handle); in noop_on_each_ring()
543 int fd = drm_open_driver(DRIVER_INTEL); in test_close_pending_fork() local
547 assert_reset_status(fd, fd, 0, RS_NO_ERROR); in test_close_pending_fork()
549 hang = igt_hang_ctx(fd, 0, e->exec_id | e->flags, 0); in test_close_pending_fork()
578 igt_post_hang_ring(fd, hang); in test_close_pending_fork()
579 close(fd); in test_close_pending_fork()
585 int fd = drm_open_driver(DRIVER_INTEL); in test_reset_count() local
590 ctx = gem_context_create(fd); in test_reset_count()
594 assert_reset_status(fd, fd, ctx, RS_NO_ERROR); in test_reset_count()
596 c1 = get_reset_count(fd, ctx); in test_reset_count()
599 inject_hang(fd, ctx, e, 0); in test_reset_count()
601 assert_reset_status(fd, fd, ctx, RS_BATCH_ACTIVE); in test_reset_count()
602 c2 = get_reset_count(fd, ctx); in test_reset_count()
609 c2 = get_reset_count(fd, ctx); in test_reset_count()
617 gem_context_destroy(fd, ctx); in test_reset_count()
619 close(fd); in test_reset_count()
622 static int _test_params(int fd, int ctx, uint32_t flags, uint32_t pad) in _test_params() argument
634 if (drmIoctl(fd, GET_RESET_STATS_IOCTL, &rs)) in _test_params()
642 static void _check_param_ctx(const int fd, const int ctx, const cap_t cap) in _check_param_ctx() argument
647 igt_assert_eq(_test_params(fd, ctx, 0, 0), 0); in _check_param_ctx()
650 igt_assert(get_reset_count(fd, ctx) == 0); in _check_param_ctx()
654 igt_assert_eq(_test_params(fd, ctx, 0, bad), -EINVAL); in _check_param_ctx()
655 igt_assert_eq(_test_params(fd, ctx, bad, 0), -EINVAL); in _check_param_ctx()
656 igt_assert_eq(_test_params(fd, ctx, bad, bad), -EINVAL); in _check_param_ctx()
659 static void check_params(const int fd, const int ctx, cap_t cap) in check_params() argument
661 igt_assert(ioctl(fd, GET_RESET_STATS_IOCTL, 0) == -1); in check_params()
662 igt_assert_eq(_test_params(fd, 0xbadbad, 0, 0), -ENOENT); in check_params()
664 _check_param_ctx(fd, ctx, cap); in check_params()
667 static void _test_param(const int fd, const int ctx) in _test_param() argument
669 check_params(fd, ctx, root); in _test_param()
672 check_params(fd, ctx, root); in _test_param()
676 check_params(fd, ctx, user); in _test_param()
679 check_params(fd, ctx, root); in _test_param()
686 int fd; in test_params_ctx() local
688 fd = drm_open_driver(DRIVER_INTEL); in test_params_ctx()
689 _test_param(fd, gem_context_create(fd)); in test_params_ctx()
690 close(fd); in test_params_ctx()
695 int fd; in test_params() local
697 fd = drm_open_driver(DRIVER_INTEL); in test_params()
698 _test_param(fd, 0); in test_params()
699 close(fd); in test_params()
703 next_engine(int fd, const struct intel_execution_engine *e) in next_engine() argument
711 } while (!has_engine(fd, 0, e)); in next_engine()
719 int fd, count_start, count_end; in defer_hangcheck() local
722 fd = drm_open_driver(DRIVER_INTEL); in defer_hangcheck()
724 next = next_engine(fd, engine); in defer_hangcheck()
727 count_start = get_reset_count(fd, 0); in defer_hangcheck()
730 inject_hang(fd, 0, engine, 0); in defer_hangcheck()
732 noop(fd, 0, next); in defer_hangcheck()
734 count_end = get_reset_count(fd, 0); in defer_hangcheck()
745 close(fd); in defer_hangcheck()
748 static bool gem_has_reset_stats(int fd) in gem_has_reset_stats() argument
758 ret = drmIoctl(fd, GET_RESET_STATS_IOCTL, &rs); in gem_has_reset_stats()
779 int fd; variable
783 fd = drm_open_driver(DRIVER_INTEL);
784 devid = intel_get_drm_devid(fd);
786 has_reset_stats = gem_has_reset_stats(fd);
789 (fd, "reset", "%d", 1 /* only global reset */));
791 using_full_reset = !gem_engine_reset_enabled(fd) &&
792 gem_gpu_reset_enabled(fd);
794 close(fd);
847 int fd; variable
849 fd = drm_open_driver(DRIVER_INTEL);
851 (fd, "reset", "%d", INT_MAX /* any reset method */));
852 close(fd);