drm/amd/powerplay: enable pp one vf mode for vega10
Subsystems (2)
PATCH 1/1 drm/amd/powerplay: enable pp one vf mode for vega10
Originally, due to the restriction from PSP and SMU, VF has to send message to hypervisor driver to handle powerplay change which is complicated and redundant. Currently, SMU and PSP can support VF to directly handle powerplay change by itself. Therefore, the old code about the handshake between VF and PF to handle powerplay will be removed and VF will use new the registers below to handshake with SMU.mmMP1_SMN_C2PMSG_101: register to handle SMU messagemmMP1_SMN_C2PMSG_102: register to handle SMU parametermmMP1_SMN_C2PMSG_103: register to handle SMU response
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 - drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 + drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 - drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 121 +++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 51 ------ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 14 +- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 78 --------- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h | 4 - drivers/gpu/drm/amd/amdgpu/soc15.c | 2 +- drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 7 +- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 24 +-- .../drm/amd/powerplay/hwmgr/hardwaremanager.c | 15 +- drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | 4 + drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c | 30 ++-- .../drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 157 ++++++++++++------ drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 1 + .../drm/amd/powerplay/smumgr/smu9_smumgr.c | 55 ++++-- .../drm/amd/powerplay/smumgr/vega10_smumgr.c | 6 + 19 files changed, 281 insertions(+), 306 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -114,6 +114,7 @@ struct amdgpu_mgpu_info/* * Modules parameters. */ +extern int amdgpu_pp_one_vf;extern int amdgpu_modeset;extern int amdgpu_vram_limit;extern int amdgpu_vis_vram_limit;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -6
@@ -2819,7 +2819,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->virt.vf_errors.lock);hash_init (adev->mn_hash);mutex_init (&adev->lock_reset); -mutex_init (&adev->virt.dpm_mutex);mutex_init (&adev->psp.mutex); r =amdgpu_device_check_arguments (adev);
@@ -3040,9 +3039,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,amdgpu_fbdev_init (adev); -if (amdgpu_sriov_vf (adev) &&amdgim_is_hwperf (adev)) -amdgpu_pm_virt_sysfs_init (adev); - r =amdgpu_pm_sysfs_init (adev);if (r) { adev->pm_sysfs_en = false;
@@ -3187,8 +3183,6 @@ void amdgpu_device_fini(struct amdgpu_device *adev)iounmap (adev->rmmio); adev->rmmio =NULL ;amdgpu_device_doorbell_fini (adev); -if (amdgpu_sriov_vf (adev) &&amdgim_is_hwperf (adev)) -amdgpu_pm_virt_sysfs_fini (adev);amdgpu_debugfs_regs_cleanup (adev);device_remove_file (adev->dev, &dev_attr_pcie_replay_count);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7 -0
@@ -135,6 +135,7 @@ int amdgpu_lbpw = -1;int amdgpu_compute_multipipe =-1 ;int amdgpu_gpu_recovery =-1 ;/* auto */ int amdgpu_emu_mode =0 ; +int amdgpu_pp_one_vf;uint amdgpu_smu_memory_pool_size =0 ;/* FBC (bit 0) disabled by default*/ uint amdgpu_dc_feature_mask =0 ;
@@ -152,6 +153,12 @@ struct amdgpu_mgpu_info mgpu_info = {int amdgpu_ras_enable =-1 ;uint amdgpu_ras_mask =0xffffffff ; +/** +* DOC: pp_one_vf (int) +* Enable VF to adjust the powerplay. The default is 0 (disable it). +*/ +MODULE_PARM_DESC (pp_one_vf,"One vf mode support (0 = disable (default), 1 = enable)" ); +module_param_named (pp_one_vf, amdgpu_pp_one_vf, int,0600 );/** * DOC: vramlimit (int) * Restrict the total amount of VRAM in MiB for testing. The default is 0 (Use full VRAM).
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -4
@@ -703,10 +703,6 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileif (adev->pm.dpm_enabled) { dev_info.max_engine_clock =amdgpu_dpm_get_sclk (adev, false) *10 ; dev_info.max_memory_clock =amdgpu_dpm_get_mclk (adev, false) *10 ; - }else if (amdgpu_sriov_vf (adev) &&amdgim_is_hwperf (adev) && - adev->virt.ops->get_pp_clk) { - dev_info.max_engine_clock =amdgpu_virt_get_sclk (adev, false) *10 ; - dev_info.max_memory_clock =amdgpu_virt_get_mclk (adev, false) *10 ; }else { dev_info.max_engine_clock = adev->clock.default_sclk *10 ; dev_info.max_memory_clock = adev->clock.default_mclk *10 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +57 -64
241 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0 -51
54 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +4 -10
@@ -57,8 +57,6 @@ struct amdgpu_virt_ops {int (*reset_gpu)(struct amdgpu_device *adev);int (*wait_reset)(struct amdgpu_device *adev);void (*trans_msg)(struct amdgpu_device *adev,u32 req,u32 data1,u32 data2,u32 data3); -int (*get_pp_clk)(struct amdgpu_device *adev,u32 type,char *buf); -int (*force_dpm_level)(struct amdgpu_device *adev,u32 level); };/*
@@ -85,8 +83,8 @@ enum AMDGIM_FEATURE_FLAG {AMDGIM_FEATURE_GIM_LOAD_UCODES =0x2 ,/* VRAM LOST by GIM */ AMDGIM_FEATURE_GIM_FLR_VRAMLOST =0x4 , -/* HW PERF SIM in GIM */ - AMDGIM_FEATURE_HW_PERF_SIMULATION = (1 << 3), +/* PP ONE VF MODE in GIM */ + AMDGIM_FEATURE_PP_ONE_VF = (1 << 4), }; struct amd_sriov_msg_pf2vf_info_header {
@@ -257,8 +255,6 @@ struct amdgpu_virt {struct amdgpu_vf_error_buffer vf_errors;struct amdgpu_virt_fw_reserve fw_reserve;uint32_t gim_feature; -/* protect DPM events to GIM */ -struct mutex dpm_mutex;uint32_t reg_access_mode; };
@@ -286,8 +282,8 @@ static inline bool is_virtual_machine(void)#endif } -#define amdgim_is_hwperf (adev) \ - ((adev)->virt.gim_feature & AMDGIM_FEATURE_HW_PERF_SIMULATION) +#define amdgim_is_pp_one_vf (adev) \ + ((adev)->virt.gim_feature & AMDGIM_FEATURE_PP_ONE_VF)bool amdgpu_virt_mmio_blocked (struct amdgpu_device *adev);void amdgpu_virt_init_setting (struct amdgpu_device *adev);
@@ -306,6 +302,4 @@ int amdgpu_virt_fw_reserve_get_checksum(void *obj, unsigned long obj_size,unsigned int key, unsigned int chksum);void amdgpu_virt_init_data_exchange (struct amdgpu_device *adev); -uint32_t amdgpu_virt_get_sclk (struct amdgpu_device *adev,bool lowest); -uint32_t amdgpu_virt_get_mclk (struct amdgpu_device *adev,bool lowest);#endif
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +0 -78
88 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h +0 -4
@@ -35,10 +35,6 @@ enum idh_request {IDH_REL_GPU_FINI_ACCESS ,IDH_REQ_GPU_RESET_ACCESS , -IDH_IRQ_FORCE_DPM_LEVEL =10 , -IDH_IRQ_GET_PP_SCLK , -IDH_IRQ_GET_PP_MCLK , - IDH_LOG_VF_ERROR = 200, };
drivers/gpu/drm/amd/amdgpu/soc15.c +1 -1
@@ -777,7 +777,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev) }amdgpu_device_ip_block_add (adev, &gfx_v9_0_ip_block);amdgpu_device_ip_block_add (adev, &sdma_v4_0_ip_block); -if (!amdgpu_sriov_vf (adev)) { +if (!amdgpu_sriov_vf (adev) || amdgpu_pp_one_vf) {if (is_support_sw_smu (adev))amdgpu_device_ip_block_add (adev, &smu_v11_0_ip_block);else
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +6 -1
@@ -48,7 +48,9 @@ static int amd_powerplay_create(struct amdgpu_device *adev) hwmgr->adev = adev; hwmgr->not_vf = !amdgpu_sriov_vf (adev); - hwmgr->pm_en = (amdgpu_dpm && hwmgr->not_vf) ? true : false; + hwmgr->pp_one_vf = amdgpu_pp_one_vf; + hwmgr->pm_en = (amdgpu_dpm && (hwmgr->not_vf || hwmgr->pp_one_vf)) + ? true : false; hwmgr->device =amdgpu_cgs_create_device (adev);mutex_init (&hwmgr->smu_lock); hwmgr->chip_family = adev->family;
@@ -276,6 +278,9 @@ static int pp_dpm_load_fw(void *handle) {struct pp_hwmgr *hwmgr = handle; +if (!hwmgr->not_vf) +return 0 ; +if (!hwmgr || !hwmgr->smumgr_funcs || !hwmgr->smumgr_funcs->start_smu)return -EINVAL ;
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +14 -10
@@ -1653,11 +1653,13 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu,if (!smu->pm_enabled)return -EINVAL ; -if (!skip_display_settings) { - ret =smu_display_config_changed (smu); -if (ret) { -pr_err ("Failed to change display config!" ); -return ret; +if (!amdgpu_sriov_vf (smu->adev)) { +if (!skip_display_settings) { + ret =smu_display_config_changed (smu); +if (ret) { +pr_err ("Failed to change display config!" ); +return ret; + } } }
@@ -1667,11 +1669,13 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu,return ret; } -if (!skip_display_settings) { - ret =smu_notify_smc_dispaly_config (smu); -if (ret) { -pr_err ("Failed to notify smc display config!" ); -return ret; +if (amdgpu_sriov_vf (smu->adev)) { +if (!skip_display_settings) { + ret =smu_notify_smc_dispaly_config (smu); +if (ret) { +pr_err ("Failed to notify smc display config!" ); +return ret; + } } }
drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c +13 -2
@@ -81,8 +81,8 @@ int phm_enable_dynamic_state_management(struct pp_hwmgr *hwmgr) adev = hwmgr->adev;/* Skip for suspend/resume case */ -if (smum_is_dpm_running (hwmgr) && !amdgpu_passthrough (adev) - && adev->in_suspend) { +if (!hwmgr->pp_one_vf &&smum_is_dpm_running (hwmgr) + && !amdgpu_passthrough (adev) && adev->in_suspend) {pr_info ("dpm has been enabled\n" );return 0 ; }
@@ -200,6 +200,9 @@ int phm_stop_thermal_controller(struct pp_hwmgr *hwmgr) {PHM_FUNC_CHECK (hwmgr); +if (!hwmgr->not_vf) +return 0 ; +if (hwmgr->hwmgr_func->stop_thermal_controller ==NULL )return -EINVAL ;
@@ -237,6 +240,9 @@ int phm_start_thermal_controller(struct pp_hwmgr *hwmgr) TEMP_RANGE_MAX};struct amdgpu_device *adev = hwmgr->adev; +if (!hwmgr->not_vf) +return 0 ; +if (hwmgr->hwmgr_func->get_thermal_temperature_range) hwmgr->hwmgr_func->get_thermal_temperature_range ( hwmgr, &range);
@@ -263,6 +269,8 @@ int phm_start_thermal_controller(struct pp_hwmgr *hwmgr)bool phm_check_smc_update_required_for_display_configuration (struct pp_hwmgr *hwmgr) {PHM_FUNC_CHECK (hwmgr); +if (hwmgr->pp_one_vf) +return false;if (hwmgr->hwmgr_func->check_smc_update_required_for_display_configuration ==NULL )return false;
@@ -482,6 +490,9 @@ int phm_disable_smc_firmware_ctf(struct pp_hwmgr *hwmgr) {PHM_FUNC_CHECK (hwmgr); +if (!hwmgr->not_vf) +return 0 ; +if (hwmgr->hwmgr_func->disable_smc_firmware_ctf ==NULL )return -EINVAL ;
drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +4 -0
@@ -365,6 +365,8 @@ int hwmgr_handle_task(struct pp_hwmgr *hwmgr, enum amd_pp_task task_id,switch (task_id) {case AMD_PP_TASK_DISPLAY_CONFIG_CHANGE : +if (!hwmgr->not_vf) +return ret; ret =phm_pre_display_configuration_changed (hwmgr);if (ret)return ret;
@@ -381,6 +383,8 @@ int hwmgr_handle_task(struct pp_hwmgr *hwmgr, enum amd_pp_task task_id,enum PP_StateUILabel requested_ui_label;struct pp_power_state *requested_ps =NULL ; +if (!hwmgr->not_vf) +return ret;if (user_state ==NULL ) { ret = -EINVAL ;break ;
drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c +16 -14
@@ -262,20 +262,22 @@ int psm_adjust_power_state_dynamic(struct pp_hwmgr *hwmgr, bool skip_display_setuint32_t index;long workload; -if (!skip_display_settings) -phm_display_configuration_changed (hwmgr); - -if (hwmgr->ps) -power_state_management (hwmgr, new_ps); -else -/* -* for vega12/vega20 which does not support power state manager -* DAL clock limits should also be honoured -*/ -phm_apply_clock_adjust_rules (hwmgr); - -if (!skip_display_settings) -phm_notify_smc_display_config_after_ps_adjustment (hwmgr); +if (hwmgr->not_vf) { +if (!skip_display_settings) +phm_display_configuration_changed (hwmgr); + +if (hwmgr->ps) +power_state_management (hwmgr, new_ps); +else +/* +* for vega12/vega20 which does not support power state manager +* DAL clock limits should also be honoured +*/ +phm_apply_clock_adjust_rules (hwmgr); + +if (!skip_display_settings) +phm_notify_smc_display_config_after_ps_adjustment (hwmgr); + }if (!phm_force_dpm_levels (hwmgr, hwmgr->request_dpm_level)) hwmgr->dpm_level = hwmgr->request_dpm_level;
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +108 -49
251 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +1 -0
@@ -741,6 +741,7 @@ struct pp_hwmgr {uint32_t smu_version;bool not_vf;bool pm_en; +bool pp_one_vf;struct mutex smu_lock;uint32_t pp_table_version;
drivers/gpu/drm/amd/powerplay/smumgr/smu9_smumgr.c +43 -12
86 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +6 -0
@@ -71,6 +71,12 @@ static int vega10_copy_table_to_smc(struct pp_hwmgr *hwmgr, {struct vega10_smumgr *priv = hwmgr->smu_backend; +/* under pp_one_vf mode, vbios or hypervisor driver +* has already copy table to smc so here only skip it +*/ +if (!hwmgr->not_vf && !hwmgr->pp_one_vf) +return 0 ; +PP_ASSERT_WITH_CODE (table_id <MAX_SMU_TABLE ,"Invalid SMU Table ID!" , return -EINVAL ); PP_ASSERT_WITH_CODE(priv->smu_tables.entry[table_id].version != 0,
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx