From: "Lazar, Lijo" <lijo.lazar@amd.com>
To: Evan Quan <evan.quan@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Alexander.Deucher@amd.com
Subject: Re: [PATCH 2/7] drm/amd/pm: record the RPM and PWM based fan speed settings
Date: Wed, 7 Jul 2021 14:23:23 +0530 [thread overview]
Message-ID: <c7951185-d2f3-df94-e977-a0a632894ddf@amd.com> (raw)
In-Reply-To: <20210707015647.139127-2-evan.quan@amd.com>
On 7/7/2021 7:26 AM, Evan Quan wrote:
> As the relationship "PWM = RPM / smu->fan_max_rpm" between fan speed
> PWM and RPM is not true for SMU11 ASICs. So, both the RPM and PWM
> settings need to be saved.
>
> Change-Id: I318c134d442273d518b805339cdf383e151b935d
> Signed-off-by: Evan Quan <evan.quan@amd.com>
> ---
> drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 8 ++++++++
> drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 20 +++++++++++++++-----
> 2 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> index 6301e4cb3c2a..fa585f0be530 100644
> --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> @@ -226,10 +226,18 @@ enum smu_memory_pool_size
> SMU_MEMORY_POOL_SIZE_2_GB = 0x80000000,
> };
>
> +enum custom_fan_speed_mode
> +{
> + SMU_CUSTOM_FAN_SPEED_RPM = 1 << 0,
> + SMU_CUSTOM_FAN_SPEED_PWM = 1 << 1,
> +};
> +
> struct smu_user_dpm_profile {
> uint32_t fan_mode;
> uint32_t power_limit;
> + uint32_t custom_fan_speed;
Use the flags field to indicate if custom mode uses PWM or RPM, no need
to have a separate field.
Thanks,
Lijo
> uint32_t fan_speed_percent;
> + uint32_t fan_speed_rpm;
> uint32_t flags;
>
> /* user clock state information */
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index 576e9ea68fd1..9a25443988e3 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> @@ -414,6 +414,12 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu)
> if (ret)
> dev_err(smu->adev->dev, "Failed to set manual fan speed\n");
> }
> +
> + if (!ret && smu->user_dpm_profile.fan_speed_rpm) {
> + ret = smu_set_fan_speed_rpm(smu, smu->user_dpm_profile.fan_speed_rpm);
> + if (ret)
> + dev_err(smu->adev->dev, "Failed to set manual fan speed\n");
> + }
> }
>
> /* Disable restore flag */
> @@ -2166,7 +2172,6 @@ static int smu_set_gfx_cgpg(struct smu_context *smu, bool enabled)
> static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
> {
> struct smu_context *smu = handle;
> - u32 percent;
> int ret = 0;
>
> if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
> @@ -2177,8 +2182,8 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)
> if (smu->ppt_funcs->set_fan_speed_rpm) {
> ret = smu->ppt_funcs->set_fan_speed_rpm(smu, speed);
> if (!ret && smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE) {
> - percent = speed * 100 / smu->fan_max_rpm;
> - smu->user_dpm_profile.fan_speed_percent = percent;
> + smu->user_dpm_profile.custom_fan_speed |= SMU_CUSTOM_FAN_SPEED_RPM;
> + smu->user_dpm_profile.fan_speed_rpm = speed;
> }
> }
>
> @@ -2539,8 +2544,11 @@ static int smu_set_fan_control_mode(struct smu_context *smu, int value)
>
> /* reset user dpm fan speed */
> if (!ret && value != AMD_FAN_CTRL_MANUAL &&
> - !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE))
> + !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) {
> smu->user_dpm_profile.fan_speed_percent = 0;
> + smu->user_dpm_profile.fan_speed_rpm = 0;
> + smu->user_dpm_profile.custom_fan_speed = 0;
> + }
>
> return ret;
> }
> @@ -2591,8 +2599,10 @@ static int smu_set_fan_speed_percent(void *handle, u32 speed)
> if (speed > 100)
> speed = 100;
> ret = smu->ppt_funcs->set_fan_speed_percent(smu, speed);
> - if (!ret && !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE))
> + if (!ret && !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) {
> + smu->user_dpm_profile.custom_fan_speed |= SMU_CUSTOM_FAN_SPEED_PWM;
> smu->user_dpm_profile.fan_speed_percent = speed;
> + }
> }
>
> mutex_unlock(&smu->mutex);
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2021-07-07 8:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-07 1:56 [PATCH 1/7] drm/amd/pm: correct the fan speed RPM setting Evan Quan
2021-07-07 1:56 ` [PATCH 2/7] drm/amd/pm: record the RPM and PWM based fan speed settings Evan Quan
2021-07-07 4:53 ` Chen, Guchun
2021-07-07 8:53 ` Lazar, Lijo [this message]
2021-07-07 1:56 ` [PATCH 3/7] drm/amd/pm: correct the fan speed PWM retrieving Evan Quan
2021-07-07 9:03 ` Lazar, Lijo
2021-07-07 1:56 ` [PATCH 4/7] drm/amd/pm: correct the fan speed RPM retrieving Evan Quan
2021-07-07 4:58 ` Chen, Guchun
2021-07-07 9:05 ` Lazar, Lijo
2021-07-07 1:56 ` [PATCH 5/7] drm/amd/pm: drop the unnecessary intermediate percent-based transition Evan Quan
2021-07-07 5:00 ` Chen, Guchun
2021-07-07 6:26 ` Nils Wallménius
2021-07-07 9:07 ` Lazar, Lijo
2021-07-07 1:56 ` [PATCH 6/7] drm/amd/pm: drop unnecessary manual mode check Evan Quan
2021-07-07 1:56 ` [PATCH 7/7] drm/amd/pm: correct the address of Arcturus fan related registers Evan Quan
2021-07-07 9:10 ` Lazar, Lijo
2021-07-07 4:47 ` [PATCH 1/7] drm/amd/pm: correct the fan speed RPM setting Chen, Guchun
2021-08-11 7:58 ` Quan, Evan
2021-07-07 8:49 ` Lazar, Lijo
2021-08-11 7:57 ` Quan, Evan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c7951185-d2f3-df94-e977-a0a632894ddf@amd.com \
--to=lijo.lazar@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=evan.quan@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox