diff options
| author | Felix Kuehling <felix.kuehling@amd.com> | 2026-04-07 17:59:03 -0400 |
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2026-09-02 15:23:17 -0400 |
| commit | fd84fb712662afa658e852f11d8a2cd35e06e265 (patch) | |
| tree | 66217656c26c82737457e15fd6fe06382666fbf8 | |
| parent | 21465778928b2b0d82b134514dec0057961a527d (diff) | |
| download | linux-next-fd84fb712662afa658e852f11d8a2cd35e06e265.tar.gz linux-next-fd84fb712662afa658e852f11d8a2cd35e06e265.zip | |
drm/amdgpu: Implement PSP cmd UAL_GET_CONFIG
To query UALink configuration information from PSP.
Signed-off-by: Felix Kuehling <felix.kuehling@amd.com>
Reviewed-by: Mukul Joshi <mukul.joshi@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 58 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 6 |
2 files changed, 64 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index e547b8e53df9..a562ebebdcce 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c @@ -835,6 +835,8 @@ static const char *psp_gfx_cmd_name(enum psp_gfx_cmd_id cmd_id) return "PERF MONITORING HW"; case GFX_CMD_ID_UAL_GET_INTERFACE_VER: return "UAL_GET_INTERFACE_VER"; + case GFX_CMD_ID_UAL_GET_CONFIG: + return "UAL_GET_CONFIG"; default: return "UNKNOWN CMD"; } @@ -1218,6 +1220,62 @@ int psp_ual_get_interface_version(struct psp_context *psp, uint32_t *intf_ver) return ret; } +int psp_ual_query_info(struct psp_context *psp, uint32_t intf_ver, + struct amdgpu_ualink_info *info) +{ + struct psp_gfx_get_config_ual_v1 *ual_config; + 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); + + ual_config = psp->cmd_ext_resp_mem; + + cmd->cmd_id = GFX_CMD_ID_UAL_GET_CONFIG; + cmd->cmd.cmd_get_config_ual.ual_cfg_addr_lo = lower_32_bits(psp->cmd_ext_resp_mc_addr); + cmd->cmd.cmd_get_config_ual.ual_cfg_addr_hi = upper_32_bits(psp->cmd_ext_resp_mc_addr); + cmd->cmd.cmd_get_config_ual.ual_cfg_size = sizeof(*ual_config); + + ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); + + if (!ret && !cmd->resp.status) { + WARN_ON(cmd->resp.uresp.get_config_ual.resp_size < sizeof(*ual_config)); + + info->link_type = (enum amdgpu_ualink_type)ual_config->link_type; + + info->ppod.accel_id = ual_config->accelerator_id; + info->ppod.bandwidth = ual_config->bandwidth; + info->ppod.latency = ual_config->latency; + info->ppod.size = ual_config->ppod_size; + memcpy(&info->ppod.id, ual_config->ppod_id, sizeof(info->ppod.id)); + + info->vpod.id = ual_config->vpod_id; + info->vpod.size = ual_config->vpod_size; + info->vpod.addr_mode = ual_config->addr_mode; + bitmap_from_arr32(info->vpod.active_accel_bits, + ual_config->vpod_active_accelerators, + min(AMDGPU_UALINK_ACCEL_MAX, PSP_GFX_UAL_MAX_ACC_BIT_MASK*32)); + /* Ensure no uninitialized data in the bitmap, even if these + * constants change in the future. + */ + if (AMDGPU_UALINK_ACCEL_MAX > PSP_GFX_UAL_MAX_ACC_BIT_MASK*32) + bitmap_clear(info->vpod.active_accel_bits, PSP_GFX_UAL_MAX_ACC_BIT_MASK*32, + AMDGPU_UALINK_ACCEL_MAX - PSP_GFX_UAL_MAX_ACC_BIT_MASK*32); + } else if (!ret) { + 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 5968595647fe..66b57c871e1a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h @@ -705,6 +705,12 @@ int amdgpu_psp_irq_mgr_register( struct amdgpu_psp_irq_mgr *mgr, const struct amdgpu_psp_irq_handler *handlers, int count, const struct amdgpu_psp_irq_handler *default_handler); + +struct amdgpu_ualink_info; + 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); + #endif |
