7
7
8
8
#include <kunit/visibility.h>
9
9
10
+ #include <drm/drm_managed.h>
11
+
10
12
#include "regs/xe_gt_regs.h"
11
13
#include "xe_gt_types.h"
12
14
#include "xe_platform_types.h"
@@ -140,10 +142,44 @@ static const struct xe_rtp_entry_sr lrc_tunings[] = {
140
142
{}
141
143
};
142
144
145
+ /**
146
+ * xe_tuning_init - initialize gt with tunings bookkeeping
147
+ * @gt: GT instance to initialize
148
+ *
149
+ * Returns 0 for success, negative error code otherwise.
150
+ */
151
+ int xe_tuning_init (struct xe_gt * gt )
152
+ {
153
+ struct xe_device * xe = gt_to_xe (gt );
154
+ size_t n_lrc , n_engine , n_gt , total ;
155
+ unsigned long * p ;
156
+
157
+ n_gt = BITS_TO_LONGS (ARRAY_SIZE (gt_tunings ));
158
+ n_engine = BITS_TO_LONGS (ARRAY_SIZE (engine_tunings ));
159
+ n_lrc = BITS_TO_LONGS (ARRAY_SIZE (lrc_tunings ));
160
+ total = n_gt + n_engine + n_lrc ;
161
+
162
+ p = drmm_kzalloc (& xe -> drm , sizeof (* p ) * total , GFP_KERNEL );
163
+ if (!p )
164
+ return - ENOMEM ;
165
+
166
+ gt -> tuning_active .gt = p ;
167
+ p += n_gt ;
168
+ gt -> tuning_active .engine = p ;
169
+ p += n_engine ;
170
+ gt -> tuning_active .lrc = p ;
171
+
172
+ return 0 ;
173
+ }
174
+ ALLOW_ERROR_INJECTION (xe_tuning_init , ERRNO ); /* See xe_pci_probe() */
175
+
143
176
void xe_tuning_process_gt (struct xe_gt * gt )
144
177
{
145
178
struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER (gt );
146
179
180
+ xe_rtp_process_ctx_enable_active_tracking (& ctx ,
181
+ gt -> tuning_active .gt ,
182
+ ARRAY_SIZE (gt_tunings ));
147
183
xe_rtp_process_to_sr (& ctx , gt_tunings , & gt -> reg_sr );
148
184
}
149
185
EXPORT_SYMBOL_IF_KUNIT (xe_tuning_process_gt );
@@ -152,6 +188,9 @@ void xe_tuning_process_engine(struct xe_hw_engine *hwe)
152
188
{
153
189
struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER (hwe );
154
190
191
+ xe_rtp_process_ctx_enable_active_tracking (& ctx ,
192
+ hwe -> gt -> tuning_active .engine ,
193
+ ARRAY_SIZE (engine_tunings ));
155
194
xe_rtp_process_to_sr (& ctx , engine_tunings , & hwe -> reg_sr );
156
195
}
157
196
EXPORT_SYMBOL_IF_KUNIT (xe_tuning_process_engine );
@@ -168,5 +207,25 @@ void xe_tuning_process_lrc(struct xe_hw_engine *hwe)
168
207
{
169
208
struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER (hwe );
170
209
210
+ xe_rtp_process_ctx_enable_active_tracking (& ctx ,
211
+ hwe -> gt -> tuning_active .lrc ,
212
+ ARRAY_SIZE (lrc_tunings ));
171
213
xe_rtp_process_to_sr (& ctx , lrc_tunings , & hwe -> reg_lrc );
172
214
}
215
+
216
+ void xe_tuning_dump (struct xe_gt * gt , struct drm_printer * p )
217
+ {
218
+ size_t idx ;
219
+
220
+ drm_printf (p , "GT Tunings\n" );
221
+ for_each_set_bit (idx , gt -> tuning_active .gt , ARRAY_SIZE (gt_tunings ))
222
+ drm_printf_indent (p , 1 , "%s\n" , gt_tunings [idx ].name );
223
+
224
+ drm_printf (p , "\nEngine Tunings\n" );
225
+ for_each_set_bit (idx , gt -> tuning_active .engine , ARRAY_SIZE (engine_tunings ))
226
+ drm_printf_indent (p , 1 , "%s\n" , engine_tunings [idx ].name );
227
+
228
+ drm_printf (p , "\nLRC Tunings\n" );
229
+ for_each_set_bit (idx , gt -> tuning_active .lrc , ARRAY_SIZE (lrc_tunings ))
230
+ drm_printf_indent (p , 1 , "%s\n" , lrc_tunings [idx ].name );
231
+ }
0 commit comments