drm/amd/pm: avoid consecutive retrieving for enabled ppfeatures
authorEvan Quan <evan.quan@amd.com>
Wed, 8 Dec 2021 07:35:00 +0000 (15:35 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 7 Feb 2022 23:01:16 +0000 (18:01 -0500)
As the enabled ppfeatures are just retrieved ahead. We can use
that directly instead of retrieving again and again.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c

index 67d7167..1a54447 100644 (file)
@@ -680,6 +680,7 @@ size_t smu_cmn_get_pp_feature_mask(struct smu_context *smu,
        int8_t sort_feature[SMU_FEATURE_COUNT];
        size_t size = 0;
        int ret = 0, i;
+       int feature_id;
 
        ret = smu_cmn_get_enabled_mask(smu,
                                       &feature_mask);
@@ -708,11 +709,18 @@ size_t smu_cmn_get_pp_feature_mask(struct smu_context *smu,
                if (sort_feature[i] < 0)
                        continue;
 
+               /* convert to asic spcific feature ID */
+               feature_id = smu_cmn_to_asic_specific_index(smu,
+                                                           CMN2ASIC_MAPPING_FEATURE,
+                                                           sort_feature[i]);
+               if (feature_id < 0)
+                       continue;
+
                size += sysfs_emit_at(buf, size, "%02d. %-20s (%2d) : %s\n",
                                count++,
                                smu_get_feature_name(smu, sort_feature[i]),
                                i,
-                               !!smu_cmn_feature_is_enabled(smu, sort_feature[i]) ?
+                               !!test_bit(feature_id, (unsigned long *)&feature_mask) ?
                                "enabled" : "disabled");
        }