Skip to content

Commit 1097727

Browse files
Jack Xiaoalexdeucher
authored andcommitted
drm/amdgpu/mes12: adjust mes12 sw/hw init for multiple pipes
Adjust mes12 sw/hw initiailization for both pipe0 and pipe1 enablement. The two pipes are almost identical pipe. Pipe0 behaves like schq and pipe1 like kiq, pipe0 was mapped by pipe1. Signed-off-by: Jack Xiao <[email protected]> Acked-by: Alex Deucher <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit aa539da)
1 parent 3738a7f commit 1097727

File tree

1 file changed

+62
-44
lines changed

1 file changed

+62
-44
lines changed

drivers/gpu/drm/amd/amdgpu/mes_v12_0.c

Lines changed: 62 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ static int convert_to_mes_queue_type(int queue_type)
266266
return MES_QUEUE_TYPE_COMPUTE;
267267
else if (queue_type == AMDGPU_RING_TYPE_SDMA)
268268
return MES_QUEUE_TYPE_SDMA;
269+
else if (queue_type == AMDGPU_RING_TYPE_MES)
270+
return MES_QUEUE_TYPE_SCHQ;
269271
else
270272
BUG();
271273
return -1;
@@ -352,6 +354,7 @@ static int mes_v12_0_map_legacy_queue(struct amdgpu_mes *mes,
352354
struct mes_map_legacy_queue_input *input)
353355
{
354356
union MESAPI__ADD_QUEUE mes_add_queue_pkt;
357+
int pipe;
355358

356359
memset(&mes_add_queue_pkt, 0, sizeof(mes_add_queue_pkt));
357360

@@ -368,8 +371,12 @@ static int mes_v12_0_map_legacy_queue(struct amdgpu_mes *mes,
368371
convert_to_mes_queue_type(input->queue_type);
369372
mes_add_queue_pkt.map_legacy_kq = 1;
370373

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,
373380
&mes_add_queue_pkt, sizeof(mes_add_queue_pkt),
374381
offsetof(union MESAPI__ADD_QUEUE, api_status));
375382
}
@@ -378,6 +385,7 @@ static int mes_v12_0_unmap_legacy_queue(struct amdgpu_mes *mes,
378385
struct mes_unmap_legacy_queue_input *input)
379386
{
380387
union MESAPI__REMOVE_QUEUE mes_remove_queue_pkt;
388+
int pipe;
381389

382390
memset(&mes_remove_queue_pkt, 0, sizeof(mes_remove_queue_pkt));
383391

@@ -402,8 +410,12 @@ static int mes_v12_0_unmap_legacy_queue(struct amdgpu_mes *mes,
402410
convert_to_mes_queue_type(input->queue_type);
403411
}
404412

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,
407419
&mes_remove_queue_pkt, sizeof(mes_remove_queue_pkt),
408420
offsetof(union MESAPI__REMOVE_QUEUE, api_status));
409421
}
@@ -439,6 +451,7 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes,
439451
struct mes_misc_op_input *input)
440452
{
441453
union MESAPI__MISC misc_pkt;
454+
int pipe;
442455

443456
memset(&misc_pkt, 0, sizeof(misc_pkt));
444457

@@ -491,8 +504,12 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes,
491504
return -EINVAL;
492505
}
493506

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,
496513
&misc_pkt, sizeof(misc_pkt),
497514
offsetof(union MESAPI__MISC, api_status));
498515
}
@@ -1107,14 +1124,12 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,
11071124
struct amdgpu_ring *ring;
11081125
int r;
11091126

1110-
if (pipe == AMDGPU_MES_KIQ_PIPE)
1127+
if (!adev->enable_uni_mes && pipe == AMDGPU_MES_KIQ_PIPE)
11111128
ring = &adev->gfx.kiq[0].ring;
1112-
else if (pipe == AMDGPU_MES_SCHED_PIPE)
1113-
ring = &adev->mes.ring[0];
11141129
else
1115-
BUG();
1130+
ring = &adev->mes.ring[pipe];
11161131

1117-
if ((pipe == AMDGPU_MES_SCHED_PIPE) &&
1132+
if ((adev->enable_uni_mes || pipe == AMDGPU_MES_SCHED_PIPE) &&
11181133
(amdgpu_in_reset(adev) || adev->in_suspend)) {
11191134
*(ring->wptr_cpu_addr) = 0;
11201135
*(ring->rptr_cpu_addr) = 0;
@@ -1126,13 +1141,12 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,
11261141
return r;
11271142

11281143
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
11321147
r = mes_v12_0_kiq_enable_queue(adev);
1133-
if (r)
1134-
return r;
1135-
}
1148+
if (r)
1149+
return r;
11361150
} else {
11371151
mes_v12_0_queue_init_register(ring);
11381152
}
@@ -1152,25 +1166,29 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,
11521166
return 0;
11531167
}
11541168

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)
11561170
{
11571171
struct amdgpu_ring *ring;
11581172

1159-
ring = &adev->mes.ring[0];
1173+
ring = &adev->mes.ring[pipe];
11601174

11611175
ring->funcs = &mes_v12_0_ring_funcs;
11621176

11631177
ring->me = 3;
1164-
ring->pipe = 0;
1178+
ring->pipe = pipe;
11651179
ring->queue = 0;
11661180

11671181
ring->ring_obj = NULL;
11681182
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];
11711184
ring->no_scheduler = true;
11721185
sprintf(ring->name, "mes_%d.%d.%d", ring->me, ring->pipe, ring->queue);
11731186

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+
11741192
return amdgpu_ring_init(adev, ring, 1024, NULL, 0,
11751193
AMDGPU_RING_PRIO_DEFAULT, NULL);
11761194
}
@@ -1184,7 +1202,7 @@ static int mes_v12_0_kiq_ring_init(struct amdgpu_device *adev)
11841202
ring = &adev->gfx.kiq[0].ring;
11851203

