xref: /linux/drivers/gpu/drm/xe/tests/xe_pci_test.c (revision dd0e89e5edc20d3875ed7ded48e7e97118cdfbc8)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #include <drm/drm_drv.h>
7 #include <drm/drm_kunit_helpers.h>
8 
9 #include <kunit/test.h>
10 
11 #include "tests/xe_test.h"
12 
13 #include "xe_device.h"
14 #include "xe_pci_test.h"
15 #include "xe_pci_types.h"
16 
17 static void check_graphics_ip(const struct xe_graphics_desc *graphics)
18 {
19 	struct kunit *test = xe_cur_kunit();
20 	u64 mask = graphics->hw_engine_mask;
21 
22 	/* RCS, CCS, and BCS engines are allowed on the graphics IP */
23 	mask &= ~(XE_HW_ENGINE_RCS_MASK |
24 		  XE_HW_ENGINE_CCS_MASK |
25 		  XE_HW_ENGINE_BCS_MASK);
26 
27 	/* Any remaining engines are an error */
28 	KUNIT_ASSERT_EQ(test, mask, 0);
29 }
30 
31 static void check_media_ip(const struct xe_media_desc *media)
32 {
33 	struct kunit *test = xe_cur_kunit();
34 	u64 mask = media->hw_engine_mask;
35 
36 	/*
37 	 * VCS and VECS engines are allowed on the media IP
38 	 *
39 	 * TODO:  Add GSCCS once support is added to the driver.
40 	 */
41 	mask &= ~(XE_HW_ENGINE_VCS_MASK |
42 		  XE_HW_ENGINE_VECS_MASK);
43 
44 	/* Any remaining engines are an error */
45 	KUNIT_ASSERT_EQ(test, mask, 0);
46 }
47 
48 static void xe_gmdid_graphics_ip(struct kunit *test)
49 {
50 	xe_call_for_each_graphics_ip(check_graphics_ip);
51 }
52 
53 static void xe_gmdid_media_ip(struct kunit *test)
54 {
55 	xe_call_for_each_media_ip(check_media_ip);
56 }
57 
58 static struct kunit_case xe_pci_tests[] = {
59 	KUNIT_CASE(xe_gmdid_graphics_ip),
60 	KUNIT_CASE(xe_gmdid_media_ip),
61 	{}
62 };
63 
64 static struct kunit_suite xe_pci_test_suite = {
65 	.name = "xe_pci",
66 	.test_cases = xe_pci_tests,
67 };
68 
69 kunit_test_suite(xe_pci_test_suite);
70 
71 MODULE_AUTHOR("Intel Corporation");
72 MODULE_LICENSE("GPL");
73 MODULE_DESCRIPTION("xe_pci kunit test");
74 MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING);
75