drm/amd/pm: restrict sensor load values to 0-100
Subsystems (3)
PATCH 1/1 drm/amd/pm: restrict sensor load values to 0-100
Limit GPU/MEM/VCN load sensor values to 0-100 range via clamp_t to ensure validity.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +23 -4
@@ -1414,20 +1414,39 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,static int amdgpu_pm_get_sensor_generic (struct amdgpu_device *adev,enum amd_pp_sensors sensor, -void *query) +uint32_t *val) { -int r, size =sizeof (uint32_t ); +uint32_t tmp =UINT_MAX , size =sizeof (tmp); +int r; + +if (!val) +return -EINVAL ; r =amdgpu_pm_get_access_if_active (adev);if (r)return r;/* get the sensor value */ - r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); + r =amdgpu_dpm_read_sensor (adev, sensor, (void *)&tmp, &size);amdgpu_pm_put_access (adev); -return r; +if (r) +return r; + +switch (sensor) { +case AMDGPU_PP_SENSOR_GPU_LOAD : +case AMDGPU_PP_SENSOR_MEM_LOAD : +case AMDGPU_PP_SENSOR_VCN_LOAD : + tmp =clamp_t (uint32_t, tmp,0 ,100 ); +break ; +default : +break ; + } + + *val = tmp; + +return 0 ; }/**
Signature · 1 line
2.47.3
Quoted 3 lines · Yang Wang
Limit GPU/MEM/VCN load sensor values to 0-100 range via
clamp_tto ensure validity.
Is this a workaround? If it's not within range, it indicates some underlying issue.
Thanks,
Lijo
Quoted 53 lines
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +23
-4@@ -1414,20 +1414,39 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,static int amdgpu_pm_get_sensor_generic (struct amdgpu_device *adev,enum amd_pp_sensors sensor, -void *query) +uint32_t *val) { -int r, size =sizeof (uint32_t ); +uint32_t tmp =UINT_MAX , size =sizeof (tmp); +int r; + +if (!val) +return -EINVAL ; r =amdgpu_pm_get_access_if_active (adev);if (r)return r;/* get the sensor value */ - r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); + r =amdgpu_dpm_read_sensor (adev, sensor, (void *)&tmp, &size);amdgpu_pm_put_access (adev); -return r; +if (r) +return r; + +switch (sensor) { +case AMDGPU_PP_SENSOR_GPU_LOAD : +case AMDGPU_PP_SENSOR_MEM_LOAD : +case AMDGPU_PP_SENSOR_VCN_LOAD : + tmp =clamp_t (uint32_t, tmp,0 ,100 ); +break ; +default : +break ; + } + + *val = tmp; + +return 0 ; }/**
Quoted 10 lines · Lijo
Quoted 3 lines · Yang Wang
Limit GPU/MEM/VCN load sensor values to 0-100 range via
clamp_tto ensure validity.Is this a workaround? If it's not within range, it indicates some underlying issue.
Likely for:
https://gitlab.freedesktop.org/drm/amd/-/issues/4905
Alex
Quoted 58 lines
Thanks,
LijoQuoted 53 lines
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +23
-4@@ -1414,20 +1414,39 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,static int amdgpu_pm_get_sensor_generic (struct amdgpu_device *adev,enum amd_pp_sensors sensor, -void *query) +uint32_t *val) { -int r, size =sizeof (uint32_t ); +uint32_t tmp =UINT_MAX , size =sizeof (tmp); +int r; + +if (!val) +return -EINVAL ; r =amdgpu_pm_get_access_if_active (adev);if (r)return r;/* get the sensor value */ - r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); + r =amdgpu_dpm_read_sensor (adev, sensor, (void *)&tmp, &size);amdgpu_pm_put_access (adev); -return r; +if (r) +return r; + +switch (sensor) { +case AMDGPU_PP_SENSOR_GPU_LOAD : +case AMDGPU_PP_SENSOR_MEM_LOAD : +case AMDGPU_PP_SENSOR_VCN_LOAD : + tmp =clamp_t (uint32_t, tmp,0 ,100 ); +break ; +default : +break ; + } + + *val = tmp; + +return 0 ; }/**
[AMD Official Use Only - AMD Internal Distribution Only]
Ping...
Best Regards,
Kevin
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, February 25, 2026 10:24 PM
To: Lazar, Lijo <[email protected]>
Cc: Wang, Yang(Kevin) <[email protected]>; [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100
Quoted 10 lines · Lijo
Quoted 3 lines · Yang Wang
Limit GPU/MEM/VCN load sensor values to 0-100 range via
clamp_tto ensure validity.Is this a workaround? If it's not within range, it indicates some underlying issue.
Likely for:
https://gitlab.freedesktop.org/drm/amd/-/issues/4905
Alex
Quoted 60 lines
Thanks,
LijoQuoted 55 lines
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +23
-4@@ -1414,20 +1414,39 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, static int amdgpu_pm_get_sensor_generic(struct amdgpu_device *adev, enum amd_pp_sensors sensor, - void *query) + uint32_t *val) { - int r, size = sizeof(uint32_t); + uint32_t tmp = UINT_MAX, size = sizeof(tmp); +int r; + +if (!val) +return -EINVAL ; r =amdgpu_pm_get_access_if_active (adev);if (r)return r;/* get the sensor value */ - r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); + r =amdgpu_dpm_read_sensor (adev, sensor, (void *)&tmp, &size);amdgpu_pm_put_access (adev); -return r; +if (r) +return r; + +switch (sensor) { +case AMDGPU_PP_SENSOR_GPU_LOAD : +case AMDGPU_PP_SENSOR_MEM_LOAD : +case AMDGPU_PP_SENSOR_VCN_LOAD : + tmp =clamp_t (uint32_t, tmp,0 ,100 ); +break ; +default : +break ; + } + + *val = tmp; + +return 0 ; }/**
Quoted 4 lines · Yang(Kevin)
[AMD Official Use Only - AMD Internal Distribution Only]
Ping...
Please restrict this workaround to the affected SOC. Otherwise, if there are bogus values, we will fix it at the right place.
Thanks,
Lijo
Quoted 87 lines
Best Regards,
Kevin-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, February 25, 2026 10:24 PM
To: Lazar, Lijo <[email protected]>
Cc: Wang, Yang(Kevin) <[email protected]>; [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100Quoted 10 lines · Lijo
Quoted 3 lines · Yang Wang
Limit GPU/MEM/VCN load sensor values to 0-100 range via
clamp_tto ensure validity.Is this a workaround? If it's not within range, it indicates some underlying issue.
Likely for:
https://gitlab.freedesktop.org/drm/amd/-/issues/4905Alex
Quoted 60 lines
Thanks,
LijoQuoted 55 lines
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +23
-4@@ -1414,20 +1414,39 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, static int amdgpu_pm_get_sensor_generic(struct amdgpu_device *adev, enum amd_pp_sensors sensor, - void *query) + uint32_t *val) { - int r, size = sizeof(uint32_t); + uint32_t tmp = UINT_MAX, size = sizeof(tmp); +int r; + +if (!val) +return -EINVAL ; r =amdgpu_pm_get_access_if_active (adev);if (r)return r;/* get the sensor value */ - r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); + r =amdgpu_dpm_read_sensor (adev, sensor, (void *)&tmp, &size);amdgpu_pm_put_access (adev); -return r; +if (r) +return r; + +switch (sensor) { +case AMDGPU_PP_SENSOR_GPU_LOAD : +case AMDGPU_PP_SENSOR_MEM_LOAD : +case AMDGPU_PP_SENSOR_VCN_LOAD : + tmp =clamp_t (uint32_t, tmp,0 ,100 ); +break ; +default : +break ; + } + + *val = tmp; + +return 0 ; }/**
[AMD Official Use Only - AMD Internal Distribution Only]
This is not a workaround; you have misunderstood the intent of this patch.
All ASIC load sensors must be constrained to the 0–100 range.
In other words, the KMD driver must not blindly trust the value returned by the firmware without validation. For example, invalid values may arise from issues such as memory corruption.
Best Regards,
Kevin
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, February 27, 2026 13:40
To: Wang, Yang(Kevin) <[email protected]>; Alex Deucher <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100
Quoted 4 lines · Yang(Kevin)
[AMD Official Use Only - AMD Internal Distribution Only]
Ping...
Please restrict this workaround to the affected SOC. Otherwise, if there are bogus values, we will fix it at the right place.
Thanks,
Lijo
Quoted 90 lines
Best Regards,
Kevin-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, February 25, 2026 10:24 PM
To: Lazar, Lijo <[email protected]>
Cc: Wang, Yang(Kevin) <[email protected]>; [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100Quoted 10 lines · Lijo
Quoted 3 lines · Yang Wang
Limit GPU/MEM/VCN load sensor values to 0-100 range via
clamp_tto ensure validity.Is this a workaround? If it's not within range, it indicates some underlying issue.
Likely for:
https://gitlab.freedesktop.org/drm/amd/-/issues/4905Alex
Quoted 60 lines
Thanks,
LijoQuoted 55 lines
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +23
-4@@ -1414,20 +1414,39 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, static int amdgpu_pm_get_sensor_generic(struct amdgpu_device *adev, enum amd_pp_sensors sensor, - void *query) + uint32_t *val) { - int r, size = sizeof(uint32_t); + uint32_t tmp = UINT_MAX, size = sizeof(tmp); +int r; + +if (!val) +return -EINVAL ; r =amdgpu_pm_get_access_if_active (adev);if (r)return r;/* get the sensor value */ - r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); + r =amdgpu_dpm_read_sensor (adev, sensor, (void *)&tmp, &size);amdgpu_pm_put_access (adev); -return r; +if (r) +return r; + +switch (sensor) { +case AMDGPU_PP_SENSOR_GPU_LOAD : +case AMDGPU_PP_SENSOR_MEM_LOAD : +case AMDGPU_PP_SENSOR_VCN_LOAD : + tmp =clamp_t (uint32_t, tmp,0 ,100 ); +break ; +default : +break ; + } + + *val = tmp; + +return 0 ; }/**
Quoted 7 lines · Yang(Kevin)
[AMD Official Use Only - AMD Internal Distribution Only]
This is not a workaround; you have misunderstood the intent of this patch.
All ASIC load sensors must be constrained to the 0–100 range.
In other words, the KMD driver must not blindly trust the value returned by the firmware without validation. For example, invalid values may arise from issues such as memory corruption.
We have many users who really care about the validity of the utilization values. If firmware returns any garbage like 65535 and driver clamping to show as 100% utilization is not the value. We don't want to chase ghost utilization bugs with this. If there are issues with corruption, fix it in the right place, but keep the integrity of utilization values.
Thanks,
Lijo
Quoted 113 lines
Best Regards,
Kevin-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, February 27, 2026 13:40
To: Wang, Yang(Kevin) <[email protected]>; Alex Deucher <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100Quoted 4 lines · Yang(Kevin)
[AMD Official Use Only - AMD Internal Distribution Only]
Ping...
Please restrict this workaround to the affected SOC. Otherwise, if there are bogus values, we will fix it at the right place.
Thanks,
LijoQuoted 90 lines
Best Regards,
Kevin-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, February 25, 2026 10:24 PM
To: Lazar, Lijo <[email protected]>
Cc: Wang, Yang(Kevin) <[email protected]>; [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100Quoted 10 lines · Lijo
Quoted 3 lines · Yang Wang
Limit GPU/MEM/VCN load sensor values to 0-100 range via
clamp_tto ensure validity.Is this a workaround? If it's not within range, it indicates some underlying issue.
Likely for:
https://gitlab.freedesktop.org/drm/amd/-/issues/4905Alex
Quoted 60 lines
Thanks,
LijoQuoted 55 lines
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +23
-4@@ -1414,20 +1414,39 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, static int amdgpu_pm_get_sensor_generic(struct amdgpu_device *adev, enum amd_pp_sensors sensor, - void *query) + uint32_t *val) { - int r, size = sizeof(uint32_t); + uint32_t tmp = UINT_MAX, size = sizeof(tmp); +int r; + +if (!val) +return -EINVAL ; r =amdgpu_pm_get_access_if_active (adev);if (r)return r;/* get the sensor value */ - r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); + r =amdgpu_dpm_read_sensor (adev, sensor, (void *)&tmp, &size);amdgpu_pm_put_access (adev); -return r; +if (r) +return r; + +switch (sensor) { +case AMDGPU_PP_SENSOR_GPU_LOAD : +case AMDGPU_PP_SENSOR_MEM_LOAD : +case AMDGPU_PP_SENSOR_VCN_LOAD : + tmp =clamp_t (uint32_t, tmp,0 ,100 ); +break ; +default : +break ; + } + + *val = tmp; + +return 0 ; }/**
[AMD Official Use Only - AMD Internal Distribution Only]
The KMD should be responsible(e.g user mode application) for the returned results rather than simply forwarding firmware values. So, I totally disagree with your point, and we need to right person to review this, no further discussion is needed with you.
Best Regards,
Kevin
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, February 27, 2026 15:55
To: Wang, Yang(Kevin) <[email protected]>; Alex Deucher <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100
Quoted 7 lines · Yang(Kevin)
[AMD Official Use Only - AMD Internal Distribution Only]
This is not a workaround; you have misunderstood the intent of this patch.
All ASIC load sensors must be constrained to the 0–100 range.
In other words, the KMD driver must not blindly trust the value returned by the firmware without validation. For example, invalid values may arise from issues such as memory corruption.
We have many users who really care about the validity of the utilization values. If firmware returns any garbage like 65535 and driver clamping to show as 100% utilization is not the value. We don't want to chase ghost utilization bugs with this. If there are issues with corruption, fix it in the right place, but keep the integrity of utilization values.
Thanks,
Lijo
Quoted 117 lines
Best Regards,
Kevin-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, February 27, 2026 13:40
To: Wang, Yang(Kevin) <[email protected]>; Alex Deucher <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100Quoted 4 lines · Yang(Kevin)
[AMD Official Use Only - AMD Internal Distribution Only]
Ping...
Please restrict this workaround to the affected SOC. Otherwise, if there are bogus values, we will fix it at the right place.
Thanks,
LijoQuoted 91 lines
Best Regards,
Kevin-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, February 25, 2026 10:24 PM
To: Lazar, Lijo <[email protected]>
Cc: Wang, Yang(Kevin) <[email protected]>; [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100Quoted 10 lines · Lijo
Quoted 3 lines · Yang Wang
Limit GPU/MEM/VCN load sensor values to 0-100 range via
clamp_tto ensure validity.Is this a workaround? If it's not within range, it indicates some underlying issue.
Likely for:
https://gitlab.freedesktop.org/drm/amd/-/issues/4905Alex
Quoted 61 lines
Thanks,
LijoQuoted 56 lines
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +24
-4@@ -1414,20 +1414,39 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, static int amdgpu_pm_get_sensor_generic(struct amdgpu_device *adev, enum amd_pp_sensors sensor, - void *query) + uint32_t *val) { - int r, size = sizeof(uint32_t); + uint32_t tmp = UINT_MAX, size = sizeof(tmp); +int r; + +if (!val) +return -EINVAL ; r =amdgpu_pm_get_access_if_active (adev);if (r)return r;/* get the sensor value */ - r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); + r =amdgpu_dpm_read_sensor (adev, sensor, (void *)&tmp, + &size);amdgpu_pm_put_access (adev); -return r; +if (r) +return r; + +switch (sensor) { +case AMDGPU_PP_SENSOR_GPU_LOAD : +case AMDGPU_PP_SENSOR_MEM_LOAD : +case AMDGPU_PP_SENSOR_VCN_LOAD : + tmp =clamp_t (uint32_t, tmp,0 ,100 ); +break ; +default : +break ; + } + + *val = tmp; + +return 0 ; }/**
Quoted 5 lines · Yang(Kevin)
[AMD Official Use Only - AMD Internal Distribution Only]
The KMD should be responsible(e.g user mode application) for the returned results rather than simply forwarding firmware values. So, I totally disagree with your point, and we need to right person to review this, no further discussion is needed with you.
KMD doesn't know anything about the actual utilization. If you want to handle it correctly, either return an error (because the utilization values are improper) or fix at the proper place and return the correct values.
Doing a blind clamping is not the way to fix it.
Thanks,
Lijo
Quoted 143 lines
Best Regards,
Kevin
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, February 27, 2026 15:55
To: Wang, Yang(Kevin) <[email protected]>; Alex Deucher <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100Quoted 7 lines · Yang(Kevin)
[AMD Official Use Only - AMD Internal Distribution Only]
This is not a workaround; you have misunderstood the intent of this patch.
All ASIC load sensors must be constrained to the 0–100 range.
In other words, the KMD driver must not blindly trust the value returned by the firmware without validation. For example, invalid values may arise from issues such as memory corruption.We have many users who really care about the validity of the utilization values. If firmware returns any garbage like 65535 and driver clamping to show as 100% utilization is not the value. We don't want to chase ghost utilization bugs with this. If there are issues with corruption, fix it in the right place, but keep the integrity of utilization values.
Thanks,
LijoQuoted 117 lines
Best Regards,
Kevin-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, February 27, 2026 13:40
To: Wang, Yang(Kevin) <[email protected]>; Alex Deucher <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100Quoted 4 lines · Yang(Kevin)
[AMD Official Use Only - AMD Internal Distribution Only]
Ping...
Please restrict this workaround to the affected SOC. Otherwise, if there are bogus values, we will fix it at the right place.
Thanks,
LijoQuoted 91 lines
Best Regards,
Kevin-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, February 25, 2026 10:24 PM
To: Lazar, Lijo <[email protected]>
Cc: Wang, Yang(Kevin) <[email protected]>; [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: restrict sensor load values to 0-100Quoted 10 lines · Lijo
Quoted 3 lines · Yang Wang
Limit GPU/MEM/VCN load sensor values to 0-100 range via
clamp_tto ensure validity.Is this a workaround? If it's not within range, it indicates some underlying issue.
Likely for:
https://gitlab.freedesktop.org/drm/amd/-/issues/4905Alex
Quoted 61 lines
Thanks,
LijoQuoted 56 lines
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +24
-4@@ -1414,20 +1414,39 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, static int amdgpu_pm_get_sensor_generic(struct amdgpu_device *adev, enum amd_pp_sensors sensor, - void *query) + uint32_t *val) { - int r, size = sizeof(uint32_t); + uint32_t tmp = UINT_MAX, size = sizeof(tmp); +int r; + +if (!val) +return -EINVAL ; r =amdgpu_pm_get_access_if_active (adev);if (r)return r;/* get the sensor value */ - r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); + r =amdgpu_dpm_read_sensor (adev, sensor, (void *)&tmp, + &size);amdgpu_pm_put_access (adev); -return r; +if (r) +return r; + +switch (sensor) { +case AMDGPU_PP_SENSOR_GPU_LOAD : +case AMDGPU_PP_SENSOR_MEM_LOAD : +case AMDGPU_PP_SENSOR_VCN_LOAD : + tmp =clamp_t (uint32_t, tmp,0 ,100 ); +break ; +default : +break ; + } + + *val = tmp; + +return 0 ; }/**