[PATCH v3 2/3] drm/amd: Make SW CTF handler cope with different read_sensor() results
Mario Limonciello
mario.limonciello at amd.com
Fri Dec 15 19:55:35 UTC 2023
The SW CTF handler assumes that the read_sensor() call always succeeds
and has updated `hotspot_tmp`, but this may not be guaranteed.
For example some of the read_sensor() callbacks will return 0 when a RAS
interrupt is triggered in which case `hotspot_tmp` won't be updated.
Adjust the logic to catch this circumstance and output a warning.
Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
---
v2->v3:
* Correctly handle fallthrough case
v1->v2:
* Only show `Failed to read hotspot temperature` when sensor read fails
---
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 24 ++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index d24fccf28f6a..963cf6e76935 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -1165,21 +1165,27 @@ static void smu_swctf_delayed_work_handler(struct work_struct *work)
struct smu_temperature_range *range =
&smu->thermal_range;
struct amdgpu_device *adev = smu->adev;
- uint32_t hotspot_tmp, size;
+ uint32_t hotspot_tmp = 0, size;
/*
* If the hotspot temperature is confirmed as below SW CTF setting point
* after the delay enforced, nothing will be done.
* Otherwise, a graceful shutdown will be performed to prevent further damage.
*/
- if (range->software_shutdown_temp &&
- smu->ppt_funcs->read_sensor &&
- !smu->ppt_funcs->read_sensor(smu,
- AMDGPU_PP_SENSOR_HOTSPOT_TEMP,
- &hotspot_tmp,
- &size) &&
- hotspot_tmp / 1000 < range->software_shutdown_temp)
- return;
+ if (range->software_shutdown_temp && smu->ppt_funcs->read_sensor) {
+ int r = smu->ppt_funcs->read_sensor(smu,
+ AMDGPU_PP_SENSOR_HOTSPOT_TEMP,
+ &hotspot_tmp,
+ &size);
+ switch (r) {
+ case 0:
+ if (hotspot_tmp / 1000 < range->software_shutdown_temp)
+ return;
+ break;
+ default:
+ dev_err(adev->dev, "Failed to read hotspot temperature: %d\n", r);
+ }
+ }
dev_emerg(adev->dev, "ERROR: GPU over temperature range(SW CTF) detected!\n");
dev_emerg(adev->dev, "ERROR: System is going to shutdown due to GPU SW CTF!\n");
--
2.34.1
More information about the amd-gfx
mailing list