12
12
#include "selftests/igt_spinner.h"
13
13
14
14
struct live_mocs {
15
- struct drm_i915_mocs_table mocs ;
16
- struct drm_i915_mocs_table l3cc ;
15
+ struct drm_i915_mocs_table table ;
16
+ struct drm_i915_mocs_table * mocs ;
17
+ struct drm_i915_mocs_table * l3cc ;
17
18
struct i915_vma * scratch ;
18
19
void * vaddr ;
19
20
};
@@ -58,21 +59,20 @@ static int request_add_spin(struct i915_request *rq, struct igt_spinner *spin)
58
59
59
60
static int live_mocs_init (struct live_mocs * arg , struct intel_gt * gt )
60
61
{
61
- struct drm_i915_mocs_table table ;
62
62
unsigned int flags ;
63
63
int err ;
64
64
65
65
memset (arg , 0 , sizeof (* arg ));
66
66
67
- flags = get_mocs_settings (gt -> i915 , & table );
67
+ flags = get_mocs_settings (gt -> i915 , & arg -> table );
68
68
if (!flags )
69
69
return - EINVAL ;
70
70
71
71
if (flags & HAS_RENDER_L3CC )
72
- arg -> l3cc = table ;
72
+ arg -> l3cc = & arg -> table ;
73
73
74
74
if (flags & (HAS_GLOBAL_MOCS | HAS_ENGINE_MOCS ))
75
- arg -> mocs = table ;
75
+ arg -> mocs = & arg -> table ;
76
76
77
77
arg -> scratch = __vm_create_scratch_for_read (& gt -> ggtt -> vm , PAGE_SIZE );
78
78
if (IS_ERR (arg -> scratch ))
@@ -130,6 +130,9 @@ static int read_mocs_table(struct i915_request *rq,
130
130
{
131
131
u32 addr ;
132
132
133
+ if (!table )
134
+ return 0 ;
135
+
133
136
if (HAS_GLOBAL_MOCS_REGISTERS (rq -> engine -> i915 ))
134
137
addr = global_mocs_offset ();
135
138
else
@@ -144,6 +147,9 @@ static int read_l3cc_table(struct i915_request *rq,
144
147
{
145
148
u32 addr = i915_mmio_reg_offset (GEN9_LNCFCMOCS (0 ));
146
149
150
+ if (!table )
151
+ return 0 ;
152
+
147
153
return read_regs (rq , addr , (table -> n_entries + 1 ) / 2 , offset );
148
154
}
149
155
@@ -154,6 +160,9 @@ static int check_mocs_table(struct intel_engine_cs *engine,
154
160
unsigned int i ;
155
161
u32 expect ;
156
162
163
+ if (!table )
164
+ return 0 ;
165
+
157
166
for_each_mocs (expect , table , i ) {
158
167
if (* * vaddr != expect ) {
159
168
pr_err ("%s: Invalid MOCS[%d] entry, found %08x, expected %08x\n" ,
@@ -185,6 +194,9 @@ static int check_l3cc_table(struct intel_engine_cs *engine,
185
194
unsigned int i ;
186
195
u32 expect ;
187
196
197
+ if (!table )
198
+ return 0 ;
199
+
188
200
for_each_l3cc (expect , table , i ) {
189
201
if (!mcr_range (engine -> i915 , reg ) && * * vaddr != expect ) {
190
202
pr_err ("%s: Invalid L3CC[%d] entry, found %08x, expected %08x\n" ,
@@ -222,9 +234,9 @@ static int check_mocs_engine(struct live_mocs *arg,
222
234
/* Read the mocs tables back using SRM */
223
235
offset = i915_ggtt_offset (vma );
224
236
if (!err )
225
- err = read_mocs_table (rq , & arg -> mocs , & offset );
237
+ err = read_mocs_table (rq , arg -> mocs , & offset );
226
238
if (!err && ce -> engine -> class == RENDER_CLASS )
227
- err = read_l3cc_table (rq , & arg -> l3cc , & offset );
239
+ err = read_l3cc_table (rq , arg -> l3cc , & offset );
228
240
offset -= i915_ggtt_offset (vma );
229
241
GEM_BUG_ON (offset > PAGE_SIZE );
230
242
@@ -235,9 +247,9 @@ static int check_mocs_engine(struct live_mocs *arg,
235
247
/* Compare the results against the expected tables */
236
248
vaddr = arg -> vaddr ;
237
249
if (!err )
238
- err = check_mocs_table (ce -> engine , & arg -> mocs , & vaddr );
250
+ err = check_mocs_table (ce -> engine , arg -> mocs , & vaddr );
239
251
if (!err && ce -> engine -> class == RENDER_CLASS )
240
- err = check_l3cc_table (ce -> engine , & arg -> l3cc , & vaddr );
252
+ err = check_l3cc_table (ce -> engine , arg -> l3cc , & vaddr );
241
253
if (err )
242
254
return err ;
243
255
0 commit comments