drm/amd/powerplay: implement feature get&set functions
authorKevin Wang <Kevin1.Wang@amd.com>
Wed, 26 Dec 2018 08:13:09 +0000 (16:13 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 Mar 2019 20:03:57 +0000 (15:03 -0500)
add smu feature operation function helper to deal with smu feature
bitmap.

Signed-off-by: Kevin Wang <Kevin1.Wang@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h

index f9b254c8dad9dffd5edd208931078544d7353615..aba3fb1a6bdbce051b36ae21e141da2ff0024bcf 100644 (file)
@@ -49,6 +49,43 @@ int smu_feature_init_dpm(struct smu_context *smu)
        return ret;
 }
 
+int smu_feature_is_enabled(struct smu_context *smu, int feature_id)
+{
+       struct smu_feature *feature = &smu->smu_feature;
+       WARN_ON(feature_id > feature->feature_num);
+       return test_bit(feature_id, feature->enabled);
+}
+
+int smu_feature_set_enabled(struct smu_context *smu, int feature_id, bool enable)
+{
+       struct smu_feature *feature = &smu->smu_feature;
+       WARN_ON(feature_id > feature->feature_num);
+       if (enable)
+               test_and_set_bit(feature_id, feature->enabled);
+       else
+               test_and_clear_bit(feature_id, feature->enabled);
+       return 0;
+}
+
+int smu_feature_is_supported(struct smu_context *smu, int feature_id)
+{
+       struct smu_feature *feature = &smu->smu_feature;
+       WARN_ON(feature_id > feature->feature_num);
+       return test_bit(feature_id, feature->supported);
+}
+
+int smu_feature_set_supported(struct smu_context *smu, int feature_id,
+                             bool enable)
+{
+       struct smu_feature *feature = &smu->smu_feature;
+       WARN_ON(feature_id > feature->feature_num);
+       if (enable)
+               test_and_set_bit(feature_id, feature->supported);
+       else
+               test_and_clear_bit(feature_id, feature->supported);
+       return 0;
+}
+
 static int smu_set_funcs(struct amdgpu_device *adev)
 {
        struct smu_context *smu = &adev->smu;
index 740dae2d62217f8fbfb0fdc014c323fac4c49eb5..dfabd73fedaf5e1cff07db324efb988a093f33a2 100644 (file)
@@ -327,4 +327,9 @@ extern const struct amd_ip_funcs smu_ip_funcs;
 extern const struct amdgpu_ip_block_version smu_v11_0_ip_block;
 extern int smu_feature_init_dpm(struct smu_context *smu);
 
+extern int smu_feature_is_enabled(struct smu_context *smu, int feature_id);
+extern int smu_feature_set_enabled(struct smu_context *smu, int feature_id, bool enable);
+extern int smu_feature_is_supported(struct smu_context *smu, int feature_id);
+extern int smu_feature_set_supported(struct smu_context *smu, int feature_id, bool enable);
+
 #endif