[PATCH v2 7/9] drm/amd/pm: Add xgmi plpd to arcturus pm_policy
Lijo Lazar
lijo.lazar at amd.com
Thu Mar 14 11:56:28 UTC 2024
On arcturus, allow changing xgmi plpd policy through pm_policy sysfs
interface.
Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com>
---
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 7 ++--
.../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 42 +++++++++++++++++++
2 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index e5d5766ede9e..6ec0734d34b7 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -1192,19 +1192,20 @@ static void smu_init_xgmi_plpd_mode(struct smu_context *smu)
{
struct smu_dpm_context *dpm_ctxt = &(smu->smu_dpm);
struct smu_dpm_policy_ctxt *policy_ctxt;
+ struct smu_dpm_policy *policy;
+ policy = smu_get_pm_policy(smu, PP_PM_POLICY_XGMI_PLPD);
if (amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(11, 0, 2)) {
smu->plpd_mode = XGMI_PLPD_DEFAULT;
+ if (policy)
+ policy->current_level = XGMI_PLPD_DEFAULT;
return;
}
/* PMFW put PLPD into default policy after enabling the feature */
if (smu_feature_is_enabled(smu,
SMU_FEATURE_XGMI_PER_LINK_PWR_DWN_BIT)) {
- struct smu_dpm_policy *policy;
-
smu->plpd_mode = XGMI_PLPD_DEFAULT;
- policy = smu_get_pm_policy(smu, PP_PM_POLICY_XGMI_PLPD);
if (policy)
policy->current_level = XGMI_PLPD_DEFAULT;
} else {
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
index 40ba7227cca5..c6ee2e22e6cc 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
@@ -283,9 +283,29 @@ static int arcturus_tables_init(struct smu_context *smu)
return 0;
}
+static int arcturus_select_plpd_policy(struct smu_context *smu, int level)
+{
+ /* PPSMC_MSG_GmiPwrDnControl is supported by 54.23.0 and onwards */
+ if (smu->smc_fw_version < 0x00361700) {
+ dev_err(smu->adev->dev,
+ "XGMI power down control is only supported by PMFW 54.23.0 and onwards\n");
+ return -EINVAL;
+ }
+
+ if (level == XGMI_PLPD_DEFAULT)
+ return smu_cmn_send_smc_msg_with_param(
+ smu, SMU_MSG_GmiPwrDnControl, 1, NULL);
+ else if (level == XGMI_PLPD_DISALLOW)
+ return smu_cmn_send_smc_msg_with_param(
+ smu, SMU_MSG_GmiPwrDnControl, 0, NULL);
+ else
+ return -EINVAL;
+}
+
static int arcturus_allocate_dpm_context(struct smu_context *smu)
{
struct smu_dpm_context *smu_dpm = &smu->smu_dpm;
+ struct smu_dpm_policy *policy;
smu_dpm->dpm_context = kzalloc(sizeof(struct smu_11_0_dpm_context),
GFP_KERNEL);
@@ -293,6 +313,20 @@ static int arcturus_allocate_dpm_context(struct smu_context *smu)
return -ENOMEM;
smu_dpm->dpm_context_size = sizeof(struct smu_11_0_dpm_context);
+ smu_dpm->dpm_policies =
+ kzalloc(sizeof(struct smu_dpm_policy_ctxt), GFP_KERNEL);
+
+ if (!smu_dpm->dpm_policies)
+ return -ENOMEM;
+
+ policy = &(smu_dpm->dpm_policies->policies[0]);
+ policy->policy_type = PP_PM_POLICY_XGMI_PLPD;
+ policy->level_mask = BIT(XGMI_PLPD_DISALLOW) | BIT(XGMI_PLPD_DEFAULT);
+ policy->current_level = XGMI_PLPD_DEFAULT;
+ policy->set_policy = arcturus_select_plpd_policy;
+ smu_cmn_generic_plpd_policy_desc(policy);
+ smu_dpm->dpm_policies->policy_mask |= BIT(PP_PM_POLICY_XGMI_PLPD);
+
return 0;
}
@@ -403,6 +437,14 @@ static int arcturus_set_default_dpm_table(struct smu_context *smu)
dpm_table->max = dpm_table->dpm_levels[0].value;
}
+ /* XGMI PLPD is supported by 54.23.0 and onwards */
+ if (smu->smc_fw_version < 0x00361700) {
+ struct smu_dpm_context *smu_dpm = &smu->smu_dpm;
+
+ smu_dpm->dpm_policies->policy_mask &=
+ ~BIT(PP_PM_POLICY_XGMI_PLPD);
+ }
+
return 0;
}
--
2.25.1
More information about the amd-gfx
mailing list