On 1/8/2025 08:00, Jiang Liu wrote:
There are some mismatch between IP block state machine and its associated
status flags, especially about the meaning of `status.late_initialized`.
So let's make the state machine and associated status flas work in stack-like
s/flas/flag/
way as below:
Callback Status
early_init: valid = true
sw_init: sw = true
hw_init: hw = true
late_init: late_initialized = true
early_fini: late_initialized = false
hw_fini: hw = false
sw_fini: sw = false
late_fini: valid = false
Would you mind also putting this into kerneldoc? I think it would be
really helpful for others to be able to follow in the future why there
are so many variables and what they all mean.
Signed-off-by: Jiang Liu <gerry@xxxxxxxxxxxxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 0e69c7c7fe1f..36a33a391411 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3332,6 +3332,8 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
DRM_DEBUG("early_fini of IP block <%s> failed %d\n",
adev->ip_blocks[i].version->funcs->name, r);
}
+
+ adev->ip_blocks[i].status.late_initialized = false;
}
amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
@@ -3407,15 +3409,14 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
adev->ip_blocks[i].version->funcs->name, r);
}
adev->ip_blocks[i].status.sw = false;
- adev->ip_blocks[i].status.valid = false;
}
for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
- if (!adev->ip_blocks[i].status.late_initialized)
+ if (!adev->ip_blocks[i].status.valid)
continue;
if (adev->ip_blocks[i].version->funcs->late_fini)
adev->ip_blocks[i].version->funcs->late_fini(&adev->ip_blocks[i]);
- adev->ip_blocks[i].status.late_initialized = false;
+ adev->ip_blocks[i].status.valid = false;
}
amdgpu_ras_fini(adev);