11861204
ring->me = 3;
1187-
ring->pipe = adev->enable_uni_mes ? 0 : 1;
1205+
ring->pipe = 1;
11881206
ring->queue = 0;
11891207

11901208
ring->adev = NULL;
@@ -1206,12 +1224,10 @@ static int mes_v12_0_mqd_sw_init(struct amdgpu_device *adev,
12061224
int r, mqd_size = sizeof(struct v12_compute_mqd);
12071225
struct amdgpu_ring *ring;
12081226

1209-
if (pipe == AMDGPU_MES_KIQ_PIPE)
1227+
if (!adev->enable_uni_mes && pipe == AMDGPU_MES_KIQ_PIPE)
12101228
ring = &adev->gfx.kiq[0].ring;
1211-
else if (pipe == AMDGPU_MES_SCHED_PIPE)
1212-
ring = &adev->mes.ring[0];
12131229
else
1214-
BUG();
1230+
ring = &adev->mes.ring[pipe];
12151231

12161232
if (ring->mqd_obj)
12171233
return 0;
@@ -1252,28 +1268,22 @@ static int mes_v12_0_sw_init(void *handle)
12521268
return r;
12531269

12541270
for (pipe = 0; pipe < AMDGPU_MAX_MES_PIPES; pipe++) {
1255-
if (!adev->enable_mes_kiq && pipe == AMDGPU_MES_KIQ_PIPE)
1256-
continue;
1257-
12581271
r = mes_v12_0_allocate_eop_buf(adev, pipe);
12591272
if (r)
12601273
return r;
12611274

12621275
r = mes_v12_0_mqd_sw_init(adev, pipe);
12631276
if (r)
12641277
return r;
1265-
}
12661278

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);
12691283
if (r)
12701284
return r;
12711285
}
12721286

1273-
r = mes_v12_0_ring_init(adev);
1274-
if (r)
1275-
return r;
1276-
12771287
return 0;
12781288
}
12791289

@@ -1368,10 +1378,10 @@ static int mes_v12_0_kiq_hw_init(struct amdgpu_device *adev)
13681378
{
13691379
int r = 0;
13701380

1371-
mes_v12_0_kiq_setting(&adev->gfx.kiq[0].ring);
1372-
13731381
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);
13751385

13761386
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {
13771387

@@ -1398,6 +1408,14 @@ static int mes_v12_0_kiq_hw_init(struct amdgpu_device *adev)
13981408
if (r)
13991409
goto failure;
14001410

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+
14011419
r = mes_v12_0_hw_init(adev);
14021420
if (r)
14031421
goto failure;
@@ -1429,7 +1447,7 @@ static int mes_v12_0_hw_init(void *handle)
14291447
if (adev->mes.ring[0].sched.ready)
14301448
goto out;
14311449

1432-
if (!adev->enable_mes_kiq || adev->enable_uni_mes) {
1450+
if (!adev->enable_mes_kiq) {
14331451
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {
14341452
r = mes_v12_0_load_microcode(adev,
14351453
AMDGPU_MES_SCHED_PIPE, true);
@@ -1449,6 +1467,9 @@ static int mes_v12_0_hw_init(void *handle)
14491467
mes_v12_0_enable(adev, true);
14501468
}
14511469

1470+
/* Enable the MES to handle doorbell ring on unmapped queue */
1471+
mes_v12_0_enable_unmapped_doorbell_handling(&adev->mes, true);
1472+
14521473
r = mes_v12_0_queue_init(adev, AMDGPU_MES_SCHED_PIPE);
14531474
if (r)
14541475
goto failure;
@@ -1462,9 +1483,6 @@ static int mes_v12_0_hw_init(void *handle)
14621483

14631484
mes_v12_0_init_aggregated_doorbell(&adev->mes);
14641485

1465-
/* Enable the MES to handle doorbell ring on unmapped queue */
1466-
mes_v12_0_enable_unmapped_doorbell_handling(&adev->mes, true);
1467-
14681486
r = mes_v12_0_query_sched_status(&adev->mes, AMDGPU_MES_SCHED_PIPE);
14691487
if (r) {
14701488
DRM_ERROR("MES is busy\n");

0 commit comments

Comments
 (0)