* [PATCH] drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics
@ 2022-12-16 10:35 Evan Quan
2022-12-16 11:49 ` Christian König
0 siblings, 1 reply; 4+ messages in thread
From: Evan Quan @ 2022-12-16 10:35 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Evan Quan
For SMU 13.0.0 and 13.0.7, the output from PMFW is in percent. Driver
need to convert that into correct PMW(255) based.
Signed-off-by: Evan Quan <evan.quan@amd.com>
Change-Id: I7bbeae3c0d81c6cf6e0033aa28ca6d26f5b6d178
---
.../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 15 ++++++++++++---
.../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 15 ++++++++++++---
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
index 636cb561fea9..283cf7cf95ab 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
@@ -1445,12 +1445,21 @@ static void smu_v13_0_0_get_unique_id(struct smu_context *smu)
static int smu_v13_0_0_get_fan_speed_pwm(struct smu_context *smu,
uint32_t *speed)
{
+ int ret = 0;
+
if (!speed)
return -EINVAL;
- return smu_v13_0_0_get_smu_metrics_data(smu,
- METRICS_CURR_FANPWM,
- speed);
+ ret = smu_v13_0_0_get_smu_metrics_data(smu,
+ METRICS_CURR_FANPWM,
+ speed);
+ if (ret)
+ return ret;
+
+ /* Convert the PMFW output which is in percent to pwm(255) based */
+ *speed = MIN(*speed * 255 / 100, 255);
+
+ return 0;
}
static int smu_v13_0_0_get_fan_speed_rpm(struct smu_context *smu,
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
index 5e937e4efb51..f207f102ed7e 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
@@ -1365,12 +1365,21 @@ static int smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)
static int smu_v13_0_7_get_fan_speed_pwm(struct smu_context *smu,
uint32_t *speed)
{
+ int ret = 0;
+
if (!speed)
return -EINVAL;
- return smu_v13_0_7_get_smu_metrics_data(smu,
- METRICS_CURR_FANPWM,
- speed);
+ ret = smu_v13_0_7_get_smu_metrics_data(smu,
+ METRICS_CURR_FANPWM,
+ speed);
+ if (ret)
+ return ret;
+
+ /* Convert the PMFW output which is in percent to pwm(255) based */
+ *speed = MIN(*speed * 255 / 100, 255);
+
+ return 0;
}
static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics
2022-12-16 10:35 [PATCH] drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics Evan Quan
@ 2022-12-16 11:49 ` Christian König
2022-12-16 14:58 ` Alex Deucher
2022-12-19 2:10 ` Quan, Evan
0 siblings, 2 replies; 4+ messages in thread
From: Christian König @ 2022-12-16 11:49 UTC (permalink / raw)
To: Evan Quan, amd-gfx; +Cc: Alexander.Deucher
Am 16.12.22 um 11:35 schrieb Evan Quan:
> For SMU 13.0.0 and 13.0.7, the output from PMFW is in percent. Driver
> need to convert that into correct PMW(255) based.
>
> Signed-off-by: Evan Quan <evan.quan@amd.com>
> Change-Id: I7bbeae3c0d81c6cf6e0033aa28ca6d26f5b6d178
> ---
> .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 15 ++++++++++++---
> .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 15 ++++++++++++---
> 2 files changed, 24 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
> index 636cb561fea9..283cf7cf95ab 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
> @@ -1445,12 +1445,21 @@ static void smu_v13_0_0_get_unique_id(struct smu_context *smu)
> static int smu_v13_0_0_get_fan_speed_pwm(struct smu_context *smu,
> uint32_t *speed)
> {
> + int ret = 0;
Please don't initialize local variables when there isn't a need for this.
We often get complains about this from automated scripts.
Regards,
Christian.
> +
> if (!speed)
> return -EINVAL;
>
> - return smu_v13_0_0_get_smu_metrics_data(smu,
> - METRICS_CURR_FANPWM,
> - speed);
> + ret = smu_v13_0_0_get_smu_metrics_data(smu,
> + METRICS_CURR_FANPWM,
> + speed);
> + if (ret)
> + return ret;
> +
> + /* Convert the PMFW output which is in percent to pwm(255) based */
> + *speed = MIN(*speed * 255 / 100, 255);
> +
> + return 0;
> }
>
> static int smu_v13_0_0_get_fan_speed_rpm(struct smu_context *smu,
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
> index 5e937e4efb51..f207f102ed7e 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
> @@ -1365,12 +1365,21 @@ static int smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)
> static int smu_v13_0_7_get_fan_speed_pwm(struct smu_context *smu,
> uint32_t *speed)
> {
> + int ret = 0;
> +
> if (!speed)
> return -EINVAL;
>
> - return smu_v13_0_7_get_smu_metrics_data(smu,
> - METRICS_CURR_FANPWM,
> - speed);
> + ret = smu_v13_0_7_get_smu_metrics_data(smu,
> + METRICS_CURR_FANPWM,
> + speed);
> + if (ret)
> + return ret;
> +
> + /* Convert the PMFW output which is in percent to pwm(255) based */
> + *speed = MIN(*speed * 255 / 100, 255);
> +
> + return 0;
> }
>
> static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics
2022-12-16 11:49 ` Christian König
@ 2022-12-16 14:58 ` Alex Deucher
2022-12-19 2:10 ` Quan, Evan
1 sibling, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2022-12-16 14:58 UTC (permalink / raw)
To: Christian König; +Cc: Alexander.Deucher, Evan Quan, amd-gfx
With Christian's comment addressed, the patch is:
Acked-by: Alex Deucher <alexander.deucher@amd.com>
On Fri, Dec 16, 2022 at 6:50 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> Am 16.12.22 um 11:35 schrieb Evan Quan:
> > For SMU 13.0.0 and 13.0.7, the output from PMFW is in percent. Driver
> > need to convert that into correct PMW(255) based.
> >
> > Signed-off-by: Evan Quan <evan.quan@amd.com>
> > Change-Id: I7bbeae3c0d81c6cf6e0033aa28ca6d26f5b6d178
> > ---
> > .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 15 ++++++++++++---
> > .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 15 ++++++++++++---
> > 2 files changed, 24 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
> > index 636cb561fea9..283cf7cf95ab 100644
> > --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
> > +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
> > @@ -1445,12 +1445,21 @@ static void smu_v13_0_0_get_unique_id(struct smu_context *smu)
> > static int smu_v13_0_0_get_fan_speed_pwm(struct smu_context *smu,
> > uint32_t *speed)
> > {
> > + int ret = 0;
>
> Please don't initialize local variables when there isn't a need for this.
>
> We often get complains about this from automated scripts.
>
> Regards,
> Christian.
>
> > +
> > if (!speed)
> > return -EINVAL;
> >
> > - return smu_v13_0_0_get_smu_metrics_data(smu,
> > - METRICS_CURR_FANPWM,
> > - speed);
> > + ret = smu_v13_0_0_get_smu_metrics_data(smu,
> > + METRICS_CURR_FANPWM,
> > + speed);
> > + if (ret)
> > + return ret;
> > +
> > + /* Convert the PMFW output which is in percent to pwm(255) based */
> > + *speed = MIN(*speed * 255 / 100, 255);
> > +
> > + return 0;
> > }
> >
> > static int smu_v13_0_0_get_fan_speed_rpm(struct smu_context *smu,
> > diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
> > index 5e937e4efb51..f207f102ed7e 100644
> > --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
> > +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
> > @@ -1365,12 +1365,21 @@ static int smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)
> > static int smu_v13_0_7_get_fan_speed_pwm(struct smu_context *smu,
> > uint32_t *speed)
> > {
> > + int ret = 0;
> > +
> > if (!speed)
> > return -EINVAL;
> >
> > - return smu_v13_0_7_get_smu_metrics_data(smu,
> > - METRICS_CURR_FANPWM,
> > - speed);
> > + ret = smu_v13_0_7_get_smu_metrics_data(smu,
> > + METRICS_CURR_FANPWM,
> > + speed);
> > + if (ret)
> > + return ret;
> > +
> > + /* Convert the PMFW output which is in percent to pwm(255) based */
> > + *speed = MIN(*speed * 255 / 100, 255);
> > +
> > + return 0;
> > }
> >
> > static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics
2022-12-16 11:49 ` Christian König
2022-12-16 14:58 ` Alex Deucher
@ 2022-12-19 2:10 ` Quan, Evan
1 sibling, 0 replies; 4+ messages in thread
From: Quan, Evan @ 2022-12-19 2:10 UTC (permalink / raw)
To: Christian König, amd-gfx; +Cc: Deucher, Alexander
[AMD Official Use Only - General]
Thanks Christian,
Yes, it is not such needed.
I checked this with checkpatch.pl script and no complains popped out about this. That is weird...
Anyway, I will fix this up.
BR
Evan
> -----Original Message-----
> From: Christian König <ckoenig.leichtzumerken@gmail.com>
> Sent: Friday, December 16, 2022 7:50 PM
> To: Quan, Evan <Evan.Quan@amd.com>; amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>
> Subject: Re: [PATCH] drm/amd/pm: correct the fan speed retrieving in PWM
> for some SMU13 asics
>
> Am 16.12.22 um 11:35 schrieb Evan Quan:
> > For SMU 13.0.0 and 13.0.7, the output from PMFW is in percent. Driver
> > need to convert that into correct PMW(255) based.
> >
> > Signed-off-by: Evan Quan <evan.quan@amd.com>
> > Change-Id: I7bbeae3c0d81c6cf6e0033aa28ca6d26f5b6d178
> > ---
> > .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 15
> ++++++++++++---
> > .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 15
> ++++++++++++---
> > 2 files changed, 24 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
> > b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
> > index 636cb561fea9..283cf7cf95ab 100644
> > --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
> > +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
> > @@ -1445,12 +1445,21 @@ static void smu_v13_0_0_get_unique_id(struct
> smu_context *smu)
> > static int smu_v13_0_0_get_fan_speed_pwm(struct smu_context *smu,
> > uint32_t *speed)
> > {
> > + int ret = 0;
>
> Please don't initialize local variables when there isn't a need for this.
>
> We often get complains about this from automated scripts.
>
> Regards,
> Christian.
>
> > +
> > if (!speed)
> > return -EINVAL;
> >
> > - return smu_v13_0_0_get_smu_metrics_data(smu,
> > - METRICS_CURR_FANPWM,
> > - speed);
> > + ret = smu_v13_0_0_get_smu_metrics_data(smu,
> > + METRICS_CURR_FANPWM,
> > + speed);
> > + if (ret)
> > + return ret;
> > +
> > + /* Convert the PMFW output which is in percent to pwm(255) based
> */
> > + *speed = MIN(*speed * 255 / 100, 255);
> > +
> > + return 0;
> > }
> >
> > static int smu_v13_0_0_get_fan_speed_rpm(struct smu_context *smu,
> > diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
> > b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
> > index 5e937e4efb51..f207f102ed7e 100644
> > --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
> > +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
> > @@ -1365,12 +1365,21 @@ static int
> smu_v13_0_7_populate_umd_state_clk(struct smu_context *smu)
> > static int smu_v13_0_7_get_fan_speed_pwm(struct smu_context *smu,
> > uint32_t *speed)
> > {
> > + int ret = 0;
> > +
> > if (!speed)
> > return -EINVAL;
> >
> > - return smu_v13_0_7_get_smu_metrics_data(smu,
> > - METRICS_CURR_FANPWM,
> > - speed);
> > + ret = smu_v13_0_7_get_smu_metrics_data(smu,
> > + METRICS_CURR_FANPWM,
> > + speed);
> > + if (ret)
> > + return ret;
> > +
> > + /* Convert the PMFW output which is in percent to pwm(255) based
> */
> > + *speed = MIN(*speed * 255 / 100, 255);
> > +
> > + return 0;
> > }
> >
> > static int smu_v13_0_7_get_fan_speed_rpm(struct smu_context *smu,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-19 2:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-16 10:35 [PATCH] drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics Evan Quan
2022-12-16 11:49 ` Christian König
2022-12-16 14:58 ` Alex Deucher
2022-12-19 2:10 ` Quan, Evan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.