Support XGMI reset on init
Subsystems (3)
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.
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 | 21 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 245 +++++++++++------- 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 | 148 +++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 4 + drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 72 ++++- 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, 492 insertions(+), 214 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/10 drm/amdgpu: Add init levels
Add init levels to define the level to which device needs to be initialized.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 14 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 54 ++++++++++++++++++++++ 2 files changed, 68 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +14 -0
@@ -820,6 +820,16 @@ struct amdgpu_mqd { struct amdgpu_mqd_prop *p); }; +enum amdgpu_init_lvl_id { +AMDGPU_INIT_LEVEL_DEFAULT , +AMDGPU_INIT_LEVEL_MINIMAL , +}; + +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 +1179,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 +1635,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 +54 -0
96 lines not on this page · raw message
Signature · 1 line
2.25.1
RE: [PATCH 01/10] drm/amdgpu: Add init levels
[AMD Official Use Only - AMD Internal Distribution Only]
Comments inline.
Thanks,
Feifei
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Monday, September 2, 2024 3:34 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH 01/10] drm/amdgpu: Add init levels
Add init levels to define the level to which device needs to be initialized.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 14 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 54 ++++++++++++++++++++++ 2 files changed, 68 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +12 -0
@@ -820,6 +820,16 @@ struct amdgpu_mqd { struct amdgpu_mqd_prop *p); }; +enum amdgpu_init_lvl_id { +AMDGPU_INIT_LEVEL_DEFAULT , +AMDGPU_INIT_LEVEL_MINIMAL , +}; + +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 +1179,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 +1635,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 +35 -0
@@ -144,6 +144,42 @@ const char *amdgpu_asic_name[] = { "LAST", }; +#define AMDGPU_IP_BLK_MASK_ALL GENMASK(AMDGPU_MAX_IP_NUM - 1, 0) + +struct amdgpu_init_level amdgpu_init_default = { + .level =AMDGPU_INIT_LEVEL_DEFAULT , + .hwini_ip_block_mask =AMDGPU_IP_BLK_MASK_ALL , }; + +struct amdgpu_init_level amdgpu_init_minimal = { + .level =AMDGPU_INIT_LEVEL_MINIMAL , + .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_DEFAULT : + adev->init_lvl = &amdgpu_init_default; +break ; +case AMDGPU_INIT_LEVEL_MINIMAL : + adev->init_lvl = &amdgpu_init_minimal; +break ; +default : + adev->init_lvl = &amdgpu_init_default; +break ; + } +} +static inline void amdgpu_device_stop_pending_resets (struct amdgpu_device *adev);/**
@@ -2633,6 +2669,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 ;
[Feifei]: If xgmi-reset-init (mode1) not applicable to sriov VF, above check in amdgpu_device_ip_hw_init_phase1() is redundant.
In amdgpu_device_ip_hw_init_phase1(), it only hw_init 2 ips in BM: AMD_IP_BLOCK_TYPE_COMMON/ AMD_IP_BLOCK_TYPE_IH
And add one more PSP in VF. In BM, both COMMON and IH are minimal supported ips.
But harmless to keep it here.
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 +2697,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 +2723,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 +2849,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 +4246,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
amdgpu_device_set_mcbp(adev);+ amdgpu_set_init_level(adev, AMDGPU_INIT_LEVEL_DEFAULT);
+ adev->init_lvl = &amdgpu_init_default;
[Feifei]: We can just keep amdgpu_set_init_level(adev, AMDGPU_INIT_LEVEL_DEFAULT); and drop adev->init_lvl = &amdgpu_init_default; They're doing the same thing.
/* early init functions */
r = amdgpu_device_ip_early_init(adev);
if (r)
@@ -5473,6 +5525,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);--
2.25.1
Re: [PATCH 01/10] drm/amdgpu: Add init levels
In reply to Lijo LazarQuoted 15 lines · Lijo Lazar
Add init levels to define the level to which device needs to be initialized.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 14 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 54 ++++++++++++++++++++++ 2 files changed, 68 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_mqd { · line 825
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-0@@ -820,6 +820,16 @@ struct amdgpu_mqd { struct amdgpu_mqd_prop *p); }; +enum amdgpu_init_lvl_id { +AMDGPU_INIT_LEVEL_DEFAULT , +AMDGPU_INIT_LEVEL_MINIMAL ,
Add some comments here to define what they mean? E.g.,
+ AMDGPU_INIT_LEVEL_MINIMAL, /* minimum needed for reset at load time */
Quoted 49 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +11
-0+}; + +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 +1179,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 +1635,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 +15
-0@@ -144,6 +144,42 @@ const char *amdgpu_asic_name[] = { "LAST", }; +#define AMDGPU_IP_BLK_MASK_ALL GENMASK(AMDGPU_MAX_IP_NUM - 1, 0) + +struct amdgpu_init_level amdgpu_init_default = { + .level =AMDGPU_INIT_LEVEL_DEFAULT , + .hwini_ip_block_mask =AMDGPU_IP_BLK_MASK_ALL , +}; + +struct amdgpu_init_level amdgpu_init_minimal = { + .level =AMDGPU_INIT_LEVEL_MINIMAL , + .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,
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c const char *amdgpu_asic_name[] = { · line 171
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-0+ 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_DEFAULT :
Can move the default case here.
Quoted 57 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +25
-0+ adev->init_lvl = &amdgpu_init_default; +break ; +case AMDGPU_INIT_LEVEL_MINIMAL : + adev->init_lvl = &amdgpu_init_minimal; +break ; +default : + adev->init_lvl = &amdgpu_init_default; +break ; + } +} +static inline void amdgpu_device_stop_pending_resets (struct amdgpu_device *adev);/** @@ -2633,6 +2669,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 +2697,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 +2723,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 +2849,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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 4248
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4196,6 +4246,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,amdgpu_device_set_mcbp (adev);
Add a comment here to make it clear where and why we change the init level.
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 4250
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0+amdgpu_set_init_level (adev,AMDGPU_INIT_LEVEL_DEFAULT ); + adev->init_lvl = &amdgpu_init_default;
This pointer assignment can be dropped.
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-1/* early init functions */ r =amdgpu_device_ip_early_init (adev);if (r)@@ -5473,6 +5525,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); --2.25.1
Re: [PATCH 01/10] drm/amdgpu: Add init levels
Quoted 20 lines · Alex Deucher
Quoted 18 lines · Lijo Lazar
Add init levels to define the level to which device needs to be initialized.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 14 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 54 ++++++++++++++++++++++ 2 files changed, 68 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0@@ -820,6 +820,16 @@ struct amdgpu_mqd { struct amdgpu_mqd_prop *p); };
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_mqd { · line 825
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-0+enum amdgpu_init_lvl_id { +AMDGPU_INIT_LEVEL_DEFAULT , +AMDGPU_INIT_LEVEL_MINIMAL ,Add some comments here to define what they mean? E.g.,
+
AMDGPU_INIT_LEVEL_MINIMAL, /* minimum needed for reset at load time */
Or maybe:
AMDGPU_INIT_LEVEL_MINIMAL_RESET_ON_INIT
to make it explicit?
Quoted 146 lines
Quoted 50 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +11
-0+}; + +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 +1179,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 +1635,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 +15
-0@@ -144,6 +144,42 @@ const char *amdgpu_asic_name[] = { "LAST", }; +#define AMDGPU_IP_BLK_MASK_ALL GENMASK(AMDGPU_MAX_IP_NUM - 1, 0) + +struct amdgpu_init_level amdgpu_init_default = { + .level =AMDGPU_INIT_LEVEL_DEFAULT , + .hwini_ip_block_mask =AMDGPU_IP_BLK_MASK_ALL , +}; + +struct amdgpu_init_level amdgpu_init_minimal = { + .level =AMDGPU_INIT_LEVEL_MINIMAL , + .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,drivers/gpu/drm/amd/amdgpu/amdgpu_device.c const char *amdgpu_asic_name[] = { · line 171
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-0+ 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_DEFAULT :Can move the default case here.
Quoted 57 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +25
-0+ adev->init_lvl = &amdgpu_init_default; +break ; +case AMDGPU_INIT_LEVEL_MINIMAL : + adev->init_lvl = &amdgpu_init_minimal; +break ; +default : + adev->init_lvl = &amdgpu_init_default; +break ; + } +} +static inline void amdgpu_device_stop_pending_resets (struct amdgpu_device *adev);/** @@ -2633,6 +2669,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 +2697,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 +2723,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 +2849,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);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 4248
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4196,6 +4246,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,amdgpu_device_set_mcbp (adev);Add a comment here to make it clear where and why we change the init level.
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 4250
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0+amdgpu_set_init_level (adev,AMDGPU_INIT_LEVEL_DEFAULT ); + adev->init_lvl = &amdgpu_init_default;This pointer assignment can be dropped.
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-1/* early init functions */ r =amdgpu_device_ip_early_init (adev);if (r)@@ -5473,6 +5525,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); --2.25.1
PATCH 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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++--------------- 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, 13 insertions(+), 33 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -26
@@ -1691,7 +1691,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 )return false;if (adev->has_hw_reset) {
@@ -2985,7 +2985,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 ) {kgd2kfd_init_zone_device (adev);amdgpu_amdkfd_device_init (adev); }
@@ -3499,14 +3499,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
@@ -4320,20 +4315,7 @@ 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 ); }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);
@@ -4441,7 +4423,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 ) { r =amdgpu_device_ip_late_init (adev);if (r) {dev_err (adev->dev,"amdgpu_device_ip_late_init failed\n" );
@@ -4518,7 +4500,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 )queue_delayed_work (system_wq, &mgpu_info.delayed_reset_work,msecs_to_jiffies (AMDGPU_RESUME_MS ));
@@ -5490,7 +5472,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 )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 ) &&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 ) &&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 )) 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 )) {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
RE: [PATCH 02/10] drm/amdgpu: Use init level for pending_reset flag
[AMD Official Use Only - AMD Internal Distribution Only]
Comment inline.
Thanks,
Feifei
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Monday, September 2, 2024 3:34 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH 02/10] drm/amdgpu: Use init level for pending_reset flag
Drop pending_reset flag in gmc block. Instead use init level to determine which type of init is preferred - in this case MINIMAL.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++--------------- 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, 13 insertions(+), 33 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -9
@@ -1691,7 +1691,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 )return false;if (adev->has_hw_reset) {
@@ -2985,7 +2985,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 ) {kgd2kfd_init_zone_device (adev);amdgpu_amdkfd_device_init (adev); }
@@ -3499,14 +3499,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 ; - }
[Feifei]: AMDGPU_INIT_LEVEL_MINIMAL indicate the minimal necessary blocks which need to do hw_init if SMC need to handle the mode1 reset. Though in newer ASICs it is smc doing the reset, in some old one, it is MP0.
Is it more readable if we use naming like AMDGPU_INIT_LEVEL_MINIMAL_SMC to avoid confusion ?
/* skip suspend of gfx/mes and psp for S0ix
* gfx is in gfxoff state, so on resume it will exit gfxoff just @@ -4320,20 +4315,7 @@ 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);
} 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);
@@ -4441,7 +4423,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) {
r = amdgpu_device_ip_late_init(adev);
if (r) {
dev_err(adev->dev, "amdgpu_device_ip_late_init failed\n"); @@ -4518,7 +4500,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)
queue_delayed_work(system_wq, &mgpu_info.delayed_reset_work,
msecs_to_jiffies(AMDGPU_RESUME_MS));@@ -5490,7 +5472,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;
} elsedrivers/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 */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index 4d951a1baefa..33b2adffd58b 100644
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 )return 0 ; ret =amdgpu_ras_eeprom_init (&con->eeprom_control);/*
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +2 -2
@@ -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 ) &&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 ) &&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))
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 )) {
[Feifei] Is it a typo? If adev->init_lvl->level taking place of adev->gmc.xgmi.pending_reset, here should be(adev->init_lvl->level == AMDGPU_INIT_LEVEL_MINIMAL)
if (amdgpu_ip_version(adev, MP1_HWIP, 0) ==
IP_VERSION(11, 0, 2)) {
data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL_ARCT);--
2.25.1
Re: [PATCH 02/10] drm/amdgpu: Use init level for pending_reset flag
Quoted 63 lines · Feifei
[AMD Official Use Only - AMD Internal Distribution Only]
Comment inline.
Thanks,
Feifei-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Monday, September 2, 2024 3:34 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH 02/10] drm/amdgpu: Use init level forpending_resetflagDrop
pending_resetflag in gmc block. Instead use init level to determine which type of init is preferred - in this case MINIMAL.Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++--------------- 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, 13 insertions(+), 33 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-9@@ -1691,7 +1691,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 )return false;if (adev->has_hw_reset) {@@ -2985,7 +2985,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 ) {kgd2kfd_init_zone_device (adev);amdgpu_amdkfd_device_init (adev); }@@ -3499,14 +3499,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 ; - }
Quoted 2 lines
[Feifei]:
AMDGPU_INIT_LEVEL_MINIMALindicate the minimal necessary blocks which need to dohw_initif SMC need to handle the mode1 reset. Though in newer ASICs it is smc doing the reset, in some old one, it is MP0.
Is it more readable if we use naming likeAMDGPU_INIT_LEVEL_MINIMAL_SMCto avoid confusion ?
Original intention for levels is like -
Define a single 'minimal' level init required for the SOC. Further
levels like suspend, s0i3, emulation/simulation etc. may be introduced later which defines the level of initialization required for those scenarios. Basically, the idea was to make it SOC specific with a callback.
It is kept this way now as the immediate purpose is to support 'minimal' init required for XGMI-reset-on-init scenario for limited SOCs. In that sense, this could be renamed that way also.
Quoted 121 lines
/* skip suspend of gfx/mes and psp for S0ix * gfx is in gfxoff state, so on resume it will exit gfxoff just @@ -4320,20 +4315,7 @@ 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");drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-15- 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 ); }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);@@ -4441,7 +4423,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 ) { r =amdgpu_device_ip_late_init (adev);if (r) { dev_err(adev->dev, "amdgpu_device_ip_late_init failed\n"); @@ -4518,7 +4500,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,if (px) vga_switcheroo_init_domain_pm_ops(adev->dev, &adev->vga_pm_domain);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-2-if (adev->gmc.xgmi.pending_reset) +if (adev->init_lvl->level ==AMDGPU_INIT_LEVEL_MINIMAL )queue_delayed_work (system_wq, &mgpu_info.delayed_reset_work,msecs_to_jiffies (AMDGPU_RESUME_MS ));@@ -5490,7 +5472,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 */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.hindex
4d951a1baefa..33b2adffd58b100644drivers/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 )return 0 ; ret =amdgpu_ras_eeprom_init (&con->eeprom_control);/* drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +2
-2@@ -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 ) &&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 ) &&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)} }drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +1
-1-if (!ret && !adev->gmc.xgmi.pending_reset) +if (!ret && (adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL )) ret =amdgpu_xgmi_sysfs_add_dev_info (adev, hive); exit_unlock:drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +0
-0
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state) · line 1623
Quoted 9 lines
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)) { [Feifei] Is it a typo? If adev->init_lvl->level taking place of adev->gmc.xgmi.pending_reset, here should be(adev->init_lvl->level == AMDGPU_INIT_LEVEL_MINIMAL)
Yes, this is incorrect. Thanks for catching.
Thanks,
Lijo
Quoted 7 lines
if (amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(11, 0, 2)) { data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL_ARCT);--
2.25.1
RE: [PATCH 02/10] drm/amdgpu: Use init level for pending_reset flag
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 2 lines
Quoted 2 lines
It is kept this way now as the immediate purpose is to support 'minimal'
init required for XGMI-reset-on-init scenario for limited SOCs. In that sense, this could be renamed that way also.
Maybe adding comments of the MINIMAL like above explanation(minimal ip blocks required in xgmi-reset-on-init scenario) in [PATCH 01/10] drm/amdgpu: Add init levels , could be more readable.
Thanks,
Feifei
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, September 4, 2024 11:24 AM
To: Xu, Feifei <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 02/10] drm/amdgpu: Use init level for pending_reset flag
Quoted 68 lines · Feifei
[AMD Official Use Only - AMD Internal Distribution Only]
Comment inline.
Thanks,
Feifei-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Monday, September 2, 2024 3:34 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH 02/10] drm/amdgpu: Use init level forpending_resetflagDrop
pending_resetflag in gmc block. Instead use init level to determine which type of init is preferred - in this case MINIMAL.Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++--------------- 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, 13 insertions(+), 33 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-9@@ -1691,7 +1691,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 )return false;if (adev->has_hw_reset) {@@ -2985,7 +2985,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 ) {kgd2kfd_init_zone_device (adev);amdgpu_amdkfd_device_init (adev); }@@ -3499,14 +3499,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 ; - }
Quoted 2 lines
[Feifei]:
AMDGPU_INIT_LEVEL_MINIMALindicate the minimal necessary blocks which need to dohw_initif SMC need to handle the mode1 reset. Though in newer ASICs it is smc doing the reset, in some old one, it is MP0.
Is it more readable if we use naming likeAMDGPU_INIT_LEVEL_MINIMAL_SMCto avoid confusion ?
Original intention for levels is like -
Define a single 'minimal' level init required for the SOC. Further levels like suspend, s0i3, emulation/simulation etc. may be introduced later which defines the level of initialization required for those scenarios. Basically, the idea was to make it SOC specific with a callback.
It is kept this way now as the immediate purpose is to support 'minimal'
init required for XGMI-reset-on-init scenario for limited SOCs. In that sense, this could be renamed that way also.
Quoted 140 lines
/* skip suspend of gfx/mes and psp for S0ix * gfx is in gfxoff state, so on resume it will exit gfxoff just @@ -4320,20 +4315,7 @@ 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");drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-16- 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 ); }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); @@ -4441,7 +4423,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 ) { r =amdgpu_device_ip_late_init (adev);if (r) { dev_err(adev->dev, "amdgpu_device_ip_late_init failed\n"); @@ -4518,7 +4500,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, if (px) vga_switcheroo_init_domain_pm_ops(adev->dev,
&adev->vga_pm_domain);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1-if (adev->gmc.xgmi.pending_reset) +if (adev->init_lvl->level ==AMDGPU_INIT_LEVEL_MINIMAL ) queue_delayed_work(system_wq, &mgpu_info.delayed_reset_work,
msecs_to_jiffies(AMDGPU_RESUME_MS));drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1@@ -5490,7 +5472,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 */ diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.hb/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index4d951a1baefa..33b2adffd58b100644drivers/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 )return 0 ; ret =amdgpu_ras_eeprom_init (&con->eeprom_control);/* drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +2
-2@@ -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 ) &&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 ) &&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) } }drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +2
-1-if (!ret && !adev->gmc.xgmi.pending_reset) +if (!ret && (adev->init_lvl->level != +AMDGPU_INIT_LEVEL_MINIMAL )) 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 )) {
Quoted 3 lines
[Feifei] Is it a typo? If
adev->init_lvl->leveltaking place ofadev->gmc.xgmi.pending_reset, here shouldbe(adev->init_lvl->level == AMDGPU_INIT_LEVEL_MINIMAL)
Yes, this is incorrect. Thanks for catching.
Thanks,
Lijo
Quoted 8 lines
if (amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(11, 0, 2)) { data = RREG32_SOC15(THM, 0,
mmTHM_BACO_CNTL_ARCT);
--
2.25.1
Re: [PATCH 02/10] drm/amdgpu: Use init level for pending_reset flag
In reply to Lijo LazarWith the error Feifei mentioned fixed,
Quoted 186 lines · Lijo Lazar
Drop
pending_resetflag in gmc block. Instead use init level to determine which type of init is preferred - in this case MINIMAL.Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++--------------- 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, 13 insertions(+), 33 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-26@@ -1691,7 +1691,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 )return false;if (adev->has_hw_reset) {@@ -2985,7 +2985,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 ) {kgd2kfd_init_zone_device (adev);amdgpu_amdkfd_device_init (adev); }@@ -3499,14 +3499,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 @@ -4320,20 +4315,7 @@ 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 ); }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);@@ -4441,7 +4423,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 ) { r =amdgpu_device_ip_late_init (adev);if (r) {dev_err (adev->dev,"amdgpu_device_ip_late_init failed\n" );@@ -4518,7 +4500,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 )queue_delayed_work (system_wq, &mgpu_info.delayed_reset_work,msecs_to_jiffies (AMDGPU_RESUME_MS ));@@ -5490,7 +5472,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 )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 ) &&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 ) &&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 )) ret =amdgpu_xgmi_sysfs_add_dev_info (adev, hive); exit_unlock:drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +2
-2@@ -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 )) {if (amdgpu_ip_version (adev,MP1_HWIP ,0 ) ==IP_VERSION (11 ,0 ,2 )) { data =RREG32_SOC15 (THM ,0 , mmTHM_BACO_CNTL_ARCT); --2.25.1
PATCH 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
@@ -1276,6 +1276,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
Re: [PATCH 03/10] drm/amdgpu: Separate reinitialization after reset
Quoted 5 lines · Lijo Lazar
Move the reinitialization part after a reset to another function. No functional changes.
Signed-off-by Lijo Lazar <[email protected]>
Quoted 207 lines
--- 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@@ -1276,6 +1276,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
-64@@ -5440,75 +5440,25 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,return r; } -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) { -struct amdgpu_device *tmp_adev =NULL ; -bool need_full_reset, skip_hw_reset, vram_lost = false; -int r =0 ; - -/* Try reset handler method first */ - tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, - reset_list); - - reset_context->reset_device_list = device_list_handle; - r =amdgpu_reset_perform_reset (tmp_adev, reset_context); -/* If reset handler not implemented, continue; otherwise return */ -if (r == -EOPNOTSUPP ) - r =0 ; -else -return r; - -/* Reset handler not implemented, use the default method */ - need_full_reset = -test_bit (AMDGPU_NEED_FULL_RESET , &reset_context->flags); - skip_hw_reset =test_bit (AMDGPU_SKIP_HW_RESET , &reset_context->flags); - -/* -* ASIC reset has to be done on all XGMI hive nodes ASAP -* to allow proper links negotiation in FW (within 1 sec) -*/ -if (!skip_hw_reset && need_full_reset) { -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 ) { -if (!queue_work (system_unbound_wq, &tmp_adev->xgmi_reset_work)) - r = -EALREADY ; - }else - r =amdgpu_asic_reset (tmp_adev); - -if (r) { -dev_err (tmp_adev->dev,"ASIC reset failed with error, %d for drm dev, %s" , - r,adev_to_drm (tmp_adev)->unique); - goto out; - } - } +struct list_head *device_list_handle; +bool full_reset, vram_lost = false; +struct amdgpu_device *tmp_adev; +int r; -/* For XGMI wait for all resets to complete before proceed */ -if (!r) { -list_for_each_entry (tmp_adev, device_list_handle, reset_list) { -if (tmp_adev->gmc.xgmi.num_physical_nodes >1 ) { -flush_work (&tmp_adev->xgmi_reset_work); - r = tmp_adev->asic_reset_res; -if (r) -break ; - } - } - } - } + device_list_handle = reset_context->reset_device_list; -if (!r &&amdgpu_ras_intr_triggered ()) { -list_for_each_entry (tmp_adev, device_list_handle, reset_list) { -amdgpu_ras_reset_error_count (tmp_adev,AMDGPU_RAS_BLOCK__MMHUB ); - } +if (!device_list_handle) +return -EINVAL ; -amdgpu_ras_intr_cleared (); - } + full_reset =test_bit (AMDGPU_NEED_FULL_RESET , &reset_context->flags); + r =0 ;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) { +if (full_reset) {/* post card */ amdgpu_ras_set_fed (tmp_adev, false); r =amdgpu_device_asic_init (tmp_adev);@@ -5598,7 +5548,6 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, r =amdgpu_ib_ring_tests (tmp_adev);if (r) {dev_err (tmp_adev->dev,"ib ring test failed (%d).\n" , r); - need_full_reset = true; r = -EAGAIN ; goto end; }@@ -5611,10 +5560,85 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, } end: -if (need_full_reset) +return r; +} + +int amdgpu_do_asic_reset (struct list_head *device_list_handle, +struct amdgpu_reset_context *reset_context) +{ +struct amdgpu_device *tmp_adev =NULL ; +bool need_full_reset, skip_hw_reset; +int r =0 ; + +/* Try reset handler method first */ + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, + reset_list); + + reset_context->reset_device_list = device_list_handle; + r =amdgpu_reset_perform_reset (tmp_adev, reset_context); +/* If reset handler not implemented, continue; otherwise return */ +if (r == -EOPNOTSUPP ) + r =0 ; +else +return r; + +/* Reset handler not implemented, use the default method */ + need_full_reset = +test_bit (AMDGPU_NEED_FULL_RESET , &reset_context->flags); + skip_hw_reset =test_bit (AMDGPU_SKIP_HW_RESET , &reset_context->flags); + +/* +* ASIC reset has to be done on all XGMI hive nodes ASAP +* to allow proper links negotiation in FW (within 1 sec) +*/ +if (!skip_hw_reset && need_full_reset) { +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 ) { +if (!queue_work (system_unbound_wq, + &tmp_adev->xgmi_reset_work)) + r = -EALREADY ; + }else + r =amdgpu_asic_reset (tmp_adev); + +if (r) { +dev_err (tmp_adev->dev, +"ASIC reset failed with error, %d for drm dev, %s" , + r,adev_to_drm (tmp_adev)->unique); + goto out; + } + } + +/* For XGMI wait for all resets to complete before proceed */ +if (!r) { +list_for_each_entry (tmp_adev, device_list_handle, + reset_list) { +if (tmp_adev->gmc.xgmi.num_physical_nodes >1 ) { +flush_work (&tmp_adev->xgmi_reset_work); + r = tmp_adev->asic_reset_res; +if (r) +break ; + } + } + } + } + +if (!r &&amdgpu_ras_intr_triggered ()) { +list_for_each_entry (tmp_adev, device_list_handle, reset_list) { +amdgpu_ras_reset_error_count (tmp_adev, +AMDGPU_RAS_BLOCK__MMHUB ); + } + +amdgpu_ras_intr_cleared (); + } + + r =amdgpu_device_reinit_after_reset (reset_context); +if (r == -EAGAIN )set_bit (AMDGPU_NEED_FULL_RESET , &reset_context->flags);else clear_bit (AMDGPU_NEED_FULL_RESET , &reset_context->flags); + +out:return r; } --2.25.1
PATCH 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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 148 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 4 + 3 files changed, 153 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 +148 -0
154 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +4 -0
@@ -153,4 +153,8 @@ 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 reset_on_init_handler; +int amdgpu_reset_xgmi_rst_on_init (struct amdgpu_reset_context *reset_context); +#endif
Signature · 1 line
2.25.1
Re: [PATCH 04/10] drm/amdgpu: Add reset on init handler for XGMI
Quoted 28 lines · Lijo Lazar
In some cases, device needs to be reset before first use. Add handlers for doing device reset during driver init sequence.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 148 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 4 + 3 files changed, 153 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 +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c line 29
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1
-0@@ -26,6 +26,154 @@#include "sienna_cichlid.h" #include "smu_v13_0_10.h" +static int amdgpu_reset_xgmi_rst_on_init_suspend (struct amdgpu_device *adev)
maybe write out reset_on_init rather than rst_on_init? or use the roi or r_o_i for consistency?
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +18
-0+{ +int i, r; + +for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) { +if (!adev->ip_blocks[i].status.valid) +continue ; +if (!adev->ip_blocks[i].status.hw) +continue ; +/* displays are handled in phase1 */ +if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_DCE ) +continue ; + +/* XXX handle errors */ + r = adev->ip_blocks[i].version->funcs->suspend (adev); +/* XXX handle errors */ +if (r) { +dev_err (adev->dev,"suspend of IP block <%s> failed %d" , + adev->ip_blocks[i].version->funcs->name, r);
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c line 57
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +10
-0+ } + adev->ip_blocks[i].status.hw = false; + } + +return 0 ; +} + +static int +amdgpu_reset_xgmi_roi_prep_hwctxt (struct amdgpu_reset_control *reset_ctl, +struct amdgpu_reset_context *reset_context)
use consistent naming; e.g., roi vs reset_on_init.
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +32
-0+{ +struct list_head *reset_device_list = reset_context->reset_device_list; +struct amdgpu_device *tmp_adev; +int r; + +list_for_each_entry (tmp_adev, reset_device_list, reset_list) { +amdgpu_unregister_gpu_instance (tmp_adev); + r =amdgpu_reset_xgmi_rst_on_init_suspend (tmp_adev); +if (r) { +dev_err (tmp_adev->dev, +"xgmi reset on init: prepare for reset failed" ); +return r; + } + } + +return r; +} + +static int +amdgpu_reset_xgmi_roi_restore_hwctxt (struct amdgpu_reset_control *reset_ctl, +struct amdgpu_reset_context *reset_context) +{ +struct list_head *reset_device_list = reset_context->reset_device_list; +struct amdgpu_device *tmp_adev =NULL ; +int r; + + r =amdgpu_device_reinit_after_reset (reset_context); +if (r) +return r; +list_for_each_entry (tmp_adev, reset_device_list, reset_list) { +if (!tmp_adev->kfd.init_complete) { +kgd2kfd_init_zone_device (tmp_adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c line 99
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +10
-0+amdgpu_amdkfd_device_init (tmp_adev); +amdgpu_amdkfd_drm_client_create (tmp_adev); + } + } + +return r; +} + +static int +amdgpu_reset_xgmi_roi_perform_reset(struct amdgpu_reset_control *reset_ctl,
Same comment here.
Quoted 37 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +37
-0+ struct amdgpu_reset_context *reset_context) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)reset_ctl->handle; +struct list_head *reset_device_list = reset_context->reset_device_list; +struct amdgpu_device *tmp_adev =NULL ; +int r; + +dev_dbg (adev->dev,"xgmi roi - hw reset\n" ); + +list_for_each_entry (tmp_adev, reset_device_list, reset_list) { +mutex_lock (&tmp_adev->reset_cntl->reset_lock); + tmp_adev->reset_cntl->active_reset = +amdgpu_asic_reset_method (adev); + } + r =0 ; +/* Mode1 reset needs to be triggered on all devices together */ +list_for_each_entry (tmp_adev, reset_device_list, reset_list) { +/* For XGMI run all resets in parallel to speed up the process */ +if (!queue_work (system_unbound_wq, &tmp_adev->xgmi_reset_work)) + r = -EALREADY ; +if (r) { +dev_err (tmp_adev->dev, +"xgmi reset on init: reset failed with error, %d" , + r); +break ; + } + } + +/* For XGMI wait for all resets to complete before proceed */ +if (!r) { +list_for_each_entry (tmp_adev, reset_device_list, reset_list) { +flush_work (&tmp_adev->xgmi_reset_work); + r = tmp_adev->asic_reset_res; +if (r) +break ; + } + }
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c line 146
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +10
-0+ +list_for_each_entry (tmp_adev, reset_device_list, reset_list) { +mutex_unlock (&tmp_adev->reset_cntl->reset_lock); + tmp_adev->reset_cntl->active_reset =AMD_RESET_METHOD_NONE ; + } + +return r; +} + +int amdgpu_reset_xgmi_rst_on_init (struct amdgpu_reset_context *reset_context)
and here.
Alex
Quoted 49 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +30
-0+{ +struct list_head *reset_device_list = reset_context->reset_device_list; +struct amdgpu_device *adev; +int r; + +if (!reset_device_list ||list_empty (reset_device_list) || +list_is_singular (reset_device_list)) +return -EINVAL ; + + adev = list_first_entry(reset_device_list, struct amdgpu_device, + reset_list); + r =amdgpu_reset_prepare_hwcontext (adev, reset_context); +if (r) +return r; + + r =amdgpu_reset_perform_reset (adev, reset_context); + +return r; +} + +struct amdgpu_reset_handler reset_on_init_handler = { + .reset_method =AMD_RESET_METHOD_ON_INIT , + .prepare_env =NULL , + .prepare_hwcontext = amdgpu_reset_xgmi_roi_prep_hwctxt, + .perform_reset = amdgpu_reset_xgmi_roi_perform_reset, + .restore_hwcontext = amdgpu_reset_xgmi_roi_restore_hwctxt, + .restore_env =NULL , + .do_reset =NULL , +}; +int amdgpu_reset_init (struct amdgpu_device *adev) {int ret =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +4
-1@@ -153,4 +153,8 @@ 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 reset_on_init_handler; +int amdgpu_reset_xgmi_rst_on_init (struct amdgpu_reset_context *reset_context); +#endif --2.25.1
PATCH 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
@@ -2945,7 +2945,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
Re: [PATCH 05/10] drm/amdgpu: Add helper to initialize badpage info
Quoted 7 lines · Lijo Lazar
Add 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.
Signed-off-by Lijo Lazar <[email protected]>
Quoted 113 lines
--- 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@@ -2945,7 +2945,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@@ -3146,7 +3146,42 @@ static int amdgpu_ras_page_retirement_thread(void *param)return 0 ; } -int amdgpu_ras_recovery_init (struct amdgpu_device *adev) +int amdgpu_ras_init_badpage_info (struct amdgpu_device *adev) +{ +struct amdgpu_ras *con =amdgpu_ras_get_context (adev); +int ret; + +if (!con ||amdgpu_sriov_vf (adev)) +return 0 ; + + ret =amdgpu_ras_eeprom_init (&con->eeprom_control); + +if (ret) +return ret; + +/* HW not usable */ +if (amdgpu_ras_is_rma (adev)) +return -EHWPOISON ; + +if (con->eeprom_control.ras_num_recs) { + ret =amdgpu_ras_load_bad_pages (adev); +if (ret) +return ret; + +amdgpu_dpm_send_hbm_bad_pages_num ( + adev, con->eeprom_control.ras_num_recs); + +if (con->update_channel_flag == true) { +amdgpu_dpm_send_hbm_bad_channel_flag ( + adev, con->eeprom_control.bad_channel_bitmap); + con->update_channel_flag = false; + } + } + +return ret; +} + +int amdgpu_ras_recovery_init (struct amdgpu_device *adev,bool init_bp_info) {struct amdgpu_ras *con =amdgpu_ras_get_context (adev);struct ras_err_handler_data **data;@@ -3187,25 +3222,10 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)*/ if (adev->init_lvl->level ==AMDGPU_INIT_LEVEL_MINIMAL )return 0 ; - ret =amdgpu_ras_eeprom_init (&con->eeprom_control); -/* -* This calling fails when is_rma is true or -* ret != 0. -*/ -if (amdgpu_ras_is_rma (adev) || ret) - goto free; - -if (con->eeprom_control.ras_num_recs) { - ret =amdgpu_ras_load_bad_pages (adev); +if (init_bp_info) { + ret =amdgpu_ras_init_badpage_info (adev);if (ret) goto free; - -amdgpu_dpm_send_hbm_bad_pages_num (adev, con->eeprom_control.ras_num_recs); - -if (con->update_channel_flag == true) { -amdgpu_dpm_send_hbm_bad_channel_flag (adev, con->eeprom_control.bad_channel_bitmap); - con->update_channel_flag = false; - } }mutex_init (&con->page_rsv_lock);drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2
-3@@ -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); --2.25.1
PATCH 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.
--- 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 | 72 ++++++++++++++++++++-- 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, 90 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -4
@@ -155,7 +155,8 @@ struct amdgpu_init_level amdgpu_init_minimal = { .level = AMDGPU_INIT_LEVEL_MINIMAL, .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,
@@ -2832,6 +2833,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);
@@ -2945,7 +2947,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 ); + r =amdgpu_ras_recovery_init (adev, init_badpage);if (r) goto init_failed;
@@ -4501,8 +4504,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 ) -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 ) -return 0 ;if (init_bp_info) { ret =amdgpu_ras_init_badpage_info (adev);if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +67 -5
93 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 roi_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 ) { +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 ) && adev->nbio.ras_if &&amdgpu_ras_is_supported (adev, adev->nbio.ras_if->block)) { if (adev->nbio.ras &&
Signature · 1 line
2.25.1
Re: [PATCH 06/10] drm/amdgpu: Refactor XGMI reset on init handling
Quoted 108 lines · Lijo Lazar
Use XGMI hive information to rely on resetting XGMI devices on initialization rather than using mgpu structure. mgpu structure may have other devices as well.
Signed-off-by Lijo Lazar <[email protected]>--- 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 | 72 ++++++++++++++++++++-- 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, 90 insertions(+), 19 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-4@@ -155,7 +155,8 @@ struct amdgpu_init_level amdgpu_init_minimal = { .level = AMDGPU_INIT_LEVEL_MINIMAL, .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,@@ -2832,6 +2833,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);@@ -2945,7 +2947,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 ); + r =amdgpu_ras_recovery_init (adev, init_badpage);if (r) goto init_failed;@@ -4501,8 +4504,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 ) -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 ) -return 0 ;if (init_bp_info) { ret =amdgpu_ras_init_badpage_info (adev);if (ret)drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +3
-5@@ -860,8 +860,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)if (!adev->gmc.xgmi.supported)return 0 ; -if ((adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL ) && -amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_PSP )) { +if (amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_PSP )) { ret =psp_xgmi_initialize (&adev->psp, false, true);if (ret) { dev_err(adev->dev,@@ -907,8 +906,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)task_barrier_add_task (&hive->tb); -if ((adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL ) && -amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_PSP )) { +if (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 */ if (tmp_adev != adev) {@@ -985,7 +983,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev) } } -if (!ret && (adev->init_lvl->level !=AMDGPU_INIT_LEVEL_MINIMAL )) +if (!ret) ret =amdgpu_xgmi_sysfs_add_dev_info (adev, hive); exit_unlock:
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c int amdgpu_xgmi_ras_sw_init(struct amdgpu_device *adev) · line 1502
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +2
-0@@ -1500,3 +1498,67 @@ int amdgpu_xgmi_ras_sw_init(struct amdgpu_device *adev)return 0 ; } + +static void amdgpu_xgmi_roi_handler (struct work_struct *work)
Use consistent naming for roi, depending on what you decide in the earlier patches. Other than that:
Quoted 127 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +62
-0+{ +struct amdgpu_hive_info *hive = + container_of(work, struct amdgpu_hive_info, roi_work); +struct amdgpu_reset_context reset_context; +struct amdgpu_device *tmp_adev; +struct list_head device_list; +int r; + +mutex_lock (&hive->hive_lock); + +INIT_LIST_HEAD (&device_list); +list_for_each_entry (tmp_adev, &hive->device_list, gmc.xgmi.head) +list_add_tail (&tmp_adev->reset_list, &device_list); + + tmp_adev = list_first_entry(&device_list, struct amdgpu_device, + reset_list); +amdgpu_device_lock_reset_domain (tmp_adev->reset_domain); + + reset_context.method =AMD_RESET_METHOD_ON_INIT ; + reset_context.reset_req_dev = tmp_adev; + reset_context.hive = hive; + reset_context.reset_device_list = &device_list; +set_bit (AMDGPU_NEED_FULL_RESET , &reset_context.flags); +set_bit (AMDGPU_SKIP_COREDUMP , &reset_context.flags); + +amdgpu_reset_xgmi_rst_on_init (&reset_context); +mutex_unlock (&hive->hive_lock); +amdgpu_device_unlock_reset_domain (tmp_adev->reset_domain); + +list_for_each_entry (tmp_adev, &hive->device_list, gmc.xgmi.head) { + r =amdgpu_ras_init_badpage_info (tmp_adev); +if (r && r != -EHWPOISON ) +dev_err (tmp_adev->dev, +"error during bad page data initializtion" ); + } +} + +static void amdgpu_xgmi_schedule_reset_on_init (struct amdgpu_hive_info *hive) +{ +INIT_WORK (&hive->roi_work, amdgpu_xgmi_roi_handler); +amdgpu_reset_domain_schedule (hive->reset_domain, &hive->roi_work); +} + +int amdgpu_xgmi_reset_on_init (struct amdgpu_device *adev) +{ +struct amdgpu_hive_info *hive; +int r, num_devs; + + hive =amdgpu_get_xgmi_hive (adev); +if (!hive) +return -EINVAL ; + +mutex_lock (&hive->hive_lock); + num_devs =atomic_read (&hive->number_devices); +if (num_devs == adev->gmc.xgmi.num_physical_nodes) +amdgpu_xgmi_schedule_reset_on_init (hive); + +mutex_unlock (&hive->hive_lock); +amdgpu_put_xgmi_hive (hive); + +return r; +}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 roi_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 ) { +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
-1@@ -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 ) && adev->nbio.ras_if &&amdgpu_ras_is_supported (adev, adev->nbio.ras_if->block)) { if (adev->nbio.ras && --2.25.1
PATCH 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
Re: [PATCH 07/10] drm/amdgpu: Drop delayed reset work handler
Quoted 4 lines · Lijo Lazar
Drop delayed reset work handler as it is no longer used.
Signed-off-by Lijo Lazar <[email protected]>
Quoted 128 lines
--- 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
-81@@ -221,8 +221,6 @@ int amdgpu_wbrf = -1;int amdgpu_damage_clips =-1 ;/* auto */ int amdgpu_umsch_mm_fwlog; -static void amdgpu_drv_delayed_reset_work_handler (struct work_struct *work); - DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, "DRM_UT_CORE", "DRM_UT_DRIVER",@@ -237,9 +235,6 @@ DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,struct amdgpu_mgpu_info mgpu_info = { .mutex =__MUTEX_INITIALIZER (mgpu_info.mutex), - .delayed_reset_work =__DELAYED_WORK_INITIALIZER ( - mgpu_info.delayed_reset_work, - amdgpu_drv_delayed_reset_work_handler,0 ), };int amdgpu_ras_enable =-1 ;uint amdgpu_ras_mask =0xffffffff ;@@ -2455,81 +2450,6 @@ amdgpu_pci_shutdown(struct pci_dev *pdev) adev->mp1_state =PP_MP1_STATE_NONE ; } -/** -* amdgpu_drv_delayed_reset_work_handler - work handler for reset -* -* @work: work_struct. -*/ -static void amdgpu_drv_delayed_reset_work_handler (struct work_struct *work) -{ -struct list_head device_list; -struct amdgpu_device *adev; -int i, r; -struct amdgpu_reset_context reset_context; - -memset (&reset_context,0 ,sizeof (reset_context)); - -mutex_lock (&mgpu_info.mutex); -if (mgpu_info.pending_reset == true) { -mutex_unlock (&mgpu_info.mutex); -return ; - } - mgpu_info.pending_reset = true; -mutex_unlock (&mgpu_info.mutex); - -/* Use a common context, just need to make sure full reset is done */ - reset_context.method =AMD_RESET_METHOD_NONE ; -set_bit (AMDGPU_NEED_FULL_RESET , &reset_context.flags); - -for (i =0 ; i < mgpu_info.num_dgpu; i++) { - adev = mgpu_info.gpu_ins[i].adev; - reset_context.reset_req_dev = adev; - r =amdgpu_device_pre_asic_reset (adev, &reset_context); -if (r) { -dev_err (adev->dev,"GPU pre asic reset failed with err, %d for drm dev, %s " , - r,adev_to_drm (adev)->unique); - } -if (!queue_work (system_unbound_wq, &adev->xgmi_reset_work)) - r = -EALREADY ; - } -for (i =0 ; i < mgpu_info.num_dgpu; i++) { - adev = mgpu_info.gpu_ins[i].adev; -flush_work (&adev->xgmi_reset_work); - } - -/* reset function will rebuild the xgmi hive info , clear it now */ -for (i =0 ; i < mgpu_info.num_dgpu; i++) -amdgpu_xgmi_remove_device (mgpu_info.gpu_ins[i].adev); - -INIT_LIST_HEAD (&device_list); - -for (i =0 ; i < mgpu_info.num_dgpu; i++) -list_add_tail (&mgpu_info.gpu_ins[i].adev->reset_list, &device_list); - -/* unregister the GPU first, reset function will add them back */ -list_for_each_entry (adev, &device_list, reset_list) -amdgpu_unregister_gpu_instance (adev); - -/* Use a common context, just need to make sure full reset is done */ -set_bit (AMDGPU_SKIP_HW_RESET , &reset_context.flags); -set_bit (AMDGPU_SKIP_COREDUMP , &reset_context.flags); - r =amdgpu_do_asic_reset (&device_list, &reset_context); - -if (r) { -DRM_ERROR ("reinit gpus failure" ); -return ; - } -for (i =0 ; i < mgpu_info.num_dgpu; i++) { - adev = mgpu_info.gpu_ins[i].adev; -if (!adev->kfd.init_complete) { -kgd2kfd_init_zone_device (adev); -amdgpu_amdkfd_device_init (adev); -amdgpu_amdkfd_drm_client_create (adev); - } -amdgpu_ttm_set_buffer_funcs_status (adev, true); - } -} -static int amdgpu_pmops_prepare (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); --2.25.1
PATCH 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.
--- 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, + &reset_on_init_handler, };int aldebaran_reset_init (struct amdgpu_device *adev)
Signature · 1 line
2.25.1
Re: [PATCH 08/10] drm/amdgpu: Support reset-on-init on select SOCs
Quoted 4 lines · Lijo Lazar
Add XGMI reset on init support to aldebaran and SOCs with GC v9.4.3.
Signed-off-by Lijo Lazar <[email protected]>
Quoted 19 lines
--- drivers/gpu/drm/amd/amdgpu/aldebaran.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/aldebaran.c +1
-1@@ -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, + &reset_on_init_handler, };int aldebaran_reset_init (struct amdgpu_device *adev) --2.25.1
PATCH 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
Re: [PATCH 09/10] drm/amdgpu: Add interface for TOS reload cases
Quoted 6 lines · Lijo Lazar
Add 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.
Signed-off-by Lijo Lazar <[email protected]>
Quoted 95 lines
--- 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
-1@@ -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) --2.25.1
PATCH 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
Re: [PATCH 10/10] drm/amdgpu: Add PSP reload case to reset-on-init
Quoted 7 lines · Lijo Lazar
A 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.
Signed-off-by Lijo Lazar <[email protected]>
Quoted 20 lines
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/amdgpu/soc15.c +2
-1@@ -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. */ --2.25.1
Am 02.09.24 um 09:34 schrieb Lijo Lazar:
Quoted 24 lines
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.
Quoted 6 lines
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.
At least from the high level that sounds totally sane, but I have no idea where to get time from to review the details.
I need to discuss that with Alex and/or Tim. Maybe I can delegate some more work.
Christian.
Quoted 33 lines
Lijo Lazar (10):
drm/amdgpu: Add init levels
drm/amdgpu: Use init level forpending_resetflag 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-initdrivers/gpu/drm/amd/amdgpu/aldebaran.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu.h | 21 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 245 +++++++++++------- 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 | 148 +++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 4 + drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 72 ++++- 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, 492 insertions(+), 214 deletions(-)
[AMD Official Use Only - AMD Internal Distribution Only]
Patch3~10:
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Monday, September 2, 2024 3:34 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH 00/10] 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.
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 | 21 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 245 +++++++++++------- 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 | 148 +++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 4 + drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 72 ++++- 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, 492 insertions(+), 214 deletions(-)
--
2.25.1