drm/amd/pm: add the interface to set and save the bootup workload type
Kenneth Feng
maintainerPATCH 1/2 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
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 27 +++++++++++++++++++ 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, 32 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +27 -0
@@ -349,6 +349,33 @@ 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) +{ +struct smu_context *smu = (struct smu_context *)(adev->powerplay.pp_handle); +int current_profile_mode = smu->power_profile_mode; +int saved_profile_mode = smu->saved_power_profile_mode; +int ret =0 ; + +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); + smu->saved_power_profile_mode = current_profile_mode; + smu->power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ; + }else { + ret =amdgpu_dpm_switch_power_profile (adev, saved_profile_mode, !en); + smu->power_profile_mode = saved_profile_mode; + smu->saved_power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ; + } + +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
Kenneth Feng
maintainerPATCH 2/2 drm/amd/display: set the workload based on MALL status
set the workload based on MALL status
--- .../drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c +16 -2
@@ -244,6 +244,8 @@ static void amdgpu_dm_crtc_vblank_control_worker(struct work_struct *work)struct vblank_control_work *vblank_work = container_of(work, struct vblank_control_work, work);struct amdgpu_display_manager *dm = vblank_work->dm; +struct amdgpu_device *adev = dm->adev; +int ret;mutex_lock (&dm->dc_lock);
@@ -252,8 +254,14 @@ static void amdgpu_dm_crtc_vblank_control_worker(struct work_struct *work)else if (dm->active_vblank_irq_count) dm->active_vblank_irq_count--; -if (dm->active_vblank_irq_count >0 ) +if (dm->active_vblank_irq_count >0 ) { + ret =amdgpu_dpm_set_and_save_bootup_power_profile (adev, false); +if (ret) { +dev_err (adev->dev,"(%d) failed to exit bootup workload\n" , ret); +return ; + }dc_allow_idle_optimizations (dm->dc, false); + }/* * Control PSR based on vblank requirements from OS
@@ -271,8 +279,14 @@ static void amdgpu_dm_crtc_vblank_control_worker(struct work_struct *work) vblank_work->acrtc->dm_irq_params.allow_sr_entry); } -if (dm->active_vblank_irq_count ==0 ) +if (dm->active_vblank_irq_count ==0 ) { + ret =amdgpu_dpm_set_and_save_bootup_power_profile (adev, true); +if (ret) { +dev_err (adev->dev,"(%d) failed to set bootup workload\n" , ret); +return ; + }dc_allow_idle_optimizations (dm->dc, true); + }mutex_unlock (&dm->dc_lock);
Signature · 1 line
2.34.1
Quoted 16 lines · Kenneth Feng
add the interface to set and save the bootup workload type
Signed-off-by Kenneth Feng <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 27 +++++++++++++++++++ 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, 32 insertions(+)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev, · line 355
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0@@ -349,6 +349,33 @@ 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) +{ +struct smu_context *smu = (struct smu_context *)(adev->powerplay.pp_handle);
You need to check if is_support_sw_smu() before accessing the smu context.
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+int current_profile_mode = smu->power_profile_mode; +int saved_profile_mode = smu->saved_power_profile_mode; +int ret =0 ; +
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev, · line 369
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+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); + smu->saved_power_profile_mode = current_profile_mode; + smu->power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ;
Should take the pm.mutex when you mess with the smu context.
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev, · line 373
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+ }else { + ret =amdgpu_dpm_switch_power_profile (adev, saved_profile_mode, !en); + smu->power_profile_mode = saved_profile_mode; + smu->saved_power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ;
Same here.
Quoted 49 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+ } + +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
-1@@ -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; --2.34.1
Feng, Kenneth
maintainer[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, January 6, 2025 11:59 PM
To: Feng, Kenneth <[email protected]>
Cc: [email protected]; Pillai, Aurabindo <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 1/2] drm/amd/pm: add the interface to set and save the bootup workload type
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 17 lines · Kenneth Feng
add the interface to set and save the bootup workload type
Signed-off-by Kenneth Feng <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 27 +++++++++++++++++++ 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, 32 insertions(+)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev, · line 355
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0@@ -349,6 +349,33 @@ 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) { +struct smu_context *smu = (struct +smu_context *)(adev->powerplay.pp_handle);
You need to check if is_support_sw_smu() before accessing the smu context.
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+int current_profile_mode = smu->power_profile_mode; +int saved_profile_mode = smu->saved_power_profile_mode; +int ret =0 ; + +if (en && current_profile_mode ==PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT )
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev,
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+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); + smu->saved_power_profile_mode = current_profile_mode; + smu->power_profile_mode = +PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ;
Should take the pm.mutex when you mess with the smu context.
[Kenneth] - the pm.mutex is taken in the called function amdgpu_dpm_switch_power_profile. Do we need it before calling amdgpu_dpm_switch_power_profile? Thanks.
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+ }else { + ret =amdgpu_dpm_switch_power_profile (adev, saved_profile_mode, !en); + smu->power_profile_mode = saved_profile_mode; + smu->saved_power_profile_mode = +PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ;
Same here.
Quoted 51 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+ } + +return ret; +} +int amdgpu_dpm_set_xgmi_pstate (struct amdgpu_device *adev, uint32_t pstate) { diff --git
a/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.hb/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h
index1f5ac7e0230d..5fe404bbb033100644drivers/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); diff --git
a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.cb/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index8ca793c222ff..a6f748361198100644drivers/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) diff --git
a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.hb/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
index3630593bce61..c58fc31fb1d7100644drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-1@@ -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; --2.34.1
Quoted 51 lines · Kenneth
[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, January 6, 2025 11:59 PM
To: Feng, Kenneth <[email protected]>
Cc: [email protected]; Pillai, Aurabindo <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 1/2] drm/amd/pm: add the interface to set and save the bootup workload typeCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 17 lines · Kenneth Feng
add the interface to set and save the bootup workload type
Signed-off-by Kenneth Feng <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 27 +++++++++++++++++++ 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, 32 insertions(+)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev, · line 355
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0@@ -349,6 +349,33 @@ 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) { +struct smu_context *smu = (struct +smu_context *)(adev->powerplay.pp_handle);You need to check if
is_support_sw_smu()before accessing the smu context.Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+int current_profile_mode = smu->power_profile_mode; +int saved_profile_mode = smu->saved_power_profile_mode; +int ret =0 ; + +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 ; +
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+if (en) { + ret =amdgpu_dpm_switch_power_profile (adev, current_profile_mode, !en); + smu->saved_power_profile_mode = current_profile_mode; + smu->power_profile_mode = +PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ;Should take the pm.mutex when you mess with the smu context.
[Kenneth] - the pm.mutex is taken in the called functionamdgpu_dpm_switch_power_profile. Do we need it before callingamdgpu_dpm_switch_power_profile?
no, wrap the smu->saved_power_profile_mode and smu->power_profile_mode with the mutex. E.g.,
+ if (en) {
+ ret = amdgpu_dpm_switch_power_profile(adev,current_profile_mode, !en);
mutex_lock()
+ smu->saved_power_profile_mode = current_profile_mode;
+ smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
mutex_unlock()
+ } else {
+ ret = amdgpu_dpm_switch_power_profile(adev,saved_profile_mode, !en);
mutex_lock()
+ smu->power_profile_mode = saved_profile_mode;
+ smu->saved_power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
mutex_unlock()
+ }
Alex
Quoted 61 lines
Thanks.
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+ }else { + ret =amdgpu_dpm_switch_power_profile (adev, saved_profile_mode, !en); + smu->power_profile_mode = saved_profile_mode; + smu->saved_power_profile_mode = +PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ;Same here.
Quoted 51 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+ } + +return ret; +} +int amdgpu_dpm_set_xgmi_pstate (struct amdgpu_device *adev, uint32_t pstate) { diff --git
a/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.hb/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h
index1f5ac7e0230d..5fe404bbb033100644drivers/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); diff --git
a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.cb/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index8ca793c222ff..a6f748361198100644drivers/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) diff --git
a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.hb/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
index3630593bce61..c58fc31fb1d7100644drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-1@@ -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; --2.34.1