<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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>yeah, that  way another of my fix patch is not neede</p>
<p><br>
</p>
<p>Reviewed-by: Monk Liu <monk.liu@amd.com><br>
</p>
<p><br>
</p>
<p>BR Monk<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> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Rex Zhu <Rex.Zhu@amd.com><br>
<b>Sent:</b> Wednesday, October 18, 2017 5:29:39 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Zhu, Rex<br>
<b>Subject:</b> [PATCH] drm/amdgpu: fix regresstion on SR-IOV gpu reset failed</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">fw ucode is corrupted after vf flr by PSP so ucode_init() is<br>
a must in psp_hw_init othewise KIQ/KCQ enabling will fail<br>
<br>
Revert "drm/amdgpu: refine code delete duplicated error handling"<br>
This reverts commit e57b87ff828f95efe992468e6d18c2c059b27aa9.<br>
Revert "drm/amdgpu: move amdgpu_ucode_init_bo to amdgpu_device.c"<br>
This reverts commit 815b8f8595148d06a64d2ce4282e8e80dfcb02f1.<br>
<br>
Change-Id: I4c4f05ce85f7828e7ac19a2bfffa223614cca59a<br>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 8 --------<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | 5 +++++<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       | 9 +++++++++<br>
 3 files changed, 14 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
index 2ae488b..0e35e09 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
@@ -1680,7 +1680,6 @@ static int amdgpu_init(struct amdgpu_device *adev)<br>
                         return r;<br>
                 }<br>
                 adev->ip_blocks[i].status.sw = true;<br>
-<br>
                 /* need to do gmc hw init early so we can allocate gpu mem */<br>
                 if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) {<br>
                         r = amdgpu_vram_scratch_init(adev);<br>
@@ -1711,11 +1710,6 @@ static int amdgpu_init(struct amdgpu_device *adev)<br>
                 }<br>
         }<br>
 <br>
-       mutex_lock(&adev->firmware.mutex);<br>
-       if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)<br>
-               amdgpu_ucode_init_bo(adev);<br>
-       mutex_unlock(&adev->firmware.mutex);<br>
-<br>
         for (i = 0; i < adev->num_ip_blocks; i++) {<br>
                 if (!adev->ip_blocks[i].status.sw)<br>
                         continue;<br>
@@ -1851,8 +1845,6 @@ static int amdgpu_fini(struct amdgpu_device *adev)<br>
 <br>
                 adev->ip_blocks[i].status.hw = false;<br>
         }<br>
-       if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)<br>
-               amdgpu_ucode_fini_bo(adev);<br>
 <br>
         for (i = adev->num_ip_blocks - 1; i >= 0; i--) {<br>
                 if (!adev->ip_blocks[i].status.sw)<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c<br>
index 3b42f40..5f5aa5f 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c<br>
@@ -145,6 +145,8 @@ static int amdgpu_pp_hw_init(void *handle)<br>
         int ret = 0;<br>
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
 <br>
+       if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)<br>
+               amdgpu_ucode_init_bo(adev);<br>
 <br>
         if (adev->powerplay.ip_funcs->hw_init)<br>
                 ret = adev->powerplay.ip_funcs->hw_init(<br>
@@ -162,6 +164,9 @@ static int amdgpu_pp_hw_fini(void *handle)<br>
                 ret = adev->powerplay.ip_funcs->hw_fini(<br>
                                         adev->powerplay.pp_handle);<br>
 <br>
+       if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)<br>
+               amdgpu_ucode_fini_bo(adev);<br>
+<br>
         return ret;<br>
 }<br>
 <br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
index f1035a6..447d446 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
@@ -411,6 +411,13 @@ static int psp_hw_init(void *handle)<br>
                 return 0;<br>
 <br>
         mutex_lock(&adev->firmware.mutex);<br>
+       /*<br>
+        * This sequence is just used on hw_init only once, no need on<br>
+        * resume.<br>
+        */<br>
+       ret = amdgpu_ucode_init_bo(adev);<br>
+       if (ret)<br>
+               goto failed;<br>
 <br>
         ret = psp_load_fw(adev);<br>
         if (ret) {<br>
@@ -435,6 +442,8 @@ static int psp_hw_fini(void *handle)<br>
         if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)<br>
                 return 0;<br>
 <br>
+       amdgpu_ucode_fini_bo(adev);<br>
+<br>
         psp_ring_destroy(psp, PSP_RING_TYPE__KM);<br>
 <br>
         amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);<br>
-- <br>
1.9.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font>
</body>
</html>