Unified entry point for other blocks to interact with power
Subsystems (5)
v3 cover Unified entry point for other blocks to interact with power
There are several problems with current power implementations:
1. Too many internal details are exposed to other blocks. Thus to interact with power, they need to know which power framework is used(powerplay vs swsmu) or even whether some API is implemented.
2. A lot of cross callings exist which make it hard to get a whole picture of the code hierarchy. And that makes any code change/increment error-prone.
3. Many different types of lock are used. It is calculated there is totally 13 different locks are used within power. Some of them are even designed for the same purpose.
To ease the problems above, this patch series try to
1. provide unified entry point for other blocks to interact with power.
2. relocate some source code piece/headers to avoid cross callings.
3. enforce a unified lock protection on those entry point APIs above. That makes the future optimization for unnecessary power locks possible.
Evan Quan (17):
drm/amd/pm: do not expose implementation details to other blocks out
of power
drm/amd/pm: do not expose power implementation details to amdgpu_pm.c drm/amd/pm: do not expose power implementation details to display drm/amd/pm: do not expose those APIs used internally only in
amdgpu_dpm.c
drm/amd/pm: do not expose those APIs used internally only in si_dpm.c drm/amd/pm: do not expose the API used internally only in kv_dpm.c drm/amd/pm: create a new holder for those APIs used only by legacy
ASICs(si/kv)
drm/amd/pm: move pp_force_state_enabled member to amdgpu_pm structure drm/amd/pm: optimize the amdgpu_pm_compute_clocks() implementations drm/amd/pm: move those code piece used by Stoney only to smu8_hwmgr.c drm/amd/pm: correct the usage for amdgpu_dpm_dispatch_task() drm/amd/pm: drop redundant or unused APIs and data structures drm/amd/pm: do not expose the smu_context structure used internally in
power
drm/amd/pm: relocate the power related headers
drm/amd/pm: drop unnecessary gfxoff controls
drm/amd/pm: revise the performance level setting APIs drm/amd/pm: unified lock protections in amdgpu_dpm.c
drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 -
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 25 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 18 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 7 -
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 5 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 5 +-
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 2 +-
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 2 +-
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 2 +-
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 2 +-
drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 2 +-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +-
.../amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 248 +-
.../gpu/drm/amd/include/kgd_pp_interface.h | 8 +
drivers/gpu/drm/amd/pm/Makefile | 12 +-
drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2434 ++++++++---------
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c | 94 +
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 570 ++--
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 341 +--
.../gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h | 32 +
drivers/gpu/drm/amd/pm/legacy-dpm/Makefile | 32 +
.../pm/{powerplay => legacy-dpm}/cik_dpm.h | 0
.../amd/pm/{powerplay => legacy-dpm}/kv_dpm.c | 47 +-
.../amd/pm/{powerplay => legacy-dpm}/kv_dpm.h | 0
.../amd/pm/{powerplay => legacy-dpm}/kv_smc.c | 0
.../gpu/drm/amd/pm/legacy-dpm/legacy_dpm.c | 1081 ++++++++
.../gpu/drm/amd/pm/legacy-dpm/legacy_dpm.h | 38 +
.../amd/pm/{powerplay => legacy-dpm}/ppsmc.h | 0
.../pm/{powerplay => legacy-dpm}/r600_dpm.h | 0
.../amd/pm/{powerplay => legacy-dpm}/si_dpm.c | 163 +-
.../amd/pm/{powerplay => legacy-dpm}/si_dpm.h | 15 +-
.../amd/pm/{powerplay => legacy-dpm}/si_smc.c | 0
.../{powerplay => legacy-dpm}/sislands_smc.h | 0
drivers/gpu/drm/amd/pm/powerplay/Makefile | 4 -
.../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 51 +-
.../drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 10 +-
.../pm/{ => powerplay}/inc/amd_powerplay.h | 0
.../drm/amd/pm/{ => powerplay}/inc/cz_ppsmc.h | 0
.../amd/pm/{ => powerplay}/inc/fiji_ppsmc.h | 0
.../pm/{ => powerplay}/inc/hardwaremanager.h | 0
.../drm/amd/pm/{ => powerplay}/inc/hwmgr.h | 3 -
.../{ => powerplay}/inc/polaris10_pwrvirus.h | 0
.../amd/pm/{ => powerplay}/inc/power_state.h | 0
.../drm/amd/pm/{ => powerplay}/inc/pp_debug.h | 0
.../amd/pm/{ => powerplay}/inc/pp_endian.h | 0
.../amd/pm/{ => powerplay}/inc/pp_thermal.h | 0
.../amd/pm/{ => powerplay}/inc/ppinterrupt.h | 0
.../drm/amd/pm/{ => powerplay}/inc/rv_ppsmc.h | 0
.../drm/amd/pm/{ => powerplay}/inc/smu10.h | 0
.../pm/{ => powerplay}/inc/smu10_driver_if.h | 0
.../pm/{ => powerplay}/inc/smu11_driver_if.h | 0
.../gpu/drm/amd/pm/{ => powerplay}/inc/smu7.h | 0
.../drm/amd/pm/{ => powerplay}/inc/smu71.h | 0
.../pm/{ => powerplay}/inc/smu71_discrete.h | 0
.../drm/amd/pm/{ => powerplay}/inc/smu72.h | 0
.../pm/{ => powerplay}/inc/smu72_discrete.h | 0
.../drm/amd/pm/{ => powerplay}/inc/smu73.h | 0
.../pm/{ => powerplay}/inc/smu73_discrete.h | 0
.../drm/amd/pm/{ => powerplay}/inc/smu74.h | 0
.../pm/{ => powerplay}/inc/smu74_discrete.h | 0
.../drm/amd/pm/{ => powerplay}/inc/smu75.h | 0
.../pm/{ => powerplay}/inc/smu75_discrete.h | 0
.../amd/pm/{ => powerplay}/inc/smu7_common.h | 0
.../pm/{ => powerplay}/inc/smu7_discrete.h | 0
.../amd/pm/{ => powerplay}/inc/smu7_fusion.h | 0
.../amd/pm/{ => powerplay}/inc/smu7_ppsmc.h | 0
.../gpu/drm/amd/pm/{ => powerplay}/inc/smu8.h | 0
.../amd/pm/{ => powerplay}/inc/smu8_fusion.h | 0
.../gpu/drm/amd/pm/{ => powerplay}/inc/smu9.h | 0
.../pm/{ => powerplay}/inc/smu9_driver_if.h | 0
.../{ => powerplay}/inc/smu_ucode_xfer_cz.h | 0
.../{ => powerplay}/inc/smu_ucode_xfer_vi.h | 0
.../drm/amd/pm/{ => powerplay}/inc/smumgr.h | 0
.../amd/pm/{ => powerplay}/inc/tonga_ppsmc.h | 0
.../amd/pm/{ => powerplay}/inc/vega10_ppsmc.h | 0
.../inc/vega12/smu9_driver_if.h | 0
.../amd/pm/{ => powerplay}/inc/vega12_ppsmc.h | 0
.../amd/pm/{ => powerplay}/inc/vega20_ppsmc.h | 0
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 95 +-
.../amd/pm/{ => swsmu}/inc/aldebaran_ppsmc.h | 0
.../drm/amd/pm/{ => swsmu}/inc/amdgpu_smu.h | 15 +-
.../amd/pm/{ => swsmu}/inc/arcturus_ppsmc.h | 0
.../inc/smu11_driver_if_arcturus.h | 0
.../inc/smu11_driver_if_cyan_skillfish.h | 0
.../{ => swsmu}/inc/smu11_driver_if_navi10.h | 0
.../inc/smu11_driver_if_sienna_cichlid.h | 0
.../{ => swsmu}/inc/smu11_driver_if_vangogh.h | 0
.../amd/pm/{ => swsmu}/inc/smu12_driver_if.h | 0
.../inc/smu13_driver_if_aldebaran.h | 0
.../inc/smu13_driver_if_yellow_carp.h | 0
.../pm/{ => swsmu}/inc/smu_11_0_cdr_table.h | 0
.../drm/amd/pm/{ => swsmu}/inc/smu_types.h | 0
.../drm/amd/pm/{ => swsmu}/inc/smu_v11_0.h | 0
.../pm/{ => swsmu}/inc/smu_v11_0_7_ppsmc.h | 0
.../pm/{ => swsmu}/inc/smu_v11_0_7_pptable.h | 0
.../amd/pm/{ => swsmu}/inc/smu_v11_0_ppsmc.h | 0
.../pm/{ => swsmu}/inc/smu_v11_0_pptable.h | 0
.../amd/pm/{ => swsmu}/inc/smu_v11_5_pmfw.h | 0
.../amd/pm/{ => swsmu}/inc/smu_v11_5_ppsmc.h | 0
.../amd/pm/{ => swsmu}/inc/smu_v11_8_pmfw.h | 0
.../amd/pm/{ => swsmu}/inc/smu_v11_8_ppsmc.h | 0
.../drm/amd/pm/{ => swsmu}/inc/smu_v12_0.h | 0
.../amd/pm/{ => swsmu}/inc/smu_v12_0_ppsmc.h | 0
.../drm/amd/pm/{ => swsmu}/inc/smu_v13_0.h | 0
.../amd/pm/{ => swsmu}/inc/smu_v13_0_1_pmfw.h | 0
.../pm/{ => swsmu}/inc/smu_v13_0_1_ppsmc.h | 0
.../pm/{ => swsmu}/inc/smu_v13_0_pptable.h | 0
.../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 10 +-
.../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 9 +-
.../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 34 +-
.../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 11 +-
.../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 10 +-
.../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 15 +-
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 4 +
116 files changed, 3224 insertions(+), 2253 deletions(-)
create mode 100644 drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c
create mode 100644 drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h
create mode 100644 drivers/gpu/drm/amd/pm/legacy-dpm/Makefile
rename drivers/gpu/drm/amd/pm/{powerplay => legacy-dpm}/cik_dpm.h (100%)
rename drivers/gpu/drm/amd/pm/{powerplay => legacy-dpm}/kv_dpm.c (99%)
rename drivers/gpu/drm/amd/pm/{powerplay => legacy-dpm}/kv_dpm.h (100%)
rename drivers/gpu/drm/amd/pm/{powerplay => legacy-dpm}/kv_smc.c (100%)
create mode 100644 drivers/gpu/drm/amd/pm/legacy-dpm/legacy_dpm.c
create mode 100644 drivers/gpu/drm/amd/pm/legacy-dpm/legacy_dpm.h
rename drivers/gpu/drm/amd/pm/{powerplay => legacy-dpm}/ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{powerplay => legacy-dpm}/r600_dpm.h (100%)
rename drivers/gpu/drm/amd/pm/{powerplay => legacy-dpm}/si_dpm.c (98%)
rename drivers/gpu/drm/amd/pm/{powerplay => legacy-dpm}/si_dpm.h (99%)
rename drivers/gpu/drm/amd/pm/{powerplay => legacy-dpm}/si_smc.c (100%)
rename drivers/gpu/drm/amd/pm/{powerplay => legacy-dpm}/sislands_smc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/amd_powerplay.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/cz_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/fiji_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/hardwaremanager.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/hwmgr.h (99%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/polaris10_pwrvirus.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/power_state.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/pp_debug.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/pp_endian.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/pp_thermal.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/ppinterrupt.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/rv_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu10.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu10_driver_if.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu11_driver_if.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu7.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu71.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu71_discrete.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu72.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu72_discrete.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu73.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu73_discrete.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu74.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu74_discrete.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu75.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu75_discrete.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu7_common.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu7_discrete.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu7_fusion.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu7_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu8.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu8_fusion.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu9.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu9_driver_if.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu_ucode_xfer_cz.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smu_ucode_xfer_vi.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/smumgr.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/tonga_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/vega10_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/vega12/smu9_driver_if.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/vega12_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => powerplay}/inc/vega20_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/aldebaran_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/amdgpu_smu.h (99%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/arcturus_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu11_driver_if_arcturus.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu11_driver_if_cyan_skillfish.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu11_driver_if_navi10.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu11_driver_if_sienna_cichlid.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu11_driver_if_vangogh.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu12_driver_if.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu13_driver_if_aldebaran.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu13_driver_if_yellow_carp.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_11_0_cdr_table.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_types.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v11_0.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v11_0_7_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v11_0_7_pptable.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v11_0_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v11_0_pptable.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v11_5_pmfw.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v11_5_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v11_8_pmfw.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v11_8_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v12_0.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v12_0_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v13_0.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v13_0_1_pmfw.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v13_0_1_ppsmc.h (100%)
rename drivers/gpu/drm/amd/pm/{ => swsmu}/inc/smu_v13_0_pptable.h (100%)Signature · 1 line
2.29.0
PATCH v3 1/17 drm/amd/pm: do not expose implementation details to other blocks out of power
Those implementation details(whether swsmu supported, some ppt_funcs supported, accessing internal statistics ...)should be kept internally. It's not a good practice and even error prone to expose implementation details.
--- drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 25 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 18 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 7 -- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 5 +- drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 2 +- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 90 +++++++++++++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 25 +++++- drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 11 +-- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 26 +++--- 13 files changed, 161 insertions(+), 65 deletions(-)
drivers/gpu/drm/amd/amdgpu/aldebaran.c +1 -1
@@ -260,7 +260,7 @@ static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev) adev->gfx.rlc.funcs->resume (adev);/* Wait for FW reset event complete */ - r =smu_wait_for_event (adev,SMU_EVENT_RESET_COMPLETE ,0 ); + r =amdgpu_dpm_wait_for_event (adev,SMU_EVENT_RESET_COMPLETE ,0 );if (r) {dev_err (adev->dev,"Failed to get response from firmware after reset\n" );
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +14 -11
@@ -1585,22 +1585,25 @@ static int amdgpu_debugfs_sclk_set(void *data, u64 val)return ret; } -if (is_support_sw_smu (adev)) { - ret =smu_get_dpm_freq_range (&adev->smu,SMU_SCLK , &min_freq, &max_freq); -if (ret || val > max_freq || val < min_freq) -return -EINVAL ; - ret =smu_set_soft_freq_range (&adev->smu,SMU_SCLK , (uint32_t )val, (uint32_t )val); - }else { -return 0 ; + ret =amdgpu_dpm_get_dpm_freq_range (adev,PP_SCLK , &min_freq, &max_freq); +if (ret == -EOPNOTSUPP ) { + ret =0 ; + goto out; } +if (ret || val > max_freq || val < min_freq) { + ret = -EINVAL ; + goto out; + } + + ret =amdgpu_dpm_set_soft_freq_range (adev,PP_SCLK , (uint32_t )val, (uint32_t )val); +if (ret) + ret = -EINVAL ; +out:pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); -if (ret) -return -EINVAL ; - -return 0 ; +return ret; } DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
@@ -2617,7 +2617,7 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)if (adev->asic_type ==CHIP_ARCTURUS &&amdgpu_passthrough (adev) && adev->gmc.xgmi.num_physical_nodes >1 ) -smu_set_light_sbr (&adev->smu, true); +amdgpu_dpm_set_light_sbr (adev, true);if (adev->gmc.xgmi.num_physical_nodes >1 ) {mutex_lock (&mgpu_info.mutex);
@@ -2857,7 +2857,7 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)int i, r;if (adev->in_s0ix) -amdgpu_gfx_state_change_set (adev, sGpuChangeState_D3Entry); +amdgpu_dpm_gfx_state_change (adev, sGpuChangeState_D3Entry);for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.valid)
@@ -3982,7 +3982,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)return 0 ;if (adev->in_s0ix) -amdgpu_gfx_state_change_set (adev, sGpuChangeState_D0Entry); +amdgpu_dpm_gfx_state_change (adev, sGpuChangeState_D0Entry);/* post card */ if (amdgpu_device_need_post (adev)) {
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -17
@@ -615,7 +615,7 @@ int amdgpu_get_gfx_off_status(struct amdgpu_device *adev, uint32_t *value)mutex_lock (&adev->gfx.gfx_off_mutex); - r =smu_get_status_gfxoff (adev, value); + r =amdgpu_dpm_get_status_gfxoff (adev, value);mutex_unlock (&adev->gfx.gfx_off_mutex);
@@ -852,19 +852,3 @@ int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev) }return amdgpu_num_kcq; } - -/* amdgpu_gfx_state_change_set - Handle gfx power state change set -* @adev: amdgpu_device pointer -* @state: gfx power state(1 -sGpuChangeState_D0Entry and 2 -sGpuChangeState_D3Entry) -* -*/ - -void amdgpu_gfx_state_change_set (struct amdgpu_device *adev,enum gfx_change_state state) -{ -mutex_lock (&adev->pm.mutex); -if (adev->powerplay.pp_funcs && - adev->powerplay.pp_funcs->gfx_state_change_set) - ((adev)->powerplay.pp_funcs->gfx_state_change_set ( - (adev)->powerplay.pp_handle, state)); -mutex_unlock (&adev->pm.mutex); -}
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0 -7
@@ -47,12 +47,6 @@ enum amdgpu_gfx_pipe_priority { AMDGPU_GFX_PIPE_PRIO_HIGH = AMDGPU_RING_PRIO_2 }; -/* Argument for PPSMC_MSG_GpuChangeState */ -enum gfx_change_state { - sGpuChangeState_D0Entry =1 , - sGpuChangeState_D3Entry, -}; -#define AMDGPU_GFX_QUEUE_PRIORITY_MINIMUM 0#define AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM 15
@@ -410,5 +404,4 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v);int amdgpu_gfx_get_num_kcq (struct amdgpu_device *adev); -void amdgpu_gfx_state_change_set (struct amdgpu_device *adev,enum gfx_change_state state);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -3
@@ -901,7 +901,7 @@ static void amdgpu_ras_get_ecc_info(struct amdgpu_device *adev, struct ras_err_d* choosing right query method according to * whether smu support query error information */ - ret =smu_get_ecc_info (&adev->smu, (void *)&(ras->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(ras->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)
@@ -2132,8 +2132,7 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)if (ret) goto free; -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->send_hbm_bad_pages_num) - adev->smu.ppt_funcs->send_hbm_bad_pages_num (&adev->smu, con->eeprom_control.ras_num_recs); +amdgpu_dpm_send_hbm_bad_pages_num (adev, con->eeprom_control.ras_num_recs); }#ifdef CONFIG_X86_MCE_AMD
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -3
@@ -97,7 +97,7 @@ int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,int ret =0 ;kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); - ret =smu_get_ecc_info (&adev->smu, (void *)&(con->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(con->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)
@@ -160,8 +160,7 @@ int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev, err_data->err_addr_cnt);amdgpu_ras_save_bad_pages (adev); -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->send_hbm_bad_pages_num) - adev->smu.ppt_funcs->send_hbm_bad_pages_num (&adev->smu, con->eeprom_control.ras_num_recs); +amdgpu_dpm_send_hbm_bad_pages_num (adev, con->eeprom_control.ras_num_recs); }amdgpu_ras_reset_gpu (adev);
drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c +1 -1
@@ -222,7 +222,7 @@ void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev, len =snprintf (fifo_in,sizeof (fifo_in),"%x %llx:%llx\n" ,KFD_SMI_EVENT_THERMAL_THROTTLE , throttle_bitmask, -atomic64_read (&dev->adev->smu.throttle_int_counter)); +amdgpu_dpm_get_thermal_throttling_counter (dev->adev));add_event_to_kfifo (dev,KFD_SMI_EVENT_THERMAL_THROTTLE , fifo_in, len); }
drivers/gpu/drm/amd/include/kgd_pp_interface.h +4 -0
@@ -26,6 +26,10 @@extern const struct amdgpu_ip_block_version pp_smu_ip_block; +enum smu_event_type { +SMU_EVENT_RESET_COMPLETE =0 , +}; +struct amd_vce_state {/* vce clocks */ u32 evclk;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +90 -0
93 lines not on this page · raw message
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +24 -1
@@ -23,6 +23,12 @@#ifndef __AMDGPU_DPM_H__#define __AMDGPU_DPM_H__ +/* Argument for PPSMC_MSG_GpuChangeState */ +enum gfx_change_state { + sGpuChangeState_D0Entry =1 , + sGpuChangeState_D3Entry, +}; +enum amdgpu_int_thermal_type {THERMAL_TYPE_NONE , THERMAL_TYPE_EXTERNAL,
@@ -574,5 +580,22 @@ void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable);void amdgpu_dpm_enable_jpeg (struct amdgpu_device *adev,bool enable);void amdgpu_pm_print_power_states (struct amdgpu_device *adev);int amdgpu_pm_load_smu_firmware (struct amdgpu_device *adev,uint32_t *smu_version); - +int amdgpu_dpm_set_light_sbr (struct amdgpu_device *adev,bool enable); +int amdgpu_dpm_send_hbm_bad_pages_num (struct amdgpu_device *adev,uint32_t size); +int amdgpu_dpm_get_dpm_freq_range (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t *min, +uint32_t *max); +int amdgpu_dpm_set_soft_freq_range (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t min, +uint32_t max); +int amdgpu_dpm_wait_for_event (struct amdgpu_device *adev,enum smu_event_type event, +uint64_t event_arg); +int amdgpu_dpm_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value); +uint64_t amdgpu_dpm_get_thermal_throttling_counter (struct amdgpu_device *adev); +void amdgpu_dpm_gfx_state_change (struct amdgpu_device *adev, +enum gfx_change_state state); +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc);#endif
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +3 -8
@@ -241,11 +241,6 @@ struct smu_user_dpm_profile {uint32_t clk_dependency; }; -enum smu_event_type { - -SMU_EVENT_RESET_COMPLETE =0 , -}; -#define SMU_TABLE_INIT (tables, table_id, s, a, d) \ do { \ tables[table_id].size = s; \
@@ -1412,15 +1407,15 @@ int smu_set_ac_dc(struct smu_context *smu);int smu_allow_xgmi_power_down (struct smu_context *smu,bool en); -int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value); +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value);int smu_set_light_sbr (struct smu_context *smu,bool enable); -int smu_wait_for_event (struct amdgpu_device *adev,enum smu_event_type event, +int smu_wait_for_event (struct smu_context *smu,enum smu_event_type event,uint64_t event_arg);int smu_get_ecc_info (struct smu_context *smu,void *umc_ecc);int smu_stb_collect_info (struct smu_context *smu,void *buff,uint32_t size);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);#endif #endif
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +16 -10
@@ -100,17 +100,14 @@ static int smu_sys_set_pp_feature_mask(void *handle,return ret; } -int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value) +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value) { -int ret =0 ; -struct smu_context *smu = &adev->smu; +if (!smu->ppt_funcs->get_gfx_off_status) +return -EINVAL ; -if (is_support_sw_smu (adev) && smu->ppt_funcs->get_gfx_off_status) - *value =smu_get_gfx_off_status (smu); -else - ret = -EINVAL ; + *value =smu_get_gfx_off_status (smu); -return ret; +return 0 ; } int smu_set_soft_freq_range(struct smu_context *smu,
@@ -3167,11 +3164,10 @@ static const struct amd_pm_funcs swsmu_pm_funcs = { .get_smu_prv_buf_details = smu_get_prv_buffer_details, }; -int smu_wait_for_event (struct amdgpu_device *adev,enum smu_event_type event, +int smu_wait_for_event (struct smu_context *smu,enum smu_event_type event,uint64_t event_arg) {int ret = -EINVAL ; -struct smu_context *smu = &adev->smu;if (smu->ppt_funcs->wait_for_event) {mutex_lock (&smu->mutex);
@@ -3285,3 +3281,13 @@ void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev)#endif } + +int smu_send_hbm_bad_pages_num (struct smu_context *smu,uint32_t size) +{ +int ret =0 ; + +if (smu->ppt_funcs && smu->ppt_funcs->send_hbm_bad_pages_num) + ret = smu->ppt_funcs->send_hbm_bad_pages_num (smu, size); + +return ret; +}
Signature · 1 line
2.29.0
Re: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of power
Quoted 27 lines · Evan Quan
Those implementation
details(whether swsmu supported, some ppt_funcs supported, accessing internal statistics ...)should be kept internally. It's not a good practice and even error prone to expose implementation details.Signed-off-by Evan Quan <[email protected]>Change-Id Ibca3462ceaa26a27a9145282b60c6ce5deca7752--- drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 25 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 18 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 7 -- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 5 +- drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 2 +- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 90 +++++++++++++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 25 +++++- drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 11 +-- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 26 +++--- 13 files changed, 161 insertions(+), 65 deletions(-)drivers/gpu/drm/amd/amdgpu/aldebaran.c +0
-0
drivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev) · line 263
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c +1
-1@@ -260,7 +260,7 @@ static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev) adev->gfx.rlc.funcs->resume (adev);/* Wait for FW reset event complete */ - r =smu_wait_for_event (adev,SMU_EVENT_RESET_COMPLETE ,0 ); + r =amdgpu_dpm_wait_for_event (adev,SMU_EVENT_RESET_COMPLETE ,0 );
Hi Evan,
As mentioned in the earlier comments, I suggest you to leave these newer APIs and take care of the rest of the APIs. These may be covered as amdgpu_smu* in another patch set. Till that time, it's not needed to move them to amdgpu_dpm (as mentioned before, some of them are are not even remotely related to power management).
Thanks,
Lijo
Quoted 434 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c +0
-0if (r) {dev_err (adev->dev,"Failed to get response from firmware after reset\n" );drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +14
-11@@ -1585,22 +1585,25 @@ static int amdgpu_debugfs_sclk_set(void *data, u64 val)return ret; } -if (is_support_sw_smu (adev)) { - ret =smu_get_dpm_freq_range (&adev->smu,SMU_SCLK , &min_freq, &max_freq); -if (ret || val > max_freq || val < min_freq) -return -EINVAL ; - ret =smu_set_soft_freq_range (&adev->smu,SMU_SCLK , (uint32_t )val, (uint32_t )val); - }else { -return 0 ; + ret =amdgpu_dpm_get_dpm_freq_range (adev,PP_SCLK , &min_freq, &max_freq); +if (ret == -EOPNOTSUPP ) { + ret =0 ; + goto out; } +if (ret || val > max_freq || val < min_freq) { + ret = -EINVAL ; + goto out; + } + + ret =amdgpu_dpm_set_soft_freq_range (adev,PP_SCLK , (uint32_t )val, (uint32_t )val); +if (ret) + ret = -EINVAL ; +out:pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); -if (ret) -return -EINVAL ; - -return 0 ; +return ret; } DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-3@@ -2617,7 +2617,7 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)if (adev->asic_type ==CHIP_ARCTURUS &&amdgpu_passthrough (adev) && adev->gmc.xgmi.num_physical_nodes >1 ) -smu_set_light_sbr (&adev->smu, true); +amdgpu_dpm_set_light_sbr (adev, true);if (adev->gmc.xgmi.num_physical_nodes >1 ) {mutex_lock (&mgpu_info.mutex);@@ -2857,7 +2857,7 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)int i, r;if (adev->in_s0ix) -amdgpu_gfx_state_change_set (adev, sGpuChangeState_D3Entry); +amdgpu_dpm_gfx_state_change (adev, sGpuChangeState_D3Entry);for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.valid)@@ -3982,7 +3982,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)return 0 ;if (adev->in_s0ix) -amdgpu_gfx_state_change_set (adev, sGpuChangeState_D0Entry); +amdgpu_dpm_gfx_state_change (adev, sGpuChangeState_D0Entry);/* post card */ if (amdgpu_device_need_post (adev)) {drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-17@@ -615,7 +615,7 @@ int amdgpu_get_gfx_off_status(struct amdgpu_device *adev, uint32_t *value)mutex_lock (&adev->gfx.gfx_off_mutex); - r =smu_get_status_gfxoff (adev, value); + r =amdgpu_dpm_get_status_gfxoff (adev, value);mutex_unlock (&adev->gfx.gfx_off_mutex);@@ -852,19 +852,3 @@ int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev) }return amdgpu_num_kcq; } - -/* amdgpu_gfx_state_change_set - Handle gfx power state change set -* @adev: amdgpu_device pointer -* @state: gfx power state(1 -sGpuChangeState_D0Entry and 2 -sGpuChangeState_D3Entry) -* -*/ - -void amdgpu_gfx_state_change_set (struct amdgpu_device *adev,enum gfx_change_state state) -{ -mutex_lock (&adev->pm.mutex); -if (adev->powerplay.pp_funcs && - adev->powerplay.pp_funcs->gfx_state_change_set) - ((adev)->powerplay.pp_funcs->gfx_state_change_set ( - (adev)->powerplay.pp_handle, state)); -mutex_unlock (&adev->pm.mutex); -}drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-7@@ -47,12 +47,6 @@ enum amdgpu_gfx_pipe_priority { AMDGPU_GFX_PIPE_PRIO_HIGH = AMDGPU_RING_PRIO_2 }; -/* Argument for PPSMC_MSG_GpuChangeState */ -enum gfx_change_state { - sGpuChangeState_D0Entry =1 , - sGpuChangeState_D3Entry, -}; -#define AMDGPU_GFX_QUEUE_PRIORITY_MINIMUM 0#define AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM 15@@ -410,5 +404,4 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v);int amdgpu_gfx_get_num_kcq (struct amdgpu_device *adev); -void amdgpu_gfx_state_change_set (struct amdgpu_device *adev,enum gfx_change_state state);#endif drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2
-3@@ -901,7 +901,7 @@ static void amdgpu_ras_get_ecc_info(struct amdgpu_device *adev, struct ras_err_d* choosing right query method according to * whether smu support query error information */ - ret =smu_get_ecc_info (&adev->smu, (void *)&(ras->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(ras->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)@@ -2132,8 +2132,7 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)if (ret) goto free; -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->send_hbm_bad_pages_num) - adev->smu.ppt_funcs->send_hbm_bad_pages_num (&adev->smu, con->eeprom_control.ras_num_recs); +amdgpu_dpm_send_hbm_bad_pages_num (adev, con->eeprom_control.ras_num_recs); }#ifdef CONFIG_X86_MCE_AMD drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2
-3@@ -97,7 +97,7 @@ int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev,int ret =0 ;kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); - ret =smu_get_ecc_info (&adev->smu, (void *)&(con->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(con->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)@@ -160,8 +160,7 @@ int amdgpu_umc_process_ras_data_cb(struct amdgpu_device *adev, err_data->err_addr_cnt);amdgpu_ras_save_bad_pages (adev); -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->send_hbm_bad_pages_num) - adev->smu.ppt_funcs->send_hbm_bad_pages_num (&adev->smu, con->eeprom_control.ras_num_recs); +amdgpu_dpm_send_hbm_bad_pages_num (adev, con->eeprom_control.ras_num_recs); }amdgpu_ras_reset_gpu (adev);drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c +1
-1@@ -222,7 +222,7 @@ void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev, len =snprintf (fifo_in,sizeof (fifo_in),"%x %llx:%llx\n" ,KFD_SMI_EVENT_THERMAL_THROTTLE , throttle_bitmask, -atomic64_read (&dev->adev->smu.throttle_int_counter)); +amdgpu_dpm_get_thermal_throttling_counter (dev->adev));add_event_to_kfifo (dev,KFD_SMI_EVENT_THERMAL_THROTTLE , fifo_in, len); }drivers/gpu/drm/amd/include/kgd_pp_interface.h +4
-0@@ -26,6 +26,10 @@extern const struct amdgpu_ip_block_version pp_smu_ip_block; +enum smu_event_type { +SMU_EVENT_RESET_COMPLETE =0 , +}; +struct amd_vce_state {/* vce clocks */ u32 evclk;drivers/gpu/drm/amd/pm/amdgpu_dpm.c +90
-0@@ -1614,3 +1614,93 @@ int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versioreturn 0 ; } + +int amdgpu_dpm_set_light_sbr (struct amdgpu_device *adev,bool enable) +{ +return smu_set_light_sbr (&adev->smu, enable); +} + +int amdgpu_dpm_send_hbm_bad_pages_num (struct amdgpu_device *adev,uint32_t size) +{ +return smu_send_hbm_bad_pages_num (&adev->smu, size); +} + +int amdgpu_dpm_get_dpm_freq_range (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t *min, +uint32_t *max) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +switch (type) { +case PP_SCLK : +return smu_get_dpm_freq_range (&adev->smu,SMU_SCLK , min, max); +default : +return -EINVAL ; + } +} + +int amdgpu_dpm_set_soft_freq_range (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t min, +uint32_t max) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +switch (type) { +case PP_SCLK : +return smu_set_soft_freq_range (&adev->smu,SMU_SCLK , min, max); +default : +return -EINVAL ; + } +} + +int amdgpu_dpm_wait_for_event (struct amdgpu_device *adev, +enum smu_event_type event, +uint64_t event_arg) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_wait_for_event (&adev->smu, event, event_arg); +} + +int amdgpu_dpm_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_get_status_gfxoff (&adev->smu, value); +} + +uint64_t amdgpu_dpm_get_thermal_throttling_counter (struct amdgpu_device *adev) +{ +return atomic64_read (&adev->smu.throttle_int_counter); +} + +/* amdgpu_dpm_gfx_state_change - Handle gfx power state change set +* @adev: amdgpu_device pointer +* @state: gfx power state(1 -sGpuChangeState_D0Entry and 2 -sGpuChangeState_D3Entry) +* +*/ +void amdgpu_dpm_gfx_state_change (struct amdgpu_device *adev, +enum gfx_change_state state) +{ +mutex_lock (&adev->pm.mutex); +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->gfx_state_change_set) + ((adev)->powerplay.pp_funcs->gfx_state_change_set ( + (adev)->powerplay.pp_handle, state)); +mutex_unlock (&adev->pm.mutex); +} + +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_get_ecc_info (&adev->smu, umc_ecc); +}drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +24
-1@@ -23,6 +23,12 @@#ifndef __AMDGPU_DPM_H__#define __AMDGPU_DPM_H__ +/* Argument for PPSMC_MSG_GpuChangeState */ +enum gfx_change_state { + sGpuChangeState_D0Entry =1 , + sGpuChangeState_D3Entry, +}; +enum amdgpu_int_thermal_type {THERMAL_TYPE_NONE , THERMAL_TYPE_EXTERNAL,@@ -574,5 +580,22 @@ void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable);void amdgpu_dpm_enable_jpeg (struct amdgpu_device *adev,bool enable);void amdgpu_pm_print_power_states (struct amdgpu_device *adev);int amdgpu_pm_load_smu_firmware (struct amdgpu_device *adev,uint32_t *smu_version); - +int amdgpu_dpm_set_light_sbr (struct amdgpu_device *adev,bool enable); +int amdgpu_dpm_send_hbm_bad_pages_num (struct amdgpu_device *adev,uint32_t size); +int amdgpu_dpm_get_dpm_freq_range (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t *min, +uint32_t *max); +int amdgpu_dpm_set_soft_freq_range (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t min, +uint32_t max); +int amdgpu_dpm_wait_for_event (struct amdgpu_device *adev,enum smu_event_type event, +uint64_t event_arg); +int amdgpu_dpm_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value); +uint64_t amdgpu_dpm_get_thermal_throttling_counter (struct amdgpu_device *adev); +void amdgpu_dpm_gfx_state_change (struct amdgpu_device *adev, +enum gfx_change_state state); +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc);#endif drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +3
-8@@ -241,11 +241,6 @@ struct smu_user_dpm_profile {uint32_t clk_dependency; }; -enum smu_event_type { - -SMU_EVENT_RESET_COMPLETE =0 , -}; -#define SMU_TABLE_INIT (tables, table_id, s, a, d) \ do { \ tables[table_id].size = s; \@@ -1412,15 +1407,15 @@ int smu_set_ac_dc(struct smu_context *smu);int smu_allow_xgmi_power_down (struct smu_context *smu,bool en); -int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value); +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value);int smu_set_light_sbr (struct smu_context *smu,bool enable); -int smu_wait_for_event (struct amdgpu_device *adev,enum smu_event_type event, +int smu_wait_for_event (struct smu_context *smu,enum smu_event_type event,uint64_t event_arg);int smu_get_ecc_info (struct smu_context *smu,void *umc_ecc);int smu_stb_collect_info (struct smu_context *smu,void *buff,uint32_t size);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);#endif #endif drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +16
-10@@ -100,17 +100,14 @@ static int smu_sys_set_pp_feature_mask(void *handle,return ret; } -int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value) +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value) { -int ret =0 ; -struct smu_context *smu = &adev->smu; +if (!smu->ppt_funcs->get_gfx_off_status) +return -EINVAL ; -if (is_support_sw_smu (adev) && smu->ppt_funcs->get_gfx_off_status) - *value =smu_get_gfx_off_status (smu); -else - ret = -EINVAL ; + *value =smu_get_gfx_off_status (smu); -return ret; +return 0 ; } int smu_set_soft_freq_range(struct smu_context *smu,@@ -3167,11 +3164,10 @@ static const struct amd_pm_funcs swsmu_pm_funcs = { .get_smu_prv_buf_details = smu_get_prv_buffer_details, }; -int smu_wait_for_event (struct amdgpu_device *adev,enum smu_event_type event, +int smu_wait_for_event (struct smu_context *smu,enum smu_event_type event,uint64_t event_arg) {int ret = -EINVAL ; -struct smu_context *smu = &adev->smu;if (smu->ppt_funcs->wait_for_event) {mutex_lock (&smu->mutex);@@ -3285,3 +3281,13 @@ void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev)#endif } + +int smu_send_hbm_bad_pages_num (struct smu_context *smu,uint32_t size) +{ +int ret =0 ; + +if (smu->ppt_funcs && smu->ppt_funcs->send_hbm_bad_pages_num) + ret = smu->ppt_funcs->send_hbm_bad_pages_num (smu, size); + +return ret; +}
RE: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of power
[AMD Official Use Only]
Quoted 50 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, December 2, 2021 12:13 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of powerQuoted 3 lines · Evan Quan
Those implementation
details(whether swsmu supported, some ppt_funcs supported, accessing internal statistics ...)should be kept internally. It's not a good practice and even error prone to exposeimplementation details.
Quoted 14 lines
Signed-off-by Evan Quan <[email protected]>Change-Id Ibca3462ceaa26a27a9145282b60c6ce5deca7752--- drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 25 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 18 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 7 -- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 5 +- drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 2 +- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 90+++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct
Quoted 11 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 25 +++++- drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 11 +-- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 26 +++--- 13 files changed, 161 insertions(+), 65 deletions(-)drivers/gpu/drm/amd/amdgpu/aldebaran.c +0
-0@@ -260,7 +260,7 @@ static int aldebaran_mode2_restore_ip(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c +1
-1adev->gfx.rlc.funcs->resume (adev);/* Wait for FW reset event complete */ - r =smu_wait_for_event (adev,SMU_EVENT_RESET_COMPLETE ,0 ); + r = amdgpu_dpm_wait_for_event(adev,
SMU_EVENT_RESET_COMPLETE, 0);
Quoted 7 lines
Hi Evan,
As mentioned in the earlier comments, I suggest you to leave these newer APIs and take care of the rest of the APIs. These may be covered as amdgpu_smu* in another patch set. Till that time, it's not needed to move them to
amdgpu_dpm(as mentioned before, some of them are are not even remotely related to power management).
[Quan, Evan] This patch series highly relies on such change. That is swsmu is another framework as powerplay and all access should come through amdgpu_dpm.c. More specifically, patch 13 and 17 directly relies on this.
Further more, without the unified lock protection from patch 17, the changes for dropping unneeded locks(which had been in my local branch) will be impossible.
I'm fine with the idea that naming those APIs supported by swsmu only with prefix amdgpu_smu*. But that has to be done after this patch series. And I would expect those APIs are located in amdgpu_dpm.c(instead of amdgpu_smu.c) also.
BR
Evan
Quoted 511 lines
Thanks,
Lijodrivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev) · line 266
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c +0
-0if (r) {dev_err (adev->dev,"Failed to get response from firmware after reset\n" );diff --git
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data,
Quoted 6 lines
a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index164d6a9e9fbb..0d1f00b24aae100644drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1585,22 +1585,25 @@ static int amdgpu_debugfs_sclk_set(void *data,u64 val)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-2return ret; } -if (is_support_sw_smu (adev)) { - ret = smu_get_dpm_freq_range(&adev->smu, SMU_SCLK,
&min_freq,&max_freq);drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-3-if (ret || val > max_freq || val < min_freq) -return -EINVAL ; - ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK,(uint32_t)val, (uint32_t)val);
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2- }else { -return 0 ; + ret = amdgpu_dpm_get_dpm_freq_range(adev, PP_SCLK,
&min_freq,&max_freq);drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+if (ret == -EOPNOTSUPP ) { + ret =0 ; + goto out; } +if (ret || val > max_freq || val < min_freq) { + ret = -EINVAL ; + goto out; + } + + ret = amdgpu_dpm_set_soft_freq_range(adev, PP_SCLK,(uint32_t)val, (uint32_t)val);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_late_init(struct
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-4+if (ret) + ret = -EINVAL ; +out:pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); -if (ret) -return -EINVAL ; - -return 0 ; +return ret; } DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index1989f9e9379e..41cc1ffb5809100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -2617,7 +2617,7 @@ static int amdgpu_device_ip_late_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1if (adev->asic_type ==CHIP_ARCTURUS &&amdgpu_passthrough (adev) && adev->gmc.xgmi.num_physical_nodes >1 ) -smu_set_light_sbr (&adev->smu, true); +amdgpu_dpm_set_light_sbr (adev, true);if (adev->gmc.xgmi.num_physical_nodes >1 ) {mutex_lock (&mgpu_info.mutex);@@ -2857,7 +2857,7 @@ static int
amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1int i, r;if (adev->in_s0ix) - amdgpu_gfx_state_change_set(adev,
sGpuChangeState_D3Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int · line 2860
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+ amdgpu_dpm_gfx_state_change(adev,
sGpuChangeState_D3Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.valid)@@ -3982,7 +3982,7 @@ int amdgpu_device_resume(struct drm_device*dev, bool fbcon)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1return 0 ;if (adev->in_s0ix) - amdgpu_gfx_state_change_set(adev,
sGpuChangeState_D0Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3985
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+ amdgpu_dpm_gfx_state_change(adev,
sGpuChangeState_D0Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_get_gfx_off_status(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0/* post card */ if (amdgpu_device_need_post(adev)) { diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index1916ec84dd71..3d8f82dc8c97100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0@@ -615,7 +615,7 @@ int amdgpu_get_gfx_off_status(struct
amdgpu_devicedrivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_get_num_kcq(struct
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1*adev, uint32_t *value)mutex_lock (&adev->gfx.gfx_off_mutex); - r =smu_get_status_gfxoff (adev, value); + r =amdgpu_dpm_get_status_gfxoff (adev, value);mutex_unlock (&adev->gfx.gfx_off_mutex);@@ -852,19 +852,3 @@ int amdgpu_gfx_get_num_kcq(struct
amdgpu_device*adev)Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-9}return amdgpu_num_kcq; } - -/* amdgpu_gfx_state_change_set - Handle gfx power state change set -* @adev: amdgpu_device pointer -* @state: gfx power state(1 -sGpuChangeState_D0Entry and 2 -sGpuChangeState_D3Entry) -* -*/ - -void amdgpu_gfx_state_change_set(struct amdgpu_device *adev, enum
gfx_change_statestate) -{drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-7-mutex_lock (&adev->pm.mutex); -if (adev->powerplay.pp_funcs && - adev->powerplay.pp_funcs->gfx_state_change_set) - ((adev)->powerplay.pp_funcs->gfx_state_change_set ( - (adev)->powerplay.pp_handle, state)); -mutex_unlock (&adev->pm.mutex); -}drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h enum amdgpu_gfx_pipe_priority { · line 50
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-1@@ -47,12 +47,6 @@ enum amdgpu_gfx_pipe_priority { AMDGPU_GFX_PIPE_PRIO_HIGH = AMDGPU_RING_PRIO_2 }; -/* Argument for PPSMC_MSG_GpuChangeState */ -enum
gfx_change_state{drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h int amdgpu_gfx_cp_ecc_error_irq(struct
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-4- sGpuChangeState_D0Entry =1 , - sGpuChangeState_D3Entry, -}; -#define AMDGPU_GFX_QUEUE_PRIORITY_MINIMUM 0#define AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM 15@@ -410,5 +404,4 @@ int amdgpu_gfx_cp_ecc_error_irq(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h int amdgpu_gfx_cp_ecc_error_irq(struct · line 405
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg); void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg,
uint32_tv);Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0int amdgpu_gfx_get_num_kcq (struct amdgpu_device *adev); -voidamdgpu_gfx_state_change_set(struct
amdgpu_device*adev, enum
gfx_change_statestate);drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_get_ecc_info(struct
Quoted 7 lines
#endifdrivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-0@@ -901,7 +901,7 @@ static void amdgpu_ras_get_ecc_info(struct
amdgpu_device*adev, structras_err_ddrivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_recovery_init(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1
-1* choosing right query method according to * whether smu support query error information */ - ret =smu_get_ecc_info (&adev->smu, (void *)&(ras->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(ras->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)@@ -2132,8 +2132,7 @@ int amdgpu_ras_recovery_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-2if (ret) goto free; -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs- send_hbm_bad_pages_num) - adev->smu.ppt_funcs-send_hbm_bad_pages_num(&adev->smu, con-
eeprom_control.ras_num_recs);drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2
-0+amdgpu_dpm_send_hbm_bad_pages_num (adev, +con->eeprom_control.ras_num_recs); }#ifdef CONFIG_X86_MCE_AMD drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0
-0@@ -97,7 +97,7 @@ int amdgpu_umc_process_ras_data_cb(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1
-1int ret =0 ;kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); - ret =smu_get_ecc_info (&adev->smu, (void *)&(con->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(con->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)@@ -160,8 +160,7 @@ int amdgpu_umc_process_ras_data_cb(struct
amdgpu_device*adev,Quoted 27 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0
-2err_data->err_addr_cnt);amdgpu_ras_save_bad_pages (adev); -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs- send_hbm_bad_pages_num) - adev->smu.ppt_funcs-send_hbm_bad_pages_num(&adev->smu, con-
eeprom_control.ras_num_recs);drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2
-0+amdgpu_dpm_send_hbm_bad_pages_num (adev, +con->eeprom_control.ras_num_recs); }amdgpu_ras_reset_gpu (adev);drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c +1
-1@@ -222,7 +222,7 @@ void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev, len =snprintf (fifo_in,sizeof (fifo_in),"%x %llx:%llx\n" ,KFD_SMI_EVENT_THERMAL_THROTTLE , throttle_bitmask, -atomic64_read (&dev->adev->smu.throttle_int_counter)); +amdgpu_dpm_get_thermal_throttling_counter (dev- adev));Quoted 1 line
add_event_to_kfifo(dev,
KFD_SMI_EVENT_THERMAL_THROTTLE,fifo_in, len);Quoted 27 lines
}drivers/gpu/drm/amd/include/kgd_pp_interface.h +4
-0@@ -26,6 +26,10 @@extern const struct amdgpu_ip_block_version pp_smu_ip_block; +enum smu_event_type { +SMU_EVENT_RESET_COMPLETE =0 , +}; +struct amd_vce_state {/* vce clocks */ u32 evclk;drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1614,3 +1614,93 @@ int amdgpu_pm_load_smu_firmware(struct
amdgpu_device*adev,uint32_t*smu_versioreturn 0; }drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-0+ +int amdgpu_dpm_set_light_sbr(struct amdgpu_device *adev, boolenable)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+{ +return smu_set_light_sbr (&adev->smu, enable); } + +int amdgpu_dpm_send_hbm_bad_pages_num(struct amdgpu_device*adev,
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+uint32_t size) { +return smu_send_hbm_bad_pages_num (&adev->smu, size); } + +int amdgpu_dpm_get_dpm_freq_range(struct amdgpu_device *adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+enum pp_clock_type type, + uint32_t *min, + uint32_t *max) +{ + if (!is_support_sw_smu(adev)) + return -EOPNOTSUPP; + +switch (type) { +case PP_SCLK : + return smu_get_dpm_freq_range(&adev->smu, SMU_SCLK,min, max);
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +6
-0+default : +return -EINVAL ; + } +} + +int amdgpu_dpm_set_soft_freq_range(struct amdgpu_device *adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+enum pp_clock_type type, + uint32_t min, + uint32_t max) +{ + if (!is_support_sw_smu(adev)) + return -EOPNOTSUPP; + +switch (type) { +case PP_SCLK : + return smu_set_soft_freq_range(&adev->smu, SMU_SCLK,min, max);
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+default : +return -EINVAL ; + } +} +drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+int amdgpu_dpm_wait_for_event (struct amdgpu_device *adev, +enum smu_event_type event, +uint64_t event_arg) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_wait_for_event (&adev->smu, event, event_arg); } + +int amdgpu_dpm_get_status_gfxoff(struct amdgpu_device *adev,
uint32_tQuoted 41 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +35
-0+*value) { +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_get_status_gfxoff (&adev->smu, value); } + +uint64_t amdgpu_dpm_get_thermal_throttling_counter (struct +amdgpu_device *adev) { +return atomic64_read (&adev->smu.throttle_int_counter); +} + +/* amdgpu_dpm_gfx_state_change - Handle gfx power state change set +* @adev: amdgpu_device pointer +* @state: gfx power state(1 -sGpuChangeState_D0Entry and 2 +-sGpuChangeState_D3Entry) +* +*/ +void amdgpu_dpm_gfx_state_change (struct amdgpu_device *adev, +enum gfx_change_state state) +{ +mutex_lock (&adev->pm.mutex); +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->gfx_state_change_set) + ((adev)->powerplay.pp_funcs->gfx_state_change_set ( + (adev)->powerplay.pp_handle, state)); +mutex_unlock (&adev->pm.mutex); +} + +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_get_ecc_info (&adev->smu, umc_ecc); }drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h line 26
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0@@ -23,6 +23,12 @@#ifndef __AMDGPU_DPM_H__#define __AMDGPU_DPM_H__ +/* Argument for PPSMC_MSG_GpuChangeState */ enum
gfx_change_state{drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct
Quoted 8 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +4
-0+ sGpuChangeState_D0Entry =1 , + sGpuChangeState_D3Entry, +}; +enum amdgpu_int_thermal_type {THERMAL_TYPE_NONE , THERMAL_TYPE_EXTERNAL,@@ -574,5 +580,22 @@ void amdgpu_dpm_enable_vce(struct
amdgpu_device*adev, bool enable);drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 580
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_dpm_enable_jpeg(struct amdgpu_device *adev, boolenable);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 582
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_pm_print_power_states (struct amdgpu_device *adev); int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev,
uint32_tdrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 585
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-1*smu_version); - +int amdgpu_dpm_set_light_sbr (struct amdgpu_device *adev,bool +enable); int amdgpu_dpm_send_hbm_bad_pages_num(struct
amdgpu_devicedrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 586
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+*adev, uint32_t size); int amdgpu_dpm_get_dpm_freq_range(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable);
Quoted 8 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8
-0+enum pp_clock_type type, + uint32_t *min, + uint32_t *max); +int amdgpu_dpm_set_soft_freq_range (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t min, +uint32_t max); +int amdgpu_dpm_wait_for_event(struct amdgpu_device *adev, enum
smu_event_typeevent,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 596
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0+ uint64_t event_arg); +int amdgpu_dpm_get_status_gfxoff(struct amdgpu_device *adev,
uint32_tdrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 598
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0+*value); uint64_t amdgpu_dpm_get_thermal_throttling_counter(struct +amdgpu_device *adev); void amdgpu_dpm_gfx_state_change(struct
amdgpu_device*adev,Quoted 24 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +3
-0+ enum gfx_change_state state); +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc);#endifdrivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0
-5@@ -241,11 +241,6 @@ struct smu_user_dpm_profile {uint32_t clk_dependency; }; -enum smu_event_type { - -SMU_EVENT_RESET_COMPLETE =0 , -}; -#define SMU_TABLE_INIT (tables, table_id, s, a, d) \ do { \ tables[table_id].size = s; \@@ -1412,15 +1407,15 @@ int smu_set_ac_dc(struct smu_context *smu);int smu_allow_xgmi_power_down (struct smu_context *smu,bool en);drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h int smu_set_ac_dc(struct smu_context *smu); · line 1416
Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2
-2-int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value); +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value);int smu_set_light_sbr (struct smu_context *smu,bool enable); -int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event, +int smu_wait_for_event(struct smu_context *smu, enum
smu_event_typedrivers/gpu/drm/amd/pm/inc/amdgpu_smu.h int smu_set_ac_dc(struct smu_context *smu);
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1
-0+event, uint64_t event_arg);int smu_get_ecc_info (struct smu_context *smu,void *umc_ecc); int smu_stb_collect_info(struct smu_context *smu, void *buff, uint32_tsize);
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_sys_set_pp_feature_mask(void
Quoted 12 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2
-1void amdgpu_smu_stb_debug_fs_init (struct amdgpu_device *adev); - +int smu_send_hbm_bad_pages_num (struct smu_context *smu,uint32_t +size);#endif #endif drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -100,17 +100,14 @@ static int smu_sys_set_pp_feature_mask(void*handle,
Quoted 23 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-8return ret; } -int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value) +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value) { -int ret =0 ; -struct smu_context *smu = &adev->smu; +if (!smu->ppt_funcs->get_gfx_off_status) +return -EINVAL ; -if (is_support_sw_smu (adev) && smu->ppt_funcs- get_gfx_off_status) - *value =smu_get_gfx_off_status (smu); -else - ret = -EINVAL ; + *value =smu_get_gfx_off_status (smu); -return ret; +return 0 ; }Quoted 8 lines
int smu_set_soft_freq_range(struct
smu_context*smu, @@ -3167,11
+3164,10 @@ static const structamd_pm_funcsswsmu_pm_funcs= {
.get_smu_prv_buf_details =smu_get_prv_buffer_details,
};-int smu_wait_for_event(struct
amdgpu_device*adev, enumsmu_event_typeevent,
+int smu_wait_for_event(structsmu_context*smu, enum
smu_event_typedrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c void amdgpu_smu_stb_debug_fs_init(struct
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+event, uint64_t event_arg) {int ret = -EINVAL ; -struct smu_context *smu = &adev->smu;if (smu->ppt_funcs->wait_for_event) {mutex_lock (&smu->mutex);@@ -3285,3 +3281,13 @@ void amdgpu_smu_stb_debug_fs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +6
-0#endif } + +int smu_send_hbm_bad_pages_num(struct smu_context *smu, uint32_t +size) { + int ret = 0; + + if (smu->ppt_funcs && smu->ppt_funcs-
send_hbm_bad_pages_num)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ ret = smu->ppt_funcs->send_hbm_bad_pages_num(smu,size);
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0+ +return ret; +}
Re: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of power
Quoted 56 lines · Evan
[AMD Official Use Only]
Quoted 52 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, December 2, 2021 12:13 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of powerQuoted 3 lines · Evan Quan
Those implementation
details(whether swsmu supported, some ppt_funcs supported, accessing internal statistics ...)should be kept internally. It's not a good practice and even error prone to exposeimplementation details.
Quoted 14 lines
Signed-off-by Evan Quan <[email protected]>Change-Id Ibca3462ceaa26a27a9145282b60c6ce5deca7752--- drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 25 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 18 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 7 -- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 5 +- drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 2 +- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 90+++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct
Quoted 11 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 25 +++++- drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 11 +-- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 26 +++--- 13 files changed, 161 insertions(+), 65 deletions(-)drivers/gpu/drm/amd/amdgpu/aldebaran.c +0
-0@@ -260,7 +260,7 @@ static int aldebaran_mode2_restore_ip(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c +1
-1adev->gfx.rlc.funcs->resume (adev);/* Wait for FW reset event complete */ - r =smu_wait_for_event (adev,SMU_EVENT_RESET_COMPLETE ,0 ); + r = amdgpu_dpm_wait_for_event(adev,
SMU_EVENT_RESET_COMPLETE, 0);Hi Evan,
Quoted 9 lines
Quoted 5 lines
As mentioned in the earlier comments, I suggest you to leave these newer APIs and take care of the rest of the APIs. These may be covered as amdgpu_smu* in another patch set. Till that time, it's not needed to move them to
amdgpu_dpm(as mentioned before, some of them are are not even remotely related to power management).[Quan, Evan] This patch series highly relies on such change. That is swsmu is another framework as powerplay and all access should come through
amdgpu_dpm.c. More specifically, patch 13 and 17 directly relies on this.
Further more, without the unified lock protection from patch 17, the changes for dropping unneeded locks(which had been in my local branch) will be impossible.
Patch 13 is directly related to smu context. I don't see many smu context related APIs added in amdgpu_dpm. I guess you could convert those APIs directly to pass amdgpu_device instead of smu_context.
Ex: smu_get_ecc_info(struct amdgpu_device *adev,
As for the mutex change, we could still use pm.mutex in place of smu mutex, right?
Quoted 2 lines
I'm fine with the idea that naming those APIs supported by swsmu only with prefix amdgpu_smu*. But that has to be done after this patch series. And I would expect those APIs are located in
amdgpu_dpm.c(instead of amdgpu_smu.c)also.
I don't think so. amdgpu_dpm and amdgpu_smu should be separate. I guess we shouldn't plan to have additional APIs in amdgpu_dpm anymore and move to component based APIs.
Thanks,
Lijo
Quoted 514 lines
BR
EvanQuoted 511 lines
Thanks,
Lijodrivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev) · line 266
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c +0
-0if (r) {dev_err (adev->dev,"Failed to get response from firmware after reset\n" );diff --git
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data,
Quoted 6 lines
a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index164d6a9e9fbb..0d1f00b24aae100644drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1585,22 +1585,25 @@ static int amdgpu_debugfs_sclk_set(void *data,u64 val)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-2return ret; } -if (is_support_sw_smu (adev)) { - ret = smu_get_dpm_freq_range(&adev->smu, SMU_SCLK,
&min_freq,&max_freq);drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-3-if (ret || val > max_freq || val < min_freq) -return -EINVAL ; - ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK,(uint32_t)val, (uint32_t)val);
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2- }else { -return 0 ; + ret = amdgpu_dpm_get_dpm_freq_range(adev, PP_SCLK,
&min_freq,&max_freq);drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+if (ret == -EOPNOTSUPP ) { + ret =0 ; + goto out; } +if (ret || val > max_freq || val < min_freq) { + ret = -EINVAL ; + goto out; + } + + ret = amdgpu_dpm_set_soft_freq_range(adev, PP_SCLK,(uint32_t)val, (uint32_t)val);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_late_init(struct
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-4+if (ret) + ret = -EINVAL ; +out:pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); -if (ret) -return -EINVAL ; - -return 0 ; +return ret; } DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index1989f9e9379e..41cc1ffb5809100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -2617,7 +2617,7 @@ static int amdgpu_device_ip_late_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1if (adev->asic_type ==CHIP_ARCTURUS &&amdgpu_passthrough (adev) && adev->gmc.xgmi.num_physical_nodes >1 ) -smu_set_light_sbr (&adev->smu, true); +amdgpu_dpm_set_light_sbr (adev, true);if (adev->gmc.xgmi.num_physical_nodes >1 ) {mutex_lock (&mgpu_info.mutex);@@ -2857,7 +2857,7 @@ static int
amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1int i, r;if (adev->in_s0ix) - amdgpu_gfx_state_change_set(adev,
sGpuChangeState_D3Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int · line 2860
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+ amdgpu_dpm_gfx_state_change(adev,
sGpuChangeState_D3Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.valid)@@ -3982,7 +3982,7 @@ int amdgpu_device_resume(struct drm_device*dev, bool fbcon)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1return 0 ;if (adev->in_s0ix) - amdgpu_gfx_state_change_set(adev,
sGpuChangeState_D0Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3985
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+ amdgpu_dpm_gfx_state_change(adev,
sGpuChangeState_D0Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_get_gfx_off_status(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0/* post card */ if (amdgpu_device_need_post(adev)) { diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index1916ec84dd71..3d8f82dc8c97100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0@@ -615,7 +615,7 @@ int amdgpu_get_gfx_off_status(struct
amdgpu_devicedrivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_get_num_kcq(struct
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1*adev, uint32_t *value)mutex_lock (&adev->gfx.gfx_off_mutex); - r =smu_get_status_gfxoff (adev, value); + r =amdgpu_dpm_get_status_gfxoff (adev, value);mutex_unlock (&adev->gfx.gfx_off_mutex);@@ -852,19 +852,3 @@ int amdgpu_gfx_get_num_kcq(struct
amdgpu_device*adev)Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-9}return amdgpu_num_kcq; } - -/* amdgpu_gfx_state_change_set - Handle gfx power state change set -* @adev: amdgpu_device pointer -* @state: gfx power state(1 -sGpuChangeState_D0Entry and 2 -sGpuChangeState_D3Entry) -* -*/ - -void amdgpu_gfx_state_change_set(struct amdgpu_device *adev, enum
gfx_change_statestate) -{drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-7-mutex_lock (&adev->pm.mutex); -if (adev->powerplay.pp_funcs && - adev->powerplay.pp_funcs->gfx_state_change_set) - ((adev)->powerplay.pp_funcs->gfx_state_change_set ( - (adev)->powerplay.pp_handle, state)); -mutex_unlock (&adev->pm.mutex); -}drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h enum amdgpu_gfx_pipe_priority { · line 50
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-1@@ -47,12 +47,6 @@ enum amdgpu_gfx_pipe_priority { AMDGPU_GFX_PIPE_PRIO_HIGH = AMDGPU_RING_PRIO_2 }; -/* Argument for PPSMC_MSG_GpuChangeState */ -enum
gfx_change_state{drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h int amdgpu_gfx_cp_ecc_error_irq(struct
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-4- sGpuChangeState_D0Entry =1 , - sGpuChangeState_D3Entry, -}; -#define AMDGPU_GFX_QUEUE_PRIORITY_MINIMUM 0#define AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM 15@@ -410,5 +404,4 @@ int amdgpu_gfx_cp_ecc_error_irq(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h int amdgpu_gfx_cp_ecc_error_irq(struct · line 405
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg); void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg,
uint32_tv);Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0int amdgpu_gfx_get_num_kcq (struct amdgpu_device *adev); -voidamdgpu_gfx_state_change_set(struct
amdgpu_device*adev, enum
gfx_change_statestate);drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_get_ecc_info(struct
Quoted 7 lines
#endifdrivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-0@@ -901,7 +901,7 @@ static void amdgpu_ras_get_ecc_info(struct
amdgpu_device*adev, structras_err_ddrivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_recovery_init(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1
-1* choosing right query method according to * whether smu support query error information */ - ret =smu_get_ecc_info (&adev->smu, (void *)&(ras->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(ras->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)@@ -2132,8 +2132,7 @@ int amdgpu_ras_recovery_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-2if (ret) goto free; -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs- send_hbm_bad_pages_num) - adev->smu.ppt_funcs-send_hbm_bad_pages_num(&adev->smu, con-
eeprom_control.ras_num_recs);drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2
-0+amdgpu_dpm_send_hbm_bad_pages_num (adev, +con->eeprom_control.ras_num_recs); }#ifdef CONFIG_X86_MCE_AMD drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0
-0@@ -97,7 +97,7 @@ int amdgpu_umc_process_ras_data_cb(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1
-1int ret =0 ;kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); - ret =smu_get_ecc_info (&adev->smu, (void *)&(con->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(con->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)@@ -160,8 +160,7 @@ int amdgpu_umc_process_ras_data_cb(struct
amdgpu_device*adev,Quoted 27 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0
-2err_data->err_addr_cnt);amdgpu_ras_save_bad_pages (adev); -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs- send_hbm_bad_pages_num) - adev->smu.ppt_funcs-send_hbm_bad_pages_num(&adev->smu, con-
eeprom_control.ras_num_recs);drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2
-0+amdgpu_dpm_send_hbm_bad_pages_num (adev, +con->eeprom_control.ras_num_recs); }amdgpu_ras_reset_gpu (adev);drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c +1
-1@@ -222,7 +222,7 @@ void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev, len =snprintf (fifo_in,sizeof (fifo_in),"%x %llx:%llx\n" ,KFD_SMI_EVENT_THERMAL_THROTTLE , throttle_bitmask, -atomic64_read (&dev->adev->smu.throttle_int_counter)); +amdgpu_dpm_get_thermal_throttling_counter (dev- adev));Quoted 1 line
add_event_to_kfifo(dev,
KFD_SMI_EVENT_THERMAL_THROTTLE,fifo_in, len);Quoted 27 lines
}drivers/gpu/drm/amd/include/kgd_pp_interface.h +4
-0@@ -26,6 +26,10 @@extern const struct amdgpu_ip_block_version pp_smu_ip_block; +enum smu_event_type { +SMU_EVENT_RESET_COMPLETE =0 , +}; +struct amd_vce_state {/* vce clocks */ u32 evclk;drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1614,3 +1614,93 @@ int amdgpu_pm_load_smu_firmware(struct
amdgpu_device*adev,uint32_t*smu_versioreturn 0; }drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-0+ +int amdgpu_dpm_set_light_sbr(struct amdgpu_device *adev, boolenable)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+{ +return smu_set_light_sbr (&adev->smu, enable); } + +int amdgpu_dpm_send_hbm_bad_pages_num(struct amdgpu_device*adev,
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+uint32_t size) { +return smu_send_hbm_bad_pages_num (&adev->smu, size); } + +int amdgpu_dpm_get_dpm_freq_range(struct amdgpu_device *adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+enum pp_clock_type type, + uint32_t *min, + uint32_t *max) +{ + if (!is_support_sw_smu(adev)) + return -EOPNOTSUPP; + +switch (type) { +case PP_SCLK : + return smu_get_dpm_freq_range(&adev->smu, SMU_SCLK,min, max);
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +6
-0+default : +return -EINVAL ; + } +} + +int amdgpu_dpm_set_soft_freq_range(struct amdgpu_device *adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+enum pp_clock_type type, + uint32_t min, + uint32_t max) +{ + if (!is_support_sw_smu(adev)) + return -EOPNOTSUPP; + +switch (type) { +case PP_SCLK : + return smu_set_soft_freq_range(&adev->smu, SMU_SCLK,min, max);
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+default : +return -EINVAL ; + } +} +drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+int amdgpu_dpm_wait_for_event (struct amdgpu_device *adev, +enum smu_event_type event, +uint64_t event_arg) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_wait_for_event (&adev->smu, event, event_arg); } + +int amdgpu_dpm_get_status_gfxoff(struct amdgpu_device *adev,
uint32_tQuoted 41 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +35
-0+*value) { +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_get_status_gfxoff (&adev->smu, value); } + +uint64_t amdgpu_dpm_get_thermal_throttling_counter (struct +amdgpu_device *adev) { +return atomic64_read (&adev->smu.throttle_int_counter); +} + +/* amdgpu_dpm_gfx_state_change - Handle gfx power state change set +* @adev: amdgpu_device pointer +* @state: gfx power state(1 -sGpuChangeState_D0Entry and 2 +-sGpuChangeState_D3Entry) +* +*/ +void amdgpu_dpm_gfx_state_change (struct amdgpu_device *adev, +enum gfx_change_state state) +{ +mutex_lock (&adev->pm.mutex); +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->gfx_state_change_set) + ((adev)->powerplay.pp_funcs->gfx_state_change_set ( + (adev)->powerplay.pp_handle, state)); +mutex_unlock (&adev->pm.mutex); +} + +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_get_ecc_info (&adev->smu, umc_ecc); }drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h line 26
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0@@ -23,6 +23,12 @@#ifndef __AMDGPU_DPM_H__#define __AMDGPU_DPM_H__ +/* Argument for PPSMC_MSG_GpuChangeState */ enum
gfx_change_state{drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct
Quoted 8 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +4
-0+ sGpuChangeState_D0Entry =1 , + sGpuChangeState_D3Entry, +}; +enum amdgpu_int_thermal_type {THERMAL_TYPE_NONE , THERMAL_TYPE_EXTERNAL,@@ -574,5 +580,22 @@ void amdgpu_dpm_enable_vce(struct
amdgpu_device*adev, bool enable);drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 580
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_dpm_enable_jpeg(struct amdgpu_device *adev, boolenable);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 582
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_pm_print_power_states (struct amdgpu_device *adev); int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev,
uint32_tdrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 585
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-1*smu_version); - +int amdgpu_dpm_set_light_sbr (struct amdgpu_device *adev,bool +enable); int amdgpu_dpm_send_hbm_bad_pages_num(struct
amdgpu_devicedrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 586
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+*adev, uint32_t size); int amdgpu_dpm_get_dpm_freq_range(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable);
Quoted 8 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8
-0+enum pp_clock_type type, + uint32_t *min, + uint32_t *max); +int amdgpu_dpm_set_soft_freq_range (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t min, +uint32_t max); +int amdgpu_dpm_wait_for_event(struct amdgpu_device *adev, enum
smu_event_typeevent,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 596
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0+ uint64_t event_arg); +int amdgpu_dpm_get_status_gfxoff(struct amdgpu_device *adev,
uint32_tdrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 598
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0+*value); uint64_t amdgpu_dpm_get_thermal_throttling_counter(struct +amdgpu_device *adev); void amdgpu_dpm_gfx_state_change(struct
amdgpu_device*adev,Quoted 24 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +3
-0+ enum gfx_change_state state); +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc);#endifdrivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0
-5@@ -241,11 +241,6 @@ struct smu_user_dpm_profile {uint32_t clk_dependency; }; -enum smu_event_type { - -SMU_EVENT_RESET_COMPLETE =0 , -}; -#define SMU_TABLE_INIT (tables, table_id, s, a, d) \ do { \ tables[table_id].size = s; \@@ -1412,15 +1407,15 @@ int smu_set_ac_dc(struct smu_context *smu);int smu_allow_xgmi_power_down (struct smu_context *smu,bool en);drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h int smu_set_ac_dc(struct smu_context *smu); · line 1416
Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2
-2-int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value); +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value);int smu_set_light_sbr (struct smu_context *smu,bool enable); -int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event, +int smu_wait_for_event(struct smu_context *smu, enum
smu_event_typedrivers/gpu/drm/amd/pm/inc/amdgpu_smu.h int smu_set_ac_dc(struct smu_context *smu);
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1
-0+event, uint64_t event_arg);int smu_get_ecc_info (struct smu_context *smu,void *umc_ecc); int smu_stb_collect_info(struct smu_context *smu, void *buff, uint32_tsize);
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_sys_set_pp_feature_mask(void
Quoted 12 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2
-1void amdgpu_smu_stb_debug_fs_init (struct amdgpu_device *adev); - +int smu_send_hbm_bad_pages_num (struct smu_context *smu,uint32_t +size);#endif #endif drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -100,17 +100,14 @@ static int smu_sys_set_pp_feature_mask(void*handle,
Quoted 23 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-8return ret; } -int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value) +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value) { -int ret =0 ; -struct smu_context *smu = &adev->smu; +if (!smu->ppt_funcs->get_gfx_off_status) +return -EINVAL ; -if (is_support_sw_smu (adev) && smu->ppt_funcs- get_gfx_off_status) - *value =smu_get_gfx_off_status (smu); -else - ret = -EINVAL ; + *value =smu_get_gfx_off_status (smu); -return ret; +return 0 ; }Quoted 8 lines
int smu_set_soft_freq_range(struct smu_context *smu, @@ -3167,11+3164,10 @@ static const struct
amd_pm_funcsswsmu_pm_funcs= {
.get_smu_prv_buf_details =smu_get_prv_buffer_details,
};-int smu_wait_for_event(struct
amdgpu_device*adev, enumsmu_event_typeevent,
+int smu_wait_for_event(structsmu_context*smu, enum
smu_event_typedrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c void amdgpu_smu_stb_debug_fs_init(struct
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+event, uint64_t event_arg) {int ret = -EINVAL ; -struct smu_context *smu = &adev->smu;if (smu->ppt_funcs->wait_for_event) {mutex_lock (&smu->mutex);@@ -3285,3 +3281,13 @@ void amdgpu_smu_stb_debug_fs_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +6
-0#endif } + +int smu_send_hbm_bad_pages_num(struct smu_context *smu, uint32_t +size) { + int ret = 0; + + if (smu->ppt_funcs && smu->ppt_funcs-
send_hbm_bad_pages_num)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ ret = smu->ppt_funcs->send_hbm_bad_pages_num(smu,size);
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0+ +return ret; +}
RE: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of power
[AMD Official Use Only]
Quoted 85 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, December 2, 2021 1:12 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of powerQuoted 9 lines · Evan
[AMD Official Use Only]
Quoted 5 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, December 2, 2021 12:13 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig,Christian
Quoted 8 lines
Quoted 8 lines
<[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of powerQuoted 1 line · Evan Quan
Those implementation details(whether swsmu supported, some
ppt_funcsQuoted 37 lines
Quoted 37 lines
Quoted 2 lines
supported, accessing internal statistics ...)should be kept internally. It's not a good practice and even error prone to expose
implementation details.
Quoted 14 lines
Signed-off-by Evan Quan <[email protected]>Change-Id Ibca3462ceaa26a27a9145282b60c6ce5deca7752--- drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 25 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 18 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 7 -- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 5 +- drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 2 +- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 90+++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct
Quoted 11 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 25 +++++- drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 11 +-- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 26 +++--- 13 files changed, 161 insertions(+), 65 deletions(-)drivers/gpu/drm/amd/amdgpu/aldebaran.c +0
-0@@ -260,7 +260,7 @@ static int aldebaran_mode2_restore_ip(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c +1
-1adev->gfx.rlc.funcs->resume (adev);/* Wait for FW reset event complete */ - r =smu_wait_for_event (adev,SMU_EVENT_RESET_COMPLETE ,0 ); + r = amdgpu_dpm_wait_for_event(adev,
SMU_EVENT_RESET_COMPLETE, 0);Quoted 7 lines
Quoted 7 lines
Hi Evan,
As mentioned in the earlier comments, I suggest you to leave these newer APIs and take care of the rest of the APIs. These may be covered as
amdgpu_smu* in another patch set. Till that time, it's not needed to move them toamdgpu_dpm(as mentioned before, some of them areare
Quoted 2 lines
Quoted 1 line
not even remotely related to power management).
[Quan, Evan] This patch series highly relies on such change. That is swsmu is
another framework as powerplay and all access should come through
amdgpu_dpm.c.Quoted 2 lines
More specifically, patch 13 and 17 directly relies on this. Further more, without the unified lock protection from patch 17, the
changes for dropping unneeded locks(which had been in my local branch) will be impossible.
Quoted 1 line
Quoted 8 lines
Patch 13 is directly related to smu context. I don't see many smu context related APIs added in
amdgpu_dpm. I guess you could convert those APIs directly to passamdgpu_deviceinstead ofsmu_context.Ex: smu_get_ecc_info(struct
amdgpu_device*adev,As for the mutex change, we could still use pm.mutex in place of smu mutex, right?
[Quan, Evan] I'm afraid such partial change(some swsmu APIs get called though amdgpu_dpm while others via smu_* directly) will cause some chaos. That is some will have their lock protection(pm.mutex) in amdgpu_dpm.c while others in amdgpu_smu.c.
That also means some swsmu APIs in amdgpu_smu.c need pm.mutex while others do not.
I would prefer current way which converts all of them to be called through amdgpu_dpm. If needed, we can convert them all back to smu_* directly later(with new patch set). That will be simpler.
Quoted 9 lines
Quoted 2 lines
I'm fine with the idea that naming those APIs supported by swsmu only
with prefix amdgpu_smu*. But that has to be done after this patch series.
Quoted 1 line
And I would expect those APIs are located in amdgpu_dpm.c(instead of
amdgpu_smu.c) also.I don't think so.
amdgpu_dpmandamdgpu_smushould be separate. I guess we shouldn't plan to have additional APIs inamdgpu_dpmanymore and move to component based APIs.
[Quan, Evan] Well, you could argue that. But as I said, image user wants to call some swsmu api from gfx_v9_0.c(some asics(ALDEBARAN/ARCTURUS) support swsmu while others not). What will be used then? Maybe checking for the asic type(knows which ASIC support swsmu) or swsmu support before calling. Then still we are leaking power implementation details.
Hmm, if you do not think this("leave these newer APIs and take care of the rest of the APIs") as a fatal/critical issue.
Can I have your RB to get this patch series launched first and discuss the further action later?
Since this patch series had been verified locally.
And the possible action based on the comment("leave these newer APIs and take care of the rest of the APIs") will involve a lot of rebase. That seems a risk.
BR
Evan
Quoted 527 lines
Thanks,
LijoQuoted 116 lines
BR
EvanQuoted 113 lines
Thanks,
Lijodrivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev) · line 266
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c +0
-0if (r) {dev_err (adev->dev,"Failed to get response from firmware after reset\n" );diff --git
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void · line 1585
Quoted 7 lines
a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index164d6a9e9fbb..0d1f00b24aae100644drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1585,22 +1585,25 @@ static int amdgpu_debugfs_sclk_set(void *data,u64 val)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-2return ret; } -if (is_support_sw_smu (adev)) { - ret = smu_get_dpm_freq_range(&adev->smu, SMU_SCLK,
&min_freq,&max_freq);drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-3-if (ret || val > max_freq || val < min_freq) -return -EINVAL ; - ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK,(uint32_t)val, (uint32_t)val);
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2- }else { -return 0 ; + ret = amdgpu_dpm_get_dpm_freq_range(adev, PP_SCLK,
&min_freq,&max_freq);drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+if (ret == -EOPNOTSUPP ) { + ret =0 ; + goto out; } +if (ret || val > max_freq || val < min_freq) { + ret = -EINVAL ; + goto out; + } + + ret = amdgpu_dpm_set_soft_freq_range(adev, PP_SCLK,(uint32_t)val, (uint32_t)val);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_late_init(struct
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-4+if (ret) + ret = -EINVAL ; +out:pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); -if (ret) -return -EINVAL ; - -return 0 ; +return ret; }DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index1989f9e9379e..41cc1ffb5809100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -2617,7 +2617,7 @@ static int amdgpu_device_ip_late_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1if (adev->asic_type ==CHIP_ARCTURUS &&amdgpu_passthrough (adev) && adev->gmc.xgmi.num_physical_nodes >1 ) -smu_set_light_sbr (&adev->smu, true); +amdgpu_dpm_set_light_sbr (adev, true);if (adev->gmc.xgmi.num_physical_nodes >1 ) {mutex_lock (&mgpu_info.mutex);@@ -2857,7 +2857,7 @@ static int
amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1int i, r;if (adev->in_s0ix) - amdgpu_gfx_state_change_set(adev,
sGpuChangeState_D3Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int · line 2860
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+ amdgpu_dpm_gfx_state_change(adev,
sGpuChangeState_D3Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.valid)@@ -3982,7 +3982,7 @@ int amdgpu_device_resume(struct drm_device*dev, bool fbcon)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1return 0 ;if (adev->in_s0ix) - amdgpu_gfx_state_change_set(adev,
sGpuChangeState_D0Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3985
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+ amdgpu_dpm_gfx_state_change(adev,
sGpuChangeState_D0Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_get_gfx_off_status(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0/* post card */ if (amdgpu_device_need_post(adev)) { diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index1916ec84dd71..3d8f82dc8c97100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0@@ -615,7 +615,7 @@ int amdgpu_get_gfx_off_status(struct
amdgpu_devicedrivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_get_num_kcq(struct
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1*adev, uint32_t *value)mutex_lock (&adev->gfx.gfx_off_mutex); - r =smu_get_status_gfxoff (adev, value); + r =amdgpu_dpm_get_status_gfxoff (adev, value);mutex_unlock (&adev->gfx.gfx_off_mutex);@@ -852,19 +852,3 @@ int amdgpu_gfx_get_num_kcq(struct
amdgpu_device*adev)Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-1}return amdgpu_num_kcq; } -Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev)
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-8-/* amdgpu_gfx_state_change_set - Handle gfx power state change set -* @adev: amdgpu_device pointer -* @state: gfx power state(1 -sGpuChangeState_D0Entry and 2 -sGpuChangeState_D3Entry) -* -*/ - -void amdgpu_gfx_state_change_set(struct amdgpu_device *adev,enum
Quoted 194 lines
Quoted 194 lines
Quoted 14 lines
gfx_change_statestate) -{drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-7-mutex_lock (&adev->pm.mutex); -if (adev->powerplay.pp_funcs && - adev->powerplay.pp_funcs->gfx_state_change_set) - ((adev)->powerplay.pp_funcs->gfx_state_change_set ( - (adev)->powerplay.pp_handle, state)); -mutex_unlock (&adev->pm.mutex); -}drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h enum amdgpu_gfx_pipe_priority { · line 50
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-1@@ -47,12 +47,6 @@ enum amdgpu_gfx_pipe_priority { AMDGPU_GFX_PIPE_PRIO_HIGH = AMDGPU_RING_PRIO_2 }; -/* Argument for PPSMC_MSG_GpuChangeState */ -enum
gfx_change_state{drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h int amdgpu_gfx_cp_ecc_error_irq(struct
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-4- sGpuChangeState_D0Entry =1 , - sGpuChangeState_D3Entry, -}; -#define AMDGPU_GFX_QUEUE_PRIORITY_MINIMUM 0#define AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM 15@@ -410,5 +404,4 @@ int amdgpu_gfx_cp_ecc_error_irq(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h int amdgpu_gfx_cp_ecc_error_irq(struct · line 405
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg); void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg,
uint32_tv);Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0int amdgpu_gfx_get_num_kcq (struct amdgpu_device *adev); -voidamdgpu_gfx_state_change_set(struct
amdgpu_device*adev, enum
gfx_change_statestate);drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_get_ecc_info(struct
Quoted 7 lines
#endifdrivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-0@@ -901,7 +901,7 @@ static void amdgpu_ras_get_ecc_info(struct
amdgpu_device*adev, structras_err_ddrivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_recovery_init(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1
-1* choosing right query method according to * whether smu support query error information */ - ret =smu_get_ecc_info (&adev->smu, (void *)&(ras->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(ras->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)@@ -2132,8 +2132,7 @@ int amdgpu_ras_recovery_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-2if (ret) goto free; -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs- send_hbm_bad_pages_num) - adev->smu.ppt_funcs-send_hbm_bad_pages_num(&adev->smu, con-
eeprom_control.ras_num_recs);drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2
-0+amdgpu_dpm_send_hbm_bad_pages_num (adev, +con->eeprom_control.ras_num_recs); }#ifdef CONFIG_X86_MCE_AMD drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0
-0@@ -97,7 +97,7 @@ int amdgpu_umc_process_ras_data_cb(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1
-1int ret =0 ;kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); - ret =smu_get_ecc_info (&adev->smu, (void *)&(con->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(con->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)@@ -160,8 +160,7 @@ int amdgpu_umc_process_ras_data_cb(struct
amdgpu_device*adev,Quoted 27 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0
-2err_data->err_addr_cnt);amdgpu_ras_save_bad_pages (adev); -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs- send_hbm_bad_pages_num) - adev->smu.ppt_funcs-send_hbm_bad_pages_num(&adev->smu, con-
eeprom_control.ras_num_recs);drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2
-0+amdgpu_dpm_send_hbm_bad_pages_num (adev, +con->eeprom_control.ras_num_recs); }amdgpu_ras_reset_gpu (adev);drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c +1
-1@@ -222,7 +222,7 @@ void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev, len =snprintf (fifo_in,sizeof (fifo_in),"%x %llx:%llx\n" ,KFD_SMI_EVENT_THERMAL_THROTTLE , throttle_bitmask, -atomic64_read (&dev->adev->smu.throttle_int_counter)); +amdgpu_dpm_get_thermal_throttling_counter (dev- adev));Quoted 1 line
add_event_to_kfifo(dev,
KFD_SMI_EVENT_THERMAL_THROTTLE,fifo_in, len);Quoted 27 lines
}drivers/gpu/drm/amd/include/kgd_pp_interface.h +4
-0@@ -26,6 +26,10 @@extern const struct amdgpu_ip_block_version pp_smu_ip_block; +enum smu_event_type { +SMU_EVENT_RESET_COMPLETE =0 , +}; +struct amd_vce_state {/* vce clocks */ u32 evclk;drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1614,3 +1614,93 @@ int amdgpu_pm_load_smu_firmware(struct
amdgpu_device*adev,uint32_t*smu_versioreturn 0; }drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-0+ +int amdgpu_dpm_set_light_sbr(struct amdgpu_device *adev, boolenable)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+{ +return smu_set_light_sbr (&adev->smu, enable); } + +int amdgpu_dpm_send_hbm_bad_pages_num(struct amdgpu_device*adev,
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+uint32_t size) { +return smu_send_hbm_bad_pages_num (&adev->smu, size); } + +int amdgpu_dpm_get_dpm_freq_range(struct amdgpu_device *adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+enum pp_clock_type type, + uint32_t *min, + uint32_t *max) +{ + if (!is_support_sw_smu(adev)) + return -EOPNOTSUPP; + +switch (type) { +case PP_SCLK : + return smu_get_dpm_freq_range(&adev->smu, SMU_SCLK,min, max);
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +6
-0+default : +return -EINVAL ; + } +} + +int amdgpu_dpm_set_soft_freq_range(struct amdgpu_device *adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+enum pp_clock_type type, + uint32_t min, + uint32_t max) +{ + if (!is_support_sw_smu(adev)) + return -EOPNOTSUPP; + +switch (type) { +case PP_SCLK : + return smu_set_soft_freq_range(&adev->smu, SMU_SCLK,min, max);
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+default : +return -EINVAL ; + } +} +drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+int amdgpu_dpm_wait_for_event (struct amdgpu_device *adev, +enum smu_event_type event, +uint64_t event_arg) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_wait_for_event (&adev->smu, event, event_arg); } + +int amdgpu_dpm_get_status_gfxoff(struct amdgpu_device *adev,
uint32_tQuoted 12 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+*value) { +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; +Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +8
-0+return smu_get_status_gfxoff (&adev->smu, value); } + +uint64_t amdgpu_dpm_get_thermal_throttling_counter (struct +amdgpu_device *adev) { +return atomic64_read (&adev->smu.throttle_int_counter); +} + +/* amdgpu_dpm_gfx_state_change - Handle gfx power state change set
Quoted 64 lines
Quoted 64 lines
Quoted 29 lines
+ * @adev:
amdgpu_devicepointer
+ * @state: gfx powerstate(1 -sGpuChangeState_D0Entry and 2 +-sGpuChangeState_D3Entry)
+ *
+ */drivers/gpu/drm/amd/pm/amdgpu_dpm.c +18
-0+void amdgpu_dpm_gfx_state_change (struct amdgpu_device *adev, +enum gfx_change_state state) +{ +mutex_lock (&adev->pm.mutex); +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->gfx_state_change_set) + ((adev)->powerplay.pp_funcs->gfx_state_change_set ( + (adev)->powerplay.pp_handle, state)); +mutex_unlock (&adev->pm.mutex); +} + +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_get_ecc_info (&adev->smu, umc_ecc); }drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h line 26
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0@@ -23,6 +23,12 @@#ifndef __AMDGPU_DPM_H__#define __AMDGPU_DPM_H__ +/* Argument for PPSMC_MSG_GpuChangeState */ enum
gfx_change_state{drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct
Quoted 8 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +4
-0+ sGpuChangeState_D0Entry =1 , + sGpuChangeState_D3Entry, +}; +enum amdgpu_int_thermal_type {THERMAL_TYPE_NONE , THERMAL_TYPE_EXTERNAL,@@ -574,5 +580,22 @@ void amdgpu_dpm_enable_vce(struct
amdgpu_device*adev, bool enable);drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 580
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_dpm_enable_jpeg(struct amdgpu_device *adev, boolenable);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 582
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_pm_print_power_states (struct amdgpu_device *adev); int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev,
uint32_tdrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 585
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-1*smu_version); - +int amdgpu_dpm_set_light_sbr (struct amdgpu_device *adev,bool +enable); int amdgpu_dpm_send_hbm_bad_pages_num(struct
amdgpu_devicedrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 586
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+*adev, uint32_t size); int amdgpu_dpm_get_dpm_freq_range(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable);
Quoted 8 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8
-0+enum pp_clock_type type, + uint32_t *min, + uint32_t *max); +int amdgpu_dpm_set_soft_freq_range (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t min, +uint32_t max); +int amdgpu_dpm_wait_for_event(struct amdgpu_device *adev, enum
smu_event_typeevent,Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 596
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0+ uint64_t event_arg); +int amdgpu_dpm_get_status_gfxoff(struct amdgpu_device *adev,
uint32_tQuoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+*value); uint64_tamdgpu_dpm_get_thermal_throttling_counter(struct
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 598
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+amdgpu_device *adev); void amdgpu_dpm_gfx_state_change(struct
amdgpu_device*adev,Quoted 13 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +3
-0+ enum gfx_change_state state); +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc);#endifdrivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0
-0@@ -241,11 +241,6 @@ struct smu_user_dpm_profile {uint32_t clk_dependency; };Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h int smu_set_ac_dc(struct smu_context
Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0
-5-enum smu_event_type { - -SMU_EVENT_RESET_COMPLETE =0 , -}; -#define SMU_TABLE_INIT (tables, table_id, s, a, d) \ do { \ tables[table_id].size = s; \@@ -1412,15 +1407,15 @@ int smu_set_ac_dc(struct smu_context*smu);
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h int smu_set_ac_dc(struct smu_context · line 1416
Quoted 13 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +3
-2int smu_allow_xgmi_power_down (struct smu_context *smu,bool en); -int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value); +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t +*value);int smu_set_light_sbr (struct smu_context *smu,bool enable); -int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event, +int smu_wait_for_event(struct smu_context *smu, enum
smu_event_typeQuoted 5 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1
-0+event, uint64_t event_arg);int smu_get_ecc_info (struct smu_context *smu,void *umc_ecc); int smu_stb_collect_info(struct smu_context *smu, void *buff,
uint32_tQuoted 4 lines
Quoted 4 lines
size);
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
Quoted 3 lines
void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev);drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1
-1- +int smu_send_hbm_bad_pages_num(struct smu_context *smu,
uint32_tQuoted 52 lines
Quoted 52 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_sys_set_pp_feature_mask(void
Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1
-0+size);#endif #endif drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -100,17 +100,14 @@ static int smu_sys_set_pp_feature_mask(void*handle,
Quoted 23 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-8return ret; } -int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value) +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value) { -int ret =0 ; -struct smu_context *smu = &adev->smu; +if (!smu->ppt_funcs->get_gfx_off_status) +return -EINVAL ; -if (is_support_sw_smu (adev) && smu->ppt_funcs- get_gfx_off_status) - *value =smu_get_gfx_off_status (smu); -else - ret = -EINVAL ; + *value =smu_get_gfx_off_status (smu); -return ret; +return 0 ; }Quoted 8 lines
int smu_set_soft_freq_range(struct smu_context *smu, @@ -3167,11+3164,10 @@ static const struct
amd_pm_funcsswsmu_pm_funcs= {
.get_smu_prv_buf_details =smu_get_prv_buffer_details,
};-int smu_wait_for_event(struct
amdgpu_device*adev, enumsmu_event_typeevent,
+int smu_wait_for_event(structsmu_context*smu, enum
smu_event_typedrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c void amdgpu_smu_stb_debug_fs_init(struct
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+event, uint64_t event_arg) {int ret = -EINVAL ; -struct smu_context *smu = &adev->smu;if (smu->ppt_funcs->wait_for_event) {mutex_lock (&smu->mutex);@@ -3285,3 +3281,13 @@ void amdgpu_smu_stb_debug_fs_init(struct
amdgpu_device*adev)Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0#endif } + +int smu_send_hbm_bad_pages_num(struct smu_context *smu,
uint32_tQuoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-0+size) { + int ret = 0; + + if (smu->ppt_funcs && smu->ppt_funcs-
send_hbm_bad_pages_num)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ ret = smu->ppt_funcs->send_hbm_bad_pages_num(smu,size);
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0+ +return ret; +}
Re: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of power
Quoted 107 lines · Evan
[AMD Official Use Only]
Quoted 85 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, December 2, 2021 1:12 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of powerQuoted 9 lines · Evan
[AMD Official Use Only]
Quoted 5 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, December 2, 2021 12:13 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig,Christian
Quoted 8 lines
Quoted 8 lines
<[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH V3 01/17] drm/amd/pm: do not expose implementation details to other blocks out of powerQuoted 1 line · Evan Quan
Those implementation details(whether swsmu supported, some
ppt_funcsQuoted 37 lines
Quoted 37 lines
Quoted 2 lines
supported, accessing internal statistics ...)should be kept internally. It's not a good practice and even error prone to expose
implementation details.
Quoted 14 lines
Signed-off-by Evan Quan <[email protected]>Change-Id Ibca3462ceaa26a27a9145282b60c6ce5deca7752--- drivers/gpu/drm/amd/amdgpu/aldebaran.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 25 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 18 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 7 -- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 5 +- drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 2 +- .../gpu/drm/amd/include/kgd_pp_interface.h | 4 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 90+++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct
Quoted 11 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 25 +++++- drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 11 +-- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 26 +++--- 13 files changed, 161 insertions(+), 65 deletions(-)drivers/gpu/drm/amd/amdgpu/aldebaran.c +0
-0@@ -260,7 +260,7 @@ static int aldebaran_mode2_restore_ip(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c +1
-1adev->gfx.rlc.funcs->resume (adev);/* Wait for FW reset event complete */ - r =smu_wait_for_event (adev,SMU_EVENT_RESET_COMPLETE ,0 ); + r = amdgpu_dpm_wait_for_event(adev,
SMU_EVENT_RESET_COMPLETE, 0);Quoted 7 lines
Quoted 7 lines
Hi Evan,
As mentioned in the earlier comments, I suggest you to leave these newer APIs and take care of the rest of the APIs. These may be covered as
amdgpu_smu* in another patch set. Till that time, it's not needed to move them toamdgpu_dpm(as mentioned before, some of them areare
Quoted 2 lines
Quoted 1 line
not even remotely related to power management).
[Quan, Evan] This patch series highly relies on such change. That is swsmu is
another framework as powerplay and all access should come through
amdgpu_dpm.c.Quoted 2 lines
More specifically, patch 13 and 17 directly relies on this. Further more, without the unified lock protection from patch 17, the
changes for dropping unneeded locks(which had been in my local branch) will be impossible.
Quoted 1 line
Quoted 8 lines
Patch 13 is directly related to smu context. I don't see many smu context related APIs added in
amdgpu_dpm. I guess you could convert those APIs directly to passamdgpu_deviceinstead ofsmu_context.Ex: smu_get_ecc_info(struct
amdgpu_device*adev,As for the mutex change, we could still use pm.mutex in place of smu mutex, right?
[Quan, Evan] I'm afraid such partial
change(some swsmu APIs get called though amdgpu_dpm while others via smu_* directly)will cause some chaos. That is some will have their lock protection(pm.mutex) inamdgpu_dpm.cwhile others inamdgpu_smu.c.
That also means some swsmu APIs inamdgpu_smu.cneed pm.mutex while others do not.I would prefer current way which converts all of them to be called through
amdgpu_dpm. If needed, we can convert them all back to smu_* directly later(with new patch set). That will be simpler.Quoted 3 lines
Quoted 2 lines
I'm fine with the idea that naming those APIs supported by swsmu only
with prefix amdgpu_smu*. But that has to be done after this patch series.
Quoted 9 lines
Quoted 6 lines
Quoted 1 line
And I would expect those APIs are located in amdgpu_dpm.c(instead of
amdgpu_smu.c) also.I don't think so.
amdgpu_dpmandamdgpu_smushould be separate. I guess we shouldn't plan to have additional APIs inamdgpu_dpmanymore and move to component based APIs.[Quan, Evan] Well, you could argue that. But as I said, image user wants to call some swsmu api from
gfx_v9_0.c(some asics(ALDEBARAN/ARCTURUS) support swsmu while others not). What will be used then? Maybe checking for the asic type(knows which ASIC support swsmu) or swsmu support before calling. Then still we are leaking power implementation details.
Currently, I don't see a case like this. But as per the component version arch we have, it is managed with a component version. Like, we don't keep a common gfx_v9_0.c that has all the logic for all gfx9 ASICs. We also have specific versions also like gfx_9_4.c gfx_9_4_2.c etc. The newer ones could call amdgpu_smu_* without any checks.
The exception could be a common place like debugfs/sysfs calls, though there also we could have nodes which are valid only amdgpu_smu. Those need to be managed during the creation of such ones.
Quoted 2 lines
Hmm, if you do not think
this("leave these newer APIs and take care of the rest of the APIs")as a fatal/critical issue. Can I have your RB to get this patch series launched first and discuss the further action later?
I think it's cleaner to do smu -> amdgpu_smu and avoid smu -> dpm -> amdgpu_smu.
Quoted 3 lines
Since this patch series had been verified locally.
And the possible action based on thecomment("leave these newer APIs and take care of the rest of the APIs")will involve a lot of rebase. That seems a risk.
I haven't checked other ones in v3 series yet. In general, would prefer to take smu -> amdgpu_smu rather than having an intermediate state.
Thanks,
Lijo
Quoted 529 lines
BR
EvanQuoted 527 lines
Thanks,
LijoQuoted 116 lines
BR
EvanQuoted 113 lines
Thanks,
Lijodrivers/gpu/drm/amd/amdgpu/aldebaran.c static int aldebaran_mode2_restore_ip(struct amdgpu_device *adev) · line 266
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/aldebaran.c +0
-0if (r) {dev_err (adev->dev,"Failed to get response from firmware after reset\n" );diff --git
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void · line 1585
Quoted 7 lines
a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index164d6a9e9fbb..0d1f00b24aae100644drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1585,22 +1585,25 @@ static int amdgpu_debugfs_sclk_set(void *data,u64 val)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-2return ret; } -if (is_support_sw_smu (adev)) { - ret = smu_get_dpm_freq_range(&adev->smu, SMU_SCLK,
&min_freq,&max_freq);drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-3-if (ret || val > max_freq || val < min_freq) -return -EINVAL ; - ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK,(uint32_t)val, (uint32_t)val);
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2- }else { -return 0 ; + ret = amdgpu_dpm_get_dpm_freq_range(adev, PP_SCLK,
&min_freq,&max_freq);drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+if (ret == -EOPNOTSUPP ) { + ret =0 ; + goto out; } +if (ret || val > max_freq || val < min_freq) { + ret = -EINVAL ; + goto out; + } + + ret = amdgpu_dpm_set_soft_freq_range(adev, PP_SCLK,(uint32_t)val, (uint32_t)val);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_late_init(struct
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-4+if (ret) + ret = -EINVAL ; +out:pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); -if (ret) -return -EINVAL ; - -return 0 ; +return ret; }DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index1989f9e9379e..41cc1ffb5809100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -2617,7 +2617,7 @@ static int amdgpu_device_ip_late_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1if (adev->asic_type ==CHIP_ARCTURUS &&amdgpu_passthrough (adev) && adev->gmc.xgmi.num_physical_nodes >1 ) -smu_set_light_sbr (&adev->smu, true); +amdgpu_dpm_set_light_sbr (adev, true);if (adev->gmc.xgmi.num_physical_nodes >1 ) {mutex_lock (&mgpu_info.mutex);@@ -2857,7 +2857,7 @@ static int
amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1int i, r;if (adev->in_s0ix) - amdgpu_gfx_state_change_set(adev,
sGpuChangeState_D3Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int · line 2860
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+ amdgpu_dpm_gfx_state_change(adev,
sGpuChangeState_D3Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.valid)@@ -3982,7 +3982,7 @@ int amdgpu_device_resume(struct drm_device*dev, bool fbcon)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1return 0 ;if (adev->in_s0ix) - amdgpu_gfx_state_change_set(adev,
sGpuChangeState_D0Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3985
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+ amdgpu_dpm_gfx_state_change(adev,
sGpuChangeState_D0Entry);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_get_gfx_off_status(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0/* post card */ if (amdgpu_device_need_post(adev)) { diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index1916ec84dd71..3d8f82dc8c97100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0@@ -615,7 +615,7 @@ int amdgpu_get_gfx_off_status(struct
amdgpu_devicedrivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_get_num_kcq(struct
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1*adev, uint32_t *value)mutex_lock (&adev->gfx.gfx_off_mutex); - r =smu_get_status_gfxoff (adev, value); + r =amdgpu_dpm_get_status_gfxoff (adev, value);mutex_unlock (&adev->gfx.gfx_off_mutex);@@ -852,19 +852,3 @@ int amdgpu_gfx_get_num_kcq(struct
amdgpu_device*adev)Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-1}return amdgpu_num_kcq; } -Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev)
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-8-/* amdgpu_gfx_state_change_set - Handle gfx power state change set -* @adev: amdgpu_device pointer -* @state: gfx power state(1 -sGpuChangeState_D0Entry and 2 -sGpuChangeState_D3Entry) -* -*/ - -void amdgpu_gfx_state_change_set(struct amdgpu_device *adev,enum
Quoted 194 lines
Quoted 194 lines
Quoted 14 lines
gfx_change_statestate) -{drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-7-mutex_lock (&adev->pm.mutex); -if (adev->powerplay.pp_funcs && - adev->powerplay.pp_funcs->gfx_state_change_set) - ((adev)->powerplay.pp_funcs->gfx_state_change_set ( - (adev)->powerplay.pp_handle, state)); -mutex_unlock (&adev->pm.mutex); -}drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h enum amdgpu_gfx_pipe_priority { · line 50
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-1@@ -47,12 +47,6 @@ enum amdgpu_gfx_pipe_priority { AMDGPU_GFX_PIPE_PRIO_HIGH = AMDGPU_RING_PRIO_2 }; -/* Argument for PPSMC_MSG_GpuChangeState */ -enum
gfx_change_state{drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h int amdgpu_gfx_cp_ecc_error_irq(struct
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-4- sGpuChangeState_D0Entry =1 , - sGpuChangeState_D3Entry, -}; -#define AMDGPU_GFX_QUEUE_PRIORITY_MINIMUM 0#define AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM 15@@ -410,5 +404,4 @@ int amdgpu_gfx_cp_ecc_error_irq(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h int amdgpu_gfx_cp_ecc_error_irq(struct · line 405
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg); void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg,
uint32_tv);Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0
-0int amdgpu_gfx_get_num_kcq (struct amdgpu_device *adev); -voidamdgpu_gfx_state_change_set(struct
amdgpu_device*adev, enum
gfx_change_statestate);drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_get_ecc_info(struct
Quoted 7 lines
#endifdrivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-0@@ -901,7 +901,7 @@ static void amdgpu_ras_get_ecc_info(struct
amdgpu_device*adev, structras_err_ddrivers/gpu/drm/amd/amdgpu/amdgpu_ras.c int amdgpu_ras_recovery_init(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1
-1* choosing right query method according to * whether smu support query error information */ - ret =smu_get_ecc_info (&adev->smu, (void *)&(ras->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(ras->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)@@ -2132,8 +2132,7 @@ int amdgpu_ras_recovery_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0
-2if (ret) goto free; -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs- send_hbm_bad_pages_num) - adev->smu.ppt_funcs-send_hbm_bad_pages_num(&adev->smu, con-
eeprom_control.ras_num_recs);drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2
-0+amdgpu_dpm_send_hbm_bad_pages_num (adev, +con->eeprom_control.ras_num_recs); }#ifdef CONFIG_X86_MCE_AMD drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0
-0@@ -97,7 +97,7 @@ int amdgpu_umc_process_ras_data_cb(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_process_ras_data_cb(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +1
-1int ret =0 ;kgd2kfd_set_sram_ecc_flag (adev->kfd.dev); - ret =smu_get_ecc_info (&adev->smu, (void *)&(con->umc_ecc)); + ret =amdgpu_dpm_get_ecc_info (adev, (void *)&(con->umc_ecc));if (ret == -EOPNOTSUPP ) {if (adev->umc.ras_funcs && adev->umc.ras_funcs->query_ras_error_count)@@ -160,8 +160,7 @@ int amdgpu_umc_process_ras_data_cb(struct
amdgpu_device*adev,Quoted 27 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0
-2err_data->err_addr_cnt);amdgpu_ras_save_bad_pages (adev); -if (adev->smu.ppt_funcs && adev->smu.ppt_funcs- send_hbm_bad_pages_num) - adev->smu.ppt_funcs-send_hbm_bad_pages_num(&adev->smu, con-
eeprom_control.ras_num_recs);drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2
-0+amdgpu_dpm_send_hbm_bad_pages_num (adev, +con->eeprom_control.ras_num_recs); }amdgpu_ras_reset_gpu (adev);drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c +1
-1@@ -222,7 +222,7 @@ void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev, len =snprintf (fifo_in,sizeof (fifo_in),"%x %llx:%llx\n" ,KFD_SMI_EVENT_THERMAL_THROTTLE , throttle_bitmask, -atomic64_read (&dev->adev->smu.throttle_int_counter)); +amdgpu_dpm_get_thermal_throttling_counter (dev- adev));Quoted 1 line
add_event_to_kfifo(dev,
KFD_SMI_EVENT_THERMAL_THROTTLE,fifo_in, len);Quoted 27 lines
}drivers/gpu/drm/amd/include/kgd_pp_interface.h +4
-0@@ -26,6 +26,10 @@extern const struct amdgpu_ip_block_version pp_smu_ip_block; +enum smu_event_type { +SMU_EVENT_RESET_COMPLETE =0 , +}; +struct amd_vce_state {/* vce clocks */ u32 evclk;drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1614,3 +1614,93 @@ int amdgpu_pm_load_smu_firmware(struct
amdgpu_device*adev,uint32_t*smu_versioreturn 0; }drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-0+ +int amdgpu_dpm_set_light_sbr(struct amdgpu_device *adev, boolenable)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+{ +return smu_set_light_sbr (&adev->smu, enable); } + +int amdgpu_dpm_send_hbm_bad_pages_num(struct amdgpu_device*adev,
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+uint32_t size) { +return smu_send_hbm_bad_pages_num (&adev->smu, size); } + +int amdgpu_dpm_get_dpm_freq_range(struct amdgpu_device *adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+enum pp_clock_type type, + uint32_t *min, + uint32_t *max) +{ + if (!is_support_sw_smu(adev)) + return -EOPNOTSUPP; + +switch (type) { +case PP_SCLK : + return smu_get_dpm_freq_range(&adev->smu, SMU_SCLK,min, max);
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +6
-0+default : +return -EINVAL ; + } +} + +int amdgpu_dpm_set_soft_freq_range(struct amdgpu_device *adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+enum pp_clock_type type, + uint32_t min, + uint32_t max) +{ + if (!is_support_sw_smu(adev)) + return -EOPNOTSUPP; + +switch (type) { +case PP_SCLK : + return smu_set_soft_freq_range(&adev->smu, SMU_SCLK,min, max);
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +5
-0+default : +return -EINVAL ; + } +} +drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-0+int amdgpu_dpm_wait_for_event (struct amdgpu_device *adev, +enum smu_event_type event, +uint64_t event_arg) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_wait_for_event (&adev->smu, event, event_arg); } + +int amdgpu_dpm_get_status_gfxoff(struct amdgpu_device *adev,
uint32_tQuoted 12 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-0+*value) { +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; +Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +8
-0+return smu_get_status_gfxoff (&adev->smu, value); } + +uint64_t amdgpu_dpm_get_thermal_throttling_counter (struct +amdgpu_device *adev) { +return atomic64_read (&adev->smu.throttle_int_counter); +} + +/* amdgpu_dpm_gfx_state_change - Handle gfx power state change set
Quoted 64 lines
Quoted 64 lines
Quoted 29 lines
+ * @adev:
amdgpu_devicepointer
+ * @state: gfx powerstate(1 -sGpuChangeState_D0Entry and 2 +-sGpuChangeState_D3Entry)
+ *
+ */drivers/gpu/drm/amd/pm/amdgpu_dpm.c +18
-0+void amdgpu_dpm_gfx_state_change (struct amdgpu_device *adev, +enum gfx_change_state state) +{ +mutex_lock (&adev->pm.mutex); +if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->gfx_state_change_set) + ((adev)->powerplay.pp_funcs->gfx_state_change_set ( + (adev)->powerplay.pp_handle, state)); +mutex_unlock (&adev->pm.mutex); +} + +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc) +{ +if (!is_support_sw_smu (adev)) +return -EOPNOTSUPP ; + +return smu_get_ecc_info (&adev->smu, umc_ecc); }drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h line 26
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0@@ -23,6 +23,12 @@#ifndef __AMDGPU_DPM_H__#define __AMDGPU_DPM_H__ +/* Argument for PPSMC_MSG_GpuChangeState */ enum
gfx_change_state{drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct
Quoted 8 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +4
-0+ sGpuChangeState_D0Entry =1 , + sGpuChangeState_D3Entry, +}; +enum amdgpu_int_thermal_type {THERMAL_TYPE_NONE , THERMAL_TYPE_EXTERNAL,@@ -574,5 +580,22 @@ void amdgpu_dpm_enable_vce(struct
amdgpu_device*adev, bool enable);drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 580
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_dpm_enable_jpeg(struct amdgpu_device *adev, boolenable);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 582
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_pm_print_power_states (struct amdgpu_device *adev); int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev,
uint32_tdrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 585
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-1*smu_version); - +int amdgpu_dpm_set_light_sbr (struct amdgpu_device *adev,bool +enable); int amdgpu_dpm_send_hbm_bad_pages_num(struct
amdgpu_devicedrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 586
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+*adev, uint32_t size); int amdgpu_dpm_get_dpm_freq_range(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable);
Quoted 8 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8
-0+enum pp_clock_type type, + uint32_t *min, + uint32_t *max); +int amdgpu_dpm_set_soft_freq_range (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t min, +uint32_t max); +int amdgpu_dpm_wait_for_event(struct amdgpu_device *adev, enum
smu_event_typeevent,Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 596
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2
-0+ uint64_t event_arg); +int amdgpu_dpm_get_status_gfxoff(struct amdgpu_device *adev,
uint32_tQuoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+*value); uint64_tamdgpu_dpm_get_thermal_throttling_counter(struct
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_dpm_enable_vce(struct · line 598
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-0+amdgpu_device *adev); void amdgpu_dpm_gfx_state_change(struct
amdgpu_device*adev,Quoted 13 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +3
-0+ enum gfx_change_state state); +int amdgpu_dpm_get_ecc_info (struct amdgpu_device *adev, +void *umc_ecc);#endifdrivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0
-0@@ -241,11 +241,6 @@ struct smu_user_dpm_profile {uint32_t clk_dependency; };Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h int smu_set_ac_dc(struct smu_context
Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0
-5-enum smu_event_type { - -SMU_EVENT_RESET_COMPLETE =0 , -}; -#define SMU_TABLE_INIT (tables, table_id, s, a, d) \ do { \ tables[table_id].size = s; \@@ -1412,15 +1407,15 @@ int smu_set_ac_dc(struct smu_context*smu);
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h int smu_set_ac_dc(struct smu_context · line 1416
Quoted 13 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +3
-2int smu_allow_xgmi_power_down (struct smu_context *smu,bool en); -int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value); +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t +*value);int smu_set_light_sbr (struct smu_context *smu,bool enable); -int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event, +int smu_wait_for_event(struct smu_context *smu, enum
smu_event_typeQuoted 5 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1
-0+event, uint64_t event_arg);int smu_get_ecc_info (struct smu_context *smu,void *umc_ecc); int smu_stb_collect_info(struct smu_context *smu, void *buff,
uint32_tQuoted 4 lines
Quoted 4 lines
size);
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
Quoted 3 lines
void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev);drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1
-1- +int smu_send_hbm_bad_pages_num(struct smu_context *smu,
uint32_tQuoted 52 lines
Quoted 52 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_sys_set_pp_feature_mask(void
Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1
-0+size);#endif #endif drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -100,17 +100,14 @@ static int smu_sys_set_pp_feature_mask(void*handle,
Quoted 23 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-8return ret; } -int smu_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value) +int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value) { -int ret =0 ; -struct smu_context *smu = &adev->smu; +if (!smu->ppt_funcs->get_gfx_off_status) +return -EINVAL ; -if (is_support_sw_smu (adev) && smu->ppt_funcs- get_gfx_off_status) - *value =smu_get_gfx_off_status (smu); -else - ret = -EINVAL ; + *value =smu_get_gfx_off_status (smu); -return ret; +return 0 ; }Quoted 8 lines
int smu_set_soft_freq_range(struct smu_context *smu, @@ -3167,11+3164,10 @@ static const struct
amd_pm_funcsswsmu_pm_funcs= {
.get_smu_prv_buf_details =smu_get_prv_buffer_details,
};-int smu_wait_for_event(struct
amdgpu_device*adev, enumsmu_event_typeevent,
+int smu_wait_for_event(structsmu_context*smu, enum
smu_event_typedrivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c void amdgpu_smu_stb_debug_fs_init(struct
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-1+event, uint64_t event_arg) {int ret = -EINVAL ; -struct smu_context *smu = &adev->smu;if (smu->ppt_funcs->wait_for_event) {mutex_lock (&smu->mutex);@@ -3285,3 +3281,13 @@ void amdgpu_smu_stb_debug_fs_init(struct
amdgpu_device*adev)Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0#endif } + +int smu_send_hbm_bad_pages_num(struct smu_context *smu,
uint32_tQuoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-0+size) { + int ret = 0; + + if (smu->ppt_funcs && smu->ppt_funcs-
send_hbm_bad_pages_num)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1
-0+ ret = smu->ppt_funcs->send_hbm_bad_pages_num(smu,size);
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0+ +return ret; +}
PATCH v3 2/17 drm/amd/pm: do not expose power implementation details to amdgpu_pm.c
In reply to Evan Quanamdgpu_pm.c holds all the user sysfs/hwmon interfaces. It's another client of our power APIs. It's not proper to spike into power implementation details there.
--v1->v2:
- drop unneeded "return;" in amdgpu_dpm_get_current_power_state(Guchun)
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 456 ++++++++++++++++++- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 519 ++++++++-------------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 160 +++---- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 3 - 4 files changed, 707 insertions(+), 431 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +455 -1
@@ -1453,7 +1453,9 @@ static void amdgpu_dpm_change_power_state_locked(struct amdgpu_device *adev)if (equal)return ; -amdgpu_dpm_set_power_state (adev); +if (adev->powerplay.pp_funcs->set_power_state) + adev->powerplay.pp_funcs->set_power_state (adev->powerplay.pp_handle); +amdgpu_dpm_post_set_power_state (adev); adev->pm.dpm.current_active_crtcs = adev->pm.dpm.new_active_crtcs;
@@ -1704,3 +1706,455 @@ int amdgpu_dpm_get_ecc_info(struct amdgpu_device *adev,return smu_get_ecc_info (&adev->smu, umc_ecc); } + +struct amd_vce_state *amdgpu_dpm_get_vce_clock_state (struct amdgpu_device *adev, +uint32_t idx) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_vce_clock_state) +return NULL ; + +return pp_funcs->get_vce_clock_state (adev->powerplay.pp_handle, + idx); +} + +void amdgpu_dpm_get_current_power_state (struct amdgpu_device *adev, +enum amd_pm_state_type *state) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_current_power_state) { + *state = adev->pm.dpm.user_state; +return ; + } + + *state = pp_funcs->get_current_power_state (adev->powerplay.pp_handle); +if (*state <POWER_STATE_TYPE_DEFAULT || + *state >POWER_STATE_TYPE_INTERNAL_3DPERF ) + *state = adev->pm.dpm.user_state; +} + +void amdgpu_dpm_set_power_state (struct amdgpu_device *adev, +enum amd_pm_state_type state) +{ + adev->pm.dpm.user_state = state; + +if (adev->powerplay.pp_funcs->dispatch_tasks) +amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_ENABLE_USER_STATE , &state); +else +amdgpu_pm_compute_clocks (adev); +} + +enum amd_dpm_forced_level amdgpu_dpm_get_performance_level (struct amdgpu_device *adev) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +enum amd_dpm_forced_level level; + +if (pp_funcs->get_performance_level) + level = pp_funcs->get_performance_level (adev->powerplay.pp_handle); +else + level = adev->pm.dpm.forced_level; + +return level; +} + +int amdgpu_dpm_force_performance_level (struct amdgpu_device *adev, +enum amd_dpm_forced_level level) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (pp_funcs->force_performance_level) { +if (adev->pm.dpm.thermal_active) +return -EINVAL ; + +if (pp_funcs->force_performance_level (adev->powerplay.pp_handle, + level)) +return -EINVAL ; + } + + adev->pm.dpm.forced_level = level; + +return 0 ; +} + +int amdgpu_dpm_get_pp_num_states (struct amdgpu_device *adev, +struct pp_states_info *states) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_pp_num_states) +return -EOPNOTSUPP ; + +return pp_funcs->get_pp_num_states (adev->powerplay.pp_handle, states); +} + +int amdgpu_dpm_dispatch_task (struct amdgpu_device *adev, +enum amd_pp_task task_id, +enum amd_pm_state_type *user_state) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->dispatch_tasks) +return -EOPNOTSUPP ; + +return pp_funcs->dispatch_tasks (adev->powerplay.pp_handle, task_id, user_state); +} + +int amdgpu_dpm_get_pp_table (struct amdgpu_device *adev,char **table) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_pp_table) +return 0 ; + +return pp_funcs->get_pp_table (adev->powerplay.pp_handle, table); +} + +int amdgpu_dpm_set_fine_grain_clk_vol (struct amdgpu_device *adev, +uint32_t type, +long *input, +uint32_t size) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->set_fine_grain_clk_vol) +return 0 ; + +return pp_funcs->set_fine_grain_clk_vol (adev->powerplay.pp_handle, + type, + input, + size); +} + +int amdgpu_dpm_odn_edit_dpm_table (struct amdgpu_device *adev, +uint32_t type, +long *input, +uint32_t size) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->odn_edit_dpm_table) +return 0 ; + +return pp_funcs->odn_edit_dpm_table (adev->powerplay.pp_handle, + type, + input, + size); +} + +int amdgpu_dpm_print_clock_levels (struct amdgpu_device *adev, +enum pp_clock_type type, +char *buf) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->print_clock_levels) +return 0 ; + +return pp_funcs->print_clock_levels (adev->powerplay.pp_handle, + type, + buf); +} + +int amdgpu_dpm_set_ppfeature_status (struct amdgpu_device *adev, +uint64_t ppfeature_masks) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->set_ppfeature_status) +return 0 ; + +return pp_funcs->set_ppfeature_status (adev->powerplay.pp_handle, + ppfeature_masks); +} + +int amdgpu_dpm_get_ppfeature_status (struct amdgpu_device *adev,char *buf) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_ppfeature_status) +return 0 ; + +return pp_funcs->get_ppfeature_status (adev->powerplay.pp_handle, + buf); +} + +int amdgpu_dpm_force_clock_level (struct amdgpu_device *adev, +enum pp_clock_type type, +uint32_t mask) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->force_clock_level) +return 0 ; + +return pp_funcs->force_clock_level (adev->powerplay.pp_handle, + type, + mask); +} + +int amdgpu_dpm_get_sclk_od (struct amdgpu_device *adev) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_sclk_od) +return 0 ; + +return pp_funcs->get_sclk_od (adev->powerplay.pp_handle); +} + +int amdgpu_dpm_set_sclk_od (struct amdgpu_device *adev,uint32_t value) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->set_sclk_od) +return -EOPNOTSUPP ; + + pp_funcs->set_sclk_od (adev->powerplay.pp_handle, value); + +if (amdgpu_dpm_dispatch_task (adev, +AMD_PP_TASK_READJUST_POWER_STATE , +NULL ) == -EOPNOTSUPP ) { + adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; +amdgpu_pm_compute_clocks (adev); + } + +return 0 ; +} + +int amdgpu_dpm_get_mclk_od (struct amdgpu_device *adev) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_mclk_od) +return 0 ; + +return pp_funcs->get_mclk_od (adev->powerplay.pp_handle); +} + +int amdgpu_dpm_set_mclk_od (struct amdgpu_device *adev,uint32_t value) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->set_mclk_od) +return -EOPNOTSUPP ; + + pp_funcs->set_mclk_od (adev->powerplay.pp_handle, value); + +if (amdgpu_dpm_dispatch_task (adev, +AMD_PP_TASK_READJUST_POWER_STATE , +NULL ) == -EOPNOTSUPP ) { + adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; +amdgpu_pm_compute_clocks (adev); + } + +return 0 ; +} + +int amdgpu_dpm_get_power_profile_mode (struct amdgpu_device *adev, +char *buf) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_power_profile_mode) +return -EOPNOTSUPP ; + +return pp_funcs->get_power_profile_mode (adev->powerplay.pp_handle, + buf); +} + +int amdgpu_dpm_set_power_profile_mode (struct amdgpu_device *adev, +long *input,uint32_t size) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->set_power_profile_mode) +return 0 ; + +return pp_funcs->set_power_profile_mode (adev->powerplay.pp_handle, + input, + size); +} + +int amdgpu_dpm_get_gpu_metrics (struct amdgpu_device *adev,void **table) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_gpu_metrics) +return 0 ; + +return pp_funcs->get_gpu_metrics (adev->powerplay.pp_handle, table); +} + +int amdgpu_dpm_get_fan_control_mode (struct amdgpu_device *adev, +uint32_t *fan_mode) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_fan_control_mode) +return -EOPNOTSUPP ; + + *fan_mode = pp_funcs->get_fan_control_mode (adev->powerplay.pp_handle); + +return 0 ; +} + +int amdgpu_dpm_set_fan_speed_pwm (struct amdgpu_device *adev, +uint32_t speed) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->set_fan_speed_pwm) +return -EINVAL ; + +return pp_funcs->set_fan_speed_pwm (adev->powerplay.pp_handle, speed); +} + +int amdgpu_dpm_get_fan_speed_pwm (struct amdgpu_device *adev, +uint32_t *speed) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_fan_speed_pwm) +return -EINVAL ; + +return pp_funcs->get_fan_speed_pwm (adev->powerplay.pp_handle, speed); +} + +int amdgpu_dpm_get_fan_speed_rpm (struct amdgpu_device *adev, +uint32_t *speed) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_fan_speed_rpm) +return -EINVAL ; + +return pp_funcs->get_fan_speed_rpm (adev->powerplay.pp_handle, speed); +} + +int amdgpu_dpm_set_fan_speed_rpm (struct amdgpu_device *adev, +uint32_t speed) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->set_fan_speed_rpm) +return -EINVAL ; + +return pp_funcs->set_fan_speed_rpm (adev->powerplay.pp_handle, speed); +} + +int amdgpu_dpm_set_fan_control_mode (struct amdgpu_device *adev, +uint32_t mode) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->set_fan_control_mode) +return -EOPNOTSUPP ; + + pp_funcs->set_fan_control_mode (adev->powerplay.pp_handle, mode); + +return 0 ; +} + +int amdgpu_dpm_get_power_limit (struct amdgpu_device *adev, +uint32_t *limit, +enum pp_power_limit_level pp_limit_level, +enum pp_power_type power_type) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_power_limit) +return -ENODATA ; + +return pp_funcs->get_power_limit (adev->powerplay.pp_handle, + limit, + pp_limit_level, + power_type); +} + +int amdgpu_dpm_set_power_limit (struct amdgpu_device *adev, +uint32_t limit) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->set_power_limit) +return -EINVAL ; + +return pp_funcs->set_power_limit (adev->powerplay.pp_handle, limit); +} + +int amdgpu_dpm_is_cclk_dpm_supported (struct amdgpu_device *adev) +{ +if (!is_support_sw_smu (adev)) +return false; + +return is_support_cclk_dpm (adev); +} + +int amdgpu_dpm_debugfs_print_current_performance_level (struct amdgpu_device *adev, +struct seq_file *m) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->debugfs_print_current_performance_level) +return -EOPNOTSUPP ; + + pp_funcs->debugfs_print_current_performance_level (adev->powerplay.pp_handle, + m); + +return 0 ; +} + +int amdgpu_dpm_get_smu_prv_buf_details (struct amdgpu_device *adev, +void **addr, +size_t *size) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->get_smu_prv_buf_details) +return -ENOSYS ; + +return pp_funcs->get_smu_prv_buf_details (adev->powerplay.pp_handle, + addr, + size); +} + +int amdgpu_dpm_is_overdrive_supported (struct amdgpu_device *adev) +{ +struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; + +if ((is_support_sw_smu (adev) && adev->smu.od_enabled) || + (is_support_sw_smu (adev) && adev->smu.is_apu) || + (!is_support_sw_smu (adev) && hwmgr->od_enabled)) +return true; + +return false; +} + +int amdgpu_dpm_set_pp_table (struct amdgpu_device *adev, +const char *buf, +size_t size) +{ +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs->set_pp_table) +return -EOPNOTSUPP ; + +return pp_funcs->set_pp_table (adev->powerplay.pp_handle, + buf, + size); +} + +int amdgpu_dpm_get_num_cpu_cores (struct amdgpu_device *adev) +{ +return adev->smu.cpu_core_num; +} + +void amdgpu_dpm_stb_debug_fs_init (struct amdgpu_device *adev) +{ +if (!is_support_sw_smu (adev)) +return ; + +amdgpu_smu_stb_debug_fs_init (adev); +}
drivers/gpu/drm/amd/pm/amdgpu_pm.c +182 -337
922 lines not on this page · raw message
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +70 -90
183 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -3
@@ -470,9 +470,6 @@ bool is_support_cclk_dpm(struct amdgpu_device *adev) {struct smu_context *smu = &adev->smu; -if (!is_support_sw_smu (adev)) -return false; -if (!smu_feature_is_enabled (smu,SMU_FEATURE_CCLK_DPM_BIT ))return false;
Signature · 1 line
2.29.0
PATCH v3 3/17 drm/amd/pm: do not expose power implementation details to display
In reply to Evan QuanDisplay is another client of our power APIs. It's not proper to spike into power implementation details there.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +- .../amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 246 +++++++----------- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 218 ++++++++++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 38 +++ 4 files changed, 344 insertions(+), 164 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -5
@@ -2139,12 +2139,8 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend)static int amdgpu_dm_smu_write_watermarks_table (struct amdgpu_device *adev) { -struct smu_context *smu = &adev->smu;int ret =0 ; -if (!is_support_sw_smu (adev)) -return 0 ; -/* This interface is for dGPU Navi1x.Linux dc-pplib interface depends * on window driver dc implementation. * For Navi1x, clock settings of dcn watermarks are fixed. the settings
@@ -2183,7 +2179,7 @@ static int amdgpu_dm_smu_write_watermarks_table(struct amdgpu_device *adev)return 0 ; } - ret =smu_write_watermarks_table (smu); + ret =amdgpu_dpm_write_watermarks_table (adev);if (ret) {DRM_ERROR ("Failed to update WMTABLE!\n" );return ret;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +87 -159
461 lines not on this page · raw message
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +218 -0
227 lines not on this page · raw message
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +38 -0
@@ -500,6 +500,7 @@ int amdgpu_dpm_set_soft_freq_range(struct amdgpu_device *adev,enum pp_clock_type type, uint32_t min, uint32_t max); +int amdgpu_dpm_write_watermarks_table (struct amdgpu_device *adev);int amdgpu_dpm_wait_for_event (struct amdgpu_device *adev,enum smu_event_type event,uint64_t event_arg);int amdgpu_dpm_get_status_gfxoff (struct amdgpu_device *adev,uint32_t *value);
@@ -578,4 +579,41 @@ int amdgpu_dpm_set_pp_table(struct amdgpu_device *adev, size_t size);int amdgpu_dpm_get_num_cpu_cores (struct amdgpu_device *adev);void amdgpu_dpm_stb_debug_fs_init (struct amdgpu_device *adev); +int amdgpu_dpm_display_configuration_change (struct amdgpu_device *adev, +const struct amd_pp_display_configuration *input); +int amdgpu_dpm_get_clock_by_type (struct amdgpu_device *adev, +enum amd_pp_clock_type type, +struct amd_pp_clocks *clocks); +int amdgpu_dpm_get_display_mode_validation_clks (struct amdgpu_device *adev, +struct amd_pp_simple_clock_info *clocks); +int amdgpu_dpm_get_clock_by_type_with_latency (struct amdgpu_device *adev, +enum amd_pp_clock_type type, +struct pp_clock_levels_with_latency *clocks); +int amdgpu_dpm_get_clock_by_type_with_voltage (struct amdgpu_device *adev, +enum amd_pp_clock_type type, +struct pp_clock_levels_with_voltage *clocks); +int amdgpu_dpm_set_watermarks_for_clocks_ranges (struct amdgpu_device *adev, +void *clock_ranges); +int amdgpu_dpm_display_clock_voltage_request (struct amdgpu_device *adev, +struct pp_display_clock_request *clock); +int amdgpu_dpm_get_current_clocks (struct amdgpu_device *adev, +struct amd_pp_clock_info *clocks); +void amdgpu_dpm_notify_smu_enable_pwe (struct amdgpu_device *adev); +int amdgpu_dpm_set_active_display_count (struct amdgpu_device *adev, +uint32_t count); +int amdgpu_dpm_set_min_deep_sleep_dcefclk (struct amdgpu_device *adev, +uint32_t clock); +void amdgpu_dpm_set_hard_min_dcefclk_by_freq (struct amdgpu_device *adev, +uint32_t clock); +void amdgpu_dpm_set_hard_min_fclk_by_freq (struct amdgpu_device *adev, +uint32_t clock); +int amdgpu_dpm_display_disable_memory_clock_switch (struct amdgpu_device *adev, +bool disable_memory_clock_switch); +int amdgpu_dpm_get_max_sustainable_clocks_by_dc (struct amdgpu_device *adev, +struct pp_smu_nv_clock_table *max_clocks); +enum pp_smu_status amdgpu_dpm_get_uclk_dpm_states (struct amdgpu_device *adev, +unsigned int *clock_values_in_khz, +unsigned int *num_states); +int amdgpu_dpm_get_dpm_clock_table (struct amdgpu_device *adev, +struct dpm_clocks *clock_table);#endif
Signature · 1 line
2.29.0
PATCH v3 4/17 drm/amd/pm: do not expose those APIs used internally only in amdgpu_dpm.c
In reply to Evan QuanMove them to amdgpu_dpm.c instead.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 25 +++++++++++++++++++++++-- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 23 ----------------------- 2 files changed, 23 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +23 -2
@@ -34,6 +34,27 @@#define WIDTH_4K 3840 +#define amdgpu_dpm_pre_set_power_state (adev) \ + ((adev)->powerplay.pp_funcs->pre_set_power_state((adev)->powerplay.pp_handle)) + +#define amdgpu_dpm_post_set_power_state (adev) \ + ((adev)->powerplay.pp_funcs->post_set_power_state((adev)->powerplay.pp_handle)) + +#define amdgpu_dpm_display_configuration_changed (adev) \ + ((adev)->powerplay.pp_funcs->display_configuration_changed((adev)->powerplay.pp_handle)) + +#define amdgpu_dpm_print_power_state (adev, ps) \ + ((adev)->powerplay.pp_funcs->print_power_state((adev)->powerplay.pp_handle, (ps))) + +#define amdgpu_dpm_vblank_too_short (adev) \ + ((adev)->powerplay.pp_funcs->vblank_too_short((adev)->powerplay.pp_handle)) + +#define amdgpu_dpm_enable_bapm (adev, e) \ + ((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e))) + +#define amdgpu_dpm_check_state_equal (adev, cps, rps, equal) \ + ((adev)->powerplay.pp_funcs->check_state_equal((adev)->powerplay.pp_handle, (cps), (rps), (equal))) +void amdgpu_dpm_print_class_info (u32 class,u32 class2) {const char *s;
@@ -120,7 +141,7 @@ void amdgpu_dpm_print_ps_status(struct amdgpu_device *adev,pr_cont ("\n" ); } -void amdgpu_dpm_get_active_displays (struct amdgpu_device *adev) +static void amdgpu_dpm_get_active_displays (struct amdgpu_device *adev) {struct drm_device *ddev =adev_to_drm (adev);struct drm_crtc *crtc;
@@ -168,7 +189,7 @@ u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev)return vblank_time_us; } -u32 amdgpu_dpm_get_vrefresh (struct amdgpu_device *adev) +static u32 amdgpu_dpm_get_vrefresh (struct amdgpu_device *adev) {struct drm_device *dev =adev_to_drm (adev);struct drm_crtc *crtc;
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -23
@@ -259,27 +259,6 @@ enum amdgpu_pcie_gen { AMDGPU_PCIE_GEN_INVALID = 0xffff }; -#define amdgpu_dpm_pre_set_power_state (adev) \ - ((adev)->powerplay.pp_funcs->pre_set_power_state((adev)->powerplay.pp_handle)) - -#define amdgpu_dpm_post_set_power_state (adev) \ - ((adev)->powerplay.pp_funcs->post_set_power_state((adev)->powerplay.pp_handle)) - -#define amdgpu_dpm_display_configuration_changed (adev) \ - ((adev)->powerplay.pp_funcs->display_configuration_changed((adev)->powerplay.pp_handle)) - -#define amdgpu_dpm_print_power_state (adev, ps) \ - ((adev)->powerplay.pp_funcs->print_power_state((adev)->powerplay.pp_handle, (ps))) - -#define amdgpu_dpm_vblank_too_short (adev) \ - ((adev)->powerplay.pp_funcs->vblank_too_short((adev)->powerplay.pp_handle)) - -#define amdgpu_dpm_enable_bapm (adev, e) \ - ((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e))) - -#define amdgpu_dpm_check_state_equal (adev, cps, rps, equal) \ - ((adev)->powerplay.pp_funcs->check_state_equal((adev)->powerplay.pp_handle, (cps), (rps), (equal))) -#define amdgpu_dpm_reset_power_profile_state (adev, request) \ ((adev)->powerplay.pp_funcs->reset_power_profile_state(\ (adev)->powerplay.pp_handle, request))
@@ -412,8 +391,6 @@ void amdgpu_dpm_print_cap_info(u32 caps);void amdgpu_dpm_print_ps_status (struct amdgpu_device *adev,struct amdgpu_ps *rps);u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev); -u32 amdgpu_dpm_get_vrefresh (struct amdgpu_device *adev); -void amdgpu_dpm_get_active_displays (struct amdgpu_device *adev);int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor,void *data,uint32_t *size);
Signature · 1 line
2.29.0
PATCH v3 5/17 drm/amd/pm: do not expose those APIs used internally only in si_dpm.c
In reply to Evan QuanMove them to si_dpm.c instead.
--v1->v2:
- rename the API with "si_" prefix(Alex)v2->v3:
- rename other data structures used only in si_dpm.c(Lijo)
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 25 ----- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 25 ----- drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 106 +++++++++++++++------- drivers/gpu/drm/amd/pm/powerplay/si_dpm.h | 15 ++- 4 files changed, 83 insertions(+), 88 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -25
@@ -894,31 +894,6 @@ void amdgpu_add_thermal_controller(struct amdgpu_device *adev) } } -enum amdgpu_pcie_gen amdgpu_get_pcie_gen_support (struct amdgpu_device *adev, -u32 sys_mask, -enum amdgpu_pcie_gen asic_gen, -enum amdgpu_pcie_gen default_gen) -{ -switch (asic_gen) { -case AMDGPU_PCIE_GEN1 : -return AMDGPU_PCIE_GEN1 ; -case AMDGPU_PCIE_GEN2 : -return AMDGPU_PCIE_GEN2 ; -case AMDGPU_PCIE_GEN3 : -return AMDGPU_PCIE_GEN3 ; -default : -if ((sys_mask &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 ) && - (default_gen ==AMDGPU_PCIE_GEN3 )) -return AMDGPU_PCIE_GEN3 ; -else if ((sys_mask &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 ) && - (default_gen ==AMDGPU_PCIE_GEN2 )) -return AMDGPU_PCIE_GEN2 ; -else -return AMDGPU_PCIE_GEN1 ; - } -return AMDGPU_PCIE_GEN1 ; -} -struct amd_vce_state *amdgpu_get_vce_clock_state (void *handle,u32 idx) {
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -25
@@ -45,19 +45,6 @@ enum amdgpu_int_thermal_type { THERMAL_TYPE_KV, }; -enum amdgpu_dpm_auto_throttle_src { -AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL , -AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL -}; - -enum amdgpu_dpm_event_src { -AMDGPU_DPM_EVENT_SRC_ANALOG =0 , -AMDGPU_DPM_EVENT_SRC_EXTERNAL =1 , -AMDGPU_DPM_EVENT_SRC_DIGITAL =2 , -AMDGPU_DPM_EVENT_SRC_ANALOG_OR_EXTERNAL =3 , -AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL =4 -}; -struct amdgpu_ps {u32 caps;/* vbios flags */ u32 class;/* vbios flags */
@@ -252,13 +239,6 @@ struct amdgpu_dpm_fan {bool ucode_fan_control; }; -enum amdgpu_pcie_gen { -AMDGPU_PCIE_GEN1 =0 , -AMDGPU_PCIE_GEN2 =1 , -AMDGPU_PCIE_GEN3 =2 , -AMDGPU_PCIE_GEN_INVALID =0xffff -}; -#define amdgpu_dpm_reset_power_profile_state (adev, request) \ ((adev)->powerplay.pp_funcs->reset_power_profile_state(\ (adev)->powerplay.pp_handle, request))
@@ -403,11 +383,6 @@ void amdgpu_free_extended_power_table(struct amdgpu_device *adev);void amdgpu_add_thermal_controller (struct amdgpu_device *adev); -enum amdgpu_pcie_gen amdgpu_get_pcie_gen_support (struct amdgpu_device *adev, -u32 sys_mask, -enum amdgpu_pcie_gen asic_gen, -enum amdgpu_pcie_gen default_gen); -struct amd_vce_state *amdgpu_get_vce_clock_state (void *handle,u32 idx);
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +72 -34
212 lines not on this page · raw message
drivers/gpu/drm/amd/pm/powerplay/si_dpm.h +11 -4
@@ -595,13 +595,20 @@ struct rv7xx_power_info {RV770_SMC_STATETABLE smc_statetable; }; +enum si_pcie_gen { +PCIE_GEN1 =0 , +PCIE_GEN2 =1 , +PCIE_GEN3 =2 , +PCIE_GEN_INVALID =0xffff +}; +struct rv7xx_pl {u32 sclk;u32 mclk;u16 vddc;u16 vddci;/* eg+ only */ u32 flags; -enum amdgpu_pcie_gen pcie_gen;/* si+ only */ +enum si_pcie_gen pcie_gen;/* si+ only */ };struct rv7xx_ps {
@@ -967,9 +974,9 @@ struct si_power_info {struct si_ulv_param ulv;u32 max_cu;/* pcie gen */ -enum amdgpu_pcie_gen force_pcie_gen; -enum amdgpu_pcie_gen boot_pcie_gen; -enum amdgpu_pcie_gen acpi_pcie_gen; +enum si_pcie_gen force_pcie_gen; +enum si_pcie_gen boot_pcie_gen; +enum si_pcie_gen acpi_pcie_gen;u32 sys_pcie_mask;/* flags */ bool enable_dte;
Signature · 1 line
2.29.0
PATCH v3 6/17 drm/amd/pm: do not expose the API used internally only in kv_dpm.c
In reply to Evan QuanMove it to kv_dpm.c instead.
--v1->v2:
- rename the API with "kv_" prefix(Alex)
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 23 --------------------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 2 -- drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c | 25 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -23
@@ -209,29 +209,6 @@ static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)return vrefresh; } -bool amdgpu_is_internal_thermal_sensor (enum amdgpu_int_thermal_type sensor) -{ -switch (sensor) { -case THERMAL_TYPE_RV6XX : -case THERMAL_TYPE_RV770 : -case THERMAL_TYPE_EVERGREEN : -case THERMAL_TYPE_SUMO : -case THERMAL_TYPE_NI : -case THERMAL_TYPE_SI : -case THERMAL_TYPE_CI : -case THERMAL_TYPE_KV : -return true; -case THERMAL_TYPE_ADT7473_WITH_INTERNAL : -case THERMAL_TYPE_EMC2103_WITH_INTERNAL : -return false;/* need special handling */ -case THERMAL_TYPE_NONE : -case THERMAL_TYPE_EXTERNAL : -case THERMAL_TYPE_EXTERNAL_GPIO : -default : -return false; - } -} -union power_info {struct _ATOM_POWERPLAY_INFO info;struct _ATOM_POWERPLAY_INFO_V2 info_2;
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -2
@@ -374,8 +374,6 @@ u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev);int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor,void *data,uint32_t *size); -bool amdgpu_is_internal_thermal_sensor (enum amdgpu_int_thermal_type sensor); -int amdgpu_get_platform_caps (struct amdgpu_device *adev);int amdgpu_parse_extended_power_table (struct amdgpu_device *adev);
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +24 -1
@@ -1256,6 +1256,29 @@ static void kv_dpm_enable_bapm(void *handle, bool enable) } } +static bool kv_is_internal_thermal_sensor (enum amdgpu_int_thermal_type sensor) +{ +switch (sensor) { +case THERMAL_TYPE_RV6XX : +case THERMAL_TYPE_RV770 : +case THERMAL_TYPE_EVERGREEN : +case THERMAL_TYPE_SUMO : +case THERMAL_TYPE_NI : +case THERMAL_TYPE_SI : +case THERMAL_TYPE_CI : +case THERMAL_TYPE_KV : +return true; +case THERMAL_TYPE_ADT7473_WITH_INTERNAL : +case THERMAL_TYPE_EMC2103_WITH_INTERNAL : +return false;/* need special handling */ +case THERMAL_TYPE_NONE : +case THERMAL_TYPE_EXTERNAL : +case THERMAL_TYPE_EXTERNAL_GPIO : +default : +return false; + } +} +static int kv_dpm_enable (struct amdgpu_device *adev) {struct kv_power_info *pi =kv_get_pi (adev);
@@ -1352,7 +1375,7 @@ static int kv_dpm_enable(struct amdgpu_device *adev) }if (adev->irq.installed && -amdgpu_is_internal_thermal_sensor (adev->pm.int_thermal_type)) { +kv_is_internal_thermal_sensor (adev->pm.int_thermal_type)) { ret =kv_set_thermal_temperature_range (adev,KV_TEMP_RANGE_MIN ,KV_TEMP_RANGE_MAX );if (ret) {DRM_ERROR ("kv_set_thermal_temperature_range failed\n" );
Signature · 1 line
2.29.0
PATCH v3 7/17 drm/amd/pm: create a new holder for those APIs used only by legacy ASICs(si/kv)
In reply to Evan QuanThose APIs are used only by legacy ASICs(si/kv). They cannot be shared by other ASICs. So, we create a new holder for them.
--v1->v2:
- rename amdgpu_pm_compute_clocks as amdgpu_dpm_compute_clocks(Lijo)
--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 2 +- .../amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 2 +- .../gpu/drm/amd/include/kgd_pp_interface.h | 1 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 1022 +--------------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 17 +- drivers/gpu/drm/amd/pm/powerplay/Makefile | 2 +- drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c | 6 +- drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c | 1024 +++++++++++++++++ drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h | 37 + drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 6 +- 13 files changed, 1089 insertions(+), 1036 deletions(-) create mode 100644 drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c create mode 100644 drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1 -1
@@ -2532,7 +2532,7 @@ static void dce_v10_0_crtc_dpms(struct drm_crtc *crtc, int mode)break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v10_0_crtc_prepare (struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1 -1
@@ -2608,7 +2608,7 @@ static void dce_v11_0_crtc_dpms(struct drm_crtc *crtc, int mode)break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v11_0_crtc_prepare (struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -1
@@ -2424,7 +2424,7 @@ static void dce_v6_0_crtc_dpms(struct drm_crtc *crtc, int mode)break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v6_0_crtc_prepare (struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1 -1
@@ -2433,7 +2433,7 @@ static void dce_v8_0_crtc_dpms(struct drm_crtc *crtc, int mode)break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v8_0_crtc_prepare (struct drm_crtc *crtc)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +1 -1
@@ -101,7 +101,7 @@ bool dm_pp_apply_display_requirements(amdgpu_dpm_display_configuration_change (adev, &adev->pm.pm_display_cfg); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return true;
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -0
@@ -404,6 +404,7 @@ struct amd_pm_funcs {int (*get_dpm_clock_table)(void *handle,struct dpm_clocks *clock_table);int (*get_smu_prv_buf_details)(void *handle,void **addr,size_t *size); +int (*change_power_state)(void *handle); };struct metrics_table_header {
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +12 -1010
1,102 lines not on this page · raw message
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -16
@@ -366,24 +366,10 @@ enum amdgpu_display_gap AMDGPU_PM_DISPLAY_GAP_IGNORE = 3, }; -void amdgpu_dpm_print_class_info (u32 class,u32 class2); -void amdgpu_dpm_print_cap_info (u32 caps); -void amdgpu_dpm_print_ps_status (struct amdgpu_device *adev, -struct amdgpu_ps *rps);u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev);int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor,void *data,uint32_t *size); -int amdgpu_get_platform_caps (struct amdgpu_device *adev); - -int amdgpu_parse_extended_power_table (struct amdgpu_device *adev); -void amdgpu_free_extended_power_table (struct amdgpu_device *adev); - -void amdgpu_add_thermal_controller (struct amdgpu_device *adev); - -struct amd_vce_state * -amdgpu_get_vce_clock_state (void *handle,u32 idx); -int amdgpu_dpm_set_powergating_by_smu (struct amdgpu_device *adev,uint32_t block_type,bool gate);
@@ -434,11 +420,10 @@ int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors sensovoid amdgpu_dpm_thermal_work_handler (struct work_struct *work); -void amdgpu_pm_compute_clocks (struct amdgpu_device *adev); +void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev);void amdgpu_dpm_enable_uvd (struct amdgpu_device *adev,bool enable);void amdgpu_dpm_enable_vce (struct amdgpu_device *adev,bool enable);void amdgpu_dpm_enable_jpeg (struct amdgpu_device *adev,bool enable); -void amdgpu_pm_print_power_states (struct amdgpu_device *adev);int amdgpu_pm_load_smu_firmware (struct amdgpu_device *adev,uint32_t *smu_version);int amdgpu_dpm_set_light_sbr (struct amdgpu_device *adev,bool enable);int amdgpu_dpm_send_hbm_bad_pages_num (struct amdgpu_device *adev,uint32_t size);
drivers/gpu/drm/amd/pm/powerplay/Makefile +1 -1
@@ -28,7 +28,7 @@ AMD_POWERPLAY = $(addsuffix /Makefile,$(addprefix $(FULL_AMD_PATH)/pm/powerplay/ include $(AMD_POWERPLAY) -POWER_MGR-y = amd_powerplay.o +POWER_MGR-y = amd_powerplay.o legacy_dpm.o POWER_MGR-$(CONFIG_DRM_AMDGPU_CIK)+= kv_dpm.o kv_smc.o
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +4 -2
@@ -36,6 +36,7 @@#include "gca/gfx_7_2_d.h" #include "gca/gfx_7_2_sh_mask.h" +#include "legacy_dpm.h" #define KV_MAX_DEEPSLEEP_DIVIDER_ID 5#define KV_MINIMUM_ENGINE_CLOCK 800
@@ -3087,7 +3088,7 @@ static int kv_dpm_hw_init(void *handle)else adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev);return ret; }
@@ -3135,7 +3136,7 @@ static int kv_dpm_resume(void *handle) adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex);if (adev->pm.dpm_enabled) -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return 0 ; }
@@ -3389,6 +3390,7 @@ static const struct amd_pm_funcs kv_dpm_funcs = { .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, .read_sensor = &kv_dpm_read_sensor, + .change_power_state = amdgpu_dpm_change_power_state_locked, };static const struct amdgpu_irq_src_funcs kv_dpm_irq_funcs = {
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1024 -0
1,024 lines not on this page · raw message
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ +#ifndef __LEGACY_DPM_H__ +#define __LEGACY_DPM_H__ + +void amdgpu_dpm_print_class_info (u32 class,u32 class2); +void amdgpu_dpm_print_cap_info (u32 caps); +void amdgpu_dpm_print_ps_status (struct amdgpu_device *adev, +struct amdgpu_ps *rps); +int amdgpu_get_platform_caps (struct amdgpu_device *adev); +int amdgpu_parse_extended_power_table (struct amdgpu_device *adev); +void amdgpu_free_extended_power_table (struct amdgpu_device *adev); +void amdgpu_add_thermal_controller (struct amdgpu_device *adev); +struct amd_vce_state *amdgpu_get_vce_clock_state (void *handle,u32 idx); +int amdgpu_dpm_change_power_state_locked (void *handle); +void amdgpu_pm_print_power_states (struct amdgpu_device *adev); +#endif
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +4 -2
@@ -37,6 +37,7 @@#include <linux/math64.h> #include <linux/seq_file.h> #include <linux/firmware.h> +#include <legacy_dpm.h> #define MC_CG_ARB_FREQ_F0 0x0a#define MC_CG_ARB_FREQ_F1 0x0b
@@ -7800,7 +7801,7 @@ static int si_dpm_hw_init(void *handle)else adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev);return ret; }
@@ -7848,7 +7849,7 @@ static int si_dpm_resume(void *handle) adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex);if (adev->pm.dpm_enabled) -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return 0 ; }
@@ -8101,6 +8102,7 @@ static const struct amd_pm_funcs si_dpm_funcs = { .check_state_equal = &si_check_state_equal, .get_vce_clock_state = amdgpu_get_vce_clock_state, .read_sensor = &si_dpm_read_sensor, + .change_power_state = amdgpu_dpm_change_power_state_locked, };static const struct amdgpu_irq_src_funcs si_dpm_irq_funcs = {
Signature · 1 line
2.29.0
Re: [PATCH V3 07/17] drm/amd/pm: create a new holder for those APIs used only by legacy ASICs(si/kv)
Quoted 1,128 lines · Evan Quan
Those APIs are used only by legacy ASICs(si/kv). They cannot be shared by other ASICs. So, we create a new holder for them.
Signed-off-by Evan Quan <[email protected]>Change-Id I555dfa37e783a267b1d3b3a7db5c87fcc3f1556f--
v1->v2:
- renameamdgpu_pm_compute_clocksasamdgpu_dpm_compute_clocks(Lijo)--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 2 +- .../amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 2 +- .../gpu/drm/amd/include/kgd_pp_interface.h | 1 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 1022 +--------------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 17 +- drivers/gpu/drm/amd/pm/powerplay/Makefile | 2 +- drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c | 6 +- drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c | 1024 +++++++++++++++++ drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h | 37 + drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 6 +- 13 files changed, 1089 insertions(+), 1036 deletions(-)create mode 100644
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.ccreate mode 100644drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.hdrivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1
-1@@ -2532,7 +2532,7 @@ static void dce_v10_0_crtc_dpms(struct drm_crtc *crtc, int mode)break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v10_0_crtc_prepare (struct drm_crtc *crtc)drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1
-1@@ -2608,7 +2608,7 @@ static void dce_v11_0_crtc_dpms(struct drm_crtc *crtc, int mode)break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v11_0_crtc_prepare (struct drm_crtc *crtc)drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1
-1@@ -2424,7 +2424,7 @@ static void dce_v6_0_crtc_dpms(struct drm_crtc *crtc, int mode)break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v6_0_crtc_prepare (struct drm_crtc *crtc)drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1
-1@@ -2433,7 +2433,7 @@ static void dce_v8_0_crtc_dpms(struct drm_crtc *crtc, int mode)break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v8_0_crtc_prepare (struct drm_crtc *crtc)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +1
-1@@ -101,7 +101,7 @@ bool dm_pp_apply_display_requirements(amdgpu_dpm_display_configuration_change (adev, &adev->pm.pm_display_cfg); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return true;drivers/gpu/drm/amd/include/kgd_pp_interface.h +1
-0@@ -404,6 +404,7 @@ struct amd_pm_funcs {int (*get_dpm_clock_table)(void *handle,struct dpm_clocks *clock_table);int (*get_smu_prv_buf_details)(void *handle,void **addr,size_t *size); +int (*change_power_state)(void *handle); };struct metrics_table_header {drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-985@@ -34,113 +34,9 @@#define WIDTH_4K 3840 -#define amdgpu_dpm_pre_set_power_state (adev) \ - ((adev)->powerplay.pp_funcs->pre_set_power_state((adev)->powerplay.pp_handle)) - -#define amdgpu_dpm_post_set_power_state (adev) \ - ((adev)->powerplay.pp_funcs->post_set_power_state((adev)->powerplay.pp_handle)) - -#define amdgpu_dpm_display_configuration_changed (adev) \ - ((adev)->powerplay.pp_funcs->display_configuration_changed((adev)->powerplay.pp_handle)) - -#define amdgpu_dpm_print_power_state (adev, ps) \ - ((adev)->powerplay.pp_funcs->print_power_state((adev)->powerplay.pp_handle, (ps))) - -#define amdgpu_dpm_vblank_too_short (adev) \ - ((adev)->powerplay.pp_funcs->vblank_too_short((adev)->powerplay.pp_handle)) -#define amdgpu_dpm_enable_bapm (adev, e) \ ((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e))) -#define amdgpu_dpm_check_state_equal (adev, cps, rps, equal) \ - ((adev)->powerplay.pp_funcs->check_state_equal((adev)->powerplay.pp_handle, (cps), (rps), (equal))) - -void amdgpu_dpm_print_class_info (u32 class,u32 class2) -{ -const char *s; - -switch (class &ATOM_PPLIB_CLASSIFICATION_UI_MASK ) { -case ATOM_PPLIB_CLASSIFICATION_UI_NONE : -default : - s ="none" ; -break ; -case ATOM_PPLIB_CLASSIFICATION_UI_BATTERY : - s ="battery" ; -break ; -case ATOM_PPLIB_CLASSIFICATION_UI_BALANCED : - s ="balanced" ; -break ; -case ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE : - s ="performance" ; -break ; - } -printk ("\tui class: %s\n" , s); -printk ("\tinternal class:" ); -if (((class & ~ATOM_PPLIB_CLASSIFICATION_UI_MASK ) ==0 ) && - (class2 ==0 )) -pr_cont (" none" ); -else { -if (class &ATOM_PPLIB_CLASSIFICATION_BOOT ) -pr_cont (" boot" ); -if (class &ATOM_PPLIB_CLASSIFICATION_THERMAL ) -pr_cont (" thermal" ); -if (class &ATOM_PPLIB_CLASSIFICATION_LIMITEDPOWERSOURCE ) -pr_cont (" limited_pwr" ); -if (class &ATOM_PPLIB_CLASSIFICATION_REST ) -pr_cont (" rest" ); -if (class &ATOM_PPLIB_CLASSIFICATION_FORCED ) -pr_cont (" forced" ); -if (class &ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE ) -pr_cont (" 3d_perf" ); -if (class &ATOM_PPLIB_CLASSIFICATION_OVERDRIVETEMPLATE ) -pr_cont (" ovrdrv" ); -if (class &ATOM_PPLIB_CLASSIFICATION_UVDSTATE ) -pr_cont (" uvd" ); -if (class &ATOM_PPLIB_CLASSIFICATION_3DLOW ) -pr_cont (" 3d_low" ); -if (class &ATOM_PPLIB_CLASSIFICATION_ACPI ) -pr_cont (" acpi" ); -if (class &ATOM_PPLIB_CLASSIFICATION_HD2STATE ) -pr_cont (" uvd_hd2" ); -if (class &ATOM_PPLIB_CLASSIFICATION_HDSTATE ) -pr_cont (" uvd_hd" ); -if (class &ATOM_PPLIB_CLASSIFICATION_SDSTATE ) -pr_cont (" uvd_sd" ); -if (class2 &ATOM_PPLIB_CLASSIFICATION2_LIMITEDPOWERSOURCE_2 ) -pr_cont (" limited_pwr2" ); -if (class2 &ATOM_PPLIB_CLASSIFICATION2_ULV ) -pr_cont (" ulv" ); -if (class2 &ATOM_PPLIB_CLASSIFICATION2_MVC ) -pr_cont (" uvd_mvc" ); - } -pr_cont ("\n" ); -} - -void amdgpu_dpm_print_cap_info (u32 caps) -{ -printk ("\tcaps:" ); -if (caps &ATOM_PPLIB_SINGLE_DISPLAY_ONLY ) -pr_cont (" single_disp" ); -if (caps &ATOM_PPLIB_SUPPORTS_VIDEO_PLAYBACK ) -pr_cont (" video" ); -if (caps &ATOM_PPLIB_DISALLOW_ON_DC ) -pr_cont (" no_dc" ); -pr_cont ("\n" ); -} - -void amdgpu_dpm_print_ps_status (struct amdgpu_device *adev, -struct amdgpu_ps *rps) -{ -printk ("\tstatus:" ); -if (rps == adev->pm.dpm.current_ps) -pr_cont (" c" ); -if (rps == adev->pm.dpm.requested_ps) -pr_cont (" r" ); -if (rps == adev->pm.dpm.boot_ps) -pr_cont (" b" ); -pr_cont ("\n" ); -} -static void amdgpu_dpm_get_active_displays (struct amdgpu_device *adev) {struct drm_device *ddev =adev_to_drm (adev);@@ -161,7 +57,6 @@ static void amdgpu_dpm_get_active_displays(struct amdgpu_device *adev) } } -u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev) {struct drm_device *dev =adev_to_drm (adev);@@ -209,679 +104,6 @@ static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)return vrefresh; } -union power_info { -struct _ATOM_POWERPLAY_INFO info; -struct _ATOM_POWERPLAY_INFO_V2 info_2; -struct _ATOM_POWERPLAY_INFO_V3 info_3; -struct _ATOM_PPLIB_POWERPLAYTABLE pplib; -struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2; -struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3; -struct _ATOM_PPLIB_POWERPLAYTABLE4 pplib4; -struct _ATOM_PPLIB_POWERPLAYTABLE5 pplib5; -}; - -union fan_info { -struct _ATOM_PPLIB_FANTABLE fan; -struct _ATOM_PPLIB_FANTABLE2 fan2; -struct _ATOM_PPLIB_FANTABLE3 fan3; -}; - -static int amdgpu_parse_clk_voltage_dep_table (struct amdgpu_clock_voltage_dependency_table *amdgpu_table, -ATOM_PPLIB_Clock_Voltage_Dependency_Table *atom_table) -{ -u32 size = atom_table->ucNumEntries * -sizeof (struct amdgpu_clock_voltage_dependency_entry ); -int i; -ATOM_PPLIB_Clock_Voltage_Dependency_Record *entry; - - amdgpu_table->entries =kzalloc (size,GFP_KERNEL ); -if (!amdgpu_table->entries) -return -ENOMEM ; - - entry = &atom_table->entries[0 ]; -for (i =0 ; i < atom_table->ucNumEntries; i++) { - amdgpu_table->entries[i].clk =le16_to_cpu (entry->usClockLow) | - (entry->ucClockHigh <<16 ); - amdgpu_table->entries[i].v =le16_to_cpu (entry->usVoltage); - entry = (ATOM_PPLIB_Clock_Voltage_Dependency_Record *) - ((u8 *)entry +sizeof (ATOM_PPLIB_Clock_Voltage_Dependency_Record)); - } - amdgpu_table->count = atom_table->ucNumEntries; - -return 0 ; -} - -int amdgpu_get_platform_caps (struct amdgpu_device *adev) -{ -struct amdgpu_mode_info *mode_info = &adev->mode_info; -union power_info *power_info; -int index =GetIndexIntoMasterTable (DATA , PowerPlayInfo); -u16 data_offset; -u8 frev, crev; - -if (!amdgpu_atom_parse_data_header (mode_info->atom_context, index,NULL , - &frev, &crev, &data_offset)) -return -EINVAL ; - power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); - - adev->pm.dpm.platform_caps =le32_to_cpu (power_info->pplib.ulPlatformCaps); - adev->pm.dpm.backbias_response_time =le16_to_cpu (power_info->pplib.usBackbiasTime); - adev->pm.dpm.voltage_response_time =le16_to_cpu (power_info->pplib.usVoltageTime); - -return 0 ; -} - -/* sizeof(ATOM_PPLIB_EXTENDEDHEADER) */ -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2 12 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3 14 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V4 16 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V5 18 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V6 20 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V7 22 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V8 24 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V9 26 - -int amdgpu_parse_extended_power_table (struct amdgpu_device *adev) -{ -struct amdgpu_mode_info *mode_info = &adev->mode_info; -union power_info *power_info; -union fan_info *fan_info; -ATOM_PPLIB_Clock_Voltage_Dependency_Table *dep_table; -int index =GetIndexIntoMasterTable (DATA , PowerPlayInfo); -u16 data_offset; -u8 frev, crev; -int ret, i; - -if (!amdgpu_atom_parse_data_header (mode_info->atom_context, index,NULL , - &frev, &crev, &data_offset)) -return -EINVAL ; - power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); - -/* fan table */ -if (le16_to_cpu (power_info->pplib.usTableSize) >= -sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE3 )) { -if (power_info->pplib3.usFanTableOffset) { - fan_info = (union fan_info *)(mode_info->atom_context->bios + data_offset + -le16_to_cpu (power_info->pplib3.usFanTableOffset)); - adev->pm.dpm.fan.t_hyst = fan_info->fan.ucTHyst; - adev->pm.dpm.fan.t_min =le16_to_cpu (fan_info->fan.usTMin); - adev->pm.dpm.fan.t_med =le16_to_cpu (fan_info->fan.usTMed); - adev->pm.dpm.fan.t_high =le16_to_cpu (fan_info->fan.usTHigh); - adev->pm.dpm.fan.pwm_min =le16_to_cpu (fan_info->fan.usPWMMin); - adev->pm.dpm.fan.pwm_med =le16_to_cpu (fan_info->fan.usPWMMed); - adev->pm.dpm.fan.pwm_high =le16_to_cpu (fan_info->fan.usPWMHigh); -if (fan_info->fan.ucFanTableFormat >=2 ) - adev->pm.dpm.fan.t_max =le16_to_cpu (fan_info->fan2.usTMax); -else - adev->pm.dpm.fan.t_max =10900 ; - adev->pm.dpm.fan.cycle_delay =100000 ; -if (fan_info->fan.ucFanTableFormat >=3 ) { - adev->pm.dpm.fan.control_mode = fan_info->fan3.ucFanControlMode; - adev->pm.dpm.fan.default_max_fan_pwm = -le16_to_cpu (fan_info->fan3.usFanPWMMax); - adev->pm.dpm.fan.default_fan_output_sensitivity =4836 ; - adev->pm.dpm.fan.fan_output_sensitivity = -le16_to_cpu (fan_info->fan3.usFanOutputSensitivity); - } - adev->pm.dpm.fan.ucode_fan_control = true; - } - } - -/* clock dependancy tables, shedding tables */ -if (le16_to_cpu (power_info->pplib.usTableSize) >= -sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE4 )) { -if (power_info->pplib4.usVddcDependencyOnSCLKOffset) { - dep_table = (ATOM_PPLIB_Clock_Voltage_Dependency_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (power_info->pplib4.usVddcDependencyOnSCLKOffset)); - ret =amdgpu_parse_clk_voltage_dep_table (&adev->pm.dpm.dyn_state.vddc_dependency_on_sclk, - dep_table); -if (ret) { -amdgpu_free_extended_power_table (adev); -return ret; - } - } -if (power_info->pplib4.usVddciDependencyOnMCLKOffset) { - dep_table = (ATOM_PPLIB_Clock_Voltage_Dependency_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (power_info->pplib4.usVddciDependencyOnMCLKOffset)); - ret =amdgpu_parse_clk_voltage_dep_table (&adev->pm.dpm.dyn_state.vddci_dependency_on_mclk, - dep_table); -if (ret) { -amdgpu_free_extended_power_table (adev); -return ret; - } - } -if (power_info->pplib4.usVddcDependencyOnMCLKOffset) { - dep_table = (ATOM_PPLIB_Clock_Voltage_Dependency_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (power_info->pplib4.usVddcDependencyOnMCLKOffset)); - ret =amdgpu_parse_clk_voltage_dep_table (&adev->pm.dpm.dyn_state.vddc_dependency_on_mclk, - dep_table); -if (ret) { -amdgpu_free_extended_power_table (adev); -return ret; - } - } -if (power_info->pplib4.usMvddDependencyOnMCLKOffset) { - dep_table = (ATOM_PPLIB_Clock_Voltage_Dependency_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (power_info->pplib4.usMvddDependencyOnMCLKOffset)); - ret =amdgpu_parse_clk_voltage_dep_table (&adev->pm.dpm.dyn_state.mvdd_dependency_on_mclk, - dep_table); -if (ret) { -amdgpu_free_extended_power_table (adev); -return ret; - } - } -if (power_info->pplib4.usMaxClockVoltageOnDCOffset) { -ATOM_PPLIB_Clock_Voltage_Limit_Table *clk_v = - (ATOM_PPLIB_Clock_Voltage_Limit_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (power_info->pplib4.usMaxClockVoltageOnDCOffset)); -if (clk_v->ucNumEntries) { - adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk = -le16_to_cpu (clk_v->entries[0 ].usSclkLow) | - (clk_v->entries[0 ].ucSclkHigh <<16 ); - adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk = -le16_to_cpu (clk_v->entries[0 ].usMclkLow) | - (clk_v->entries[0 ].ucMclkHigh <<16 ); - adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc = -le16_to_cpu (clk_v->entries[0 ].usVddc); - adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddci = -le16_to_cpu (clk_v->entries[0 ].usVddci); - } - } -if (power_info->pplib4.usVddcPhaseShedLimitsTableOffset) { -ATOM_PPLIB_PhaseSheddingLimits_Table *psl = - (ATOM_PPLIB_PhaseSheddingLimits_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (power_info->pplib4.usVddcPhaseShedLimitsTableOffset)); -ATOM_PPLIB_PhaseSheddingLimits_Record *entry; - - adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries = -kcalloc (psl->ucNumEntries, -sizeof (struct amdgpu_phase_shedding_limits_entry ), -GFP_KERNEL ); -if (!adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) { -amdgpu_free_extended_power_table (adev); -return -ENOMEM ; - } - - entry = &psl->entries[0 ]; -for (i =0 ; i < psl->ucNumEntries; i++) { - adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].sclk = -le16_to_cpu (entry->usSclkLow) | (entry->ucSclkHigh <<16 ); - adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].mclk = -le16_to_cpu (entry->usMclkLow) | (entry->ucMclkHigh <<16 ); - adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].voltage = -le16_to_cpu (entry->usVoltage); - entry = (ATOM_PPLIB_PhaseSheddingLimits_Record *) - ((u8 *)entry +sizeof (ATOM_PPLIB_PhaseSheddingLimits_Record)); - } - adev->pm.dpm.dyn_state.phase_shedding_limits_table.count = - psl->ucNumEntries; - } - } - -/* cac data */ -if (le16_to_cpu (power_info->pplib.usTableSize) >= -sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE5 )) { - adev->pm.dpm.tdp_limit =le32_to_cpu (power_info->pplib5.ulTDPLimit); - adev->pm.dpm.near_tdp_limit =le32_to_cpu (power_info->pplib5.ulNearTDPLimit); - adev->pm.dpm.near_tdp_limit_adjusted = adev->pm.dpm.near_tdp_limit; - adev->pm.dpm.tdp_od_limit =le16_to_cpu (power_info->pplib5.usTDPODLimit); -if (adev->pm.dpm.tdp_od_limit) - adev->pm.dpm.power_control = true; -else - adev->pm.dpm.power_control = false; - adev->pm.dpm.tdp_adjustment =0 ; - adev->pm.dpm.sq_ramping_threshold =le32_to_cpu (power_info->pplib5.ulSQRampingThreshold); - adev->pm.dpm.cac_leakage =le32_to_cpu (power_info->pplib5.ulCACLeakage); - adev->pm.dpm.load_line_slope =le16_to_cpu (power_info->pplib5.usLoadLineSlope); -if (power_info->pplib5.usCACLeakageTableOffset) { -ATOM_PPLIB_CAC_Leakage_Table *cac_table = - (ATOM_PPLIB_CAC_Leakage_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (power_info->pplib5.usCACLeakageTableOffset)); -ATOM_PPLIB_CAC_Leakage_Record *entry; -u32 size = cac_table->ucNumEntries *sizeof (struct amdgpu_cac_leakage_table ); - adev->pm.dpm.dyn_state.cac_leakage_table.entries =kzalloc (size,GFP_KERNEL ); -if (!adev->pm.dpm.dyn_state.cac_leakage_table.entries) { -amdgpu_free_extended_power_table (adev); -return -ENOMEM ; - } - entry = &cac_table->entries[0 ]; -for (i =0 ; i < cac_table->ucNumEntries; i++) { -if (adev->pm.dpm.platform_caps &ATOM_PP_PLATFORM_CAP_EVV ) { - adev->pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc1 = -le16_to_cpu (entry->usVddc1); - adev->pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc2 = -le16_to_cpu (entry->usVddc2); - adev->pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc3 = -le16_to_cpu (entry->usVddc3); - }else { - adev->pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc = -le16_to_cpu (entry->usVddc); - adev->pm.dpm.dyn_state.cac_leakage_table.entries[i].leakage = -le32_to_cpu (entry->ulLeakageValue); - } - entry = (ATOM_PPLIB_CAC_Leakage_Record *) - ((u8 *)entry +sizeof (ATOM_PPLIB_CAC_Leakage_Record)); - } - adev->pm.dpm.dyn_state.cac_leakage_table.count = cac_table->ucNumEntries; - } - } - -/* ext tables */ -if (le16_to_cpu (power_info->pplib.usTableSize) >= -sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE3 )) { -ATOM_PPLIB_EXTENDEDHEADER *ext_hdr = (ATOM_PPLIB_EXTENDEDHEADER *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (power_info->pplib3.usExtendendedHeaderOffset)); -if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2 ) && - ext_hdr->usVCETableOffset) { -VCEClockInfoArray *array = (VCEClockInfoArray *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usVCETableOffset) +1 ); -ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table *limits = - (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usVCETableOffset) +1 + -1 + array->ucNumEntries *sizeof (VCEClockInfo)); -ATOM_PPLIB_VCE_State_Table *states = - (ATOM_PPLIB_VCE_State_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usVCETableOffset) +1 + -1 + (array->ucNumEntries *sizeof (VCEClockInfo)) + -1 + (limits->numEntries *sizeof (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record))); -ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record *entry; -ATOM_PPLIB_VCE_State_Record *state_entry; -VCEClockInfo *vce_clk; -u32 size = limits->numEntries * -sizeof (struct amdgpu_vce_clock_voltage_dependency_entry ); - adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries = -kzalloc (size,GFP_KERNEL ); -if (!adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries) { -amdgpu_free_extended_power_table (adev); -return -ENOMEM ; - } - adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.count = - limits->numEntries; - entry = &limits->entries[0 ]; - state_entry = &states->entries[0 ]; -for (i =0 ; i < limits->numEntries; i++) { - vce_clk = (VCEClockInfo *) - ((u8 *)&array->entries[0 ] + - (entry->ucVCEClockInfoIndex *sizeof (VCEClockInfo))); - adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries[i].evclk = -le16_to_cpu (vce_clk->usEVClkLow) | (vce_clk->ucEVClkHigh <<16 ); - adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries[i].ecclk = -le16_to_cpu (vce_clk->usECClkLow) | (vce_clk->ucECClkHigh <<16 ); - adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries[i].v = -le16_to_cpu (entry->usVoltage); - entry = (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record *) - ((u8 *)entry +sizeof (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record)); - } - adev->pm.dpm.num_of_vce_states = - states->numEntries >AMD_MAX_VCE_LEVELS ? -AMD_MAX_VCE_LEVELS : states->numEntries; -for (i =0 ; i < adev->pm.dpm.num_of_vce_states; i++) { - vce_clk = (VCEClockInfo *) - ((u8 *)&array->entries[0 ] + - (state_entry->ucVCEClockInfoIndex *sizeof (VCEClockInfo))); - adev->pm.dpm.vce_states[i].evclk = -le16_to_cpu (vce_clk->usEVClkLow) | (vce_clk->ucEVClkHigh <<16 ); - adev->pm.dpm.vce_states[i].ecclk = -le16_to_cpu (vce_clk->usECClkLow) | (vce_clk->ucECClkHigh <<16 ); - adev->pm.dpm.vce_states[i].clk_idx = - state_entry->ucClockInfoIndex &0x3f ; - adev->pm.dpm.vce_states[i].pstate = - (state_entry->ucClockInfoIndex &0xc0 ) >>6 ; - state_entry = (ATOM_PPLIB_VCE_State_Record *) - ((u8 *)state_entry +sizeof (ATOM_PPLIB_VCE_State_Record)); - } - } -if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3 ) && - ext_hdr->usUVDTableOffset) { -UVDClockInfoArray *array = (UVDClockInfoArray *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usUVDTableOffset) +1 ); -ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table *limits = - (ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usUVDTableOffset) +1 + -1 + (array->ucNumEntries *sizeof (UVDClockInfo))); -ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record *entry; -u32 size = limits->numEntries * -sizeof (struct amdgpu_uvd_clock_voltage_dependency_entry ); - adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries = -kzalloc (size,GFP_KERNEL ); -if (!adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries) { -amdgpu_free_extended_power_table (adev); -return -ENOMEM ; - } - adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.count = - limits->numEntries; - entry = &limits->entries[0 ]; -for (i =0 ; i < limits->numEntries; i++) { -UVDClockInfo *uvd_clk = (UVDClockInfo *) - ((u8 *)&array->entries[0 ] + - (entry->ucUVDClockInfoIndex *sizeof (UVDClockInfo))); - adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries[i].vclk = -le16_to_cpu (uvd_clk->usVClkLow) | (uvd_clk->ucVClkHigh <<16 ); - adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries[i].dclk = -le16_to_cpu (uvd_clk->usDClkLow) | (uvd_clk->ucDClkHigh <<16 ); - adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries[i].v = -le16_to_cpu (entry->usVoltage); - entry = (ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record *) - ((u8 *)entry +sizeof (ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record)); - } - } -if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V4 ) && - ext_hdr->usSAMUTableOffset) { -ATOM_PPLIB_SAMClk_Voltage_Limit_Table *limits = - (ATOM_PPLIB_SAMClk_Voltage_Limit_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usSAMUTableOffset) +1 ); -ATOM_PPLIB_SAMClk_Voltage_Limit_Record *entry; -u32 size = limits->numEntries * -sizeof (struct amdgpu_clock_voltage_dependency_entry ); - adev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries = -kzalloc (size,GFP_KERNEL ); -if (!adev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries) { -amdgpu_free_extended_power_table (adev); -return -ENOMEM ; - } - adev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.count = - limits->numEntries; - entry = &limits->entries[0 ]; -for (i =0 ; i < limits->numEntries; i++) { - adev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries[i].clk = -le16_to_cpu (entry->usSAMClockLow) | (entry->ucSAMClockHigh <<16 ); - adev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries[i].v = -le16_to_cpu (entry->usVoltage); - entry = (ATOM_PPLIB_SAMClk_Voltage_Limit_Record *) - ((u8 *)entry +sizeof (ATOM_PPLIB_SAMClk_Voltage_Limit_Record)); - } - } -if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V5 ) && - ext_hdr->usPPMTableOffset) { -ATOM_PPLIB_PPM_Table *ppm = (ATOM_PPLIB_PPM_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usPPMTableOffset)); - adev->pm.dpm.dyn_state.ppm_table = -kzalloc (sizeof (struct amdgpu_ppm_table ),GFP_KERNEL ); -if (!adev->pm.dpm.dyn_state.ppm_table) { -amdgpu_free_extended_power_table (adev); -return -ENOMEM ; - } - adev->pm.dpm.dyn_state.ppm_table->ppm_design = ppm->ucPpmDesign; - adev->pm.dpm.dyn_state.ppm_table->cpu_core_number = -le16_to_cpu (ppm->usCpuCoreNumber); - adev->pm.dpm.dyn_state.ppm_table->platform_tdp = -le32_to_cpu (ppm->ulPlatformTDP); - adev->pm.dpm.dyn_state.ppm_table->small_ac_platform_tdp = -le32_to_cpu (ppm->ulSmallACPlatformTDP); - adev->pm.dpm.dyn_state.ppm_table->platform_tdc = -le32_to_cpu (ppm->ulPlatformTDC); - adev->pm.dpm.dyn_state.ppm_table->small_ac_platform_tdc = -le32_to_cpu (ppm->ulSmallACPlatformTDC); - adev->pm.dpm.dyn_state.ppm_table->apu_tdp = -le32_to_cpu (ppm->ulApuTDP); - adev->pm.dpm.dyn_state.ppm_table->dgpu_tdp = -le32_to_cpu (ppm->ulDGpuTDP); - adev->pm.dpm.dyn_state.ppm_table->dgpu_ulv_power = -le32_to_cpu (ppm->ulDGpuUlvPower); - adev->pm.dpm.dyn_state.ppm_table->tj_max = -le32_to_cpu (ppm->ulTjmax); - } -if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V6 ) && - ext_hdr->usACPTableOffset) { -ATOM_PPLIB_ACPClk_Voltage_Limit_Table *limits = - (ATOM_PPLIB_ACPClk_Voltage_Limit_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usACPTableOffset) +1 ); -ATOM_PPLIB_ACPClk_Voltage_Limit_Record *entry; -u32 size = limits->numEntries * -sizeof (struct amdgpu_clock_voltage_dependency_entry ); - adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries = -kzalloc (size,GFP_KERNEL ); -if (!adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries) { -amdgpu_free_extended_power_table (adev); -return -ENOMEM ; - } - adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.count = - limits->numEntries; - entry = &limits->entries[0 ]; -for (i =0 ; i < limits->numEntries; i++) { - adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries[i].clk = -le16_to_cpu (entry->usACPClockLow) | (entry->ucACPClockHigh <<16 ); - adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries[i].v = -le16_to_cpu (entry->usVoltage); - entry = (ATOM_PPLIB_ACPClk_Voltage_Limit_Record *) - ((u8 *)entry +sizeof (ATOM_PPLIB_ACPClk_Voltage_Limit_Record)); - } - } -if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V7 ) && - ext_hdr->usPowerTuneTableOffset) { -u8 rev = *(u8 *)(mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usPowerTuneTableOffset)); -ATOM_PowerTune_Table *pt; - adev->pm.dpm.dyn_state.cac_tdp_table = -kzalloc (sizeof (struct amdgpu_cac_tdp_table ),GFP_KERNEL ); -if (!adev->pm.dpm.dyn_state.cac_tdp_table) { -amdgpu_free_extended_power_table (adev); -return -ENOMEM ; - } -if (rev >0 ) { -ATOM_PPLIB_POWERTUNE_Table_V1 *ppt = (ATOM_PPLIB_POWERTUNE_Table_V1 *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usPowerTuneTableOffset)); - adev->pm.dpm.dyn_state.cac_tdp_table->maximum_power_delivery_limit = - ppt->usMaximumPowerDeliveryLimit; - pt = &ppt->power_tune_table; - }else { -ATOM_PPLIB_POWERTUNE_Table *ppt = (ATOM_PPLIB_POWERTUNE_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usPowerTuneTableOffset)); - adev->pm.dpm.dyn_state.cac_tdp_table->maximum_power_delivery_limit =255 ; - pt = &ppt->power_tune_table; - } - adev->pm.dpm.dyn_state.cac_tdp_table->tdp =le16_to_cpu (pt->usTDP); - adev->pm.dpm.dyn_state.cac_tdp_table->configurable_tdp = -le16_to_cpu (pt->usConfigurableTDP); - adev->pm.dpm.dyn_state.cac_tdp_table->tdc =le16_to_cpu (pt->usTDC); - adev->pm.dpm.dyn_state.cac_tdp_table->battery_power_limit = -le16_to_cpu (pt->usBatteryPowerLimit); - adev->pm.dpm.dyn_state.cac_tdp_table->small_power_limit = -le16_to_cpu (pt->usSmallPowerLimit); - adev->pm.dpm.dyn_state.cac_tdp_table->low_cac_leakage = -le16_to_cpu (pt->usLowCACLeakage); - adev->pm.dpm.dyn_state.cac_tdp_table->high_cac_leakage = -le16_to_cpu (pt->usHighCACLeakage); - } -if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V8 ) && - ext_hdr->usSclkVddgfxTableOffset) { - dep_table = (ATOM_PPLIB_Clock_Voltage_Dependency_Table *) - (mode_info->atom_context->bios + data_offset + -le16_to_cpu (ext_hdr->usSclkVddgfxTableOffset)); - ret =amdgpu_parse_clk_voltage_dep_table ( - &adev->pm.dpm.dyn_state.vddgfx_dependency_on_sclk, - dep_table); -if (ret) { -kfree (adev->pm.dpm.dyn_state.vddgfx_dependency_on_sclk.entries); -return ret; - } - } - } - -return 0 ; -} - -void amdgpu_free_extended_power_table (struct amdgpu_device *adev) -{ -struct amdgpu_dpm_dynamic_state *dyn_state = &adev->pm.dpm.dyn_state; - -kfree (dyn_state->vddc_dependency_on_sclk.entries); -kfree (dyn_state->vddci_dependency_on_mclk.entries); -kfree (dyn_state->vddc_dependency_on_mclk.entries); -kfree (dyn_state->mvdd_dependency_on_mclk.entries); -kfree (dyn_state->cac_leakage_table.entries); -kfree (dyn_state->phase_shedding_limits_table.entries); -kfree (dyn_state->ppm_table); -kfree (dyn_state->cac_tdp_table); -kfree (dyn_state->vce_clock_voltage_dependency_table.entries); -kfree (dyn_state->uvd_clock_voltage_dependency_table.entries); -kfree (dyn_state->samu_clock_voltage_dependency_table.entries); -kfree (dyn_state->acp_clock_voltage_dependency_table.entries); -kfree (dyn_state->vddgfx_dependency_on_sclk.entries); -} - -static const char *pp_lib_thermal_controller_names[] = { -"NONE" , -"lm63" , -"adm1032" , -"adm1030" , -"max6649" , -"lm64" , -"f75375" , -"RV6xx" , -"RV770" , -"adt7473" , -"NONE" , -"External GPIO" , -"Evergreen" , -"emc2103" , -"Sumo" , -"Northern Islands" , -"Southern Islands" , -"lm96163" , -"Sea Islands" , -"Kaveri/Kabini" , -}; - -void amdgpu_add_thermal_controller (struct amdgpu_device *adev) -{ -struct amdgpu_mode_info *mode_info = &adev->mode_info; -ATOM_PPLIB_POWERPLAYTABLE *power_table; -int index =GetIndexIntoMasterTable (DATA , PowerPlayInfo); -ATOM_PPLIB_THERMALCONTROLLER *controller; -struct amdgpu_i2c_bus_rec i2c_bus; -u16 data_offset; -u8 frev, crev; - -if (!amdgpu_atom_parse_data_header (mode_info->atom_context, index,NULL , - &frev, &crev, &data_offset)) -return ; - power_table = (ATOM_PPLIB_POWERPLAYTABLE *) - (mode_info->atom_context->bios + data_offset); - controller = &power_table->sThermalController; - -/* add the i2c bus for thermal/fan chip */ -if (controller->ucType >0 ) { -if (controller->ucFanParameters &ATOM_PP_FANPARAMETERS_NOFAN ) - adev->pm.no_fan = true; - adev->pm.fan_pulses_per_revolution = - controller->ucFanParameters &ATOM_PP_FANPARAMETERS_TACHOMETER_PULSES_PER_REVOLUTION_MASK ; -if (adev->pm.fan_pulses_per_revolution) { - adev->pm.fan_min_rpm = controller->ucFanMinRPM; - adev->pm.fan_max_rpm = controller->ucFanMaxRPM; - } -if (controller->ucType == ATOM_PP_THERMALCONTROLLER_RV6xx) { -DRM_INFO ("Internal thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_RV6XX ; - }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_RV770 ) { -DRM_INFO ("Internal thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_RV770 ; - }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_EVERGREEN ) { -DRM_INFO ("Internal thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_EVERGREEN ; - }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_SUMO ) { -DRM_INFO ("Internal thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_SUMO ; - }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_NISLANDS ) { -DRM_INFO ("Internal thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_NI ; - }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_SISLANDS ) { -DRM_INFO ("Internal thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_SI ; - }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_CISLANDS ) { -DRM_INFO ("Internal thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_CI ; - }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_KAVERI ) { -DRM_INFO ("Internal thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_KV ; - }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_EXTERNAL_GPIO ) { -DRM_INFO ("External GPIO thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_EXTERNAL_GPIO ; - }else if (controller->ucType == -ATOM_PP_THERMALCONTROLLER_ADT7473_WITH_INTERNAL ) { -DRM_INFO ("ADT7473 with internal thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_ADT7473_WITH_INTERNAL ; - }else if (controller->ucType == -ATOM_PP_THERMALCONTROLLER_EMC2103_WITH_INTERNAL ) { -DRM_INFO ("EMC2103 with internal thermal controller %s fan control\n" , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_EMC2103_WITH_INTERNAL ; - }else if (controller->ucType <ARRAY_SIZE (pp_lib_thermal_controller_names)) { -DRM_INFO ("Possible %s thermal controller at 0x%02x %s fan control\n" , - pp_lib_thermal_controller_names[controller->ucType], - controller->ucI2cAddress >>1 , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - adev->pm.int_thermal_type =THERMAL_TYPE_EXTERNAL ; - i2c_bus =amdgpu_atombios_lookup_i2c_gpio (adev, controller->ucI2cLine); - adev->pm.i2c_bus =amdgpu_i2c_lookup (adev, &i2c_bus); -if (adev->pm.i2c_bus) { -struct i2c_board_info info = { }; -const char *name = pp_lib_thermal_controller_names[controller->ucType]; - info.addr = controller->ucI2cAddress >>1 ; -strlcpy (info.type, name,sizeof (info.type)); -i2c_new_client_device (&adev->pm.i2c_bus->adapter, &info); - } - }else { -DRM_INFO ("Unknown thermal controller type %d at 0x%02x %s fan control\n" , - controller->ucType, - controller->ucI2cAddress >>1 , - (controller->ucFanParameters & -ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); - } - } -} - -struct amd_vce_state * -amdgpu_get_vce_clock_state (void *handle,u32 idx) -{ -struct amdgpu_device *adev = (struct amdgpu_device *)handle; - -if (idx < adev->pm.dpm.num_of_vce_states) -return &adev->pm.dpm.vce_states[idx]; - -return NULL ; -} -int amdgpu_dpm_get_sclk (struct amdgpu_device *adev,bool low) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;@@ -1240,215 +462,10 @@ void amdgpu_dpm_thermal_work_handler(struct work_struct *work) adev->pm.dpm.state = dpm_state;mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); } -static struct amdgpu_ps *amdgpu_dpm_pick_power_state (struct amdgpu_device *adev, -enum amd_pm_state_type dpm_state) -{ -int i; -struct amdgpu_ps *ps; -u32 ui_class; -bool single_display = (adev->pm.dpm.new_active_crtc_count <2 ) ? - true : false; - -/* check if the vblank period is too short to adjust the mclk */ -if (single_display && adev->powerplay.pp_funcs->vblank_too_short) { -if (amdgpu_dpm_vblank_too_short (adev)) - single_display = false; - } - -/* certain older asics have a separare 3D performance state, -* so try that first if the user selected performance -*/ -if (dpm_state ==POWER_STATE_TYPE_PERFORMANCE ) - dpm_state =POWER_STATE_TYPE_INTERNAL_3DPERF ; -/* balanced states don't exist at the moment */ -if (dpm_state ==POWER_STATE_TYPE_BALANCED ) - dpm_state =POWER_STATE_TYPE_PERFORMANCE ; - -restart_search: -/* Pick the best power state based on current conditions */ -for (i =0 ; i < adev->pm.dpm.num_ps; i++) { - ps = &adev->pm.dpm.ps[i]; - ui_class = ps->class &ATOM_PPLIB_CLASSIFICATION_UI_MASK ; -switch (dpm_state) { -/* user states */ -case POWER_STATE_TYPE_BATTERY : -if (ui_class ==ATOM_PPLIB_CLASSIFICATION_UI_BATTERY ) { -if (ps->caps &ATOM_PPLIB_SINGLE_DISPLAY_ONLY ) { -if (single_display) -return ps; - }else -return ps; - } -break ; -case POWER_STATE_TYPE_BALANCED : -if (ui_class ==ATOM_PPLIB_CLASSIFICATION_UI_BALANCED ) { -if (ps->caps &ATOM_PPLIB_SINGLE_DISPLAY_ONLY ) { -if (single_display) -return ps; - }else -return ps; - } -break ; -case POWER_STATE_TYPE_PERFORMANCE : -if (ui_class ==ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE ) { -if (ps->caps &ATOM_PPLIB_SINGLE_DISPLAY_ONLY ) { -if (single_display) -return ps; - }else -return ps; - } -break ; -/* internal states */ -case POWER_STATE_TYPE_INTERNAL_UVD : -if (adev->pm.dpm.uvd_ps) -return adev->pm.dpm.uvd_ps; -else -break ; -case POWER_STATE_TYPE_INTERNAL_UVD_SD : -if (ps->class &ATOM_PPLIB_CLASSIFICATION_SDSTATE ) -return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_UVD_HD : -if (ps->class &ATOM_PPLIB_CLASSIFICATION_HDSTATE ) -return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_UVD_HD2 : -if (ps->class &ATOM_PPLIB_CLASSIFICATION_HD2STATE ) -return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_UVD_MVC : -if (ps->class2 &ATOM_PPLIB_CLASSIFICATION2_MVC ) -return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_BOOT : -return adev->pm.dpm.boot_ps; -case POWER_STATE_TYPE_INTERNAL_THERMAL : -if (ps->class &ATOM_PPLIB_CLASSIFICATION_THERMAL ) -return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_ACPI : -if (ps->class &ATOM_PPLIB_CLASSIFICATION_ACPI ) -return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_ULV : -if (ps->class2 &ATOM_PPLIB_CLASSIFICATION2_ULV ) -return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_3DPERF : -if (ps->class &ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE ) -return ps; -break ; -default : -break ; - } - } -/* use a fallback state if we didn't match */ -switch (dpm_state) { -case POWER_STATE_TYPE_INTERNAL_UVD_SD : - dpm_state =POWER_STATE_TYPE_INTERNAL_UVD_HD ; - goto restart_search; -case POWER_STATE_TYPE_INTERNAL_UVD_HD : -case POWER_STATE_TYPE_INTERNAL_UVD_HD2 : -case POWER_STATE_TYPE_INTERNAL_UVD_MVC : -if (adev->pm.dpm.uvd_ps) { -return adev->pm.dpm.uvd_ps; - }else { - dpm_state =POWER_STATE_TYPE_PERFORMANCE ; - goto restart_search; - } -case POWER_STATE_TYPE_INTERNAL_THERMAL : - dpm_state =POWER_STATE_TYPE_INTERNAL_ACPI ; - goto restart_search; -case POWER_STATE_TYPE_INTERNAL_ACPI : - dpm_state =POWER_STATE_TYPE_BATTERY ; - goto restart_search; -case POWER_STATE_TYPE_BATTERY : -case POWER_STATE_TYPE_BALANCED : -case POWER_STATE_TYPE_INTERNAL_3DPERF : - dpm_state =POWER_STATE_TYPE_PERFORMANCE ; - goto restart_search; -default : -break ; - } - -return NULL ; -} - -static void amdgpu_dpm_change_power_state_locked (struct amdgpu_device *adev) -{ -struct amdgpu_ps *ps; -enum amd_pm_state_type dpm_state; -int ret; -bool equal = false; - -/* if dpm init failed */ -if (!adev->pm.dpm_enabled) -return ; - -if (adev->pm.dpm.user_state != adev->pm.dpm.state) { -/* add other state override checks here */ -if ((!adev->pm.dpm.thermal_active) && - (!adev->pm.dpm.uvd_active)) - adev->pm.dpm.state = adev->pm.dpm.user_state; - } - dpm_state = adev->pm.dpm.state; - - ps =amdgpu_dpm_pick_power_state (adev, dpm_state); -if (ps) - adev->pm.dpm.requested_ps = ps; -else -return ; - -if (amdgpu_dpm ==1 && adev->powerplay.pp_funcs->print_power_state) { -printk ("switching from power state:\n" ); -amdgpu_dpm_print_power_state (adev, adev->pm.dpm.current_ps); -printk ("switching to power state:\n" ); -amdgpu_dpm_print_power_state (adev, adev->pm.dpm.requested_ps); - } - -/* update whether vce is active */ - ps->vce_active = adev->pm.dpm.vce_active; -if (adev->powerplay.pp_funcs->display_configuration_changed) -amdgpu_dpm_display_configuration_changed (adev); - - ret =amdgpu_dpm_pre_set_power_state (adev); -if (ret) -return ; - -if (adev->powerplay.pp_funcs->check_state_equal) { -if (0 !=amdgpu_dpm_check_state_equal (adev, adev->pm.dpm.current_ps, adev->pm.dpm.requested_ps, &equal)) - equal = false; - } - -if (equal) -return ; - -if (adev->powerplay.pp_funcs->set_power_state) - adev->powerplay.pp_funcs->set_power_state (adev->powerplay.pp_handle); - -amdgpu_dpm_post_set_power_state (adev); - - adev->pm.dpm.current_active_crtcs = adev->pm.dpm.new_active_crtcs; - adev->pm.dpm.current_active_crtc_count = adev->pm.dpm.new_active_crtc_count; - -if (adev->powerplay.pp_funcs->force_performance_level) { -if (adev->pm.dpm.thermal_active) { -enum amd_dpm_forced_level level = adev->pm.dpm.forced_level; -/* force low perf level for thermal */ -amdgpu_dpm_force_performance_level (adev,AMD_DPM_FORCED_LEVEL_LOW ); -/* save the user's level */ - adev->pm.dpm.forced_level = level; - }else { -/* otherwise, user selected level */ -amdgpu_dpm_force_performance_level (adev, adev->pm.dpm.forced_level); - } - } -} - -void amdgpu_pm_compute_clocks (struct amdgpu_device *adev) +void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev) {int i =0 ;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_pm_compute_clocks(struct amdgpu_device *adev) · line 487
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-1@@ -1464,9 +481,12 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)amdgpu_fence_wait_empty (ring); } -if (adev->powerplay.pp_funcs->dispatch_tasks) { +if ((adev->family ==AMDGPU_FAMILY_SI ) || + (adev->family ==AMDGPU_FAMILY_KV )) { +amdgpu_dpm_get_active_displays (adev); + adev->powerplay.pp_funcs->change_power_state (adev->powerplay.pp_handle);
Missed this earlier. This also subtly drops the mutex lock (here and below). Is that intended?
Thanks,
Lijo
Quoted 1,290 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +6
-24+ }else {if (!amdgpu_device_has_dc_support (adev)) { -mutex_lock (&adev->pm.mutex);amdgpu_dpm_get_active_displays (adev); adev->pm.pm_display_cfg.num_display = adev->pm.dpm.new_active_crtc_count; adev->pm.pm_display_cfg.vrefresh =amdgpu_dpm_get_vrefresh (adev);@@ -1480,14 +500,8 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev) adev->powerplay.pp_funcs->display_configuration_change ( adev->powerplay.pp_handle, &adev->pm.pm_display_cfg); -mutex_unlock (&adev->pm.mutex); }amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_DISPLAY_CONFIG_CHANGE ,NULL ); - }else { -mutex_lock (&adev->pm.mutex); -amdgpu_dpm_get_active_displays (adev); -amdgpu_dpm_change_power_state_locked (adev); -mutex_unlock (&adev->pm.mutex); } }@@ -1505,7 +519,7 @@ void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable) }mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }else { ret =amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_UVD , !enable);if (ret)@@ -1541,7 +555,7 @@ void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable) }mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }else { ret =amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_VCE , !enable);if (ret)@@ -1550,18 +564,6 @@ void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable) } } -void amdgpu_pm_print_power_states (struct amdgpu_device *adev) -{ -int i; - -if (adev->powerplay.pp_funcs->print_power_state ==NULL ) -return ; - -for (i =0 ; i < adev->pm.dpm.num_ps; i++) -amdgpu_dpm_print_power_state (adev, &adev->pm.dpm.ps[i]); - -} -void amdgpu_dpm_enable_jpeg (struct amdgpu_device *adev,bool enable) {int ret =0 ;@@ -1724,7 +726,7 @@ void amdgpu_dpm_set_power_state(struct amdgpu_device *adev,if (adev->powerplay.pp_funcs->dispatch_tasks)amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_ENABLE_USER_STATE , &state);else -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }enum amd_dpm_forced_level amdgpu_dpm_get_performance_level (struct amdgpu_device *adev)@@ -1898,7 +900,7 @@ int amdgpu_dpm_set_sclk_od(struct amdgpu_device *adev, uint32_t value) AMD_PP_TASK_READJUST_POWER_STATE, NULL) == -EOPNOTSUPP) { adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return 0 ;@@ -1927,7 +929,7 @@ int amdgpu_dpm_set_mclk_od(struct amdgpu_device *adev, uint32_t value) AMD_PP_TASK_READJUST_POWER_STATE, NULL) == -EOPNOTSUPP) { adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return 0 ;drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-16@@ -366,24 +366,10 @@ enum amdgpu_display_gap AMDGPU_PM_DISPLAY_GAP_IGNORE = 3, }; -void amdgpu_dpm_print_class_info (u32 class,u32 class2); -void amdgpu_dpm_print_cap_info (u32 caps); -void amdgpu_dpm_print_ps_status (struct amdgpu_device *adev, -struct amdgpu_ps *rps);u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev);int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor,void *data,uint32_t *size); -int amdgpu_get_platform_caps (struct amdgpu_device *adev); - -int amdgpu_parse_extended_power_table (struct amdgpu_device *adev); -void amdgpu_free_extended_power_table (struct amdgpu_device *adev); - -void amdgpu_add_thermal_controller (struct amdgpu_device *adev); - -struct amd_vce_state * -amdgpu_get_vce_clock_state (void *handle,u32 idx); -int amdgpu_dpm_set_powergating_by_smu (struct amdgpu_device *adev,uint32_t block_type,bool gate);@@ -434,11 +420,10 @@ int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors sensovoid amdgpu_dpm_thermal_work_handler (struct work_struct *work); -void amdgpu_pm_compute_clocks (struct amdgpu_device *adev); +void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev);void amdgpu_dpm_enable_uvd (struct amdgpu_device *adev,bool enable);void amdgpu_dpm_enable_vce (struct amdgpu_device *adev,bool enable);void amdgpu_dpm_enable_jpeg (struct amdgpu_device *adev,bool enable); -void amdgpu_pm_print_power_states (struct amdgpu_device *adev);int amdgpu_pm_load_smu_firmware (struct amdgpu_device *adev,uint32_t *smu_version);int amdgpu_dpm_set_light_sbr (struct amdgpu_device *adev,bool enable);int amdgpu_dpm_send_hbm_bad_pages_num (struct amdgpu_device *adev,uint32_t size);drivers/gpu/drm/amd/pm/powerplay/Makefile +1
-1@@ -28,7 +28,7 @@ AMD_POWERPLAY = $(addsuffix /Makefile,$(addprefix $(FULL_AMD_PATH)/pm/powerplay/ include $(AMD_POWERPLAY) -POWER_MGR-y = amd_powerplay.o +POWER_MGR-y = amd_powerplay.o legacy_dpm.o POWER_MGR-$(CONFIG_DRM_AMDGPU_CIK)+= kv_dpm.o kv_smc.odrivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +4
-2@@ -36,6 +36,7 @@#include "gca/gfx_7_2_d.h" #include "gca/gfx_7_2_sh_mask.h" +#include "legacy_dpm.h" #define KV_MAX_DEEPSLEEP_DIVIDER_ID 5#define KV_MINIMUM_ENGINE_CLOCK 800@@ -3087,7 +3088,7 @@ static int kv_dpm_hw_init(void *handle)else adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev);return ret; }@@ -3135,7 +3136,7 @@ static int kv_dpm_resume(void *handle) adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex);if (adev->pm.dpm_enabled) -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return 0 ; }@@ -3389,6 +3390,7 @@ static const struct amd_pm_funcs kv_dpm_funcs = { .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, .read_sensor = &kv_dpm_read_sensor, + .change_power_state = amdgpu_dpm_change_power_state_locked, };static const struct amdgpu_irq_src_funcs kv_dpm_irq_funcs = {drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1024
-0@@ -0,0 +1,1024 @@ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "amdgpu.h" +#include "amdgpu_i2c.h" +#include "amdgpu_atombios.h" +#include "atom.h" +#include "amd_pcie.h" +#include "legacy_dpm.h" + +#define amdgpu_dpm_pre_set_power_state (adev) \ + ((adev)->powerplay.pp_funcs->pre_set_power_state((adev)->powerplay.pp_handle)) + +#define amdgpu_dpm_post_set_power_state (adev) \ + ((adev)->powerplay.pp_funcs->post_set_power_state((adev)->powerplay.pp_handle)) + +#define amdgpu_dpm_display_configuration_changed (adev) \ + ((adev)->powerplay.pp_funcs->display_configuration_changed((adev)->powerplay.pp_handle)) + +#define amdgpu_dpm_print_power_state (adev, ps) \ + ((adev)->powerplay.pp_funcs->print_power_state((adev)->powerplay.pp_handle, (ps))) + +#define amdgpu_dpm_vblank_too_short (adev) \ + ((adev)->powerplay.pp_funcs->vblank_too_short((adev)->powerplay.pp_handle)) + +#define amdgpu_dpm_check_state_equal (adev, cps, rps, equal) \ + ((adev)->powerplay.pp_funcs->check_state_equal((adev)->powerplay.pp_handle, (cps), (rps), (equal))) + +void amdgpu_dpm_print_class_info (u32 class,u32 class2) +{ +const char *s; + +switch (class &ATOM_PPLIB_CLASSIFICATION_UI_MASK ) { +case ATOM_PPLIB_CLASSIFICATION_UI_NONE : +default : + s ="none" ; +break ; +case ATOM_PPLIB_CLASSIFICATION_UI_BATTERY : + s ="battery" ; +break ; +case ATOM_PPLIB_CLASSIFICATION_UI_BALANCED : + s ="balanced" ; +break ; +case ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE : + s ="performance" ; +break ; + } +printk ("\tui class: %s\n" , s); +printk ("\tinternal class:" ); +if (((class & ~ATOM_PPLIB_CLASSIFICATION_UI_MASK ) ==0 ) && + (class2 ==0 )) +pr_cont (" none" ); +else { +if (class &ATOM_PPLIB_CLASSIFICATION_BOOT ) +pr_cont (" boot" ); +if (class &ATOM_PPLIB_CLASSIFICATION_THERMAL ) +pr_cont (" thermal" ); +if (class &ATOM_PPLIB_CLASSIFICATION_LIMITEDPOWERSOURCE ) +pr_cont (" limited_pwr" ); +if (class &ATOM_PPLIB_CLASSIFICATION_REST ) +pr_cont (" rest" ); +if (class &ATOM_PPLIB_CLASSIFICATION_FORCED ) +pr_cont (" forced" ); +if (class &ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE ) +pr_cont (" 3d_perf" ); +if (class &ATOM_PPLIB_CLASSIFICATION_OVERDRIVETEMPLATE ) +pr_cont (" ovrdrv" ); +if (class &ATOM_PPLIB_CLASSIFICATION_UVDSTATE ) +pr_cont (" uvd" ); +if (class &ATOM_PPLIB_CLASSIFICATION_3DLOW ) +pr_cont (" 3d_low" ); +if (class &ATOM_PPLIB_CLASSIFICATION_ACPI ) +pr_cont (" acpi" ); +if (class &ATOM_PPLIB_CLASSIFICATION_HD2STATE ) +pr_cont (" uvd_hd2" ); +if (class &ATOM_PPLIB_CLASSIFICATION_HDSTATE ) +pr_cont (" uvd_hd" ); +if (class &ATOM_PPLIB_CLASSIFICATION_SDSTATE ) +pr_cont (" uvd_sd" ); +if (class2 &ATOM_PPLIB_CLASSIFICATION2_LIMITEDPOWERSOURCE_2 ) +pr_cont (" limited_pwr2" ); +if (class2 &ATOM_PPLIB_CLASSIFICATION2_ULV ) +pr_cont (" ulv" ); +if (class2 &ATOM_PPLIB_CLASSIFICATION2_MVC ) +pr_cont (" uvd_mvc" ); + } +pr_cont ("\n" ); +} + +void amdgpu_dpm_print_cap_info (u32 caps) +{ +printk ("\tcaps:" ); +if (caps &ATOM_PPLIB_SINGLE_DISPLAY_ONLY ) +pr_cont (" single_disp" ); +if (caps &ATOM_PPLIB_SUPPORTS_VIDEO_PLAYBACK ) +pr_cont (" video" ); +if (caps &ATOM_PPLIB_DISALLOW_ON_DC ) +pr_cont (" no_dc" ); +pr_cont ("\n" ); +} + +void amdgpu_dpm_print_ps_status (struct amdgpu_device *adev, +struct amdgpu_ps *rps) +{ +printk ("\tstatus:" ); +if (rps == adev->pm.dpm.current_ps) +pr_cont (" c" ); +if (rps == adev->pm.dpm.requested_ps) +pr_cont (" r" ); +if (rps == adev->pm.dpm.boot_ps) +pr_cont (" b" ); +pr_cont ("\n" ); +} + +void amdgpu_pm_print_power_states (struct amdgpu_device *adev) +{ +int i; + +if (adev->powerplay.pp_funcs->print_power_state ==NULL ) +return ; + +for (i =0 ; i < adev->pm.dpm.num_ps; i++) +amdgpu_dpm_print_power_state (adev, &adev->pm.dpm.ps[i]); + +} + +union power_info { +struct _ATOM_POWERPLAY_INFO info; +struct _ATOM_POWERPLAY_INFO_V2 info_2; +struct _ATOM_POWERPLAY_INFO_V3 info_3; +struct _ATOM_PPLIB_POWERPLAYTABLE pplib; +struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2; +struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3; +struct _ATOM_PPLIB_POWERPLAYTABLE4 pplib4; +struct _ATOM_PPLIB_POWERPLAYTABLE5 pplib5; +}; + +int amdgpu_get_platform_caps (struct amdgpu_device *adev) +{ +struct amdgpu_mode_info *mode_info = &adev->mode_info; +union power_info *power_info; +int index =GetIndexIntoMasterTable (DATA , PowerPlayInfo); +u16 data_offset; +u8 frev, crev; + +if (!amdgpu_atom_parse_data_header (mode_info->atom_context, index,NULL , + &frev, &crev, &data_offset)) +return -EINVAL ; + power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); + + adev->pm.dpm.platform_caps =le32_to_cpu (power_info->pplib.ulPlatformCaps); + adev->pm.dpm.backbias_response_time =le16_to_cpu (power_info->pplib.usBackbiasTime); + adev->pm.dpm.voltage_response_time =le16_to_cpu (power_info->pplib.usVoltageTime); + +return 0 ; +} + +union fan_info { +struct _ATOM_PPLIB_FANTABLE fan; +struct _ATOM_PPLIB_FANTABLE2 fan2; +struct _ATOM_PPLIB_FANTABLE3 fan3; +}; + +static int amdgpu_parse_clk_voltage_dep_table (struct amdgpu_clock_voltage_dependency_table *amdgpu_table, +ATOM_PPLIB_Clock_Voltage_Dependency_Table *atom_table) +{ +u32 size = atom_table->ucNumEntries * +sizeof (struct amdgpu_clock_voltage_dependency_entry ); +int i; +ATOM_PPLIB_Clock_Voltage_Dependency_Record *entry; + + amdgpu_table->entries =kzalloc (size,GFP_KERNEL ); +if (!amdgpu_table->entries) +return -ENOMEM ; + + entry = &atom_table->entries[0 ]; +for (i =0 ; i < atom_table->ucNumEntries; i++) { + amdgpu_table->entries[i].clk =le16_to_cpu (entry->usClockLow) | + (entry->ucClockHigh <<16 ); + amdgpu_table->entries[i].v =le16_to_cpu (entry->usVoltage); + entry = (ATOM_PPLIB_Clock_Voltage_Dependency_Record *) + ((u8 *)entry +sizeof (ATOM_PPLIB_Clock_Voltage_Dependency_Record)); + } + amdgpu_table->count = atom_table->ucNumEntries; + +return 0 ; +} + +/* sizeof(ATOM_PPLIB_EXTENDEDHEADER) */ +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2 12 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3 14 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V4 16 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V5 18 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V6 20 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V7 22 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V8 24 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V9 26 + +int amdgpu_parse_extended_power_table (struct amdgpu_device *adev) +{ +struct amdgpu_mode_info *mode_info = &adev->mode_info; +union power_info *power_info; +union fan_info *fan_info; +ATOM_PPLIB_Clock_Voltage_Dependency_Table *dep_table; +int index =GetIndexIntoMasterTable (DATA , PowerPlayInfo); +u16 data_offset; +u8 frev, crev; +int ret, i; + +if (!amdgpu_atom_parse_data_header (mode_info->atom_context, index,NULL , + &frev, &crev, &data_offset)) +return -EINVAL ; + power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); + +/* fan table */ +if (le16_to_cpu (power_info->pplib.usTableSize) >= +sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE3 )) { +if (power_info->pplib3.usFanTableOffset) { + fan_info = (union fan_info *)(mode_info->atom_context->bios + data_offset + +le16_to_cpu (power_info->pplib3.usFanTableOffset)); + adev->pm.dpm.fan.t_hyst = fan_info->fan.ucTHyst; + adev->pm.dpm.fan.t_min =le16_to_cpu (fan_info->fan.usTMin); + adev->pm.dpm.fan.t_med =le16_to_cpu (fan_info->fan.usTMed); + adev->pm.dpm.fan.t_high =le16_to_cpu (fan_info->fan.usTHigh); + adev->pm.dpm.fan.pwm_min =le16_to_cpu (fan_info->fan.usPWMMin); + adev->pm.dpm.fan.pwm_med =le16_to_cpu (fan_info->fan.usPWMMed); + adev->pm.dpm.fan.pwm_high =le16_to_cpu (fan_info->fan.usPWMHigh); +if (fan_info->fan.ucFanTableFormat >=2 ) + adev->pm.dpm.fan.t_max =le16_to_cpu (fan_info->fan2.usTMax); +else + adev->pm.dpm.fan.t_max =10900 ; + adev->pm.dpm.fan.cycle_delay =100000 ; +if (fan_info->fan.ucFanTableFormat >=3 ) { + adev->pm.dpm.fan.control_mode = fan_info->fan3.ucFanControlMode; + adev->pm.dpm.fan.default_max_fan_pwm = +le16_to_cpu (fan_info->fan3.usFanPWMMax); + adev->pm.dpm.fan.default_fan_output_sensitivity =4836 ; + adev->pm.dpm.fan.fan_output_sensitivity = +le16_to_cpu (fan_info->fan3.usFanOutputSensitivity); + } + adev->pm.dpm.fan.ucode_fan_control = true; + } + } + +/* clock dependancy tables, shedding tables */ +if (le16_to_cpu (power_info->pplib.usTableSize) >= +sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE4 )) { +if (power_info->pplib4.usVddcDependencyOnSCLKOffset) { + dep_table = (ATOM_PPLIB_Clock_Voltage_Dependency_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (power_info->pplib4.usVddcDependencyOnSCLKOffset)); + ret =amdgpu_parse_clk_voltage_dep_table (&adev->pm.dpm.dyn_state.vddc_dependency_on_sclk, + dep_table); +if (ret) { +amdgpu_free_extended_power_table (adev); +return ret; + } + } +if (power_info->pplib4.usVddciDependencyOnMCLKOffset) { + dep_table = (ATOM_PPLIB_Clock_Voltage_Dependency_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (power_info->pplib4.usVddciDependencyOnMCLKOffset)); + ret =amdgpu_parse_clk_voltage_dep_table (&adev->pm.dpm.dyn_state.vddci_dependency_on_mclk, + dep_table); +if (ret) { +amdgpu_free_extended_power_table (adev); +return ret; + } + } +if (power_info->pplib4.usVddcDependencyOnMCLKOffset) { + dep_table = (ATOM_PPLIB_Clock_Voltage_Dependency_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (power_info->pplib4.usVddcDependencyOnMCLKOffset)); + ret =amdgpu_parse_clk_voltage_dep_table (&adev->pm.dpm.dyn_state.vddc_dependency_on_mclk, + dep_table); +if (ret) { +amdgpu_free_extended_power_table (adev); +return ret; + } + } +if (power_info->pplib4.usMvddDependencyOnMCLKOffset) { + dep_table = (ATOM_PPLIB_Clock_Voltage_Dependency_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (power_info->pplib4.usMvddDependencyOnMCLKOffset)); + ret =amdgpu_parse_clk_voltage_dep_table (&adev->pm.dpm.dyn_state.mvdd_dependency_on_mclk, + dep_table); +if (ret) { +amdgpu_free_extended_power_table (adev); +return ret; + } + } +if (power_info->pplib4.usMaxClockVoltageOnDCOffset) { +ATOM_PPLIB_Clock_Voltage_Limit_Table *clk_v = + (ATOM_PPLIB_Clock_Voltage_Limit_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (power_info->pplib4.usMaxClockVoltageOnDCOffset)); +if (clk_v->ucNumEntries) { + adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk = +le16_to_cpu (clk_v->entries[0 ].usSclkLow) | + (clk_v->entries[0 ].ucSclkHigh <<16 ); + adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk = +le16_to_cpu (clk_v->entries[0 ].usMclkLow) | + (clk_v->entries[0 ].ucMclkHigh <<16 ); + adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc = +le16_to_cpu (clk_v->entries[0 ].usVddc); + adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddci = +le16_to_cpu (clk_v->entries[0 ].usVddci); + } + } +if (power_info->pplib4.usVddcPhaseShedLimitsTableOffset) { +ATOM_PPLIB_PhaseSheddingLimits_Table *psl = + (ATOM_PPLIB_PhaseSheddingLimits_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (power_info->pplib4.usVddcPhaseShedLimitsTableOffset)); +ATOM_PPLIB_PhaseSheddingLimits_Record *entry; + + adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries = +kcalloc (psl->ucNumEntries, +sizeof (struct amdgpu_phase_shedding_limits_entry ), +GFP_KERNEL ); +if (!adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) { +amdgpu_free_extended_power_table (adev); +return -ENOMEM ; + } + + entry = &psl->entries[0 ]; +for (i =0 ; i < psl->ucNumEntries; i++) { + adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].sclk = +le16_to_cpu (entry->usSclkLow) | (entry->ucSclkHigh <<16 ); + adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].mclk = +le16_to_cpu (entry->usMclkLow) | (entry->ucMclkHigh <<16 ); + adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].voltage = +le16_to_cpu (entry->usVoltage); + entry = (ATOM_PPLIB_PhaseSheddingLimits_Record *) + ((u8 *)entry +sizeof (ATOM_PPLIB_PhaseSheddingLimits_Record)); + } + adev->pm.dpm.dyn_state.phase_shedding_limits_table.count = + psl->ucNumEntries; + } + } + +/* cac data */ +if (le16_to_cpu (power_info->pplib.usTableSize) >= +sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE5 )) { + adev->pm.dpm.tdp_limit =le32_to_cpu (power_info->pplib5.ulTDPLimit); + adev->pm.dpm.near_tdp_limit =le32_to_cpu (power_info->pplib5.ulNearTDPLimit); + adev->pm.dpm.near_tdp_limit_adjusted = adev->pm.dpm.near_tdp_limit; + adev->pm.dpm.tdp_od_limit =le16_to_cpu (power_info->pplib5.usTDPODLimit); +if (adev->pm.dpm.tdp_od_limit) + adev->pm.dpm.power_control = true; +else + adev->pm.dpm.power_control = false; + adev->pm.dpm.tdp_adjustment =0 ; + adev->pm.dpm.sq_ramping_threshold =le32_to_cpu (power_info->pplib5.ulSQRampingThreshold); + adev->pm.dpm.cac_leakage =le32_to_cpu (power_info->pplib5.ulCACLeakage); + adev->pm.dpm.load_line_slope =le16_to_cpu (power_info->pplib5.usLoadLineSlope); +if (power_info->pplib5.usCACLeakageTableOffset) { +ATOM_PPLIB_CAC_Leakage_Table *cac_table = + (ATOM_PPLIB_CAC_Leakage_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (power_info->pplib5.usCACLeakageTableOffset)); +ATOM_PPLIB_CAC_Leakage_Record *entry; +u32 size = cac_table->ucNumEntries *sizeof (struct amdgpu_cac_leakage_table ); + adev->pm.dpm.dyn_state.cac_leakage_table.entries =kzalloc (size,GFP_KERNEL ); +if (!adev->pm.dpm.dyn_state.cac_leakage_table.entries) { +amdgpu_free_extended_power_table (adev); +return -ENOMEM ; + } + entry = &cac_table->entries[0 ]; +for (i =0 ; i < cac_table->ucNumEntries; i++) { +if (adev->pm.dpm.platform_caps &ATOM_PP_PLATFORM_CAP_EVV ) { + adev->pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc1 = +le16_to_cpu (entry->usVddc1); + adev->pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc2 = +le16_to_cpu (entry->usVddc2); + adev->pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc3 = +le16_to_cpu (entry->usVddc3); + }else { + adev->pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc = +le16_to_cpu (entry->usVddc); + adev->pm.dpm.dyn_state.cac_leakage_table.entries[i].leakage = +le32_to_cpu (entry->ulLeakageValue); + } + entry = (ATOM_PPLIB_CAC_Leakage_Record *) + ((u8 *)entry +sizeof (ATOM_PPLIB_CAC_Leakage_Record)); + } + adev->pm.dpm.dyn_state.cac_leakage_table.count = cac_table->ucNumEntries; + } + } + +/* ext tables */ +if (le16_to_cpu (power_info->pplib.usTableSize) >= +sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE3 )) { +ATOM_PPLIB_EXTENDEDHEADER *ext_hdr = (ATOM_PPLIB_EXTENDEDHEADER *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (power_info->pplib3.usExtendendedHeaderOffset)); +if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2 ) && + ext_hdr->usVCETableOffset) { +VCEClockInfoArray *array = (VCEClockInfoArray *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usVCETableOffset) +1 ); +ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table *limits = + (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usVCETableOffset) +1 + +1 + array->ucNumEntries *sizeof (VCEClockInfo)); +ATOM_PPLIB_VCE_State_Table *states = + (ATOM_PPLIB_VCE_State_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usVCETableOffset) +1 + +1 + (array->ucNumEntries *sizeof (VCEClockInfo)) + +1 + (limits->numEntries *sizeof (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record))); +ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record *entry; +ATOM_PPLIB_VCE_State_Record *state_entry; +VCEClockInfo *vce_clk; +u32 size = limits->numEntries * +sizeof (struct amdgpu_vce_clock_voltage_dependency_entry ); + adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries = +kzalloc (size,GFP_KERNEL ); +if (!adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries) { +amdgpu_free_extended_power_table (adev); +return -ENOMEM ; + } + adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.count = + limits->numEntries; + entry = &limits->entries[0 ]; + state_entry = &states->entries[0 ]; +for (i =0 ; i < limits->numEntries; i++) { + vce_clk = (VCEClockInfo *) + ((u8 *)&array->entries[0 ] + + (entry->ucVCEClockInfoIndex *sizeof (VCEClockInfo))); + adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries[i].evclk = +le16_to_cpu (vce_clk->usEVClkLow) | (vce_clk->ucEVClkHigh <<16 ); + adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries[i].ecclk = +le16_to_cpu (vce_clk->usECClkLow) | (vce_clk->ucECClkHigh <<16 ); + adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries[i].v = +le16_to_cpu (entry->usVoltage); + entry = (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record *) + ((u8 *)entry +sizeof (ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record)); + } + adev->pm.dpm.num_of_vce_states = + states->numEntries >AMD_MAX_VCE_LEVELS ? +AMD_MAX_VCE_LEVELS : states->numEntries; +for (i =0 ; i < adev->pm.dpm.num_of_vce_states; i++) { + vce_clk = (VCEClockInfo *) + ((u8 *)&array->entries[0 ] + + (state_entry->ucVCEClockInfoIndex *sizeof (VCEClockInfo))); + adev->pm.dpm.vce_states[i].evclk = +le16_to_cpu (vce_clk->usEVClkLow) | (vce_clk->ucEVClkHigh <<16 ); + adev->pm.dpm.vce_states[i].ecclk = +le16_to_cpu (vce_clk->usECClkLow) | (vce_clk->ucECClkHigh <<16 ); + adev->pm.dpm.vce_states[i].clk_idx = + state_entry->ucClockInfoIndex &0x3f ; + adev->pm.dpm.vce_states[i].pstate = + (state_entry->ucClockInfoIndex &0xc0 ) >>6 ; + state_entry = (ATOM_PPLIB_VCE_State_Record *) + ((u8 *)state_entry +sizeof (ATOM_PPLIB_VCE_State_Record)); + } + } +if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3 ) && + ext_hdr->usUVDTableOffset) { +UVDClockInfoArray *array = (UVDClockInfoArray *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usUVDTableOffset) +1 ); +ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table *limits = + (ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usUVDTableOffset) +1 + +1 + (array->ucNumEntries *sizeof (UVDClockInfo))); +ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record *entry; +u32 size = limits->numEntries * +sizeof (struct amdgpu_uvd_clock_voltage_dependency_entry ); + adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries = +kzalloc (size,GFP_KERNEL ); +if (!adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries) { +amdgpu_free_extended_power_table (adev); +return -ENOMEM ; + } + adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.count = + limits->numEntries; + entry = &limits->entries[0 ]; +for (i =0 ; i < limits->numEntries; i++) { +UVDClockInfo *uvd_clk = (UVDClockInfo *) + ((u8 *)&array->entries[0 ] + + (entry->ucUVDClockInfoIndex *sizeof (UVDClockInfo))); + adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries[i].vclk = +le16_to_cpu (uvd_clk->usVClkLow) | (uvd_clk->ucVClkHigh <<16 ); + adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries[i].dclk = +le16_to_cpu (uvd_clk->usDClkLow) | (uvd_clk->ucDClkHigh <<16 ); + adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries[i].v = +le16_to_cpu (entry->usVoltage); + entry = (ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record *) + ((u8 *)entry +sizeof (ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record)); + } + } +if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V4 ) && + ext_hdr->usSAMUTableOffset) { +ATOM_PPLIB_SAMClk_Voltage_Limit_Table *limits = + (ATOM_PPLIB_SAMClk_Voltage_Limit_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usSAMUTableOffset) +1 ); +ATOM_PPLIB_SAMClk_Voltage_Limit_Record *entry; +u32 size = limits->numEntries * +sizeof (struct amdgpu_clock_voltage_dependency_entry ); + adev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries = +kzalloc (size,GFP_KERNEL ); +if (!adev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries) { +amdgpu_free_extended_power_table (adev); +return -ENOMEM ; + } + adev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.count = + limits->numEntries; + entry = &limits->entries[0 ]; +for (i =0 ; i < limits->numEntries; i++) { + adev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries[i].clk = +le16_to_cpu (entry->usSAMClockLow) | (entry->ucSAMClockHigh <<16 ); + adev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries[i].v = +le16_to_cpu (entry->usVoltage); + entry = (ATOM_PPLIB_SAMClk_Voltage_Limit_Record *) + ((u8 *)entry +sizeof (ATOM_PPLIB_SAMClk_Voltage_Limit_Record)); + } + } +if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V5 ) && + ext_hdr->usPPMTableOffset) { +ATOM_PPLIB_PPM_Table *ppm = (ATOM_PPLIB_PPM_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usPPMTableOffset)); + adev->pm.dpm.dyn_state.ppm_table = +kzalloc (sizeof (struct amdgpu_ppm_table ),GFP_KERNEL ); +if (!adev->pm.dpm.dyn_state.ppm_table) { +amdgpu_free_extended_power_table (adev); +return -ENOMEM ; + } + adev->pm.dpm.dyn_state.ppm_table->ppm_design = ppm->ucPpmDesign; + adev->pm.dpm.dyn_state.ppm_table->cpu_core_number = +le16_to_cpu (ppm->usCpuCoreNumber); + adev->pm.dpm.dyn_state.ppm_table->platform_tdp = +le32_to_cpu (ppm->ulPlatformTDP); + adev->pm.dpm.dyn_state.ppm_table->small_ac_platform_tdp = +le32_to_cpu (ppm->ulSmallACPlatformTDP); + adev->pm.dpm.dyn_state.ppm_table->platform_tdc = +le32_to_cpu (ppm->ulPlatformTDC); + adev->pm.dpm.dyn_state.ppm_table->small_ac_platform_tdc = +le32_to_cpu (ppm->ulSmallACPlatformTDC); + adev->pm.dpm.dyn_state.ppm_table->apu_tdp = +le32_to_cpu (ppm->ulApuTDP); + adev->pm.dpm.dyn_state.ppm_table->dgpu_tdp = +le32_to_cpu (ppm->ulDGpuTDP); + adev->pm.dpm.dyn_state.ppm_table->dgpu_ulv_power = +le32_to_cpu (ppm->ulDGpuUlvPower); + adev->pm.dpm.dyn_state.ppm_table->tj_max = +le32_to_cpu (ppm->ulTjmax); + } +if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V6 ) && + ext_hdr->usACPTableOffset) { +ATOM_PPLIB_ACPClk_Voltage_Limit_Table *limits = + (ATOM_PPLIB_ACPClk_Voltage_Limit_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usACPTableOffset) +1 ); +ATOM_PPLIB_ACPClk_Voltage_Limit_Record *entry; +u32 size = limits->numEntries * +sizeof (struct amdgpu_clock_voltage_dependency_entry ); + adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries = +kzalloc (size,GFP_KERNEL ); +if (!adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries) { +amdgpu_free_extended_power_table (adev); +return -ENOMEM ; + } + adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.count = + limits->numEntries; + entry = &limits->entries[0 ]; +for (i =0 ; i < limits->numEntries; i++) { + adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries[i].clk = +le16_to_cpu (entry->usACPClockLow) | (entry->ucACPClockHigh <<16 ); + adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries[i].v = +le16_to_cpu (entry->usVoltage); + entry = (ATOM_PPLIB_ACPClk_Voltage_Limit_Record *) + ((u8 *)entry +sizeof (ATOM_PPLIB_ACPClk_Voltage_Limit_Record)); + } + } +if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V7 ) && + ext_hdr->usPowerTuneTableOffset) { +u8 rev = *(u8 *)(mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usPowerTuneTableOffset)); +ATOM_PowerTune_Table *pt; + adev->pm.dpm.dyn_state.cac_tdp_table = +kzalloc (sizeof (struct amdgpu_cac_tdp_table ),GFP_KERNEL ); +if (!adev->pm.dpm.dyn_state.cac_tdp_table) { +amdgpu_free_extended_power_table (adev); +return -ENOMEM ; + } +if (rev >0 ) { +ATOM_PPLIB_POWERTUNE_Table_V1 *ppt = (ATOM_PPLIB_POWERTUNE_Table_V1 *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usPowerTuneTableOffset)); + adev->pm.dpm.dyn_state.cac_tdp_table->maximum_power_delivery_limit = + ppt->usMaximumPowerDeliveryLimit; + pt = &ppt->power_tune_table; + }else { +ATOM_PPLIB_POWERTUNE_Table *ppt = (ATOM_PPLIB_POWERTUNE_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usPowerTuneTableOffset)); + adev->pm.dpm.dyn_state.cac_tdp_table->maximum_power_delivery_limit =255 ; + pt = &ppt->power_tune_table; + } + adev->pm.dpm.dyn_state.cac_tdp_table->tdp =le16_to_cpu (pt->usTDP); + adev->pm.dpm.dyn_state.cac_tdp_table->configurable_tdp = +le16_to_cpu (pt->usConfigurableTDP); + adev->pm.dpm.dyn_state.cac_tdp_table->tdc =le16_to_cpu (pt->usTDC); + adev->pm.dpm.dyn_state.cac_tdp_table->battery_power_limit = +le16_to_cpu (pt->usBatteryPowerLimit); + adev->pm.dpm.dyn_state.cac_tdp_table->small_power_limit = +le16_to_cpu (pt->usSmallPowerLimit); + adev->pm.dpm.dyn_state.cac_tdp_table->low_cac_leakage = +le16_to_cpu (pt->usLowCACLeakage); + adev->pm.dpm.dyn_state.cac_tdp_table->high_cac_leakage = +le16_to_cpu (pt->usHighCACLeakage); + } +if ((le16_to_cpu (ext_hdr->usSize) >=SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V8 ) && + ext_hdr->usSclkVddgfxTableOffset) { + dep_table = (ATOM_PPLIB_Clock_Voltage_Dependency_Table *) + (mode_info->atom_context->bios + data_offset + +le16_to_cpu (ext_hdr->usSclkVddgfxTableOffset)); + ret =amdgpu_parse_clk_voltage_dep_table ( + &adev->pm.dpm.dyn_state.vddgfx_dependency_on_sclk, + dep_table); +if (ret) { +kfree (adev->pm.dpm.dyn_state.vddgfx_dependency_on_sclk.entries); +return ret; + } + } + } + +return 0 ; +} + +void amdgpu_free_extended_power_table (struct amdgpu_device *adev) +{ +struct amdgpu_dpm_dynamic_state *dyn_state = &adev->pm.dpm.dyn_state; + +kfree (dyn_state->vddc_dependency_on_sclk.entries); +kfree (dyn_state->vddci_dependency_on_mclk.entries); +kfree (dyn_state->vddc_dependency_on_mclk.entries); +kfree (dyn_state->mvdd_dependency_on_mclk.entries); +kfree (dyn_state->cac_leakage_table.entries); +kfree (dyn_state->phase_shedding_limits_table.entries); +kfree (dyn_state->ppm_table); +kfree (dyn_state->cac_tdp_table); +kfree (dyn_state->vce_clock_voltage_dependency_table.entries); +kfree (dyn_state->uvd_clock_voltage_dependency_table.entries); +kfree (dyn_state->samu_clock_voltage_dependency_table.entries); +kfree (dyn_state->acp_clock_voltage_dependency_table.entries); +kfree (dyn_state->vddgfx_dependency_on_sclk.entries); +} + +static const char *pp_lib_thermal_controller_names[] = { +"NONE" , +"lm63" , +"adm1032" , +"adm1030" , +"max6649" , +"lm64" , +"f75375" , +"RV6xx" , +"RV770" , +"adt7473" , +"NONE" , +"External GPIO" , +"Evergreen" , +"emc2103" , +"Sumo" , +"Northern Islands" , +"Southern Islands" , +"lm96163" , +"Sea Islands" , +"Kaveri/Kabini" , +}; + +void amdgpu_add_thermal_controller (struct amdgpu_device *adev) +{ +struct amdgpu_mode_info *mode_info = &adev->mode_info; +ATOM_PPLIB_POWERPLAYTABLE *power_table; +int index =GetIndexIntoMasterTable (DATA , PowerPlayInfo); +ATOM_PPLIB_THERMALCONTROLLER *controller; +struct amdgpu_i2c_bus_rec i2c_bus; +u16 data_offset; +u8 frev, crev; + +if (!amdgpu_atom_parse_data_header (mode_info->atom_context, index,NULL , + &frev, &crev, &data_offset)) +return ; + power_table = (ATOM_PPLIB_POWERPLAYTABLE *) + (mode_info->atom_context->bios + data_offset); + controller = &power_table->sThermalController; + +/* add the i2c bus for thermal/fan chip */ +if (controller->ucType >0 ) { +if (controller->ucFanParameters &ATOM_PP_FANPARAMETERS_NOFAN ) + adev->pm.no_fan = true; + adev->pm.fan_pulses_per_revolution = + controller->ucFanParameters &ATOM_PP_FANPARAMETERS_TACHOMETER_PULSES_PER_REVOLUTION_MASK ; +if (adev->pm.fan_pulses_per_revolution) { + adev->pm.fan_min_rpm = controller->ucFanMinRPM; + adev->pm.fan_max_rpm = controller->ucFanMaxRPM; + } +if (controller->ucType == ATOM_PP_THERMALCONTROLLER_RV6xx) { +DRM_INFO ("Internal thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_RV6XX ; + }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_RV770 ) { +DRM_INFO ("Internal thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_RV770 ; + }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_EVERGREEN ) { +DRM_INFO ("Internal thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_EVERGREEN ; + }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_SUMO ) { +DRM_INFO ("Internal thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_SUMO ; + }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_NISLANDS ) { +DRM_INFO ("Internal thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_NI ; + }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_SISLANDS ) { +DRM_INFO ("Internal thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_SI ; + }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_CISLANDS ) { +DRM_INFO ("Internal thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_CI ; + }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_KAVERI ) { +DRM_INFO ("Internal thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_KV ; + }else if (controller->ucType ==ATOM_PP_THERMALCONTROLLER_EXTERNAL_GPIO ) { +DRM_INFO ("External GPIO thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_EXTERNAL_GPIO ; + }else if (controller->ucType == +ATOM_PP_THERMALCONTROLLER_ADT7473_WITH_INTERNAL ) { +DRM_INFO ("ADT7473 with internal thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_ADT7473_WITH_INTERNAL ; + }else if (controller->ucType == +ATOM_PP_THERMALCONTROLLER_EMC2103_WITH_INTERNAL ) { +DRM_INFO ("EMC2103 with internal thermal controller %s fan control\n" , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_EMC2103_WITH_INTERNAL ; + }else if (controller->ucType <ARRAY_SIZE (pp_lib_thermal_controller_names)) { +DRM_INFO ("Possible %s thermal controller at 0x%02x %s fan control\n" , + pp_lib_thermal_controller_names[controller->ucType], + controller->ucI2cAddress >>1 , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + adev->pm.int_thermal_type =THERMAL_TYPE_EXTERNAL ; + i2c_bus =amdgpu_atombios_lookup_i2c_gpio (adev, controller->ucI2cLine); + adev->pm.i2c_bus =amdgpu_i2c_lookup (adev, &i2c_bus); +if (adev->pm.i2c_bus) { +struct i2c_board_info info = { }; +const char *name = pp_lib_thermal_controller_names[controller->ucType]; + info.addr = controller->ucI2cAddress >>1 ; +strlcpy (info.type, name,sizeof (info.type)); +i2c_new_client_device (&adev->pm.i2c_bus->adapter, &info); + } + }else { +DRM_INFO ("Unknown thermal controller type %d at 0x%02x %s fan control\n" , + controller->ucType, + controller->ucI2cAddress >>1 , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); + } + } +} + +struct amd_vce_state *amdgpu_get_vce_clock_state (void *handle,u32 idx) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +if (idx < adev->pm.dpm.num_of_vce_states) +return &adev->pm.dpm.vce_states[idx]; + +return NULL ; +} + +static struct amdgpu_ps *amdgpu_dpm_pick_power_state (struct amdgpu_device *adev, +enum amd_pm_state_type dpm_state) +{ +int i; +struct amdgpu_ps *ps; +u32 ui_class; +bool single_display = (adev->pm.dpm.new_active_crtc_count <2 ) ? + true : false; + +/* check if the vblank period is too short to adjust the mclk */ +if (single_display && adev->powerplay.pp_funcs->vblank_too_short) { +if (amdgpu_dpm_vblank_too_short (adev)) + single_display = false; + } + +/* certain older asics have a separare 3D performance state, +* so try that first if the user selected performance +*/ +if (dpm_state ==POWER_STATE_TYPE_PERFORMANCE ) + dpm_state =POWER_STATE_TYPE_INTERNAL_3DPERF ; +/* balanced states don't exist at the moment */ +if (dpm_state ==POWER_STATE_TYPE_BALANCED ) + dpm_state =POWER_STATE_TYPE_PERFORMANCE ; + +restart_search: +/* Pick the best power state based on current conditions */ +for (i =0 ; i < adev->pm.dpm.num_ps; i++) { + ps = &adev->pm.dpm.ps[i]; + ui_class = ps->class &ATOM_PPLIB_CLASSIFICATION_UI_MASK ; +switch (dpm_state) { +/* user states */ +case POWER_STATE_TYPE_BATTERY : +if (ui_class ==ATOM_PPLIB_CLASSIFICATION_UI_BATTERY ) { +if (ps->caps &ATOM_PPLIB_SINGLE_DISPLAY_ONLY ) { +if (single_display) +return ps; + }else +return ps; + } +break ; +case POWER_STATE_TYPE_BALANCED : +if (ui_class ==ATOM_PPLIB_CLASSIFICATION_UI_BALANCED ) { +if (ps->caps &ATOM_PPLIB_SINGLE_DISPLAY_ONLY ) { +if (single_display) +return ps; + }else +return ps; + } +break ; +case POWER_STATE_TYPE_PERFORMANCE : +if (ui_class ==ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE ) { +if (ps->caps &ATOM_PPLIB_SINGLE_DISPLAY_ONLY ) { +if (single_display) +return ps; + }else +return ps; + } +break ; +/* internal states */ +case POWER_STATE_TYPE_INTERNAL_UVD : +if (adev->pm.dpm.uvd_ps) +return adev->pm.dpm.uvd_ps; +else +break ; +case POWER_STATE_TYPE_INTERNAL_UVD_SD : +if (ps->class &ATOM_PPLIB_CLASSIFICATION_SDSTATE ) +return ps; +break ; +case POWER_STATE_TYPE_INTERNAL_UVD_HD : +if (ps->class &ATOM_PPLIB_CLASSIFICATION_HDSTATE ) +return ps; +break ; +case POWER_STATE_TYPE_INTERNAL_UVD_HD2 : +if (ps->class &ATOM_PPLIB_CLASSIFICATION_HD2STATE ) +return ps; +break ; +case POWER_STATE_TYPE_INTERNAL_UVD_MVC : +if (ps->class2 &ATOM_PPLIB_CLASSIFICATION2_MVC ) +return ps; +break ; +case POWER_STATE_TYPE_INTERNAL_BOOT : +return adev->pm.dpm.boot_ps; +case POWER_STATE_TYPE_INTERNAL_THERMAL : +if (ps->class &ATOM_PPLIB_CLASSIFICATION_THERMAL ) +return ps; +break ; +case POWER_STATE_TYPE_INTERNAL_ACPI : +if (ps->class &ATOM_PPLIB_CLASSIFICATION_ACPI ) +return ps; +break ; +case POWER_STATE_TYPE_INTERNAL_ULV : +if (ps->class2 &ATOM_PPLIB_CLASSIFICATION2_ULV ) +return ps; +break ; +case POWER_STATE_TYPE_INTERNAL_3DPERF : +if (ps->class &ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE ) +return ps; +break ; +default : +break ; + } + } +/* use a fallback state if we didn't match */ +switch (dpm_state) { +case POWER_STATE_TYPE_INTERNAL_UVD_SD : + dpm_state =POWER_STATE_TYPE_INTERNAL_UVD_HD ; + goto restart_search; +case POWER_STATE_TYPE_INTERNAL_UVD_HD : +case POWER_STATE_TYPE_INTERNAL_UVD_HD2 : +case POWER_STATE_TYPE_INTERNAL_UVD_MVC : +if (adev->pm.dpm.uvd_ps) { +return adev->pm.dpm.uvd_ps; + }else { + dpm_state =POWER_STATE_TYPE_PERFORMANCE ; + goto restart_search; + } +case POWER_STATE_TYPE_INTERNAL_THERMAL : + dpm_state =POWER_STATE_TYPE_INTERNAL_ACPI ; + goto restart_search; +case POWER_STATE_TYPE_INTERNAL_ACPI : + dpm_state =POWER_STATE_TYPE_BATTERY ; + goto restart_search; +case POWER_STATE_TYPE_BATTERY : +case POWER_STATE_TYPE_BALANCED : +case POWER_STATE_TYPE_INTERNAL_3DPERF : + dpm_state =POWER_STATE_TYPE_PERFORMANCE ; + goto restart_search; +default : +break ; + } + +return NULL ; +} + +int amdgpu_dpm_change_power_state_locked (void *handle) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct amdgpu_ps *ps; +enum amd_pm_state_type dpm_state; +int ret; +bool equal = false; + +/* if dpm init failed */ +if (!adev->pm.dpm_enabled) +return 0 ; + +if (adev->pm.dpm.user_state != adev->pm.dpm.state) { +/* add other state override checks here */ +if ((!adev->pm.dpm.thermal_active) && + (!adev->pm.dpm.uvd_active)) + adev->pm.dpm.state = adev->pm.dpm.user_state; + } + dpm_state = adev->pm.dpm.state; + + ps =amdgpu_dpm_pick_power_state (adev, dpm_state); +if (ps) + adev->pm.dpm.requested_ps = ps; +else +return -EINVAL ; + +if (amdgpu_dpm ==1 && adev->powerplay.pp_funcs->print_power_state) { +printk ("switching from power state:\n" ); +amdgpu_dpm_print_power_state (adev, adev->pm.dpm.current_ps); +printk ("switching to power state:\n" ); +amdgpu_dpm_print_power_state (adev, adev->pm.dpm.requested_ps); + } + +/* update whether vce is active */ + ps->vce_active = adev->pm.dpm.vce_active; +if (adev->powerplay.pp_funcs->display_configuration_changed) +amdgpu_dpm_display_configuration_changed (adev); + + ret =amdgpu_dpm_pre_set_power_state (adev); +if (ret) +return ret; + +if (adev->powerplay.pp_funcs->check_state_equal) { +if (0 !=amdgpu_dpm_check_state_equal (adev, adev->pm.dpm.current_ps, adev->pm.dpm.requested_ps, &equal)) + equal = false; + } + +if (equal) +return 0 ; + +if (adev->powerplay.pp_funcs->set_power_state) + adev->powerplay.pp_funcs->set_power_state (adev->powerplay.pp_handle); + +amdgpu_dpm_post_set_power_state (adev); + + adev->pm.dpm.current_active_crtcs = adev->pm.dpm.new_active_crtcs; + adev->pm.dpm.current_active_crtc_count = adev->pm.dpm.new_active_crtc_count; + +if (adev->powerplay.pp_funcs->force_performance_level) { +if (adev->pm.dpm.thermal_active) { +enum amd_dpm_forced_level level = adev->pm.dpm.forced_level; +/* force low perf level for thermal */ +amdgpu_dpm_force_performance_level (adev,AMD_DPM_FORCED_LEVEL_LOW ); +/* save the user's level */ + adev->pm.dpm.forced_level = level; + }else { +/* otherwise, user selected level */ +amdgpu_dpm_force_performance_level (adev, adev->pm.dpm.forced_level); + } + } + +return 0 ; +}drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h new file +37
-0@@ -0,0 +1,37 @@ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ +#ifndef __LEGACY_DPM_H__ +#define __LEGACY_DPM_H__ + +void amdgpu_dpm_print_class_info (u32 class,u32 class2); +void amdgpu_dpm_print_cap_info (u32 caps); +void amdgpu_dpm_print_ps_status (struct amdgpu_device *adev, +struct amdgpu_ps *rps); +int amdgpu_get_platform_caps (struct amdgpu_device *adev); +int amdgpu_parse_extended_power_table (struct amdgpu_device *adev); +void amdgpu_free_extended_power_table (struct amdgpu_device *adev); +void amdgpu_add_thermal_controller (struct amdgpu_device *adev); +struct amd_vce_state *amdgpu_get_vce_clock_state (void *handle,u32 idx); +int amdgpu_dpm_change_power_state_locked (void *handle); +void amdgpu_pm_print_power_states (struct amdgpu_device *adev); +#endif drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +4
-2@@ -37,6 +37,7 @@#include <linux/math64.h> #include <linux/seq_file.h> #include <linux/firmware.h> +#include <legacy_dpm.h> #define MC_CG_ARB_FREQ_F0 0x0a#define MC_CG_ARB_FREQ_F1 0x0b@@ -7800,7 +7801,7 @@ static int si_dpm_hw_init(void *handle)else adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev);return ret; }@@ -7848,7 +7849,7 @@ static int si_dpm_resume(void *handle) adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex);if (adev->pm.dpm_enabled) -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return 0 ; }@@ -8101,6 +8102,7 @@ static const struct amd_pm_funcs si_dpm_funcs = { .check_state_equal = &si_check_state_equal, .get_vce_clock_state = amdgpu_get_vce_clock_state, .read_sensor = &si_dpm_read_sensor, + .change_power_state = amdgpu_dpm_change_power_state_locked, };static const struct amdgpu_irq_src_funcs si_dpm_irq_funcs = {
RE: [PATCH V3 07/17] drm/amd/pm: create a new holder for those APIs used only by legacy ASICs(si/kv)
[AMD Official Use Only]
Quoted 1,486 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, December 2, 2021 10:29 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH V3 07/17] drm/amd/pm: create a new holder for those APIs used only by legacy ASICs(si/kv)Quoted 8 lines · Evan Quan
Those APIs are used only by legacy ASICs(si/kv). They cannot be shared by other ASICs. So, we create a new holder for them.
Signed-off-by Evan Quan <[email protected]>Change-Id I555dfa37e783a267b1d3b3a7db5c87fcc3f1556f--
v1->v2:
- renameamdgpu_pm_compute_clocksas
amdgpu_dpm_compute_clocks(Lijo)Quoted 4 lines
--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 2 +-Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 2 +- .../amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 2 +- .../gpu/drm/amd/include/kgd_pp_interface.h | 1 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 1022 +--------------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 17 +- drivers/gpu/drm/amd/pm/powerplay/Makefile | 2 +- drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c | 6 +- drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c | 1024+++++++++++++++++
Review
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h | 37 + drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 6 +- 13 files changed, 1089 insertions(+), 1036 deletions(-)create mode 100644
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.ccreate mode 100644drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.cdrivers/gpu/drm/amd/amdgpu/dce_v10_0.c static void dce_v10_0_crtc_dpms(struct drm_crtc
Quoted 4 lines
index
d1570a462a51..5d5205870861100644drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +0
-0@@ -2532,7 +2532,7 @@ static void dce_v10_0_crtc_dpms(struct drm_crtc*crtc, int mode)
Review
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1
-1break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v10_0_crtc_prepare (struct drm_crtc *crtc)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.cdrivers/gpu/drm/amd/amdgpu/dce_v11_0.c static void dce_v11_0_crtc_dpms(struct drm_crtc
Quoted 4 lines
index
18a7b3bd633b..4d812b22c54f100644drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +0
-0@@ -2608,7 +2608,7 @@ static void dce_v11_0_crtc_dpms(struct drm_crtc*crtc, int mode)
Review
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1
-1break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v11_0_crtc_prepare (struct drm_crtc *crtc)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.cdrivers/gpu/drm/amd/amdgpu/dce_v6_0.c static void dce_v6_0_crtc_dpms(struct drm_crtc
Quoted 4 lines
index
c7803dc2b2d5..b90bc2adf778100644drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +0
-0@@ -2424,7 +2424,7 @@ static void dce_v6_0_crtc_dpms(struct drm_crtc*crtc, int mode)
Review
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1
-1break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v6_0_crtc_prepare (struct drm_crtc *crtc)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.cdrivers/gpu/drm/amd/amdgpu/dce_v8_0.c static void dce_v8_0_crtc_dpms(struct drm_crtc
Quoted 4 lines
index
8318ee8339f1..7c1379b02f94100644drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +0
-0@@ -2433,7 +2433,7 @@ static void dce_v8_0_crtc_dpms(struct drm_crtc*crtc, int mode)
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1
-1break ; }/* adjust pm to dpms */ -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }static void dce_v8_0_crtc_prepare (struct drm_crtc *crtc)diff --git
a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.cb/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.cQuoted 3 lines
index
46550811da00..75284e2cec74100644
---a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
+++
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.cReview
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1
-1@@ -101,7 +101,7 @@ bool dm_pp_apply_display_requirements(amdgpu_dpm_display_configuration_change (adev, &adev- pm.pm_display_cfg); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return true;
(quoted diff) +0
-0
b/drivers/gpu/drm/amd/include/kgd_pp_interface.hdrivers/gpu/drm/amd/include/kgd_pp_interface.h struct amd_pm_funcs { · line 406
Quoted 7 lines
index
2e295facd086..cdf724dcf832100644drivers/gpu/drm/amd/include/kgd_pp_interface.h +0
-0@@ -404,6 +404,7 @@ struct amd_pm_funcs {int (*get_dpm_clock_table)(void *handle,struct dpm_clocks *clock_table); int (*get_smu_prv_buf_details)(void *handle, void **addr, size_t*size);
Review
Quoted 5 lines
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1
-0+int (*change_power_state)(void *handle); };struct metrics_table_header {(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/amdgpu_dpm.cQuoted 55 lines
index
efe6f8129c06..9b268f300815100644drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-15@@ -34,113 +34,9 @@#define WIDTH_4K 3840 -#define amdgpu_dpm_pre_set_power_state (adev) \ - ((adev)->powerplay.pp_funcs- pre_set_power_state((adev)->powerplay.pp_handle)) - -#define amdgpu_dpm_post_set_power_state (adev) \ - ((adev)->powerplay.pp_funcs- post_set_power_state((adev)->powerplay.pp_handle)) - -#define amdgpu_dpm_display_configuration_changed (adev) \ - ((adev)->powerplay.pp_funcs- display_configuration_changed((adev)->powerplay.pp_handle)) - -#define amdgpu_dpm_print_power_state (adev, ps) \ - ((adev)->powerplay.pp_funcs->print_power_state((adev)- powerplay.pp_handle, (ps))) - -#define amdgpu_dpm_vblank_too_short (adev) \ - ((adev)->powerplay.pp_funcs->vblank_too_short((adev)- powerplay.pp_handle)) -#define amdgpu_dpm_enable_bapm (adev, e) \ ((adev)->powerplay.pp_funcs->enable_bapm((adev)-powerplay.pp_handle, (e)))
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-#define amdgpu_dpm_check_state_equal (adev, cps, rps, equal) \ - ((adev)->powerplay.pp_funcs->check_state_equal((adev)-powerplay.pp_handle, (cps), (rps), (equal)))
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-21- -void amdgpu_dpm_print_class_info (u32 class,u32 class2) -{ -const char *s; - -switch (class &ATOM_PPLIB_CLASSIFICATION_UI_MASK ) { -case ATOM_PPLIB_CLASSIFICATION_UI_NONE : -default : - s ="none" ; -break ; -case ATOM_PPLIB_CLASSIFICATION_UI_BATTERY : - s ="battery" ; -break ; -case ATOM_PPLIB_CLASSIFICATION_UI_BALANCED : - s ="balanced" ; -break ; -case ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE : - s ="performance" ; -break ; - } -printk ("\tui class: %s\n" , s);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10-printk ("\tinternal class:" ); -if (((class & ~ATOM_PPLIB_CLASSIFICATION_UI_MASK ) ==0 ) && - (class2 ==0 )) -pr_cont (" none" ); -else { -if (class &ATOM_PPLIB_CLASSIFICATION_BOOT ) -pr_cont (" boot" ); -if (class &ATOM_PPLIB_CLASSIFICATION_THERMAL ) -pr_cont (" thermal" ); - if (class &
ATOM_PPLIB_CLASSIFICATION_LIMITEDPOWERSOURCE)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-8-pr_cont (" limited_pwr" ); -if (class &ATOM_PPLIB_CLASSIFICATION_REST ) -pr_cont (" rest" ); -if (class &ATOM_PPLIB_CLASSIFICATION_FORCED ) -pr_cont (" forced" ); -if (class &ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE ) -pr_cont (" 3d_perf" ); - if (class &
ATOM_PPLIB_CLASSIFICATION_OVERDRIVETEMPLATE)Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4-pr_cont (" ovrdrv" ); -if (class &ATOM_PPLIB_CLASSIFICATION_UVDSTATE ) -pr_cont (" uvd" ); -if (class &ATOM_PPLIB_CLASSIFICATION_3DLOW )drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10-pr_cont (" 3d_low" ); -if (class &ATOM_PPLIB_CLASSIFICATION_ACPI ) -pr_cont (" acpi" ); -if (class &ATOM_PPLIB_CLASSIFICATION_HD2STATE ) -pr_cont (" uvd_hd2" ); -if (class &ATOM_PPLIB_CLASSIFICATION_HDSTATE ) -pr_cont (" uvd_hd" ); -if (class &ATOM_PPLIB_CLASSIFICATION_SDSTATE ) -pr_cont (" uvd_sd" ); - if (class2 &
ATOM_PPLIB_CLASSIFICATION2_LIMITEDPOWERSOURCE_2)Quoted 25 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-25-pr_cont (" limited_pwr2" ); -if (class2 &ATOM_PPLIB_CLASSIFICATION2_ULV ) -pr_cont (" ulv" ); -if (class2 &ATOM_PPLIB_CLASSIFICATION2_MVC ) -pr_cont (" uvd_mvc" ); - } -pr_cont ("\n" ); -} - -void amdgpu_dpm_print_cap_info (u32 caps) -{ -printk ("\tcaps:" ); -if (caps &ATOM_PPLIB_SINGLE_DISPLAY_ONLY ) -pr_cont (" single_disp" ); -if (caps &ATOM_PPLIB_SUPPORTS_VIDEO_PLAYBACK ) -pr_cont (" video" ); -if (caps &ATOM_PPLIB_DISALLOW_ON_DC ) -pr_cont (" no_dc" ); -pr_cont ("\n" ); -} - -void amdgpu_dpm_print_ps_status (struct amdgpu_device *adev, -struct amdgpu_ps *rps) -{ -printk ("\tstatus:" );drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-9-if (rps == adev->pm.dpm.current_ps) -pr_cont (" c" ); -if (rps == adev->pm.dpm.requested_ps) -pr_cont (" r" ); -if (rps == adev->pm.dpm.boot_ps) -pr_cont (" b" ); -pr_cont ("\n" ); -} - static void amdgpu_dpm_get_active_displays(struct amdgpu_device*adev)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static void amdgpu_dpm_get_active_displays(struct
Quoted 3 lines
{ struct drm_device *ddev = adev_to_drm(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -161,7 +57,6 @@ static void amdgpu_dpm_get_active_displays(struct
amdgpu_device*adev)drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1} } -u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev) {struct drm_device *dev =adev_to_drm (adev);@@ -209,679 +104,6 @@ static u32 amdgpu_dpm_get_vrefresh(struct
amdgpu_device*adev)Quoted 11 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-8return vrefresh; } -union power_info { -struct _ATOM_POWERPLAY_INFO info; -struct _ATOM_POWERPLAY_INFO_V2 info_2; -struct _ATOM_POWERPLAY_INFO_V3 info_3; -struct _ATOM_PPLIB_POWERPLAYTABLE pplib; -struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2; -struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3; -struct _ATOM_PPLIB_POWERPLAYTABLE4 pplib4;drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10-struct _ATOM_PPLIB_POWERPLAYTABLE5 pplib5; -}; - -union fan_info { -struct _ATOM_PPLIB_FANTABLE fan; -struct _ATOM_PPLIB_FANTABLE2 fan2; -struct _ATOM_PPLIB_FANTABLE3 fan3; -}; - -static int amdgpu_parse_clk_voltage_dep_table(struct
amdgpu_clock_voltage_dependency_table*amdgpu_table,drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct · line 230
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1-
ATOM_PPLIB_Clock_Voltage_Dependency_Table*atom_table)Quoted 17 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-13-{ -u32 size = atom_table->ucNumEntries * -sizeof (struct amdgpu_clock_voltage_dependency_entry ); -int i; -ATOM_PPLIB_Clock_Voltage_Dependency_Record *entry; - - amdgpu_table->entries =kzalloc (size,GFP_KERNEL ); -if (!amdgpu_table->entries) -return -ENOMEM ; - - entry = &atom_table->entries[0 ]; -for (i =0 ; i < atom_table->ucNumEntries; i++) { - amdgpu_table->entries[i].clk = le16_to_cpu(entry-usClockLow) |
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (entry->ucClockHigh <<16 ); - amdgpu_table->entries[i].v = le16_to_cpu(entry-usVoltage);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- entry = (ATOM_PPLIB_Clock_Voltage_Dependency_Record*)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ((u8 *)entry +
sizeof(ATOM_PPLIB_Clock_Voltage_Dependency_Record));Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5- } - amdgpu_table->count = atom_table->ucNumEntries; - -return 0 ; -}drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10- -int amdgpu_get_platform_caps(struct amdgpu_device *adev) -{ - struct amdgpu_mode_info *mode_info = &adev->mode_info; - union power_info *power_info; - int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo); - u16 data_offset; - u8 frev, crev; - - if (!amdgpu_atom_parse_data_header(mode_info->atom_context,index, NULL,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- &frev, &crev, &data_offset)) -return -EINVAL ; - power_info = (union power_info *)(mode_info->atom_context-bios +
data_offset);drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- - adev->pm.dpm.platform_caps = le32_to_cpu(power_info-pplib.ulPlatformCaps);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.backbias_response_time =
le16_to_cpu(power_info->pplib.usBackbiasTime);Quoted 18 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.voltage_response_time = le16_to_cpu(power_info-pplib.usVoltageTime);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-16- -return 0 ; -} - -/* sizeof(ATOM_PPLIB_EXTENDEDHEADER) */ -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2 12 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3 14 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V4 16 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V5 18 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V6 20 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V7 22 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V8 24 -#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V9 26 - -int amdgpu_parse_extended_power_table (struct amdgpu_device *adev) -{drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10-struct amdgpu_mode_info *mode_info = &adev->mode_info; -union power_info *power_info; -union fan_info *fan_info; -ATOM_PPLIB_Clock_Voltage_Dependency_Table *dep_table; -int index =GetIndexIntoMasterTable (DATA , PowerPlayInfo); -u16 data_offset; -u8 frev, crev; -int ret, i; - - if (!amdgpu_atom_parse_data_header(mode_info->atom_context,index, NULL,
Quoted 20 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- &frev, &crev, &data_offset)) -return -EINVAL ; - power_info = (union power_info *)(mode_info->atom_context-bios +
data_offset);drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-6- -/* fan table */ -if (le16_to_cpu (power_info->pplib.usTableSize) >= -sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE3 )) { -if (power_info->pplib3.usFanTableOffset) { - fan_info = (union fan_info *)(mode_info-
atom_context->bios+data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(power_info-pplib3.usFanTableOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- adev->pm.dpm.fan.t_hyst = fan_info->fan.ucTHyst; - adev->pm.dpm.fan.t_min = le16_to_cpu(fan_info-fan.usTMin);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.fan.t_med = le16_to_cpu(fan_info-fan.usTMed);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.fan.t_high = le16_to_cpu(fan_info-fan.usTHigh);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.fan.pwm_min =
le16_to_cpu(fan_info->fan.usPWMMin);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.fan.pwm_med =
le16_to_cpu(fan_info->fan.usPWMMed);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.fan.pwm_high =
le16_to_cpu(fan_info->fan.usPWMHigh);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-if (fan_info->fan.ucFanTableFormat >=2 ) - adev->pm.dpm.fan.t_max =
le16_to_cpu(fan_info->fan2.usTMax);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5-else - adev->pm.dpm.fan.t_max =10900 ; - adev->pm.dpm.fan.cycle_delay =100000 ; -if (fan_info->fan.ucFanTableFormat >=3 ) { - adev->pm.dpm.fan.control_mode =
fan_info->fan3.ucFanControlMode;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.fan.default_max_fan_pwm=
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(fan_info-fan3.usFanPWMMax);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.fan.default_fan_output_sensitivity = 4836;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- adev->pm.dpm.fan.fan_output_sensitivity = - le16_to_cpu(fan_info-fan3.usFanOutputSensitivity);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10- } - adev->pm.dpm.fan.ucode_fan_control = true; - } - } - -/* clock dependancy tables, shedding tables */ -if (le16_to_cpu (power_info->pplib.usTableSize) >= -sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE4 )) { -if (power_info->pplib4.usVddcDependencyOnSCLKOffset) { - dep_table =(
ATOM_PPLIB_Clock_Voltage_Dependency_Table*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev) · line 401
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(power_info-pplib4.usVddcDependencyOnSCLKOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ret = amdgpu_parse_clk_voltage_dep_table(&adev-pm.dpm.dyn_state.vddc_dependency_on_sclk,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- dep_table); -if (ret) { -amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5-return ret; - } - } -if (power_info->pplib4.usVddciDependencyOnMCLKOffset) { - dep_table =(
ATOM_PPLIB_Clock_Voltage_Dependency_Table*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev) · line 401
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(power_info-pplib4.usVddciDependencyOnMCLKOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ret = amdgpu_parse_clk_voltage_dep_table(&adev-pm.dpm.dyn_state.vddci_dependency_on_mclk,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- dep_table); -if (ret) { -amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5-return ret; - } - } -if (power_info->pplib4.usVddcDependencyOnMCLKOffset) { - dep_table =(
ATOM_PPLIB_Clock_Voltage_Dependency_Table*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev) · line 401
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(power_info-pplib4.usVddcDependencyOnMCLKOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ret = amdgpu_parse_clk_voltage_dep_table(&adev-pm.dpm.dyn_state.vddc_dependency_on_mclk,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- dep_table); -if (ret) { -amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4-return ret; - } - } -if (power_info->pplib4.usMvddDependencyOnMCLKOffset){
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- dep_table =(
ATOM_PPLIB_Clock_Voltage_Dependency_Table*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev) · line 401
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(power_info-pplib4.usMvddDependencyOnMCLKOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ret = amdgpu_parse_clk_voltage_dep_table(&adev-pm.dpm.dyn_state.mvdd_dependency_on_mclk,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- dep_table); -if (ret) { -amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-7-return ret; - } - } -if (power_info->pplib4.usMaxClockVoltageOnDCOffset) { - ATOM_PPLIB_Clock_Voltage_Limit_Table *clk_v = - (ATOM_PPLIB_Clock_Voltage_Limit_Table *) - (mode_info->atom_context->bios +
data_offset+Quoted 21 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(power_info-pplib4.usMaxClockVoltageOnDCOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-if (clk_v->ucNumEntries) { - adev-pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(clk_v-entries[0].usSclkLow) |
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (clk_v->entries[0 ].ucSclkHigh <<16 ); - adev-pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(clk_v-entries[0].usMclkLow) |
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (clk_v->entries[0 ].ucMclkHigh <<16 ); - adev-pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(clk_v-entries[0].usVddc);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.max_clock_voltage_on_dc.vddci =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(clk_v-entries[0].usVddci);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- } - } -if (power_info->pplib4.usVddcPhaseShedLimitsTableOffset){
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- ATOM_PPLIB_PhaseSheddingLimits_Table *psl = - (ATOM_PPLIB_PhaseSheddingLimits_Table *) - (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(power_info-pplib4.usVddcPhaseShedLimitsTableOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-ATOM_PPLIB_PhaseSheddingLimits_Record *entry; - - adev-pm.dpm.dyn_state.phase_shedding_limits_table.entries =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- kcalloc(psl->ucNumEntries, - sizeof(struct
amdgpu_phase_shedding_limits_entry),Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- GFP_KERNEL); - if (!adev-pm.dpm.dyn_state.phase_shedding_limits_table.entries) { -
amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-6-return -ENOMEM ; - } - - entry = &psl->entries[0 ]; -for (i =0 ; i < psl->ucNumEntries; i++) { - adev-pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].sclk =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(entry->usSclkLow) |(
entry->ucSclkHigh<< 16);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].mclk =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(entry->usMclkLow) |(
entry->ucMclkHigh<< 16);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].voltage =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (entry->usVoltage); - entry =(
ATOM_PPLIB_PhaseSheddingLimits_Record*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ((u8 *)entry +
sizeof(ATOM_PPLIB_PhaseSheddingLimits_Record));Quoted 18 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- } - adev-pm.dpm.dyn_state.phase_shedding_limits_table.count =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-8- psl->ucNumEntries; - } - } - -/* cac data */ -if (le16_to_cpu (power_info->pplib.usTableSize) >= -sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE5 )) { - adev->pm.dpm.tdp_limit = le32_to_cpu(power_info-pplib5.ulTDPLimit);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.near_tdp_limit = le32_to_cpu(power_info-pplib5.ulNearTDPLimit);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.near_tdp_limit_adjusted = adev-pm.dpm.near_tdp_limit;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.tdp_od_limit = le16_to_cpu(power_info-pplib5.usTDPODLimit);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-6-if (adev->pm.dpm.tdp_od_limit) - adev->pm.dpm.power_control = true; -else - adev->pm.dpm.power_control = false; - adev->pm.dpm.tdp_adjustment =0 ; - adev->pm.dpm.sq_ramping_threshold =
le32_to_cpu(power_info->pplib5.ulSQRampingThreshold);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.cac_leakage = le32_to_cpu(power_info-pplib5.ulCACLeakage);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.load_line_slope = le16_to_cpu(power_info-pplib5.usLoadLineSlope);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4-if (power_info->pplib5.usCACLeakageTableOffset) { - ATOM_PPLIB_CAC_Leakage_Table *cac_table = - (ATOM_PPLIB_CAC_Leakage_Table *) - (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(power_info-pplib5.usCACLeakageTableOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-ATOM_PPLIB_CAC_Leakage_Record *entry; - u32 size = cac_table->ucNumEntries * sizeof(struct
amdgpu_cac_leakage_table);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.dyn_state.cac_leakage_table.entries=
kzalloc(size, GFP_KERNEL);Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- if (!adev-pm.dpm.dyn_state.cac_leakage_table.entries) {
-amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5-return -ENOMEM ; - } - entry = &cac_table->entries[0 ]; -for (i =0 ; i < cac_table->ucNumEntries; i++) { - if (adev->pm.dpm.platform_caps &
ATOM_PP_PLATFORM_CAP_EVV) {Quoted 20 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc1 =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(entry-usVddc1);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc2 =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(entry-usVddc2);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc3 =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(entry-usVddc3);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- }else { - adev-pm.dpm.dyn_state.cac_leakage_table.entries[i].vddc =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (entry->usVddc); - adev-pm.dpm.dyn_state.cac_leakage_table.entries[i].leakage =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le32_to_cpu(entry-ulLeakageValue);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- } - entry = (ATOM_PPLIB_CAC_Leakage_Record*)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ((u8 *)entry +
sizeof(ATOM_PPLIB_CAC_Leakage_Record));drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- } - adev->pm.dpm.dyn_state.cac_leakage_table.count=
cac_table->ucNumEntries;drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-7- } - } - -/* ext tables */ -if (le16_to_cpu (power_info->pplib.usTableSize) >= -sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE3 )) { - ATOM_PPLIB_EXTENDEDHEADER *ext_hdr =(
ATOM_PPLIB_EXTENDEDHEADER*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (mode_info->atom_context->bios + data_offset + - le16_to_cpu(power_info-pplib3.usExtendendedHeaderOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- if ((le16_to_cpu(ext_hdr->usSize) >=
SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2) &&drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- ext_hdr->usVCETableOffset) { - VCEClockInfoArray *array = (VCEClockInfoArray *) - (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(ext_hdr->usVCETableOffset) +1);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table*limits =
Quoted 1 line
-
(
ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(ext_hdr->usVCETableOffset) +1 +
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- 1 + array->ucNumEntries *sizeof(VCEClockInfo));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- ATOM_PPLIB_VCE_State_Table *states = - (ATOM_PPLIB_VCE_State_Table *) - (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(ext_hdr->usVCETableOffset) +1 +
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- 1 + (array->ucNumEntries * sizeof(VCEClockInfo)) +
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- 1 + (limits->numEntries *
sizeof(ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record)));drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record*entry;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4-ATOM_PPLIB_VCE_State_Record *state_entry; -VCEClockInfo *vce_clk; - u32 size = limits->numEntries * - sizeof(struct
amdgpu_vce_clock_voltage_dependency_entry);Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-kzalloc (size,GFP_KERNEL ); - if (!adev-pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries) { -
amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 11 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-return -ENOMEM ; - } - adev-pm.dpm.dyn_state.vce_clock_voltage_dependency_table.count =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-7- limits->numEntries; - entry = &limits->entries[0 ]; - state_entry = &states->entries[0 ]; -for (i =0 ; i < limits->numEntries; i++) { - vce_clk = (VCEClockInfo *) - ((u8 *)&array->entries[0] + - (entry->ucVCEClockInfoIndex *sizeof(VCEClockInfo)));
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries[i].evclk
=
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(vce_clk->usEVClkLow) |(
vce_clk->ucEVClkHigh<< 16);Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries[i].ecclk
=
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(vce_clk->usECClkLow) |(
vce_clk->ucECClkHigh<< 16);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries[i].v =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (entry->usVoltage); - entry =(
ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ((u8 *)entry +
sizeof(ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record));drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- } - adev->pm.dpm.num_of_vce_states = - states->numEntries >
AMD_MAX_VCE_LEVELS?drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- AMD_MAX_VCE_LEVELS : states-numEntries;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1-for (i =0 ; i < adev->pm.dpm.num_of_vce_states; i++){
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- vce_clk = (VCEClockInfo *) - ((u8 *)&array->entries[0] + - (state_entry->ucVCEClockInfoIndex* sizeof(VCEClockInfo)));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- adev->pm.dpm.vce_states[i].evclk = - le16_to_cpu(vce_clk->usEVClkLow) |(
vce_clk->ucEVClkHigh<< 16);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- adev->pm.dpm.vce_states[i].ecclk = - le16_to_cpu(vce_clk->usECClkLow) |(
vce_clk->ucECClkHigh<< 16);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- adev->pm.dpm.vce_states[i].clk_idx = - state_entry->ucClockInfoIndex &
0x3f;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- adev->pm.dpm.vce_states[i].pstate = - (state_entry->ucClockInfoIndex &
0xc0) >> 6;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- state_entry =(
ATOM_PPLIB_VCE_State_Record*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ((u8 *)state_entry +
sizeof(ATOM_PPLIB_VCE_State_Record));drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- } - } - if ((le16_to_cpu(ext_hdr->usSize) >=
SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3) &&drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- ext_hdr->usUVDTableOffset) { - UVDClockInfoArray *array = (UVDClockInfoArray *) - (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(ext_hdr->usUVDTableOffset) +1);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table*limits =
Quoted 1 line
-
(
ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(ext_hdr->usUVDTableOffset) +1 +
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- 1 + (array->ucNumEntries * sizeof(UVDClockInfo)));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record*entry;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- u32 size = limits->numEntries * - sizeof(struct
amdgpu_uvd_clock_voltage_dependency_entry);Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-kzalloc (size,GFP_KERNEL ); - if (!adev-pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries) { -
amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-return -ENOMEM ; - } - adev-pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.count =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-6- limits->numEntries; - entry = &limits->entries[0 ]; -for (i =0 ; i < limits->numEntries; i++) { - UVDClockInfo *uvd_clk = (UVDClockInfo *) - ((u8 *)&array->entries[0] + - (entry->ucUVDClockInfoIndex *sizeof(UVDClockInfo)));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries[i].vclk =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(uvd_clk->usVClkLow) |(
uvd_clk->ucVClkHigh<< 16);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries[i].dclk =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(uvd_clk->usDClkLow) |(
uvd_clk->ucDClkHigh<< 16);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries[i].v =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (entry->usVoltage); - entry =(
ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ((u8 *)entry +
sizeof(ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record));drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- } - } - if ((le16_to_cpu(ext_hdr->usSize) >=
SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V4) &&drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- ext_hdr->usSAMUTableOffset) { -ATOM_PPLIB_SAMClk_Voltage_Limit_Table *limits = - (ATOM_PPLIB_SAMClk_Voltage_Limit_Table*)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1-le16_to_cpu (ext_hdr->usSAMUTableOffset)+ 1);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-ATOM_PPLIB_SAMClk_Voltage_Limit_Record *entry; - u32 size = limits->numEntries * - sizeof(struct
amdgpu_clock_voltage_dependency_entry);Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-kzalloc (size,GFP_KERNEL ); - if (!adev-pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries) { -
amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-return -ENOMEM ; - } - adev-pm.dpm.dyn_state.samu_clock_voltage_dependency_table.count =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4- limits->numEntries; - entry = &limits->entries[0 ]; -for (i =0 ; i < limits->numEntries; i++) { - adev-pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries[i].clk =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1-le16_to_cpu (entry->usSAMClockLow)| (
entry->ucSAMClockHigh<< 16);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries[i].v =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (entry->usVoltage); - entry =(
ATOM_PPLIB_SAMClk_Voltage_Limit_Record*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ((u8 *)entry +
sizeof(ATOM_PPLIB_SAMClk_Voltage_Limit_Record));drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- } - } - if ((le16_to_cpu(ext_hdr->usSize) >=
SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V5) &&drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- ext_hdr->usPPMTableOffset) { - ATOM_PPLIB_PPM_Table *ppm =(
ATOM_PPLIB_PPM_Table*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- le16_to_cpu(ext_hdr->usPPMTableOffset)); - adev->pm.dpm.dyn_state.ppm_table = - kzalloc(sizeof(struct amdgpu_ppm_table),
GFP_KERNEL);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-if (!adev->pm.dpm.dyn_state.ppm_table) { -amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-return -ENOMEM ; - } - adev->pm.dpm.dyn_state.ppm_table->ppm_design=
ppm->ucPpmDesign;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.dyn_state.ppm_table-
cpu_core_number=drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (ppm->usCpuCoreNumber); - adev->pm.dpm.dyn_state.ppm_table-
platform_tdp=drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le32_to_cpu (ppm->ulPlatformTDP); - adev->pm.dpm.dyn_state.ppm_table-
small_ac_platform_tdp=drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le32_to_cpu (ppm->ulSmallACPlatformTDP); - adev->pm.dpm.dyn_state.ppm_table->platform_tdc=
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le32_to_cpu (ppm->ulPlatformTDC); - adev->pm.dpm.dyn_state.ppm_table-
small_ac_platform_tdc=drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-6-le32_to_cpu (ppm->ulSmallACPlatformTDC); - adev->pm.dpm.dyn_state.ppm_table->apu_tdp = -le32_to_cpu (ppm->ulApuTDP); - adev->pm.dpm.dyn_state.ppm_table->dgpu_tdp = -le32_to_cpu (ppm->ulDGpuTDP); - adev->pm.dpm.dyn_state.ppm_table-
dgpu_ulv_power=drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5-le32_to_cpu (ppm->ulDGpuUlvPower); - adev->pm.dpm.dyn_state.ppm_table->tj_max = -le32_to_cpu (ppm->ulTjmax); - } - if ((le16_to_cpu(ext_hdr->usSize) >=
SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V6) &&drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- ext_hdr->usACPTableOffset) { -ATOM_PPLIB_ACPClk_Voltage_Limit_Table *limits = - (ATOM_PPLIB_ACPClk_Voltage_Limit_Table*)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(ext_hdr->usACPTableOffset) +1);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-ATOM_PPLIB_ACPClk_Voltage_Limit_Record *entry; - u32 size = limits->numEntries * - sizeof(struct
amdgpu_clock_voltage_dependency_entry);Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-kzalloc (size,GFP_KERNEL ); - if (!adev-pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries) { -
amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-return -ENOMEM ; - } - adev-pm.dpm.dyn_state.acp_clock_voltage_dependency_table.count =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4- limits->numEntries; - entry = &limits->entries[0 ]; -for (i =0 ; i < limits->numEntries; i++) { - adev-pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries[i].clk =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1-le16_to_cpu (entry->usACPClockLow)| (
entry->ucACPClockHigh<< 16);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries[i].v =
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (entry->usVoltage); - entry =(
ATOM_PPLIB_ACPClk_Voltage_Limit_Record*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- ((u8 *)entry +
sizeof(ATOM_PPLIB_ACPClk_Voltage_Limit_Record));drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- } - } - if ((le16_to_cpu(ext_hdr->usSize) >=
SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V7) &&drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- ext_hdr->usPowerTuneTableOffset) { - u8 rev = *(u8 *)(mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(ext_hdr-usPowerTuneTableOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-ATOM_PowerTune_Table *pt; - adev->pm.dpm.dyn_state.cac_tdp_table = - kzalloc(sizeof(struct amdgpu_cac_tdp_table),
GFP_KERNEL);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-if (!adev->pm.dpm.dyn_state.cac_tdp_table) { -amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4-return -ENOMEM ; - } -if (rev >0 ) { - ATOM_PPLIB_POWERTUNE_Table_V1 *ppt =(
ATOM_PPLIB_POWERTUNE_Table_V1*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(ext_hdr-usPowerTuneTableOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.dyn_state.cac_tdp_table-
maximum_power_delivery_limit=drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4- ppt->usMaximumPowerDeliveryLimit; - pt = &ppt->power_tune_table; - }else { - ATOM_PPLIB_POWERTUNE_Table *ppt =(
ATOM_PPLIB_POWERTUNE_Table*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(ext_hdr-usPowerTuneTableOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.dyn_state.cac_tdp_table-
maximum_power_delivery_limit= 255;drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- pt = &ppt->power_tune_table; - } - adev->pm.dpm.dyn_state.cac_tdp_table->tdp =
le16_to_cpu(pt->usTDP);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.dyn_state.cac_tdp_table-
configurable_tdp=drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (pt->usConfigurableTDP); - adev->pm.dpm.dyn_state.cac_tdp_table->tdc =
le16_to_cpu(pt->usTDC);Quoted 11 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.dyn_state.cac_tdp_table-
battery_power_limit=drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (pt->usBatteryPowerLimit); - adev->pm.dpm.dyn_state.cac_tdp_table-
small_power_limit=drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (pt->usSmallPowerLimit); - adev->pm.dpm.dyn_state.cac_tdp_table-
low_cac_leakage=drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-le16_to_cpu (pt->usLowCACLeakage); - adev->pm.dpm.dyn_state.cac_tdp_table-
high_cac_leakage=drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-le16_to_cpu (pt->usHighCACLeakage); - } - if ((le16_to_cpu(ext_hdr->usSize) >=
SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V8) &&drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- ext_hdr->usSclkVddgfxTableOffset) { - dep_table =(
ATOM_PPLIB_Clock_Voltage_Dependency_Table*)drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (mode_info->atom_context->bios +
data_offset+Quoted 61 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- le16_to_cpu(ext_hdr-usSclkVddgfxTableOffset));
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- ret = amdgpu_parse_clk_voltage_dep_table( - &adev-pm.dpm.dyn_state.vddgfx_dependency_on_sclk,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- dep_table); -if (ret) { - kfree(adev-pm.dpm.dyn_state.vddgfx_dependency_on_sclk.entries);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-11-return ret; - } - } - } - -return 0 ; -} - -void amdgpu_free_extended_power_table (struct amdgpu_device *adev) -{ - struct amdgpu_dpm_dynamic_state *dyn_state = &adev-pm.dpm.dyn_state;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-40- -kfree (dyn_state->vddc_dependency_on_sclk.entries); -kfree (dyn_state->vddci_dependency_on_mclk.entries); -kfree (dyn_state->vddc_dependency_on_mclk.entries); -kfree (dyn_state->mvdd_dependency_on_mclk.entries); -kfree (dyn_state->cac_leakage_table.entries); -kfree (dyn_state->phase_shedding_limits_table.entries); -kfree (dyn_state->ppm_table); -kfree (dyn_state->cac_tdp_table); -kfree (dyn_state->vce_clock_voltage_dependency_table.entries); -kfree (dyn_state->uvd_clock_voltage_dependency_table.entries); -kfree (dyn_state->samu_clock_voltage_dependency_table.entries); -kfree (dyn_state->acp_clock_voltage_dependency_table.entries); -kfree (dyn_state->vddgfx_dependency_on_sclk.entries); -} - -static const char *pp_lib_thermal_controller_names[] = { -"NONE" , -"lm63" , -"adm1032" , -"adm1030" , -"max6649" , -"lm64" , -"f75375" , -"RV6xx" , -"RV770" , -"adt7473" , -"NONE" , -"External GPIO" , -"Evergreen" , -"emc2103" , -"Sumo" , -"Northern Islands" , -"Southern Islands" , -"lm96163" , -"Sea Islands" , -"Kaveri/Kabini" , -}; - -void amdgpu_add_thermal_controller (struct amdgpu_device *adev)drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10-{ - struct amdgpu_mode_info *mode_info = &adev->mode_info; - ATOM_PPLIB_POWERPLAYTABLE *power_table; - int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo); - ATOM_PPLIB_THERMALCONTROLLER *controller; - struct amdgpu_i2c_bus_rec i2c_bus; - u16 data_offset; - u8 frev, crev; - - if (!amdgpu_atom_parse_data_header(mode_info->atom_context,index, NULL,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-9- &frev, &crev, &data_offset)) -return ; - power_table = (ATOM_PPLIB_POWERPLAYTABLE *) - (mode_info->atom_context->bios + data_offset); - controller = &power_table->sThermalController; - -/* add the i2c bus for thermal/fan chip */ -if (controller->ucType >0 ) { - if (controller->ucFanParameters &
ATOM_PP_FANPARAMETERS_NOFAN)drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- adev->pm.no_fan = true; - adev->pm.fan_pulses_per_revolution = - controller->ucFanParameters &
ATOM_PP_FANPARAMETERS_TACHOMETER_PULSES_PER_REVOLUTION_MASK;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-if (adev->pm.fan_pulses_per_revolution) { - adev->pm.fan_min_rpm = controller->ucFanMinRPM; - adev->pm.fan_max_rpm = controller-ucFanMaxRPM;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- } - if (controller->ucType ==
ATOM_PP_THERMALCONTROLLER_RV6xx) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("Internal thermal controller %s fancontrol\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.int_thermal_type =
THERMAL_TYPE_RV6XX;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- } else if (controller->ucType ==
ATOM_PP_THERMALCONTROLLER_RV770) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("Internal thermal controller %s fancontrol\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.int_thermal_type =
THERMAL_TYPE_RV770;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- } else if (controller->ucType ==
ATOM_PP_THERMALCONTROLLER_EVERGREEN) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("Internal thermal controller %s fancontrol\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.int_thermal_type =
THERMAL_TYPE_EVERGREEN;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- } else if (controller->ucType ==
ATOM_PP_THERMALCONTROLLER_SUMO) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("Internal thermal controller %s fancontrol\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.int_thermal_type =
THERMAL_TYPE_SUMO;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- } else if (controller->ucType ==
ATOM_PP_THERMALCONTROLLER_NISLANDS) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("Internal thermal controller %s fancontrol\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- adev->pm.int_thermal_type =THERMAL_TYPE_NI ; - } else if (controller->ucType ==
ATOM_PP_THERMALCONTROLLER_SISLANDS) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("Internal thermal controller %s fancontrol\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- adev->pm.int_thermal_type =THERMAL_TYPE_SI ; - } else if (controller->ucType ==
ATOM_PP_THERMALCONTROLLER_CISLANDS) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("Internal thermal controller %s fancontrol\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- adev->pm.int_thermal_type =THERMAL_TYPE_CI ; - } else if (controller->ucType ==
ATOM_PP_THERMALCONTROLLER_KAVERI) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("Internal thermal controller %s fancontrol\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- adev->pm.int_thermal_type =THERMAL_TYPE_KV ; - } else if (controller->ucType ==
ATOM_PP_THERMALCONTROLLER_EXTERNAL_GPIO) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("External GPIO thermal controller %s fancontrol\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.int_thermal_type =
THERMAL_TYPE_EXTERNAL_GPIO;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- } else if (controller->ucType == -
ATOM_PP_THERMALCONTROLLER_ADT7473_WITH_INTERNAL) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("ADT7473 with internal thermalcontroller %s fan control\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.int_thermal_type =
THERMAL_TYPE_ADT7473_WITH_INTERNAL;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- } else if (controller->ucType == -
ATOM_PP_THERMALCONTROLLER_EMC2103_WITH_INTERNAL) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("EMC2103 with internal thermalcontroller %s fan control\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.int_thermal_type =
THERMAL_TYPE_EMC2103_WITH_INTERNAL;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- } else if (controller->ucType <
ARRAY_SIZE(pp_lib_thermal_controller_names)) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- DRM_INFO("Possible %s thermal controller at0x%02x %s fan control\n",
Quoted 1 line
-
pp_lib_thermal_controller_names[controller->ucType],
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- controller->ucI2cAddress >>1 , - (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.int_thermal_type =
THERMAL_TYPE_EXTERNAL;drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- i2c_bus = amdgpu_atombios_lookup_i2c_gpio(adev,
controller->ucI2cLine);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.i2c_bus = amdgpu_i2c_lookup(adev,
&i2c_bus);drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3-if (adev->pm.i2c_bus) { -struct i2c_board_info info = { }; - const char *name =pp_lib_thermal_controller_names[controller->ucType];
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- info.addr = controller->ucI2cAddress >>1 ; -strlcpy (info.type, name,sizeof (info.type)); - i2c_new_client_device(&adev->pm.i2c_bus-adapter, &info);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- } - }else { - DRM_INFO("Unknown thermal controller type %d at0x%02x %s fan control\n",
drivers/gpu/drm/amd/pm/amdgpu_dpm.c static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev)
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4- controller->ucType, - controller->ucI2cAddress >>1 , - (controller->ucFanParameters & - ATOM_PP_FANPARAMETERS_NOFAN) ?"without" : "with");
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void
Quoted 19 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-15- } - } -} - -struct amd_vce_state * -amdgpu_get_vce_clock_state (void *handle,u32 idx) -{ -struct amdgpu_device *adev = (struct amdgpu_device *)handle; - -if (idx < adev->pm.dpm.num_of_vce_states) -return &adev->pm.dpm.vce_states[idx]; - -return NULL ; -} -int amdgpu_dpm_get_sclk (struct amdgpu_device *adev,bool low) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;@@ -1240,215 +462,10 @@ void
amdgpu_dpm_thermal_work_handler(struct work_struct *work)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-2adev->pm.dpm.state = dpm_state;mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); } -static struct amdgpu_ps *amdgpu_dpm_pick_power_state(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c void · line 1247
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- enum
amd_pm_state_typedpm_state)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-9-{ -int i; -struct amdgpu_ps *ps; -u32 ui_class; -bool single_display = (adev->pm.dpm.new_active_crtc_count <2 ) ? - true : false; - -/* check if the vblank period is too short to adjust the mclk */ -if (single_display && adev->powerplay.pp_funcs->vblank_too_short){
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-8-if (amdgpu_dpm_vblank_too_short (adev)) - single_display = false; - } - -/* certain older asics have a separare 3D performance state, -* so try that first if the user selected performance -*/ -if (dpm_state ==POWER_STATE_TYPE_PERFORMANCE )drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10- dpm_state =POWER_STATE_TYPE_INTERNAL_3DPERF ; -/* balanced states don't exist at the moment */ -if (dpm_state ==POWER_STATE_TYPE_BALANCED ) - dpm_state =POWER_STATE_TYPE_PERFORMANCE ; - -restart_search: -/* Pick the best power state based on current conditions */ -for (i =0 ; i < adev->pm.dpm.num_ps; i++) { - ps = &adev->pm.dpm.ps[i]; - ui_class = ps->class &
ATOM_PPLIB_CLASSIFICATION_UI_MASK;drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4-switch (dpm_state) { -/* user states */ -case POWER_STATE_TYPE_BATTERY : - if (ui_class ==
ATOM_PPLIB_CLASSIFICATION_UI_BATTERY) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c void · line 1279
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- if (ps->caps &
ATOM_PPLIB_SINGLE_DISPLAY_ONLY) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-8-if (single_display) -return ps; - }else -return ps; - } -break ; -case POWER_STATE_TYPE_BALANCED : - if (ui_class ==
ATOM_PPLIB_CLASSIFICATION_UI_BALANCED) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c void · line 1288
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- if (ps->caps &
ATOM_PPLIB_SINGLE_DISPLAY_ONLY) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-8-if (single_display) -return ps; - }else -return ps; - } -break ; -case POWER_STATE_TYPE_PERFORMANCE : - if (ui_class ==
ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c void · line 1297
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- if (ps->caps &
ATOM_PPLIB_SINGLE_DISPLAY_ONLY) {Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4-if (single_display) -return ps; - }else -return ps;drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10- } -break ; -/* internal states */ -case POWER_STATE_TYPE_INTERNAL_UVD : -if (adev->pm.dpm.uvd_ps) -return adev->pm.dpm.uvd_ps; -else -break ; -case POWER_STATE_TYPE_INTERNAL_UVD_SD : - if (ps->class &
ATOM_PPLIB_CLASSIFICATION_SDSTATE)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4-return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_UVD_HD : - if (ps->class &
ATOM_PPLIB_CLASSIFICATION_HDSTATE)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4-return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_UVD_HD2 : - if (ps->class &
ATOM_PPLIB_CLASSIFICATION_HD2STATE)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4-return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_UVD_MVC : - if (ps->class2 &
ATOM_PPLIB_CLASSIFICATION2_MVC)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-6-return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_BOOT : -return adev->pm.dpm.boot_ps; -case POWER_STATE_TYPE_INTERNAL_THERMAL : - if (ps->class &
ATOM_PPLIB_CLASSIFICATION_THERMAL)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 12 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-12-return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_ACPI : -if (ps->class &ATOM_PPLIB_CLASSIFICATION_ACPI ) -return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_ULV : -if (ps->class2 &ATOM_PPLIB_CLASSIFICATION2_ULV ) -return ps; -break ; -case POWER_STATE_TYPE_INTERNAL_3DPERF : - if (ps->class &
ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE)Quoted 29 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-29-return ps; -break ; -default : -break ; - } - } -/* use a fallback state if we didn't match */ -switch (dpm_state) { -case POWER_STATE_TYPE_INTERNAL_UVD_SD : - dpm_state =POWER_STATE_TYPE_INTERNAL_UVD_HD ; - goto restart_search; -case POWER_STATE_TYPE_INTERNAL_UVD_HD : -case POWER_STATE_TYPE_INTERNAL_UVD_HD2 : -case POWER_STATE_TYPE_INTERNAL_UVD_MVC : -if (adev->pm.dpm.uvd_ps) { -return adev->pm.dpm.uvd_ps; - }else { - dpm_state =POWER_STATE_TYPE_PERFORMANCE ; - goto restart_search; - } -case POWER_STATE_TYPE_INTERNAL_THERMAL : - dpm_state =POWER_STATE_TYPE_INTERNAL_ACPI ; - goto restart_search; -case POWER_STATE_TYPE_INTERNAL_ACPI : - dpm_state =POWER_STATE_TYPE_BATTERY ; - goto restart_search; -case POWER_STATE_TYPE_BATTERY : -case POWER_STATE_TYPE_BALANCED : -case POWER_STATE_TYPE_INTERNAL_3DPERF :drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10- dpm_state =POWER_STATE_TYPE_PERFORMANCE ; - goto restart_search; -default : -break ; - } - -return NULL ; -} - -static void amdgpu_dpm_change_power_state_locked(struct
amdgpu_device*adev)Quoted 67 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-50-{ -struct amdgpu_ps *ps; -enum amd_pm_state_type dpm_state; -int ret; -bool equal = false; - -/* if dpm init failed */ -if (!adev->pm.dpm_enabled) -return ; - -if (adev->pm.dpm.user_state != adev->pm.dpm.state) { -/* add other state override checks here */ -if ((!adev->pm.dpm.thermal_active) && - (!adev->pm.dpm.uvd_active)) - adev->pm.dpm.state = adev->pm.dpm.user_state; - } - dpm_state = adev->pm.dpm.state; - - ps =amdgpu_dpm_pick_power_state (adev, dpm_state); -if (ps) - adev->pm.dpm.requested_ps = ps; -else -return ; - -if (amdgpu_dpm ==1 && adev->powerplay.pp_funcs- print_power_state) { -printk ("switching from power state:\n" ); -amdgpu_dpm_print_power_state (adev, adev- pm.dpm.current_ps); -printk ("switching to power state:\n" ); -amdgpu_dpm_print_power_state (adev, adev- pm.dpm.requested_ps); - } - -/* update whether vce is active */ - ps->vce_active = adev->pm.dpm.vce_active; -if (adev->powerplay.pp_funcs->display_configuration_changed) -amdgpu_dpm_display_configuration_changed (adev); - - ret =amdgpu_dpm_pre_set_power_state (adev); -if (ret) -return ; - -if (adev->powerplay.pp_funcs->check_state_equal) { -if (0 !=amdgpu_dpm_check_state_equal (adev, adev- pm.dpm.current_ps, adev->pm.dpm.requested_ps, &equal)) - equal = false; - } - -if (equal) -return ; - -if (adev->powerplay.pp_funcs->set_power_state) - adev->powerplay.pp_funcs->set_power_state(adev-powerplay.pp_handle);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4- -amdgpu_dpm_post_set_power_state (adev); - - adev->pm.dpm.current_active_crtcs = adev-pm.dpm.new_active_crtcs;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.dpm.current_active_crtc_count = adev-pm.dpm.new_active_crtc_count;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4- -if (adev->powerplay.pp_funcs->force_performance_level) { -if (adev->pm.dpm.thermal_active) { - enum amd_dpm_forced_level level = adev-pm.dpm.forced_level;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2-/* force low perf level for thermal */ - amdgpu_dpm_force_performance_level(adev,
AMD_DPM_FORCED_LEVEL_LOW);drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5-/* save the user's level */ - adev->pm.dpm.forced_level = level; - }else { -/* otherwise, user selected level */ - amdgpu_dpm_force_performance_level(adev,
adev->pm.dpm.forced_level);drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_pm_compute_clocks(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-5- } - } -} - -void amdgpu_pm_compute_clocks (struct amdgpu_device *adev) +void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev) {int i =0 ;@@ -1464,9 +481,12 @@ void amdgpu_pm_compute_clocks(struct
amdgpu_device*adev)Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0amdgpu_fence_wait_empty (ring); }
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-1-if (adev->powerplay.pp_funcs->dispatch_tasks) { +if ((adev->family ==AMDGPU_FAMILY_SI ) || + (adev->family ==AMDGPU_FAMILY_KV )) { +amdgpu_dpm_get_active_displays (adev); + adev->powerplay.pp_funcs->change_power_state (adev- powerplay.pp_handle);Missed this earlier. This also subtly drops the mutex lock (here and below). Is that intended?
[Quan, Evan] Thanks! Will add them back here. Although the last patch of the series can guard this covered.
BR
Evan
Quoted 1,672 lines
Thanks,
LijoQuoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1+ }else {if (!amdgpu_device_has_dc_support (adev)) { -mutex_lock (&adev->pm.mutex);amdgpu_dpm_get_active_displays (adev); adev->pm.pm_display_cfg.num_display = adev-pm.dpm.new_active_crtc_count;
adev->pm.pm_display_cfg.vrefresh=
amdgpu_dpm_get_vrefresh(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_pm_compute_clocks(struct
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1480,14 +500,8 @@ void amdgpu_pm_compute_clocks(struct
amdgpu_device*adev)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0adev->powerplay.pp_funcs-display_configuration_change(
adev-
powerplay.pp_handle,
&adev-
pm.pm_display_cfg);drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1-mutex_unlock (&adev->pm.mutex); } amdgpu_dpm_dispatch_task(adev,
AMD_PP_TASK_DISPLAY_CONFIG_CHANGE, NULL);drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_uvd(struct
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5- }else { -mutex_lock (&adev->pm.mutex); -amdgpu_dpm_get_active_displays (adev); -amdgpu_dpm_change_power_state_locked (adev); -mutex_unlock (&adev->pm.mutex); } }@@ -1505,7 +519,7 @@ void amdgpu_dpm_enable_uvd(struct
amdgpu_device*adev, bool enable)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable)
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1}mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }else { ret = amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_UVD, !enable);drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_vce(struct
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0if (ret)@@ -1541,7 +555,7 @@ void amdgpu_dpm_enable_vce(struct
amdgpu_device*adev, bool enable)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable)
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1}mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }else { ret = amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_VCE, !enable);drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_vce(struct
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0if (ret)@@ -1550,18 +564,6 @@ void amdgpu_dpm_enable_vce(struct
amdgpu_device*adev, bool enable)Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4} } -void amdgpu_pm_print_power_states (struct amdgpu_device *adev) -{ -int i; -drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable)
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-8-if (adev->powerplay.pp_funcs->print_power_state ==NULL ) -return ; - -for (i =0 ; i < adev->pm.dpm.num_ps; i++) -amdgpu_dpm_print_power_state (adev, &adev- pm.dpm.ps[i]); - -} - void amdgpu_dpm_enable_jpeg(struct amdgpu_device *adev, boolenable)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_set_power_state(struct
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0{int ret = 0;drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1724,7 +726,7 @@ void amdgpu_dpm_set_power_state(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_set_power_state(struct · line 727
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0if (adev->powerplay.pp_funcs->dispatch_tasks) amdgpu_dpm_dispatch_task(adev,
AMD_PP_TASK_ENABLE_USER_STATE, &state);drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_set_power_state(struct amdgpu_device *adev,
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1else -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }enum amd_dpm_forced_level
amdgpu_dpm_get_performance_level(struct amdgpu_device *adev)drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_set_sclk_od(struct
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1898,7 +900,7 @@ int amdgpu_dpm_set_sclk_od(struct
amdgpu_device*adev,uint32_tvalue)drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_set_mclk_od(struct
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1AMD_PP_TASK_READJUST_POWER_STATE, NULL) == -EOPNOTSUPP) { adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return 0 ;@@ -1927,7 +929,7 @@ int amdgpu_dpm_set_mclk_od(struct
amdgpu_device*adev,uint32_tvalue)Review
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1AMD_PP_TASK_READJUST_POWER_STATE, NULL) == -EOPNOTSUPP) { adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return 0 ;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.hdrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum amdgpu_display_gap · line 370
Quoted 13 lines
index
01120b302590..89caece4ab3e100644drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-4@@ -366,24 +366,10 @@ enum amdgpu_display_gap AMDGPU_PM_DISPLAY_GAP_IGNORE = 3, }; -void amdgpu_dpm_print_class_info (u32 class,u32 class2); -void amdgpu_dpm_print_cap_info (u32 caps); -void amdgpu_dpm_print_ps_status (struct amdgpu_device *adev, -struct amdgpu_ps *rps);u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev); int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum
amd_pp_sensorssensor,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum amdgpu_display_gap
Quoted 6 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-4void *data, uint32_t *size); -int amdgpu_get_platform_caps (struct amdgpu_device *adev); - -int amdgpu_parse_extended_power_table (struct amdgpu_device *adev); -void amdgpu_free_extended_power_table(struct amdgpu_device*adev);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum amdgpu_display_gap
Quoted 7 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-6- -void amdgpu_add_thermal_controller (struct amdgpu_device *adev); - -struct amd_vce_state * -amdgpu_get_vce_clock_state (void *handle,u32 idx); - int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device*adev,
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h int amdgpu_dpm_read_sensor(struct
Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0uint32_t block_type, bool gate);@@ -434,11 +420,10 @@ int amdgpu_dpm_read_sensor(struct
amdgpu_device*adev, enumamd_pp_sensorssensodrivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
Quoted 6 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-1void amdgpu_dpm_thermal_work_handler (struct work_struct *work); -void amdgpu_pm_compute_clocks (struct amdgpu_device *adev); +void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev); void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, boolenable);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h int amdgpu_dpm_read_sensor(struct · line 424
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, boolenable);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h int amdgpu_dpm_read_sensor(struct · line 425
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_dpm_enable_jpeg(struct amdgpu_device *adev, boolenable);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h int amdgpu_dpm_read_sensor(struct · line 426
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-1-void amdgpu_pm_print_power_states (struct amdgpu_device *adev); int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev,
uint32_t*smu_version);drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h int amdgpu_dpm_read_sensor(struct · line 427
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0int amdgpu_dpm_set_light_sbr(struct amdgpu_device *adev, boolenable);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h int amdgpu_dpm_read_sensor(struct · line 428
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0int amdgpu_dpm_send_hbm_bad_pages_num(struct amdgpu_device*adev,
uint32_tsize);Review
Quoted 1 line
(quoted diff) +0
-0b/drivers/gpu/drm/amd/pm/powerplay/Makefile
drivers/gpu/drm/amd/pm/powerplay/Makefile AMD_POWERPLAY = $(addsuffix
Quoted 4 lines
index
0fb114adc79f..614d8b6a58ad100644drivers/gpu/drm/amd/pm/powerplay/Makefile +0
-0@@ -28,7 +28,7 @@ AMD_POWERPLAY = $(addsuffix/Makefile,$(addprefix $(FULL_AMD_PATH)/pm/powerplay/
Review
Quoted 9 lines
drivers/gpu/drm/amd/pm/powerplay/Makefile +1
-1include $(AMD_POWERPLAY) -POWER_MGR-y = amd_powerplay.o +POWER_MGR-y = amd_powerplay.o legacy_dpm.o POWER_MGR-$(CONFIG_DRM_AMDGPU_CIK)+= kv_dpm.o kv_smc.o(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/powerplay/kv_dpm.cdrivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static const struct amd_pm_funcs kv_dpm_funcs
Quoted 30 lines
index
380a5336c74f..eed89835231c100644drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +3
-2@@ -36,6 +36,7 @@#include "gca/gfx_7_2_d.h" #include "gca/gfx_7_2_sh_mask.h" +#include "legacy_dpm.h" #define KV_MAX_DEEPSLEEP_DIVIDER_ID 5#define KV_MINIMUM_ENGINE_CLOCK 800@@ -3087,7 +3088,7 @@ static int kv_dpm_hw_init(void *handle)else adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex); -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev);return ret; }@@ -3135,7 +3136,7 @@ static int kv_dpm_resume(void *handle) adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex);if (adev->pm.dpm_enabled) -amdgpu_pm_compute_clocks (adev); +amdgpu_dpm_compute_clocks (adev); }return 0 ; }@@ -3389,6 +3390,7 @@ static const struct amd_pm_funcs kv_dpm_funcs= {
Review
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1
-0.get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, .read_sensor = &kv_dpm_read_sensor, + .change_power_state = amdgpu_dpm_change_power_state_locked, };static const struct amdgpu_irq_src_funcs kv_dpm_irq_funcs = {(quoted diff) +0
-0
b/drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.cdrivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c line 5
Quoted 10 lines
new file mode 100644
index 000000000000..67c84b7ad8e7drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +5
-0@@ -0,0 +1,1024 @@ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"),
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +6
-0+* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c line 15
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c line 16
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c line 17
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c line 18
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c line 19
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Quoted 54 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +12
-0+* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "amdgpu.h" +#include "amdgpu_i2c.h" +#include "amdgpu_atombios.h" +#include "atom.h" +#include "amd_pcie.h" +#include "legacy_dpm.h" + +#define amdgpu_dpm_pre_set_power_state (adev) \ + ((adev)->powerplay.pp_funcs-pre_set_power_state((adev)->powerplay.pp_handle))
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ +#define amdgpu_dpm_post_set_power_state (adev) \ + ((adev)->powerplay.pp_funcs-post_set_power_state((adev)->powerplay.pp_handle))
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ +#define amdgpu_dpm_display_configuration_changed (adev) \ + ((adev)->powerplay.pp_funcs-display_configuration_changed((adev)->powerplay.pp_handle))
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ +#define amdgpu_dpm_print_power_state (adev, ps) \ + ((adev)->powerplay.pp_funcs->print_power_state((adev)-powerplay.pp_handle, (ps)))
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ +#define amdgpu_dpm_vblank_too_short (adev) \ + ((adev)->powerplay.pp_funcs->vblank_too_short((adev)-powerplay.pp_handle))
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ +#define amdgpu_dpm_check_state_equal (adev, cps, rps, equal) \ + ((adev)->powerplay.pp_funcs->check_state_equal((adev)-powerplay.pp_handle, (cps), (rps), (equal)))
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +21
-0+ +void amdgpu_dpm_print_class_info (u32 class,u32 class2) +{ +const char *s; + +switch (class &ATOM_PPLIB_CLASSIFICATION_UI_MASK ) { +case ATOM_PPLIB_CLASSIFICATION_UI_NONE : +default : + s ="none" ; +break ; +case ATOM_PPLIB_CLASSIFICATION_UI_BATTERY : + s ="battery" ; +break ; +case ATOM_PPLIB_CLASSIFICATION_UI_BALANCED : + s ="balanced" ; +break ; +case ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE : + s ="performance" ; +break ; + } +printk ("\tui class: %s\n" , s);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +10
-0+printk ("\tinternal class:" ); +if (((class & ~ATOM_PPLIB_CLASSIFICATION_UI_MASK ) ==0 ) && + (class2 ==0 )) +pr_cont (" none" ); +else { +if (class &ATOM_PPLIB_CLASSIFICATION_BOOT ) +pr_cont (" boot" ); +if (class &ATOM_PPLIB_CLASSIFICATION_THERMAL ) +pr_cont (" thermal" ); + if (class &
ATOM_PPLIB_CLASSIFICATION_LIMITEDPOWERSOURCE)drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +8
-0+pr_cont (" limited_pwr" ); +if (class &ATOM_PPLIB_CLASSIFICATION_REST ) +pr_cont (" rest" ); +if (class &ATOM_PPLIB_CLASSIFICATION_FORCED ) +pr_cont (" forced" ); +if (class &ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE ) +pr_cont (" 3d_perf" ); + if (class &
ATOM_PPLIB_CLASSIFICATION_OVERDRIVETEMPLATE)Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +4
-0+pr_cont (" ovrdrv" ); +if (class &ATOM_PPLIB_CLASSIFICATION_UVDSTATE ) +pr_cont (" uvd" ); +if (class &ATOM_PPLIB_CLASSIFICATION_3DLOW )drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +10
-0+pr_cont (" 3d_low" ); +if (class &ATOM_PPLIB_CLASSIFICATION_ACPI ) +pr_cont (" acpi" ); +if (class &ATOM_PPLIB_CLASSIFICATION_HD2STATE ) +pr_cont (" uvd_hd2" ); +if (class &ATOM_PPLIB_CLASSIFICATION_HDSTATE ) +pr_cont (" uvd_hd" ); +if (class &ATOM_PPLIB_CLASSIFICATION_SDSTATE ) +pr_cont (" uvd_sd" ); + if (class2 &
ATOM_PPLIB_CLASSIFICATION2_LIMITEDPOWERSOURCE_2)Quoted 57 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +43
-0+pr_cont (" limited_pwr2" ); +if (class2 &ATOM_PPLIB_CLASSIFICATION2_ULV ) +pr_cont (" ulv" ); +if (class2 &ATOM_PPLIB_CLASSIFICATION2_MVC ) +pr_cont (" uvd_mvc" ); + } +pr_cont ("\n" ); +} + +void amdgpu_dpm_print_cap_info (u32 caps) +{ +printk ("\tcaps:" ); +if (caps &ATOM_PPLIB_SINGLE_DISPLAY_ONLY ) +pr_cont (" single_disp" ); +if (caps &ATOM_PPLIB_SUPPORTS_VIDEO_PLAYBACK ) +pr_cont (" video" ); +if (caps &ATOM_PPLIB_DISALLOW_ON_DC ) +pr_cont (" no_dc" ); +pr_cont ("\n" ); +} + +void amdgpu_dpm_print_ps_status (struct amdgpu_device *adev, +struct amdgpu_ps *rps) +{ +printk ("\tstatus:" ); +if (rps == adev->pm.dpm.current_ps) +pr_cont (" c" ); +if (rps == adev->pm.dpm.requested_ps) +pr_cont (" r" ); +if (rps == adev->pm.dpm.boot_ps) +pr_cont (" b" ); +pr_cont ("\n" ); +} + +void amdgpu_pm_print_power_states (struct amdgpu_device *adev) +{ +int i; + +if (adev->powerplay.pp_funcs->print_power_state ==NULL ) +return ; + +for (i =0 ; i < adev->pm.dpm.num_ps; i++) + amdgpu_dpm_print_power_state(adev, &adev-pm.dpm.ps[i]);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +13
-0+ +} + +union power_info { +struct _ATOM_POWERPLAY_INFO info; +struct _ATOM_POWERPLAY_INFO_V2 info_2; +struct _ATOM_POWERPLAY_INFO_V3 info_3; +struct _ATOM_PPLIB_POWERPLAYTABLE pplib; +struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2; +struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3; +struct _ATOM_PPLIB_POWERPLAYTABLE4 pplib4; +struct _ATOM_PPLIB_POWERPLAYTABLE5 pplib5; +};drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +10
-0+ +int amdgpu_get_platform_caps(struct amdgpu_device *adev) +{ + struct amdgpu_mode_info *mode_info = &adev->mode_info; + union power_info *power_info; + int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo); + u16 data_offset; + u8 frev, crev; + + if (!amdgpu_atom_parse_data_header(mode_info->atom_context,index, NULL,
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ &frev, &crev, &data_offset)) +return -EINVAL ; + power_info = (union power_info *)(mode_info->atom_context-bios +
data_offset);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0+ + adev->pm.dpm.platform_caps = le32_to_cpu(power_info-pplib.ulPlatformCaps);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ adev->pm.dpm.backbias_response_time =
le16_to_cpu(power_info->pplib.usBackbiasTime);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 13 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ adev->pm.dpm.voltage_response_time = le16_to_cpu(power_info-pplib.usVoltageTime);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +11
-0+ +return 0 ; +} + +union fan_info { +struct _ATOM_PPLIB_FANTABLE fan; +struct _ATOM_PPLIB_FANTABLE2 fan2; +struct _ATOM_PPLIB_FANTABLE3 fan3; +}; + +static int amdgpu_parse_clk_voltage_dep_table(struct
amdgpu_clock_voltage_dependency_table*amdgpu_table,Quoted 1 line
+
ATOM_PPLIB_Clock_Voltage_Dependency_Table*atom_table)Quoted 17 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +13
-0+{ +u32 size = atom_table->ucNumEntries * +sizeof (struct amdgpu_clock_voltage_dependency_entry ); +int i; +ATOM_PPLIB_Clock_Voltage_Dependency_Record *entry; + + amdgpu_table->entries =kzalloc (size,GFP_KERNEL ); +if (!amdgpu_table->entries) +return -ENOMEM ; + + entry = &atom_table->entries[0 ]; +for (i =0 ; i < atom_table->ucNumEntries; i++) { + amdgpu_table->entries[i].clk = le16_to_cpu(entry-usClockLow) |
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0+ (entry->ucClockHigh <<16 ); + amdgpu_table->entries[i].v = le16_to_cpu(entry-usVoltage);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ entry = (ATOM_PPLIB_Clock_Voltage_Dependency_Record*)
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ ((u8 *)entry +
sizeof(ATOM_PPLIB_Clock_Voltage_Dependency_Record));Quoted 18 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +18
-0+ } + amdgpu_table->count = atom_table->ucNumEntries; + +return 0 ; +} + +/* sizeof(ATOM_PPLIB_EXTENDEDHEADER) */ +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2 12 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3 14 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V4 16 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V5 18 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V6 20 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V7 22 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V8 24 +#define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V9 26 + +int amdgpu_parse_extended_power_table (struct amdgpu_device *adev) +{drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +10
-0+struct amdgpu_mode_info *mode_info = &adev->mode_info; +union power_info *power_info; +union fan_info *fan_info; +ATOM_PPLIB_Clock_Voltage_Dependency_Table *dep_table; +int index =GetIndexIntoMasterTable (DATA , PowerPlayInfo); +u16 data_offset; +u8 frev, crev; +int ret, i; + + if (!amdgpu_atom_parse_data_header(mode_info->atom_context,index, NULL,
Quoted 20 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ &frev, &crev, &data_offset)) +return -EINVAL ; + power_info = (union power_info *)(mode_info->atom_context-bios +
data_offset);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +6
-0+ +/* fan table */ +if (le16_to_cpu (power_info->pplib.usTableSize) >= +sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE3 )) { +if (power_info->pplib3.usFanTableOffset) { + fan_info = (union fan_info *)(mode_info-
atom_context->bios+data_offset+drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(power_info-pplib3.usFanTableOffset));
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0+ adev->pm.dpm.fan.t_hyst = fan_info->fan.ucTHyst; + adev->pm.dpm.fan.t_min = le16_to_cpu(fan_info-fan.usTMin);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ adev->pm.dpm.fan.t_med = le16_to_cpu(fan_info-fan.usTMed);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ adev->pm.dpm.fan.t_high = le16_to_cpu(fan_info-fan.usTHigh);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ adev->pm.dpm.fan.pwm_min =
le16_to_cpu(fan_info->fan.usPWMMin);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ adev->pm.dpm.fan.pwm_med =
le16_to_cpu(fan_info->fan.usPWMMed);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ adev->pm.dpm.fan.pwm_high =
le16_to_cpu(fan_info->fan.usPWMHigh);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0+if (fan_info->fan.ucFanTableFormat >=2 ) + adev->pm.dpm.fan.t_max =
le16_to_cpu(fan_info->fan2.usTMax);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +5
-0+else + adev->pm.dpm.fan.t_max =10900 ; + adev->pm.dpm.fan.cycle_delay =100000 ; +if (fan_info->fan.ucFanTableFormat >=3 ) { + adev->pm.dpm.fan.control_mode =
fan_info->fan3.ucFanControlMode;drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ adev->pm.dpm.fan.default_max_fan_pwm=
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(fan_info-fan3.usFanPWMMax);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ adev-pm.dpm.fan.default_fan_output_sensitivity = 4836;
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0+ adev->pm.dpm.fan.fan_output_sensitivity = + le16_to_cpu(fan_info-fan3.usFanOutputSensitivity);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +10
-0+ } + adev->pm.dpm.fan.ucode_fan_control = true; + } + } + +/* clock dependancy tables, shedding tables */ +if (le16_to_cpu (power_info->pplib.usTableSize) >= +sizeof (struct _ATOM_PPLIB_POWERPLAYTABLE4 )) { +if (power_info->pplib4.usVddcDependencyOnSCLKOffset) { + dep_table =(
ATOM_PPLIB_Clock_Voltage_Dependency_Table*)drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c line 335
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(power_info-pplib4.usVddcDependencyOnSCLKOffset));
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ ret = amdgpu_parse_clk_voltage_dep_table(&adev-pm.dpm.dyn_state.vddc_dependency_on_sclk,
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ dep_table); +if (ret) { +amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +5
-0+return ret; + } + } +if (power_info->pplib4.usVddciDependencyOnMCLKOffset) { + dep_table =(
ATOM_PPLIB_Clock_Voltage_Dependency_Table*)drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c line 335
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(power_info-pplib4.usVddciDependencyOnMCLKOffset));
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ ret = amdgpu_parse_clk_voltage_dep_table(&adev-pm.dpm.dyn_state.vddci_dependency_on_mclk,
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ dep_table); +if (ret) { +amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +5
-0+return ret; + } + } +if (power_info->pplib4.usVddcDependencyOnMCLKOffset) { + dep_table =(
ATOM_PPLIB_Clock_Voltage_Dependency_Table*)drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c line 335
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(power_info-pplib4.usVddcDependencyOnMCLKOffset));
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ ret = amdgpu_parse_clk_voltage_dep_table(&adev-pm.dpm.dyn_state.vddc_dependency_on_mclk,
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ dep_table); +if (ret) { +amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +4
-0+return ret; + } + } +if (power_info->pplib4.usMvddDependencyOnMCLKOffset){
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ dep_table =(
ATOM_PPLIB_Clock_Voltage_Dependency_Table*)drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c line 335
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(power_info-pplib4.usMvddDependencyOnMCLKOffset));
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ ret = amdgpu_parse_clk_voltage_dep_table(&adev-pm.dpm.dyn_state.mvdd_dependency_on_mclk,
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ dep_table); +if (ret) { +amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +7
-0+return ret; + } + } +if (power_info->pplib4.usMaxClockVoltageOnDCOffset) { + ATOM_PPLIB_Clock_Voltage_Limit_Table *clk_v = + (ATOM_PPLIB_Clock_Voltage_Limit_Table *) + (mode_info->atom_context->bios +
data_offset+Quoted 21 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(power_info-pplib4.usMaxClockVoltageOnDCOffset));
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0+if (clk_v->ucNumEntries) { + adev-pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk =
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(clk_v-entries[0].usSclkLow) |
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0+ (clk_v->entries[0 ].ucSclkHigh <<16 ); + adev-pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk =
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(clk_v-entries[0].usMclkLow) |
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0+ (clk_v->entries[0 ].ucMclkHigh <<16 ); + adev-pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc =
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(clk_v-entries[0].usVddc);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ adev-pm.dpm.dyn_state.max_clock_voltage_on_dc.vddci =
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(clk_v-entries[0].usVddci);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ } + } +if (power_info->pplib4.usVddcPhaseShedLimitsTableOffset){
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ ATOM_PPLIB_PhaseSheddingLimits_Table *psl = + (ATOM_PPLIB_PhaseSheddingLimits_Table *) + (mode_info->atom_context->bios +
data_offset+drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0+ le16_to_cpu(power_info-pplib4.usVddcPhaseShedLimitsTableOffset));
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +3
-0+ATOM_PPLIB_PhaseSheddingLimits_Record *entry; + + adev-pm.dpm.dyn_state.phase_shedding_limits_table.entries =
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0+ kcalloc(psl->ucNumEntries, + sizeof(struct
amdgpu_phase_shedding_limits_entry),Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0+ GFP_KERNEL); + if (!adev-pm.dpm.dyn_state.phase_shedding_limits_table.entries) { +
amdgpu_free_extended_power_table(adev);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +6
-0+return -ENOMEM ; + } +Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].sclk =
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
(
entry->ucSclkHigh<< 16);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].mclk =
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
(
entry->ucMclkHigh<< 16);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
pm.dpm.dyn_state.phase_shedding_limits_table.entries[i].voltage =
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
(
ATOM_PPLIB_PhaseSheddingLimits_Record*)drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
sizeof(ATOM_PPLIB_PhaseSheddingLimits_Record));drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 24 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
pm.dpm.dyn_state.phase_shedding_limits_table.count =
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
pplib5.ulTDPLimit);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
pplib5.ulNearTDPLimit);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
pm.dpm.near_tdp_limit;
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
pplib5.usTDPODLimit);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
le32_to_cpu(power_info->pplib5.ulSQRampingThreshold);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
pplib5.ulCACLeakage);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
pplib5.usLoadLineSlope);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
data_offset+971 lines not shown · raw message
Parts of this message are not shown here. View the raw message.
PATCH v3 8/17 drm/amd/pm: move pp_force_state_enabled member to amdgpu_pm structure
In reply to Evan QuanAs it lables an internal pm state and amdgpu_pm structure is the more proper place than amdgpu_device structure for it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/pm/amdgpu_pm.c | 6 +++--- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
@@ -950,7 +950,6 @@ struct amdgpu_device {/* powerplay */ struct amd_powerplay powerplay; -bool pp_force_state_enabled;/* smu */ struct smu_context smu;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3 -3
@@ -469,7 +469,7 @@ static ssize_t amdgpu_get_pp_force_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; -if (adev->pp_force_state_enabled) +if (adev->pm.pp_force_state_enabled)return amdgpu_get_pp_cur_state (dev, attr, buf);else return sysfs_emit (buf,"\n" );
@@ -492,7 +492,7 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - adev->pp_force_state_enabled = false; + adev->pm.pp_force_state_enabled = false;if (strlen (buf) ==1 )return count;
@@ -523,7 +523,7 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev,if (ret) goto err_out; - adev->pp_force_state_enabled = true; + adev->pm.pp_force_state_enabled = true; }pm_runtime_mark_last_busy (ddev->dev);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2 -0
@@ -335,6 +335,8 @@ struct amdgpu_pm {struct list_head pm_attr_list;atomic_t pwr_state[AMD_IP_BLOCK_TYPE_NUM ]; + +bool pp_force_state_enabled; };#define R600_SSTU_DFLT 0
Signature · 1 line
2.29.0
PATCH v3 9/17 drm/amd/pm: optimize the amdgpu_pm_compute_clocks() implementations
In reply to Evan QuanDrop cross callings and multi-function APIs. Also avoid exposing internal implementations details.
--- .../gpu/drm/amd/include/kgd_pp_interface.h | 2 +- drivers/gpu/drm/amd/pm/Makefile | 2 +- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 222 +++--------------- drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c | 94 ++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 2 - .../gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h | 32 +++ .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 39 ++- drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c | 6 +- drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c | 60 ++++- drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h | 3 +- drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 41 +++- 11 files changed, 295 insertions(+), 208 deletions(-) create mode 100644 drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c create mode 100644 drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -1
@@ -404,7 +404,7 @@ struct amd_pm_funcs {int (*get_dpm_clock_table)(void *handle,struct dpm_clocks *clock_table);int (*get_smu_prv_buf_details)(void *handle,void **addr,size_t *size); -int (*change_power_state)(void *handle); +void (*pm_compute_clocks)(void *handle); };struct metrics_table_header {
drivers/gpu/drm/amd/pm/Makefile +1 -1
@@ -40,7 +40,7 @@ AMD_PM = $(addsuffix /Makefile,$(addprefix $(FULL_AMD_PATH)/pm/,$(PM_LIBS))) include $(AMD_PM) -PM_MGR = amdgpu_dpm.o amdgpu_pm.o +PM_MGR = amdgpu_dpm.o amdgpu_pm.o amdgpu_dpm_internal.o AMD_PM_POWER = $(addprefix $(AMD_PM_PATH)/,$(PM_MGR))
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +28 -194
270 lines not on this page · raw message
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +94 -0
94 lines not on this page · raw message
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -2
@@ -420,8 +420,6 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev);int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor,void *data,uint32_t *size); -void amdgpu_dpm_thermal_work_handler (struct work_struct *work); -void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev);void amdgpu_dpm_enable_uvd (struct amdgpu_device *adev,bool enable);void amdgpu_dpm_enable_vce (struct amdgpu_device *adev,bool enable);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ +#ifndef __AMDGPU_DPM_INTERNAL_H__ +#define __AMDGPU_DPM_INTERNAL_H__ + +void amdgpu_dpm_get_active_displays (struct amdgpu_device *adev); + +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev); + +u32 amdgpu_dpm_get_vrefresh (struct amdgpu_device *adev); + +#endif
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +38 -1
@@ -31,7 +31,8 @@#include "power_state.h" #include "amdgpu.h" #include "hwmgr.h" - +#include "amdgpu_dpm_internal.h" +#include "amdgpu_display.h" static const struct amd_pm_funcs pp_dpm_funcs;
@@ -1678,6 +1679,41 @@ static int pp_get_prv_buffer_details(void *handle, void **addr, size_t *size)return 0 ; } +static void pp_pm_compute_clocks (void *handle) +{ +struct pp_hwmgr *hwmgr = handle; +struct amdgpu_device *adev = hwmgr->adev; +int i =0 ; + +if (adev->mode_info.num_crtc) +amdgpu_display_bandwidth_update (adev); + +for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) { +struct amdgpu_ring *ring = adev->rings[i]; +if (ring && ring->sched.ready) +amdgpu_fence_wait_empty (ring); + } + +if (!amdgpu_device_has_dc_support (adev)) { +amdgpu_dpm_get_active_displays (adev); + adev->pm.pm_display_cfg.num_display = adev->pm.dpm.new_active_crtc_count; + adev->pm.pm_display_cfg.vrefresh =amdgpu_dpm_get_vrefresh (adev); + adev->pm.pm_display_cfg.min_vblank_time =amdgpu_dpm_get_vblank_time (adev); +/* we have issues with mclk switching with +* refresh rates over 120 hz on the non-DC code. +*/ +if (adev->pm.pm_display_cfg.vrefresh >120 ) + adev->pm.pm_display_cfg.min_vblank_time =0 ; + +pp_display_configuration_change (handle, + &adev->pm.pm_display_cfg); + } + +pp_dpm_dispatch_tasks (handle, +AMD_PP_TASK_DISPLAY_CONFIG_CHANGE , +NULL ); +} +static const struct amd_pm_funcs pp_dpm_funcs = { .load_firmware = pp_dpm_load_fw, .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete,
@@ -1742,4 +1778,5 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_gpu_metrics = pp_get_gpu_metrics, .gfx_state_change_set = pp_gfx_state_change_set, .get_smu_prv_buf_details = pp_get_prv_buffer_details, + .pm_compute_clocks = pp_pm_compute_clocks, };
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +3 -3
@@ -3088,7 +3088,7 @@ static int kv_dpm_hw_init(void *handle)else adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex); -amdgpu_dpm_compute_clocks (adev); +amdgpu_legacy_dpm_compute_clocks (adev);return ret; }
@@ -3136,7 +3136,7 @@ static int kv_dpm_resume(void *handle) adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex);if (adev->pm.dpm_enabled) -amdgpu_dpm_compute_clocks (adev); +amdgpu_legacy_dpm_compute_clocks (adev); }return 0 ; }
@@ -3390,7 +3390,7 @@ static const struct amd_pm_funcs kv_dpm_funcs = { .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, .read_sensor = &kv_dpm_read_sensor, - .change_power_state = amdgpu_dpm_change_power_state_locked, + .pm_compute_clocks = amdgpu_legacy_dpm_compute_clocks, };static const struct amdgpu_irq_src_funcs kv_dpm_irq_funcs = {
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c +58 -2
76 lines not on this page · raw message
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h +2 -1
@@ -32,6 +32,7 @@ int amdgpu_parse_extended_power_table(struct amdgpu_device *adev);void amdgpu_free_extended_power_table (struct amdgpu_device *adev);void amdgpu_add_thermal_controller (struct amdgpu_device *adev);struct amd_vce_state *amdgpu_get_vce_clock_state (void *handle,u32 idx); -int amdgpu_dpm_change_power_state_locked (void *handle);void amdgpu_pm_print_power_states (struct amdgpu_device *adev); +void amdgpu_legacy_dpm_compute_clocks (void *handle); +void amdgpu_dpm_thermal_work_handler (struct work_struct *work);#endif
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +38 -3
71 lines not on this page · raw message
Signature · 1 line
2.29.0
Re: [PATCH V3 09/17] drm/amd/pm: optimize the amdgpu_pm_compute_clocks() implementations
Quoted 158 lines · Evan Quan
Drop cross callings and multi-function APIs. Also avoid exposing internal implementations details.
Signed-off-by Evan Quan <[email protected]>Change-Id I55e5ab3da6a70482f5f5d8c256eed2f754feae20--- .../gpu/drm/amd/include/kgd_pp_interface.h | 2 +- drivers/gpu/drm/amd/pm/Makefile | 2 +- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 222 +++--------------- drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c | 94 ++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 2 - .../gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h | 32 +++ .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 39 ++- drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c | 6 +- drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c | 60 ++++- drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h | 3 +- drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 41 +++- 11 files changed, 295 insertions(+), 208 deletions(-)create mode 100644
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.ccreate mode 100644drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.hdrivers/gpu/drm/amd/include/kgd_pp_interface.h +1
-1@@ -404,7 +404,7 @@ struct amd_pm_funcs {int (*get_dpm_clock_table)(void *handle,struct dpm_clocks *clock_table);int (*get_smu_prv_buf_details)(void *handle,void **addr,size_t *size); -int (*change_power_state)(void *handle); +void (*pm_compute_clocks)(void *handle); };struct metrics_table_header {drivers/gpu/drm/amd/pm/Makefile +1
-1@@ -40,7 +40,7 @@ AMD_PM = $(addsuffix /Makefile,$(addprefix $(FULL_AMD_PATH)/pm/,$(PM_LIBS))) include $(AMD_PM) -PM_MGR = amdgpu_dpm.o amdgpu_pm.o +PM_MGR = amdgpu_dpm.o amdgpu_pm.o amdgpu_dpm_internal.o AMD_PM_POWER = $(addprefix $(AMD_PM_PATH)/,$(PM_MGR))drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-96@@ -37,73 +37,6 @@#define amdgpu_dpm_enable_bapm (adev, e) \ ((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e))) -static void amdgpu_dpm_get_active_displays (struct amdgpu_device *adev) -{ -struct drm_device *ddev =adev_to_drm (adev); -struct drm_crtc *crtc; -struct amdgpu_crtc *amdgpu_crtc; - - adev->pm.dpm.new_active_crtcs =0 ; - adev->pm.dpm.new_active_crtc_count =0 ; -if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { -list_for_each_entry (crtc, - &ddev->mode_config.crtc_list, head) { - amdgpu_crtc =to_amdgpu_crtc (crtc); -if (amdgpu_crtc->enabled) { - adev->pm.dpm.new_active_crtcs |= (1 << amdgpu_crtc->crtc_id); - adev->pm.dpm.new_active_crtc_count++; - } - } - } -} - -u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev) -{ -struct drm_device *dev =adev_to_drm (adev); -struct drm_crtc *crtc; -struct amdgpu_crtc *amdgpu_crtc; -u32 vblank_in_pixels; -u32 vblank_time_us =0xffffffff ;/* if the displays are off, vblank time is max */ - -if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { -list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { - amdgpu_crtc =to_amdgpu_crtc (crtc); -if (crtc->enabled && amdgpu_crtc->enabled && amdgpu_crtc->hw_mode.clock) { - vblank_in_pixels = - amdgpu_crtc->hw_mode.crtc_htotal * - (amdgpu_crtc->hw_mode.crtc_vblank_end - - amdgpu_crtc->hw_mode.crtc_vdisplay + - (amdgpu_crtc->v_border *2 )); - - vblank_time_us = vblank_in_pixels *1000 / amdgpu_crtc->hw_mode.clock; -break ; - } - } - } - -return vblank_time_us; -} - -static u32 amdgpu_dpm_get_vrefresh (struct amdgpu_device *adev) -{ -struct drm_device *dev =adev_to_drm (adev); -struct drm_crtc *crtc; -struct amdgpu_crtc *amdgpu_crtc; -u32 vrefresh =0 ; - -if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { -list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { - amdgpu_crtc =to_amdgpu_crtc (crtc); -if (crtc->enabled && amdgpu_crtc->enabled && amdgpu_crtc->hw_mode.clock) { - vrefresh =drm_mode_vrefresh (&amdgpu_crtc->hw_mode); -break ; - } - } - } - -return vrefresh; -} -int amdgpu_dpm_get_sclk (struct amdgpu_device *adev,bool low) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;@@ -432,111 +365,35 @@ int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors sensoreturn ret; } -void amdgpu_dpm_thermal_work_handler (struct work_struct *work) -{ -struct amdgpu_device *adev = - container_of(work, struct amdgpu_device, - pm.dpm.thermal.work); -/* switch to the thermal state */ -enum amd_pm_state_type dpm_state =POWER_STATE_TYPE_INTERNAL_THERMAL ; -int temp, size =sizeof (temp); - -if (!adev->pm.dpm_enabled) -return ; - -if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_TEMP , - (void *)&temp, &size)) { -if (temp < adev->pm.dpm.thermal.min_temp) -/* switch back the user state */ - dpm_state = adev->pm.dpm.user_state; - }else { -if (adev->pm.dpm.thermal.high_to_low) -/* switch back the user state */ - dpm_state = adev->pm.dpm.user_state; - } -mutex_lock (&adev->pm.mutex); -if (dpm_state ==POWER_STATE_TYPE_INTERNAL_THERMAL ) - adev->pm.dpm.thermal_active = true; -else - adev->pm.dpm.thermal_active = false; - adev->pm.dpm.state = dpm_state; -mutex_unlock (&adev->pm.mutex);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso · line 472
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-6- -amdgpu_dpm_compute_clocks (adev); -} -void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev) { -int i =0 ; +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; -if (!adev->pm.dpm_enabled)
Isn't this needed? The callback implementations don't check this.
Quoted 90 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +16
-58+if (!pp_funcs->pm_compute_clocks)return ; -if (adev->mode_info.num_crtc) -amdgpu_display_bandwidth_update (adev); - -for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) { -struct amdgpu_ring *ring = adev->rings[i]; -if (ring && ring->sched.ready) -amdgpu_fence_wait_empty (ring); - } - -if ((adev->family ==AMDGPU_FAMILY_SI ) || - (adev->family ==AMDGPU_FAMILY_KV )) { -amdgpu_dpm_get_active_displays (adev); - adev->powerplay.pp_funcs->change_power_state (adev->powerplay.pp_handle); - }else { -if (!amdgpu_device_has_dc_support (adev)) { -amdgpu_dpm_get_active_displays (adev); - adev->pm.pm_display_cfg.num_display = adev->pm.dpm.new_active_crtc_count; - adev->pm.pm_display_cfg.vrefresh =amdgpu_dpm_get_vrefresh (adev); - adev->pm.pm_display_cfg.min_vblank_time =amdgpu_dpm_get_vblank_time (adev); -/* we have issues with mclk switching with -* refresh rates over 120 hz on the non-DC code. -*/ -if (adev->pm.pm_display_cfg.vrefresh >120 ) - adev->pm.pm_display_cfg.min_vblank_time =0 ; -if (adev->powerplay.pp_funcs->display_configuration_change) - adev->powerplay.pp_funcs->display_configuration_change ( - adev->powerplay.pp_handle, - &adev->pm.pm_display_cfg); - } -amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_DISPLAY_CONFIG_CHANGE ,NULL ); - } + pp_funcs->pm_compute_clocks (adev->powerplay.pp_handle); }void amdgpu_dpm_enable_uvd (struct amdgpu_device *adev,bool enable) {int ret =0 ; -if (adev->family ==AMDGPU_FAMILY_SI ) { -mutex_lock (&adev->pm.mutex); -if (enable) { - adev->pm.dpm.uvd_active = true; - adev->pm.dpm.state =POWER_STATE_TYPE_INTERNAL_UVD ; - }else { - adev->pm.dpm.uvd_active = false; - } -mutex_unlock (&adev->pm.mutex); + ret =amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_UVD , !enable); +if (ret) +DRM_ERROR ("Dpm %s uvd failed, ret = %d. \n" , + enable ?"enable" :"disable" , ret); -amdgpu_dpm_compute_clocks (adev); - }else { - ret =amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_UVD , !enable); -if (ret) -DRM_ERROR ("Dpm %s uvd failed, ret = %d. \n" , - enable ?"enable" :"disable" , ret); - -/* enable/disable Low Memory PState for UVD (4k videos) */ -if (adev->asic_type ==CHIP_STONEY && - adev->uvd.decode_image_width >=WIDTH_4K ) { -struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; - -if (hwmgr && hwmgr->hwmgr_func && - hwmgr->hwmgr_func->update_nbdpm_pstate) - hwmgr->hwmgr_func->update_nbdpm_pstate (hwmgr, - !enable, - true); - } +/* enable/disable Low Memory PState for UVD (4k videos) */ +if (adev->asic_type ==CHIP_STONEY && + adev->uvd.decode_image_width >=WIDTH_4K ) { +struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; + +if (hwmgr && hwmgr->hwmgr_func && + hwmgr->hwmgr_func->update_nbdpm_pstate) + hwmgr->hwmgr_func->update_nbdpm_pstate (hwmgr, + !enable, + true); } }@@ -544,24 +401,10 @@ void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable) {int ret =0 ;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable) · line 556
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-10-if (adev->family ==AMDGPU_FAMILY_SI ) { -mutex_lock (&adev->pm.mutex); -if (enable) { - adev->pm.dpm.vce_active = true; -/* XXX select vce level based on ring/task */ - adev->pm.dpm.vce_level =AMD_VCE_LEVEL_AC_ALL ; - }else { - adev->pm.dpm.vce_active = false; - } -mutex_unlock (&adev->pm.mutex);
This mutex lock is dropped when implementation is moved to callback.
Thanks,
Lijo
Quoted 480 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +11
-24- -amdgpu_dpm_compute_clocks (adev); - }else { - ret =amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_VCE , !enable); -if (ret) -DRM_ERROR ("Dpm %s vce failed, ret = %d. \n" , - enable ?"enable" :"disable" , ret); - } + ret =amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_VCE , !enable); +if (ret) +DRM_ERROR ("Dpm %s vce failed, ret = %d. \n" , + enable ?"enable" :"disable" , ret); }void amdgpu_dpm_enable_jpeg (struct amdgpu_device *adev,bool enable)@@ -723,10 +566,7 @@ void amdgpu_dpm_set_power_state(struct amdgpu_device *adev, { adev->pm.dpm.user_state = state; -if (adev->powerplay.pp_funcs->dispatch_tasks) -amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_ENABLE_USER_STATE , &state); -else -amdgpu_dpm_compute_clocks (adev); +amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_ENABLE_USER_STATE , &state); }enum amd_dpm_forced_level amdgpu_dpm_get_performance_level (struct amdgpu_device *adev)@@ -896,12 +736,9 @@ int amdgpu_dpm_set_sclk_od(struct amdgpu_device *adev, uint32_t value) pp_funcs->set_sclk_od (adev->powerplay.pp_handle, value); -if (amdgpu_dpm_dispatch_task (adev, -AMD_PP_TASK_READJUST_POWER_STATE , -NULL ) == -EOPNOTSUPP ) { - adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; -amdgpu_dpm_compute_clocks (adev); - } +amdgpu_dpm_dispatch_task (adev, +AMD_PP_TASK_READJUST_POWER_STATE , +NULL );return 0 ; }@@ -925,12 +762,9 @@ int amdgpu_dpm_set_mclk_od(struct amdgpu_device *adev, uint32_t value) pp_funcs->set_mclk_od (adev->powerplay.pp_handle, value); -if (amdgpu_dpm_dispatch_task (adev, -AMD_PP_TASK_READJUST_POWER_STATE , -NULL ) == -EOPNOTSUPP ) { - adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; -amdgpu_dpm_compute_clocks (adev); - } +amdgpu_dpm_dispatch_task (adev, +AMD_PP_TASK_READJUST_POWER_STATE , +NULL );return 0 ; }drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +94
-0@@ -0,0 +1,94 @@ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#include "amdgpu.h" +#include "amdgpu_display.h" +#include "hwmgr.h" +#include "amdgpu_smu.h" + +void amdgpu_dpm_get_active_displays (struct amdgpu_device *adev) +{ +struct drm_device *ddev =adev_to_drm (adev); +struct drm_crtc *crtc; +struct amdgpu_crtc *amdgpu_crtc; + + adev->pm.dpm.new_active_crtcs =0 ; + adev->pm.dpm.new_active_crtc_count =0 ; +if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { +list_for_each_entry (crtc, + &ddev->mode_config.crtc_list, head) { + amdgpu_crtc =to_amdgpu_crtc (crtc); +if (amdgpu_crtc->enabled) { + adev->pm.dpm.new_active_crtcs |= (1 << amdgpu_crtc->crtc_id); + adev->pm.dpm.new_active_crtc_count++; + } + } + } +} + +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev) +{ +struct drm_device *dev =adev_to_drm (adev); +struct drm_crtc *crtc; +struct amdgpu_crtc *amdgpu_crtc; +u32 vblank_in_pixels; +u32 vblank_time_us =0xffffffff ;/* if the displays are off, vblank time is max */ + +if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { +list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { + amdgpu_crtc =to_amdgpu_crtc (crtc); +if (crtc->enabled && amdgpu_crtc->enabled && amdgpu_crtc->hw_mode.clock) { + vblank_in_pixels = + amdgpu_crtc->hw_mode.crtc_htotal * + (amdgpu_crtc->hw_mode.crtc_vblank_end - + amdgpu_crtc->hw_mode.crtc_vdisplay + + (amdgpu_crtc->v_border *2 )); + + vblank_time_us = vblank_in_pixels *1000 / amdgpu_crtc->hw_mode.clock; +break ; + } + } + } + +return vblank_time_us; +} + +u32 amdgpu_dpm_get_vrefresh (struct amdgpu_device *adev) +{ +struct drm_device *dev =adev_to_drm (adev); +struct drm_crtc *crtc; +struct amdgpu_crtc *amdgpu_crtc; +u32 vrefresh =0 ; + +if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { +list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { + amdgpu_crtc =to_amdgpu_crtc (crtc); +if (crtc->enabled && amdgpu_crtc->enabled && amdgpu_crtc->hw_mode.clock) { + vrefresh =drm_mode_vrefresh (&amdgpu_crtc->hw_mode); +break ; + } + } + } + +return vrefresh; +}drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-2@@ -420,8 +420,6 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev);int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor,void *data,uint32_t *size); -void amdgpu_dpm_thermal_work_handler (struct work_struct *work); -void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev);void amdgpu_dpm_enable_uvd (struct amdgpu_device *adev,bool enable);void amdgpu_dpm_enable_vce (struct amdgpu_device *adev,bool enable);drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h new file +32
-0@@ -0,0 +1,32 @@ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ +#ifndef __AMDGPU_DPM_INTERNAL_H__ +#define __AMDGPU_DPM_INTERNAL_H__ + +void amdgpu_dpm_get_active_displays (struct amdgpu_device *adev); + +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev); + +u32 amdgpu_dpm_get_vrefresh (struct amdgpu_device *adev); + +#endif drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +38
-1@@ -31,7 +31,8 @@#include "power_state.h" #include "amdgpu.h" #include "hwmgr.h" - +#include "amdgpu_dpm_internal.h" +#include "amdgpu_display.h" static const struct amd_pm_funcs pp_dpm_funcs;@@ -1678,6 +1679,41 @@ static int pp_get_prv_buffer_details(void *handle, void **addr, size_t *size)return 0 ; } +static void pp_pm_compute_clocks (void *handle) +{ +struct pp_hwmgr *hwmgr = handle; +struct amdgpu_device *adev = hwmgr->adev; +int i =0 ; + +if (adev->mode_info.num_crtc) +amdgpu_display_bandwidth_update (adev); + +for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) { +struct amdgpu_ring *ring = adev->rings[i]; +if (ring && ring->sched.ready) +amdgpu_fence_wait_empty (ring); + } + +if (!amdgpu_device_has_dc_support (adev)) { +amdgpu_dpm_get_active_displays (adev); + adev->pm.pm_display_cfg.num_display = adev->pm.dpm.new_active_crtc_count; + adev->pm.pm_display_cfg.vrefresh =amdgpu_dpm_get_vrefresh (adev); + adev->pm.pm_display_cfg.min_vblank_time =amdgpu_dpm_get_vblank_time (adev); +/* we have issues with mclk switching with +* refresh rates over 120 hz on the non-DC code. +*/ +if (adev->pm.pm_display_cfg.vrefresh >120 ) + adev->pm.pm_display_cfg.min_vblank_time =0 ; + +pp_display_configuration_change (handle, + &adev->pm.pm_display_cfg); + } + +pp_dpm_dispatch_tasks (handle, +AMD_PP_TASK_DISPLAY_CONFIG_CHANGE , +NULL ); +} +static const struct amd_pm_funcs pp_dpm_funcs = { .load_firmware = pp_dpm_load_fw, .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete,@@ -1742,4 +1778,5 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_gpu_metrics = pp_get_gpu_metrics, .gfx_state_change_set = pp_gfx_state_change_set, .get_smu_prv_buf_details = pp_get_prv_buffer_details, + .pm_compute_clocks = pp_pm_compute_clocks, };drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +3
-3@@ -3088,7 +3088,7 @@ static int kv_dpm_hw_init(void *handle)else adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex); -amdgpu_dpm_compute_clocks (adev); +amdgpu_legacy_dpm_compute_clocks (adev);return ret; }@@ -3136,7 +3136,7 @@ static int kv_dpm_resume(void *handle) adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex);if (adev->pm.dpm_enabled) -amdgpu_dpm_compute_clocks (adev); +amdgpu_legacy_dpm_compute_clocks (adev); }return 0 ; }@@ -3390,7 +3390,7 @@ static const struct amd_pm_funcs kv_dpm_funcs = { .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, .read_sensor = &kv_dpm_read_sensor, - .change_power_state = amdgpu_dpm_change_power_state_locked, + .pm_compute_clocks = amdgpu_legacy_dpm_compute_clocks, };static const struct amdgpu_irq_src_funcs kv_dpm_irq_funcs = {drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c +58
-2@@ -26,6 +26,8 @@#include "atom.h" #include "amd_pcie.h" #include "legacy_dpm.h" +#include "amdgpu_dpm_internal.h" +#include "amdgpu_display.h" #define amdgpu_dpm_pre_set_power_state (adev) \ ((adev)->powerplay.pp_funcs->pre_set_power_state((adev)->powerplay.pp_handle))@@ -949,9 +951,8 @@ static struct amdgpu_ps *amdgpu_dpm_pick_power_state(struct amdgpu_device *adev,return NULL ; } -int amdgpu_dpm_change_power_state_locked (void *handle) +static int amdgpu_dpm_change_power_state_locked (struct amdgpu_device *adev) { -struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ps *ps;enum amd_pm_state_type dpm_state;int ret;@@ -1022,3 +1023,58 @@ int amdgpu_dpm_change_power_state_locked(void *handle)return 0 ; } + +void amdgpu_legacy_dpm_compute_clocks (void *handle) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +int i =0 ; + +if (adev->mode_info.num_crtc) +amdgpu_display_bandwidth_update (adev); + +for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) { +struct amdgpu_ring *ring = adev->rings[i]; +if (ring && ring->sched.ready) +amdgpu_fence_wait_empty (ring); + } + +amdgpu_dpm_get_active_displays (adev); + +amdgpu_dpm_change_power_state_locked (adev); +} + +void amdgpu_dpm_thermal_work_handler (struct work_struct *work) +{ +struct amdgpu_device *adev = + container_of(work, struct amdgpu_device, + pm.dpm.thermal.work); +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +/* switch to the thermal state */ +enum amd_pm_state_type dpm_state =POWER_STATE_TYPE_INTERNAL_THERMAL ; +int temp, size =sizeof (temp); + +if (!adev->pm.dpm_enabled) +return ; + +if (!pp_funcs->read_sensor (adev->powerplay.pp_handle, +AMDGPU_PP_SENSOR_GPU_TEMP , + (void *)&temp, + &size)) { +if (temp < adev->pm.dpm.thermal.min_temp) +/* switch back the user state */ + dpm_state = adev->pm.dpm.user_state; + }else { +if (adev->pm.dpm.thermal.high_to_low) +/* switch back the user state */ + dpm_state = adev->pm.dpm.user_state; + } + +if (dpm_state ==POWER_STATE_TYPE_INTERNAL_THERMAL ) + adev->pm.dpm.thermal_active = true; +else + adev->pm.dpm.thermal_active = false; + + adev->pm.dpm.state = dpm_state; + +amdgpu_legacy_dpm_compute_clocks (adev->powerplay.pp_handle); +}drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h +2
-1@@ -32,6 +32,7 @@ int amdgpu_parse_extended_power_table(struct amdgpu_device *adev);void amdgpu_free_extended_power_table (struct amdgpu_device *adev);void amdgpu_add_thermal_controller (struct amdgpu_device *adev);struct amd_vce_state *amdgpu_get_vce_clock_state (void *handle,u32 idx); -int amdgpu_dpm_change_power_state_locked (void *handle);void amdgpu_pm_print_power_states (struct amdgpu_device *adev); +void amdgpu_legacy_dpm_compute_clocks (void *handle); +void amdgpu_dpm_thermal_work_handler (struct work_struct *work);#endif drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +38
-3@@ -3891,6 +3891,40 @@ static int si_set_boot_state(struct amdgpu_device *adev) }#endif +static int si_set_powergating_by_smu (void *handle, +uint32_t block_type, +bool gate) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +switch (block_type) { +case AMD_IP_BLOCK_TYPE_UVD : +if (!gate) { + adev->pm.dpm.uvd_active = true; + adev->pm.dpm.state =POWER_STATE_TYPE_INTERNAL_UVD ; + }else { + adev->pm.dpm.uvd_active = false; + } + +amdgpu_legacy_dpm_compute_clocks (handle); +break ; +case AMD_IP_BLOCK_TYPE_VCE : +if (!gate) { + adev->pm.dpm.vce_active = true; +/* XXX select vce level based on ring/task */ + adev->pm.dpm.vce_level =AMD_VCE_LEVEL_AC_ALL ; + }else { + adev->pm.dpm.vce_active = false; + } + +amdgpu_legacy_dpm_compute_clocks (handle); +break ; +default : +break ; + } +return 0 ; +} +static int si_set_sw_state (struct amdgpu_device *adev) { return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_SwitchToSwState) == PPSMC_Result_OK) ?@@ -7801,7 +7835,7 @@ static int si_dpm_hw_init(void *handle)else adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex); -amdgpu_dpm_compute_clocks (adev); +amdgpu_legacy_dpm_compute_clocks (adev);return ret; }@@ -7849,7 +7883,7 @@ static int si_dpm_resume(void *handle) adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex);if (adev->pm.dpm_enabled) -amdgpu_dpm_compute_clocks (adev); +amdgpu_legacy_dpm_compute_clocks (adev); }return 0 ; }@@ -8094,6 +8128,7 @@ static const struct amd_pm_funcs si_dpm_funcs = { .print_power_state = &si_dpm_print_power_state, .debugfs_print_current_performance_level = &si_dpm_debugfs_print_current_performance_level, .force_performance_level = &si_dpm_force_performance_level, + .set_powergating_by_smu = &si_set_powergating_by_smu, .vblank_too_short = &si_dpm_vblank_too_short, .set_fan_control_mode = &si_dpm_set_fan_control_mode, .get_fan_control_mode = &si_dpm_get_fan_control_mode,@@ -8102,7 +8137,7 @@ static const struct amd_pm_funcs si_dpm_funcs = { .check_state_equal = &si_check_state_equal, .get_vce_clock_state = amdgpu_get_vce_clock_state, .read_sensor = &si_dpm_read_sensor, - .change_power_state = amdgpu_dpm_change_power_state_locked, + .pm_compute_clocks = amdgpu_legacy_dpm_compute_clocks, };static const struct amdgpu_irq_src_funcs si_dpm_irq_funcs = {
RE: [PATCH V3 09/17] drm/amd/pm: optimize the amdgpu_pm_compute_clocks() implementations
[AMD Official Use Only]
Quoted 203 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, December 2, 2021 10:45 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH V3 09/17] drm/amd/pm: optimize theamdgpu_pm_compute_clocks()implementationsQuoted 18 lines · Evan Quan
Drop cross callings and multi-function APIs. Also avoid exposing internal implementations details.
Signed-off-by Evan Quan <[email protected]>Change-Id I55e5ab3da6a70482f5f5d8c256eed2f754feae20--- .../gpu/drm/amd/include/kgd_pp_interface.h | 2 +- drivers/gpu/drm/amd/pm/Makefile | 2 +- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 222 +++--------------- drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c | 94 ++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 2 - .../gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h | 32 +++ .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 39 ++- drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c | 6 +- drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c | 60 ++++- drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h | 3 +- drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 41 +++- 11 files changed, 295 insertions(+), 208 deletions(-)Quoted 2 lines
create mode 100644
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.ccreate mode 100644
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.hdrivers/gpu/drm/amd/include/kgd_pp_interface.h struct amd_pm_funcs { · line 406
Quoted 10 lines
drivers/gpu/drm/amd/include/kgd_pp_interface.h +0
-0@@ -404,7 +404,7 @@ struct amd_pm_funcs {int (*get_dpm_clock_table)(void *handle,struct dpm_clocks *clock_table); int (*get_smu_prv_buf_details)(void *handle, void **addr, size_t*size);
Quoted 42 lines
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1
-1-int (*change_power_state)(void *handle); +void (*pm_compute_clocks)(void *handle); };struct metrics_table_header {(quoted diff) +0
-0b/drivers/gpu/drm/amd/pm/Makefile index
8cf6eff1ea93..d35ffde387f1100644drivers/gpu/drm/amd/pm/Makefile +1
-1@@ -40,7 +40,7 @@ AMD_PM = $(addsuffix /Makefile,$(addprefix $(FULL_AMD_PATH)/pm/,$(PM_LIBS))) include $(AMD_PM) -PM_MGR = amdgpu_dpm.o amdgpu_pm.o +PM_MGR = amdgpu_dpm.o amdgpu_pm.o amdgpu_dpm_internal.o AMD_PM_POWER = $(addprefix $(AMD_PM_PATH)/,$(PM_MGR))drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -37,73 +37,6 @@#define amdgpu_dpm_enable_bapm (adev, e) \((adev)->powerplay.pp_funcs->enable_bapm((adev)-
powerplay.pp_handle,
(e)))-static void
amdgpu_dpm_get_active_displays(struct amdgpu_device *adev)-{drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-7-struct drm_device *ddev =adev_to_drm (adev); -struct drm_crtc *crtc; -struct amdgpu_crtc *amdgpu_crtc; - - adev->pm.dpm.new_active_crtcs =0 ; - adev->pm.dpm.new_active_crtc_count =0 ; - if (adev->mode_info.num_crtc && adev-mode_info.mode_config_initialized) {
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5-list_for_each_entry (crtc, - &ddev->mode_config.crtc_list, head) { - amdgpu_crtc =to_amdgpu_crtc (crtc); -if (amdgpu_crtc->enabled) { - adev->pm.dpm.new_active_crtcs |= (1 <<
amdgpu_crtc->crtc_id);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 12 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-12- adev->pm.dpm.new_active_crtc_count++; - } - } - } -} - -u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev) -{ -struct drm_device *dev =adev_to_drm (adev); -struct drm_crtc *crtc; -struct amdgpu_crtc *amdgpu_crtc; -u32 vblank_in_pixels; -u32 vblank_time_us =0xffffffff ;/* if the displays are off, vblank time is max */
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- - if (adev->mode_info.num_crtc && adev-mode_info.mode_config_initialized) {
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1-list_for_each_entry (crtc, &dev->mode_config.crtc_list, head){
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- amdgpu_crtc =to_amdgpu_crtc (crtc); - if (crtc->enabled && amdgpu_crtc->enabled &&
amdgpu_crtc->hw_mode.clock) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- vblank_in_pixels = - amdgpu_crtc->hw_mode.crtc_htotal*
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- (amdgpu_crtc-hw_mode.crtc_vblank_end -
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- amdgpu_crtc-hw_mode.crtc_vdisplay +
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-3- (amdgpu_crtc->v_border * 2)); - - vblank_time_us = vblank_in_pixels * 1000 /
amdgpu_crtc->hw_mode.clock;Quoted 16 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-15-break ; - } - } - } - -return vblank_time_us; -} - -static u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev) -{ - struct drm_device *dev = adev_to_drm(adev); - struct drm_crtc *crtc; - struct amdgpu_crtc *amdgpu_crtc; - u32 vrefresh = 0; - - if (adev->mode_info.num_crtc && adev-mode_info.mode_config_initialized) {
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1-list_for_each_entry (crtc, &dev->mode_config.crtc_list, head){
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- amdgpu_crtc =to_amdgpu_crtc (crtc); - if (crtc->enabled && amdgpu_crtc->enabled &&
amdgpu_crtc->hw_mode.clock) {drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- vrefresh =
drm_mode_vrefresh(&amdgpu_crtc->hw_mode);drivers/gpu/drm/amd/pm/amdgpu_dpm.c line 42
Quoted 11 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-8-break ; - } - } - } - -return vrefresh; -} -int amdgpu_dpm_get_sclk (struct amdgpu_device *adev,bool low) {const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;@@
Quoted 1 line
-432,111 +365,35 @@ int amdgpu_dpm_read_sensor(struct
amdgpu_device*adev, enumamd_pp_sensorssensodrivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
Quoted 9 lines
return ret; }drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-6-void amdgpu_dpm_thermal_work_handler(struct work_struct *work) -{ -struct amdgpu_device *adev = - container_of(work, struct amdgpu_device, - pm.dpm.thermal.work); -/* switch to the thermal state */ - enum amd_pm_state_type dpm_state =
POWER_STATE_TYPE_INTERNAL_THERMAL;drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-6-int temp, size =sizeof (temp); - -if (!adev->pm.dpm_enabled) -return ; - - if (!amdgpu_dpm_read_sensor(adev,
AMDGPU_PP_SENSOR_GPU_TEMP,Quoted 25 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-21- (void *)&temp, &size)) { - if (temp < adev->pm.dpm.thermal.min_temp) - /* switch back the user state */ - dpm_state = adev->pm.dpm.user_state; - } else { -if (adev->pm.dpm.thermal.high_to_low) -/* switch back the user state */ - dpm_state = adev->pm.dpm.user_state; - } -mutex_lock (&adev->pm.mutex); -if (dpm_state ==POWER_STATE_TYPE_INTERNAL_THERMAL ) - adev->pm.dpm.thermal_active = true; -else - adev->pm.dpm.thermal_active = false; - adev->pm.dpm.state = dpm_state; -mutex_unlock (&adev->pm.mutex); - -amdgpu_dpm_compute_clocks (adev); -} -void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev) { -int i =0 ; +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1-if (!adev->pm.dpm_enabled)Isn't this needed? The callback implementations don't check this.
[Quan, Evan] Thanks! Will add this back.
Quoted 117 lines
Quoted 24 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-13+if (!pp_funcs->pm_compute_clocks)return ; -if (adev->mode_info.num_crtc) -amdgpu_display_bandwidth_update (adev); - -for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) { -struct amdgpu_ring *ring = adev->rings[i]; -if (ring && ring->sched.ready) -amdgpu_fence_wait_empty (ring); - } - -if ((adev->family ==AMDGPU_FAMILY_SI ) || - (adev->family ==AMDGPU_FAMILY_KV )) { -amdgpu_dpm_get_active_displays (adev); - adev->powerplay.pp_funcs->change_power_state(adev-powerplay.pp_handle);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4- }else { -if (!amdgpu_device_has_dc_support (adev)) { -amdgpu_dpm_get_active_displays (adev); - adev->pm.pm_display_cfg.num_display = adev-pm.dpm.new_active_crtc_count;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.pm_display_cfg.vrefresh =
amdgpu_dpm_get_vrefresh(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->pm.pm_display_cfg.min_vblank_time =
amdgpu_dpm_get_vblank_time(adev);drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5-/* we have issues with mclk switching with -* refresh rates over 120 hz on the non-DC code. -*/ -if (adev->pm.pm_display_cfg.vrefresh >120 ) - adev->pm.pm_display_cfg.min_vblank_time= 0;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- if (adev->powerplay.pp_funcs-
display_configuration_change)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev->powerplay.pp_funcs-display_configuration_change(
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- adev-powerplay.pp_handle,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-1- &adev-pm.pm_display_cfg);
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2- } - amdgpu_dpm_dispatch_task(adev,
AMD_PP_TASK_DISPLAY_CONFIG_CHANGE, NULL);drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1- } + pp_funcs->pm_compute_clocks (adev->powerplay.pp_handle); } void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, boolenable)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
Quoted 8 lines
{ int ret = 0;drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-5-if (adev->family ==AMDGPU_FAMILY_SI ) { -mutex_lock (&adev->pm.mutex); -if (enable) { - adev->pm.dpm.uvd_active = true; - adev->pm.dpm.state =
POWER_STATE_TYPE_INTERNAL_UVD;drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-4- }else { - adev->pm.dpm.uvd_active = false; - } -mutex_unlock (&adev->pm.mutex); + ret = amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_UVD, !enable);drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-3+if (ret) +DRM_ERROR ("Dpm %s uvd failed, ret = %d. \n" , + enable ?"enable" :"disable" , ret); -amdgpu_dpm_compute_clocks (adev); - }else { - ret = amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_UVD, !enable);drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_vce(struct
Quoted 32 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-8-if (ret) -DRM_ERROR ("Dpm %s uvd failed, ret = %d. \n" , - enable ?"enable" :"disable" , ret); - -/* enable/disable Low Memory PState for UVD (4k videos) */ -if (adev->asic_type ==CHIP_STONEY && - adev->uvd.decode_image_width >=WIDTH_4K ) { - struct pp_hwmgr *hwmgr = adev-powerplay.pp_handle;
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4- -if (hwmgr && hwmgr->hwmgr_func && - hwmgr->hwmgr_func->update_nbdpm_pstate) - hwmgr->hwmgr_func-update_nbdpm_pstate(hwmgr,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +8
-3- !enable, - true); - } +/* enable/disable Low Memory PState for UVD (4k videos) */ +if (adev->asic_type ==CHIP_STONEY && + adev->uvd.decode_image_width >=WIDTH_4K ) { +struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; + +if (hwmgr && hwmgr->hwmgr_func && + hwmgr->hwmgr_func->update_nbdpm_pstate) + hwmgr->hwmgr_func-update_nbdpm_pstate(hwmgr,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2
-0+ !enable, + true); } }@@ -544,24 +401,10 @@ void amdgpu_dpm_enable_vce(struct
amdgpu_device*adev, bool enable)drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable)
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-6{int ret =0 ; -if (adev->family ==AMDGPU_FAMILY_SI ) { -mutex_lock (&adev->pm.mutex); -if (enable) { - adev->pm.dpm.vce_active = true; -/* XXX select vce level based on ring/task */ - adev->pm.dpm.vce_level =
AMD_VCE_LEVEL_AC_ALL;
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable) · line 556
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4- }else { - adev->pm.dpm.vce_active = false; - } -mutex_unlock (&adev->pm.mutex);This mutex lock is dropped when implementation is moved to callback.
[Quan, Evan] This should not be a problem. Since these piece of code was replaced by amdgpu_dpm_set_powergating_by_smu() and the lock protections exist there.
BR
Evan
Quoted 569 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-4- -amdgpu_dpm_compute_clocks (adev); - }else { - ret = amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_VCE, !enable);drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable)
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-4-if (ret) -DRM_ERROR ("Dpm %s vce failed, ret = %d. \n" , - enable ?"enable" :"disable" , ret); - } + ret = amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_VCE, !enable);drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable)
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-0+if (ret) +DRM_ERROR ("Dpm %s vce failed, ret = %d. \n" , + enable ?"enable" :"disable" , ret); } void amdgpu_dpm_enable_jpeg(struct amdgpu_device *adev, boolenable)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_set_power_state(struct
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -723,10 +566,7 @@ void amdgpu_dpm_set_power_state(struct
amdgpu_device*adev,drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_set_power_state(struct amdgpu_device *adev,
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-2{ adev->pm.dpm.user_state = state; -if (adev->powerplay.pp_funcs->dispatch_tasks) - amdgpu_dpm_dispatch_task(adev,
AMD_PP_TASK_ENABLE_USER_STATE, &state);drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-2-else -amdgpu_dpm_compute_clocks (adev); + amdgpu_dpm_dispatch_task(adev,
AMD_PP_TASK_ENABLE_USER_STATE,drivers/gpu/drm/amd/pm/amdgpu_dpm.c void amdgpu_dpm_set_power_state(struct
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-0+&state); }enum amd_dpm_forced_level amdgpu_dpm_get_performance_level(struct
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_set_mclk_od(struct
Quoted 18 lines
amdgpu_device*adev) @@ -896,12 +736,9 @@ intamdgpu_dpm_set_sclk_od(struct amdgpu_device *adev, uint32_t value)pp_funcs->set_sclk_od(adev->powerplay.pp_handle, value);drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-6-if (amdgpu_dpm_dispatch_task (adev, -AMD_PP_TASK_READJUST_POWER_STATE , -NULL ) == -EOPNOTSUPP ) { - adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; -amdgpu_dpm_compute_clocks (adev); - } +amdgpu_dpm_dispatch_task (adev, +AMD_PP_TASK_READJUST_POWER_STATE , +NULL );return 0 ; }@@ -925,12 +762,9 @@ int amdgpu_dpm_set_mclk_od(struct
amdgpu_deviceQuoted 33 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3
-6*adev, uint32_t value) pp_funcs->set_mclk_od (adev->powerplay.pp_handle, value); -if (amdgpu_dpm_dispatch_task (adev, -AMD_PP_TASK_READJUST_POWER_STATE , -NULL ) == -EOPNOTSUPP ) { - adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; -amdgpu_dpm_compute_clocks (adev); - } +amdgpu_dpm_dispatch_task (adev, +AMD_PP_TASK_READJUST_POWER_STATE , +NULL );return 0 ;}drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +10
-0@@ -0,0 +1,94 @@ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c line 20
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +10
-0+sublicense, + * and/or sell copies of the Software, and to permit persons to whom +the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be +included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANYKIND,
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c line 24
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INNO EVENT
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c line 30
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +6
-0+SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE ORTHE USE
Quoted 19 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +18
-0+OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#include "amdgpu.h" +#include "amdgpu_display.h" +#include "hwmgr.h" +#include "amdgpu_smu.h" + +void amdgpu_dpm_get_active_displays(struct amdgpu_device *adev) { + struct drm_device *ddev = adev_to_drm(adev); + struct drm_crtc *crtc; + struct amdgpu_crtc *amdgpu_crtc; + + adev->pm.dpm.new_active_crtcs = 0; + adev->pm.dpm.new_active_crtc_count = 0; + if (adev->mode_info.num_crtc && adev-mode_info.mode_config_initialized) {
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +5
-0+list_for_each_entry (crtc, + &ddev->mode_config.crtc_list, head) { + amdgpu_crtc =to_amdgpu_crtc (crtc); +if (amdgpu_crtc->enabled) { + adev->pm.dpm.new_active_crtcs |= (1 <<
amdgpu_crtc->crtc_id);Quoted 16 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +15
-0+ adev->pm.dpm.new_active_crtc_count++; + } + } + } +} + +u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev) { + struct drm_device *dev = adev_to_drm(adev); + struct drm_crtc *crtc; + struct amdgpu_crtc *amdgpu_crtc; + u32 vblank_in_pixels; + u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank +time is max */ + + if (adev->mode_info.num_crtc && adev-mode_info.mode_config_initialized) {
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +1
-0+list_for_each_entry (crtc, &dev->mode_config.crtc_list, head){
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +2
-0+ amdgpu_crtc =to_amdgpu_crtc (crtc); + if (crtc->enabled && amdgpu_crtc->enabled &&
amdgpu_crtc->hw_mode.clock) {drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +2
-0+ vblank_in_pixels = + amdgpu_crtc->hw_mode.crtc_htotal*
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c
Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +1
-0+ (amdgpu_crtc-hw_mode.crtc_vblank_end -
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +1
-0+ amdgpu_crtc-hw_mode.crtc_vdisplay +
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +3
-0+ (amdgpu_crtc->v_border * 2)); + + vblank_time_us = vblank_in_pixels * 1000 /
amdgpu_crtc->hw_mode.clock;Quoted 16 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +15
-0+break ; + } + } + } + +return vblank_time_us; +} + +u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev) { + struct drm_device *dev = adev_to_drm(adev); + struct drm_crtc *crtc; + struct amdgpu_crtc *amdgpu_crtc; + u32 vrefresh = 0; + + if (adev->mode_info.num_crtc && adev-mode_info.mode_config_initialized) {
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +1
-0+list_for_each_entry (crtc, &dev->mode_config.crtc_list, head){
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +2
-0+ amdgpu_crtc =to_amdgpu_crtc (crtc); + if (crtc->enabled && amdgpu_crtc->enabled &&
amdgpu_crtc->hw_mode.clock) {drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c
Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +1
-0+ vrefresh =
drm_mode_vrefresh(&amdgpu_crtc->hw_mode);drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_pm_acpi_event_handler(struct
Quoted 13 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c new file +7
-0+break ; + } + } + } + +return vrefresh; +}drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0@@ -420,8 +420,6 @@ void amdgpu_pm_acpi_event_handler(struct
amdgpu_device*adev);drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_pm_acpi_event_handler(struct · line 420
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum
amd_pp_sensorssensor,drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev);
Quoted 6 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-2void *data, uint32_t *size); -void amdgpu_dpm_thermal_work_handler (struct work_struct *work); -void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev); void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, boolenable);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h void amdgpu_pm_acpi_event_handler(struct · line 425
Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, boolenable);
Quoted 17 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h new file +10
-0@@ -0,0 +1,32 @@ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h line 20
Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h new file +10
-0+sublicense, + * and/or sell copies of the Software, and to permit persons to whom +the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be +included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANYKIND,
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h line 24
Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INNO EVENT
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h line 30
Quoted 6 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h new file +6
-0+SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE ORTHE USE
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_get_prv_buffer_details(void
Quoted 30 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm_internal.h new file +14
-0+OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ +#ifndef __AMDGPU_DPM_INTERNAL_H__ +#define __AMDGPU_DPM_INTERNAL_H__ + +void amdgpu_dpm_get_active_displays (struct amdgpu_device *adev); + +u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev); + +u32 amdgpu_dpm_get_vrefresh (struct amdgpu_device *adev); + +#endif drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2
-1@@ -31,7 +31,8 @@#include "power_state.h" #include "amdgpu.h" #include "hwmgr.h" - +#include "amdgpu_dpm_internal.h" +#include "amdgpu_display.h" static const struct amd_pm_funcs pp_dpm_funcs;@@ -1678,6 +1679,41 @@ static int pp_get_prv_buffer_details(void*handle, void **addr,
size_t*size)Quoted 12 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +9
-0return 0 ; } +static void pp_pm_compute_clocks (void *handle) { +struct pp_hwmgr *hwmgr = handle; +struct amdgpu_device *adev = hwmgr->adev; +int i =0 ; + +if (adev->mode_info.num_crtc) +amdgpu_display_bandwidth_update (adev); + +for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) {drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_get_prv_buffer_details(void *handle, void **addr, size_t *size)
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +9
-0+struct amdgpu_ring *ring = adev->rings[i]; +if (ring && ring->sched.ready) +amdgpu_fence_wait_empty (ring); + } + +if (!amdgpu_device_has_dc_support (adev)) { +amdgpu_dpm_get_active_displays (adev); + adev->pm.pm_display_cfg.num_display = adev- pm.dpm.new_active_crtc_count; + adev->pm.pm_display_cfg.vrefresh =
amdgpu_dpm_get_vrefresh(adev);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_get_prv_buffer_details(void · line 1701
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-0+ adev->pm.pm_display_cfg.min_vblank_time =
amdgpu_dpm_get_vblank_time(adev);Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +8
-0+/* we have issues with mclk switching with +* refresh rates over 120 hz on the non-DC code. +*/ +if (adev->pm.pm_display_cfg.vrefresh >120 ) + adev->pm.pm_display_cfg.min_vblank_time =0 ; + +pp_display_configuration_change (handle, + &adev->pm.pm_display_cfg);drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_get_prv_buffer_details(void *handle, void **addr, size_t *size) · line 1719
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +7
-0+ } + +pp_dpm_dispatch_tasks (handle, +AMD_PP_TASK_DISPLAY_CONFIG_CHANGE , +NULL ); +} +static const struct amd_pm_funcs pp_dpm_funcs = { .load_firmware = pp_dpm_load_fw, .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete,@@
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static const struct amd_pm_funcs kv_dpm_funcs
Quoted 30 lines
-1742,4 +1778,5 @@ static const struct
amd_pm_funcspp_dpm_funcs= {
.get_gpu_metrics =pp_get_gpu_metrics, .gfx_state_change_set =pp_gfx_state_change_set, .get_smu_prv_buf_details =pp_get_prv_buffer_details,drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +1
-0+ .pm_compute_clocks = pp_pm_compute_clocks, };drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +2
-2@@ -3088,7 +3088,7 @@ static int kv_dpm_hw_init(void *handle)else adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex); -amdgpu_dpm_compute_clocks (adev); +amdgpu_legacy_dpm_compute_clocks (adev);return ret; }@@ -3136,7 +3136,7 @@ static int kv_dpm_resume(void *handle) adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex);if (adev->pm.dpm_enabled) -amdgpu_dpm_compute_clocks (adev); +amdgpu_legacy_dpm_compute_clocks (adev); }return 0 ; }@@ -3390,7 +3390,7 @@ static const struct amd_pm_funcs kv_dpm_funcs= {
Quoted 29 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1
-2.get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, .read_sensor = &kv_dpm_read_sensor, - .change_power_state = amdgpu_dpm_change_power_state_locked, + .pm_compute_clocks = amdgpu_legacy_dpm_compute_clocks, };static const struct amdgpu_irq_src_funcs kv_dpm_irq_funcs = { diff --git a/drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
b/drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
index67c84b7ad8e7..3c6ee493e410100644drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c +2
-0@@ -26,6 +26,8 @@#include "atom.h" #include "amd_pcie.h" #include "legacy_dpm.h" +#include "amdgpu_dpm_internal.h" +#include "amdgpu_display.h" #define amdgpu_dpm_pre_set_power_state (adev) \((adev)->powerplay.pp_funcs->pre_set_power_state((adev)- powerplay.pp_
handle)) @@ -949,9 +951,8 @@ static structamdgpu_ps*amdgpu_dpm_pick_power_state(structamdgpu_device*adev,
return NULL;
}drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c +1
-1-int amdgpu_dpm_change_power_state_locked (void *handle) +static int amdgpu_dpm_change_power_state_locked(struct
amdgpu_devicedrivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c int
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c +1
-1+*adev) { -struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ps *ps;enum amd_pm_state_type dpm_state;int ret;@@ -1022,3 +1023,58 @@ intamdgpu_dpm_change_power_state_locked(void
Quoted 20 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c +16
-0*handle)return 0 ; } + +void amdgpu_legacy_dpm_compute_clocks (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +int i =0 ; + +if (adev->mode_info.num_crtc) +amdgpu_display_bandwidth_update (adev); + +for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) { +struct amdgpu_ring *ring = adev->rings[i]; +if (ring && ring->sched.ready) +amdgpu_fence_wait_empty (ring); + } + +amdgpu_dpm_get_active_displays (adev); +drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c int amdgpu_dpm_change_power_state_locked(void *handle)
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c +10
-0+amdgpu_dpm_change_power_state_locked (adev); +} + +void amdgpu_dpm_thermal_work_handler (struct work_struct *work) { +struct amdgpu_device *adev = + container_of(work, struct amdgpu_device, + pm.dpm.thermal.work); +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +/* switch to the thermal state */ + enum amd_pm_state_type dpm_state =
POWER_STATE_TYPE_INTERNAL_THERMAL;drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h int amdgpu_parse_extended_power_table(struct
Quoted 34 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c +26
-0+int temp, size =sizeof (temp); + +if (!adev->pm.dpm_enabled) +return ; + +if (!pp_funcs->read_sensor (adev->powerplay.pp_handle, +AMDGPU_PP_SENSOR_GPU_TEMP , + (void *)&temp, + &size)) { +if (temp < adev->pm.dpm.thermal.min_temp) +/* switch back the user state */ + dpm_state = adev->pm.dpm.user_state; + }else { +if (adev->pm.dpm.thermal.high_to_low) +/* switch back the user state */ + dpm_state = adev->pm.dpm.user_state; + } + +if (dpm_state ==POWER_STATE_TYPE_INTERNAL_THERMAL ) + adev->pm.dpm.thermal_active = true; +else + adev->pm.dpm.thermal_active = false; + + adev->pm.dpm.state = dpm_state; + + amdgpu_legacy_dpm_compute_clocks(adev-powerplay.pp_handle);
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.c +1
-0+}drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h +0
-0@@ -32,6 +32,7 @@ int amdgpu_parse_extended_power_table(struct
amdgpu_device*adev);drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h int amdgpu_parse_extended_power_table(struct · line 32
Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h +0
-0void amdgpu_free_extended_power_table(struct amdgpu_device*adev);
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c static int si_set_boot_state(struct
Quoted 13 lines
drivers/gpu/drm/amd/pm/powerplay/legacy_dpm.h +2
-0void amdgpu_add_thermal_controller (struct amdgpu_device *adev);struct amd_vce_state *amdgpu_get_vce_clock_state (void *handle,u32 idx); -int amdgpu_dpm_change_power_state_locked(void *handle);void amdgpu_pm_print_power_states (struct amdgpu_device *adev); +void amdgpu_legacy_dpm_compute_clocks (void *handle);void +amdgpu_dpm_thermal_work_handler (struct work_struct *work);#endif drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +0
-0@@ -3891,6 +3891,40 @@ static int si_set_boot_state(struct
amdgpu_device*adev)Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +1
-0}#endif +static int si_set_powergating_by_smu(void *handle,drivers/gpu/drm/amd/pm/powerplay/si_dpm.c static int si_set_boot_state(struct amdgpu_device *adev)
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +10
-0+ uint32_t block_type, + bool gate) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +switch (block_type) { +case AMD_IP_BLOCK_TYPE_UVD : +if (!gate) { + adev->pm.dpm.uvd_active = true; + adev->pm.dpm.state =
POWER_STATE_TYPE_INTERNAL_UVD;drivers/gpu/drm/amd/pm/powerplay/si_dpm.c static int si_set_boot_state(struct amdgpu_device *adev)
Quoted 11 lines
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +11
-0+ }else { + adev->pm.dpm.uvd_active = false; + } + +amdgpu_legacy_dpm_compute_clocks (handle); +break ; +case AMD_IP_BLOCK_TYPE_VCE : +if (!gate) { + adev->pm.dpm.vce_active = true; +/* XXX select vce level based on ring/task */ + adev->pm.dpm.vce_level =
AMD_VCE_LEVEL_AC_ALL;Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +5
-0+ }else { + adev->pm.dpm.vce_active = false; + } + +amdgpu_legacy_dpm_compute_clocks (handle);drivers/gpu/drm/amd/pm/powerplay/si_dpm.c static int si_set_boot_state(struct amdgpu_device *adev)
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +7
-0+break ; +default : +break ; + } +return 0 ; +} +static int si_set_sw_state (struct amdgpu_device *adev) { return (amdgpu_si_send_msg_to_smc(adev,
PPSMC_MSG_SwitchToSwState) ==PPSMC_Result_OK) ?drivers/gpu/drm/amd/pm/powerplay/si_dpm.c static const struct amd_pm_funcs si_dpm_funcs
Quoted 19 lines
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +2
-2@@ -7801,7 +7835,7 @@ static int si_dpm_hw_init(void *handle)else adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex); -amdgpu_dpm_compute_clocks (adev); +amdgpu_legacy_dpm_compute_clocks (adev);return ret; }@@ -7849,7 +7883,7 @@ static int si_dpm_resume(void *handle) adev->pm.dpm_enabled = true;mutex_unlock (&adev->pm.mutex);if (adev->pm.dpm_enabled) -amdgpu_dpm_compute_clocks (adev); +amdgpu_legacy_dpm_compute_clocks (adev); }return 0 ; }@@ -8094,6 +8128,7 @@ static const struct amd_pm_funcs si_dpm_funcs= {
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c static const struct amd_pm_funcs si_dpm_funcs · line 8129
Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +0
-0.print_power_state = &si_dpm_print_power_state, .debugfs_print_current_performance_level =
&si_dpm_debugfs_print_current_performance_level,drivers/gpu/drm/amd/pm/powerplay/si_dpm.c static const struct amd_pm_funcs si_dpm_funcs = {
Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +1
-0.force_performance_level = &si_dpm_force_performance_level, + .set_powergating_by_smu = &si_set_powergating_by_smu, .vblank_too_short = &si_dpm_vblank_too_short, .set_fan_control_mode = &si_dpm_set_fan_control_mode, .get_fan_control_mode = &si_dpm_get_fan_control_mode, @@ -8102,7
Quoted 10 lines
+8137,7 @@ static const struct
amd_pm_funcssi_dpm_funcs= {
.check_state_equal =&si_check_state_equal, .get_vce_clock_state =amdgpu_get_vce_clock_state, .read_sensor =&si_dpm_read_sensor,drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +1
-1- .change_power_state = amdgpu_dpm_change_power_state_locked, + .pm_compute_clocks = amdgpu_legacy_dpm_compute_clocks, };static const struct amdgpu_irq_src_funcs si_dpm_irq_funcs = {
PATCH v3 10/17 drm/amd/pm: move those code piece used by Stoney only to smu8_hwmgr.c
In reply to Evan QuanInstead of putting them in amdgpu_dpm.c.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 14 -------------- drivers/gpu/drm/amd/pm/inc/hwmgr.h | 3 --- .../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 10 +++++++++- 3 files changed, 9 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -14
@@ -32,8 +32,6 @@#include "hwmgr.h" #include <linux/power_supply.h> -#define WIDTH_4K 3840 -#define amdgpu_dpm_enable_bapm (adev, e) \ ((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e)))
@@ -383,18 +381,6 @@ void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable)if (ret)DRM_ERROR ("Dpm %s uvd failed, ret = %d. \n" , enable ?"enable" :"disable" , ret); - -/* enable/disable Low Memory PState for UVD (4k videos) */ -if (adev->asic_type ==CHIP_STONEY && - adev->uvd.decode_image_width >=WIDTH_4K ) { -struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; - -if (hwmgr && hwmgr->hwmgr_func && - hwmgr->hwmgr_func->update_nbdpm_pstate) - hwmgr->hwmgr_func->update_nbdpm_pstate (hwmgr, - !enable, - true); - } }void amdgpu_dpm_enable_vce (struct amdgpu_device *adev,bool enable)
drivers/gpu/drm/amd/pm/inc/hwmgr.h +0 -3
@@ -331,9 +331,6 @@ struct pp_hwmgr_func {uint32_t mc_addr_low, uint32_t mc_addr_hi, uint32_t size); -int (*update_nbdpm_pstate)(struct pp_hwmgr *hwmgr, -bool enable, -bool lock);int (*get_thermal_temperature_range)(struct pp_hwmgr *hwmgr,struct PP_TemperatureRange *range);int (*get_power_profile_mode)(struct pp_hwmgr *hwmgr,char *buf);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +9 -1
@@ -1950,9 +1950,12 @@ static void smu8_dpm_powergate_acp(struct pp_hwmgr *hwmgr, bool bgate)smum_send_msg_to_smc (hwmgr, PPSMC_MSG_ACPPowerON,NULL ); } +#define WIDTH_4K 3840 +static void smu8_dpm_powergate_uvd (struct pp_hwmgr *hwmgr,bool bgate) {struct smu8_hwmgr *data = hwmgr->backend; +struct amdgpu_device *adev = hwmgr->adev; data->uvd_power_gated = bgate;
@@ -1976,6 +1979,12 @@ static void smu8_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)smu8_dpm_update_uvd_dpm (hwmgr, false); } +/* enable/disable Low Memory PState for UVD (4k videos) */ +if (adev->asic_type ==CHIP_STONEY && + adev->uvd.decode_image_width >=WIDTH_4K ) +smu8_nbdpm_pstate_enable_disable (hwmgr, + bgate, + true); }static void smu8_dpm_powergate_vce (struct pp_hwmgr *hwmgr,bool bgate)
@@ -2037,7 +2046,6 @@ static const struct pp_hwmgr_func smu8_hwmgr_funcs = { .power_state_set = smu8_set_power_state_tasks, .dynamic_state_management_disable = smu8_disable_dpm_tasks, .notify_cac_buffer_info = smu8_notify_cac_buffer_info, - .update_nbdpm_pstate = smu8_nbdpm_pstate_enable_disable, .get_thermal_temperature_range = smu8_get_thermal_temperature_range, };
Signature · 1 line
2.29.0
PATCH v3 11/17 drm/amd/pm: correct the usage for amdgpu_dpm_dispatch_task()
In reply to Evan QuanWe should avoid having multi-function APIs. It should be up to the caller to determine when or whether to call amdgpu_dpm_dispatch_task().
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 18 ++---------------- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2 -16
@@ -551,8 +551,6 @@ void amdgpu_dpm_set_power_state(struct amdgpu_device *adev, enum amd_pm_state_type state) { adev->pm.dpm.user_state = state; - -amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_ENABLE_USER_STATE , &state); }enum amd_dpm_forced_level amdgpu_dpm_get_performance_level (struct amdgpu_device *adev)
@@ -720,13 +718,7 @@ int amdgpu_dpm_set_sclk_od(struct amdgpu_device *adev, uint32_t value)if (!pp_funcs->set_sclk_od)return -EOPNOTSUPP ; - pp_funcs->set_sclk_od (adev->powerplay.pp_handle, value); - -amdgpu_dpm_dispatch_task (adev, -AMD_PP_TASK_READJUST_POWER_STATE , -NULL ); - -return 0 ; +return pp_funcs->set_sclk_od (adev->powerplay.pp_handle, value); }int amdgpu_dpm_get_mclk_od (struct amdgpu_device *adev)
@@ -746,13 +738,7 @@ int amdgpu_dpm_set_mclk_od(struct amdgpu_device *adev, uint32_t value)if (!pp_funcs->set_mclk_od)return -EOPNOTSUPP ; - pp_funcs->set_mclk_od (adev->powerplay.pp_handle, value); - -amdgpu_dpm_dispatch_task (adev, -AMD_PP_TASK_READJUST_POWER_STATE , -NULL ); - -return 0 ; +return pp_funcs->set_mclk_od (adev->powerplay.pp_handle, value); } int amdgpu_dpm_get_power_profile_mode(struct amdgpu_device *adev,
drivers/gpu/drm/amd/pm/amdgpu_pm.c +24 -2
@@ -187,6 +187,10 @@ static ssize_t amdgpu_set_power_dpm_state(struct device *dev,amdgpu_dpm_set_power_state (adev, state); +amdgpu_dpm_dispatch_task (adev, +AMD_PP_TASK_ENABLE_USER_STATE , + &state); +pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);
@@ -1278,7 +1282,16 @@ static ssize_t amdgpu_set_pp_sclk_od(struct device *dev,return ret; } -amdgpu_dpm_set_sclk_od (adev, (uint32_t )value); + ret =amdgpu_dpm_set_sclk_od (adev, (uint32_t )value); +if (ret) { +pm_runtime_mark_last_busy (ddev->dev); +pm_runtime_put_autosuspend (ddev->dev); +return ret; + } + +amdgpu_dpm_dispatch_task (adev, +AMD_PP_TASK_READJUST_POWER_STATE , +NULL );pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);
@@ -1340,7 +1353,16 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev,return ret; } -amdgpu_dpm_set_mclk_od (adev, (uint32_t )value); + ret =amdgpu_dpm_set_mclk_od (adev, (uint32_t )value); +if (ret) { +pm_runtime_mark_last_busy (ddev->dev); +pm_runtime_put_autosuspend (ddev->dev); +return ret; + } + +amdgpu_dpm_dispatch_task (adev, +AMD_PP_TASK_READJUST_POWER_STATE , +NULL );pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);
Signature · 1 line
2.29.0
PATCH v3 12/17 drm/amd/pm: drop redundant or unused APIs and data structures
In reply to Evan QuanDrop those unused APIs and data structures.
--- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 49 ------------------------- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 4 ++ 2 files changed, 4 insertions(+), 49 deletions(-)
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -49
@@ -88,19 +88,6 @@ struct amdgpu_dpm_thermal {struct amdgpu_irq_src irq; }; -enum amdgpu_clk_action -{ -AMDGPU_SCLK_UP =1 , -AMDGPU_SCLK_DOWN -}; - -struct amdgpu_blacklist_clocks -{ -u32 sclk; -u32 mclk; -enum amdgpu_clk_action action; -}; -struct amdgpu_clock_and_voltage_limits {u32 sclk;u32 mclk;
@@ -239,10 +226,6 @@ struct amdgpu_dpm_fan {bool ucode_fan_control; }; -#define amdgpu_dpm_reset_power_profile_state (adev, request) \ - ((adev)->powerplay.pp_funcs->reset_power_profile_state(\ - (adev)->powerplay.pp_handle, request)) -struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */
@@ -339,35 +322,6 @@ struct amdgpu_pm {bool pp_force_state_enabled; }; -#define R600_SSTU_DFLT 0 -#define R600_SST_DFLT 0x00C8 - -/* XXX are these ok? */ -#define R600_TEMP_RANGE_MIN (90 * 1000) -#define R600_TEMP_RANGE_MAX (120 * 1000) - -#define FDO_PWM_MODE_STATIC 1 -#define FDO_PWM_MODE_STATIC_RPM 5 - -enum amdgpu_td { -AMDGPU_TD_AUTO , -AMDGPU_TD_UP , -AMDGPU_TD_DOWN , -}; - -enum amdgpu_display_watermark { -AMDGPU_DISPLAY_WATERMARK_LOW =0 , -AMDGPU_DISPLAY_WATERMARK_HIGH =1 , -}; - -enum amdgpu_display_gap -{ -AMDGPU_PM_DISPLAY_GAP_VBLANK_OR_WM =0 , -AMDGPU_PM_DISPLAY_GAP_VBLANK =1 , -AMDGPU_PM_DISPLAY_GAP_WATERMARK =2 , -AMDGPU_PM_DISPLAY_GAP_IGNORE =3 , -}; -u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev);int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor,void *data,uint32_t *size);
@@ -417,9 +371,6 @@ int amdgpu_dpm_smu_i2c_bus_access(struct amdgpu_device *adev,void amdgpu_pm_acpi_event_handler (struct amdgpu_device *adev); -int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor, -void *data,uint32_t *size); -void amdgpu_dpm_compute_clocks (struct amdgpu_device *adev);void amdgpu_dpm_enable_uvd (struct amdgpu_device *adev,bool enable);void amdgpu_dpm_enable_vce (struct amdgpu_device *adev,bool enable);
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +4 -0
@@ -26,6 +26,10 @@#include "amdgpu_smu.h" #if defined(SWSMU_CODE_LAYER_L2 ) || defined(SWSMU_CODE_LAYER_L3 ) || defined(SWSMU_CODE_LAYER_L4 ) + +#define FDO_PWM_MODE_STATIC 1 +#define FDO_PWM_MODE_STATIC_RPM 5 +int smu_cmn_send_msg_without_waiting (struct smu_context *smu,uint16_t msg_index,uint32_t param);
Signature · 1 line
2.29.0
PATCH v3 13/17 drm/amd/pm: do not expose the smu_context structure used internally in power
In reply to Evan QuanThis can cover the power implementation details. And as what did for powerplay framework, we hook the smu_context to adev->powerplay.pp_handle.
--v1->v2:
- drop smu_ppt_limit_type used internally from kgd_pp_interface.h(Lijo)
- drop the smu_send_hbm_bad_pages_num() change which can be combined into the patch ahead(Lijo)
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 --- .../gpu/drm/amd/include/kgd_pp_interface.h | 3 ++ drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 50 ++++++++++++------ drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 +- drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 4 -- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 52 ++++++++++++------- .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 9 ++-- .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 9 ++-- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 9 ++-- .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 4 +- .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 9 ++-- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 8 +-- 12 files changed, 96 insertions(+), 69 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -6
@@ -99,7 +99,6 @@#include "amdgpu_gem.h" #include "amdgpu_doorbell.h" #include "amdgpu_amdkfd.h" -#include "amdgpu_smu.h" #include "amdgpu_discovery.h" #include "amdgpu_mes.h" #include "amdgpu_umc.h"
@@ -950,11 +949,6 @@ struct amdgpu_device {/* powerplay */ struct amd_powerplay powerplay; - -/* smu */ -struct smu_context smu; - -/* dpm */ struct amdgpu_pm pm;u32 cg_flags;u32 pg_flags;
drivers/gpu/drm/amd/include/kgd_pp_interface.h +3 -0
@@ -25,6 +25,9 @@#define __KGD_PP_INTERFACE_H__extern const struct amdgpu_ip_block_version pp_smu_ip_block; +extern const struct amdgpu_ip_block_version smu_v11_0_ip_block; +extern const struct amdgpu_ip_block_version smu_v12_0_ip_block; +extern const struct amdgpu_ip_block_version smu_v13_0_ip_block;enum smu_event_type {SMU_EVENT_RESET_COMPLETE =0 ,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +34 -16
158 lines not on this page · raw message
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -1
@@ -2884,7 +2884,7 @@ static ssize_t amdgpu_hwmon_show_power_label(struct device *dev,int limit_type =to_sensor_dev_attr (attr)->index;return sysfs_emit (buf,"%s\n" , - limit_type ==SMU_FAST_PPT_LIMIT ?"fastPPT" :"slowPPT" ); + limit_type ==PP_PWR_TYPE_FAST ?"fastPPT" :"slowPPT" ); } static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -4
@@ -1389,10 +1389,6 @@ int smu_mode1_reset(struct smu_context *smu);extern const struct amd_ip_funcs smu_ip_funcs; -extern const struct amdgpu_ip_block_version smu_v11_0_ip_block; -extern const struct amdgpu_ip_block_version smu_v12_0_ip_block; -extern const struct amdgpu_ip_block_version smu_v13_0_ip_block; -bool is_support_sw_smu (struct amdgpu_device *adev);bool is_support_cclk_dpm (struct amdgpu_device *adev);int smu_write_watermarks_table (struct smu_context *smu);
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +32 -20
179 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +5 -4
@@ -2082,7 +2082,8 @@ static int arcturus_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msg, int num_msgs) {struct amdgpu_device *adev =to_amdgpu_device (i2c_adap); -struct smu_table_context *smu_table = &adev->smu.smu_table; +struct smu_context *smu = adev->powerplay.pp_handle; +struct smu_table_context *smu_table = &smu->smu_table;struct smu_table *table = &smu_table->driver_table;SwI2cRequest_t *req, *res = (SwI2cRequest_t *)table->cpu_addr;int i, j, r, c;
@@ -2128,9 +2129,9 @@ static int arcturus_i2c_xfer(struct i2c_adapter *i2c_adap, } } } -mutex_lock (&adev->smu.mutex); - r =smu_cmn_update_table (&adev->smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); -mutex_unlock (&adev->smu.mutex); +mutex_lock (&smu->mutex); + r =smu_cmn_update_table (smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); +mutex_unlock (&smu->mutex);if (r) goto fail;
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +5 -4
@@ -2779,7 +2779,8 @@ static int navi10_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msg, int num_msgs) {struct amdgpu_device *adev =to_amdgpu_device (i2c_adap); -struct smu_table_context *smu_table = &adev->smu.smu_table; +struct smu_context *smu = adev->powerplay.pp_handle; +struct smu_table_context *smu_table = &smu->smu_table;struct smu_table *table = &smu_table->driver_table;SwI2cRequest_t *req, *res = (SwI2cRequest_t *)table->cpu_addr;int i, j, r, c;
@@ -2825,9 +2826,9 @@ static int navi10_i2c_xfer(struct i2c_adapter *i2c_adap, } } } -mutex_lock (&adev->smu.mutex); - r =smu_cmn_update_table (&adev->smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); -mutex_unlock (&adev->smu.mutex); +mutex_lock (&smu->mutex); + r =smu_cmn_update_table (smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); +mutex_unlock (&smu->mutex);if (r) goto fail;
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -4
@@ -3459,7 +3459,8 @@ static int sienna_cichlid_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msg, int num_msgs) {struct amdgpu_device *adev =to_amdgpu_device (i2c_adap); -struct smu_table_context *smu_table = &adev->smu.smu_table; +struct smu_context *smu = adev->powerplay.pp_handle; +struct smu_table_context *smu_table = &smu->smu_table;struct smu_table *table = &smu_table->driver_table;SwI2cRequest_t *req, *res = (SwI2cRequest_t *)table->cpu_addr;int i, j, r, c;
@@ -3505,9 +3506,9 @@ static int sienna_cichlid_i2c_xfer(struct i2c_adapter *i2c_adap, } } } -mutex_lock (&adev->smu.mutex); - r =smu_cmn_update_table (&adev->smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); -mutex_unlock (&adev->smu.mutex); +mutex_lock (&smu->mutex); + r =smu_cmn_update_table (smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); +mutex_unlock (&smu->mutex);if (r) goto fail;
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +2 -2
@@ -1372,7 +1372,7 @@ static int smu_v11_0_set_irq_state(struct amdgpu_device *adev,unsigned tyep, enum amdgpu_interrupt_state state) { - struct smu_context *smu = &adev->smu; + struct smu_context *smu = adev->powerplay.pp_handle;uint32_t low, high;uint32_t val =0 ;
@@ -1441,7 +1441,7 @@ static int smu_v11_0_irq_process(struct amdgpu_device *adev,struct amdgpu_irq_src *source, struct amdgpu_iv_entry *entry) { - struct smu_context *smu = &adev->smu; + struct smu_context *smu = adev->powerplay.pp_handle;uint32_t client_id = entry->client_id;uint32_t src_id = entry->src_id;/*
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +5 -4
@@ -1484,7 +1484,8 @@ static int aldebaran_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msg, int num_msgs) {struct amdgpu_device *adev =to_amdgpu_device (i2c_adap); -struct smu_table_context *smu_table = &adev->smu.smu_table; +struct smu_context *smu = adev->powerplay.pp_handle; +struct smu_table_context *smu_table = &smu->smu_table;struct smu_table *table = &smu_table->driver_table;SwI2cRequest_t *req, *res = (SwI2cRequest_t *)table->cpu_addr;int i, j, r, c;
@@ -1530,9 +1531,9 @@ static int aldebaran_i2c_xfer(struct i2c_adapter *i2c_adap, } } } -mutex_lock (&adev->smu.mutex); - r =smu_cmn_update_table (&adev->smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); -mutex_unlock (&adev->smu.mutex); +mutex_lock (&smu->mutex); + r =smu_cmn_update_table (smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); +mutex_unlock (&smu->mutex);if (r) goto fail;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +4 -4
@@ -1195,7 +1195,7 @@ static int smu_v13_0_set_irq_state(struct amdgpu_device *adev,unsigned tyep, enum amdgpu_interrupt_state state) { - struct smu_context *smu = &adev->smu; + struct smu_context *smu = adev->powerplay.pp_handle;uint32_t low, high;uint32_t val =0 ;
@@ -1270,7 +1270,7 @@ static int smu_v13_0_irq_process(struct amdgpu_device *adev,struct amdgpu_irq_src *source, struct amdgpu_iv_entry *entry) { - struct smu_context *smu = &adev->smu; + struct smu_context *smu = adev->powerplay.pp_handle;uint32_t client_id = entry->client_id;uint32_t src_id = entry->src_id;/*
@@ -1316,11 +1316,11 @@ static int smu_v13_0_irq_process(struct amdgpu_device *adev,switch (ctxid) {case 0x3 :dev_dbg (adev->dev,"Switched to AC mode!\n" ); -smu_v13_0_ack_ac_dc_interrupt (&adev->smu); +smu_v13_0_ack_ac_dc_interrupt (smu);break ;case 0x4 :dev_dbg (adev->dev,"Switched to DC mode!\n" ); -smu_v13_0_ack_ac_dc_interrupt (&adev->smu); +smu_v13_0_ack_ac_dc_interrupt (smu);break ;case 0x7 :/*
Signature · 1 line
2.29.0