diff options
author | Huang Rui <ray.huang@amd.com> | 2017-06-29 02:21:49 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-06-29 12:43:43 -0400 |
commit | 67bef0f7908a3a6b10e5a29d8e8c09e27f90c9f8 (patch) | |
tree | 4327180d678cfa4d54bd82570b503a66d55a10e0 /drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | |
parent | 6b0fa871a9a2d83dd869ca40a7fd65a935d3564c (diff) |
drm/amdgpu: fix the memory corruption on S3
psp->cmd will be used on resume phase, so we can not free it on hw_init.
Otherwise, a memory corruption will be triggered.
Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Tested-by: Xiaojie Yuan <Xiaojie.Yuan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index c224c5caba5b..e19369efb840 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | |||
@@ -333,14 +333,11 @@ static int psp_load_fw(struct amdgpu_device *adev) | |||
333 | { | 333 | { |
334 | int ret; | 334 | int ret; |
335 | struct psp_context *psp = &adev->psp; | 335 | struct psp_context *psp = &adev->psp; |
336 | struct psp_gfx_cmd_resp *cmd; | ||
337 | 336 | ||
338 | cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL); | 337 | psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL); |
339 | if (!cmd) | 338 | if (!psp->cmd) |
340 | return -ENOMEM; | 339 | return -ENOMEM; |
341 | 340 | ||
342 | psp->cmd = cmd; | ||
343 | |||
344 | ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG, | 341 | ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG, |
345 | AMDGPU_GEM_DOMAIN_GTT, | 342 | AMDGPU_GEM_DOMAIN_GTT, |
346 | &psp->fw_pri_bo, | 343 | &psp->fw_pri_bo, |
@@ -379,8 +376,6 @@ static int psp_load_fw(struct amdgpu_device *adev) | |||
379 | if (ret) | 376 | if (ret) |
380 | goto failed_mem; | 377 | goto failed_mem; |
381 | 378 | ||
382 | kfree(cmd); | ||
383 | |||
384 | return 0; | 379 | return 0; |
385 | 380 | ||
386 | failed_mem: | 381 | failed_mem: |
@@ -390,7 +385,8 @@ failed_mem1: | |||
390 | amdgpu_bo_free_kernel(&psp->fw_pri_bo, | 385 | amdgpu_bo_free_kernel(&psp->fw_pri_bo, |
391 | &psp->fw_pri_mc_addr, &psp->fw_pri_buf); | 386 | &psp->fw_pri_mc_addr, &psp->fw_pri_buf); |
392 | failed: | 387 | failed: |
393 | kfree(cmd); | 388 | kfree(psp->cmd); |
389 | psp->cmd = NULL; | ||
394 | return ret; | 390 | return ret; |
395 | } | 391 | } |
396 | 392 | ||
@@ -450,6 +446,9 @@ static int psp_hw_fini(void *handle) | |||
450 | amdgpu_bo_free_kernel(&psp->fence_buf_bo, | 446 | amdgpu_bo_free_kernel(&psp->fence_buf_bo, |
451 | &psp->fence_buf_mc_addr, &psp->fence_buf); | 447 | &psp->fence_buf_mc_addr, &psp->fence_buf); |
452 | 448 | ||
449 | kfree(psp->cmd); | ||
450 | psp->cmd = NULL; | ||
451 | |||
453 | return 0; | 452 | return 0; |
454 | } | 453 | } |
455 | 454 | ||