<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p><span style="font-size:11pt">Tested-by: Xiaojie Yuan <Xiaojie.Yuan@amd.com></span></p>
<p><br>
</p>
<p><span style="font-size:11pt">Regards,</span></p>
<p><span style="font-size:11pt">Xiaojie</span><br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Huang Rui <ray.huang@amd.com><br>
<b>Sent:</b> Thursday, June 29, 2017 4:09:21 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org; Deucher, Alexander; Koenig, Christian<br>
<b>Cc:</b> Wang, Ken; Qiao, Joe(Markham); Jiang, Sonny; Huan, Alvin; Yuan, Xiaojie; Huang, Ray<br>
<b>Subject:</b> [PATCH v2] drm/amdgpu: fix the memory corruption on S3</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">psp->cmd will be used on resume phase, so we can not free it on hw_init.<br>
Otherwise, a memory corruption will be triggered.<br>
<br>
Signed-off-by: Huang Rui <ray.huang@amd.com><br>
---<br>
<br>
V1 -> V2:<br>
- remove "cmd" variable.<br>
- fix typo of check.<br>
<br>
Alex, Christian,<br>
<br>
This is the final fix for vega10 S3. The random memory corruption issue is root<br>
caused.<br>
<br>
Thanks,<br>
Ray<br>
<br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 17 +++++++++--------<br>
1 file changed, 9 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
index 5bed483..711476792 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
@@ -330,14 +330,11 @@ static int psp_load_fw(struct amdgpu_device *adev)<br>
{<br>
int ret;<br>
struct psp_context *psp = &adev->psp;<br>
- struct psp_gfx_cmd_resp *cmd;<br>
<br>
- cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);<br>
- if (!cmd)<br>
+ psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);<br>
+ if (!psp->cmd)<br>
return -ENOMEM;<br>
<br>
- psp->cmd = cmd;<br>
-<br>
ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,<br>
AMDGPU_GEM_DOMAIN_GTT,<br>
&psp->fw_pri_bo,<br>
@@ -376,8 +373,6 @@ static int psp_load_fw(struct amdgpu_device *adev)<br>
if (ret)<br>
goto failed_mem;<br>
<br>
- kfree(cmd);<br>
-<br>
return 0;<br>
<br>
failed_mem:<br>
@@ -387,7 +382,8 @@ static int psp_load_fw(struct amdgpu_device *adev)<br>
amdgpu_bo_free_kernel(&psp->fw_pri_bo,<br>
&psp->fw_pri_mc_addr, &psp->fw_pri_buf);<br>
failed:<br>
- kfree(cmd);<br>
+ kfree(psp->cmd);<br>
+ psp->cmd = NULL;<br>
return ret;<br>
}<br>
<br>
@@ -447,6 +443,11 @@ static int psp_hw_fini(void *handle)<br>
amdgpu_bo_free_kernel(&psp->fence_buf_bo,<br>
&psp->fence_buf_mc_addr, &psp->fence_buf);<br>
<br>
+ if (psp->cmd) {<br>
+ kfree(psp->cmd);<br>
+ psp->cmd = NULL;<br>
+ }<br>
+<br>
return 0;<br>
}<br>
<br>
-- <br>
2.7.4<br>
<br>
</div>
</span></font>
</body>
</html>