diff options
author | Huang Rui <ray.huang@amd.com> | 2017-03-21 06:02:04 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-04-28 16:37:58 -0400 |
commit | f5cfef98f736f9aa42e9ad41e67b5abd96b77835 (patch) | |
tree | 6eaa349182446e2ca76b100c2b8be133c7208339 /drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | |
parent | 2b0c3aee2172451e9f982b25f3fdf59a1b687dc3 (diff) |
drm/amdgpu: split psp asd function
Rework in order to properly support suspend.
Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index ed9c04b7a286..ea5616036bf6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | |||
@@ -206,48 +206,43 @@ static void psp_prep_asd_cmd_buf(struct psp_gfx_cmd_resp *cmd, | |||
206 | cmd->cmd.cmd_load_ta.cmd_buf_len = shared_size; | 206 | cmd->cmd.cmd_load_ta.cmd_buf_len = shared_size; |
207 | } | 207 | } |
208 | 208 | ||
209 | static int psp_asd_init(struct psp_context *psp) | ||
210 | { | ||
211 | int ret; | ||
212 | |||
213 | /* | ||
214 | * Allocate 16k memory aligned to 4k from Frame Buffer (local | ||
215 | * physical) for shared ASD <-> Driver | ||
216 | */ | ||
217 | ret = amdgpu_bo_create_kernel(psp->adev, PSP_ASD_SHARED_MEM_SIZE, | ||
218 | PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, | ||
219 | &psp->asd_shared_bo, | ||
220 | &psp->asd_shared_mc_addr, | ||
221 | &psp->asd_shared_buf); | ||
222 | |||
223 | return ret; | ||
224 | } | ||
225 | |||
209 | static int psp_asd_load(struct psp_context *psp) | 226 | static int psp_asd_load(struct psp_context *psp) |
210 | { | 227 | { |
211 | int ret; | 228 | int ret; |
212 | struct amdgpu_bo *asd_shared_bo; | ||
213 | uint64_t asd_shared_mc_addr; | ||
214 | void *asd_shared_buf; | ||
215 | struct psp_gfx_cmd_resp *cmd; | 229 | struct psp_gfx_cmd_resp *cmd; |
216 | 230 | ||
217 | cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL); | 231 | cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL); |
218 | if (!cmd) | 232 | if (!cmd) |
219 | return -ENOMEM; | 233 | return -ENOMEM; |
220 | 234 | ||
221 | /* | ||
222 | * Allocate 16k memory aligned to 4k from Frame Buffer (local | ||
223 | * physical) for shared ASD <-> Driver | ||
224 | */ | ||
225 | ret = amdgpu_bo_create_kernel(psp->adev, PSP_ASD_SHARED_MEM_SIZE, PAGE_SIZE, | ||
226 | AMDGPU_GEM_DOMAIN_VRAM, | ||
227 | &asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf); | ||
228 | if (ret) | ||
229 | goto failed; | ||
230 | |||
231 | memset(psp->fw_pri_buf, 0, PSP_1_MEG); | 235 | memset(psp->fw_pri_buf, 0, PSP_1_MEG); |
232 | memcpy(psp->fw_pri_buf, psp->asd_start_addr, psp->asd_ucode_size); | 236 | memcpy(psp->fw_pri_buf, psp->asd_start_addr, psp->asd_ucode_size); |
233 | 237 | ||
234 | psp_prep_asd_cmd_buf(cmd, psp->fw_pri_mc_addr, asd_shared_mc_addr, | 238 | psp_prep_asd_cmd_buf(cmd, psp->fw_pri_mc_addr, psp->asd_shared_mc_addr, |
235 | psp->asd_ucode_size, PSP_ASD_SHARED_MEM_SIZE); | 239 | psp->asd_ucode_size, PSP_ASD_SHARED_MEM_SIZE); |
236 | 240 | ||
237 | ret = psp_cmd_submit_buf(psp, NULL, cmd, | 241 | ret = psp_cmd_submit_buf(psp, NULL, cmd, |
238 | psp->fence_buf_mc_addr, 2); | 242 | psp->fence_buf_mc_addr, 2); |
239 | if (ret) | ||
240 | goto failed_mem; | ||
241 | 243 | ||
242 | amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf); | ||
243 | kfree(cmd); | 244 | kfree(cmd); |
244 | 245 | ||
245 | return 0; | ||
246 | |||
247 | failed_mem: | ||
248 | amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf); | ||
249 | failed: | ||
250 | kfree(cmd); | ||
251 | return ret; | 246 | return ret; |
252 | } | 247 | } |
253 | 248 | ||
@@ -301,6 +296,10 @@ static int psp_load_fw(struct amdgpu_device *adev) | |||
301 | if (ret) | 296 | if (ret) |
302 | goto failed_mem; | 297 | goto failed_mem; |
303 | 298 | ||
299 | ret = psp_asd_init(psp); | ||
300 | if (ret) | ||
301 | goto failed_mem; | ||
302 | |||
304 | ret = psp_asd_load(psp); | 303 | ret = psp_asd_load(psp); |
305 | if (ret) | 304 | if (ret) |
306 | goto failed_mem; | 305 | goto failed_mem; |