Skip to contentSkip to conversation

drm/amd/pm: Add throttle limit for SMU v13.0.6

PATCH In review Lijo Lazar 3 participants 4 messages Sep 20, 2023 – Sep 29, 2023

Subsystems (3)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/2 drm/amd/pm: Add throttle limit for SMU v13.0.6

CTF limit represents the max operating temperature and thermal limit gives the limit at which throttling starts. Add support for both limits. SOC and HBM may have different limit values.*_emergency_max gives max operating temperature and *_crit_max value represents throttle limit.

---
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 34 +++++++++++++++----
 1 file changed, 27 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +27 -7
index 11a6cd96c601..73db595bf6d9 100644
@@ -165,6 +165,7 @@ static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COU
 	MSG_MAP(SetSoftMaxGfxClk,                    PPSMC_MSG_SetSoftMaxGfxClk,                0),
 	MSG_MAP(PrepareMp1ForUnload,                 PPSMC_MSG_PrepareForDriverUnload,          0),
 	MSG_MAP(GetCTFLimit,                         PPSMC_MSG_GetCTFLimit,                     0),
+	MSG_MAP(GetThermalLimit,                     PPSMC_MSG_ReadThrottlerLimit,              0),
 	MSG_MAP(ClearMcaOnRead,	                     PPSMC_MSG_ClearMcaOnRead,                  0),
 	MSG_MAP(QueryValidMcaCount,                  PPSMC_MSG_QueryValidMcaCount,              0),
 	MSG_MAP(QueryValidMcaCeCount,                PPSMC_MSG_QueryValidMcaCeCount,            0),
@@ -2110,7 +2111,7 @@ static int smu_v13_0_6_get_thermal_temperature_range(struct smu_context *smu,
 						     struct smu_temperature_range *range)
 {
 	struct amdgpu_device *adev = smu->adev;
-	u32 aid_temp, xcd_temp, mem_temp;
+	u32 aid_temp, xcd_temp, max_temp;
 	uint32_t smu_version;
 	u32 ccd_temp = 0;
 	int ret;
@@ -2126,31 +2127,50 @@ static int smu_v13_0_6_get_thermal_temperature_range(struct smu_context *smu,
 	if (smu_version < 0x554500)
 		return 0;
 
+	/* Get SOC Max operating temperature */
 	ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetCTFLimit,
 					      PPSMC_AID_THM_TYPE, &aid_temp);
 	if (ret)
 		goto failed;
-
 	if (adev->flags & AMD_IS_APU) {
 		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetCTFLimit,
 						      PPSMC_CCD_THM_TYPE, &ccd_temp);
 		if (ret)
 			goto failed;
 	}
-
 	ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetCTFLimit,
 					      PPSMC_XCD_THM_TYPE, &xcd_temp);
 	if (ret)
 		goto failed;
-
-	range->hotspot_crit_max = max3(aid_temp, xcd_temp, ccd_temp) *
+	range->hotspot_emergency_max = max3(aid_temp, xcd_temp, ccd_temp) *
 				       SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
+
+	/* Get HBM Max operating temperature */
 	ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetCTFLimit,
-					      PPSMC_HBM_THM_TYPE, &mem_temp);
+					      PPSMC_HBM_THM_TYPE, &max_temp);
 	if (ret)
 		goto failed;
+	range->mem_emergency_max =
+		max_temp * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
+
+	/* Get SOC thermal throttle limit */
+	ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetThermalLimit,
+					      PPSMC_THROTTLING_LIMIT_TYPE_SOCKET,
+					      &max_temp);
+	if (ret)
+		goto failed;
+	range->hotspot_crit_max =
+		max_temp * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
+
+	/* Get HBM thermal throttle limit */
+	ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetThermalLimit,
+					      PPSMC_THROTTLING_LIMIT_TYPE_HBM,
+					      &max_temp);
+	if (ret)
+		goto failed;
+
+	range->mem_crit_max = max_temp * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
 
-	range->mem_crit_max = mem_temp * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
 failed:
 	return ret;
 }
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/2 drm/amd/pm: Add GC v9.4.3 thermal limits to hwmon

