Commit 5d6f66b5 authored by Lijo Lazar's avatar Lijo Lazar Committed by Alex Deucher

drm/amd/pm: Add xgmi plpd to arcturus pm_policy

On arcturus, allow changing xgmi plpd policy through
'pm_policy/xgmi_plpd' sysfs interface.
Signed-off-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: default avatarAsad Kamal <asad.kamal@amd.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 258ed689
......@@ -1199,19 +1199,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 {
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment