drm/amd/powerplay: add condition for smc table hw init
authorLikun Gao <Likun.Gao@amd.com>
Fri, 15 Feb 2019 07:47:26 +0000 (15:47 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 Mar 2019 20:04:01 +0000 (15:04 -0500)
Smc table hw init should be skipped for suspend/resume when dpm running.
Unified feature enable and disable function into smu_system_features_control.

Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Reviewed-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
drivers/gpu/drm/amd/powerplay/smu_v11_0.c

index 0a9b87369f5c93167c3870efb73b6be9bf301ac5..231cce90763d073472d9ef0fb87dfddea8003042 100644 (file)
@@ -532,8 +532,14 @@ static int smu_fini_fb_allocations(struct smu_context *smu)
 static int smu_smc_table_hw_init(struct smu_context *smu,
                                 bool initialize)
 {
+       struct amdgpu_device *adev = smu->adev;
        int ret;
 
+       if (smu_is_dpm_running(smu) && adev->in_suspend) {
+               pr_info("dpm has been enabled\n");
+               return 0;
+       }
+
        ret = smu_init_display(smu);
        if (ret)
                return ret;
@@ -606,7 +612,7 @@ static int smu_smc_table_hw_init(struct smu_context *smu,
        if (ret)
                return ret;
 
-       ret = smu_feature_enable_all(smu);
+       ret = smu_system_features_control(smu, true);
        if (ret)
                return ret;
 
@@ -849,7 +855,7 @@ static int smu_suspend(void *handle)
        if (!is_support_sw_smu(adev))
                return -EINVAL;
 
-       ret = smu_feature_disable_all(smu);
+       ret = smu_system_features_control(smu, false);
        if (ret)
                return ret;
 
index a79991d6ef98d4a5046336e5efafd3e3a8418b94..feb24f2b3a14071cca48f970c2fc922e0513c90d 100644 (file)
@@ -484,8 +484,6 @@ struct smu_funcs
        int (*set_allowed_mask)(struct smu_context *smu);
        int (*get_enabled_mask)(struct smu_context *smu, uint32_t *feature_mask, uint32_t num);
        bool (*is_dpm_running)(struct smu_context *smu);
-       int (*enable_all_mask)(struct smu_context *smu);
-       int (*disable_all_mask)(struct smu_context *smu);
        int (*update_feature_enable_state)(struct smu_context *smu, uint32_t feature_id, bool enabled);
        int (*notify_display_change)(struct smu_context *smu);
        int (*get_power_limit)(struct smu_context *smu, uint32_t *limit, bool def);
@@ -612,10 +610,6 @@ struct smu_funcs
        ((smu)->funcs->get_enabled_mask? (smu)->funcs->get_enabled_mask((smu), (mask), (num)) : 0)
 #define smu_is_dpm_running(smu) \
        ((smu)->funcs->is_dpm_running ? (smu)->funcs->is_dpm_running((smu)) : 0)
-#define smu_feature_enable_all(smu) \
-       ((smu)->funcs->enable_all_mask? (smu)->funcs->enable_all_mask((smu)) : 0)
-#define smu_feature_disable_all(smu) \
-       ((smu)->funcs->disable_all_mask? (smu)->funcs->disable_all_mask((smu)) : 0)
 #define smu_feature_update_enable_state(smu, feature_id, enabled) \
        ((smu)->funcs->update_feature_enable_state? (smu)->funcs->update_feature_enable_state((smu), (feature_id), (enabled)) : 0)
 #define smu_notify_display_change(smu) \
index ba808a57185c89bb88d2a6005d21da134f497585..bc60b4b3131d416e8303272aafd0c3bdb00ffdc8 100644 (file)
@@ -771,34 +771,15 @@ static bool smu_v11_0_is_dpm_running(struct smu_context *smu)
        return !!(feature_enabled & SMC_DPM_FEATURE);
 }
 
-static int smu_v11_0_enable_all_mask(struct smu_context *smu)
+static int smu_v11_0_system_features_control(struct smu_context *smu,
+                                            bool en)
 {
        struct smu_feature *feature = &smu->smu_feature;
        uint32_t feature_mask[2];
        int ret = 0;
 
-       ret = smu_send_smc_msg(smu, SMU_MSG_EnableAllSmuFeatures);
-       if (ret)
-               return ret;
-       ret = smu_feature_get_enabled_mask(smu, feature_mask, 2);
-       if (ret)
-               return ret;
-
-       bitmap_copy(feature->enabled, (unsigned long *)&feature_mask,
-                   feature->feature_num);
-       bitmap_copy(feature->supported, (unsigned long *)&feature_mask,
-                   feature->feature_num);
-
-       return ret;
-}
-
-static int smu_v11_0_disable_all_mask(struct smu_context *smu)
-{
-       struct smu_feature *feature = &smu->smu_feature;
-       uint32_t feature_mask[2];
-       int ret = 0;
-
-       ret = smu_send_smc_msg(smu, SMU_MSG_DisableAllSmuFeatures);
+       ret = smu_send_smc_msg(smu, (en ? SMU_MSG_EnableAllSmuFeatures :
+                                    SMU_MSG_DisableAllSmuFeatures));
        if (ret)
                return ret;
        ret = smu_feature_get_enabled_mask(smu, feature_mask, 2);
@@ -1987,8 +1968,7 @@ static const struct smu_funcs smu_v11_0_funcs = {
        .set_allowed_mask = smu_v11_0_set_allowed_mask,
        .get_enabled_mask = smu_v11_0_get_enabled_mask,
        .is_dpm_running = smu_v11_0_is_dpm_running,
-       .enable_all_mask = smu_v11_0_enable_all_mask,
-       .disable_all_mask = smu_v11_0_disable_all_mask,
+       .system_features_control = smu_v11_0_system_features_control,
        .update_feature_enable_state = smu_v11_0_update_feature_enable_state,
        .notify_display_change = smu_v11_0_notify_display_change,
        .get_power_limit = smu_v11_0_get_power_limit,