[PATCH] drm/amd/pm: Fixes incorrect type in 'amdgpu_hwmon_show_power_avg() & _input()'

Kamal, Asad Asad.Kamal at amd.com
Mon Aug 21 07:19:31 UTC 2023


[AMD Official Use Only - General]

With the following patch in place
https://patchwork.freedesktop.org/patch/553433/?series=122640&rev=1

Reviewed-by: Asad Kamal <asad.kamal at amd.com>

Thanks & Regards
Asad

-----Original Message-----
From: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM at amd.com>
Sent: Monday, August 21, 2023 12:06 PM
To: Kamal, Asad <Asad.Kamal at amd.com>; SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM at amd.com>; Koenig, Christian <Christian.Koenig at amd.com>; Deucher, Alexander <Alexander.Deucher at amd.com>; Chen, Guchun <Guchun.Chen at amd.com>
Cc: Pan, Xinhui <Xinhui.Pan at amd.com>; amd-gfx at lists.freedesktop.org
Subject: Re: [PATCH] drm/amd/pm: Fixes incorrect type in 'amdgpu_hwmon_show_power_avg() & _input()'


On 8/21/2023 11:59 AM, Kamal, Asad wrote:
> [AMD Official Use Only - General]
>
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of
> Srinivasan Shanmugam
> Sent: Monday, August 21, 2023 11:36 AM
> To: Koenig, Christian <Christian.Koenig at amd.com>; Deucher, Alexander
> <Alexander.Deucher at amd.com>; Chen, Guchun <Guchun.Chen at amd.com>
> Cc: Pan, Xinhui <Xinhui.Pan at amd.com>; SHANMUGAM, SRINIVASAN
> <SRINIVASAN.SHANMUGAM at amd.com>; amd-gfx at lists.freedesktop.org
> Subject: [PATCH] drm/amd/pm: Fixes incorrect type in 'amdgpu_hwmon_show_power_avg() & _input()'
>
> The val is defined as unsigned int type, if(val<0) is invalid, hence
> modified its type to ssize_t
>
> Fixes the below:
>
> drivers/gpu/drm/amd/pm/amdgpu_pm.c:2800:5-8: WARNING: Unsigned
> expression compared with zero: val < 0
> drivers/gpu/drm/amd/pm/amdgpu_pm.c:2813:5-8: WARNING: Unsigned
> expression compared with zero: val < 0
>
> Cc: Guchun Chen <guchun.chen at amd.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Cc: "Pan, Xinhui" <Xinhui.Pan at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
>   drivers/gpu/drm/amd/pm/amdgpu_pm.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> index f03647fa3df6..cdc28e4da0c9 100644
> --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> @@ -2794,26 +2794,26 @@ static ssize_t amdgpu_hwmon_show_power_avg(struct device *dev,
>                                             struct device_attribute *attr,
>                                             char *buf)
>   {
> -       unsigned int val;
> +       ssize_t val;
>
>          val = amdgpu_hwmon_get_power(dev,
> AMDGPU_PP_SENSOR_GPU_AVG_POWER);
>
> [Kamal, Asad] amdgpu_hwmon_get_power -> This is returning unsigned int value, Shall we not change return type for amdgpu_hwmon_get_power?
Thanks!, looks like there is already a fix posted here
https://patchwork.freedesktop.org/patch/553433/?series=122640&rev=1 for 'amdgpu_hwmon_get_power'
> if (val < 0)
>                  return val;
>
> -       return sysfs_emit(buf, "%u\n", val);
> +       return sysfs_emit(buf, "%zd\n", val);
>   }
>
>   static ssize_t amdgpu_hwmon_show_power_input(struct device *dev,
>                                               struct device_attribute *attr,
>                                               char *buf)
>   {
> -       unsigned int val;
> +       ssize_t val;
>
>          val = amdgpu_hwmon_get_power(dev, AMDGPU_PP_SENSOR_GPU_INPUT_POWER);
>          if (val < 0)
>                  return val;
>
> -       return sysfs_emit(buf, "%u\n", val);
> +       return sysfs_emit(buf, "%zd\n", val);
>   }
>
>   static ssize_t amdgpu_hwmon_show_power_cap_min(struct device *dev,
> --
> 2.25.1
>


More information about the amd-gfx mailing list