Skip to contentSkip to conversation

drm/amdgpu/powerplay/smu10: refactor AMDGPU_PP_SENSOR_GPU_LOAD

PATCH In review Shirish S 2 participants 2 messages Mar 19, 2021

Subsystems (3)
lore
Share & tools
lore

Shirish S

author
#0 lore raw

PATCH 1/1 drm/amdgpu/powerplay/smu10: refactor AMDGPU_PP_SENSOR_GPU_LOAD

refactor AMDGPU_PP_SENSOR_GPU_LOAD to ensure code consistency with other commands

---
 .../gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c    | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +6 -7
index f5d59fa3a030..f5fe540cd536 100644
@@ -1297,19 +1297,18 @@ static int smu10_read_sensor(struct pp_hwmgr *hwmgr, int idx,
 		*size = 4;
 		break;
 	case AMDGPU_PP_SENSOR_GPU_LOAD:
-		if (has_gfx_busy) {
+		if (!has_gfx_busy)
+			ret = -EOPNOTSUPP;
+		else {
 			ret = smum_send_msg_to_smc(hwmgr,
 						   PPSMC_MSG_GetGfxBusy,
 						   &activity_percent);
 			if (!ret)
-				activity_percent = activity_percent > 100 ? 100 : activity_percent;
+				*((uint32_t *)value) = min(activity_percent, (u32)100);
 			else
-				return -EIO;
-			*((uint32_t *)value) = activity_percent;
-			return 0;
-		} else {
-			return -EOPNOTSUPP;
+				ret = -EIO;
 		}
+		break;
 	default:
 		ret = -EOPNOTSUPP;
 		break;
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Shirish S

refactor AMDGPU_PP_SENSOR_GPU_LOAD to ensure code consistency with other commands

Quoted 37 lines
---
 .../gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c    | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +6 -8
index f5d59fa3a030..f5fe540cd536 100644
@@ -1297,19 +1297,18 @@ static int smu10_read_sensor(struct pp_hwmgr *hwmgr, int idx,
                *size = 4;
                break;
        case AMDGPU_PP_SENSOR_GPU_LOAD:
-               if (has_gfx_busy) {
+               if (!has_gfx_busy)
+                       ret = -EOPNOTSUPP;
+               else {
                        ret = smum_send_msg_to_smc(hwmgr,
                                                   PPSMC_MSG_GetGfxBusy,
                                                   &activity_percent);
                        if (!ret)
-                               activity_percent = activity_percent > 100 ? 100 : activity_percent;
+                               *((uint32_t *)value) = min(activity_percent, (u32)100);
                        else
-                               return -EIO;
-                       *((uint32_t *)value) = activity_percent;
-                       return 0;
-               } else {
-                       return -EOPNOTSUPP;
+                               ret = -EIO;
                }
+               break;
        default:
                ret = -EOPNOTSUPP;
                break;
--

2.17.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx