Commit 548009ad authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher
Browse files

drm/amd/pm: add fan acoustic limit OD setting support for SMU13



Add SMU13 fan acoustic limit OD setting support.

Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent d7bf1b55
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -70,6 +70,12 @@ fan_curve
.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c
   :doc: fan_curve

acoustic_limit_rpm_threshold
----------------------------

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

GFXOFF
======

+2 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ enum pp_clock_type {
	OD_VDDGFX_OFFSET,
	OD_CCLK,
	OD_FAN_CURVE,
	OD_ACOUSTIC_LIMIT,
};

enum amd_pp_sensors {
@@ -189,6 +190,7 @@ enum PP_OD_DPM_TABLE_COMMAND {
	PP_OD_COMMIT_DPM_TABLE,
	PP_OD_EDIT_VDDGFX_OFFSET,
	PP_OD_EDIT_FAN_CURVE,
	PP_OD_EDIT_ACOUSTIC_LIMIT,
};

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

/**
 * DOC: acoustic_limit_rpm_threshold
 *
 * The amdgpu driver provides a sysfs API for checking and adjusting the
 * acoustic limit in RPM for fan control.
 *
 * 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.
 *
 * This setting works under auto fan control mode only. It adjusts the PMFW's
 * behavior about the maximum speed in RPM the fan can spin. Setting via this
 * interface will switch the fan control to auto mode implicitly.
 */
static ssize_t acoustic_limit_threshold_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_ACOUSTIC_LIMIT, buf);
}

static ssize_t acoustic_limit_threshold_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_ACOUSTIC_LIMIT,
							     buf,
							     count);
}

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

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

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

	return umode;
}

static struct od_feature_set amdgpu_od_set = {
	.containers = {
		[0] = {
@@ -3588,6 +3643,14 @@ static struct od_feature_set amdgpu_od_set = {
						.store = fan_curve_store,
					},
				},
				[1] = {
					.name = "acoustic_limit_rpm_threshold",
					.ops = {
						.is_visible = acoustic_limit_threshold_visible,
						.show = acoustic_limit_threshold_show,
						.store = acoustic_limit_threshold_store,
					},
				},
			},
		},
	},
+2 −0
Original line number Diff line number Diff line
@@ -316,6 +316,8 @@ struct config_table_setting

#define OD_OPS_SUPPORT_FAN_CURVE_RETRIEVE		BIT(0)
#define OD_OPS_SUPPORT_FAN_CURVE_SET			BIT(1)
#define OD_OPS_SUPPORT_ACOUSTIC_LIMIT_THRESHOLD_RETRIEVE	BIT(2)
#define OD_OPS_SUPPORT_ACOUSTIC_LIMIT_THRESHOLD_SET		BIT(3)

struct amdgpu_pm {
	struct mutex		mutex;
+2 −0
Original line number Diff line number Diff line
@@ -2483,6 +2483,8 @@ static enum smu_clk_type smu_convert_to_smuclk(enum pp_clock_type type)
		clk_type = SMU_OD_CCLK; break;
	case OD_FAN_CURVE:
		clk_type = SMU_OD_FAN_CURVE; break;
	case OD_ACOUSTIC_LIMIT:
		clk_type = SMU_OD_ACOUSTIC_LIMIT; break;
	default:
		clk_type = SMU_CLK_COUNT; break;
	}
Loading