Skip to contentSkip to conversation

drm/amdgpu: fix regresstion on SR-IOV gpu reset failed

PATCH In review Rex Zhu 2 participants 2 messages Oct 18, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Rex Zhu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix regresstion on SR-IOV gpu reset failed

fw ucode is corrupted after vf flr by PSP so ucode_init() is a must in psp_hw_init othewise KIQ/KCQ enabling will fail

Revert "drm/amdgpu: refine code delete duplicated error handling" This reverts commit e57b87ff828f95efe992468e6d18c2c059b27aa9. Revert "drm/amdgpu: move amdgpu_ucode_init_bo to amdgpu_device.c" This reverts commit 815b8f8595148d06a64d2ce4282e8e80dfcb02f1.

Change-Id I4c4f05ce85f7828e7ac19a2bfffa223614cca59a
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 8 --------
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | 5 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       | 9 +++++++++
 3 files changed, 14 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -8
index 2ae488b..0e35e09 100644
@@ -1680,7 +1680,6 @@ static int amdgpu_init(struct amdgpu_device *adev)
 			return r;
 		}
 		adev->ip_blocks[i].status.sw = true;
-
 		/* need to do gmc hw init early so we can allocate gpu mem */
 		if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) {
 			r = amdgpu_vram_scratch_init(adev);
@@ -1711,11 +1710,6 @@ static int amdgpu_init(struct amdgpu_device *adev)
 		}
 	}
 
-	mutex_lock(&adev->firmware.mutex);
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)
-		amdgpu_ucode_init_bo(adev);
-	mutex_unlock(&adev->firmware.mutex);
-
 	for (i = 0; i < adev->num_ip_blocks; i++) {
 		if (!adev->ip_blocks[i].status.sw)
 			continue;
@@ -1851,8 +1845,6 @@ static int amdgpu_fini(struct amdgpu_device *adev)
 
 		adev->ip_blocks[i].status.hw = false;
 	}
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)
-		amdgpu_ucode_fini_bo(adev);
 
 	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
 		if (!adev->ip_blocks[i].status.sw)
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +5 -0
index 3b42f40..5f5aa5f 100644
@@ -145,6 +145,8 @@ static int amdgpu_pp_hw_init(void *handle)
 	int ret = 0;
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
+		amdgpu_ucode_init_bo(adev);
 
 	if (adev->powerplay.ip_funcs->hw_init)
 		ret = adev->powerplay.ip_funcs->hw_init(
@@ -162,6 +164,9 @@ static int amdgpu_pp_hw_fini(void *handle)
 		ret = adev->powerplay.ip_funcs->hw_fini(
 					adev->powerplay.pp_handle);
 
+	if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
+		amdgpu_ucode_fini_bo(adev);
+
 	return ret;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -0
index f1035a6..447d446 100644
@@ -411,6 +411,13 @@ static int psp_hw_init(void *handle)
 		return 0;
 
 	mutex_lock(&adev->firmware.mutex);
+	/*
+	 * This sequence is just used on hw_init only once, no need on
+	 * resume.
+	 */
+	ret = amdgpu_ucode_init_bo(adev);
+	if (ret)
+		goto failed;
 
 	ret = psp_load_fw(adev);
 	if (ret) {
@@ -435,6 +442,8 @@ static int psp_hw_fini(void *handle)
 	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
 		return 0;
 
+	amdgpu_ucode_fini_bo(adev);
+
 	psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
 	amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#2 lore raw
In reply to a message not in the archive

yeah, that way another of my fix patch is not neede

BR Monk

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <[email protected]>
Sent: Wednesday, October 18, 2017 5:29:39 PM
To: [email protected]
Cc: Zhu, Rex
Subject: [PATCH] drm/amdgpu: fix regresstion on SR-IOV gpu reset failed

fw ucode is corrupted after vf flr by PSP so ucode_init() is a must in psp_hw_init othewise KIQ/KCQ enabling will fail

Revert "drm/amdgpu: refine code delete duplicated error handling" This reverts commit e57b87ff828f95efe992468e6d18c2c059b27aa9. Revert "drm/amdgpu: move amdgpu_ucode_init_bo to amdgpu_device.c" This reverts commit 815b8f8595148d06a64d2ce4282e8e80dfcb02f1.

Change-Id I4c4f05ce85f7828e7ac19a2bfffa223614cca59a
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 8 --------
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | 5 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       | 9 +++++++++
 3 files changed, 14 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -8
index 2ae488b..0e35e09 100644
@@ -1680,7 +1680,6 @@ static int amdgpu_init(struct amdgpu_device *adev)
                         return r;
                 }
                 adev->ip_blocks[i].status.sw = true;
-
                 /* need to do gmc hw init early so we can allocate gpu mem */
                 if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) {
                         r = amdgpu_vram_scratch_init(adev);
@@ -1711,11 +1710,6 @@ static int amdgpu_init(struct amdgpu_device *adev)
                 }
         }
 
-       mutex_lock(&adev->firmware.mutex);
-       if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)
-               amdgpu_ucode_init_bo(adev);
-       mutex_unlock(&adev->firmware.mutex);
-
         for (i = 0; i < adev->num_ip_blocks; i++) {
                 if (!adev->ip_blocks[i].status.sw)
                         continue;
@@ -1851,8 +1845,6 @@ static int amdgpu_fini(struct amdgpu_device *adev)
 
                 adev->ip_blocks[i].status.hw = false;
         }
-       if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)
-               amdgpu_ucode_fini_bo(adev);
 
         for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
                 if (!adev->ip_blocks[i].status.sw)
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +5 -0
index 3b42f40..5f5aa5f 100644
@@ -145,6 +145,8 @@ static int amdgpu_pp_hw_init(void *handle)
         int ret = 0;
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+       if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
+               amdgpu_ucode_init_bo(adev);
 
         if (adev->powerplay.ip_funcs->hw_init)
                 ret = adev->powerplay.ip_funcs->hw_init(
@@ -162,6 +164,9 @@ static int amdgpu_pp_hw_fini(void *handle)
                 ret = adev->powerplay.ip_funcs->hw_fini(
                                         adev->powerplay.pp_handle);
 
+       if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
+               amdgpu_ucode_fini_bo(adev);
+
         return ret;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -0
index f1035a6..447d446 100644
@@ -411,6 +411,13 @@ static int psp_hw_init(void *handle)
                 return 0;
 
         mutex_lock(&adev->firmware.mutex);
+       /*
+        * This sequence is just used on hw_init only once, no need on
+        * resume.
+        */
+       ret = amdgpu_ucode_init_bo(adev);
+       if (ret)
+               goto failed;
 
         ret = psp_load_fw(adev);
         if (ret) {
@@ -435,6 +442,8 @@ static int psp_hw_fini(void *handle)
         if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
                 return 0;
 
+       amdgpu_ucode_fini_bo(adev);
+
         psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
         amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);

--
1.9.1

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

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