drm/amd/pm: add the interface to set and save the bootup workload type
Subsystems (3)
Kenneth Feng
maintainerPATCH v3 1/1 drm/amd/pm: add the interface to set and save the bootup workload type
add the interface to set and save the bootup workload type
v2: add is_support_sw_smu check and pm mutex lock.
v3: return before the scoreboard is set.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 44 +++++++++++++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 3 ++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 1 + drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 1 + 4 files changed, 49 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +44 -0
@@ -349,6 +349,50 @@ int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev,return ret; } +int amdgpu_dpm_set_and_save_bootup_power_profile (struct amdgpu_device *adev, +bool en) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +struct smu_context *smu = (struct smu_context *)(adev->powerplay.pp_handle); +int ret =0 ; +int current_profile_mode; +int saved_profile_mode; + +mutex_lock (&adev->pm.mutex); + current_profile_mode = smu->power_profile_mode; + saved_profile_mode = smu->saved_power_profile_mode; +mutex_unlock (&adev->pm.mutex); + +if (en && current_profile_mode ==PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ) +return 0 ; + +if (!en && current_profile_mode !=PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ) +return 0 ; + +if (en) { + ret =amdgpu_dpm_switch_power_profile (adev, current_profile_mode, !en); +if (ret) + goto out; +mutex_lock (&adev->pm.mutex); + smu->saved_power_profile_mode = current_profile_mode; + smu->power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ; +mutex_unlock (&adev->pm.mutex); + }else { + ret =amdgpu_dpm_switch_power_profile (adev, saved_profile_mode, !en); +if (ret) + goto out; +mutex_lock (&adev->pm.mutex); + smu->power_profile_mode = saved_profile_mode; + smu->saved_power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ; +mutex_unlock (&adev->pm.mutex); + } + +out: +return ret; +} +int amdgpu_dpm_set_xgmi_pstate (struct amdgpu_device *adev,uint32_t pstate) {
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +3 -0
@@ -410,6 +410,9 @@ int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev,enum PP_SMC_POWER_PROFILE type, bool en); +int amdgpu_dpm_set_and_save_bootup_power_profile (struct amdgpu_device *adev, +bool en); +int amdgpu_dpm_baco_reset (struct amdgpu_device *adev);int amdgpu_dpm_mode2_reset (struct amdgpu_device *adev);
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1 -0
@@ -1272,6 +1272,7 @@ static void smu_init_power_profile(struct smu_context *smu)PP_SMC_POWER_PROFILE_FULLSCREEN3D ; }smu_power_profile_mode_get (smu, smu->power_profile_mode); + smu->saved_power_profile_mode = smu->power_profile_mode; }static int smu_sw_init (struct amdgpu_ip_block *ip_block)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1 -0
@@ -560,6 +560,7 @@ struct smu_context {uint32_t workload_mask;/* default/user workload preference */ uint32_t power_profile_mode; +uint32_t saved_power_profile_mode;uint32_t workload_refcount[PP_SMC_POWER_PROFILE_COUNT ];/* backend specific custom workload settings */ long *custom_profile_params;
Signature · 1 line
2.34.1
Quoted 31 lines · Kenneth Feng
add the interface to set and save the bootup workload type
v2: addis_support_sw_smucheck and pm mutex lock.
v3: return before the scoreboard is set.Signed-off-by Kenneth Feng <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 44 +++++++++++++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 3 ++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 1 + drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 1 + 4 files changed, 49 insertions(+)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +11
-0@@ -349,6 +349,50 @@ int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev,return ret; } +int amdgpu_dpm_set_and_save_bootup_power_profile (struct amdgpu_device *adev, +bool en) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +struct smu_context *smu = (struct smu_context *)(adev->powerplay.pp_handle); +int ret =0 ; +int current_profile_mode; +int saved_profile_mode; +
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev, · line 372
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+mutex_lock (&adev->pm.mutex); + current_profile_mode = smu->power_profile_mode; + saved_profile_mode = smu->saved_power_profile_mode; +mutex_unlock (&adev->pm.mutex); + +if (en && current_profile_mode ==PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ) +return 0 ; + +if (!en && current_profile_mode !=PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ) +return 0 ;
Does this mean that user may be allowed to set a different profile after function is called with en?
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev, · line 380
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +8
-0+ +if (en) { + ret =amdgpu_dpm_switch_power_profile (adev, current_profile_mode, !en); +if (ret) + goto out; +mutex_lock (&adev->pm.mutex); + smu->saved_power_profile_mode = current_profile_mode; + smu->power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ;
With the second patch combined, the whole logic is applied in generic layer and may not work for all SOCs.
The default power profile mode of most SOCs is now set to PP_SMC_POWER_PROFILE_FULLSCREEN3D if supported.
If driver internally has set compute/video profile, then disabling them reverts only to default init mode which could be 3D mode. So the assumption that power profile mode is back to bootup default is wrong in such cases.
If no profile is set and when passed with !en, it will disable the default init profile mode and workload mask will be 0. If user has set another profile, it's the same behavior where workload mask is cleared. Not sure if that's the desired behavior for SOCs where 3D mode is set as default profile on init.
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev, · line 383
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0+mutex_unlock (&adev->pm.mutex); + }else { + ret =amdgpu_dpm_switch_power_profile (adev, saved_profile_mode, !en);
I guess the intention here is to enable the saved profile back and !en doesn't do that.
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev, · line 388
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+if (ret) + goto out; +mutex_lock (&adev->pm.mutex); + smu->power_profile_mode = saved_profile_mode; + smu->saved_power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ;
If it's always assumed to be bootup default, what is the purpose of saving this? Again, why is the assumption that boot_up default is the saved one?
Thanks,
Lijo
Quoted 48 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +7
-0+mutex_unlock (&adev->pm.mutex); + } + +out: +return ret; +} +int amdgpu_dpm_set_xgmi_pstate (struct amdgpu_device *adev,uint32_t pstate) {drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +3
-0@@ -410,6 +410,9 @@ int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev,enum PP_SMC_POWER_PROFILE type, bool en); +int amdgpu_dpm_set_and_save_bootup_power_profile (struct amdgpu_device *adev, +bool en); +int amdgpu_dpm_baco_reset (struct amdgpu_device *adev);int amdgpu_dpm_mode2_reset (struct amdgpu_device *adev);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0@@ -1272,6 +1272,7 @@ static void smu_init_power_profile(struct smu_context *smu)PP_SMC_POWER_PROFILE_FULLSCREEN3D ; }smu_power_profile_mode_get (smu, smu->power_profile_mode); + smu->saved_power_profile_mode = smu->power_profile_mode; }static int smu_sw_init (struct amdgpu_ip_block *ip_block)drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-0@@ -560,6 +560,7 @@ struct smu_context {uint32_t workload_mask;/* default/user workload preference */ uint32_t power_profile_mode; +uint32_t saved_power_profile_mode;uint32_t workload_refcount[PP_SMC_POWER_PROFILE_COUNT ];/* backend specific custom workload settings */ long *custom_profile_params;