[PATCH 2/2] drm/amdgpu: add the fan abnormal detection feature

Feng, Kenneth Kenneth.Feng at amd.com
Mon Nov 21 02:16:08 UTC 2022


[AMD Official Use Only - General]

Series is Reviewed-by: Kenneth Feng <kenneth.feng at amd.com>

-----Original Message-----
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of lyndonli
Sent: Monday, November 21, 2022 9:45 AM
To: amd-gfx at lists.freedesktop.org
Cc: Xu, Feifei <Feifei.Xu at amd.com>; enneth.feng at amd.com; Quan, Evan <Evan.Quan at amd.com>; Li, Lyndon <Lyndon.Li at amd.com>
Subject: [PATCH 2/2] drm/amdgpu: add the fan abnormal detection feature

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.


Update the SW CTF limit from existing register when there's a fan failure detected via SMU interrupt.

Signed-off-by: lyndonli <Lyndon.Li at amd.com>
---
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  1 +
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    | 28 +++++++++++++++++++
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c  |  1 +
 3 files changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
index 44bbf17e4bef..3bc4128a22ac 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
@@ -168,6 +168,7 @@ struct smu_temperature_range {
        int mem_crit_max;
        int mem_emergency_max;
        int software_shutdown_temp;
+       int software_shutdown_temp_offset;
 };

 struct smu_state_validation_block {
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
index 89f0f6eb19f3..5a905002252d 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
@@ -1376,6 +1376,7 @@ static int smu_v13_0_irq_process(struct amdgpu_device *adev,
         */
        uint32_t ctxid = entry->src_data[0];
        uint32_t data;
+       uint32_t high;

        if (client_id == SOC15_IH_CLIENTID_THM) {
                switch (src_id) {
@@ -1432,6 +1433,33 @@ static int smu_v13_0_irq_process(struct amdgpu_device *adev,
                                        schedule_work(&smu->throttling_logging_work);

                                break;
+                       case 0x8:
+                               high = smu->thermal_range.software_shutdown_temp +
+                                       smu->thermal_range.software_shutdown_temp_offset;
+                               high = min(SMU_THERMAL_MAXIMUM_ALERT_TEMP, high);
+                               dev_emerg(adev->dev, "Reduce soft CTF limit to %d (by an offset %d)\n",
+                                                       high,
+
+ smu->thermal_range.software_shutdown_temp_offset);
+
+                               data = RREG32_SOC15(THM, 0, regTHM_THERMAL_INT_CTRL);
+                               data = REG_SET_FIELD(data, THM_THERMAL_INT_CTRL,
+                                                       DIG_THERM_INTH,
+                                                       (high & 0xff));
+                               data = data & (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK);
+                               WREG32_SOC15(THM, 0, regTHM_THERMAL_INT_CTRL, data);
+                               break;
+                       case 0x9:
+                               high = min(SMU_THERMAL_MAXIMUM_ALERT_TEMP,
+                                       smu->thermal_range.software_shutdown_temp);
+                               dev_emerg(adev->dev, "Recover soft CTF
+ limit to %d\n", high);
+
+                               data = RREG32_SOC15(THM, 0, regTHM_THERMAL_INT_CTRL);
+                               data = REG_SET_FIELD(data, THM_THERMAL_INT_CTRL,
+                                                       DIG_THERM_INTH,
+                                                       (high & 0xff));
+                               data = data & (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK);
+                               WREG32_SOC15(THM, 0, regTHM_THERMAL_INT_CTRL, data);
+                               break;
                        }
                }
        }
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
index d74debc584f8..c3c9ef523e59 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
@@ -1223,6 +1223,7 @@ static int smu_v13_0_7_get_thermal_temperature_range(struct smu_context *smu,
        range->mem_emergency_max = (pptable->SkuTable.TemperatureLimit[TEMP_MEM] + CTF_OFFSET_MEM)*
                SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
        range->software_shutdown_temp = powerplay_table->software_shutdown_temp;
+       range->software_shutdown_temp_offset =
+ pptable->SkuTable.FanAbnormalTempLimitOffset;

        return 0;
 }
--
2.25.1



More information about the amd-gfx mailing list