Add PM policy interfaces
Subsystems (5)
v3 cover Add PM policy interfaces
This series adds APIs to get the supported PM policies and also set them. A PM policy type is a predefined policy type supported by an SOC and each policy may define two or more levels to choose from. A user can select the appropriate level through amdgpu_dpm_set_pm_policy() or through sysfs node pm_policy. Based on the specific PM functional area, multiple PM policies may be defined for an SOC For ex: a policy may be defined to set the right setting for XGMI per link power down feature and another may be defined to select the SOC Pstate preferences.
Presently, XGMI PLPD and SOC Pstate policy types are supported. It also removes the legacy sysfs interface to set XGMI PLPD as it is not used any client like SMI tool.
v2:
Add NULL checks to avoid access on SOCs which don't support any policy.
v3:
Rebase and add documentation patch
Lijo Lazar (10):
drm/amd/pm: Add support for DPM policies drm/amd/pm: Update PMFW messages for SMUv13.0.6 drm/amd/pm: Add support to select pstate policy drm/amd/pm: Add xgmi plpd policy to pm_policy drm/amd/pm: Add xgmi plpd to SMU v13.0.6 pm_policy drm/amd/pm: Add xgmi plpd to aldebaran pm_policy drm/amd/pm: Add xgmi plpd to arcturus pm_policy drm/amd/pm: Remove legacy interface for xgmi plpd drm/amd/pm: Remove unused interface to set plpd Documentation/amdgpu: Add PM policy documentation
Documentation/gpu/amdgpu/thermal.rst | 6 + drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 4 +- .../gpu/drm/amd/include/kgd_pp_interface.h | 17 ++ drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 32 ++-- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 133 +++++++++++---- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 9 +- drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 2 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 113 +++++++++++-- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 37 ++++- .../pm/swsmu/inc/pmfw_if/smu_v13_0_6_ppsmc.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 64 +++++--- .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 59 ++++--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 + .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 153 +++++++++++++----- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 57 +++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 2 + 17 files changed, 527 insertions(+), 169 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/10 drm/amd/pm: Add support for DPM policies
Add support to set/get information about different DPM policies. The support is only available on SOCs which use swsmu architecture.
A DPM policy type may be defined with different levels. For example, a policy may be defined to select Pstate preference and then later a pstate preference may be chosen.
---
v2: Add NULL checks before accessing smu_dpm_policy_ctxt
v3: Rebase to add device_attr_id__pm_policy
.../gpu/drm/amd/include/kgd_pp_interface.h | 16 +++ drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 29 ++++++ drivers/gpu/drm/amd/pm/amdgpu_pm.c | 92 +++++++++++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 4 + drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 1 + drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 98 +++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 29 ++++++ 7 files changed, 269 insertions(+)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +16 -0
@@ -273,6 +273,22 @@ enum pp_xgmi_plpd_mode { XGMI_PLPD_COUNT, }; +enum pp_pm_policy { +PP_PM_POLICY_NONE =-1 , +PP_PM_POLICY_SOC_PSTATE =0 , +PP_PM_POLICY_NUM , +}; + +enum pp_policy_soc_pstate { +SOC_PSTATE_DEFAULT =0 , +SOC_PSTATE_0 , +SOC_PSTATE_1 , +SOC_PSTATE_2 , +SOC_PSTAT_COUNT , +}; + +#define PP_POLICY_MAX_LEVELS 5 +#define PP_GROUP_MASK 0xF0000000#define PP_GROUP_SHIFT 28
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +29 -0
@@ -411,6 +411,35 @@ int amdgpu_dpm_set_xgmi_plpd_mode(struct amdgpu_device *adev, int mode)return ret; } +ssize_t amdgpu_dpm_get_pm_policy_info (struct amdgpu_device *adev,char *buf) +{ +struct smu_context *smu = adev->powerplay.pp_handle; +int ret = -EOPNOTSUPP ; + +if (is_support_sw_smu (adev)) { +mutex_lock (&adev->pm.mutex); + ret =smu_get_pm_policy_info (smu, buf); +mutex_unlock (&adev->pm.mutex); + } + +return ret; +} + +int amdgpu_dpm_set_pm_policy (struct amdgpu_device *adev,int policy_type, +int policy_level) +{ +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_pm_policy (smu, policy_type, policy_level); +mutex_unlock (&adev->pm.mutex); + } + +return ret; +} +int amdgpu_dpm_enable_mgpu_fan_boost (struct amdgpu_device *adev) {void *pp_handle = adev->powerplay.pp_handle;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +92 -0
104 lines not on this page · raw message
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +4 -0
@@ -598,4 +598,8 @@ enum pp_smu_status amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev, unsigned int *num_states);int amdgpu_dpm_get_dpm_clock_table (struct amdgpu_device *adev,struct dpm_clocks *clock_table); +int amdgpu_dpm_set_pm_policy (struct amdgpu_device *adev,int policy_type, +int policy_level); +ssize_t amdgpu_dpm_get_pm_policy_info (struct amdgpu_device *adev,char *buf); +#endif
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +1 -0
@@ -79,6 +79,7 @@ enum amdgpu_device_attr_id { device_attr_id__smartshift_bias, device_attr_id__xgmi_plpd_policy, device_attr_id__pm_metrics, + device_attr_id__pm_policy, device_attr_id__count, };
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +98 -0
104 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +29 -0
@@ -362,6 +362,27 @@ struct smu_table_context {void *gpu_metrics_table; }; +struct smu_context ; +struct smu_dpm_policy ; + +struct smu_dpm_policy_desc { +const char *name; +char *(*get_desc)(struct smu_dpm_policy *dpm_policy,int level); +}; + +struct smu_dpm_policy { +struct smu_dpm_policy_desc *desc; +enum pp_pm_policy policy_type; +unsigned long level_mask; +int current_level; +int (*set_policy)(struct smu_context *ctxt,int level); +}; + +struct smu_dpm_policy_ctxt { +struct smu_dpm_policy policies[PP_PM_POLICY_NUM ]; +unsigned long policy_mask; +}; +struct smu_dpm_context {uint32_t dpm_context_size;void *dpm_context;
@@ -372,6 +393,7 @@ struct smu_dpm_context {struct smu_power_state *dpm_request_power_state;struct smu_power_state *dpm_current_power_state;struct mclock_latency_table *mclk_latency_table; +struct smu_dpm_policy_ctxt *dpm_policies; };struct smu_power_gate {
@@ -1551,6 +1573,9 @@ typedef struct {uint32_t MmHubPadding[8 ]; } WifiBandEntryTable_t; +struct smu_dpm_policy *smu_get_pm_policy (struct smu_context *smu, +enum pp_pm_policy p_type); +#if !defined(SWSMU_CODE_LAYER_L2 ) && !defined(SWSMU_CODE_LAYER_L3 ) && !defined(SWSMU_CODE_LAYER_L4 ) int smu_get_power_limit(void *handle, uint32_t *limit,
@@ -1598,5 +1623,9 @@ void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev);int smu_send_hbm_bad_pages_num (struct smu_context *smu,uint32_t size);int smu_send_hbm_bad_channel_flag (struct smu_context *smu,uint32_t size);int smu_send_rma_reason (struct smu_context *smu); +int smu_set_pm_policy (struct smu_context *smu,enum pp_pm_policy p_type, +int level); +ssize_t smu_get_pm_policy_info (struct smu_context *smu,char *sysbuf); +#endif #endif
Signature · 1 line
2.25.1
PATCH v3 2/10 drm/amd/pm: Update PMFW messages for SMUv13.0.6
In reply to Lijo LazarAdd PMF message to select a Pstate policy in SOCs with SMU v13.0.6.
--- drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_6_ppsmc.h | 3 ++- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v13_0_6_ppsmc.h +2 -1
@@ -92,7 +92,8 @@#define PPSMC_MSG_McaBankCeDumpDW 0x3B#define PPSMC_MSG_SelectPLPDMode 0x40#define PPSMC_MSG_RmaDueToBadPageThreshold 0x43 -#define PPSMC_Message_Count 0x44 +#define PPSMC_MSG_SelectPstatePolicy 0x44 +#define PPSMC_Message_Count 0x45//PPSMC Reset Types for driver msg argument #define PPSMC_RESET_TYPE_DRIVER_MODE_1_RESET 0x1
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2 -1
@@ -272,7 +272,8 @@__SMU_DUMMY_MAP (SetSoftMinVpe), \__SMU_DUMMY_MAP (GetMetricsVersion), \__SMU_DUMMY_MAP (EnableUCLKShadow), \ -__SMU_DUMMY_MAP (RmaDueToBadPageThreshold), +__SMU_DUMMY_MAP (RmaDueToBadPageThreshold),\ +__SMU_DUMMY_MAP (SelectPstatePolicy), #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##type
Signature · 1 line
2.25.1
PATCH v3 3/10 drm/amd/pm: Add support to select pstate policy
In reply to Lijo LazarAdd support to select pstate policy in SOCs with SMUv13.0.6
--- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 + .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 71 +++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 30 ++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 1 + 4 files changed, 104 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
@@ -531,10 +531,12 @@ int smu_v13_0_fini_smc_tables(struct smu_context *smu) smu_table->watermarks_table =NULL ; smu_table->metrics_time =0 ; +kfree (smu_dpm->dpm_policies);kfree (smu_dpm->dpm_context);kfree (smu_dpm->golden_dpm_context);kfree (smu_dpm->dpm_current_power_state);kfree (smu_dpm->dpm_request_power_state); + smu_dpm->dpm_policies =NULL ; smu_dpm->dpm_context =NULL ; smu_dpm->golden_dpm_context =NULL ; smu_dpm->dpm_context_size =0 ;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +71 -0
101 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +30 -0
@@ -1132,3 +1132,33 @@ bool smu_cmn_is_audio_func_enabled(struct amdgpu_device *adev)return snd_driver_loaded; } + +static char *smu_soc_policy_get_desc (struct smu_dpm_policy *policy,int level) +{ +if (level <0 || !(policy->level_mask &BIT (level))) +return "Invalid" ; + +switch (level) { +case SOC_PSTATE_DEFAULT : +return "soc_pstate_default" ; +case SOC_PSTATE_0 : +return "soc_pstate_0" ; +case SOC_PSTATE_1 : +return "soc_pstate_1" ; +case SOC_PSTATE_2 : +return "soc_pstate_2" ; + } + +return "Invalid" ; +} + +static struct smu_dpm_policy_desc pstate_policy_desc = { + .name ="soc pstate" , + .get_desc = smu_soc_policy_get_desc, +}; + +void smu_cmn_generic_soc_policy_desc (struct smu_dpm_policy *policy) +{ + policy->desc = &pstate_policy_desc; +} +
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
@@ -144,6 +144,7 @@ static inline void smu_cmn_get_sysfs_buf(char **buf, int *offset) }bool smu_cmn_is_audio_func_enabled (struct amdgpu_device *adev); +void smu_cmn_generic_soc_policy_desc (struct smu_dpm_policy *policy);#endif #endif
Signature · 1 line
2.25.1
PATCH v3 4/10 drm/amd/pm: Add xgmi plpd policy to pm_policy
In reply to Lijo LazarAdd support to set XGMI PLPD policy levels through pm_policy sysfs node.
--- drivers/gpu/drm/amd/include/kgd_pp_interface.h | 1 + drivers/gpu/drm/amd/pm/amdgpu_pm.c | 3 +++ 2 files changed, 4 insertions(+)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -0
@@ -276,6 +276,7 @@ enum pp_xgmi_plpd_mode {enum pp_pm_policy {PP_PM_POLICY_NONE =-1 ,PP_PM_POLICY_SOC_PSTATE =0 , +PP_PM_POLICY_XGMI_PLPD ,PP_PM_POLICY_NUM , };
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3 -0
@@ -2318,6 +2318,9 @@ static ssize_t amdgpu_set_pm_policy(struct device *dev,if (strncmp (tmp,"soc_pstate" ,strlen ("soc_pstate" )) ==0 ) { policy_type =PP_PM_POLICY_SOC_PSTATE ; tmp +=strlen ("soc_pstate" ); + }else if (strncmp (tmp,"xgmi" ,strlen ("xgmi" )) ==0 ) { + policy_type =PP_PM_POLICY_XGMI_PLPD ; + tmp +=strlen ("xgmi" ); }else {return -EINVAL ; }
Signature · 1 line
2.25.1
PATCH v3 5/10 drm/amd/pm: Add xgmi plpd to SMU v13.0.6 pm_policy
In reply to Lijo LazarOn SOCs with SMU v13.0.6, allow changing xgmi plpd policy through pm_policy sysfs interface.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 19 +++++-- .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 51 +++++++++++++++++-- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 27 ++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 1 + 4 files changed, 91 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +16 -3
@@ -1197,6 +1197,9 @@ static void smu_swctf_delayed_work_handler(struct work_struct *work)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; +if (amdgpu_ip_version (smu->adev,MP1_HWIP ,0 ) ==IP_VERSION (11 ,0 ,2 )) { smu->plpd_mode =XGMI_PLPD_DEFAULT ;return ;
@@ -1204,10 +1207,20 @@ 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_FEATURE_XGMI_PER_LINK_PWR_DWN_BIT )) { +struct smu_dpm_policy *policy; + smu->plpd_mode =XGMI_PLPD_DEFAULT ; -else + policy =smu_get_pm_policy (smu,PP_PM_POLICY_XGMI_PLPD ); +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 &= + ~BIT (PP_PM_POLICY_XGMI_PLPD ); + } }static int smu_sw_init (void *handle)
@@ -3555,7 +3568,7 @@ struct smu_dpm_policy *smu_get_pm_policy(struct smu_context *smu, policy_ctxt = dpm_ctxt->dpm_policies;if (!policy_ctxt)return NULL ; - +for_each_set_bit (i, &policy_ctxt->policy_mask,PP_PM_POLICY_NUM ) {if (policy_ctxt->policies[i].policy_type == p_type)return &policy_ctxt->policies[i];
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +47 -4
73 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +27 -0
@@ -1162,3 +1162,30 @@ void smu_cmn_generic_soc_policy_desc(struct smu_dpm_policy *policy) policy->desc = &pstate_policy_desc; } +static char *smu_xgmi_plpd_policy_get_desc (struct smu_dpm_policy *policy, +int level) +{ +if (level <0 || !(policy->level_mask &BIT (level))) +return "Invalid" ; + +switch (level) { +case XGMI_PLPD_DISALLOW : +return "plpd_disallow" ; +case XGMI_PLPD_DEFAULT : +return "plpd_default" ; +case XGMI_PLPD_OPTIMIZED : +return "plpd_optimized" ; + } + +return "Invalid" ; +} + +static struct smu_dpm_policy_desc xgmi_plpd_policy_desc = { + .name ="xgmi plpd" , + .get_desc = smu_xgmi_plpd_policy_get_desc, +}; + +void smu_cmn_generic_plpd_policy_desc (struct smu_dpm_policy *policy) +{ + policy->desc = &xgmi_plpd_policy_desc; +}
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
@@ -145,6 +145,7 @@ static inline void smu_cmn_get_sysfs_buf(char **buf, int *offset)bool smu_cmn_is_audio_func_enabled (struct amdgpu_device *adev);void smu_cmn_generic_soc_policy_desc (struct smu_dpm_policy *policy); +void smu_cmn_generic_plpd_policy_desc (struct smu_dpm_policy *policy);#endif #endif
Signature · 1 line
2.25.1
PATCH v3 6/10 drm/amd/pm: Add xgmi plpd to aldebaran pm_policy
In reply to Lijo LazarOn aldebaran, allow changing xgmi plpd policy through pm_policy sysfs interface.
--- .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +35 -0
@@ -266,9 +266,30 @@ 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 +297,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 ; }
Signature · 1 line
2.25.1
PATCH v3 7/10 drm/amd/pm: Add xgmi plpd to arcturus pm_policy
In reply to Lijo LazarOn arcturus, allow changing xgmi plpd policy through pm_policy sysfs interface.
--- 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(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4 -3
@@ -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 {
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +42 -0
63 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 8/10 drm/amd/pm: Remove legacy interface for xgmi plpd
In reply to Lijo LazarReplace 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.
---
v2: No change
v3: Rebase to remove device_attr_id__xgmi_plpd_policy
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/inc/amdgpu_pm.h | 1 - drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 27 -------- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 2 - 7 files changed, 2 insertions(+), 148 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +2 -2
@@ -1446,7 +1446,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" );
@@ -1455,7 +1455,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" );
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -43
49 lines not on this page · raw message
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -68
86 lines not on this page · raw message
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -5
@@ -430,11 +430,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,
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +0 -1
@@ -77,7 +77,6 @@ enum amdgpu_device_attr_id { device_attr_id__smartshift_apu_power, device_attr_id__smartshift_dgpu_power, device_attr_id__smartshift_bias, - device_attr_id__xgmi_plpd_policy, device_attr_id__pm_metrics, device_attr_id__pm_policy, device_attr_id__count,
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -27
@@ -1203,7 +1203,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 ;
@@ -1212,11 +1211,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 &=
@@ -3610,30 +3607,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,
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -2
@@ -602,8 +602,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;
Signature · 1 line
2.25.1
PATCH v3 9/10 drm/amd/pm: Remove unused interface to set plpd
In reply to Lijo LazarRemove unused callback to set PLPD policy and its implementation from arcturus, aldebaran and SMUv13.0.6 SOCs.
--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 6 --- .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 22 ----------- .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 24 ------------ .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 39 ------------------- 4 files changed, 91 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -6
@@ -876,12 +876,6 @@ struct pptable_funcs {*/ int (*set_df_cstate)(struct smu_context *smu,enum pp_df_cstate state); -/** -* @select_xgmi_plpd_policy: Select xgmi per-link power down policy. -*/ -int (*select_xgmi_plpd_policy)(struct smu_context *smu, -enum pp_xgmi_plpd_mode mode); -/** * @update_pcie_parameters: Update and upload the system's PCIe * capabilites to the SMU.
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +0 -22
@@ -2222,27 +2222,6 @@ static int arcturus_set_df_cstate(struct smu_context *smu,return smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_DFCstateControl, state,NULL ); } -static int arcturus_select_xgmi_plpd_policy (struct smu_context *smu, -enum pp_xgmi_plpd_mode mode) -{ -/* 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 (mode ==XGMI_PLPD_DEFAULT ) -return smu_cmn_send_smc_msg_with_param (smu, - SMU_MSG_GmiPwrDnControl, -1 ,NULL ); -else if (mode ==XGMI_PLPD_DISALLOW ) -return smu_cmn_send_smc_msg_with_param (smu, - SMU_MSG_GmiPwrDnControl, -0 ,NULL ); -else -return -EINVAL ; -} - static const struct throttling_logging_label { uint32_t feature_mask; const char *label;
@@ -2440,7 +2419,6 @@ static const struct pptable_funcs arcturus_ppt_funcs = { .get_dpm_ultimate_freq = smu_v11_0_get_dpm_ultimate_freq, .set_soft_freq_limited_range = smu_v11_0_set_soft_freq_limited_range, .set_df_cstate = arcturus_set_df_cstate, - .select_xgmi_plpd_policy = arcturus_select_xgmi_plpd_policy, .log_thermal_throttling_event = arcturus_log_thermal_throttling_event, .get_pp_feature_mask = smu_cmn_get_pp_feature_mask, .set_pp_feature_mask = smu_cmn_set_pp_feature_mask,
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -24
@@ -1642,29 +1642,6 @@ static int aldebaran_set_df_cstate(struct smu_context *smu,return smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_DFCstateControl, state,NULL ); } -static int aldebaran_select_xgmi_plpd_policy (struct smu_context *smu, -enum pp_xgmi_plpd_mode mode) -{ -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 (mode ==XGMI_PLPD_DEFAULT ) -return smu_cmn_send_smc_msg_with_param (smu, - SMU_MSG_GmiPwrDnControl, -0 ,NULL ); -else if (mode ==XGMI_PLPD_DISALLOW ) -return smu_cmn_send_smc_msg_with_param (smu, - SMU_MSG_GmiPwrDnControl, -1 ,NULL ); -else -return -EINVAL ; -} - static const struct throttling_logging_label { uint32_t feature_mask; const char *label;
@@ -2104,7 +2081,6 @@ static const struct pptable_funcs aldebaran_ppt_funcs = { .set_soft_freq_limited_range = aldebaran_set_soft_freq_limited_range, .od_edit_dpm_table = aldebaran_usr_edit_dpm_table, .set_df_cstate = aldebaran_set_df_cstate, - .select_xgmi_plpd_policy = aldebaran_select_xgmi_plpd_policy, .log_thermal_throttling_event = aldebaran_log_thermal_throttling_event, .get_pp_feature_mask = smu_cmn_get_pp_feature_mask, .set_pp_feature_mask = smu_cmn_set_pp_feature_mask,
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +0 -39
@@ -3240,44 +3240,6 @@ static const struct aca_smu_funcs smu_v13_0_6_aca_smu_funcs = { .parse_error_code = aca_smu_parse_error_code, }; -static int smu_v13_0_6_select_xgmi_plpd_policy (struct smu_context *smu, -enum pp_xgmi_plpd_mode mode) -{ -struct amdgpu_device *adev = smu->adev; -int ret, param; - -switch (mode) { -case XGMI_PLPD_DEFAULT : - param =PPSMC_PLPD_MODE_DEFAULT ; -break ; -case XGMI_PLPD_OPTIMIZED : - param =PPSMC_PLPD_MODE_OPTIMIZED ; -break ; -case XGMI_PLPD_DISALLOW : - param =0 ; -break ; -default : -return -EINVAL ; - } - -if (mode ==XGMI_PLPD_DISALLOW ) - ret =smu_cmn_send_smc_msg_with_param (smu, - SMU_MSG_GmiPwrDnControl, - param,NULL ); -else -/* change xgmi per-link power down policy */ - ret =smu_cmn_send_smc_msg_with_param (smu, - SMU_MSG_SelectPLPDMode, - param,NULL ); - -if (ret) -dev_err (adev->dev, -"select xgmi per-link power down policy %d failed\n" , - mode); - -return ret; -} -static const struct pptable_funcs smu_v13_0_6_ppt_funcs = {/* init dpm */ .get_allowed_feature_mask = smu_v13_0_6_get_allowed_feature_mask,
@@ -3318,7 +3280,6 @@ static const struct pptable_funcs smu_v13_0_6_ppt_funcs = { .get_dpm_ultimate_freq = smu_v13_0_6_get_dpm_ultimate_freq, .set_soft_freq_limited_range = smu_v13_0_6_set_soft_freq_limited_range, .od_edit_dpm_table = smu_v13_0_6_usr_edit_dpm_table, - .select_xgmi_plpd_policy = smu_v13_0_6_select_xgmi_plpd_policy, .log_thermal_throttling_event = smu_v13_0_6_log_thermal_throttling_event, .get_pp_feature_mask = smu_cmn_get_pp_feature_mask, .get_gpu_metrics = smu_v13_0_6_get_gpu_metrics,
Signature · 1 line
2.25.1
PATCH v3 10/10 Documentation/amdgpu: Add PM policy documentation
In reply to Lijo LazarAdd documentation about the newly added pm_policy node in sysfs.
--- Documentation/gpu/amdgpu/thermal.rst | 6 ++++ drivers/gpu/drm/amd/pm/amdgpu_pm.c | 48 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
Documentation/gpu/amdgpu/thermal.rst +6 -0
@@ -49,6 +49,12 @@ pp_power_profile_mode .. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: pp_power_profile_mode +pm_policy +--------------------- + +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c + :doc: pm_policy + \*_busy_percent ---------------
drivers/gpu/drm/amd/pm/amdgpu_pm.c +48 -0
54 lines not on this page · raw message
Signature · 1 line
2.25.1
Deucher, Alexander
maintainerRE: [PATCH v3 10/10] Documentation/amdgpu: Add PM policy documentation
[Public]
Quoted 91 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, May 13, 2024 5:21 AM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Kamal, Asad <[email protected]>; Ma, Le <[email protected]>
Subject: [PATCH v3 10/10]Documentation/amdgpu: Add PM policy documentationAdd documentation about the newly added
pm_policynode in sysfs.Signed-off-by Lijo Lazar <[email protected]>--- Documentation/gpu/amdgpu/thermal.rst | 6 ++++ drivers/gpu/drm/amd/pm/amdgpu_pm.c | 48 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)Documentation/gpu/amdgpu/thermal.rst +0
-0@@ -49,6 +49,12 @@ pp_power_profile_mode .. kernel-doc::
drivers/gpu/drm/amd/pm/amdgpu_pm.c
:doc:pp_power_profile_modeDocumentation/gpu/amdgpu/thermal.rst +6
-0+pm_policy +--------------------- + +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c + :doc: pm_policy + \*_busy_percent ---------------drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -2214,6 +2214,54 @@ static int pp_dpm_clk_default_attr_update(struct
amdgpu_device*adev, struct amdreturn 0;}
drivers/gpu/drm/amd/pm/amdgpu_pm.c +44
-0+/** +* DOC: pm_policy +* +* Certain SOCs can support different power policies to optimize +application +* performance. However, this policy is provided only at SOC level and +not at a +* per-process level. This is useful especially when entire SOC is +utilized for +* dedicated workload. +* +* The amdgpu driver provides a sysfs API for selecting the policy. +Presently, +* only two types of policies are supported through this interface. +* +* Pstate Policy Selection - This is to select different Pstate +profiles which +* decides clock/throttling preferences. +* +* XGMI PLPD Policy Selection - When multiple devices are connected +over XGMI, +* this helps to select policy to be applied for per link power down. +* +* The list of available policies and policy levels vary between SOCs. +They can +* be viewed by reading the file. The policy level which is applied +presently is +* denoted by * (asterisk). E.g., +* +* .. code-block:: console +* +* cat /sys/bus/pci/devices/.../pm_policy +* soc pstate +* 0 : soc_pstate_default +* 1 : soc_pstate_0 +* 2 : soc_pstate_1* +* 3 : soc_pstate_2 +* xgmi plpd +* 0 : plpd_disallow +* 1 : plpd_default +* 2 : plpd_optimized* +* +* To apply a specific policy +*
drivers/gpu/drm/amd/pm/amdgpu_pm.c static int pp_dpm_clk_default_attr_update(struct amdgpu_device *adev, struct amd · line 2261
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +10
-0+* "echo <policy type> <level> > /sys/bus/pci/devices/.../pm_policy" +* +* For the levels listed in the example above, to select +"plpd_optimized" for +* XGMI and "soc_pstate_2" for soc pstate policy - +* +* .. code-block:: console +* +* echo "xgmi 2" > /sys/bus/pci/devices/.../pm_policy +* echo "soc_pstate 3" > /sys/bus/pci/devices/.../pm_policy
The naming should be consistent between what is printed when you read the file and what you write to it. E.g., policy_type should be soc_pstate and xgmi_plpd in both cases.
Alex
Quoted 7 lines
+ *
+ */
+
staticssize_tamdgpu_get_pm_policy(struct device *dev,struct device_attribute *attr, char *buf) {--
2.25.1