xref: /aosp_15_r20/external/igt-gpu-tools/tests/vc4_wait_seqno.c (revision d83cc019efdc2edc6c4b16e9034a3ceb8d35d77c)
1 /*
2  * Copyright © 2016 Broadcom
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #include "igt.h"
25 #include <unistd.h>
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <string.h>
29 #include <fcntl.h>
30 #include <inttypes.h>
31 #include <errno.h>
32 #include <sys/stat.h>
33 #include <sys/ioctl.h>
34 #include "vc4_drm.h"
35 
36 igt_main
37 {
38 	int fd;
39 
40 	igt_fixture
41 		fd = drm_open_driver(DRIVER_VC4);
42 
43 	/* A 64-bit seqno should never hit the maximum value over the
44 	 * lifetime of the system.  (A submit per 1000 cycles at 1Ghz
45 	 * would still take 584000 years).  As a result, we can wait
46 	 * for it and be sure of a timeout.
47 	 */
48 	igt_subtest("bad-seqno-0ns") {
49 		struct drm_vc4_wait_seqno arg = {
50 			.seqno = ~0ull,
51 			.timeout_ns = 0,
52 		};
53 		do_ioctl_err(fd, DRM_IOCTL_VC4_WAIT_SEQNO, &arg, ETIME);
54 	}
55 
56 	igt_subtest("bad-seqno-1ns") {
57 		struct drm_vc4_wait_seqno arg = {
58 			.seqno = ~0ull,
59 			.timeout_ns = 1,
60 		};
61 		do_ioctl_err(fd, DRM_IOCTL_VC4_WAIT_SEQNO, &arg, ETIME);
62 	}
63 
64 	igt_fixture
65 		close(fd);
66 }
67