Skip to content

Commit 3e6dd28

Browse files
Yang Wangalexdeucher
authored andcommitted
drm/amd/pm: disable OD_FAN_CURVE if temp or pwm range invalid for smu v13
Forcibly disable the OD_FAN_CURVE feature when temperature or PWM range is invalid, otherwise PMFW will reject this configuration on smu v13.0.x example: $ sudo cat /sys/bus/pci/devices/<BDF>/gpu_od/fan_ctrl/fan_curve OD_FAN_CURVE: 0: 0C 0% 1: 0C 0% 2: 0C 0% 3: 0C 0% 4: 0C 0% OD_RANGE: FAN_CURVE(hotspot temp): 0C 0C FAN_CURVE(fan speed): 0% 0% $ echo "0 50 40" | sudo tee fan_curve kernel log: [ 756.442527] amdgpu 0000:03:00.0: amdgpu: Fan curve temp setting(50) must be within [0, 0]! [ 777.345800] amdgpu 0000:03:00.0: amdgpu: Fan curve temp setting(50) must be within [0, 0]! Closes: ROCm/amdgpu#208 Signed-off-by: Yang Wang <kevinyang.wang@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 4708916) Cc: stable@vger.kernel.org
1 parent 2f0e491 commit 3e6dd28

2 files changed

Lines changed: 64 additions & 2 deletions

File tree

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959

6060
#define to_amdgpu_device(x) (container_of(x, struct amdgpu_device, pm.smu_i2c))
6161

62+
static void smu_v13_0_0_get_od_setting_limits(struct smu_context *smu,
63+
int od_feature_bit,
64+
int32_t *min, int32_t *max);
65+
6266
static const struct smu_feature_bits smu_v13_0_0_dpm_features = {
6367
.bits = {
6468
SMU_FEATURE_BIT_INIT(FEATURE_DPM_GFXCLK_BIT),
@@ -1043,8 +1047,35 @@ static bool smu_v13_0_0_is_od_feature_supported(struct smu_context *smu,
10431047
PPTable_t *pptable = smu->smu_table.driver_pptable;
10441048
const OverDriveLimits_t * const overdrive_upperlimits =
10451049
&pptable->SkuTable.OverDriveLimitsBasicMax;
1050+
int32_t min_value, max_value;
1051+
bool feature_enabled;
10461052

1047-
return overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit);
1053+
switch (od_feature_bit) {
1054+
case PP_OD_FEATURE_FAN_CURVE_BIT:
1055+
feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit));
1056+
if (feature_enabled) {
1057+
smu_v13_0_0_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_TEMP,
1058+
&min_value, &max_value);
1059+
if (!min_value && !max_value) {
1060+
feature_enabled = false;
1061+
goto out;
1062+
}
1063+
1064+
smu_v13_0_0_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_PWM,
1065+
&min_value, &max_value);
1066+
if (!min_value && !max_value) {
1067+
feature_enabled = false;
1068+
goto out;
1069+
}
1070+
}
1071+
break;
1072+
default:
1073+
feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit));
1074+
break;
1075+
}
1076+
1077+
out:
1078+
return feature_enabled;
10481079
}
10491080

10501081
static void smu_v13_0_0_get_od_setting_limits(struct smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959

6060
#define to_amdgpu_device(x) (container_of(x, struct amdgpu_device, pm.smu_i2c))
6161

62+
static void smu_v13_0_7_get_od_setting_limits(struct smu_context *smu,
63+
int od_feature_bit,
64+
int32_t *min, int32_t *max);
65+
6266
static const struct smu_feature_bits smu_v13_0_7_dpm_features = {
6367
.bits = {
6468
SMU_FEATURE_BIT_INIT(FEATURE_DPM_GFXCLK_BIT),
@@ -1053,8 +1057,35 @@ static bool smu_v13_0_7_is_od_feature_supported(struct smu_context *smu,
10531057
PPTable_t *pptable = smu->smu_table.driver_pptable;
10541058
const OverDriveLimits_t * const overdrive_upperlimits =
10551059
&pptable->SkuTable.OverDriveLimitsBasicMax;
1060+
int32_t min_value, max_value;
1061+
bool feature_enabled;
10561062

1057-
return overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit);
1063+
switch (od_feature_bit) {
1064+
case PP_OD_FEATURE_FAN_CURVE_BIT:
1065+
feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit));
1066+
if (feature_enabled) {
1067+
smu_v13_0_7_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_TEMP,
1068+
&min_value, &max_value);
1069+
if (!min_value && !max_value) {
1070+
feature_enabled = false;
1071+
goto out;
1072+
}
1073+
1074+
smu_v13_0_7_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_PWM,
1075+
&min_value, &max_value);
1076+
if (!min_value && !max_value) {
1077+
feature_enabled = false;
1078+
goto out;
1079+
}
1080+
}
1081+
break;
1082+
default:
1083+
feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit));
1084+
break;
1085+
}
1086+
1087+
out:
1088+
return feature_enabled;
10581089
}
10591090

10601091
static void smu_v13_0_7_get_od_setting_limits(struct smu_context *smu,

0 commit comments

Comments
 (0)