drm/amd/ras: initialize CPER after XGMI reset on init
Subsystems (2)
PATCH 1/1 drm/amd/ras: initialize CPER after XGMI reset on init
The XGMI reset-on-init path can run while the device is still at the minimal init level, such as during an NPS memory partition switch. In that flow the normal RAS IP block hw_init is skipped, so unified RAS is not enabled when the early CPER initialization is attempted.
Resume RAS after the XGMI reset-on-init completes and retry CPER initialization for devices that still do not have CPER enabled. This lets the CPER ring come up once RAS is ready while keeping the path a no-op for devices where CPER was already initialized.
CPER may now be initialized after the normal debugfs setup has already walked the ring list, so register the CPER ring debugfs entry from the retry path when debugfs is available. Track CPER ring debugfs registration to avoid duplicate registration and clear that state when CPER is torn down.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cper.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 15 +++++++++++++++ 4 files changed, 22 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c +1 -0
@@ -504,6 +504,7 @@ int amdgpu_cper_fini(struct amdgpu_device *adev)return 0 ; adev->cper.enabled = false; + adev->cper.ring_debugfs_registered = false;amdgpu_ring_fini (&(adev->cper.ring_buf)); adev->cper.count =0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_cper.h +1 -0
@@ -51,6 +51,7 @@ enum amdgpu_cper_type {struct amdgpu_cper {bool enabled; +bool ring_debugfs_registered;atomic_t unique_id;struct mutex cper_lock;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +5 -0
@@ -2184,8 +2184,13 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)if (!ring)continue ; +if (ring == &adev->cper.ring_buf && + adev->cper.ring_debugfs_registered) +continue ;amdgpu_debugfs_ring_init (adev, ring); +if (ring == &adev->cper.ring_buf) + adev->cper.ring_debugfs_registered = true; }for (i =0 ; i < adev->vcn.num_vcn_inst; i++) {
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +15 -0
@@ -1400,6 +1400,21 @@ static void amdgpu_xgmi_reset_on_init_work(struct work_struct *work)* initialized, and for non-uniras devices. */ amdgpu_ras_resume_after_reset (tmp_adev); + +if (!tmp_adev->cper.enabled) { + r =amdgpu_cper_init (tmp_adev); +if (r) +dev_err (tmp_adev->dev,"failed to initialize CPER after XGMI reset-on-init\n" ); +#if defined(CONFIG_DEBUG_FS ) + else if (tmp_adev->cper.enabled && + !tmp_adev->cper.ring_debugfs_registered && + adev_to_drm(tmp_adev)->primary->debugfs_root) { +amdgpu_debugfs_ring_init (tmp_adev, + &tmp_adev->cper.ring_buf); + tmp_adev->cper.ring_debugfs_registered = true; + } +#endif + } } }
Signature · 1 line
2.34.1
Quoted 53 lines · Xiang Liu
The XGMI reset-on-init path can run while the device is still at the minimal init level, such as during an NPS memory partition switch. In that flow the normal RAS IP block
hw_initis skipped, so unified RAS is not enabled when the early CPER initialization is attempted.Resume RAS after the XGMI reset-on-init completes and retry CPER initialization for devices that still do not have CPER enabled. This lets the CPER ring come up once RAS is ready while keeping the path a no-op for devices where CPER was already initialized.
CPER may now be initialized after the normal debugfs setup has already walked the ring list, so register the CPER ring debugfs entry from the retry path when debugfs is available. Track CPER ring debugfs registration to avoid duplicate registration and clear that state when CPER is torn down.
Signed-off-by Xiang Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cper.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 15 +++++++++++++++ 4 files changed, 22 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c +1
-0@@ -504,6 +504,7 @@ int amdgpu_cper_fini(struct amdgpu_device *adev)return 0 ; adev->cper.enabled = false; + adev->cper.ring_debugfs_registered = false;amdgpu_ring_fini (&(adev->cper.ring_buf)); adev->cper.count =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_cper.h +1
-0@@ -51,6 +51,7 @@ enum amdgpu_cper_type {struct amdgpu_cper {bool enabled; +bool ring_debugfs_registered;atomic_t unique_id;struct mutex cper_lock;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device *adev) · line 2189
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0@@ -2184,8 +2184,13 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)if (!ring)continue ; +if (ring == &adev->cper.ring_buf && + adev->cper.ring_debugfs_registered) +continue ;
Instead of a new flag, can this check if (!adev->cper.enabled)?>
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0amdgpu_debugfs_ring_init (adev, ring); +if (ring == &adev->cper.ring_buf) + adev->cper.ring_debugfs_registered = true; }for (i =0 ; i < adev->vcn.num_vcn_inst; i++) {drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +4
-0@@ -1400,6 +1400,21 @@ static void amdgpu_xgmi_reset_on_init_work(struct work_struct *work)* initialized, and for non-uniras devices. */ amdgpu_ras_resume_after_reset (tmp_adev); + +if (!tmp_adev->cper.enabled) { + r =amdgpu_cper_init (tmp_adev); +if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c static void amdgpu_xgmi_reset_on_init_work(struct work_struct *work) · line 1416
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +10
-0+dev_err (tmp_adev->dev,"failed to initialize CPER after XGMI reset-on-init\n" ); +#if defined(CONFIG_DEBUG_FS ) + else if (tmp_adev->cper.enabled && + !tmp_adev->cper.ring_debugfs_registered && + adev_to_drm(tmp_adev)->primary->debugfs_root) { +amdgpu_debugfs_ring_init (tmp_adev, + &tmp_adev->cper.ring_buf); + tmp_adev->cper.ring_debugfs_registered = true; + } +#endif
Here it could then init both debugfs and cper together since cper is enabled only at this point.
BTW, is it possible to call both inside amdgpu_ras_resume_after_reset? If not, better to create a wrapper function like amdgpu_cper_deferred_init or similar and move inside that.
Thanks,
Lijo
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +1
-0+ } } }
AMD General
Thanks, will improve this.
Best Regards,
Liu, Xiang
________________________________
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, July 14, 2026 6:16 PM
To: Liu, Xiang(Dean) <[email protected]>; [email protected] <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: Re: [PATCH] drm/amd/ras: initialize CPER after XGMI reset on init
Quoted 53 lines · Xiang Liu
The XGMI reset-on-init path can run while the device is still at the minimal init level, such as during an NPS memory partition switch. In that flow the normal RAS IP block
hw_initis skipped, so unified RAS is not enabled when the early CPER initialization is attempted.Resume RAS after the XGMI reset-on-init completes and retry CPER initialization for devices that still do not have CPER enabled. This lets the CPER ring come up once RAS is ready while keeping the path a no-op for devices where CPER was already initialized.
CPER may now be initialized after the normal debugfs setup has already walked the ring list, so register the CPER ring debugfs entry from the retry path when debugfs is available. Track CPER ring debugfs registration to avoid duplicate registration and clear that state when CPER is torn down.
Signed-off-by Xiang Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cper.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 15 +++++++++++++++ 4 files changed, 22 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c +1
-0@@ -504,6 +504,7 @@ int amdgpu_cper_fini(struct amdgpu_device *adev)return 0 ; adev->cper.enabled = false; + adev->cper.ring_debugfs_registered = false;amdgpu_ring_fini (&(adev->cper.ring_buf)); adev->cper.count =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_cper.h +1
-0@@ -51,6 +51,7 @@ enum amdgpu_cper_type {struct amdgpu_cper {bool enabled; +bool ring_debugfs_registered;atomic_t unique_id;struct mutex cper_lock;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device *adev) · line 2189
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0@@ -2184,8 +2184,13 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)if (!ring)continue ; +if (ring == &adev->cper.ring_buf && + adev->cper.ring_debugfs_registered) +continue ;
Instead of a new flag, can this check if (!adev->cper.enabled)?>
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0amdgpu_debugfs_ring_init (adev, ring); +if (ring == &adev->cper.ring_buf) + adev->cper.ring_debugfs_registered = true; }for (i =0 ; i < adev->vcn.num_vcn_inst; i++) {drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +4
-0@@ -1400,6 +1400,21 @@ static void amdgpu_xgmi_reset_on_init_work(struct work_struct *work)* initialized, and for non-uniras devices. */ amdgpu_ras_resume_after_reset (tmp_adev); + +if (!tmp_adev->cper.enabled) { + r =amdgpu_cper_init (tmp_adev); +if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c static void amdgpu_xgmi_reset_on_init_work(struct work_struct *work) · line 1416
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +10
-0+dev_err (tmp_adev->dev,"failed to initialize CPER after XGMI reset-on-init\n" ); +#if defined(CONFIG_DEBUG_FS ) + else if (tmp_adev->cper.enabled && + !tmp_adev->cper.ring_debugfs_registered && + adev_to_drm(tmp_adev)->primary->debugfs_root) { +amdgpu_debugfs_ring_init (tmp_adev, + &tmp_adev->cper.ring_buf); + tmp_adev->cper.ring_debugfs_registered = true; + } +#endif
Here it could then init both debugfs and cper together since cper is enabled only at this point.
BTW, is it possible to call both inside amdgpu_ras_resume_after_reset? If not, better to create a wrapper function like amdgpu_cper_deferred_init or similar and move inside that.
Thanks,
Lijo
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +1
-0+ } } }