@@ -266,6 +266,8 @@ static int convert_to_mes_queue_type(int queue_type)
266
266
return MES_QUEUE_TYPE_COMPUTE ;
267
267
else if (queue_type == AMDGPU_RING_TYPE_SDMA )
268
268
return MES_QUEUE_TYPE_SDMA ;
269
+ else if (queue_type == AMDGPU_RING_TYPE_MES )
270
+ return MES_QUEUE_TYPE_SCHQ ;
269
271
else
270
272
BUG ();
271
273
return -1 ;
@@ -352,6 +354,7 @@ static int mes_v12_0_map_legacy_queue(struct amdgpu_mes *mes,
352
354
struct mes_map_legacy_queue_input * input )
353
355
{
354
356
union MESAPI__ADD_QUEUE mes_add_queue_pkt ;
357
+ int pipe ;
355
358
356
359
memset (& mes_add_queue_pkt , 0 , sizeof (mes_add_queue_pkt ));
357
360
@@ -368,8 +371,12 @@ static int mes_v12_0_map_legacy_queue(struct amdgpu_mes *mes,
368
371
convert_to_mes_queue_type (input -> queue_type );
369
372
mes_add_queue_pkt .map_legacy_kq = 1 ;
370
373
371
- return mes_v12_0_submit_pkt_and_poll_completion (mes ,
372
- AMDGPU_MES_SCHED_PIPE ,
374
+ if (mes -> adev -> enable_uni_mes )
375
+ pipe = AMDGPU_MES_KIQ_PIPE ;
376
+ else
377
+ pipe = AMDGPU_MES_SCHED_PIPE ;
378
+
379
+ return mes_v12_0_submit_pkt_and_poll_completion (mes , pipe ,
373
380
& mes_add_queue_pkt , sizeof (mes_add_queue_pkt ),
374
381
offsetof(union MESAPI__ADD_QUEUE , api_status ));
375
382
}
@@ -378,6 +385,7 @@ static int mes_v12_0_unmap_legacy_queue(struct amdgpu_mes *mes,
378
385
struct mes_unmap_legacy_queue_input * input )
379
386
{
380
387
union MESAPI__REMOVE_QUEUE mes_remove_queue_pkt ;
388
+ int pipe ;
381
389
382
390
memset (& mes_remove_queue_pkt , 0 , sizeof (mes_remove_queue_pkt ));
383
391
@@ -402,8 +410,12 @@ static int mes_v12_0_unmap_legacy_queue(struct amdgpu_mes *mes,
402
410
convert_to_mes_queue_type (input -> queue_type );
403
411
}
404
412
405
- return mes_v12_0_submit_pkt_and_poll_completion (mes ,
406
- AMDGPU_MES_SCHED_PIPE ,
413
+ if (mes -> adev -> enable_uni_mes )
414
+ pipe = AMDGPU_MES_KIQ_PIPE ;
415
+ else
416
+ pipe = AMDGPU_MES_SCHED_PIPE ;
417
+
418
+ return mes_v12_0_submit_pkt_and_poll_completion (mes , pipe ,
407
419
& mes_remove_queue_pkt , sizeof (mes_remove_queue_pkt ),
408
420
offsetof(union MESAPI__REMOVE_QUEUE , api_status ));
409
421
}
@@ -439,6 +451,7 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes,
439
451
struct mes_misc_op_input * input )
440
452
{
441
453
union MESAPI__MISC misc_pkt ;
454
+ int pipe ;
442
455
443
456
memset (& misc_pkt , 0 , sizeof (misc_pkt ));
444
457
@@ -491,8 +504,12 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes,
491
504
return - EINVAL ;
492
505
}
493
506
494
- return mes_v12_0_submit_pkt_and_poll_completion (mes ,
495
- AMDGPU_MES_SCHED_PIPE ,
507
+ if (mes -> adev -> enable_uni_mes )
508
+ pipe = AMDGPU_MES_KIQ_PIPE ;
509
+ else
510
+ pipe = AMDGPU_MES_SCHED_PIPE ;
511
+
512
+ return mes_v12_0_submit_pkt_and_poll_completion (mes , pipe ,
496
513
& misc_pkt , sizeof (misc_pkt ),
497
514
offsetof(union MESAPI__MISC , api_status ));
498
515
}
@@ -1107,14 +1124,12 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,
1107
1124
struct amdgpu_ring * ring ;
1108
1125
int r ;
1109
1126
1110
- if (pipe == AMDGPU_MES_KIQ_PIPE )
1127
+ if (! adev -> enable_uni_mes && pipe == AMDGPU_MES_KIQ_PIPE )
1111
1128
ring = & adev -> gfx .kiq [0 ].ring ;
1112
- else if (pipe == AMDGPU_MES_SCHED_PIPE )
1113
- ring = & adev -> mes .ring [0 ];
1114
1129
else
1115
- BUG () ;
1130
+ ring = & adev -> mes . ring [ pipe ] ;
1116
1131
1117
- if ((pipe == AMDGPU_MES_SCHED_PIPE ) &&
1132
+ if ((adev -> enable_uni_mes || pipe == AMDGPU_MES_SCHED_PIPE ) &&
1118
1133
(amdgpu_in_reset (adev ) || adev -> in_suspend )) {
1119
1134
* (ring -> wptr_cpu_addr ) = 0 ;
1120
1135
* (ring -> rptr_cpu_addr ) = 0 ;
@@ -1126,13 +1141,12 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,
1126
1141
return r ;
1127
1142
1128
1143
if (pipe == AMDGPU_MES_SCHED_PIPE ) {
1129
- if (adev -> enable_uni_mes ) {
1130
- mes_v12_0_queue_init_register ( ring );
1131
- } else {
1144
+ if (adev -> enable_uni_mes )
1145
+ r = amdgpu_mes_map_legacy_queue ( adev , ring );
1146
+ else
1132
1147
r = mes_v12_0_kiq_enable_queue (adev );
1133
- if (r )
1134
- return r ;
1135
- }
1148
+ if (r )
1149
+ return r ;
1136
1150
} else {
1137
1151
mes_v12_0_queue_init_register (ring );
1138
1152
}
@@ -1152,25 +1166,29 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,
1152
1166
return 0 ;
1153
1167
}
1154
1168
1155
- static int mes_v12_0_ring_init (struct amdgpu_device * adev )
1169
+ static int mes_v12_0_ring_init (struct amdgpu_device * adev , int pipe )
1156
1170
{
1157
1171
struct amdgpu_ring * ring ;
1158
1172
1159
- ring = & adev -> mes .ring [0 ];
1173
+ ring = & adev -> mes .ring [pipe ];
1160
1174
1161
1175
ring -> funcs = & mes_v12_0_ring_funcs ;
1162
1176
1163
1177
ring -> me = 3 ;
1164
- ring -> pipe = 0 ;
1178
+ ring -> pipe = pipe ;
1165
1179
ring -> queue = 0 ;
1166
1180
1167
1181
ring -> ring_obj = NULL ;
1168
1182
ring -> use_doorbell = true;
1169
- ring -> doorbell_index = adev -> doorbell_index .mes_ring0 << 1 ;
1170
- ring -> eop_gpu_addr = adev -> mes .eop_gpu_addr [AMDGPU_MES_SCHED_PIPE ];
1183
+ ring -> eop_gpu_addr = adev -> mes .eop_gpu_addr [pipe ];
1171
1184
ring -> no_scheduler = true;
1172
1185
sprintf (ring -> name , "mes_%d.%d.%d" , ring -> me , ring -> pipe , ring -> queue );
1173
1186
1187
+ if (pipe == AMDGPU_MES_SCHED_PIPE )
1188
+ ring -> doorbell_index = adev -> doorbell_index .mes_ring0 << 1 ;
1189
+ else
1190
+ ring -> doorbell_index = adev -> doorbell_index .mes_ring1 << 1 ;
1191
+
1174
1192
return amdgpu_ring_init (adev , ring , 1024 , NULL , 0 ,
1175
1193
AMDGPU_RING_PRIO_DEFAULT , NULL );
1176
1194
}
@@ -1184,7 +1202,7 @@ static int mes_v12_0_kiq_ring_init(struct amdgpu_device *adev)
1184
1202
ring = & adev -> gfx .kiq [0 ].ring ;
1185
1203
1186
1204
ring -> me = 3 ;
1187
- ring -> pipe = adev -> enable_uni_mes ? 0 : 1 ;
1205
+ ring -> pipe = 1 ;
1188
1206
ring -> queue = 0 ;
1189
1207
1190
1208
ring -> adev = NULL ;
@@ -1206,12 +1224,10 @@ static int mes_v12_0_mqd_sw_init(struct amdgpu_device *adev,
1206
1224
int r , mqd_size = sizeof (struct v12_compute_mqd );
1207
1225
struct amdgpu_ring * ring ;
1208
1226
1209
- if (pipe == AMDGPU_MES_KIQ_PIPE )
1227
+ if (! adev -> enable_uni_mes && pipe == AMDGPU_MES_KIQ_PIPE )
1210
1228
ring = & adev -> gfx .kiq [0 ].ring ;
1211
- else if (pipe == AMDGPU_MES_SCHED_PIPE )
1212
- ring = & adev -> mes .ring [0 ];
1213
1229
else
1214
- BUG () ;
1230
+ ring = & adev -> mes . ring [ pipe ] ;
1215
1231
1216
1232
if (ring -> mqd_obj )
1217
1233
return 0 ;
@@ -1252,28 +1268,22 @@ static int mes_v12_0_sw_init(void *handle)
1252
1268
return r ;
1253
1269
1254
1270
for (pipe = 0 ; pipe < AMDGPU_MAX_MES_PIPES ; pipe ++ ) {
1255
- if (!adev -> enable_mes_kiq && pipe == AMDGPU_MES_KIQ_PIPE )
1256
- continue ;
1257
-
1258
1271
r = mes_v12_0_allocate_eop_buf (adev , pipe );
1259
1272
if (r )
1260
1273
return r ;
1261
1274
1262
1275
r = mes_v12_0_mqd_sw_init (adev , pipe );
1263
1276
if (r )
1264
1277
return r ;
1265
- }
1266
1278
1267
- if (adev -> enable_mes_kiq ) {
1268
- r = mes_v12_0_kiq_ring_init (adev );
1279
+ if (!adev -> enable_uni_mes && pipe == AMDGPU_MES_KIQ_PIPE )
1280
+ r = mes_v12_0_kiq_ring_init (adev );
1281
+ else
1282
+ r = mes_v12_0_ring_init (adev , pipe );
1269
1283
if (r )
1270
1284
return r ;
1271
1285
}
1272
1286
1273
- r = mes_v12_0_ring_init (adev );
1274
- if (r )
1275
- return r ;
1276
-
1277
1287
return 0 ;
1278
1288
}
1279
1289
@@ -1368,10 +1378,10 @@ static int mes_v12_0_kiq_hw_init(struct amdgpu_device *adev)
1368
1378
{
1369
1379
int r = 0 ;
1370
1380
1371
- mes_v12_0_kiq_setting (& adev -> gfx .kiq [0 ].ring );
1372
-
1373
1381
if (adev -> enable_uni_mes )
1374
- return mes_v12_0_hw_init (adev );
1382
+ mes_v12_0_kiq_setting (& adev -> mes .ring [AMDGPU_MES_KIQ_PIPE ]);
1383
+ else
1384
+ mes_v12_0_kiq_setting (& adev -> gfx .kiq [0 ].ring );
1375
1385
1376
1386
if (adev -> firmware .load_type == AMDGPU_FW_LOAD_DIRECT ) {
1377
1387
@@ -1398,6 +1408,14 @@ static int mes_v12_0_kiq_hw_init(struct amdgpu_device *adev)
1398
1408
if (r )
1399
1409
goto failure ;
1400
1410
1411
+ if (adev -> enable_uni_mes ) {
1412
+ r = mes_v12_0_set_hw_resources (& adev -> mes , AMDGPU_MES_KIQ_PIPE );
1413
+ if (r )
1414
+ goto failure ;
1415
+
1416
+ mes_v12_0_set_hw_resources_1 (& adev -> mes , AMDGPU_MES_KIQ_PIPE );
1417
+ }
1418
+
1401
1419
r = mes_v12_0_hw_init (adev );
1402
1420
if (r )
1403
1421
goto failure ;
@@ -1429,7 +1447,7 @@ static int mes_v12_0_hw_init(void *handle)
1429
1447
if (adev -> mes .ring [0 ].sched .ready )
1430
1448
goto out ;
1431
1449
1432
- if (!adev -> enable_mes_kiq || adev -> enable_uni_mes ) {
1450
+ if (!adev -> enable_mes_kiq ) {
1433
1451
if (adev -> firmware .load_type == AMDGPU_FW_LOAD_DIRECT ) {
1434
1452
r = mes_v12_0_load_microcode (adev ,
1435
1453
AMDGPU_MES_SCHED_PIPE , true);
@@ -1449,6 +1467,9 @@ static int mes_v12_0_hw_init(void *handle)
1449
1467
mes_v12_0_enable (adev , true);
1450
1468
}
1451
1469
1470
+ /* Enable the MES to handle doorbell ring on unmapped queue */
1471
+ mes_v12_0_enable_unmapped_doorbell_handling (& adev -> mes , true);
1472
+
1452
1473
r = mes_v12_0_queue_init (adev , AMDGPU_MES_SCHED_PIPE );
1453
1474
if (r )
1454
1475
goto failure ;
@@ -1462,9 +1483,6 @@ static int mes_v12_0_hw_init(void *handle)
1462
1483
1463
1484
mes_v12_0_init_aggregated_doorbell (& adev -> mes );
1464
1485
1465
- /* Enable the MES to handle doorbell ring on unmapped queue */
1466
- mes_v12_0_enable_unmapped_doorbell_handling (& adev -> mes , true);
1467
-
1468
1486
r = mes_v12_0_query_sched_status (& adev -> mes , AMDGPU_MES_SCHED_PIPE );
1469
1487
if (r ) {
1470
1488
DRM_ERROR ("MES is busy\n" );
0 commit comments