[PATCH v2 8/9] drm/amd/pm: Remove legacy interface for xgmi plpd
Lijo Lazar
lijo.lazar at amd.com
Thu Mar 14 11:56:29 UTC 2024
Replace the legacy interface with amdgpu_dpm_set_pm_policy to set XGMI
PLPD mode. Also, xgmi_plpd sysfs node is not used by any client. Remove
that as well.
Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 4 +-
drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 43 ------------
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 68 -------------------
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 5 --
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 27 --------
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 2 -
6 files changed, 2 insertions(+), 147 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 20d51f6c9bb8..ecac9607a819 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -1429,7 +1429,7 @@ static int amdgpu_ras_error_inject_xgmi(struct amdgpu_device *adev,
if (amdgpu_dpm_set_df_cstate(adev, DF_CSTATE_DISALLOW))
dev_warn(adev->dev, "Failed to disallow df cstate");
- ret1 = amdgpu_dpm_set_xgmi_plpd_mode(adev, XGMI_PLPD_DISALLOW);
+ ret1 = amdgpu_dpm_set_pm_policy(adev, PP_PM_POLICY_XGMI_PLPD, XGMI_PLPD_DISALLOW);
if (ret1 && ret1 != -EOPNOTSUPP)
dev_warn(adev->dev, "Failed to disallow XGMI power down");
@@ -1438,7 +1438,7 @@ static int amdgpu_ras_error_inject_xgmi(struct amdgpu_device *adev,
if (amdgpu_ras_intr_triggered())
return ret2;
- ret1 = amdgpu_dpm_set_xgmi_plpd_mode(adev, XGMI_PLPD_DEFAULT);
+ ret1 = amdgpu_dpm_set_pm_policy(adev, PP_PM_POLICY_XGMI_PLPD, XGMI_PLPD_DEFAULT);
if (ret1 && ret1 != -EOPNOTSUPP)
dev_warn(adev->dev, "Failed to allow XGMI power down");
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index db3addd07120..21d05fab20d5 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
@@ -368,49 +368,6 @@ int amdgpu_dpm_set_df_cstate(struct amdgpu_device *adev,
return ret;
}
-int amdgpu_dpm_get_xgmi_plpd_mode(struct amdgpu_device *adev, char **mode_desc)
-{
- struct smu_context *smu = adev->powerplay.pp_handle;
- int mode = XGMI_PLPD_NONE;
-
- if (is_support_sw_smu(adev)) {
- mode = smu->plpd_mode;
- if (mode_desc == NULL)
- return mode;
- switch (smu->plpd_mode) {
- case XGMI_PLPD_DISALLOW:
- *mode_desc = "disallow";
- break;
- case XGMI_PLPD_DEFAULT:
- *mode_desc = "default";
- break;
- case XGMI_PLPD_OPTIMIZED:
- *mode_desc = "optimized";
- break;
- case XGMI_PLPD_NONE:
- default:
- *mode_desc = "none";
- break;
- }
- }
-
- return mode;
-}
-
-int amdgpu_dpm_set_xgmi_plpd_mode(struct amdgpu_device *adev, int mode)
-{
- struct smu_context *smu = adev->powerplay.pp_handle;
- int ret = -EOPNOTSUPP;
-
- if (is_support_sw_smu(adev)) {
- mutex_lock(&adev->pm.mutex);
- ret = smu_set_xgmi_plpd_mode(smu, mode);
- mutex_unlock(&adev->pm.mutex);
- }
-
- return ret;
-}
-
ssize_t amdgpu_dpm_get_pm_policy_info(struct amdgpu_device *adev, char *buf)
{
struct smu_context *smu = adev->powerplay.pp_handle;
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index ea9112ca1ac4..628d2ea6798b 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -2115,70 +2115,6 @@ static int pp_dpm_dcefclk_attr_update(struct amdgpu_device *adev, struct amdgpu_
return 0;
}
-/* Following items will be read out to indicate current plpd policy:
- * - -1: none
- * - 0: disallow
- * - 1: default
- * - 2: optimized
- */
-static ssize_t amdgpu_get_xgmi_plpd_policy(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct drm_device *ddev = dev_get_drvdata(dev);
- struct amdgpu_device *adev = drm_to_adev(ddev);
- char *mode_desc = "none";
- int mode;
-
- if (amdgpu_in_reset(adev))
- return -EPERM;
- if (adev->in_suspend && !adev->in_runpm)
- return -EPERM;
-
- mode = amdgpu_dpm_get_xgmi_plpd_mode(adev, &mode_desc);
-
- return sysfs_emit(buf, "%d: %s\n", mode, mode_desc);
-}
-
-/* Following argument value is expected from user to change plpd policy
- * - arg 0: disallow plpd
- * - arg 1: default policy
- * - arg 2: optimized policy
- */
-static ssize_t amdgpu_set_xgmi_plpd_policy(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct drm_device *ddev = dev_get_drvdata(dev);
- struct amdgpu_device *adev = drm_to_adev(ddev);
- int mode, ret;
-
- if (amdgpu_in_reset(adev))
- return -EPERM;
- if (adev->in_suspend && !adev->in_runpm)
- return -EPERM;
-
- ret = kstrtos32(buf, 0, &mode);
- if (ret)
- return -EINVAL;
-
- ret = pm_runtime_get_sync(ddev->dev);
- if (ret < 0) {
- pm_runtime_put_autosuspend(ddev->dev);
- return ret;
- }
-
- ret = amdgpu_dpm_set_xgmi_plpd_mode(adev, mode);
-
- pm_runtime_mark_last_busy(ddev->dev);
- pm_runtime_put_autosuspend(ddev->dev);
-
- if (ret)
- return ret;
-
- return count;
-}
-
static ssize_t amdgpu_get_pm_policy(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -2310,7 +2246,6 @@ static struct amdgpu_device_attr amdgpu_device_attrs[] = {
.attr_update = ss_power_attr_update),
AMDGPU_DEVICE_ATTR_RW(smartshift_bias, ATTR_FLAG_BASIC,
.attr_update = ss_bias_attr_update),
- AMDGPU_DEVICE_ATTR_RW(xgmi_plpd_policy, ATTR_FLAG_BASIC),
AMDGPU_DEVICE_ATTR_RW(pm_policy, ATTR_FLAG_BASIC,
.attr_update = amdgpu_pm_policy_attr_update),
AMDGPU_DEVICE_ATTR_RO(pm_metrics, ATTR_FLAG_BASIC,
@@ -2418,9 +2353,6 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_
else if ((gc_ver == IP_VERSION(10, 3, 0) ||
gc_ver == IP_VERSION(11, 0, 3)) && amdgpu_sriov_vf(adev))
*states = ATTR_STATE_UNSUPPORTED;
- } else if (DEVICE_ATTR_IS(xgmi_plpd_policy)) {
- if (amdgpu_dpm_get_xgmi_plpd_mode(adev, NULL) == XGMI_PLPD_NONE)
- *states = ATTR_STATE_UNSUPPORTED;
} else if (DEVICE_ATTR_IS(pp_mclk_od)) {
if (amdgpu_dpm_get_mclk_od(adev) == -EOPNOTSUPP)
*states = ATTR_STATE_UNSUPPORTED;
diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h
index a98d1bda4430..645c501649f3 100644
--- a/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h
+++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h
@@ -426,11 +426,6 @@ int amdgpu_dpm_baco_enter(struct amdgpu_device *adev);
int amdgpu_dpm_set_df_cstate(struct amdgpu_device *adev,
uint32_t cstate);
-int amdgpu_dpm_get_xgmi_plpd_mode(struct amdgpu_device *adev,
- char **mode);
-
-int amdgpu_dpm_set_xgmi_plpd_mode(struct amdgpu_device *adev, int mode);
-
int amdgpu_dpm_enable_mgpu_fan_boost(struct amdgpu_device *adev);
int amdgpu_dpm_set_clockgating_by_smu(struct amdgpu_device *adev,
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 6ec0734d34b7..a45a60bcfa84 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -1196,7 +1196,6 @@ static void smu_init_xgmi_plpd_mode(struct smu_context *smu)
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;
@@ -1205,11 +1204,9 @@ static void smu_init_xgmi_plpd_mode(struct smu_context *smu)
/* PMFW put PLPD into default policy after enabling the feature */
if (smu_feature_is_enabled(smu,
SMU_FEATURE_XGMI_PER_LINK_PWR_DWN_BIT)) {
- smu->plpd_mode = XGMI_PLPD_DEFAULT;
if (policy)
policy->current_level = XGMI_PLPD_DEFAULT;
} else {
- smu->plpd_mode = XGMI_PLPD_NONE;
policy_ctxt = dpm_ctxt->dpm_policies;
if (policy_ctxt)
policy_ctxt->policy_mask &=
@@ -3576,30 +3573,6 @@ int smu_set_pm_policy(struct smu_context *smu, enum pp_pm_policy p_type,
return ret;
}
-int smu_set_xgmi_plpd_mode(struct smu_context *smu,
- enum pp_xgmi_plpd_mode mode)
-{
- int ret = -EOPNOTSUPP;
-
- if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
- return ret;
-
- /* PLPD policy is not supported if it's NONE */
- if (smu->plpd_mode == XGMI_PLPD_NONE)
- return ret;
-
- if (smu->plpd_mode == mode)
- return 0;
-
- if (smu->ppt_funcs && smu->ppt_funcs->select_xgmi_plpd_policy)
- ret = smu->ppt_funcs->select_xgmi_plpd_policy(smu, mode);
-
- if (!ret)
- smu->plpd_mode = mode;
-
- return ret;
-}
-
static const struct amd_pm_funcs swsmu_pm_funcs = {
/* export for sysfs */
.set_fan_control_mode = smu_set_fan_control_mode,
diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
index 39405e4ef590..5970b99c8f4e 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
@@ -600,8 +600,6 @@ struct smu_context {
struct delayed_work swctf_delayed_work;
- enum pp_xgmi_plpd_mode plpd_mode;
-
/* data structures for wbrf feature support */
bool wbrf_supported;
struct notifier_block wbrf_notifier;
--
2.25.1
More information about the amd-gfx
mailing list