]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/pm: Add xgmi plpd to aldebaran pm_policy
authorLijo Lazar <lijo.lazar@amd.com>
Mon, 4 Mar 2024 06:33:08 +0000 (12:03 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 17 May 2024 21:40:39 +0000 (17:40 -0400)
On aldebaran, allow changing xgmi plpd policy through
'pm_policy/xgmi_plpd' sysfs interface.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c

index a22eb6bbb05ed67f770964d06b5fd6e0062fd86c..66478cfb8b776340895a24ca7a9b48432128253c 100644 (file)
@@ -266,9 +266,31 @@ static int aldebaran_tables_init(struct smu_context *smu)
        return 0;
 }
 
+static int aldebaran_select_plpd_policy(struct smu_context *smu, int level)
+{
+       struct amdgpu_device *adev = smu->adev;
+
+       /* The message only works on master die and NACK will be sent
+        * back for other dies, only send it on master die.
+        */
+       if (adev->smuio.funcs->get_socket_id(adev) ||
+           adev->smuio.funcs->get_die_id(adev))
+               return 0;
+
+       if (level == XGMI_PLPD_DEFAULT)
+               return smu_cmn_send_smc_msg_with_param(
+                       smu, SMU_MSG_GmiPwrDnControl, 0, NULL);
+       else if (level == XGMI_PLPD_DISALLOW)
+               return smu_cmn_send_smc_msg_with_param(
+                       smu, SMU_MSG_GmiPwrDnControl, 1, NULL);
+       else
+               return -EINVAL;
+}
+
 static int aldebaran_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_13_0_dpm_context),
                                       GFP_KERNEL);
@@ -276,6 +298,20 @@ static int aldebaran_allocate_dpm_context(struct smu_context *smu)
                return -ENOMEM;
        smu_dpm->dpm_context_size = sizeof(struct smu_13_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 = aldebaran_select_plpd_policy;
+       smu_cmn_generic_plpd_policy_desc(policy);
+       smu_dpm->dpm_policies->policy_mask |= BIT(PP_PM_POLICY_XGMI_PLPD);
+
        return 0;
 }