Publish max operating temperature of SOC and memory as temp*_emergency nodes in hwmon. temp*_crit will show the throttle temperature limits.

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +12 -7
index 2807f3bd9ebe..5d84cdcd7c0e 100644
@@ -3353,15 +3353,20 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
 		return 0;
 
 	/* hotspot temperature for gc 9,4,3*/
-	if ((gc_ver == IP_VERSION(9, 4, 3)) &&
-	    (attr == &sensor_dev_attr_temp1_input.dev_attr.attr ||
-	     attr == &sensor_dev_attr_temp1_label.dev_attr.attr))
-		return 0;
+	if (gc_ver == IP_VERSION(9, 4, 3)) {
+		if (attr == &sensor_dev_attr_temp1_input.dev_attr.attr ||
+		    attr == &sensor_dev_attr_temp1_emergency.dev_attr.attr ||
+		    attr == &sensor_dev_attr_temp1_label.dev_attr.attr)
+			return 0;
+
+		if (attr == &sensor_dev_attr_temp2_emergency.dev_attr.attr ||
+		    attr == &sensor_dev_attr_temp3_emergency.dev_attr.attr)
+			return attr->mode;
+	}
 
 	/* only SOC15 dGPUs support hotspot and mem temperatures */
-	if (((adev->flags & AMD_IS_APU) || gc_ver < IP_VERSION(9, 0, 0) ||
-	    (gc_ver == IP_VERSION(9, 4, 3))) &&
-	     (attr == &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr ||
+	if (((adev->flags & AMD_IS_APU) || gc_ver < IP_VERSION(9, 0, 0)) &&
+	    (attr == &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr ||
 	     attr == &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr ||
 	     attr == &sensor_dev_attr_temp1_emergency.dev_attr.attr ||
 	     attr == &sensor_dev_attr_temp2_emergency.dev_attr.attr ||
Signature · 1 line
2.25.1
maintainer Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amd/pm: Add GC v9.4.3 thermal limits to hwmon

[AMD Official Use Only - General]

Series is:

On a somewhat related note, we should fix the hysteresis values. They are currently set to the min and max temperatures which IIRC was not the intent of these values in hwmon.

Alex

________________________________
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, September 20, 2023 6:40 AM
To: [email protected] <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH 2/2] drm/amd/pm: Add GC v9.4.3 thermal limits to hwmon

Publish max operating temperature of SOC and memory as temp*_emergency nodes in hwmon. temp*_crit will show the throttle temperature limits.

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +12 -7
index 2807f3bd9ebe..5d84cdcd7c0e 100644
@@ -3353,15 +3353,20 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
                 return 0;
 
         /* hotspot temperature for gc 9,4,3*/
-       if ((gc_ver == IP_VERSION(9, 4, 3)) &&
-           (attr == &sensor_dev_attr_temp1_input.dev_attr.attr ||
-            attr == &sensor_dev_attr_temp1_label.dev_attr.attr))
-               return 0;
+       if (gc_ver == IP_VERSION(9, 4, 3)) {
+               if (attr == &sensor_dev_attr_temp1_input.dev_attr.attr ||
+                   attr == &sensor_dev_attr_temp1_emergency.dev_attr.attr ||
+                   attr == &sensor_dev_attr_temp1_label.dev_attr.attr)
+                       return 0;
+
+               if (attr == &sensor_dev_attr_temp2_emergency.dev_attr.attr ||
+                   attr == &sensor_dev_attr_temp3_emergency.dev_attr.attr)
+                       return attr->mode;
+       }
 
         /* only SOC15 dGPUs support hotspot and mem temperatures */
-       if (((adev->flags & AMD_IS_APU) || gc_ver < IP_VERSION(9, 0, 0) ||
-           (gc_ver == IP_VERSION(9, 4, 3))) &&
-            (attr == &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr ||
+       if (((adev->flags & AMD_IS_APU) || gc_ver < IP_VERSION(9, 0, 0)) &&
+           (attr == &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr ||
              attr == &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr ||
              attr == &sensor_dev_attr_temp1_emergency.dev_attr.attr ||
              attr == &sensor_dev_attr_temp2_emergency.dev_attr.attr ||

--
2.25.1

#3 lore raw
In reply to Lijo Lazar

[AMD Official Use Only - General]

Series is Reviewed-by: Asad Kamal <[email protected]>

Thanks & Regards
Asad

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Wednesday, September 20, 2023 4:10 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH 1/2] drm/amd/pm: Add throttle limit for SMU v13.0.6

CTF limit represents the max operating temperature and thermal limit gives the limit at which throttling starts. Add support for both limits. SOC and HBM may have different limit values.*_emergency_max gives max operating temperature and *_crit_max value represents throttle limit.

---
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 34 +++++++++++++++----
 1 file changed, 27 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +28 -7
index 11a6cd96c601..73db595bf6d9 100644
@@ -165,6 +165,7 @@ static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COU
        MSG_MAP(SetSoftMaxGfxClk,                    PPSMC_MSG_SetSoftMaxGfxClk,                0),
        MSG_MAP(PrepareMp1ForUnload,                 PPSMC_MSG_PrepareForDriverUnload,          0),
        MSG_MAP(GetCTFLimit,                         PPSMC_MSG_GetCTFLimit,                     0),
+       MSG_MAP(GetThermalLimit,                     PPSMC_MSG_ReadThrottlerLimit,              0),
        MSG_MAP(ClearMcaOnRead,                      PPSMC_MSG_ClearMcaOnRead,                  0),
        MSG_MAP(QueryValidMcaCount,                  PPSMC_MSG_QueryValidMcaCount,              0),
        MSG_MAP(QueryValidMcaCeCount,                PPSMC_MSG_QueryValidMcaCeCount,            0),
@@ -2110,7 +2111,7 @@ static int smu_v13_0_6_get_thermal_temperature_range(struct smu_context *smu,
                                                     struct smu_temperature_range *range)  {
        struct amdgpu_device *adev = smu->adev;
-       u32 aid_temp, xcd_temp, mem_temp;
+       u32 aid_temp, xcd_temp, max_temp;
        uint32_t smu_version;
        u32 ccd_temp = 0;
        int ret;
@@ -2126,31 +2127,50 @@ static int smu_v13_0_6_get_thermal_temperature_range(struct smu_context *smu,
        if (smu_version < 0x554500)
                return 0;
 
+       /* Get SOC Max operating temperature */
        ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetCTFLimit,
                                              PPSMC_AID_THM_TYPE, &aid_temp);
        if (ret)
                goto failed;
-
        if (adev->flags & AMD_IS_APU) {
                ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetCTFLimit,
                                                      PPSMC_CCD_THM_TYPE, &ccd_temp);
                if (ret)
                        goto failed;
        }
-
        ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetCTFLimit,
                                              PPSMC_XCD_THM_TYPE, &xcd_temp);
        if (ret)
                goto failed;
-
-       range->hotspot_crit_max = max3(aid_temp, xcd_temp, ccd_temp) *
+       range->hotspot_emergency_max = max3(aid_temp, xcd_temp, ccd_temp) *
                                       SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
+
+       /* Get HBM Max operating temperature */
        ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetCTFLimit,
-                                             PPSMC_HBM_THM_TYPE, &mem_temp);
+                                             PPSMC_HBM_THM_TYPE, &max_temp);
        if (ret)
                goto failed;
+       range->mem_emergency_max =
+               max_temp * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
+
+       /* Get SOC thermal throttle limit */
+       ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetThermalLimit,
+                                             PPSMC_THROTTLING_LIMIT_TYPE_SOCKET,
+                                             &max_temp);
+       if (ret)
+               goto failed;
+       range->hotspot_crit_max =
+               max_temp * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
+
+       /* Get HBM thermal throttle limit */
+       ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GetThermalLimit,
+                                             PPSMC_THROTTLING_LIMIT_TYPE_HBM,
+                                             &max_temp);
+       if (ret)
+               goto failed;
+
+       range->mem_crit_max = max_temp *
+SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
 
-       range->mem_crit_max = mem_temp * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
 failed:
        return ret;

}
--
2.25.1