drm/amdgpu: add an asic callback to determine the reset method
Subsystems (2)
PATCH 1/9 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 */
@@ -1109,6 +1118,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): 20190724050012.31398-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org
PATCH 2/9 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/9 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/9 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/9 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/9 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
A message that is not in the archive (sent off-list or not yet received): 20190724050012.31398-6-alexander.deucher-5C7GfCeVMHo@public.gmane.org
Kevin Wang
Reviewed-byRe: [PATCH 6/9] drm/amdgpu: add reset_method asic callback for navi
Quoted 41 lines · Alex Deucher
Navi uses either mode1 or baco depending on various conditions.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/nv.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/nv.c +13
-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);
drivers/gpu/drm/amd/amdgpu/nv.c static const struct amdgpu_asic_funcs nv_asic_funcs = · line 518
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/nv.c +1
-0@@ -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,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/9 drm/amdgpu/powerplay/vega10: only use PrepareMp1ForUnload for mode1 reset
In reply to a message not in the archiveIt's not needed for BACO.
--- drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +8 -4
@@ -4732,6 +4732,7 @@ static int vega10_disable_dpm_tasks(struct pp_hwmgr *hwmgr)static int vega10_power_off_asic (struct pp_hwmgr *hwmgr) {struct vega10_hwmgr *data = hwmgr->backend; +struct amdgpu_device *adev = hwmgr->adev;int result; result =vega10_disable_dpm_tasks (hwmgr);
@@ -4740,10 +4741,13 @@ static int vega10_power_off_asic(struct pp_hwmgr *hwmgr) ); data->water_marks_bitmap &= ~(WaterMarksLoaded); -PP_ASSERT_WITH_CODE ((result =smum_send_msg_to_smc (hwmgr, - PPSMC_MSG_PrepareMp1ForUnload)) ==0 , -"[PrepareMp1ForUnload] Failed!" , - return result); +if (amdgpu_asic_reset_method (adev) ==AMD_RESET_METHOD_MODE1 ) { +PP_ASSERT_WITH_CODE ((result = +smum_send_msg_to_smc (hwmgr, + PPSMC_MSG_PrepareMp1ForUnload)) ==0 , +"[PrepareMp1ForUnload] Failed!" , + return result); + }return result; }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/9 drm/amdgpu/powerplay/vega12: only use PrepareMp1ForUnload for mode1 reset
In reply to a message not in the archiveIt's not needed for BACO.
--- drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c +8 -4
@@ -2460,6 +2460,7 @@ static int vega12_disable_dpm_tasks(struct pp_hwmgr *hwmgr)static int vega12_power_off_asic (struct pp_hwmgr *hwmgr) {struct vega12_hwmgr *data = (struct vega12_hwmgr *)(hwmgr->backend); +struct amdgpu_device *adev = hwmgr->adev;int result; result =vega12_disable_dpm_tasks (hwmgr);
@@ -2468,10 +2469,13 @@ static int vega12_power_off_asic(struct pp_hwmgr *hwmgr) ); data->water_marks_bitmap &= ~(WaterMarksLoaded); -PP_ASSERT_WITH_CODE ((result =smum_send_msg_to_smc (hwmgr, - PPSMC_MSG_PrepareMp1ForUnload)) ==0 , -"[PrepareMp1ForUnload] Failed!" , - return result); +if (amdgpu_asic_reset_method (adev) ==AMD_RESET_METHOD_MODE1 ) { +PP_ASSERT_WITH_CODE ((result = +smum_send_msg_to_smc (hwmgr, + PPSMC_MSG_PrepareMp1ForUnload)) ==0 , +"[PrepareMp1ForUnload] Failed!" , + return result); + }return result; }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/9 drm/amdgpu/powerplay/vega120: only use PrepareMp1ForUnload for mode1 reset
In reply to a message not in the archiveUse PrepareMp1ForUnload for mode1 reset and PrepareMp1ForShutdown for baco reset.
--- .../gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +14 -4
@@ -3756,6 +3756,7 @@ static int vega20_disable_dpm_tasks(struct pp_hwmgr *hwmgr)static int vega20_power_off_asic (struct pp_hwmgr *hwmgr) {struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); +struct amdgpu_device *adev = hwmgr->adev;int result; result =vega20_disable_dpm_tasks (hwmgr);
@@ -3764,10 +3765,19 @@ static int vega20_power_off_asic(struct pp_hwmgr *hwmgr) ); data->water_marks_bitmap &= ~(WaterMarksLoaded); -PP_ASSERT_WITH_CODE ((result =smum_send_msg_to_smc (hwmgr, - PPSMC_MSG_PrepareMp1ForUnload)) ==0 , -"[PrepareMp1ForUnload] Failed!" , - return result); +if (amdgpu_asic_reset_method (adev) ==AMD_RESET_METHOD_MODE1 ) { +PP_ASSERT_WITH_CODE ((result = +smum_send_msg_to_smc (hwmgr, + PPSMC_MSG_PrepareMp1ForUnload)) ==0 , +"[PrepareMp1ForUnload] Failed!" , + return result); + }else { +PP_ASSERT_WITH_CODE ((result = +smum_send_msg_to_smc (hwmgr, + PPSMC_MSG_PrepareMp1ForShutdown)) ==0 , +"[PrepareMp1ForUnload] Failed!" , + return result); + }return result; }
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): 20190724050012.31398-9-alexander.deucher-5C7GfCeVMHo@public.gmane.org
RE: [PATCH 9/9] drm/amdgpu/powerplay/vega120: only use PrepareMp1ForUnload for mode1 reset
Patch1 - 6: Reviewed-by: Evan Quan <[email protected]>
Patch7 - 9: I think suspend needs also be taken into consideration as vega20_power_off_asic() is also on the suspend path.
That means even if the default asic method is baco, you may still need using PrepareMp1ForUnload() for suspend case.
BTW there is typo for patch9 header. The "vega120" should be "vega20".
Regards,
Evan
Quoted 62 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, July 24, 2019 1:00 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 9/9] drm/amdgpu/powerplay/vega120: only use PrepareMp1ForUnload for mode1 resetUse PrepareMp1ForUnload for mode1 reset and PrepareMp1ForShutdown for baco reset.
Signed-off-by Alex Deucher <[email protected]>--- .../gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +0
-0@@ -3756,6 +3756,7 @@ static int vega20_disable_dpm_tasks(struct
pp_hwmgr*hwmgr) static intvega20_power_off_asic(struct pp_hwmgr *hwmgr){
structvega20_hwmgr*data = (structvega20_hwmgr*)(hwmgr-Quoted 1 line
backend);
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-0+struct amdgpu_device *adev = hwmgr->adev;int result; result = vega20_disable_dpm_tasks(hwmgr); @@ -3764,10 +3765,19@@ static int
vega20_power_off_asic(struct pp_hwmgr *hwmgr)drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +1
-4); data->water_marks_bitmap &= ~(WaterMarksLoaded); -PP_ASSERT_WITH_CODE ((result =smum_send_msg_to_smc (hwmgr, - PPSMC_MSG_PrepareMp1ForUnload)) ==0 , -"[PrepareMp1ForUnload] Failed!" , - return result); + if (amdgpu_asic_reset_method(adev) ==
AMD_RESET_METHOD_MODE1) {drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-0+ PP_ASSERT_WITH_CODE((result = + smum_send_msg_to_smc(hwmgr, +
PPSMC_MSG_PrepareMp1ForUnload)) == 0,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +6
-0+"[PrepareMp1ForUnload] Failed!" , + return result); + } else { + PP_ASSERT_WITH_CODE((result = + smum_send_msg_to_smc(hwmgr, +
PPSMC_MSG_PrepareMp1ForShutdown)) == 0,drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +3
-1+"[PrepareMp1ForUnload] Failed!" , + return result); + }return result; } --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