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 <[email protected]>
---

Alex, Christian,

This is the final fix for vega10 S3. The random memory corruption issue is root
caused.

Thanks,
Ray

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 5041073..fcdd542 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -372,8 +372,6 @@ static int psp_load_fw(struct amdgpu_device *adev)
        if (ret)
                goto failed_mem;
 
-       kfree(cmd);
-
        return 0;
 
 failed_mem:
@@ -384,6 +382,7 @@ static int psp_load_fw(struct amdgpu_device *adev)
                              &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
 failed:
        kfree(cmd);
+       cmd = NULL;
        return ret;
 }
 
@@ -443,6 +442,11 @@ static int psp_hw_fini(void *handle)
                amdgpu_bo_free_kernel(&psp->fence_buf_bo,
                                      &psp->fence_buf_mc_addr, &psp->fence_buf);
 
+       if (!psp->cmd) {
+               kfree(psp->cmd);
+               psp->cmd = NULL;
+       }
+
        return 0;
 }
 
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to