drm/amd/pm: Fix return value and drop redundant param
authorMa Jun <Jun.Ma2@amd.com>
Thu, 2 Nov 2023 03:19:46 +0000 (11:19 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 17 Nov 2023 14:29:53 +0000 (09:29 -0500)
Fix the return value and drop redundant parameter
of get_asic_baco_capability function.

Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/include/kgd_pp_interface.h
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_baco.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_baco.h
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu9_baco.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu9_baco.h
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_baco.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_baco.h
drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

index cd3c40a860293c2430efbf26c9832fc82533de34..b14231f470dc502edef95eab45efadcc1feeba6c 100644 (file)
@@ -421,7 +421,7 @@ struct amd_pm_funcs {
        int (*set_hard_min_dcefclk_by_freq)(void *handle, uint32_t clock);
        int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
        int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
-       int (*get_asic_baco_capability)(void *handle, bool *cap);
+       bool (*get_asic_baco_capability)(void *handle);
        int (*get_asic_baco_state)(void *handle, int *state);
        int (*set_asic_baco_state)(void *handle, int state);
        int (*get_ppfeature_status)(void *handle, char *buf);
index 08cb79401410ad0768a7bf9d95bea93c2ba2916b..1ae3b81548fa3e4567d2586b6a23cd302f0e7dbb 100644 (file)
@@ -185,8 +185,7 @@ bool amdgpu_dpm_is_baco_supported(struct amdgpu_device *adev)
 {
        const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
        void *pp_handle = adev->powerplay.pp_handle;
-       bool baco_cap;
-       int ret = 0;
+       bool ret;
 
        if (!pp_funcs || !pp_funcs->get_asic_baco_capability)
                return false;
@@ -204,12 +203,11 @@ bool amdgpu_dpm_is_baco_supported(struct amdgpu_device *adev)
 
        mutex_lock(&adev->pm.mutex);
 
-       ret = pp_funcs->get_asic_baco_capability(pp_handle,
-                                                &baco_cap);
+       ret = pp_funcs->get_asic_baco_capability(pp_handle);
 
        mutex_unlock(&adev->pm.mutex);
 
-       return ret ? false : baco_cap;
+       return ret;
 }
 
 int amdgpu_dpm_mode2_reset(struct amdgpu_device *adev)
index 914c15387157564f4f8f4fb0636b6ad9ad53fca8..aed0e2cefbf99072dbd503e43853739013e42db6 100644 (file)
@@ -1371,21 +1371,18 @@ static int pp_set_active_display_count(void *handle, uint32_t count)
        return phm_set_active_display_count(hwmgr, count);
 }
 
-static int pp_get_asic_baco_capability(void *handle, bool *cap)
+static bool pp_get_asic_baco_capability(void *handle)
 {
        struct pp_hwmgr *hwmgr = handle;
 
-       *cap = false;
        if (!hwmgr)
-               return -EINVAL;
+               return false;
 
        if (!(hwmgr->not_vf && amdgpu_dpm) ||
                !hwmgr->hwmgr_func->get_asic_baco_capability)
-               return 0;
+               return false;
 
-       hwmgr->hwmgr_func->get_asic_baco_capability(hwmgr, cap);
-
-       return 0;
+       return hwmgr->hwmgr_func->get_asic_baco_capability(hwmgr);
 }
 
 static int pp_get_asic_baco_state(void *handle, int *state)
index 044cda005aed114379b1ba878139be2c6716e109..e8a9471c1898bccf9628dbcfc2f8b33b341a113d 100644 (file)
 #include "smu/smu_7_1_2_d.h"
 #include "smu/smu_7_1_2_sh_mask.h"
 
-int smu7_baco_get_capability(struct pp_hwmgr *hwmgr, bool *cap)
+bool smu7_baco_get_capability(struct pp_hwmgr *hwmgr)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
        uint32_t reg;
 
-       *cap = false;
        if (!phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_BACO))
                return 0;
 
        reg = RREG32(mmCC_BIF_BX_FUSESTRAP0);
 
        if (reg & CC_BIF_BX_FUSESTRAP0__STRAP_BIF_PX_CAPABLE_MASK)
-               *cap = true;
+               return true;
 
-       return 0;
+       return false;
 }
 
 int smu7_baco_get_state(struct pp_hwmgr *hwmgr, enum BACO_STATE *state)
index be0d98abb5369c8942eeaf585fd1c9ab2a75880b..73a773f4ce2eb10c3cb34baa884db176e9fff137 100644 (file)
@@ -25,7 +25,7 @@
 #include "hwmgr.h"
 #include "common_baco.h"
 
-extern int smu7_baco_get_capability(struct pp_hwmgr *hwmgr, bool *cap);
+extern bool smu7_baco_get_capability(struct pp_hwmgr *hwmgr);
 extern int smu7_baco_get_state(struct pp_hwmgr *hwmgr, enum BACO_STATE *state);
 extern int smu7_baco_set_state(struct pp_hwmgr *hwmgr, enum BACO_STATE state);
 
index de0a37f7c63246d1ba7fb8a2554feac75091002f..c66ef974153580c39fd4307fd72bf64b47cb3928 100644 (file)
 #include "vega10_inc.h"
 #include "smu9_baco.h"
 
