[PATCH 17/26] drm/amd/powerplay: add condition for smc table hw init

Huang Rui ray.huang at amd.com
Mon Feb 25 12:12:23 UTC 2019


From: Likun Gao <Likun.Gao at amd.com>

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 at amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng at amd.com>
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c     | 10 +++++++--
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  6 ------
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c      | 30 +++++---------------------
 3 files changed, 13 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index f6e659e..a5c672a 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -536,8 +536,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;
@@ -610,7 +616,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;
 
@@ -853,7 +859,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;
 
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
index 87d3320..b7313a9 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
@@ -489,8 +489,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);
@@ -617,10 +615,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) \
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index 3faf8fa..ffd71aa 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -761,34 +761,15 @@ static bool smu_v11_0_is_dpm_running(struct smu_context *smu)
 	return !!(feature_enabled & SMC_DPM_FEATURES);
 }
 
-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);
@@ -1992,8 +1973,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,
-- 
2.7.4



More information about the amd-gfx mailing list