Loading...
Note: File does not exist in v4.6.
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 "xe_device.h"
12#include "xe_pci_test.h"
13#include "xe_reg_sr.h"
14#include "xe_tuning.h"
15#include "xe_wa.h"
16
17struct platform_test_case {
18 const char *name;
19 enum xe_platform platform;
20 enum xe_subplatform subplatform;
21 u32 graphics_verx100;
22 u32 media_verx100;
23 struct xe_step_info step;
24};
25
26#define PLATFORM_CASE(platform__, graphics_step__) \
27 { \
28 .name = #platform__ " (" #graphics_step__ ")", \
29 .platform = XE_ ## platform__, \
30 .subplatform = XE_SUBPLATFORM_NONE, \
31 .step = { .graphics = STEP_ ## graphics_step__ } \
32 }
33
34
35#define SUBPLATFORM_CASE(platform__, subplatform__, graphics_step__) \
36 { \
37 .name = #platform__ "_" #subplatform__ " (" #graphics_step__ ")", \
38 .platform = XE_ ## platform__, \
39 .subplatform = XE_SUBPLATFORM_ ## platform__ ## _ ## subplatform__, \
40 .step = { .graphics = STEP_ ## graphics_step__ } \
41 }
42
43#define GMDID_CASE(platform__, graphics_verx100__, graphics_step__, \
44 media_verx100__, media_step__) \
45 { \
46 .name = #platform__ " (g:" #graphics_step__ ", m:" #media_step__ ")",\
47 .platform = XE_ ## platform__, \
48 .subplatform = XE_SUBPLATFORM_NONE, \
49 .graphics_verx100 = graphics_verx100__, \
50 .media_verx100 = media_verx100__, \
51 .step = { .graphics = STEP_ ## graphics_step__, \
52 .media = STEP_ ## media_step__ } \
53 }
54
55static const struct platform_test_case cases[] = {
56 PLATFORM_CASE(TIGERLAKE, B0),
57 PLATFORM_CASE(DG1, A0),
58 PLATFORM_CASE(DG1, B0),
59 PLATFORM_CASE(ALDERLAKE_S, A0),
60 PLATFORM_CASE(ALDERLAKE_S, B0),
61 PLATFORM_CASE(ALDERLAKE_S, C0),
62 PLATFORM_CASE(ALDERLAKE_S, D0),
63 PLATFORM_CASE(ALDERLAKE_P, A0),
64 PLATFORM_CASE(ALDERLAKE_P, B0),
65 PLATFORM_CASE(ALDERLAKE_P, C0),
66 SUBPLATFORM_CASE(ALDERLAKE_S, RPLS, D0),
67 SUBPLATFORM_CASE(ALDERLAKE_P, RPLU, E0),
68 SUBPLATFORM_CASE(DG2, G10, A0),
69 SUBPLATFORM_CASE(DG2, G10, A1),
70 SUBPLATFORM_CASE(DG2, G10, B0),
71 SUBPLATFORM_CASE(DG2, G10, C0),
72 SUBPLATFORM_CASE(DG2, G11, A0),
73 SUBPLATFORM_CASE(DG2, G11, B0),
74 SUBPLATFORM_CASE(DG2, G11, B1),
75 SUBPLATFORM_CASE(DG2, G12, A0),
76 SUBPLATFORM_CASE(DG2, G12, A1),
77 GMDID_CASE(METEORLAKE, 1270, A0, 1300, A0),
78 GMDID_CASE(METEORLAKE, 1271, A0, 1300, A0),
79 GMDID_CASE(LUNARLAKE, 2004, A0, 2000, A0),
80 GMDID_CASE(LUNARLAKE, 2004, B0, 2000, A0),
81};
82
83static void platform_desc(const struct platform_test_case *t, char *desc)
84{
85 strscpy(desc, t->name, KUNIT_PARAM_DESC_SIZE);
86}
87
88KUNIT_ARRAY_PARAM(platform, cases, platform_desc);
89
90static int xe_wa_test_init(struct kunit *test)
91{
92 const struct platform_test_case *param = test->param_value;
93 struct xe_pci_fake_data data = {
94 .platform = param->platform,
95 .subplatform = param->subplatform,
96 .graphics_verx100 = param->graphics_verx100,
97 .media_verx100 = param->media_verx100,
98 .graphics_step = param->step.graphics,
99 .media_step = param->step.media,
100 };
101 struct xe_device *xe;
102 struct device *dev;
103 int ret;
104
105 dev = drm_kunit_helper_alloc_device(test);
106 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
107
108 xe = drm_kunit_helper_alloc_drm_device(test, dev,
109 struct xe_device,
110 drm, DRIVER_GEM);
111 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xe);
112
113 test->priv = &data;
114 ret = xe_pci_fake_device_init(xe);
115 KUNIT_ASSERT_EQ(test, ret, 0);
116
117 if (!param->graphics_verx100)
118 xe->info.step = param->step;
119
120 /* TODO: init hw engines for engine/LRC WAs */
121 xe->drm.dev = dev;
122 test->priv = xe;
123
124 return 0;
125}
126
127static void xe_wa_test_exit(struct kunit *test)
128{
129 struct xe_device *xe = test->priv;
130
131 drm_kunit_helper_free_device(test, xe->drm.dev);
132}
133
134static void xe_wa_gt(struct kunit *test)
135{
136 struct xe_device *xe = test->priv;
137 struct xe_gt *gt;
138 int id;
139
140 for_each_gt(gt, xe, id) {
141 xe_reg_sr_init(>->reg_sr, "GT", xe);
142
143 xe_wa_process_gt(gt);
144 xe_tuning_process_gt(gt);
145
146 KUNIT_ASSERT_EQ(test, gt->reg_sr.errors, 0);
147 }
148}
149
150static struct kunit_case xe_wa_tests[] = {
151 KUNIT_CASE_PARAM(xe_wa_gt, platform_gen_params),
152 {}
153};
154
155static struct kunit_suite xe_rtp_test_suite = {
156 .name = "xe_wa",
157 .init = xe_wa_test_init,
158 .exit = xe_wa_test_exit,
159 .test_cases = xe_wa_tests,
160};
161
162kunit_test_suite(xe_rtp_test_suite);
163
164MODULE_AUTHOR("Intel Corporation");
165MODULE_LICENSE("GPL");
166MODULE_DESCRIPTION("xe_wa kunit test");
167MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING);