Commit fe96e563 authored by Candice Li's avatar Candice Li Committed by Alex Deucher

drm/amdgpu: Use indirect buffer and save response status for TA load/invoke

The upcoming TA debugfs interface needs to use indirect buffer
when performing TA invoke and check psp response status for TA
load and invoke.
Signed-off-by: default avatarJohn Clements <john.clements@amd.com>
Signed-off-by: default avatarCandice Li <candice.li@amd.com>
Reviewed-by: default avatarTao Zhou <tao.zhou1@amd.com>
Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 747eea07
...@@ -46,8 +46,6 @@ static int psp_sysfs_init(struct amdgpu_device *adev); ...@@ -46,8 +46,6 @@ static int psp_sysfs_init(struct amdgpu_device *adev);
static void psp_sysfs_fini(struct amdgpu_device *adev); static void psp_sysfs_fini(struct amdgpu_device *adev);
static int psp_load_smu_fw(struct psp_context *psp); static int psp_load_smu_fw(struct psp_context *psp);
static int psp_ta_unload(struct psp_context *psp, struct ta_context *context);
static int psp_ta_load(struct psp_context *psp, struct ta_context *context);
static int psp_rap_terminate(struct psp_context *psp); static int psp_rap_terminate(struct psp_context *psp);
static int psp_securedisplay_terminate(struct psp_context *psp); static int psp_securedisplay_terminate(struct psp_context *psp);
...@@ -862,7 +860,7 @@ static void psp_prep_ta_unload_cmd_buf(struct psp_gfx_cmd_resp *cmd, ...@@ -862,7 +860,7 @@ static void psp_prep_ta_unload_cmd_buf(struct psp_gfx_cmd_resp *cmd,
cmd->cmd.cmd_unload_ta.session_id = session_id; cmd->cmd.cmd_unload_ta.session_id = session_id;
} }
static int psp_ta_unload(struct psp_context *psp, struct ta_context *context) int psp_ta_unload(struct psp_context *psp, struct ta_context *context)
{ {
int ret; int ret;
struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp); struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp);
...@@ -944,7 +942,7 @@ static void psp_prep_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd, ...@@ -944,7 +942,7 @@ static void psp_prep_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
cmd->cmd.cmd_load_ta.cmd_buf_len = context->mem_context.shared_mem_size; cmd->cmd.cmd_load_ta.cmd_buf_len = context->mem_context.shared_mem_size;
} }
static int psp_ta_init_shared_buf(struct psp_context *psp, int psp_ta_init_shared_buf(struct psp_context *psp,
struct ta_mem_context *mem_ctx) struct ta_mem_context *mem_ctx)
{ {
/* /*
...@@ -958,7 +956,7 @@ static int psp_ta_init_shared_buf(struct psp_context *psp, ...@@ -958,7 +956,7 @@ static int psp_ta_init_shared_buf(struct psp_context *psp,
&mem_ctx->shared_buf); &mem_ctx->shared_buf);
} }
static void psp_ta_free_shared_buf(struct ta_mem_context *mem_ctx) void psp_ta_free_shared_buf(struct ta_mem_context *mem_ctx)
{ {
amdgpu_bo_free_kernel(&mem_ctx->shared_bo, &mem_ctx->shared_mc_addr, amdgpu_bo_free_kernel(&mem_ctx->shared_bo, &mem_ctx->shared_mc_addr,
&mem_ctx->shared_buf); &mem_ctx->shared_buf);
...@@ -969,6 +967,42 @@ static int psp_xgmi_init_shared_buf(struct psp_context *psp) ...@@ -969,6 +967,42 @@ static int psp_xgmi_init_shared_buf(struct psp_context *psp)
return psp_ta_init_shared_buf(psp, &psp->xgmi_context.context.mem_context); return psp_ta_init_shared_buf(psp, &psp->xgmi_context.context.mem_context);
} }
static void psp_prep_ta_invoke_indirect_cmd_buf(struct psp_gfx_cmd_resp *cmd,
uint32_t ta_cmd_id,
struct ta_context *context)
{
cmd->cmd_id = GFX_CMD_ID_INVOKE_CMD;
cmd->cmd.cmd_invoke_cmd.session_id = context->session_id;
cmd->cmd.cmd_invoke_cmd.ta_cmd_id = ta_cmd_id;
cmd->cmd.cmd_invoke_cmd.buf.num_desc = 1;
cmd->cmd.cmd_invoke_cmd.buf.total_size = context->mem_context.shared_mem_size;
cmd->cmd.cmd_invoke_cmd.buf.buf_desc[0].buf_size = context->mem_context.shared_mem_size;
cmd->cmd.cmd_invoke_cmd.buf.buf_desc[0].buf_phy_addr_lo =
lower_32_bits(context->mem_context.shared_mc_addr);
cmd->cmd.cmd_invoke_cmd.buf.buf_desc[0].buf_phy_addr_hi =
upper_32_bits(context->mem_context.shared_mc_addr);
}
int psp_ta_invoke_indirect(struct psp_context *psp,
uint32_t ta_cmd_id,
struct ta_context *context)
{
int ret;
struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp);
psp_prep_ta_invoke_indirect_cmd_buf(cmd, ta_cmd_id, context);
ret = psp_cmd_submit_buf(psp, NULL, cmd,
psp->fence_buf_mc_addr);
context->resp_status = cmd->resp.status;
release_psp_cmd_buf(psp);
return ret;
}
static void psp_prep_ta_invoke_cmd_buf(struct psp_gfx_cmd_resp *cmd, static void psp_prep_ta_invoke_cmd_buf(struct psp_gfx_cmd_resp *cmd,
uint32_t ta_cmd_id, uint32_t ta_cmd_id,
uint32_t session_id) uint32_t session_id)
...@@ -978,7 +1012,7 @@ static void psp_prep_ta_invoke_cmd_buf(struct psp_gfx_cmd_resp *cmd, ...@@ -978,7 +1012,7 @@ static void psp_prep_ta_invoke_cmd_buf(struct psp_gfx_cmd_resp *cmd,
cmd->cmd.cmd_invoke_cmd.ta_cmd_id = ta_cmd_id; cmd->cmd.cmd_invoke_cmd.ta_cmd_id = ta_cmd_id;
} }
static int psp_ta_invoke(struct psp_context *psp, int psp_ta_invoke(struct psp_context *psp,
uint32_t ta_cmd_id, uint32_t ta_cmd_id,
struct ta_context *context) struct ta_context *context)
{ {
...@@ -990,12 +1024,14 @@ static int psp_ta_invoke(struct psp_context *psp, ...@@ -990,12 +1024,14 @@ static int psp_ta_invoke(struct psp_context *psp,
ret = psp_cmd_submit_buf(psp, NULL, cmd, ret = psp_cmd_submit_buf(psp, NULL, cmd,
psp->fence_buf_mc_addr); psp->fence_buf_mc_addr);
context->resp_status = cmd->resp.status;
release_psp_cmd_buf(psp); release_psp_cmd_buf(psp);
return ret; return ret;
} }
static int psp_ta_load(struct psp_context *psp, struct ta_context *context) int psp_ta_load(struct psp_context *psp, struct ta_context *context)
{ {
int ret; int ret;
struct psp_gfx_cmd_resp *cmd; struct psp_gfx_cmd_resp *cmd;
...@@ -1010,6 +1046,8 @@ static int psp_ta_load(struct psp_context *psp, struct ta_context *context) ...@@ -1010,6 +1046,8 @@ static int psp_ta_load(struct psp_context *psp, struct ta_context *context)
ret = psp_cmd_submit_buf(psp, NULL, cmd, ret = psp_cmd_submit_buf(psp, NULL, cmd,
psp->fence_buf_mc_addr); psp->fence_buf_mc_addr);
context->resp_status = cmd->resp.status;
if (!ret) { if (!ret) {
context->session_id = cmd->resp.session_id; context->session_id = cmd->resp.session_id;
} }
...@@ -1415,7 +1453,7 @@ int psp_ras_enable_features(struct psp_context *psp, ...@@ -1415,7 +1453,7 @@ int psp_ras_enable_features(struct psp_context *psp,
return 0; return 0;
} }
static int psp_ras_terminate(struct psp_context *psp) int psp_ras_terminate(struct psp_context *psp)
{ {
int ret; int ret;
......
...@@ -48,6 +48,17 @@ enum psp_shared_mem_size { ...@@ -48,6 +48,17 @@ enum psp_shared_mem_size {
PSP_SECUREDISPLAY_SHARED_MEM_SIZE = 0x4000, PSP_SECUREDISPLAY_SHARED_MEM_SIZE = 0x4000,
}; };
enum ta_type_id {
TA_TYPE_XGMI = 1,
TA_TYPE_RAS,
TA_TYPE_HDCP,
TA_TYPE_DTM,
TA_TYPE_RAP,
TA_TYPE_SECUREDISPLAY,
TA_TYPE_MAX_INDEX,
};
struct psp_context; struct psp_context;
struct psp_xgmi_node_info; struct psp_xgmi_node_info;
struct psp_xgmi_topology_info; struct psp_xgmi_topology_info;
...@@ -151,9 +162,11 @@ struct ta_mem_context { ...@@ -151,9 +162,11 @@ struct ta_mem_context {
struct ta_context { struct ta_context {
bool initialized; bool initialized;
uint32_t session_id; uint32_t session_id;
uint32_t resp_status;
struct ta_mem_context mem_context; struct ta_mem_context mem_context;
struct psp_bin_desc bin_desc; struct psp_bin_desc bin_desc;
enum psp_gfx_cmd_id ta_load_type; enum psp_gfx_cmd_id ta_load_type;
enum ta_type_id ta_type;
}; };
struct ta_cp_context { struct ta_cp_context {
...@@ -407,6 +420,18 @@ int psp_gpu_reset(struct amdgpu_device *adev); ...@@ -407,6 +420,18 @@ int psp_gpu_reset(struct amdgpu_device *adev);
int psp_update_vcn_sram(struct amdgpu_device *adev, int inst_idx, int psp_update_vcn_sram(struct amdgpu_device *adev, int inst_idx,
uint64_t cmd_gpu_addr, int cmd_size); uint64_t cmd_gpu_addr, int cmd_size);
int psp_ta_init_shared_buf(struct psp_context *psp,
struct ta_mem_context *mem_ctx);
void psp_ta_free_shared_buf(struct ta_mem_context *mem_ctx);
int psp_ta_unload(struct psp_context *psp, struct ta_context *context);
int psp_ta_load(struct psp_context *psp, struct ta_context *context);
int psp_ta_invoke(struct psp_context *psp,
uint32_t ta_cmd_id,
struct ta_context *context);
int psp_ta_invoke_indirect(struct psp_context *psp,
uint32_t ta_cmd_id,
struct ta_context *context);
int psp_xgmi_initialize(struct psp_context *psp, bool set_extended_data, bool load_ta); int psp_xgmi_initialize(struct psp_context *psp, bool set_extended_data, bool load_ta);
int psp_xgmi_terminate(struct psp_context *psp); int psp_xgmi_terminate(struct psp_context *psp);
int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id); int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
...@@ -425,6 +450,7 @@ int psp_ras_enable_features(struct psp_context *psp, ...@@ -425,6 +450,7 @@ int psp_ras_enable_features(struct psp_context *psp,
union ta_ras_cmd_input *info, bool enable); union ta_ras_cmd_input *info, bool enable);
int psp_ras_trigger_error(struct psp_context *psp, int psp_ras_trigger_error(struct psp_context *psp,
struct ta_ras_trigger_error_input *info); struct ta_ras_trigger_error_input *info);
int psp_ras_terminate(struct psp_context *psp);
int psp_hdcp_invoke(struct psp_context *psp, uint32_t ta_cmd_id); int psp_hdcp_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
int psp_dtm_invoke(struct psp_context *psp, uint32_t ta_cmd_id); int psp_dtm_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment