Support XGMI reset on init
Subsystems (3)
v2 cover Support XGMI reset on init
There are case where a device needs to be reset first before it is fully initialized. An example case is a driver reinstallation with a different version of PSP TOS. In such a case, if a device supports reset in which PSP TOS is unloaded, then driver needs to reset device first and then load the new firmware components.
For devices in an XGMI hive, a reset needs to be sent on all devices in the hive. Thus driver should discover first devices that belong to a hive with PSP support.
There is an existing delayed reset handler, however it has the below limitations-
1) It doesn't discover devices in the hive, instead it tries to do XGMI reset for all devices registered to mgpu struct. mgpu struct may have other devices than the one which belong to a hive. Also, if there is more than one hive, it doesn't work.
2) It doesn't take a reset lock and since this is a delayed reset, that could result in unwanted hardware accesses during a reset.
3) It doesn't initialize RAS properly (left as TODO)
This series overcomes the above limitations. Instead of marking a pending reset, init levels are defined where the level of initialization may be defined. In case of a pending reset, only specific hardware blocks may be initialized.
Further work (not done in this series) may be done to have fine grain controls for init levels - say skip enabling features like DPM enablement, or skip loading specific set of fimwares as they won't be required during a minimal init scenario where device is going to be reset.
The series adds an API interface to check if a PSP TOS reload is required.
v2:
Fix logical issue while replacing pending_reset flag with init level Use consistent naming for functions/variables
Lijo Lazar (10):
drm/amdgpu: Add init levels
drm/amdgpu: Use init level for pending_reset flag drm/amdgpu: Separate reinitialization after reset drm/amdgpu: Add reset on init handler for XGMI drm/amdgpu: Add helper to initialize badpage info drm/amdgpu: Refactor XGMI reset on init handling drm/amdgpu: Drop delayed reset work handler drm/amdgpu: Support reset-on-init on select SOCs drm/amdgpu: Add interface for TOS reload cases drm/amdgpu: Add PSP reload case to reset-on-init
drivers/gpu/drm/amd/amdgpu/aldebaran.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu.h | 29 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 258 +++++++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 81 ------ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 13 + drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 62 +++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 149 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 5 + drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 73 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 + drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 +- drivers/gpu/drm/amd/amdgpu/psp_v13_0.c | 25 ++ drivers/gpu/drm/amd/amdgpu/soc15.c | 7 + .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 3 +- 17 files changed, 516 insertions(+), 214 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/10 drm/amdgpu: Add init levels
Add init levels to define the level to which device needs to be initialized.
---
v2:
Add comments describing init levels
Drop unnecessary assignment
Rename AMDGPU_INIT_LEVEL_MINIMAL to AMDGPU_INIT_LEVEL_MINIMAL_XGMI
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 22 ++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 66 ++++++++++++++++++++++ 2 files changed, 88 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +22 -0
@@ -820,6 +820,24 @@ struct amdgpu_mqd { struct amdgpu_mqd_prop *p); }; +/* +* Custom Init levels could be defined for different situations where a full +* initialization of all hardware blocks are not expected. Sample cases are +* custom init sequences after resume after S0i3/S3, reset on initialization, +* partial reset of blocks etc. Presently, this defines only two levels. Levels +* are described in corresponding struct definitions - amdgpu_init_default, +* amdgpu_init_minimal_xgmi. +*/ +enum amdgpu_init_lvl_id { +AMDGPU_INIT_LEVEL_DEFAULT , +AMDGPU_INIT_LEVEL_MINIMAL_XGMI , +}; + +struct amdgpu_init_level { +enum amdgpu_init_lvl_id level; +uint32_t hwini_ip_block_mask; +}; +#define AMDGPU_RESET_MAGIC_NUM 64#define AMDGPU_MAX_DF_PERFMONS 4struct amdgpu_reset_domain ;
@@ -1169,6 +1187,8 @@ struct amdgpu_device {bool enforce_isolation[MAX_XCP ];/* Added this mutex for cleaner shader isolation between GFX and compute processes */ struct mutex enforce_isolation_mutex; + +struct amdgpu_init_level *init_lvl; }; static inline uint32_t amdgpu_ip_version(const struct amdgpu_device *adev,
@@ -1623,4 +1643,6 @@ extern const struct attribute_group amdgpu_vram_mgr_attr_group;extern const struct attribute_group amdgpu_gtt_mgr_attr_group;extern const struct attribute_group amdgpu_flash_attr_group; +void amdgpu_set_init_level (struct amdgpu_device *adev, +enum amdgpu_init_lvl_id lvl);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +66 -0
108 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v2 01/10] drm/amdgpu: Add init levels
The series is
Quoted 179 lines · Lijo Lazar
Add init levels to define the level to which device needs to be initialized.
Signed-off-by Lijo Lazar <[email protected]>---
v2:
Add comments describing init levels
Drop unnecessary assignment
RenameAMDGPU_INIT_LEVEL_MINIMALtoAMDGPU_INIT_LEVEL_MINIMAL_XGMIdrivers/gpu/drm/amd/amdgpu/amdgpu.h | 22 ++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 66 ++++++++++++++++++++++ 2 files changed, 88 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +22
-0@@ -820,6 +820,24 @@ struct amdgpu_mqd { struct amdgpu_mqd_prop *p); }; +/* +* Custom Init levels could be defined for different situations where a full +* initialization of all hardware blocks are not expected. Sample cases are +* custom init sequences after resume after S0i3/S3, reset on initialization, +* partial reset of blocks etc. Presently, this defines only two levels. Levels +* are described in corresponding struct definitions - amdgpu_init_default, +* amdgpu_init_minimal_xgmi. +*/ +enum amdgpu_init_lvl_id { +AMDGPU_INIT_LEVEL_DEFAULT , +AMDGPU_INIT_LEVEL_MINIMAL_XGMI , +}; + +struct amdgpu_init_level { +enum amdgpu_init_lvl_id level; +uint32_t hwini_ip_block_mask; +}; +#define AMDGPU_RESET_MAGIC_NUM 64#define AMDGPU_MAX_DF_PERFMONS 4struct amdgpu_reset_domain ;@@ -1169,6 +1187,8 @@ struct amdgpu_device {bool enforce_isolation[MAX_XCP ];/* Added this mutex for cleaner shader isolation between GFX and compute processes */ struct mutex enforce_isolation_mutex; + +struct amdgpu_init_level *init_lvl; }; static inline uint32_t amdgpu_ip_version(const struct amdgpu_device *adev,@@ -1623,4 +1643,6 @@ extern const struct attribute_group amdgpu_vram_mgr_attr_group;extern const struct attribute_group amdgpu_gtt_mgr_attr_group;extern const struct attribute_group amdgpu_flash_attr_group; +void amdgpu_set_init_level (struct amdgpu_device *adev, +enum amdgpu_init_lvl_id lvl);#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +66
-0@@ -144,6 +144,50 @@ const char *amdgpu_asic_name[] = { "LAST", }; +#define AMDGPU_IP_BLK_MASK_ALL GENMASK(AMDGPU_MAX_IP_NUM - 1, 0) +/* +* Default init level where all blocks are expected to be initialized. This is +* the level of initialization expected by default and also after a full reset +* of the device. +*/ +struct amdgpu_init_level amdgpu_init_default = { + .level =AMDGPU_INIT_LEVEL_DEFAULT , + .hwini_ip_block_mask =AMDGPU_IP_BLK_MASK_ALL , +}; + +/* +* Minimal blocks needed to be initialized before a XGMI hive can be reset. This +* is used for cases like reset on initialization where the entire hive needs to +* be reset before first use. +*/ +struct amdgpu_init_level amdgpu_init_minimal_xgmi = { + .level =AMDGPU_INIT_LEVEL_MINIMAL_XGMI , + .hwini_ip_block_mask = +BIT (AMD_IP_BLOCK_TYPE_GMC ) |BIT (AMD_IP_BLOCK_TYPE_SMC ) | +BIT (AMD_IP_BLOCK_TYPE_COMMON ) |BIT (AMD_IP_BLOCK_TYPE_IH ) +}; + +static inline bool amdgpu_ip_member_of_hwini (struct amdgpu_device *adev, +enum amd_ip_block_type block) +{ +return (adev->init_lvl->hwini_ip_block_mask & (1U << block)) !=0 ; +} + +void amdgpu_set_init_level (struct amdgpu_device *adev, +enum amdgpu_init_lvl_id lvl) +{ +switch (lvl) { +case AMDGPU_INIT_LEVEL_MINIMAL_XGMI : + adev->init_lvl = &amdgpu_init_minimal_xgmi; +break ; +case AMDGPU_INIT_LEVEL_DEFAULT : + fallthrough; +default : + adev->init_lvl = &amdgpu_init_default; +break ; + } +} +static inline void amdgpu_device_stop_pending_resets (struct amdgpu_device *adev);/** @@ -2633,6 +2677,9 @@ static int amdgpu_device_ip_hw_init_phase1(struct amdgpu_device *adev)continue ;if (adev->ip_blocks[i].status.hw)continue ; +if (!amdgpu_ip_member_of_hwini ( + adev, adev->ip_blocks[i].version->type)) +continue ;if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_COMMON || (amdgpu_sriov_vf (adev) && (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_PSP )) || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_IH ) {@@ -2658,6 +2705,9 @@ static int amdgpu_device_ip_hw_init_phase2(struct amdgpu_device *adev)continue ;if (adev->ip_blocks[i].status.hw)continue ; +if (!amdgpu_ip_member_of_hwini ( + adev, adev->ip_blocks[i].version->type)) +continue ; r = adev->ip_blocks[i].version->funcs->hw_init (adev);if (r) { DRM_ERROR("hw_init of IP block <%s> failed %d\n",@@ -2681,6 +2731,10 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev)if (adev->ip_blocks[i].version->type !=AMD_IP_BLOCK_TYPE_PSP )continue ; +if (!amdgpu_ip_member_of_hwini (adev, +AMD_IP_BLOCK_TYPE_PSP )) +break ; +if (!adev->ip_blocks[i].status.sw)continue ;@@ -2803,6 +2857,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } adev->ip_blocks[i].status.sw = true; +if (!amdgpu_ip_member_of_hwini ( + adev, adev->ip_blocks[i].version->type)) +continue ; +if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_COMMON ) {/* need to do common hw init early so everything is set up for gmc */ r = adev->ip_blocks[i].version->funcs->hw_init ((void *)adev);@@ -4196,6 +4254,12 @@ int amdgpu_device_init(struct amdgpu_device *adev,amdgpu_device_set_mcbp (adev); +/* +* By default, use default mode where all blocks are expected to be +* initialized. At present a 'swinit' of blocks is required to be +* completed before the need for a different level is detected. +*/ +amdgpu_set_init_level (adev,AMDGPU_INIT_LEVEL_DEFAULT );/* early init functions */ r =amdgpu_device_ip_early_init (adev);if (r)@@ -5473,6 +5537,8 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, }list_for_each_entry (tmp_adev, device_list_handle, reset_list) { +/* After reset, it's default init level */ +amdgpu_set_init_level (tmp_adev,AMDGPU_INIT_LEVEL_DEFAULT );if (need_full_reset) {/* post card */ amdgpu_ras_set_fed (tmp_adev, false);
PATCH v2 2/10 drm/amdgpu: Use init level for pending_reset flag
In reply to Lijo LazarDrop pending_reset flag in gmc block. Instead use init level to determine which type of init is preferred - in this case MINIMAL.
---
v2:
Fix logical issue while replacing pending_reset flag in smuv11 (Feifei) Use renamed init level id - AMDGPU_INIT_LEVEL_MINIMAL_XGMI
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 34 +++++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 6 ++-- .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 3 +- 6 files changed, 14 insertions(+), 33 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -26
@@ -1699,7 +1699,7 @@ bool amdgpu_device_need_post(struct amdgpu_device *adev) }/* Don't post if we need to reset whole hive on init */ -if (adev->gmc.xgmi.pending_reset) +if (adev->init_lvl->level ==AMDGPU_INIT_LEVEL_MINIMAL_XGMI )return false;if (adev->has_hw_reset) {
@@ -2993,7 +2993,7 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)amdgpu_ttm_set_buffer_funcs_status (adev, true);/* Don't init kfd if whole hive need to be reset during init */ -if (!adev->gmc.xgmi.pending_reset) { +if (adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL_XGMI ) {kgd2kfd_init_zone_device (adev);amdgpu_amdkfd_device_init (adev); }
@@ -3507,14 +3507,9 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev) }/* skip unnecessary suspend if we do not initialize them yet */ -if (adev->gmc.xgmi.pending_reset && - !(adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_GMC || - adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_SMC || - adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_COMMON || - adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_IH )) { - adev->ip_blocks[i].status.hw = false; +if (!amdgpu_ip_member_of_hwini ( + adev, adev->ip_blocks[i].version->type))continue ; - }/* skip suspend of gfx/mes and psp for S0ix * gfx is in gfxoff state, so on resume it will exit gfxoff just
@@ -4332,20 +4327,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,if (!amdgpu_sriov_vf (adev) &&amdgpu_asic_need_reset_on_init (adev)) {if (adev->gmc.xgmi.num_physical_nodes) {dev_info (adev->dev,"Pending hive reset.\n" ); - adev->gmc.xgmi.pending_reset = true; -/* Only need to init necessary block for SMU to handle the reset */ -for (i =0 ; i < adev->num_ip_blocks; i++) { -if (!adev->ip_blocks[i].status.valid) -continue ; -if (!(adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_GMC || - adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_COMMON || - adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_IH || - adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_SMC )) { -DRM_DEBUG ("IP %s disabled for hw_init.\n" , - adev->ip_blocks[i].version->funcs->name); - adev->ip_blocks[i].status.hw = true; - } - } +amdgpu_set_init_level (adev, +AMDGPU_INIT_LEVEL_MINIMAL_XGMI ); }else if (amdgpu_ip_version (adev,MP1_HWIP ,0 ) ==IP_VERSION (13 ,0 ,10 ) && !amdgpu_device_has_display_hardware (adev)) { r =psp_gpu_reset (adev);
@@ -4453,7 +4436,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,/* enable clockgating, etc. after ib tests, etc. since some blocks require * explicit gating rather than handling it automatically. */ -if (!adev->gmc.xgmi.pending_reset) { +if (adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL_XGMI ) { r =amdgpu_device_ip_late_init (adev);if (r) {dev_err (adev->dev,"amdgpu_device_ip_late_init failed\n" );
@@ -4530,7 +4513,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,if (px)vga_switcheroo_init_domain_pm_ops (adev->dev, &adev->vga_pm_domain); -if (adev->gmc.xgmi.pending_reset) +if (adev->init_lvl->level ==AMDGPU_INIT_LEVEL_MINIMAL_XGMI )queue_delayed_work (system_wq, &mgpu_info.delayed_reset_work,msecs_to_jiffies (AMDGPU_RESUME_MS ));
@@ -5502,7 +5485,6 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,list_for_each_entry (tmp_adev, device_list_handle, reset_list) {/* For XGMI run all resets in parallel to speed up the process */ if (tmp_adev->gmc.xgmi.num_physical_nodes >1 ) { - tmp_adev->gmc.xgmi.pending_reset = false;if (!queue_work (system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY ; }else
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -1
@@ -2495,7 +2495,6 @@ static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work)for (i =0 ; i < mgpu_info.num_dgpu; i++) { adev = mgpu_info.gpu_ins[i].adev;flush_work (&adev->xgmi_reset_work); - adev->gmc.xgmi.pending_reset = false; }/* reset function will rebuild the xgmi hive info , clear it now */
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +0 -1
@@ -182,7 +182,6 @@ struct amdgpu_xgmi {bool supported;struct ras_common_if *ras_if;bool connected_to_cpu; -bool pending_reset;struct amdgpu_xgmi_ras *ras; };
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
@@ -3185,7 +3185,7 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)* when the GPU is pending on XGMI reset during probe time * (Mostly after second bus reset), skip it now */ -if (adev->gmc.xgmi.pending_reset) +if (adev->init_lvl->level ==AMDGPU_INIT_LEVEL_MINIMAL_XGMI )return 0 ; ret =amdgpu_ras_eeprom_init (&con->eeprom_control);/*
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +3 -3
@@ -860,7 +860,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)if (!adev->gmc.xgmi.supported)return 0 ; -if (!adev->gmc.xgmi.pending_reset && +if ((adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL_XGMI ) &&amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_PSP )) { ret =psp_xgmi_initialize (&adev->psp, false, true);if (ret) {
@@ -907,7 +907,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)task_barrier_add_task (&hive->tb); -if (!adev->gmc.xgmi.pending_reset && +if ((adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL_XGMI ) &&amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_PSP )) {list_for_each_entry (tmp_adev, &hive->device_list, gmc.xgmi.head) {/* update node list for other device in the hive */
@@ -985,7 +985,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev) } } -if (!ret && !adev->gmc.xgmi.pending_reset) +if (!ret && (adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL_XGMI )) ret =amdgpu_xgmi_sysfs_add_dev_info (adev, hive); exit_unlock:
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +2 -1
@@ -1616,7 +1616,8 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state)break ;default :if (!ras || !adev->ras_enabled || - adev->gmc.xgmi.pending_reset) { + (adev->init_lvl->level == +AMDGPU_INIT_LEVEL_MINIMAL_XGMI )) {if (amdgpu_ip_version (adev,MP1_HWIP ,0 ) ==IP_VERSION (11 ,0 ,2 )) { data =RREG32_SOC15 (THM ,0 , mmTHM_BACO_CNTL_ARCT);
Signature · 1 line
2.25.1
PATCH v2 3/10 drm/amdgpu: Separate reinitialization after reset
In reply to Lijo LazarMove the reinitialization part after a reset to another function. No functional changes.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 150 ++++++++++++--------- 2 files changed, 89 insertions(+), 63 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1284,6 +1284,8 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,int amdgpu_do_asic_reset (struct list_head *device_list_handle,struct amdgpu_reset_context *reset_context); +int amdgpu_device_reinit_after_reset (struct amdgpu_reset_context *reset_context); +int emu_soc_asic_init (struct amdgpu_device *adev);/*
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +87 -63
179 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 4/10 drm/amdgpu: Add reset on init handler for XGMI
In reply to Lijo LazarIn some cases, device needs to be reset before first use. Add handlers for doing device reset during driver init sequence.
---
v2:
Use consistent naming scheme for functions/variables (Alex Deucher)
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 149 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 5 + 3 files changed, 155 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -562,6 +562,7 @@ enum amd_reset_method {AMD_RESET_METHOD_MODE2 ,AMD_RESET_METHOD_BACO ,AMD_RESET_METHOD_PCI , + AMD_RESET_METHOD_ON_INIT, }; struct amdgpu_video_codec_info {
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +149 -0
155 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +5 -0
@@ -153,4 +153,9 @@ void amdgpu_reset_get_desc(struct amdgpu_reset_context *rst_ctxt, char *buf,for (i =0 ; (i <AMDGPU_RESET_MAX_HANDLERS ) && \ (handler = (*reset_ctl->reset_handlers)[i]); \ ++i) + +extern struct amdgpu_reset_handler xgmi_reset_on_init_handler; +int amdgpu_reset_do_xgmi_reset_on_init ( +struct amdgpu_reset_context *reset_context); +#endif
Signature · 1 line
2.25.1
PATCH v2 5/10 drm/amdgpu: Add helper to initialize badpage info
In reply to Lijo LazarAdd a separate function to read badpage data during initialization. Reading bad pages will need hardware access and cannot be done during reset. Hence in cases where device needs a full reset during init itself, attempting to read will cause a deadlock.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 56 +++++++++++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 4 +- 3 files changed, 41 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2953,7 +2953,7 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)* Note: theoretically, this should be called before all vram allocations * to protect retired page from abusing */ - r =amdgpu_ras_recovery_init (adev); + r =amdgpu_ras_recovery_init (adev, true);if (r) goto init_failed;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +38 -18
70 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2 -2
@@ -736,8 +736,8 @@ struct amdgpu_ras_block_hw_ops {* 8: feature disable */ - -int amdgpu_ras_recovery_init (struct amdgpu_device *adev); +int amdgpu_ras_init_badpage_info (struct amdgpu_device *adev); +int amdgpu_ras_recovery_init (struct amdgpu_device *adev,bool init_bp_info);void amdgpu_ras_resume (struct amdgpu_device *adev);void amdgpu_ras_suspend (struct amdgpu_device *adev);
Signature · 1 line
2.25.1
PATCH v2 6/10 drm/amdgpu: Refactor XGMI reset on init handling
In reply to Lijo LazarUse XGMI hive information to rely on resetting XGMI devices on initialization rather than using mgpu structure. mgpu structure may have other devices as well.
---
v2:
Use consistent naming scheme for functions/variables (Alex Deucher) Use renamed init level id - AMDGPU_INIT_LEVEL_MINIMAL_XGMI
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 6 -- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 73 ++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 + drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 +++-- drivers/gpu/drm/amd/amdgpu/soc15.c | 5 ++ 6 files changed, 91 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -4
@@ -164,7 +164,8 @@ struct amdgpu_init_level amdgpu_init_minimal_xgmi = { .level = AMDGPU_INIT_LEVEL_MINIMAL_XGMI, .hwini_ip_block_mask =BIT (AMD_IP_BLOCK_TYPE_GMC ) |BIT (AMD_IP_BLOCK_TYPE_SMC ) | -BIT (AMD_IP_BLOCK_TYPE_COMMON ) |BIT (AMD_IP_BLOCK_TYPE_IH ) +BIT (AMD_IP_BLOCK_TYPE_COMMON ) |BIT (AMD_IP_BLOCK_TYPE_IH ) | +BIT (AMD_IP_BLOCK_TYPE_PSP ) }; static inline bool amdgpu_ip_member_of_hwini(struct amdgpu_device *adev,
@@ -2840,6 +2841,7 @@ static int amdgpu_device_init_schedulers(struct amdgpu_device *adev)*/ static int amdgpu_device_ip_init (struct amdgpu_device *adev) { +bool init_badpage;int i, r; r =amdgpu_ras_init (adev);
@@ -2953,7 +2955,8 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)* Note: theoretically, this should be called before all vram allocations * to protect retired page from abusing */ - r =amdgpu_ras_recovery_init (adev, true); + init_badpage = (adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL_XGMI ); + r =amdgpu_ras_recovery_init (adev, init_badpage);if (r) goto init_failed;
@@ -4514,8 +4517,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,vga_switcheroo_init_domain_pm_ops (adev->dev, &adev->vga_pm_domain);if (adev->init_lvl->level ==AMDGPU_INIT_LEVEL_MINIMAL_XGMI ) -queue_delayed_work (system_wq, &mgpu_info.delayed_reset_work, -msecs_to_jiffies (AMDGPU_RESUME_MS )); +amdgpu_xgmi_reset_on_init (adev);amdgpu_device_check_iommu_direct_map (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -6
@@ -3216,12 +3216,6 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev, bool init_bp_info) max_eeprom_records_count =amdgpu_ras_eeprom_max_record_count (&con->eeprom_control);amdgpu_ras_validate_threshold (adev, max_eeprom_records_count); -/* Todo: During test the SMU might fail to read the eeprom through I2C -* when the GPU is pending on XGMI reset during probe time -* (Mostly after second bus reset), skip it now -*/ -if (adev->init_lvl->level ==AMDGPU_INIT_LEVEL_MINIMAL_XGMI ) -return 0 ;if (init_bp_info) { ret =amdgpu_ras_init_badpage_info (adev);if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +68 -5
94 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +2 -0
@@ -45,6 +45,7 @@ struct amdgpu_hive_info {struct amdgpu_reset_domain *reset_domain;atomic_t ras_recovery;struct ras_event_manager event_mgr; +struct work_struct reset_on_init_work; };struct amdgpu_pcs_ras_field {
@@ -75,5 +76,6 @@ static inline bool amdgpu_xgmi_same_hive(struct amdgpu_device *adev, adev->gmc.xgmi.hive_id == bo_adev->gmc.xgmi.hive_id); }int amdgpu_xgmi_ras_sw_init (struct amdgpu_device *adev); +int amdgpu_xgmi_reset_on_init (struct amdgpu_device *adev);#endif
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +10 -4
@@ -2413,11 +2413,17 @@ static int gmc_v9_0_hw_fini(void *handle)if (adev->mmhub.funcs->update_power_gating) adev->mmhub.funcs->update_power_gating (adev, false); -amdgpu_irq_put (adev, &adev->gmc.vm_fault,0 ); +/* +* For minimal init, late_init is not called, hence VM fault/RAS irqs +* are not enabled. +*/ +if (adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL_XGMI ) { +amdgpu_irq_put (adev, &adev->gmc.vm_fault,0 ); -if (adev->gmc.ecc_irq.funcs && -amdgpu_ras_is_supported (adev,AMDGPU_RAS_BLOCK__UMC )) -amdgpu_irq_put (adev, &adev->gmc.ecc_irq,0 ); +if (adev->gmc.ecc_irq.funcs && +amdgpu_ras_is_supported (adev,AMDGPU_RAS_BLOCK__UMC )) +amdgpu_irq_put (adev, &adev->gmc.ecc_irq,0 ); + }return 0 ; }
drivers/gpu/drm/amd/amdgpu/soc15.c +5 -0
@@ -1295,7 +1295,12 @@ static int soc15_common_hw_fini(void *handle)if (amdgpu_sriov_vf (adev))xgpu_ai_mailbox_put_irq (adev); +/* +* For minimal init, late_init is not called, hence RAS irqs are not +* enabled. +*/ if ((!amdgpu_sriov_vf (adev)) && + (adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL_XGMI ) && adev->nbio.ras_if &&amdgpu_ras_is_supported (adev, adev->nbio.ras_if->block)) { if (adev->nbio.ras &&
Signature · 1 line
2.25.1
PATCH v2 7/10 drm/amdgpu: Drop delayed reset work handler
In reply to Lijo LazarDrop delayed reset work handler as it is no longer used.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 -- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 80 ------------------------- 2 files changed, 84 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -4
@@ -131,10 +131,6 @@ struct amdgpu_mgpu_info {uint32_t num_gpu;uint32_t num_dgpu;uint32_t num_apu; - -/* delayed reset_func for XGMI configuration if necessary */ -struct delayed_work delayed_reset_work; -bool pending_reset; };enum amdgpu_ss {
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -80
98 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 8/10 drm/amdgpu: Support reset-on-init on select SOCs
In reply to Lijo LazarAdd XGMI reset on init support to aldebaran and SOCs with GC v9.4.3.
---
v2:
Use renamed variable
drivers/gpu/drm/amd/amdgpu/aldebaran.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/aldebaran.c +1 -0
@@ -417,6 +417,7 @@ static struct amdgpu_reset_handler aldebaran_mode2_handler = {static struct amdgpu_reset_handler *aldebaran_rst_handlers[AMDGPU_RESET_MAX_HANDLERS ] = { &aldebaran_mode2_handler, + &xgmi_reset_on_init_handler, };int aldebaran_reset_init (struct amdgpu_device *adev)
Signature · 1 line
2.25.1
PATCH v2 9/10 drm/amdgpu: Add interface for TOS reload cases
In reply to Lijo LazarAdd interface to check if a different TOS needs to be loaded than the one which is which is already active on the SOC. Presently the interface is restricted to specific variants of PSPv13.0.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 3 +++ drivers/gpu/drm/amd/amdgpu/psp_v13_0.c | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +13 -0
@@ -2264,6 +2264,19 @@ bool amdgpu_psp_get_ras_capability(struct psp_context *psp) } } +bool amdgpu_psp_tos_reload_needed (struct amdgpu_device *adev) +{ +struct psp_context *psp = &adev->psp; + +if (amdgpu_sriov_vf (adev)) +return false; + +if (psp->funcs && psp->funcs->is_reload_needed) +return psp->funcs->is_reload_needed (psp); + +return false; +} +static int psp_hw_start (struct psp_context *psp) {struct amdgpu_device *adev = psp->adev;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +3 -0
@@ -138,6 +138,7 @@ struct psp_funcs {int (*vbflash_stat)(struct psp_context *psp);int (*fatal_error_recovery_quirk)(struct psp_context *psp);bool (*get_ras_capability)(struct psp_context *psp); +bool (*is_reload_needed)(struct psp_context *psp); };struct ta_funcs {
@@ -553,4 +554,6 @@ int is_psp_fw_valid(struct psp_bin_desc bin);int amdgpu_psp_wait_for_bootloader (struct amdgpu_device *adev);bool amdgpu_psp_get_ras_capability (struct psp_context *psp); +bool amdgpu_psp_tos_reload_needed (struct amdgpu_device *adev); +#endif
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +25 -0
@@ -807,6 +807,30 @@ static bool psp_v13_0_get_ras_capability(struct psp_context *psp) } } +static bool psp_v13_0_is_reload_needed (struct psp_context *psp) +{ +uint32_t ucode_ver; + +if (!psp_v13_0_is_sos_alive (psp)) +return false; + +/* Restrict reload support only to specific IP versions */ +switch (amdgpu_ip_version (psp->adev,MP0_HWIP ,0 )) { +case IP_VERSION (13 ,0 ,2 ): +case IP_VERSION (13 ,0 ,6 ): +case IP_VERSION (13 ,0 ,14 ): +/* TOS version read from microcode header */ + ucode_ver = psp->sos.fw_version; +/* Read TOS version from hardware */ +psp_v13_0_init_sos_version (psp); +return (ucode_ver != psp->sos.fw_version); +default : +return false; + } + +return false; +} +static const struct psp_funcs psp_v13_0_funcs = { .init_microcode = psp_v13_0_init_microcode, .wait_for_bootloader = psp_v13_0_wait_for_bootloader_steady_state,
@@ -830,6 +854,7 @@ static const struct psp_funcs psp_v13_0_funcs = { .vbflash_stat = psp_v13_0_vbflash_status, .fatal_error_recovery_quirk = psp_v13_0_fatal_error_recovery_quirk, .get_ras_capability = psp_v13_0_get_ras_capability, + .is_reload_needed = psp_v13_0_is_reload_needed, };void psp_v13_0_set_psp_funcs (struct psp_context *psp)
Signature · 1 line
2.25.1
PATCH v2 10/10 drm/amdgpu: Add PSP reload case to reset-on-init
In reply to Lijo LazarA reset on initialization will be needed if a new PSP TOS needs to be loaded than the one currently active on the system. This is possible only on SOCs which support a full device reset which results in unload of active PSP TOS.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc15.c +2 -0
@@ -829,6 +829,8 @@ static bool soc15_need_reset_on_init(struct amdgpu_device *adev)if (adev->asic_type ==CHIP_RENOIR )return true; +if (amdgpu_psp_tos_reload_needed (adev)) +return true;/* Just return false for soc15 GPUs. Reset does not seem to * be necessary. */
Signature · 1 line
2.25.1