File: v3d_wait_bo.c

package info (click to toggle)
intel-gpu-tools 2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 63,360 kB
  • sloc: xml: 781,458; ansic: 360,567; python: 8,336; yacc: 2,781; perl: 1,196; sh: 1,177; lex: 487; asm: 227; lisp: 35; makefile: 30
file content (127 lines) | stat: -rw-r--r-- 3,121 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// SPDX-License-Identifier: MIT
/*
 * Copyright © 2022 Igalia S.L.
 */

#include "igt.h"
#include "igt_v3d.h"
#include "v3d/v3d_cl.h"

IGT_TEST_DESCRIPTION("Tests for the V3D's Wait BO IOCTL");

static void test_used_bo(int fd, struct v3d_bo *bo, uint64_t timeout)
{
	struct drm_v3d_wait_bo arg = {
		.timeout_ns = timeout,
		.handle = bo->handle,
	};
	int ret;

	ret = igt_ioctl(fd, DRM_IOCTL_V3D_WAIT_BO, &arg);

	if (ret == -1 && errno == ETIME)
		igt_debug("Timeout triggered\n");
	igt_assert(ret == 0 || (ret == -1 && errno == ETIME));
}

igt_main
{
	int fd;
	struct v3d_bo *bo;

	igt_fixture {
		fd = drm_open_driver(DRIVER_V3D);
		bo = igt_v3d_create_bo(fd, PAGE_SIZE);
	}

	igt_describe("Make sure it cannot wait on an invalid BO.");
	igt_subtest("bad-bo") {
		struct drm_v3d_wait_bo arg = {
			.handle = bo->handle + 1,
			.timeout_ns = 0,
		};
		do_ioctl_err(fd, DRM_IOCTL_V3D_WAIT_BO, &arg, EINVAL);
	}

	igt_describe("Make sure the pad is zero.");
	igt_subtest("bad-pad") {
		struct drm_v3d_wait_bo arg = {
			.pad = 1,
			.handle = bo->handle,
			.timeout_ns = 0,
		};
		do_ioctl_err(fd, DRM_IOCTL_V3D_WAIT_BO, &arg, EINVAL);
	}

	igt_describe("Wait on an unused BO for 0 ns.");
	igt_subtest("unused-bo-0ns")
		igt_v3d_wait_bo(fd, bo, 0);

	igt_describe("Wait on an unused BO for 1 ns.");
	igt_subtest("unused-bo-1ns")
		igt_v3d_wait_bo(fd, bo, 1);

	igt_describe("Wait on a newly mapped BO for 0 ns.");
	igt_subtest("map-bo-0ns") {
		igt_v3d_bo_mmap(fd, bo);
		igt_v3d_wait_bo(fd, bo, 0);
		munmap(bo->map, bo->size);
	}

	igt_describe("Wait on a newly mapped BO for 1 ns.");
	igt_subtest("map-bo-1ns") {
		igt_v3d_bo_mmap(fd, bo);
		igt_v3d_wait_bo(fd, bo, 1);
		munmap(bo->map, bo->size);
	}

	igt_describe("Wait for BOs used for a noop job for 0 ns.");
	igt_subtest("used-bo-0ns") {
		struct v3d_cl_job *job = igt_v3d_noop_job(fd);

		do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, job->submit);

		test_used_bo(fd, job->tile_alloc, 0);
		test_used_bo(fd, job->tile_state, 0);
		test_used_bo(fd, job->bcl->bo, 0);
		test_used_bo(fd, job->rcl->bo, 0);
		test_used_bo(fd, job->icl->bo, 0);

		igt_v3d_free_cl_job(fd, job);
	}

	igt_describe("Wait for BOs used for a noop job for 1 ns.");
	igt_subtest("used-bo-1ns") {
		struct v3d_cl_job *job = igt_v3d_noop_job(fd);

		do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, job->submit);

		test_used_bo(fd, job->tile_alloc, 1);
		test_used_bo(fd, job->tile_state, 1);
		test_used_bo(fd, job->bcl->bo, 1);
		test_used_bo(fd, job->rcl->bo, 1);
		test_used_bo(fd, job->icl->bo, 1);

		igt_v3d_free_cl_job(fd, job);
	}

	igt_describe("Wait for BOs used for a noop job for a long amount of time.");
	igt_subtest("used-bo") {
		struct v3d_cl_job *job = igt_v3d_noop_job(fd);

		do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, job->submit);

		igt_v3d_wait_bo(fd, job->tile_alloc, INT64_MAX);
		igt_v3d_wait_bo(fd, job->tile_state, INT64_MAX);
		igt_v3d_wait_bo(fd, job->bcl->bo, INT64_MAX);
		igt_v3d_wait_bo(fd, job->rcl->bo, INT64_MAX);
		igt_v3d_wait_bo(fd, job->icl->bo, INT64_MAX);

		igt_v3d_free_cl_job(fd, job);
	}

	igt_fixture {
		igt_v3d_free_bo(fd, bo);
		drm_close_driver(fd);
	}
}