Skip to content

Commit 8521e3c

Browse files
Shaoyun Liualexdeucher
authored andcommitted
drm/amd/amdgpu: limit single process inside MES
This is for MES to limit only one process for the user queues Signed-off-by: Shaoyun Liu <shaoyun.liu@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 377dda2 commit 8521e3c

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,9 +1598,11 @@ static ssize_t amdgpu_gfx_set_enforce_isolation(struct device *dev,
15981598
if (adev->enforce_isolation[i] && !partition_values[i]) {
15991599
/* Going from enabled to disabled */
16001600
amdgpu_vmid_free_reserved(adev, AMDGPU_GFXHUB(i));
1601+
amdgpu_mes_set_enforce_isolation(adev, i, false);
16011602
} else if (!adev->enforce_isolation[i] && partition_values[i]) {
16021603
/* Going from disabled to enabled */
16031604
amdgpu_vmid_alloc_reserved(adev, AMDGPU_GFXHUB(i));
1605+
amdgpu_mes_set_enforce_isolation(adev, i, true);
16041606
}
16051607
adev->enforce_isolation[i] = partition_values[i];
16061608
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,29 @@ bool amdgpu_mes_suspend_resume_all_supported(struct amdgpu_device *adev)
16781678
return is_supported;
16791679
}
16801680

1681+
/* Fix me -- node_id is used to identify the correct MES instances in the future */
1682+
int amdgpu_mes_set_enforce_isolation(struct amdgpu_device *adev, uint32_t node_id, bool enable)
1683+
{
1684+
struct mes_misc_op_input op_input = {0};
1685+
int r;
1686+
1687+
op_input.op = MES_MISC_OP_CHANGE_CONFIG;
1688+
op_input.change_config.option.limit_single_process = enable ? 1 : 0;
1689+
1690+
if (!adev->mes.funcs->misc_op) {
1691+
dev_err(adev->dev, "mes change config is not supported!\n");
1692+
r = -EINVAL;
1693+
goto error;
1694+
}
1695+
1696+
r = adev->mes.funcs->misc_op(&adev->mes, &op_input);
1697+
if (r)
1698+
dev_err(adev->dev, "failed to change_config.\n");
1699+
1700+
error:
1701+
return r;
1702+
}
1703+
16811704
#if defined(CONFIG_DEBUG_FS)
16821705

16831706
static int amdgpu_debugfs_mes_event_log_show(struct seq_file *m, void *unused)

drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ enum mes_misc_opcode {
309309
MES_MISC_OP_WRM_REG_WAIT,
310310
MES_MISC_OP_WRM_REG_WR_WAIT,
311311
MES_MISC_OP_SET_SHADER_DEBUGGER,
312+
MES_MISC_OP_CHANGE_CONFIG,
312313
};
313314

314315
struct mes_misc_op_input {
@@ -347,6 +348,21 @@ struct mes_misc_op_input {
347348
uint32_t tcp_watch_cntl[4];
348349
uint32_t trap_en;
349350
} set_shader_debugger;
351+
352+
struct {
353+
union {
354+
struct {
355+
uint32_t limit_single_process : 1;
356+
uint32_t enable_hws_logging_buffer : 1;
357+
uint32_t reserved : 30;
358+
};
359+
uint32_t all;
360+
} option;
361+
struct {
362+
uint32_t tdr_level;
363+
uint32_t tdr_delay;
364+
} tdr_config;
365+
} change_config;
350366
};
351367
};
352368

@@ -517,4 +533,7 @@ static inline void amdgpu_mes_unlock(struct amdgpu_mes *mes)
517533
}
518534

519535
bool amdgpu_mes_suspend_resume_all_supported(struct amdgpu_device *adev);
536+
537+
int amdgpu_mes_set_enforce_isolation(struct amdgpu_device *adev, uint32_t node_id, bool enable);
538+
520539
#endif /* __AMDGPU_MES_H__ */

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,18 @@ static int mes_v11_0_misc_op(struct amdgpu_mes *mes,
644644
sizeof(misc_pkt.set_shader_debugger.tcp_watch_cntl));
645645
misc_pkt.set_shader_debugger.trap_en = input->set_shader_debugger.trap_en;
646646
break;
647+
case MES_MISC_OP_CHANGE_CONFIG:
648+
if ((mes->adev->mes.sched_version & AMDGPU_MES_VERSION_MASK) < 0x63) {
649+
dev_err(mes->adev->dev, "MES FW versoin must be larger than 0x63 to support limit single process feature.\n");
650+
return -EINVAL;
651+
}
652+
misc_pkt.opcode = MESAPI_MISC__CHANGE_CONFIG;
653+
misc_pkt.change_config.opcode =
654+
MESAPI_MISC__CHANGE_CONFIG_OPTION_LIMIT_SINGLE_PROCESS;
655+
misc_pkt.change_config.option.bits.limit_single_process =
656+
input->change_config.option.limit_single_process;
657+
break;
658+
647659
default:
648660
DRM_ERROR("unsupported misc op (%d) \n", input->op);
649661
return -EINVAL;
@@ -708,6 +720,9 @@ static int mes_v11_0_set_hw_resources(struct amdgpu_mes *mes)
708720
mes->event_log_gpu_addr;
709721
}
710722

723+
if (enforce_isolation)
724+
mes_set_hw_res_pkt.limit_single_process = 1;
725+
711726
return mes_v11_0_submit_pkt_and_poll_completion(mes,
712727
&mes_set_hw_res_pkt, sizeof(mes_set_hw_res_pkt),
713728
offsetof(union MESAPI_SET_HW_RESOURCES, api_status));

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,14 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes,
531531
sizeof(misc_pkt.set_shader_debugger.tcp_watch_cntl));
532532
misc_pkt.set_shader_debugger.trap_en = input->set_shader_debugger.trap_en;
533533
break;
534+
case MES_MISC_OP_CHANGE_CONFIG:
535+
misc_pkt.opcode = MESAPI_MISC__CHANGE_CONFIG;
536+
misc_pkt.change_config.opcode =
537+
MESAPI_MISC__CHANGE_CONFIG_OPTION_LIMIT_SINGLE_PROCESS;
538+
misc_pkt.change_config.option.bits.limit_single_process =
539+
input->change_config.option.limit_single_process;
540+
break;
541+
534542
default:
535543
DRM_ERROR("unsupported misc op (%d) \n", input->op);
536544
return -EINVAL;
@@ -624,6 +632,9 @@ static int mes_v12_0_set_hw_resources(struct amdgpu_mes *mes, int pipe)
624632
mes_set_hw_res_pkt.event_intr_history_gpu_mc_ptr = mes->event_log_gpu_addr + pipe * AMDGPU_MES_LOG_BUFFER_SIZE;
625633
}
626634

635+
if (enforce_isolation)
636+
mes_set_hw_res_pkt.limit_single_process = 1;
637+
627638
return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe,
628639
&mes_set_hw_res_pkt, sizeof(mes_set_hw_res_pkt),
629640
offsetof(union MESAPI_SET_HW_RESOURCES, api_status));

0 commit comments

Comments
 (0)