@@ -165,36 +165,38 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
165
165
adev -> mes .sdma_hqd_mask [i ] = 0xfc ;
166
166
}
167
167
168
- r = amdgpu_device_wb_get (adev , & adev -> mes .sch_ctx_offs );
169
- if (r ) {
170
- dev_err (adev -> dev ,
171
- "(%d) ring trail_fence_offs wb alloc failed\n" , r );
172
- goto error_ids ;
173
- }
174
- adev -> mes .sch_ctx_gpu_addr =
175
- adev -> wb .gpu_addr + (adev -> mes .sch_ctx_offs * 4 );
176
- adev -> mes .sch_ctx_ptr =
177
- (uint64_t * )& adev -> wb .wb [adev -> mes .sch_ctx_offs ];
168
+ for (i = 0 ; i < AMDGPU_MAX_MES_PIPES ; i ++ ) {
169
+ r = amdgpu_device_wb_get (adev , & adev -> mes .sch_ctx_offs [i ]);
170
+ if (r ) {
171
+ dev_err (adev -> dev ,
172
+ "(%d) ring trail_fence_offs wb alloc failed\n" ,
173
+ r );
174
+ goto error ;
175
+ }
176
+ adev -> mes .sch_ctx_gpu_addr [i ] =
177
+ adev -> wb .gpu_addr + (adev -> mes .sch_ctx_offs [i ] * 4 );
178
+ adev -> mes .sch_ctx_ptr [i ] =
179
+ (uint64_t * )& adev -> wb .wb [adev -> mes .sch_ctx_offs [i ]];
178
180
179
- r = amdgpu_device_wb_get (adev , & adev -> mes .query_status_fence_offs );
180
- if (r ) {
181
- amdgpu_device_wb_free (adev , adev -> mes .sch_ctx_offs );
182
- dev_err (adev -> dev ,
183
- "(%d) query_status_fence_offs wb alloc failed\n" , r );
184
- goto error_ids ;
181
+ r = amdgpu_device_wb_get (adev ,
182
+ & adev -> mes .query_status_fence_offs [i ]);
183
+ if (r ) {
184
+ dev_err (adev -> dev ,
185
+ "(%d) query_status_fence_offs wb alloc failed\n" ,
186
+ r );
187
+ goto error ;
188
+ }
189
+ adev -> mes .query_status_fence_gpu_addr [i ] = adev -> wb .gpu_addr +
190
+ (adev -> mes .query_status_fence_offs [i ] * 4 );
191
+ adev -> mes .query_status_fence_ptr [i ] =
192
+ (uint64_t * )& adev -> wb .wb [adev -> mes .query_status_fence_offs [i ]];
185
193
}
186
- adev -> mes .query_status_fence_gpu_addr =
187
- adev -> wb .gpu_addr + (adev -> mes .query_status_fence_offs * 4 );
188
- adev -> mes .query_status_fence_ptr =
189
- (uint64_t * )& adev -> wb .wb [adev -> mes .query_status_fence_offs ];
190
194
191
195
r = amdgpu_device_wb_get (adev , & adev -> mes .read_val_offs );
192
196
if (r ) {
193
- amdgpu_device_wb_free (adev , adev -> mes .sch_ctx_offs );
194
- amdgpu_device_wb_free (adev , adev -> mes .query_status_fence_offs );
195
197
dev_err (adev -> dev ,
196
198
"(%d) read_val_offs alloc failed\n" , r );
197
- goto error_ids ;
199
+ goto error ;
198
200
}
199
201
adev -> mes .read_val_gpu_addr =
200
202
adev -> wb .gpu_addr + (adev -> mes .read_val_offs * 4 );
@@ -214,10 +216,16 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
214
216
error_doorbell :
215
217
amdgpu_mes_doorbell_free (adev );
216
218
error :
217
- amdgpu_device_wb_free (adev , adev -> mes .sch_ctx_offs );
218
- amdgpu_device_wb_free (adev , adev -> mes .query_status_fence_offs );
219
- amdgpu_device_wb_free (adev , adev -> mes .read_val_offs );
220
- error_ids :
219
+ for (i = 0 ; i < AMDGPU_MAX_MES_PIPES ; i ++ ) {
220
+ if (adev -> mes .sch_ctx_ptr [i ])
221
+ amdgpu_device_wb_free (adev , adev -> mes .sch_ctx_offs [i ]);
222
+ if (adev -> mes .query_status_fence_ptr [i ])
223
+ amdgpu_device_wb_free (adev ,
224
+ adev -> mes .query_status_fence_offs [i ]);
225
+ }
226
+ if (adev -> mes .read_val_ptr )
227
+ amdgpu_device_wb_free (adev , adev -> mes .read_val_offs );
228
+
221
229
idr_destroy (& adev -> mes .pasid_idr );
222
230
idr_destroy (& adev -> mes .gang_id_idr );
223
231
idr_destroy (& adev -> mes .queue_id_idr );
@@ -228,13 +236,22 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
228
236
229
237
void amdgpu_mes_fini (struct amdgpu_device * adev )
230
238
{
239
+ int i ;
240
+
231
241
amdgpu_bo_free_kernel (& adev -> mes .event_log_gpu_obj ,
232
242
& adev -> mes .event_log_gpu_addr ,
233
243
& adev -> mes .event_log_cpu_addr );
234
244
235
- amdgpu_device_wb_free (adev , adev -> mes .sch_ctx_offs );
236
- amdgpu_device_wb_free (adev , adev -> mes .query_status_fence_offs );
237
- amdgpu_device_wb_free (adev , adev -> mes .read_val_offs );
245
+ for (i = 0 ; i < AMDGPU_MAX_MES_PIPES ; i ++ ) {
246
+ if (adev -> mes .sch_ctx_ptr [i ])
247
+ amdgpu_device_wb_free (adev , adev -> mes .sch_ctx_offs [i ]);
248
+ if (adev -> mes .query_status_fence_ptr [i ])
249
+ amdgpu_device_wb_free (adev ,
250
+ adev -> mes .query_status_fence_offs [i ]);
251
+ }
252
+ if (adev -> mes .read_val_ptr )
253
+ amdgpu_device_wb_free (adev , adev -> mes .read_val_offs );
254
+
238
255
amdgpu_mes_doorbell_free (adev );
239
256
240
257
idr_destroy (& adev -> mes .pasid_idr );
0 commit comments