提交 a1952da7 编写于 作者: H Huang Rui 提交者: Alex Deucher

drm/amdgpu: make psp cmd buffer as a reserve memory

Signed-off-by: NHuang Rui <ray.huang@amd.com>
Acked-by: NChristian König <christian.koenig@amd.com>
Reviewed-by: NJunwei Zhang <Jerry.Zhang@amd.com>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
上级 311146c9
...@@ -118,33 +118,18 @@ psp_cmd_submit_buf(struct psp_context *psp, ...@@ -118,33 +118,18 @@ psp_cmd_submit_buf(struct psp_context *psp,
int index) int index)
{ {
int ret; int ret;
struct amdgpu_bo *cmd_buf_bo;
uint64_t cmd_buf_mc_addr;
struct psp_gfx_cmd_resp *cmd_buf_mem;
struct amdgpu_device *adev = psp->adev;
ret = amdgpu_bo_create_kernel(adev, PSP_CMD_BUFFER_SIZE, PAGE_SIZE,
AMDGPU_GEM_DOMAIN_VRAM,
&cmd_buf_bo, &cmd_buf_mc_addr,
(void **)&cmd_buf_mem);
if (ret)
return ret;
memset(cmd_buf_mem, 0, PSP_CMD_BUFFER_SIZE); memset(psp->cmd_buf_mem, 0, PSP_CMD_BUFFER_SIZE);
memcpy(cmd_buf_mem, cmd, sizeof(struct psp_gfx_cmd_resp)); memcpy(psp->cmd_buf_mem, cmd, sizeof(struct psp_gfx_cmd_resp));
ret = psp_cmd_submit(psp, ucode, cmd_buf_mc_addr, ret = psp_cmd_submit(psp, ucode, psp->cmd_buf_mc_addr,
fence_mc_addr, index); fence_mc_addr, index);
while (*((unsigned int *)psp->fence_buf) != index) { while (*((unsigned int *)psp->fence_buf) != index) {
msleep(1); msleep(1);
} }
amdgpu_bo_free_kernel(&cmd_buf_bo,
&cmd_buf_mc_addr,
(void **)&cmd_buf_mem);
return ret; return ret;
} }
...@@ -351,6 +336,13 @@ static int psp_load_fw(struct amdgpu_device *adev) ...@@ -351,6 +336,13 @@ static int psp_load_fw(struct amdgpu_device *adev)
&psp->fence_buf_bo, &psp->fence_buf_bo,
&psp->fence_buf_mc_addr, &psp->fence_buf_mc_addr,
&psp->fence_buf); &psp->fence_buf);
if (ret)
goto failed_mem2;
ret = amdgpu_bo_create_kernel(adev, PSP_CMD_BUFFER_SIZE, PAGE_SIZE,
AMDGPU_GEM_DOMAIN_VRAM,
&psp->cmd_buf_bo, &psp->cmd_buf_mc_addr,
(void **)&psp->cmd_buf_mem);
if (ret) if (ret)
goto failed_mem1; goto failed_mem1;
...@@ -358,7 +350,7 @@ static int psp_load_fw(struct amdgpu_device *adev) ...@@ -358,7 +350,7 @@ static int psp_load_fw(struct amdgpu_device *adev)
ret = psp_ring_init(psp, PSP_RING_TYPE__KM); ret = psp_ring_init(psp, PSP_RING_TYPE__KM);
if (ret) if (ret)
goto failed_mem1; goto failed_mem;
ret = psp_tmr_init(psp); ret = psp_tmr_init(psp);
if (ret) if (ret)
...@@ -379,9 +371,13 @@ static int psp_load_fw(struct amdgpu_device *adev) ...@@ -379,9 +371,13 @@ static int psp_load_fw(struct amdgpu_device *adev)
return 0; return 0;
failed_mem: failed_mem:
amdgpu_bo_free_kernel(&psp->cmd_buf_bo,
&psp->cmd_buf_mc_addr,
(void **)&psp->cmd_buf_mem);
failed_mem1:
amdgpu_bo_free_kernel(&psp->fence_buf_bo, amdgpu_bo_free_kernel(&psp->fence_buf_bo,
&psp->fence_buf_mc_addr, &psp->fence_buf); &psp->fence_buf_mc_addr, &psp->fence_buf);
failed_mem1: failed_mem2:
amdgpu_bo_free_kernel(&psp->fw_pri_bo, amdgpu_bo_free_kernel(&psp->fw_pri_bo,
&psp->fw_pri_mc_addr, &psp->fw_pri_buf); &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
failed: failed:
...@@ -442,6 +438,8 @@ static int psp_hw_fini(void *handle) ...@@ -442,6 +438,8 @@ static int psp_hw_fini(void *handle)
&psp->fence_buf_mc_addr, &psp->fence_buf); &psp->fence_buf_mc_addr, &psp->fence_buf);
amdgpu_bo_free_kernel(&psp->asd_shared_bo, &psp->asd_shared_mc_addr, amdgpu_bo_free_kernel(&psp->asd_shared_bo, &psp->asd_shared_mc_addr,
&psp->asd_shared_buf); &psp->asd_shared_buf);
amdgpu_bo_free_kernel(&psp->cmd_buf_bo, &psp->cmd_buf_mc_addr,
(void **)&psp->cmd_buf_mem);
kfree(psp->cmd); kfree(psp->cmd);
psp->cmd = NULL; psp->cmd = NULL;
......
...@@ -108,6 +108,11 @@ struct psp_context ...@@ -108,6 +108,11 @@ struct psp_context
struct amdgpu_bo *fence_buf_bo; struct amdgpu_bo *fence_buf_bo;
uint64_t fence_buf_mc_addr; uint64_t fence_buf_mc_addr;
void *fence_buf; void *fence_buf;
/* cmd buffer */
struct amdgpu_bo *cmd_buf_bo;
uint64_t cmd_buf_mc_addr;
struct psp_gfx_cmd_resp *cmd_buf_mem;
}; };
struct amdgpu_psp_funcs { struct amdgpu_psp_funcs {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册