drm/amd/amdgpu: consolidate PSP TA init shared buf functions
Signed-off-by: Candice Li <candice.li@amd.com> Reviewed-by: John Clements <john.clements@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
355e3e4ccc
commit
30acef3c4a
|
@ -899,23 +899,37 @@ static void psp_prep_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
|
||||||
cmd->cmd.cmd_load_ta.cmd_buf_len = ta_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_ta_init_shared_buf(struct psp_context *psp,
|
||||||
|
struct ta_mem_context *mem_ctx,
|
||||||
|
uint32_t shared_mem_size)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate 16k memory aligned to 4k from Frame Buffer (local
|
* Allocate 16k memory aligned to 4k from Frame Buffer (local
|
||||||
* physical) for xgmi ta <-> Driver
|
* physical) for ta to host memory
|
||||||
*/
|
*/
|
||||||
ret = amdgpu_bo_create_kernel(psp->adev, PSP_XGMI_SHARED_MEM_SIZE,
|
ret = amdgpu_bo_create_kernel(psp->adev, shared_mem_size, PAGE_SIZE,
|
||||||
PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM,
|
AMDGPU_GEM_DOMAIN_VRAM,
|
||||||
&psp->xgmi_context.context.mem_context.shared_bo,
|
&mem_ctx->shared_bo,
|
||||||
&psp->xgmi_context.context.mem_context.shared_mc_addr,
|
&mem_ctx->shared_mc_addr,
|
||||||
&psp->xgmi_context.context.mem_context.shared_buf);
|
&mem_ctx->shared_buf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static 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,
|
||||||
|
&mem_ctx->shared_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int psp_xgmi_init_shared_buf(struct psp_context *psp)
|
||||||
|
{
|
||||||
|
return psp_ta_init_shared_buf(psp, &psp->xgmi_context.context.mem_context,
|
||||||
|
PSP_XGMI_SHARED_MEM_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -1020,9 +1034,7 @@ int psp_xgmi_terminate(struct psp_context *psp)
|
||||||
psp->xgmi_context.context.initialized = false;
|
psp->xgmi_context.context.initialized = false;
|
||||||
|
|
||||||
/* free xgmi shared memory */
|
/* free xgmi shared memory */
|
||||||
amdgpu_bo_free_kernel(&psp->xgmi_context.context.mem_context.shared_bo,
|
psp_ta_free_shared_buf(&psp->xgmi_context.context.mem_context);
|
||||||
&psp->xgmi_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->xgmi_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1270,19 +1282,8 @@ int psp_xgmi_set_topology_info(struct psp_context *psp,
|
||||||
// ras begin
|
// ras begin
|
||||||
static int psp_ras_init_shared_buf(struct psp_context *psp)
|
static int psp_ras_init_shared_buf(struct psp_context *psp)
|
||||||
{
|
{
|
||||||
int ret;
|
return psp_ta_init_shared_buf(psp, &psp->ras_context.context.mem_context,
|
||||||
|
PSP_RAS_SHARED_MEM_SIZE);
|
||||||
/*
|
|
||||||
* Allocate 16k memory aligned to 4k from Frame Buffer (local
|
|
||||||
* physical) for ras ta <-> Driver
|
|
||||||
*/
|
|
||||||
ret = amdgpu_bo_create_kernel(psp->adev, PSP_RAS_SHARED_MEM_SIZE,
|
|
||||||
PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM,
|
|
||||||
&psp->ras_context.context.mem_context.shared_bo,
|
|
||||||
&psp->ras_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->ras_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int psp_ras_load(struct psp_context *psp)
|
static int psp_ras_load(struct psp_context *psp)
|
||||||
|
@ -1466,9 +1467,7 @@ static int psp_ras_terminate(struct psp_context *psp)
|
||||||
psp->ras_context.context.initialized = false;
|
psp->ras_context.context.initialized = false;
|
||||||
|
|
||||||
/* free ras shared memory */
|
/* free ras shared memory */
|
||||||
amdgpu_bo_free_kernel(&psp->ras_context.context.mem_context.shared_bo,
|
psp_ta_free_shared_buf(&psp->ras_context.context.mem_context);
|
||||||
&psp->ras_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->ras_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1576,19 +1575,8 @@ int psp_ras_trigger_error(struct psp_context *psp,
|
||||||
// HDCP start
|
// HDCP start
|
||||||
static int psp_hdcp_init_shared_buf(struct psp_context *psp)
|
static int psp_hdcp_init_shared_buf(struct psp_context *psp)
|
||||||
{
|
{
|
||||||
int ret;
|
return psp_ta_init_shared_buf(psp, &psp->hdcp_context.context.mem_context,
|
||||||
|
PSP_HDCP_SHARED_MEM_SIZE);
|
||||||
/*
|
|
||||||
* Allocate 16k memory aligned to 4k from Frame Buffer (local
|
|
||||||
* physical) for hdcp ta <-> Driver
|
|
||||||
*/
|
|
||||||
ret = amdgpu_bo_create_kernel(psp->adev, PSP_HDCP_SHARED_MEM_SIZE,
|
|
||||||
PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM,
|
|
||||||
&psp->hdcp_context.context.mem_context.shared_bo,
|
|
||||||
&psp->hdcp_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->hdcp_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int psp_hdcp_load(struct psp_context *psp)
|
static int psp_hdcp_load(struct psp_context *psp)
|
||||||
|
@ -1712,9 +1700,7 @@ static int psp_hdcp_terminate(struct psp_context *psp)
|
||||||
|
|
||||||
out:
|
out:
|
||||||
/* free hdcp shared memory */
|
/* free hdcp shared memory */
|
||||||
amdgpu_bo_free_kernel(&psp->hdcp_context.context.mem_context.shared_bo,
|
psp_ta_free_shared_buf(&psp->hdcp_context.context.mem_context);
|
||||||
&psp->hdcp_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->hdcp_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1723,19 +1709,8 @@ out:
|
||||||
// DTM start
|
// DTM start
|
||||||
static int psp_dtm_init_shared_buf(struct psp_context *psp)
|
static int psp_dtm_init_shared_buf(struct psp_context *psp)
|
||||||
{
|
{
|
||||||
int ret;
|
return psp_ta_init_shared_buf(psp, &psp->dtm_context.context.mem_context,
|
||||||
|
PSP_DTM_SHARED_MEM_SIZE);
|
||||||
/*
|
|
||||||
* Allocate 16k memory aligned to 4k from Frame Buffer (local
|
|
||||||
* physical) for dtm ta <-> Driver
|
|
||||||
*/
|
|
||||||
ret = amdgpu_bo_create_kernel(psp->adev, PSP_DTM_SHARED_MEM_SIZE,
|
|
||||||
PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM,
|
|
||||||
&psp->dtm_context.context.mem_context.shared_bo,
|
|
||||||
&psp->dtm_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->dtm_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int psp_dtm_load(struct psp_context *psp)
|
static int psp_dtm_load(struct psp_context *psp)
|
||||||
|
@ -1858,10 +1833,8 @@ static int psp_dtm_terminate(struct psp_context *psp)
|
||||||
psp->dtm_context.context.initialized = false;
|
psp->dtm_context.context.initialized = false;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
/* free hdcp shared memory */
|
/* free dtm shared memory */
|
||||||
amdgpu_bo_free_kernel(&psp->dtm_context.context.mem_context.shared_bo,
|
psp_ta_free_shared_buf(&psp->dtm_context.context.mem_context);
|
||||||
&psp->dtm_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->dtm_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1870,19 +1843,8 @@ out:
|
||||||
// RAP start
|
// RAP start
|
||||||
static int psp_rap_init_shared_buf(struct psp_context *psp)
|
static int psp_rap_init_shared_buf(struct psp_context *psp)
|
||||||
{
|
{
|
||||||
int ret;
|
return psp_ta_init_shared_buf(psp, &psp->rap_context.context.mem_context,
|
||||||
|
PSP_RAP_SHARED_MEM_SIZE);
|
||||||
/*
|
|
||||||
* Allocate 16k memory aligned to 4k from Frame Buffer (local
|
|
||||||
* physical) for rap ta <-> Driver
|
|
||||||
*/
|
|
||||||
ret = amdgpu_bo_create_kernel(psp->adev, PSP_RAP_SHARED_MEM_SIZE,
|
|
||||||
PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM,
|
|
||||||
&psp->rap_context.context.mem_context.shared_bo,
|
|
||||||
&psp->rap_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->rap_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int psp_rap_load(struct psp_context *psp)
|
static int psp_rap_load(struct psp_context *psp)
|
||||||
|
@ -1958,9 +1920,7 @@ static int psp_rap_initialize(struct psp_context *psp)
|
||||||
if (ret || status != TA_RAP_STATUS__SUCCESS) {
|
if (ret || status != TA_RAP_STATUS__SUCCESS) {
|
||||||
psp_rap_unload(psp);
|
psp_rap_unload(psp);
|
||||||
|
|
||||||
amdgpu_bo_free_kernel(&psp->rap_context.context.mem_context.shared_bo,
|
psp_ta_free_shared_buf(&psp->rap_context.context.mem_context);
|
||||||
&psp->rap_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->rap_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
psp->rap_context.context.initialized = false;
|
psp->rap_context.context.initialized = false;
|
||||||
|
|
||||||
|
@ -1985,9 +1945,7 @@ static int psp_rap_terminate(struct psp_context *psp)
|
||||||
psp->rap_context.context.initialized = false;
|
psp->rap_context.context.initialized = false;
|
||||||
|
|
||||||
/* free rap shared memory */
|
/* free rap shared memory */
|
||||||
amdgpu_bo_free_kernel(&psp->rap_context.context.mem_context.shared_bo,
|
psp_ta_free_shared_buf(&psp->rap_context.context.mem_context);
|
||||||
&psp->rap_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->rap_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2030,19 +1988,9 @@ out_unlock:
|
||||||
/* securedisplay start */
|
/* securedisplay start */
|
||||||
static int psp_securedisplay_init_shared_buf(struct psp_context *psp)
|
static int psp_securedisplay_init_shared_buf(struct psp_context *psp)
|
||||||
{
|
{
|
||||||
int ret;
|
return psp_ta_init_shared_buf(
|
||||||
|
psp, &psp->securedisplay_context.context.mem_context,
|
||||||
/*
|
PSP_SECUREDISPLAY_SHARED_MEM_SIZE);
|
||||||
* Allocate 16k memory aligned to 4k from Frame Buffer (local
|
|
||||||
* physical) for sa ta <-> Driver
|
|
||||||
*/
|
|
||||||
ret = amdgpu_bo_create_kernel(psp->adev, PSP_SECUREDISPLAY_SHARED_MEM_SIZE,
|
|
||||||
PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM,
|
|
||||||
&psp->securedisplay_context.context.mem_context.shared_bo,
|
|
||||||
&psp->securedisplay_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->securedisplay_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int psp_securedisplay_load(struct psp_context *psp)
|
static int psp_securedisplay_load(struct psp_context *psp)
|
||||||
|
@ -2120,9 +2068,7 @@ static int psp_securedisplay_initialize(struct psp_context *psp)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
psp_securedisplay_unload(psp);
|
psp_securedisplay_unload(psp);
|
||||||
|
|
||||||
amdgpu_bo_free_kernel(&psp->securedisplay_context.context.mem_context.shared_bo,
|
psp_ta_free_shared_buf(&psp->securedisplay_context.context.mem_context);
|
||||||
&psp->securedisplay_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->securedisplay_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
psp->securedisplay_context.context.initialized = false;
|
psp->securedisplay_context.context.initialized = false;
|
||||||
|
|
||||||
|
@ -2159,9 +2105,7 @@ static int psp_securedisplay_terminate(struct psp_context *psp)
|
||||||
psp->securedisplay_context.context.initialized = false;
|
psp->securedisplay_context.context.initialized = false;
|
||||||
|
|
||||||
/* free securedisplay shared memory */
|
/* free securedisplay shared memory */
|
||||||
amdgpu_bo_free_kernel(&psp->securedisplay_context.context.mem_context.shared_bo,
|
psp_ta_free_shared_buf(&psp->securedisplay_context.context.mem_context);
|
||||||
&psp->securedisplay_context.context.mem_context.shared_mc_addr,
|
|
||||||
&psp->securedisplay_context.context.mem_context.shared_buf);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue