Skip to contentSkip to conversation

drm/amdgpu: Execute IP's hw_fini when hw_init failed

PATCH In review Alice Wong 3 participants 4 messages Apr 19, 2022 – Apr 20, 2022

Subsystems (2)
lore
Share & tools
lore

Alice Wong

author
#0 lore raw

PATCH 1/2 drm/amdgpu: Execute IP's hw_fini when hw_init failed

amdgpu_device_ip_hw_init_phase1 and amdgpu_device_ip_hw_init_phase2 call IP blocks' respective hw_fini when hw_init failed.

BUG SWDEV-332449
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index ec38517ab33f..3abe647bbd2a 100644
@@ -2281,6 +2281,7 @@ static int amdgpu_device_ip_hw_init_phase1(struct amdgpu_device *adev)
 			if (r) {
 				DRM_ERROR("hw_init of IP block <%s> failed %d\n",
 					  adev->ip_blocks[i].version->funcs->name, r);
+				adev->ip_blocks[i].version->funcs->hw_fini(adev);
 				return r;
 			}
 			adev->ip_blocks[i].status.hw = true;
@@ -2303,6 +2304,7 @@ static int amdgpu_device_ip_hw_init_phase2(struct amdgpu_device *adev)
 		if (r) {
 			DRM_ERROR("hw_init of IP block <%s> failed %d\n",
 				  adev->ip_blocks[i].version->funcs->name, r);
+			adev->ip_blocks[i].version->funcs->hw_fini(adev);
 			return r;
 		}
 		adev->ip_blocks[i].status.hw = true;
Signature · 1 line
2.25.1
#1 lore raw

[AMD Official Use Only]

amdgpu_device_ip_hw_init_phase1 and amdgpu_device_ip_hw_init_phase2 call IP blocks' respective hw_fini when hw_init failed.

BUG SWDEV-332449
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index ec38517ab33f..3abe647bbd2a 100644
@@ -2281,6 +2281,7 @@ static int amdgpu_device_ip_hw_init_phase1(struct amdgpu_device *adev)
 			if (r) {
 				DRM_ERROR("hw_init of IP block <%s> failed %d\n",
 					  adev->ip_blocks[i].version->funcs->name, r);
+				adev->ip_blocks[i].version->funcs->hw_fini(adev);
 				return r;
 			}
 			adev->ip_blocks[i].status.hw = true; @@ -2303,6 +2304,7 @@ static int amdgpu_device_ip_hw_init_phase2(struct amdgpu_device *adev)

if (r) {
DRM_ERROR("hw_init of IP block <%s> failed %d\n",
adev->ip_blocks[i].version->funcs->name, r);
+ adev->ip_blocks[i].version->funcs->hw_fini(adev);
return r;
}
adev->ip_blocks[i].status.hw = true;
--
2.25.1

#2 lore raw
In reply to Alice Wong
Quoted 3 lines · Alice Wong

amdgpu_device_ip_hw_init_phase1 and amdgpu_device_ip_hw_init_phase2 call IP blocks' respective hw_fini when hw_init failed.

I don't think we should call hw_fini() if hw_init() failed. If there are things that are not properly cleaned up in hw_init() fail cases, those should be fixed in the relevant hw_init callbacks.

Alex

Quoted 30 lines
BUG SWDEV-332449
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
index ec38517ab33f..3abe647bbd2a 100644
@@ -2281,6 +2281,7 @@ static int amdgpu_device_ip_hw_init_phase1(struct amdgpu_device *adev)
                        if (r) {
                                DRM_ERROR("hw_init of IP block <%s> failed %d\n",
                                          adev->ip_blocks[i].version->funcs->name, r);
+                               adev->ip_blocks[i].version->funcs->hw_fini(adev);
                                return r;
                        }
                        adev->ip_blocks[i].status.hw = true;
@@ -2303,6 +2304,7 @@ static int amdgpu_device_ip_hw_init_phase2(struct amdgpu_device *adev)
                if (r) {
                        DRM_ERROR("hw_init of IP block <%s> failed %d\n",
                                  adev->ip_blocks[i].version->funcs->name, r);
+                       adev->ip_blocks[i].version->funcs->hw_fini(adev);
                        return r;
                }
                adev->ip_blocks[i].status.hw = true;
--

2.25.1

#3 lore raw

Am 19.04.22 um 21:59 schrieb Alex Deucher:

Quoted 6 lines · Alice Wong
Quoted 2 lines

amdgpu_device_ip_hw_init_phase1 and amdgpu_device_ip_hw_init_phase2 call IP blocks' respective hw_fini when hw_init failed.

I don't think we should call hw_fini() if hw_init() failed. If there are things that are not properly cleaned up in hw_init() fail cases, those should be fixed in the relevant hw_init callbacks.

I agree. That doesn't looks like good design to me.

Each IP block should cleanup themselves when their hw_init fails.

Only the previously initialized blocks should be cleaned up by the common framework.

Regards,
Christian.

Quoted 32 lines

Alex

Quoted 29 lines
BUG SWDEV-332449
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
index ec38517ab33f..3abe647bbd2a 100644
@@ -2281,6 +2281,7 @@ static int amdgpu_device_ip_hw_init_phase1(struct amdgpu_device *adev)
                         if (r) {
                                 DRM_ERROR("hw_init of IP block <%s> failed %d\n",
                                           adev->ip_blocks[i].version->funcs->name, r);
+                               adev->ip_blocks[i].version->funcs->hw_fini(adev);
                                 return r;
                         }
                         adev->ip_blocks[i].status.hw = true;
@@ -2303,6 +2304,7 @@ static int amdgpu_device_ip_hw_init_phase2(struct amdgpu_device *adev)
                 if (r) {
                         DRM_ERROR("hw_init of IP block <%s> failed %d\n",
                                   adev->ip_blocks[i].version->funcs->name, r);
+                       adev->ip_blocks[i].version->funcs->hw_fini(adev);
                         return r;
                 }
                 adev->ip_blocks[i].status.hw = true;
--

2.25.1