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>
This commit is contained in:
Felix Kuehling 2026-04-07 17:59:03 -04:00 committed by Alex Deucher
parent 2146577892
commit fd84fb7126
2 changed files with 64 additions and 0 deletions

View File

@ -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;

View File

@ -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