Commit 6bfe777e authored by Wolfgang Müller's avatar Wolfgang Müller Committed by Alex Deucher
Browse files

drm/amd/pm: add zero RPM stop temperature OD setting support for SMU13



Together with the feature to enable or disable zero RPM in the last
commit, it also makes sense to expose the OD setting determining under
which temperature the fan should stop if zero RPM is enabled.

Reviewed-by: default avatarKenneth Feng <kenneth.feng@amd.com>
Signed-off-by: default avatarWolfgang Müller <wolf@oriole.systems>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e89bd361
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -106,6 +106,12 @@ fan_zero_rpm_enable
.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c
   :doc: fan_zero_rpm_enable

fan_zero_rpm_stop_temperature
-----------------------------

.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c
   :doc: fan_zero_rpm_stop_temperature

GFXOFF
======

+2 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ enum pp_clock_type {
	OD_FAN_TARGET_TEMPERATURE,
	OD_FAN_MINIMUM_PWM,
	OD_FAN_ZERO_RPM_ENABLE,
	OD_FAN_ZERO_RPM_STOP_TEMP,
};

enum amd_pp_sensors {
@@ -201,6 +202,7 @@ enum PP_OD_DPM_TABLE_COMMAND {
	PP_OD_EDIT_FAN_TARGET_TEMPERATURE,
	PP_OD_EDIT_FAN_MINIMUM_PWM,
	PP_OD_EDIT_FAN_ZERO_RPM_ENABLE,
	PP_OD_EDIT_FAN_ZERO_RPM_STOP_TEMP,
};

struct pp_states_info {
+65 −0
Original line number Diff line number Diff line
@@ -4163,6 +4163,63 @@ static umode_t fan_zero_rpm_enable_visible(struct amdgpu_device *adev)
	return umode;
}

/**
 * DOC: fan_zero_rpm_stop_temperature
 *
 * The amdgpu driver provides a sysfs API for checking and adjusting the
 * zero RPM stop temperature feature.
 *
 * Reading back the file shows you the current setting and the permitted
 * ranges if changable.
 *
 * Writing an integer to the file, change the setting accordingly.
 *
 * When you have finished the editing, write "c" (commit) to the file to commit
 * your changes.
 *
 * If you want to reset to the default value, write "r" (reset) to the file to
 * reset them.
 *
 * This setting works only if the Zero RPM setting is enabled. It adjusts the
 * temperature below which the fan can stop.
 */
static ssize_t fan_zero_rpm_stop_temp_show(struct kobject *kobj,
					   struct kobj_attribute *attr,
					   char *buf)
{
	struct od_kobj *container = container_of(kobj, struct od_kobj, kobj);
	struct amdgpu_device *adev = (struct amdgpu_device *)container->priv;

	return (ssize_t)amdgpu_retrieve_od_settings(adev, OD_FAN_ZERO_RPM_STOP_TEMP, buf);
}

static ssize_t fan_zero_rpm_stop_temp_store(struct kobject *kobj,
					    struct kobj_attribute *attr,
					    const char *buf,
					    size_t count)
{
	struct od_kobj *container = container_of(kobj, struct od_kobj, kobj);
	struct amdgpu_device *adev = (struct amdgpu_device *)container->priv;

	return (ssize_t)amdgpu_distribute_custom_od_settings(adev,
							     PP_OD_EDIT_FAN_ZERO_RPM_STOP_TEMP,
							     buf,
							     count);
}

static umode_t fan_zero_rpm_stop_temp_visible(struct amdgpu_device *adev)
{
	umode_t umode = 0000;

	if (adev->pm.od_feature_mask & OD_OPS_SUPPORT_FAN_ZERO_RPM_STOP_TEMP_RETRIEVE)
		umode |= S_IRUSR | S_IRGRP | S_IROTH;

	if (adev->pm.od_feature_mask & OD_OPS_SUPPORT_FAN_ZERO_RPM_STOP_TEMP_SET)
		umode |= S_IWUSR;

	return umode;
}

static struct od_feature_set amdgpu_od_set = {
	.containers = {
		[0] = {
@@ -4216,6 +4273,14 @@ static struct od_feature_set amdgpu_od_set = {
						.store = fan_zero_rpm_enable_store,
					},
				},
				[6] = {
					.name = "fan_zero_rpm_stop_temperature",
					.ops = {
						.is_visible = fan_zero_rpm_stop_temp_visible,
						.show = fan_zero_rpm_stop_temp_show,
						.store = fan_zero_rpm_stop_temp_store,
					},
				},
			},
		},
	},
+2 −0
Original line number Diff line number Diff line
@@ -330,6 +330,8 @@ struct config_table_setting
#define OD_OPS_SUPPORT_FAN_MINIMUM_PWM_SET		BIT(9)
#define OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_RETRIEVE	BIT(10)
#define OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_SET		BIT(11)
#define OD_OPS_SUPPORT_FAN_ZERO_RPM_STOP_TEMP_RETRIEVE	BIT(12)
#define OD_OPS_SUPPORT_FAN_ZERO_RPM_STOP_TEMP_SET	BIT(13)

struct amdgpu_pm {
	struct mutex		mutex;
+2 −0
Original line number Diff line number Diff line
@@ -2897,6 +2897,8 @@ static enum smu_clk_type smu_convert_to_smuclk(enum pp_clock_type type)
		clk_type = SMU_OD_FAN_MINIMUM_PWM; break;
	case OD_FAN_ZERO_RPM_ENABLE:
		clk_type = SMU_OD_FAN_ZERO_RPM_ENABLE; break;
	case OD_FAN_ZERO_RPM_STOP_TEMP:
		clk_type = SMU_OD_FAN_ZERO_RPM_STOP_TEMP; break;
	default:
		clk_type = SMU_CLK_COUNT; break;
	}
Loading