Commit 5f4f49a4 authored by Mario Limonciello's avatar Mario Limonciello Committed by Alex Deucher
Browse files

drm/amd: Stop overloading power limit with limit type



When passed around internally the upper 8 bits of power limit include
the limit type. This is non-obvious without digging into the nuances
of each function. Instead pass the limit type as an argument to all
applicable layers.

Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 16dc933a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -454,7 +454,7 @@ struct amd_pm_funcs {
				bool gate,
				int inst);
	int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id);
	int (*set_power_limit)(void *handle, uint32_t n);
	int (*set_power_limit)(void *handle, uint32_t limit_type, uint32_t n);
	int (*get_power_limit)(void *handle, uint32_t *limit,
			enum pp_power_limit_level pp_limit_level,
			enum pp_power_type power_type);
+2 −1
Original line number Diff line number Diff line
@@ -1616,6 +1616,7 @@ int amdgpu_dpm_get_power_limit(struct amdgpu_device *adev,
}

int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,
			       uint32_t limit_type,
			       uint32_t limit)
{
	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
@@ -1626,7 +1627,7 @@ int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,

	mutex_lock(&adev->pm.mutex);
	ret = pp_funcs->set_power_limit(adev->powerplay.pp_handle,
					limit);
					limit_type, limit);
	mutex_unlock(&adev->pm.mutex);

	return ret;
+1 −2
Original line number Diff line number Diff line
@@ -3390,13 +3390,12 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,
		return err;

	value = value / 1000000; /* convert to Watt */
	value |= limit_type << 24;

	err = amdgpu_pm_get_access(adev);
	if (err < 0)
		return err;

	err = amdgpu_dpm_set_power_limit(adev, value);
	err = amdgpu_dpm_set_power_limit(adev, limit_type, value);

	amdgpu_pm_put_access(adev);

+1 −1
Original line number Diff line number Diff line
@@ -553,7 +553,7 @@ int amdgpu_dpm_get_power_limit(struct amdgpu_device *adev,
			       enum pp_power_limit_level pp_limit_level,
			       enum pp_power_type power_type);
int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev,
			       uint32_t limit);
			       uint32_t limit_type, uint32_t limit);
int amdgpu_dpm_is_cclk_dpm_supported(struct amdgpu_device *adev);
int amdgpu_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev,
						       struct seq_file *m);
+1 −1
Original line number Diff line number Diff line
@@ -952,7 +952,7 @@ static int pp_dpm_switch_power_profile(void *handle,
	return 0;
}

static int pp_set_power_limit(void *handle, uint32_t limit)
static int pp_set_power_limit(void *handle, uint32_t limit_type, uint32_t limit)
{
	struct pp_hwmgr *hwmgr = handle;
	uint32_t max_power_limit;
Loading