xref: /linux/drivers/gpu/drm/i915/gt/selftest_engine_cs.c (revision 1517d90cfafe0f95fd7863d04e1596f7beb7dfa8)
1 /*
2  * SPDX-License-Identifier: GPL-2.0
3  *
4  * Copyright © 2018 Intel Corporation
5  */
6 
7 #include "../i915_selftest.h"
8 
9 static int intel_mmio_bases_check(void *arg)
10 {
11 	int i, j;
12 
13 	for (i = 0; i < ARRAY_SIZE(intel_engines); i++) {
14 		const struct engine_info *info = &intel_engines[i];
15 		u8 prev = U8_MAX;
16 
17 		for (j = 0; j < MAX_MMIO_BASES; j++) {
18 			u8 gen = info->mmio_bases[j].gen;
19 			u32 base = info->mmio_bases[j].base;
20 
21 			if (gen >= prev) {
22 				pr_err("%s(%s, class:%d, instance:%d): mmio base for gen %x is before the one for gen %x\n",
23 				       __func__,
24 				       intel_engine_class_repr(info->class),
25 				       info->class, info->instance,
26 				       prev, gen);
27 				return -EINVAL;
28 			}
29 
30 			if (gen == 0)
31 				break;
32 
33 			if (!base) {
34 				pr_err("%s(%s, class:%d, instance:%d): invalid mmio base (%x) for gen %x at entry %u\n",
35 				       __func__,
36 				       intel_engine_class_repr(info->class),
37 				       info->class, info->instance,
38 				       base, gen, j);
39 				return -EINVAL;
40 			}
41 
42 			prev = gen;
43 		}
44 
45 		pr_debug("%s: min gen supported for %s%d is %d\n",
46 			 __func__,
47 			 intel_engine_class_repr(info->class),
48 			 info->instance,
49 			 prev);
50 	}
51 
52 	return 0;
53 }
54 
55 int intel_engine_cs_mock_selftests(void)
56 {
57 	static const struct i915_subtest tests[] = {
58 		SUBTEST(intel_mmio_bases_check),
59 	};
60 
61 	return i915_subtests(tests, NULL);
62 }
63