Commit 1f455f25 authored by John Clements's avatar John Clements Committed by Alex Deucher

drm/amdgpu: amalgamate PSP TA load/unload functions

reduce duplicate code
Reviewed-by: default avatarGuchun Chen <guchun.chen@amd.com>
Signed-off-by: default avatarJohn Clements <john.clements@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e6e193c0
...@@ -365,11 +365,11 @@ static int psp_asd_load(struct psp_context *psp) ...@@ -365,11 +365,11 @@ static int psp_asd_load(struct psp_context *psp)
return ret; return ret;
} }
static void psp_prep_asd_unload_cmd_buf(struct psp_gfx_cmd_resp *cmd, static void psp_prep_ta_unload_cmd_buf(struct psp_gfx_cmd_resp *cmd,
uint32_t asd_session_id) uint32_t session_id)
{ {
cmd->cmd_id = GFX_CMD_ID_UNLOAD_TA; cmd->cmd_id = GFX_CMD_ID_UNLOAD_TA;
cmd->cmd.cmd_unload_ta.session_id = asd_session_id; cmd->cmd.cmd_unload_ta.session_id = session_id;
} }
static int psp_asd_unload(struct psp_context *psp) static int psp_asd_unload(struct psp_context *psp)
...@@ -387,7 +387,7 @@ static int psp_asd_unload(struct psp_context *psp) ...@@ -387,7 +387,7 @@ static int psp_asd_unload(struct psp_context *psp)
if (!cmd) if (!cmd)
return -ENOMEM; return -ENOMEM;
psp_prep_asd_unload_cmd_buf(cmd, psp->asd_context.session_id); psp_prep_ta_unload_cmd_buf(cmd, psp->asd_context.session_id);
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);
...@@ -427,18 +427,20 @@ int psp_reg_program(struct psp_context *psp, enum psp_reg_prog_id reg, ...@@ -427,18 +427,20 @@ int psp_reg_program(struct psp_context *psp, enum psp_reg_prog_id reg,
return ret; return ret;
} }
static void psp_prep_xgmi_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd, static void psp_prep_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
uint64_t xgmi_ta_mc, uint64_t xgmi_mc_shared, uint64_t ta_bin_mc,
uint32_t xgmi_ta_size, uint32_t shared_size) uint32_t ta_bin_size,
uint64_t ta_shared_mc,
uint32_t ta_shared_size)
{ {
cmd->cmd_id = GFX_CMD_ID_LOAD_TA; cmd->cmd_id = GFX_CMD_ID_LOAD_TA;
cmd->cmd.cmd_load_ta.app_phy_addr_lo = lower_32_bits(xgmi_ta_mc); cmd->cmd.cmd_load_ta.app_phy_addr_lo = lower_32_bits(ta_bin_mc);
cmd->cmd.cmd_load_ta.app_phy_addr_hi = upper_32_bits(xgmi_ta_mc); cmd->cmd.cmd_load_ta.app_phy_addr_hi = upper_32_bits(ta_bin_mc);
cmd->cmd.cmd_load_ta.app_len = xgmi_ta_size; cmd->cmd.cmd_load_ta.app_len = ta_bin_size;
cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_lo = lower_32_bits(xgmi_mc_shared); cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_lo = lower_32_bits(ta_shared_mc);
cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_hi = upper_32_bits(xgmi_mc_shared); cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_hi = upper_32_bits(ta_shared_mc);
cmd->cmd.cmd_load_ta.cmd_buf_len = shared_size; cmd->cmd.cmd_load_ta.cmd_buf_len = ta_shared_size;
} }
static int psp_xgmi_init_shared_buf(struct psp_context *psp) static int psp_xgmi_init_shared_buf(struct psp_context *psp)
...@@ -474,9 +476,11 @@ static int psp_xgmi_load(struct psp_context *psp) ...@@ -474,9 +476,11 @@ static int psp_xgmi_load(struct psp_context *psp)
memset(psp->fw_pri_buf, 0, PSP_1_MEG); memset(psp->fw_pri_buf, 0, PSP_1_MEG);
memcpy(psp->fw_pri_buf, psp->ta_xgmi_start_addr, psp->ta_xgmi_ucode_size); memcpy(psp->fw_pri_buf, psp->ta_xgmi_start_addr, psp->ta_xgmi_ucode_size);
psp_prep_xgmi_ta_load_cmd_buf(cmd, psp->fw_pri_mc_addr, psp_prep_ta_load_cmd_buf(cmd,
psp->fw_pri_mc_addr,
psp->ta_xgmi_ucode_size,
psp->xgmi_context.xgmi_shared_mc_addr, psp->xgmi_context.xgmi_shared_mc_addr,
psp->ta_xgmi_ucode_size, PSP_XGMI_SHARED_MEM_SIZE); PSP_XGMI_SHARED_MEM_SIZE);
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);
...@@ -491,13 +495,6 @@ static int psp_xgmi_load(struct psp_context *psp) ...@@ -491,13 +495,6 @@ static int psp_xgmi_load(struct psp_context *psp)
return ret; return ret;
} }
static void psp_prep_xgmi_ta_unload_cmd_buf(struct psp_gfx_cmd_resp *cmd,
uint32_t xgmi_session_id)
{
cmd->cmd_id = GFX_CMD_ID_UNLOAD_TA;
cmd->cmd.cmd_unload_ta.session_id = xgmi_session_id;
}
static int psp_xgmi_unload(struct psp_context *psp) static int psp_xgmi_unload(struct psp_context *psp)
{ {
int ret; int ret;
...@@ -511,7 +508,7 @@ static int psp_xgmi_unload(struct psp_context *psp) ...@@ -511,7 +508,7 @@ static int psp_xgmi_unload(struct psp_context *psp)
if (!cmd) if (!cmd)
return -ENOMEM; return -ENOMEM;
psp_prep_xgmi_ta_unload_cmd_buf(cmd, psp->xgmi_context.session_id); psp_prep_ta_unload_cmd_buf(cmd, psp->xgmi_context.session_id);
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);
...@@ -605,20 +602,6 @@ static int psp_xgmi_initialize(struct psp_context *psp) ...@@ -605,20 +602,6 @@ static int psp_xgmi_initialize(struct psp_context *psp)
} }
// ras begin // ras begin
static void psp_prep_ras_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
uint64_t ras_ta_mc, uint64_t ras_mc_shared,
uint32_t ras_ta_size, uint32_t shared_size)
{
cmd->cmd_id = GFX_CMD_ID_LOAD_TA;
cmd->cmd.cmd_load_ta.app_phy_addr_lo = lower_32_bits(ras_ta_mc);
cmd->cmd.cmd_load_ta.app_phy_addr_hi = upper_32_bits(ras_ta_mc);
cmd->cmd.cmd_load_ta.app_len = ras_ta_size;
cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_lo = lower_32_bits(ras_mc_shared);
cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_hi = upper_32_bits(ras_mc_shared);
cmd->cmd.cmd_load_ta.cmd_buf_len = shared_size;
}
static int psp_ras_init_shared_buf(struct psp_context *psp) static int psp_ras_init_shared_buf(struct psp_context *psp)
{ {
int ret; int ret;
...@@ -654,9 +637,11 @@ static int psp_ras_load(struct psp_context *psp) ...@@ -654,9 +637,11 @@ static int psp_ras_load(struct psp_context *psp)
memset(psp->fw_pri_buf, 0, PSP_1_MEG); memset(psp->fw_pri_buf, 0, PSP_1_MEG);
memcpy(psp->fw_pri_buf, psp->ta_ras_start_addr, psp->ta_ras_ucode_size); memcpy(psp->fw_pri_buf, psp->ta_ras_start_addr, psp->ta_ras_ucode_size);
psp_prep_ras_ta_load_cmd_buf(cmd, psp->fw_pri_mc_addr, psp_prep_ta_load_cmd_buf(cmd,
psp->fw_pri_mc_addr,
psp->ta_ras_ucode_size,
psp->ras.ras_shared_mc_addr, psp->ras.ras_shared_mc_addr,
psp->ta_ras_ucode_size, PSP_RAS_SHARED_MEM_SIZE); PSP_RAS_SHARED_MEM_SIZE);
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);
...@@ -671,13 +656,6 @@ static int psp_ras_load(struct psp_context *psp) ...@@ -671,13 +656,6 @@ static int psp_ras_load(struct psp_context *psp)
return ret; return ret;
} }
static void psp_prep_ras_ta_unload_cmd_buf(struct psp_gfx_cmd_resp *cmd,
uint32_t ras_session_id)
{
cmd->cmd_id = GFX_CMD_ID_UNLOAD_TA;
cmd->cmd.cmd_unload_ta.session_id = ras_session_id;
}
static int psp_ras_unload(struct psp_context *psp) static int psp_ras_unload(struct psp_context *psp)
{ {
int ret; int ret;
...@@ -693,7 +671,7 @@ static int psp_ras_unload(struct psp_context *psp) ...@@ -693,7 +671,7 @@ static int psp_ras_unload(struct psp_context *psp)
if (!cmd) if (!cmd)
return -ENOMEM; return -ENOMEM;
psp_prep_ras_ta_unload_cmd_buf(cmd, psp->ras.session_id); psp_prep_ta_unload_cmd_buf(cmd, psp->ras.session_id);
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);
...@@ -823,24 +801,6 @@ static int psp_ras_initialize(struct psp_context *psp) ...@@ -823,24 +801,6 @@ static int psp_ras_initialize(struct psp_context *psp)
// ras end // ras end
// HDCP start // HDCP start
static void psp_prep_hdcp_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
uint64_t hdcp_ta_mc,
uint64_t hdcp_mc_shared,
uint32_t hdcp_ta_size,
uint32_t shared_size)
{
cmd->cmd_id = GFX_CMD_ID_LOAD_TA;
cmd->cmd.cmd_load_ta.app_phy_addr_lo = lower_32_bits(hdcp_ta_mc);
cmd->cmd.cmd_load_ta.app_phy_addr_hi = upper_32_bits(hdcp_ta_mc);
cmd->cmd.cmd_load_ta.app_len = hdcp_ta_size;
cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_lo =
lower_32_bits(hdcp_mc_shared);
cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_hi =
upper_32_bits(hdcp_mc_shared);
cmd->cmd.cmd_load_ta.cmd_buf_len = shared_size;
}
static int psp_hdcp_init_shared_buf(struct psp_context *psp) static int psp_hdcp_init_shared_buf(struct psp_context *psp)
{ {
int ret; int ret;
...@@ -877,9 +837,10 @@ static int psp_hdcp_load(struct psp_context *psp) ...@@ -877,9 +837,10 @@ static int psp_hdcp_load(struct psp_context *psp)
memcpy(psp->fw_pri_buf, psp->ta_hdcp_start_addr, memcpy(psp->fw_pri_buf, psp->ta_hdcp_start_addr,
psp->ta_hdcp_ucode_size); psp->ta_hdcp_ucode_size);
psp_prep_hdcp_ta_load_cmd_buf(cmd, psp->fw_pri_mc_addr, psp_prep_ta_load_cmd_buf(cmd,
psp->hdcp_context.hdcp_shared_mc_addr, psp->fw_pri_mc_addr,
psp->ta_hdcp_ucode_size, psp->ta_hdcp_ucode_size,
psp->hdcp_context.hdcp_shared_mc_addr,
PSP_HDCP_SHARED_MEM_SIZE); PSP_HDCP_SHARED_MEM_SIZE);
ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
...@@ -921,12 +882,6 @@ static int psp_hdcp_initialize(struct psp_context *psp) ...@@ -921,12 +882,6 @@ static int psp_hdcp_initialize(struct psp_context *psp)
return 0; return 0;
} }
static void psp_prep_hdcp_ta_unload_cmd_buf(struct psp_gfx_cmd_resp *cmd,
uint32_t hdcp_session_id)
{
cmd->cmd_id = GFX_CMD_ID_UNLOAD_TA;
cmd->cmd.cmd_unload_ta.session_id = hdcp_session_id;
}
static int psp_hdcp_unload(struct psp_context *psp) static int psp_hdcp_unload(struct psp_context *psp)
{ {
...@@ -943,7 +898,7 @@ static int psp_hdcp_unload(struct psp_context *psp) ...@@ -943,7 +898,7 @@ static int psp_hdcp_unload(struct psp_context *psp)
if (!cmd) if (!cmd)
return -ENOMEM; return -ENOMEM;
psp_prep_hdcp_ta_unload_cmd_buf(cmd, psp->hdcp_context.session_id); psp_prep_ta_unload_cmd_buf(cmd, psp->hdcp_context.session_id);
ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
...@@ -1016,22 +971,6 @@ static int psp_hdcp_terminate(struct psp_context *psp) ...@@ -1016,22 +971,6 @@ static int psp_hdcp_terminate(struct psp_context *psp)
// HDCP end // HDCP end
// DTM start // DTM start
static void psp_prep_dtm_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
uint64_t dtm_ta_mc,
uint64_t dtm_mc_shared,
uint32_t dtm_ta_size,
uint32_t shared_size)
{
cmd->cmd_id = GFX_CMD_ID_LOAD_TA;
cmd->cmd.cmd_load_ta.app_phy_addr_lo = lower_32_bits(dtm_ta_mc);
cmd->cmd.cmd_load_ta.app_phy_addr_hi = upper_32_bits(dtm_ta_mc);
cmd->cmd.cmd_load_ta.app_len = dtm_ta_size;
cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_lo = lower_32_bits(dtm_mc_shared);
cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_hi = upper_32_bits(dtm_mc_shared);
cmd->cmd.cmd_load_ta.cmd_buf_len = shared_size;
}
static int psp_dtm_init_shared_buf(struct psp_context *psp) static int psp_dtm_init_shared_buf(struct psp_context *psp)
{ {
int ret; int ret;
...@@ -1067,9 +1006,10 @@ static int psp_dtm_load(struct psp_context *psp) ...@@ -1067,9 +1006,10 @@ static int psp_dtm_load(struct psp_context *psp)
memset(psp->fw_pri_buf, 0, PSP_1_MEG); memset(psp->fw_pri_buf, 0, PSP_1_MEG);
memcpy(psp->fw_pri_buf, psp->ta_dtm_start_addr, psp->ta_dtm_ucode_size); memcpy(psp->fw_pri_buf, psp->ta_dtm_start_addr, psp->ta_dtm_ucode_size);
psp_prep_dtm_ta_load_cmd_buf(cmd, psp->fw_pri_mc_addr, psp_prep_ta_load_cmd_buf(cmd,
psp->dtm_context.dtm_shared_mc_addr, psp->fw_pri_mc_addr,
psp->ta_dtm_ucode_size, psp->ta_dtm_ucode_size,
psp->dtm_context.dtm_shared_mc_addr,
PSP_DTM_SHARED_MEM_SIZE); PSP_DTM_SHARED_MEM_SIZE);
ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
......
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