drm/amdgpu: add an asic callback to determine the reset method
Subsystems (2)
PATCH 1/11 drm/amdgpu: add an asic callback to determine the reset method
Sometimes the driver may have to behave differently depending on the method we are using to reset the GPU.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +10 -0
@@ -532,6 +532,14 @@ struct amdgpu_allowed_register_entry {bool grbm_indexed; }; +enum amd_reset_method { +AMD_RESET_METHOD_LEGACY =0 , +AMD_RESET_METHOD_MODE0 , +AMD_RESET_METHOD_MODE1 , +AMD_RESET_METHOD_MODE2 , +AMD_RESET_METHOD_BACO +}; +/* * ASIC specific functions. */
@@ -543,6 +551,7 @@ struct amdgpu_asic_funcs { u32 sh_num, u32 reg_offset, u32 *value);void (*set_vga_state)(struct amdgpu_device *adev,bool state);int (*reset)(struct amdgpu_device *adev); +enum amd_reset_method (*reset_method)(struct amdgpu_device *adev);/* get the reference clock */ u32 (*get_xclk)(struct amdgpu_device *adev);/* MM block clocks */
@@ -1112,6 +1121,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);*/ #define amdgpu_asic_set_vga_state (adev, state) (adev)->asic_funcs->set_vga_state((adev), (state))#define amdgpu_asic_reset (adev) (adev)->asic_funcs->reset((adev)) +#define amdgpu_asic_reset_method (adev) (adev)->asic_funcs->reset_method((adev))#define amdgpu_asic_get_xclk (adev) (adev)->asic_funcs->get_xclk((adev))#define amdgpu_asic_set_uvd_clocks (adev, v, d) (adev)->asic_funcs->set_uvd_clocks((adev), (v), (d))#define amdgpu_asic_set_vce_clocks (adev, ev, ec) (adev)->asic_funcs->set_vce_clocks((adev), (ev), (ec))
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190726032146.3187-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org
PATCH 2/11 drm/amdgpu: add reset_method asic callback for si
SI always uses the legacy pci based reset.
--- drivers/gpu/drm/amd/amdgpu/si.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/si.c +7 -0
@@ -1185,6 +1185,12 @@ static int si_asic_reset(struct amdgpu_device *adev)return 0 ; } +static enum amd_reset_method +si_asic_reset_method (struct amdgpu_device *adev) +{ +return AMD_RESET_METHOD_LEGACY ; +} +static u32 si_get_config_memsize (struct amdgpu_device *adev) {return RREG32 (mmCONFIG_MEMSIZE);
@@ -1393,6 +1399,7 @@ static const struct amdgpu_asic_funcs si_asic_funcs = .read_bios_from_rom = &si_read_bios_from_rom, .read_register = &si_read_register, .reset = &si_asic_reset, + .reset_method = &si_asic_reset_method, .set_vga_state = &si_vga_set_state, .get_xclk = &si_get_xclk, .set_uvd_clocks = &si_set_uvd_clocks,
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/11 drm/amdgpu: add reset_method asic callback for cik
In reply to a message not in the archiveCIK always uses the legacy pci based reset.
--- drivers/gpu/drm/amd/amdgpu/cik.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/cik.c +7 -0
@@ -1290,6 +1290,12 @@ static int cik_asic_reset(struct amdgpu_device *adev)return r; } +static enum amd_reset_method +cik_asic_reset_method (struct amdgpu_device *adev) +{ +return AMD_RESET_METHOD_LEGACY ; +} +static u32 cik_get_config_memsize (struct amdgpu_device *adev) {return RREG32 (mmCONFIG_MEMSIZE);
@@ -1822,6 +1828,7 @@ static const struct amdgpu_asic_funcs cik_asic_funcs = .read_bios_from_rom = &cik_read_bios_from_rom, .read_register = &cik_read_register, .reset = &cik_asic_reset, + .reset_method = &cik_asic_reset_method, .set_vga_state = &cik_vga_set_state, .get_xclk = &cik_get_xclk, .set_uvd_clocks = &cik_set_uvd_clocks,
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/11 drm/amdgpu: add reset_method asic callback for vi
In reply to a message not in the archiveVI always uses the legacy pci based reset.
--- drivers/gpu/drm/amd/amdgpu/vi.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/vi.c +7 -0
@@ -709,6 +709,12 @@ static int vi_asic_reset(struct amdgpu_device *adev)return r; } +static enum amd_reset_method +vi_asic_reset_method (struct amdgpu_device *adev) +{ +return AMD_RESET_METHOD_LEGACY ; +} +static u32 vi_get_config_memsize (struct amdgpu_device *adev) {return RREG32 (mmCONFIG_MEMSIZE);
@@ -1021,6 +1027,7 @@ static const struct amdgpu_asic_funcs vi_asic_funcs = .read_bios_from_rom = &vi_read_bios_from_rom, .read_register = &vi_read_register, .reset = &vi_asic_reset, + .reset_method = &vi_asic_reset_method, .set_vga_state = &vi_vga_set_state, .get_xclk = &vi_get_xclk, .set_uvd_clocks = &vi_set_uvd_clocks,
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/11 drm/amdgpu: add reset_method asic callback for soc15
In reply to a message not in the archiveAPUs only support mode2 reset. dGPUs use either mode1 or baco depending on various conditions.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/soc15.c +15 -2
@@ -464,12 +464,14 @@ static int soc15_asic_baco_reset(struct amdgpu_device *adev)return 0 ; } -static int soc15_asic_reset (struct amdgpu_device *adev) +static enum amd_reset_method +soc15_asic_reset_method (struct amdgpu_device *adev) { -int ret;bool baco_reset;switch (adev->asic_type) { +case CHIP_RAVEN : +return AMD_RESET_METHOD_MODE2 ;case CHIP_VEGA10 :case CHIP_VEGA12 :soc15_asic_get_baco_capability (adev, &baco_reset);
@@ -493,6 +495,16 @@ static int soc15_asic_reset(struct amdgpu_device *adev) }if (baco_reset) +return AMD_RESET_METHOD_BACO ; +else +return AMD_RESET_METHOD_MODE1 ; +} + +static int soc15_asic_reset (struct amdgpu_device *adev) +{ +int ret; + +if (soc15_asic_reset_method (adev) ==AMD_RESET_METHOD_BACO ) ret =soc15_asic_baco_reset (adev);else ret =soc15_asic_mode1_reset (adev);
@@ -806,6 +818,7 @@ static const struct amdgpu_asic_funcs soc15_asic_funcs = .read_bios_from_rom = &soc15_read_bios_from_rom, .read_register = &soc15_read_register, .reset = &soc15_asic_reset, + .reset_method = &soc15_asic_reset_method, .set_vga_state = &soc15_vga_set_state, .get_xclk = &soc15_get_xclk, .set_uvd_clocks = &soc15_set_uvd_clocks,
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/11 drm/amdgpu: add reset_method asic callback for navi
In reply to a message not in the archiveNavi uses either mode1 or baco depending on various conditions.
--- drivers/gpu/drm/amd/amdgpu/nv.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/nv.c +14 -1
@@ -289,6 +289,18 @@ static int nv_asic_mode1_reset(struct amdgpu_device *adev)return ret; } + +static enum amd_reset_method +nv_asic_reset_method (struct amdgpu_device *adev) +{ +struct smu_context *smu = &adev->smu; + +if (smu_baco_is_support (smu)) +return AMD_RESET_METHOD_BACO ; +else +return AMD_RESET_METHOD_MODE1 ; +} +static int nv_asic_reset (struct amdgpu_device *adev) {
@@ -303,7 +315,7 @@ static int nv_asic_reset(struct amdgpu_device *adev)int ret =0 ;struct smu_context *smu = &adev->smu; -if (smu_baco_is_support (smu)) +if (nv_asic_reset_method (adev) ==AMD_RESET_METHOD_BACO ) ret =smu_baco_reset (smu);else ret =nv_asic_mode1_reset (adev);
@@ -500,6 +512,7 @@ static const struct amdgpu_asic_funcs nv_asic_funcs = .read_bios_from_rom = &nv_read_bios_from_rom, .read_register = &nv_read_register, .reset = &nv_asic_reset, + .reset_method = &nv_asic_reset_method, .set_vga_state = &nv_vga_set_state, .get_xclk = &nv_get_xclk, .set_uvd_clocks = &nv_set_uvd_clocks,
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/11 drm/amdgpu/powerplay: add a new interface to set the mp1 state
In reply to a message not in the archiveThis is required for certain cases such as various GPU resets (mode1, mode2), BACO, shutdown, unload, etc. to put the SMU into the appropriate state for when the hw is re-initialized.
--- drivers/gpu/drm/amd/include/kgd_pp_interface.h | 8 ++++++++ drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 16 ++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 1 + 3 files changed, 25 insertions(+)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +8 -0
@@ -171,6 +171,13 @@ enum PP_HWMON_TEMP { PP_TEMP_MAX }; +enum pp_mp1_state { +PP_MP1_STATE_NONE , +PP_MP1_STATE_SHUTDOWN , +PP_MP1_STATE_UNLOAD , +PP_MP1_STATE_RESET , +}; +#define PP_GROUP_MASK 0xF0000000#define PP_GROUP_SHIFT 28
@@ -266,6 +273,7 @@ struct amd_pm_funcs {int (*get_power_profile_mode)(void *handle,char *buf);int (*set_power_profile_mode)(void *handle,long *input,uint32_t size);int (*odn_edit_dpm_table)(void *handle,uint32_t type,long *input,uint32_t size); +int (*set_mp1_state)(void *handle,enum pp_mp1_state mp1_state);/* export to DC */ u32 (*get_sclk)(void *handle,bool low);u32 (*get_mclk)(void *handle,bool low);
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +16 -0
@@ -924,6 +924,21 @@ static int pp_odn_edit_dpm_table(void *handle, uint32_t type, long *input, uint3return hwmgr->hwmgr_func->odn_edit_dpm_table (hwmgr, type, input, size); } +static int pp_dpm_set_mp1_state (void *handle,enum pp_mp1_state mp1_state) +{ +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en) +return -EINVAL ; + +if (hwmgr->hwmgr_func->set_mp1_state ==NULL ) { +pr_info_ratelimited ("%s was not implemented.\n" , __func__); +return -EINVAL ; + } + +return hwmgr->hwmgr_func->set_mp1_state (hwmgr, mp1_state); +} +static int pp_dpm_switch_power_profile (void *handle,enum PP_SMC_POWER_PROFILE type,bool en) {
@@ -1525,6 +1540,7 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .get_power_profile_mode = pp_get_power_profile_mode, .set_power_profile_mode = pp_set_power_profile_mode, .odn_edit_dpm_table = pp_odn_edit_dpm_table, + .set_mp1_state = pp_dpm_set_mp1_state, .set_power_limit = pp_set_power_limit, .get_power_limit = pp_get_power_limit,/* export to DC */
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +1 -0
@@ -344,6 +344,7 @@ struct pp_hwmgr_func {int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr,enum BACO_STATE state);int (*get_ppfeature_status)(struct pp_hwmgr *hwmgr,char *buf);int (*set_ppfeature_status)(struct pp_hwmgr *hwmgr,uint64_t ppfeature_masks); +int (*set_mp1_state)(struct pp_hwmgr *hwmgr,enum pp_mp1_state mp1_state); };struct pp_table_func {
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/11 drm/amdgpu/powerplay: add set_mp1_state for vega20
In reply to a message not in the archiveThis sets the SMU into the proper state for various operations (shutdown, unload, GPU reset, etc.).
--- .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +29 -0
@@ -3063,6 +3063,34 @@ static int vega20_odn_edit_dpm_table(struct pp_hwmgr *hwmgr,return 0 ; } +static int vega20_set_mp1_state (struct pp_hwmgr *hwmgr, +enum pp_mp1_state mp1_state) +{ +uint16_t msg; +int ret; + +switch (mp1_state) { +case PP_MP1_STATE_SHUTDOWN : + msg = PPSMC_MSG_PrepareMp1ForShutdown; +break ; +case PP_MP1_STATE_UNLOAD : + msg = PPSMC_MSG_PrepareMp1ForUnload; +break ; +case PP_MP1_STATE_RESET : + msg = PPSMC_MSG_PrepareMp1ForReset; +break ; +case PP_MP1_STATE_NONE : +default : +return 0 ; + } + +PP_ASSERT_WITH_CODE ((ret =smum_send_msg_to_smc (hwmgr, msg)) ==0 , +"[PrepareMp1] Failed!" , + return ret); + +return 0 ; +} +static int vega20_get_ppfeature_status (struct pp_hwmgr *hwmgr,char *buf) {static const char *ppfeature_name[] = {
@@ -4123,6 +4151,7 @@ static const struct pp_hwmgr_func vega20_hwmgr_funcs = { .get_asic_baco_capability = vega20_baco_get_capability, .get_asic_baco_state = vega20_baco_get_state, .set_asic_baco_state = vega20_baco_set_state, + .set_mp1_state = vega20_set_mp1_state, };int vega20_hwmgr_init (struct pp_hwmgr *hwmgr)
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/11 drm/amdgpu/powerplay: add set_mp1_state for vega10
In reply to a message not in the archiveThis sets the SMU into the proper state for various operations (shutdown, unload, GPU reset, etc.).
--- .../drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +25 -0
@@ -5218,6 +5218,30 @@ static int vega10_odn_edit_dpm_table(struct pp_hwmgr *hwmgr,return 0 ; } +static int vega10_set_mp1_state (struct pp_hwmgr *hwmgr, +enum pp_mp1_state mp1_state) +{ +uint16_t msg; +int ret; + +switch (mp1_state) { +case PP_MP1_STATE_UNLOAD : + msg = PPSMC_MSG_PrepareMp1ForUnload; +break ; +case PP_MP1_STATE_SHUTDOWN : +case PP_MP1_STATE_RESET : +case PP_MP1_STATE_NONE : +default : +return 0 ; + } + +PP_ASSERT_WITH_CODE ((ret =smum_send_msg_to_smc (hwmgr, msg)) ==0 , +"[PrepareMp1] Failed!" , + return ret); + +return 0 ; +} +static int vega10_get_performance_level (struct pp_hwmgr *hwmgr,const struct pp_hw_power_state *state,PHM_PerformanceLevelDesignation designation,uint32_t index,PHM_PerformanceLevel *level)
@@ -5307,6 +5331,7 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = { .enable_mgpu_fan_boost = vega10_enable_mgpu_fan_boost, .get_ppfeature_status = vega10_get_ppfeature_status, .set_ppfeature_status = vega10_set_ppfeature_status, + .set_mp1_state = vega10_set_mp1_state, };int vega10_hwmgr_init (struct pp_hwmgr *hwmgr)
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/11 drm/amdgpu/powerplay: add set_mp1_state for vega12
In reply to a message not in the archiveThis sets the SMU into the proper state for various operations (shutdown, unload, GPU reset, etc.).
--- .../drm/amd/powerplay/hwmgr/vega12_hwmgr.c | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c +25 -1
@@ -2639,6 +2639,30 @@ static int vega12_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_return 0 ; } +static int vega12_set_mp1_state (struct pp_hwmgr *hwmgr, +enum pp_mp1_state mp1_state) +{ +uint16_t msg; +int ret; + +switch (mp1_state) { +case PP_MP1_STATE_UNLOAD : + msg = PPSMC_MSG_PrepareMp1ForUnload; +break ; +case PP_MP1_STATE_SHUTDOWN : +case PP_MP1_STATE_RESET : +case PP_MP1_STATE_NONE : +default : +return 0 ; + } + +PP_ASSERT_WITH_CODE ((ret =smum_send_msg_to_smc (hwmgr, msg)) ==0 , +"[PrepareMp1] Failed!" , + return ret); + +return 0 ; +} +static const struct pp_hwmgr_func vega12_hwmgr_funcs = { .backend_init = vega12_hwmgr_backend_init, .backend_fini = vega12_hwmgr_backend_fini,
@@ -2695,7 +2719,7 @@ static const struct pp_hwmgr_func vega12_hwmgr_funcs = { .set_asic_baco_state = vega12_baco_set_state, .get_ppfeature_status = vega12_get_ppfeature_status, .set_ppfeature_status = vega12_set_ppfeature_status, - + .set_mp1_state = vega12_set_mp1_state, };int vega12_hwmgr_init (struct pp_hwmgr *hwmgr)
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 11/11 drm/amdgpu: put the SMC into the proper state on reset/unload
In reply to a message not in the archiveWhen doing a GPU reset or unloading the driver, we need to put the SMU into the apprpriate state for the re-init after the reset or unload to reliably work.
I don't think this is necessary for BACO because the SMU actually controls the BACO state to it needs to be active.
For suspend (S3), the asic is put into D3 so the SMU would be powered down so I don't think we need to put the SMU into any special state.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 27 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ 3 files changed, 30 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -993,6 +993,7 @@ struct amdgpu_device {/* record last mm index being written through WREG32*/ unsigned long last_mm_index;bool in_gpu_reset; +enum pp_mp1_state mp1_state;struct mutex lock_reset;struct amdgpu_doorbell_index doorbell_index;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +27 -0
@@ -2174,6 +2174,21 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)DRM_ERROR ("suspend of IP block <%s> failed %d\n" , adev->ip_blocks[i].version->funcs->name, r); } +/* handle putting the SMC in the appropriate state */ +if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_SMC ) { +if (is_support_sw_smu (adev)) { +/* todo */ + }else if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->set_mp1_state) { + r = adev->powerplay.pp_funcs->set_mp1_state ( + adev->powerplay.pp_handle, + adev->mp1_state); +if (r) { +DRM_ERROR ("SMC failed to set mp1 state %d, %d\n" , + adev->mp1_state, r); + } + } + } }return 0 ;
@@ -3639,6 +3654,17 @@ static bool amdgpu_device_lock_adev(struct amdgpu_device *adev, bool trylock)atomic_inc (&adev->gpu_reset_counter); adev->in_gpu_reset =1 ; +switch (amdgpu_asic_reset_method (adev)) { +case AMD_RESET_METHOD_MODE1 : + adev->mp1_state =PP_MP1_STATE_SHUTDOWN ; +break ; +case AMD_RESET_METHOD_MODE2 : + adev->mp1_state =PP_MP1_STATE_RESET ; +break ; +default : + adev->mp1_state =PP_MP1_STATE_NONE ; +break ; + }/* Block kfd: SRIOV would do it separately */ if (!amdgpu_sriov_vf (adev))amdgpu_amdkfd_pre_reset (adev);
@@ -3652,6 +3678,7 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev)if (!amdgpu_sriov_vf (adev))amdgpu_amdkfd_post_reset (adev);amdgpu_vf_error_trans_all (adev); + adev->mp1_state =PP_MP1_STATE_NONE ; adev->in_gpu_reset =0 ;mutex_unlock (&adev->lock_reset); }
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
@@ -1094,7 +1094,9 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)* unfortunately we can't detect certain * hypervisors so just do this all the time. */ + adev->mp1_state =PP_MP1_STATE_UNLOAD ;amdgpu_device_ip_suspend (adev); + adev->mp1_state =PP_MP1_STATE_NONE ; }static int amdgpu_pmops_suspend (struct device *dev)
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190726032146.3187-11-alexander.deucher-5C7GfCeVMHo@public.gmane.org
RE: [PATCH 11/11] drm/amdgpu: put the SMC into the proper state on reset/unload
I think it's OK to leave the S3 and BACO as they were for now. Series is reviewed-by Evan Quan <[email protected]>
Quoted 118 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, July 26, 2019 11:22 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 11/11] drm/amdgpu: put the SMC into the proper state on reset/unloadWhen doing a GPU reset or unloading the driver, we need to put the SMU into the apprpriate state for the re-init after the reset or unload to reliably work.
I don't think this is necessary for BACO because the SMU actually controls the BACO state to it needs to be active.
For suspend (S3), the asic is put into D3 so the SMU would be powered down so I don't think we need to put the SMU into any special state.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 27 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ 3 files changed, 30 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -993,6 +993,7 @@ struct amdgpu_device {/* record last mm index being written through WREG32*/ unsigned long last_mm_index;bool in_gpu_reset; +enum pp_mp1_state mp1_state;struct mutex lock_reset;struct amdgpu_doorbell_index doorbell_index;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0@@ -2174,6 +2174,21 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev) DRM_ERROR("suspend of IP block <%s> failed %d\n", adev->ip_blocks[i].version->funcs->name, r); } +/* handle putting the SMC in the appropriate state */ + if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) { + if (is_support_sw_smu(adev)) { + /* todo */ + } else if (adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs-Quoted 1 line
set_mp1_state) {drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+ r = adev->powerplay.pp_funcs-Quoted 1 line
set_mp1_state(
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0+ adev->powerplay.pp_handle, + adev->mp1_state); +if (r) { + DRM_ERROR("SMC failed to set mp1state %d, %d\n",
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +15
-0+ adev->mp1_state, r); + } + } + } }return 0 ;@@ -3639,6 +3654,17 @@ static bool amdgpu_device_lock_adev(struct amdgpu_device *adev, bool trylock) atomic_inc(&adev->gpu_reset_counter); adev->in_gpu_reset =1 ; +switch (amdgpu_asic_reset_method (adev)) { +case AMD_RESET_METHOD_MODE1 : + adev->mp1_state =PP_MP1_STATE_SHUTDOWN ; +break ; +case AMD_RESET_METHOD_MODE2 : + adev->mp1_state =PP_MP1_STATE_RESET ; +break ; +default : + adev->mp1_state =PP_MP1_STATE_NONE ; +break ; + }/* Block kfd: SRIOV would do it separately */ if (!amdgpu_sriov_vf (adev))amdgpu_amdkfd_pre_reset(adev); @@ -3652,6 +3678,7 @@ staticvoid
amdgpu_device_unlock_adev(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0if (!amdgpu_sriov_vf (adev))amdgpu_amdkfd_post_reset (adev);amdgpu_vf_error_trans_all (adev); + adev->mp1_state =PP_MP1_STATE_NONE ; adev->in_gpu_reset =0 ;mutex_unlock (&adev->lock_reset); }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -1094,7 +1094,9 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)* unfortunately we can't detect certain * hypervisors so just do this all the time. */ + adev->mp1_state =PP_MP1_STATE_UNLOAD ;amdgpu_device_ip_suspend (adev); + adev->mp1_state =PP_MP1_STATE_NONE ; }static int amdgpu_pmops_suspend (struct device *dev) --2.20.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx