drm/amd/powerplay: correct the way for checking SMU_FEATURE_BACO_BIT support
authorEvan Quan <evan.quan@amd.com>
Wed, 12 Feb 2020 03:52:20 +0000 (11:52 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 13 Feb 2020 21:16:45 +0000 (16:16 -0500)
Since 'smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT)' will always return
false considering the 'smu_system_features_control(smu, false)' disabled
all SMU features.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c

index 4720aa58a150be6a38135a2585a36cea2f9944ec..9f2428fd98f657124bd46195c043ee49278523a6 100644 (file)
@@ -1488,7 +1488,18 @@ static int smu_disable_dpm(struct smu_context *smu)
 
        /* For baco, need to leave BACO feature enabled */
        if (use_baco) {
-               if (smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT)) {
+               /*
+                * Correct the way for checking whether SMU_FEATURE_BACO_BIT
+                * is supported.
+                *
+                * Since 'smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT)' will
+                * always return false as the 'smu_system_features_control(smu, false)'
+                * was just issued above which disabled all SMU features.
+                *
+                * Thus 'smu_feature_get_index(smu, SMU_FEATURE_BACO_BIT)' is used
+                * now for the checking.
+                */
+               if (smu_feature_get_index(smu, SMU_FEATURE_BACO_BIT) >= 0) {
                        ret = smu_feature_set_enabled(smu, SMU_FEATURE_BACO_BIT, true);
                        if (ret) {
                                pr_warn("set BACO feature enabled failed, return %d\n", ret);