<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<font size="2"><span style="font-size:11pt">Reviewed-by: John Clements <john.clements@amd.com></span></font><br>
</div>
<div>
<div id="appendonsend"></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size: 11pt;" face="Calibri, sans-serif" color="#000000"><b>From:</b> Li, Candice <Candice.Li@amd.com><br>
<b>Sent:</b> Monday, September 13, 2021 3:54 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Clements, John <John.Clements@amd.com>; Li, Candice <Candice.Li@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdgpu: Conform ASD header/loading to generic TA systems</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Update asd_context structure and add asd_initialize function to<br>
conform ASD header/loading to generic TA systems.<br>
<br>
Signed-off-by: Candice Li <candice.li@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 60 ++++++++++---------------<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 10 ++---<br>
2 files changed, 26 insertions(+), 44 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
index 071dadf3a4509f..bc861f2fe0ecf6 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
@@ -47,6 +47,7 @@ static void psp_sysfs_fini(struct amdgpu_device *adev);<br>
<br>
static int psp_load_smu_fw(struct psp_context *psp);<br>
static int psp_ta_unload(struct psp_context *psp, uint32_t session_id);<br>
+static int psp_ta_load(struct psp_context *psp, struct ta_context *context);<br>
static int psp_rap_terminate(struct psp_context *psp);<br>
static int psp_securedisplay_terminate(struct psp_context *psp);<br>
<br>
@@ -781,23 +782,14 @@ static int psp_rl_load(struct amdgpu_device *adev)<br>
return ret;<br>
}<br>
<br>
-static void psp_prep_asd_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,<br>
- uint64_t asd_mc, uint32_t size)<br>
+static int psp_asd_load(struct psp_context *psp)<br>
{<br>
- cmd->cmd_id = GFX_CMD_ID_LOAD_ASD;<br>
- cmd->cmd.cmd_load_ta.app_phy_addr_lo = lower_32_bits(asd_mc);<br>
- cmd->cmd.cmd_load_ta.app_phy_addr_hi = upper_32_bits(asd_mc);<br>
- cmd->cmd.cmd_load_ta.app_len = size;<br>
-<br>
- cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_lo = 0;<br>
- cmd->cmd.cmd_load_ta.cmd_buf_phy_addr_hi = 0;<br>
- cmd->cmd.cmd_load_ta.cmd_buf_len = 0;<br>
+ return psp_ta_load(psp, &psp->asd_context);<br>
}<br>
<br>
-static int psp_asd_load(struct psp_context *psp)<br>
+static int psp_asd_initialize(struct psp_context *psp)<br>
{<br>
int ret;<br>
- struct psp_gfx_cmd_resp *cmd;<br>
<br>
/* If PSP version doesn't match ASD version, asd loading will be failed.<br>
* add workaround to bypass it for sriov now.<br>
@@ -806,22 +798,13 @@ static int psp_asd_load(struct psp_context *psp)<br>
if (amdgpu_sriov_vf(psp->adev) || !psp->asd_context.bin_desc.size_bytes)<br>
return 0;<br>
<br>
- cmd = acquire_psp_cmd_buf(psp);<br>
+ psp->asd_context.mem_context.shared_mc_addr = 0;<br>
+ psp->asd_context.mem_context.shared_mem_size = PSP_ASD_SHARED_MEM_SIZE;<br>
+ psp->asd_context.ta_load_type = GFX_CMD_ID_LOAD_ASD;<br>
<br>
- psp_copy_fw(psp, psp->asd_context.bin_desc.start_addr,<br>
- psp->asd_context.bin_desc.size_bytes);<br>
-<br>
- psp_prep_asd_load_cmd_buf(cmd, psp->fw_pri_mc_addr,<br>
- psp->asd_context.bin_desc.size_bytes);<br>
-<br>
- ret = psp_cmd_submit_buf(psp, NULL, cmd,<br>
- psp->fence_buf_mc_addr);<br>
- if (!ret) {<br>
- psp->asd_context.asd_initialized = true;<br>
- psp->asd_context.session_id = cmd->resp.session_id;<br>
- }<br>
-<br>
- release_psp_cmd_buf(psp);<br>
+ ret = psp_asd_load(psp);<br>
+ if (!ret)<br>
+ psp->asd_context.initialized = true;<br>
<br>
return ret;<br>
}<br>
@@ -859,13 +842,13 @@ static int psp_asd_terminate(struct psp_context *psp)<br>
if (amdgpu_sriov_vf(psp->adev))<br>
return 0;<br>
<br>
- if (!psp->asd_context.asd_initialized)<br>
+ if (!psp->asd_context.initialized)<br>
return 0;<br>
<br>
ret = psp_asd_unload(psp);<br>
<br>
if (!ret)<br>
- psp->asd_context.asd_initialized = false;<br>
+ psp->asd_context.initialized = false;<br>
<br>
return ret;<br>
}<br>
@@ -903,7 +886,7 @@ static void psp_prep_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,<br>
uint64_t ta_bin_mc,<br>
struct ta_context *context)<br>
{<br>
- cmd->cmd_id = GFX_CMD_ID_LOAD_TA;<br>
+ cmd->cmd_id = context->ta_load_type;<br>
cmd->cmd.cmd_load_ta.app_phy_addr_lo = lower_32_bits(ta_bin_mc);<br>
cmd->cmd.cmd_load_ta.app_phy_addr_hi = upper_32_bits(ta_bin_mc);<br>
cmd->cmd.cmd_load_ta.app_len = context->bin_desc.size_bytes;<br>
@@ -970,8 +953,7 @@ static int psp_ta_invoke(struct psp_context *psp,<br>
return ret;<br>
}<br>
<br>
-static int psp_ta_load(struct psp_context *psp,<br>
- struct ta_context *context)<br>
+static int psp_ta_load(struct psp_context *psp, struct ta_context *context)<br>
{<br>
int ret;<br>
struct psp_gfx_cmd_resp *cmd;<br>
@@ -981,9 +963,7 @@ static int psp_ta_load(struct psp_context *psp,<br>
psp_copy_fw(psp, context->bin_desc.start_addr,<br>
context->bin_desc.size_bytes);<br>
<br>
- psp_prep_ta_load_cmd_buf(cmd,<br>
- psp->fw_pri_mc_addr,<br>
- context);<br>
+ psp_prep_ta_load_cmd_buf(cmd, psp->fw_pri_mc_addr, context);<br>
<br>
ret = psp_cmd_submit_buf(psp, NULL, cmd,<br>
psp->fence_buf_mc_addr);<br>
@@ -1051,6 +1031,7 @@ int psp_xgmi_initialize(struct psp_context *psp, bool set_extended_data, bool lo<br>
goto invoke;<br>
<br>
psp->xgmi_context.context.mem_context.shared_mem_size = PSP_XGMI_SHARED_MEM_SIZE;<br>
+ psp->xgmi_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA;<br>
<br>
if (!psp->xgmi_context.context.initialized) {<br>
ret = psp_xgmi_init_shared_buf(psp);<br>
@@ -1450,6 +1431,7 @@ static int psp_ras_initialize(struct psp_context *psp)<br>
}<br>
<br>
psp->ras_context.context.mem_context.shared_mem_size = PSP_RAS_SHARED_MEM_SIZE;<br>
+ psp->ras_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA;<br>
<br>
if (!psp->ras_context.context.initialized) {<br>
ret = psp_ras_init_shared_buf(psp);<br>
@@ -1539,6 +1521,7 @@ static int psp_hdcp_initialize(struct psp_context *psp)<br>
}<br>
<br>
psp->hdcp_context.context.mem_context.shared_mem_size = PSP_HDCP_SHARED_MEM_SIZE;<br>
+ psp->hdcp_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA;<br>
<br>
if (!psp->hdcp_context.context.initialized) {<br>
ret = psp_hdcp_init_shared_buf(psp);<br>
@@ -1630,6 +1613,7 @@ static int psp_dtm_initialize(struct psp_context *psp)<br>
}<br>
<br>
psp->dtm_context.context.mem_context.shared_mem_size = PSP_DTM_SHARED_MEM_SIZE;<br>
+ psp->dtm_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA;<br>
<br>
if (!psp->dtm_context.context.initialized) {<br>
ret = psp_dtm_init_shared_buf(psp);<br>
@@ -1727,6 +1711,7 @@ static int psp_rap_initialize(struct psp_context *psp)<br>
}<br>
<br>
psp->rap_context.context.mem_context.shared_mem_size = PSP_RAP_SHARED_MEM_SIZE;<br>
+ psp->rap_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA;<br>
<br>
if (!psp->rap_context.context.initialized) {<br>
ret = psp_rap_init_shared_buf(psp);<br>
@@ -1842,6 +1827,7 @@ static int psp_securedisplay_initialize(struct psp_context *psp)<br>
<br>
psp->securedisplay_context.context.mem_context.shared_mem_size =<br>
PSP_SECUREDISPLAY_SHARED_MEM_SIZE;<br>
+ psp->securedisplay_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA;<br>
<br>
if (!psp->securedisplay_context.context.initialized) {<br>
ret = psp_securedisplay_init_shared_buf(psp);<br>
@@ -2419,7 +2405,7 @@ static int psp_load_fw(struct amdgpu_device *adev)<br>
if (ret)<br>
goto failed;<br>
<br>
- ret = psp_asd_load(psp);<br>
+ ret = psp_asd_initialize(psp);<br>
if (ret) {<br>
DRM_ERROR("PSP load asd failed!\n");<br>
return ret;<br>
@@ -2616,7 +2602,7 @@ static int psp_resume(void *handle)<br>
if (ret)<br>
goto failed;<br>
<br>
- ret = psp_asd_load(psp);<br>
+ ret = psp_asd_initialize(psp);<br>
if (ret) {<br>
DRM_ERROR("PSP load asd failed!\n");<br>
goto failed;<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
index cfd7ac976cd1e6..f29afabbff1fbe 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
@@ -39,6 +39,7 @@<br>
#define PSP_FW_NAME_LEN 0x24<br>
<br>
enum psp_shared_mem_size {<br>
+ PSP_ASD_SHARED_MEM_SIZE = 0x0,<br>
PSP_XGMI_SHARED_MEM_SIZE = 0x4000,<br>
PSP_RAS_SHARED_MEM_SIZE = 0x4000,<br>
PSP_HDCP_SHARED_MEM_SIZE = 0x4000,<br>
@@ -140,12 +141,6 @@ struct psp_bin_desc {<br>
uint8_t *start_addr;<br>
};<br>
<br>
-struct psp_asd_context {<br>
- bool asd_initialized;<br>
- uint32_t session_id;<br>
- struct psp_bin_desc bin_desc;<br>
-};<br>
-<br>
struct ta_mem_context {<br>
struct amdgpu_bo *shared_bo;<br>
uint64_t shared_mc_addr;<br>
@@ -158,6 +153,7 @@ struct ta_context {<br>
uint32_t session_id;<br>
struct ta_mem_context mem_context;<br>
struct psp_bin_desc bin_desc;<br>
+ enum psp_gfx_cmd_id ta_load_type;<br>
};<br>
<br>
struct ta_cp_context {<br>
@@ -331,7 +327,7 @@ struct psp_context<br>
const struct firmware *ta_fw;<br>
uint32_t ta_fw_version;<br>
<br>
- struct psp_asd_context asd_context;<br>
+ struct ta_context asd_context;<br>
struct psp_xgmi_context xgmi_context;<br>
struct psp_ras_context ras_context;<br>
struct ta_cp_context hdcp_context;<br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>