-int smu9_baco_get_capability(struct pp_hwmgr *hwmgr, bool *cap)
+bool smu9_baco_get_capability(struct pp_hwmgr *hwmgr)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
        uint32_t reg, data;
 
-       *cap = false;
        if (!phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_BACO))
-               return 0;
+               return false;
 
        WREG32(0x12074, 0xFFF0003B);
        data = RREG32(0x12075);
@@ -44,10 +43,10 @@ int smu9_baco_get_capability(struct pp_hwmgr *hwmgr, bool *cap)
                reg = RREG32_SOC15(NBIF, 0, mmRCC_BIF_STRAP0);
 
                if (reg & RCC_BIF_STRAP0__STRAP_PX_CAPABLE_MASK)
-                       *cap = true;
+                       return true;
        }
 
-       return 0;
+       return false;
 }
 
 int smu9_baco_get_state(struct pp_hwmgr *hwmgr, enum BACO_STATE *state)
index 84e90f801ac30593562b1820ad47b19bfcca032c..9ff7c2ea1b58d149657f9f5f7bc9df7815ed4c23 100644 (file)
@@ -25,7 +25,7 @@
 #include "hwmgr.h"
 #include "common_baco.h"
 
-extern int smu9_baco_get_capability(struct pp_hwmgr *hwmgr, bool *cap);
+extern bool smu9_baco_get_capability(struct pp_hwmgr *hwmgr);
 extern int smu9_baco_get_state(struct pp_hwmgr *hwmgr, enum BACO_STATE *state);
 
 #endif
index 994c0d374bfaeb9f3384be77c206b05bba135365..dad4c80aee58a2914950163e574e996c15f26c38 100644 (file)
@@ -36,23 +36,22 @@ static const struct soc15_baco_cmd_entry clean_baco_tbl[] = {
        {CMD_WRITE, SOC15_REG_ENTRY(NBIF, 0, mmBIOS_SCRATCH_7), 0, 0, 0, 0},
 };
 
-int vega20_baco_get_capability(struct pp_hwmgr *hwmgr, bool *cap)
+bool vega20_baco_get_capability(struct pp_hwmgr *hwmgr)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
        uint32_t reg;
 
-       *cap = false;
        if (!phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_BACO))
-               return 0;
+               return false;
 
        if (((RREG32(0x17569) & 0x20000000) >> 29) == 0x1) {
                reg = RREG32_SOC15(NBIF, 0, mmRCC_BIF_STRAP0);
 
                if (reg & RCC_BIF_STRAP0__STRAP_PX_CAPABLE_MASK)
-                       *cap = true;
+                       return true;
        }
 
-       return 0;
+       return false;
 }
 
 int vega20_baco_get_state(struct pp_hwmgr *hwmgr, enum BACO_STATE *state)
index f06471e712dcba646a7a00eb5327217d0ac5a60b..bdad9c915631b04ecc77d8d5451d8f79605635eb 100644 (file)
@@ -25,7 +25,7 @@
 #include "hwmgr.h"
 #include "common_baco.h"
 
-extern int vega20_baco_get_capability(struct pp_hwmgr *hwmgr, bool *cap);
+extern bool vega20_baco_get_capability(struct pp_hwmgr *hwmgr);
 extern int vega20_baco_get_state(struct pp_hwmgr *hwmgr, enum BACO_STATE *state);
 extern int vega20_baco_set_state(struct pp_hwmgr *hwmgr, enum BACO_STATE state);
 extern int vega20_baco_apply_vdci_flush_workaround(struct pp_hwmgr *hwmgr);
index 81650727a5defe45c36cd042f53f6524403db196..6f536159df4d8ee7f98f7a465b6763970553c2f2 100644 (file)
@@ -351,7 +351,7 @@ struct pp_hwmgr_func {
        int (*set_hard_min_fclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);
        int (*set_hard_min_gfxclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);
        int (*set_soft_max_gfxclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);
-       int (*get_asic_baco_capability)(struct pp_hwmgr *hwmgr, bool *cap);
+       bool (*get_asic_baco_capability)(struct pp_hwmgr *hwmgr);
        int (*get_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE *state);
        int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE state);
        int (*get_ppfeature_status)(struct pp_hwmgr *hwmgr, char *buf);
index 1ead323f1c78138b0176ec55032fd990239e94fa..37c2605f9b35110d3ff0a07b67f6298d7ede7a4d 100644 (file)
@@ -3005,19 +3005,17 @@ static int smu_set_xgmi_pstate(void *handle,
        return ret;
 }
 
-static int smu_get_baco_capability(void *handle, bool *cap)
+static bool smu_get_baco_capability(void *handle)
 {
        struct smu_context *smu = handle;
 
-       *cap = false;
-
        if (!smu->pm_enabled)
-               return 0;
+               return false;
 
-       if (smu->ppt_funcs && smu->ppt_funcs->baco_is_support)
-               *cap = smu->ppt_funcs->baco_is_support(smu);
+       if (!smu->ppt_funcs || !smu->ppt_funcs->baco_is_support)
+               return false;
 
-       return 0;
+       return smu->ppt_funcs->baco_is_support(smu);
 }
 
 static int smu_baco_set_state(void *handle, int state)