[PATCH 10/95] drm/amdgpu: Implement PSP cmd UAL_SET_PPOD_CONFIG
Alex Deucher <[email protected]>
| Newsgroups | org.freedesktop.lists.amd-gfx |
|---|---|
| Message-ID | <[email protected]> |
From: Felix Kuehling <[email protected]> To set the physical pod configuration to PSP. Signed-off-by: Felix Kuehling <[email protected]> Reviewed-by: Mukul Joshi <[email protected]> Signed-off-by: Alex Deucher <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 45 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 4 +++ 2 files changed, 49 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index 006ec1a241f48..1d78d8589f54a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c @@ -831,6 +831,8 @@ static const char *psp_gfx_cmd_name(enum psp_gfx_cmd_id cmd_id) return "UAL_GET_INTERFACE_VER"; case GFX_CMD_ID_UAL_GET_CONFIG: return "UAL_GET_CONFIG"; + case GFX_CMD_ID_UAL_SET_PPOD_CONFIG: + return "UAL_SET_PPOD_CONFIG"; default: return "UNKNOWN CMD"; } @@ -1270,6 +1272,49 @@ int psp_ual_query_info(struct psp_context *psp, uint32_t intf_ver, return ret; } +int psp_ual_set_ppod_config(struct psp_context *psp, uint32_t intf_ver, + const struct amdgpu_ualink_ppod_setup *setup) +{ + struct psp_gfx_cmd_resp *cmd; + int ret; + + /* TBD check interface version 1.x */ + if (intf_ver > 0x1ffff) { + pr_warn("PSP UAL interface version mismatch: 0x%x\n", intf_ver); + return -EOPNOTSUPP; + } + + cmd = acquire_psp_cmd_buf(psp); + + cmd->cmd_id = GFX_CMD_ID_UAL_SET_PPOD_CONFIG; + cmd->cmd.cmd_set_ppod_config_ual.accelerator_id = setup->ppod.accel_id; + memcpy(cmd->cmd.cmd_set_ppod_config_ual.ppod_id, &setup->ppod.id, + sizeof(cmd->cmd.cmd_set_ppod_config_ual.ppod_id)); + cmd->cmd.cmd_set_ppod_config_ual.ppod_size = setup->ppod.size; + cmd->cmd.cmd_set_ppod_config_ual.bandwidth = setup->ppod.bandwidth; + cmd->cmd.cmd_set_ppod_config_ual.latency = setup->ppod.latency; + + memcpy(cmd->cmd.cmd_set_ppod_config_ual.local_accelerators, + setup->local_accels, + min(sizeof(cmd->cmd.cmd_set_ppod_config_ual.local_accelerators), + setup->n_local_accels * sizeof(u32))); + /* Fill the remainder of the array with invalid accelerator IDs */ + if (sizeof(cmd->cmd.cmd_set_ppod_config_ual.local_accelerators) > + setup->n_local_accels * sizeof(u32)) + memset(&cmd->cmd.cmd_set_ppod_config_ual.local_accelerators[setup->n_local_accels], + 0xff, sizeof(cmd->cmd.cmd_set_ppod_config_ual.local_accelerators) - + setup->n_local_accels * sizeof(u32)); + + ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); + + if (!ret && cmd->resp.status) + ret = -EINVAL; + + release_psp_cmd_buf(psp); + + return ret; +} + int psp_update_fw_reservation(struct psp_context *psp) { int ret; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h index 66b57c871e1a5..b65ac4f825d75 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h @@ -707,10 +707,14 @@ int amdgpu_psp_irq_mgr_register( const struct amdgpu_psp_irq_handler *default_handler); struct amdgpu_ualink_info; +struct amdgpu_ualink_ppod_setup; int psp_ual_get_interface_version(struct psp_context *psp, uint32_t *intf_ver); int psp_ual_query_info(struct psp_context *psp, uint32_t intf_ver, struct amdgpu_ualink_info *info); +int psp_ual_set_ppod_config(struct psp_context *psp, uint32_t intf_ver, + const struct amdgpu_ualink_ppod_setup *setup); + #endif -- 2.55.0