* [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers
@ 2026-11-05 3:05 Jesse Zhang
2026-11-05 3:05 ` [PATCH v4 02/13] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed Jesse Zhang
` (13 more replies)
0 siblings, 14 replies; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
amdgpu_multi_ring_reset_helper_begin() and _end() take the device from
the guilty ring. A reset triggered by a hung user queue has no guilty
kernel ring, so pass the device explicitly and allow a NULL guilty ring.
No functional change.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c | 4 ++--
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 14 ++++++++------
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 6 ++++--
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
index 734f2a0bc79a..d0b0d3eaffc5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
@@ -465,11 +465,11 @@ int amdgpu_device_ip_soft_reset(struct amdgpu_ring *guilty_ring,
ring_type_mask = amdgpu_ring_mask_from_ip(ip_type);
amdgpu_device_lock_reset_domain(adev->reset_domain);
- amdgpu_multi_ring_reset_helper_begin(ring_type_mask, guilty_ring, guilty_fence);
+ amdgpu_multi_ring_reset_helper_begin(adev, ring_type_mask, guilty_ring, guilty_fence);
r = ip_block->version->funcs->soft_reset(ip_block);
- r = amdgpu_multi_ring_reset_helper_end(ring_type_mask, guilty_ring, r);
+ r = amdgpu_multi_ring_reset_helper_end(adev, ring_type_mask, guilty_ring, r);
amdgpu_device_unlock_reset_domain(adev->reset_domain);
if (r) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index 7b67e8cecca2..edae764eb0c4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -919,8 +919,9 @@ int amdgpu_ring_reset_helper_end(struct amdgpu_ring *ring,
/**
* amdgpu_multi_ring_reset_helper_begin() - Prepare multiple rings for a reset.
*
+ * @adev: amdgpu device
* @ring_type_mask: Bitmask of affected ring types
- * @guilty_ring: The ring which is guilty of causing a reset.
+ * @guilty_ring: The ring which is guilty of causing a reset, or NULL.
* @guilty_fence: The fence which didn't signal on the guilty ring.
*
* Useful when performing a GPU reset method that affects
@@ -938,11 +939,11 @@ int amdgpu_ring_reset_helper_end(struct amdgpu_ring *ring,
* After the reset is complete, the caller should then call
* amdgpu_multi_ring_reset_helper_end() to restore the rings.
*/
-void amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
+void amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device *adev,
+ const u32 ring_type_mask,
struct amdgpu_ring *guilty_ring,
struct amdgpu_fence *guilty_fence)
{
- struct amdgpu_device *adev = guilty_ring->adev;
struct amdgpu_fence *ring_guilty_fence;
struct amdgpu_ring *ring;
bool rings_busy;
@@ -1034,8 +1035,9 @@ void amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
/**
* amdgpu_multi_ring_reset_helper_end() - Prepare multiple rings for a reset.
*
+ * @adev: amdgpu device
* @ring_type_mask: Bitmask of affected ring types
- * @guilty_ring: The ring which is guilty of causing a reset.
+ * @guilty_ring: The ring which is guilty of causing a reset, or NULL.
* @ret: Return code from the reset function.
*
* After calling amdgpu_multi_ring_reset_helper_begin()
@@ -1046,10 +1048,10 @@ void amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
* be called to restore preemption state, but it won't attempt to
* fully restore the ring contents.
*/
-int amdgpu_multi_ring_reset_helper_end(const u32 ring_type_mask,
+int amdgpu_multi_ring_reset_helper_end(struct amdgpu_device *adev,
+ const u32 ring_type_mask,
struct amdgpu_ring *guilty_ring, int ret)
{
- struct amdgpu_device *adev = guilty_ring->adev;
struct amdgpu_ring *ring;
int i, r;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
index b2040f80b7f2..7e6ed43771f2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
@@ -637,10 +637,12 @@ void amdgpu_ring_reset_helper_begin(struct amdgpu_ring *ring,
struct amdgpu_fence *guilty_fence);
int amdgpu_ring_reset_helper_end(struct amdgpu_ring *ring,
struct amdgpu_fence *guilty_fence);
-void amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
+void amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device *adev,
+ const u32 ring_type_mask,
struct amdgpu_ring *guilty_ring,
struct amdgpu_fence *guilty_fence);
-int amdgpu_multi_ring_reset_helper_end(const u32 ring_type_mask,
+int amdgpu_multi_ring_reset_helper_end(struct amdgpu_device *adev,
+ const u32 ring_type_mask,
struct amdgpu_ring *guilty_ring, int ret);
bool amdgpu_ring_is_reset_type_supported(struct amdgpu_ring *ring,
u32 reset_type);
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 02/13] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-11 23:52 ` Daniel Campos Ramos
2026-11-19 11:34 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 03/13] drm/amdgpu: add an engine scope to the IP block soft reset Jesse Zhang
` (12 subsequent siblings)
13 siblings, 2 replies; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
From: Timur Kristóf <timur.kristof@gmail.com>
This is necessary to make soft reset work after a failed queue
reset. Otherwise the ring reset begin helper would clear out
the guilty fence and the backed up ring contents.
v2: skip the begin helper only for the guilty ring already backed up by
the failed ring reset, and keep backing up the other rings (Jesse).
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index edae764eb0c4..c71e1c3b6d7b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -1027,8 +1027,10 @@ void amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device *adev,
* Backup current contents of the ring.
* The helper takes care to only reemit unsignalled fences
* so we don't have to worry about that here.
+ * A failed ring reset of the same job already backed it up.
*/
- amdgpu_ring_reset_helper_begin(ring, ring_guilty_fence);
+ if (ring != guilty_ring || ring->guilty_fence != guilty_fence)
+ amdgpu_ring_reset_helper_begin(ring, ring_guilty_fence);
}
}
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 03/13] drm/amdgpu: add an engine scope to the IP block soft reset
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
2026-11-05 3:05 ` [PATCH v4 02/13] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:35 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 04/13] drm/amdgpu/gfx: add callbacks to save and restore a gfx HQD Jesse Zhang
` (11 subsequent siblings)
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
Some IP blocks have engines the hardware can reset on their own, eg.
the graphics and compute engines of the GFX IP. Add an optional
soft_reset_engine() callback, which resets the engine of a ring type and
recovers its user queues. amdgpu_device_ip_soft_reset() uses it instead
of soft_reset(), and then only stops and replays the rings of that type,
holding the reset domain for read: KFD can still add and remove queues
on the other engines.
A hung user queue has no kernel ring, so amdgpu_device_ip_soft_reset()
now takes the device and the ring type, and an optional guilty ring and
user queue.
v3: New patch, replaces the separate engine reset type and helper
(Timur).
v4: Fold the engine reset into amdgpu_device_ip_soft_reset(), and take
the ring type instead of a new engine enum (Timur).
Suggested-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c | 59 ++++++++++++++++--------
drivers/gpu/drm/amd/amdgpu/amdgpu_ip.h | 7 ++-
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 3 +-
drivers/gpu/drm/amd/include/amd_shared.h | 6 +++
4 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
index d0b0d3eaffc5..9d75bdb2c14b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
@@ -421,8 +421,11 @@ static u32 amdgpu_ring_mask_from_ip(const enum amd_ip_block_type ip_type)
/**
* amdgpu_device_ip_soft_reset() - Perform a graceful soft reset on an IP block.
*
- * @guilty_ring: The ring which is guilty of causing a reset.
- * @guilty_fence: The fence which didn't signal.
+ * @adev: amdgpu device
+ * @ring_type: The type of the ring or user queue that hung.
+ * @guilty_ring: The ring which is guilty of causing a reset, or NULL.
+ * @guilty_fence: The fence which didn't signal on @guilty_ring.
+ * @guilty_queue: The user queue which is guilty of causing a reset, or NULL.
*
* IP block soft reset is used when attempting to recover
* from a GPU hang in a situation where a more fine grained
@@ -430,55 +433,71 @@ static u32 amdgpu_ring_mask_from_ip(const enum amd_ip_block_type ip_type)
* resets all rings that belong to the same device IP block
* and re-initializes the device IP block.
*
+ * IP blocks implementing soft_reset_engine() only reset the engine of
+ * @ring_type and its rings, and recover its user queues.
+ *
* The reset is handled gracefully, meaning that we try to
* minimize collateral damage (ie. avoid rejecting non-guilty jobs)
* as well as back up and restore the contents of all rings
* so that the system can move on from the hang.
*/
-int amdgpu_device_ip_soft_reset(struct amdgpu_ring *guilty_ring,
- struct amdgpu_fence *guilty_fence)
+int amdgpu_device_ip_soft_reset(struct amdgpu_device *adev,
+ enum amdgpu_ring_type ring_type,
+ struct amdgpu_ring *guilty_ring,
+ struct amdgpu_fence *guilty_fence,
+ struct amdgpu_usermode_queue *guilty_queue)
{
- struct amdgpu_device *adev = guilty_ring->adev;
+ const struct amd_ip_funcs *funcs;
struct amdgpu_ip_block *ip_block;
enum amd_ip_block_type ip_type;
u32 ring_type_mask;
+ bool engine;
int r;
- ip_type = amdgpu_ip_from_ring(guilty_ring->funcs->type);
+ ip_type = amdgpu_ip_from_ring(ring_type);
ip_block = amdgpu_device_ip_get_ip_block(adev, ip_type);
if (unlikely(!ip_block)) {
- dev_warn(adev->dev, "IP block not found for ring %s\n",
- guilty_ring->name);
+ dev_warn(adev->dev, "IP block not found for ring type %d\n",
+ ring_type);
return -EOPNOTSUPP;
}
- if (!ip_block->version->funcs->soft_reset) {
+ funcs = ip_block->version->funcs;
+ engine = funcs->soft_reset_engine;
+ if (!engine && (!funcs->soft_reset || !guilty_ring)) {
dev_warn(adev->dev, "IP block soft reset not supported on %s\n",
- ip_block->version->funcs->name);
+ funcs->name);
return -EOPNOTSUPP;
}
- dev_err(adev->dev, "Starting %s IP block soft reset\n",
- ip_block->version->funcs->name);
-
- ring_type_mask = amdgpu_ring_mask_from_ip(ip_type);
+ dev_err(adev->dev, "Starting %s IP block soft reset\n", funcs->name);
- amdgpu_device_lock_reset_domain(adev->reset_domain);
+ /* An engine reset leaves the others running: let KFD add/remove queues. */
+ if (engine) {
+ ring_type_mask = BIT(ring_type);
+ down_read(&adev->reset_domain->sem);
+ } else {
+ ring_type_mask = amdgpu_ring_mask_from_ip(ip_type);
+ amdgpu_device_lock_reset_domain(adev->reset_domain);
+ }
amdgpu_multi_ring_reset_helper_begin(adev, ring_type_mask, guilty_ring, guilty_fence);
- r = ip_block->version->funcs->soft_reset(ip_block);
+ r = engine ? funcs->soft_reset_engine(ip_block, ring_type, guilty_queue) :
+ funcs->soft_reset(ip_block);
r = amdgpu_multi_ring_reset_helper_end(adev, ring_type_mask, guilty_ring, r);
- amdgpu_device_unlock_reset_domain(adev->reset_domain);
+ if (engine)
+ up_read(&adev->reset_domain->sem);
+ else
+ amdgpu_device_unlock_reset_domain(adev->reset_domain);
if (r) {
dev_err(adev->dev, "Failed %s IP block soft reset: %d\n",
- ip_block->version->funcs->name, r);
+ funcs->name, r);
return r;
}
- dev_err(adev->dev, "Successful %s IP block soft reset\n",
- ip_block->version->funcs->name);
+ dev_err(adev->dev, "Successful %s IP block soft reset\n", funcs->name);
return 0;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.h
index 5dd6273982c4..6532c16b1a15 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.h
@@ -158,7 +158,10 @@ int amdgpu_device_ip_wait_for_idle(struct amdgpu_device *adev,
enum amd_ip_block_type block_type);
bool amdgpu_device_ip_is_valid(struct amdgpu_device *adev,
enum amd_ip_block_type block_type);
-int amdgpu_device_ip_soft_reset(struct amdgpu_ring *guilty_ring,
- struct amdgpu_fence *guilty_fence);
+int amdgpu_device_ip_soft_reset(struct amdgpu_device *adev,
+ enum amdgpu_ring_type ring_type,
+ struct amdgpu_ring *guilty_ring,
+ struct amdgpu_fence *guilty_fence,
+ struct amdgpu_usermode_queue *guilty_queue);
#endif /* __AMDGPU_IP_H__ */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index 8689a3c933b2..cb72d273bd52 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -154,7 +154,8 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
/* Attempt an IP block soft reset, if supported. */
if (amdgpu_gpu_recovery &&
amdgpu_ring_is_reset_type_supported(ring, AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET)) {
- r = amdgpu_device_ip_soft_reset(ring, job->hw_fence);
+ r = amdgpu_device_ip_soft_reset(adev, ring->funcs->type, ring,
+ job->hw_fence, NULL);
if (!r) {
atomic_inc(&ring->adev->gpu_reset_counter);
drm_dev_wedged_event(adev_to_drm(adev), DRM_WEDGE_RECOVERY_NONE, info);
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index e81ce9d79009..06874a338b27 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -29,6 +29,7 @@
#define AMD_MAX_USEC_TIMEOUT 1000000 /* 1000 ms */
struct amdgpu_ip_block;
+struct amdgpu_usermode_queue;
/*
@@ -421,6 +422,7 @@ enum DC_DEBUG_MASK {
};
enum amd_dpm_forced_level;
+enum amdgpu_ring_type;
/**
* struct amd_ip_funcs - general hooks for managing amdgpu IP Blocks
@@ -441,6 +443,7 @@ enum amd_dpm_forced_level;
* @complete: handles IP specific changes after resume
* @wait_for_idle: poll for idle
* @soft_reset: soft reset the IP block
+ * @soft_reset_engine: soft reset the engine of a ring type and its user queues
* @set_clockgating_state: enable/disable cg for the IP block
* @set_powergating_state: enable/disable pg for the IP block
* @get_clockgating_state: get current clockgating status
@@ -469,6 +472,9 @@ struct amd_ip_funcs {
void (*complete)(struct amdgpu_ip_block *ip_block);
int (*wait_for_idle)(struct amdgpu_ip_block *ip_block);
int (*soft_reset)(struct amdgpu_ip_block *ip_block);
+ int (*soft_reset_engine)(struct amdgpu_ip_block *ip_block,
+ enum amdgpu_ring_type ring_type,
+ struct amdgpu_usermode_queue *guilty_queue);
int (*set_clockgating_state)(struct amdgpu_ip_block *ip_block,
enum amd_clockgating_state state);
int (*set_powergating_state)(struct amdgpu_ip_block *ip_block,
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 04/13] drm/amdgpu/gfx: add callbacks to save and restore a gfx HQD
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
2026-11-05 3:05 ` [PATCH v4 02/13] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed Jesse Zhang
2026-11-05 3:05 ` [PATCH v4 03/13] drm/amdgpu: add an engine scope to the IP block soft reset Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:35 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 05/13] drm/amdgpu/gfx12: " Jesse Zhang
` (10 subsequent siblings)
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
A gfx engine reset clears the HQD registers of the gfx queues, including
the only copy of the ring position of the queues MES didn't preempt.
MES doesn't save them in the MQD either when the engine hangs.
Add struct amdgpu_gfx_saved_hqd for that state, and gfx callbacks for
the gfx IP, which knows its registers and the layout of its MQD:
- save_hqd() saves the state of the gfx HQD of a doorbell;
- restore_hqd() writes it into the MQD after the reset, for MES to load
it into the HQD when it maps the queue again.
v4: Rename to save_hqd()/restore_hqd() and struct amdgpu_gfx_saved_hqd
(Timur).
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index 5939e1fb3b24..1c23e97fd04d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -345,6 +345,17 @@ struct amdgpu_gfx_shadow_info {
u32 eop_alignment;
};
+/* State of a gfx HQD that a gfx engine reset clears. */
+struct amdgpu_gfx_saved_hqd {
+ u32 doorbell_index;
+ u64 mqd_addr; /* the MQD loaded in the HQD */
+ bool on_hqd;
+ u64 wptr;
+ u32 offset;
+ u32 csmd_rptr;
+ bool connected; /* the queue the pipe executes */
+};
+
struct amdgpu_gfx_funcs {
/* get the gpu clock counter */
uint64_t (*get_gpu_clock_counter)(struct amdgpu_device *adev);
@@ -376,6 +387,17 @@ struct amdgpu_gfx_funcs {
/* find the gfx HQD slot (me/pipe/queue) for a doorbell */
bool (*detect_hung_queue)(struct amdgpu_device *adev, u32 doorbell_index,
u32 *me, u32 *pipe, u32 *queue);
+ /* save the state of the gfx HQD of a doorbell, if it has one */
+ bool (*save_hqd)(struct amdgpu_device *adev, u32 doorbell_index,
+ struct amdgpu_gfx_saved_hqd *hqd);
+ /*
+ * write the HQD state saved by save_hqd() into a gfx MQD, for MES to
+ * load it into the HQD when it maps the queue again;
+ * true if the work up to hqd->wptr was dropped
+ */
+ bool (*restore_hqd)(struct amdgpu_device *adev, void *mqd,
+ u32 ring_size,
+ const struct amdgpu_gfx_saved_hqd *hqd);
};
struct sq_work {
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 05/13] drm/amdgpu/gfx12: save and restore a gfx HQD
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (2 preceding siblings ...)
2026-11-05 3:05 ` [PATCH v4 04/13] drm/amdgpu/gfx: add callbacks to save and restore a gfx HQD Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:35 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 06/13] drm/amdgpu/gfx11: " Jesse Zhang
` (9 subsequent siblings)
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
Implement the gfx callbacks to save and restore a gfx HQD for gfx12:
- save_hqd() saves the HQD offset, CSMD read pointer and write pointer
of the gfx HQD of a doorbell, and whether the queue is the one
connected to its pipe;
- restore_hqd() writes them into the MQD after a reset, for MES to map
the queue again where it was. A queue switched out of the pipe resumes
from the preemption status the PFP saved in its MQD, also in the
middle of an IB. The queue the pipe was executing has its state in the
PFP, which the reset cleared: it restarts after the work submitted so
far instead, and that work is dropped.
v4: Rename to save_hqd()/restore_hqd() (Timur).
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 83 ++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
index cb15dad0e57b..484e876fe235 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
@@ -274,6 +274,11 @@ static void gfx_v12_0_set_imu_funcs(struct amdgpu_device *adev);
static int gfx_v12_0_get_cu_info(struct amdgpu_device *adev,
struct amdgpu_cu_info *cu_info);
static uint64_t gfx_v12_0_get_gpu_clock_counter(struct amdgpu_device *adev);
+static bool gfx_v12_0_save_hqd(struct amdgpu_device *adev, u32 doorbell_index,
+ struct amdgpu_gfx_saved_hqd *hqd);
+static bool gfx_v12_0_restore_hqd(struct amdgpu_device *adev, void *m,
+ u32 ring_size,
+ const struct amdgpu_gfx_saved_hqd *hqd);
static void gfx_v12_0_select_se_sh(struct amdgpu_device *adev, u32 se_num,
u32 sh_num, u32 instance, int xcc_id);
static u32 gfx_v12_0_get_wgp_active_bitmap_per_sh(struct amdgpu_device *adev);
@@ -962,6 +967,8 @@ static const struct amdgpu_gfx_funcs gfx_v12_0_gfx_funcs = {
.update_perfmon_mgcg = &gfx_v12_0_update_perf_clk,
.get_gfx_shadow_info = &gfx_v12_0_get_gfx_shadow_info,
.get_hdp_flush_mask = &amdgpu_gfx_get_hdp_flush_mask,
+ .save_hqd = &gfx_v12_0_save_hqd,
+ .restore_hqd = &gfx_v12_0_restore_hqd,
};
static int gfx_v12_0_gpu_early_init(struct amdgpu_device *adev)
@@ -3853,6 +3860,82 @@ static int gfx_v12_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
return -ETIMEDOUT;
}
+#define GFX12_HPD_QUEUE_STATE_CONNECTED_MIN 3
+#define GFX12_HPD_QUEUE_STATE_CONNECTED_MAX 15
+
+static bool gfx_v12_0_save_hqd(struct amdgpu_device *adev, u32 doorbell_index,
+ struct amdgpu_gfx_saved_hqd *hqd)
+{
+ u32 me, pipe, queue, status, state;
+
+ memset(hqd, 0, sizeof(*hqd));
+ hqd->doorbell_index = doorbell_index;
+ if (!gfx_v12_0_detect_hung_queue(adev, doorbell_index, &me, &pipe, &queue))
+ return true;
+
+ amdgpu_gfx_off_ctrl(adev, false);
+ mutex_lock(&adev->srbm_mutex);
+ soc24_grbm_select(adev, me, pipe, queue, 0);
+ hqd->on_hqd = RREG32_SOC15(GC, 0, regCP_GFX_HQD_ACTIVE) &
+ CP_GFX_HQD_ACTIVE__ACTIVE_MASK;
+ if (!hqd->on_hqd)
+ goto out;
+ hqd->mqd_addr = RREG32_SOC15(GC, 0, regCP_GFX_MQD_BASE_ADDR) |
+ (u64)RREG32_SOC15(GC, 0, regCP_GFX_MQD_BASE_ADDR_HI) << 32;
+ hqd->offset = RREG32_SOC15(GC, 0, regCP_GFX_HQD_OFFSET);
+ hqd->csmd_rptr = RREG32_SOC15(GC, 0, regCP_GFX_HQD_CSMD_RPTR);
+ hqd->wptr = RREG32_SOC15(GC, 0, regCP_GFX_HQD_WPTR) |
+ (u64)RREG32_SOC15(GC, 0, regCP_GFX_HQD_WPTR_HI) << 32;
+ status = RREG32_SOC15(GC, 0, regCP_GFX_HPD_STATUS0);
+ state = REG_GET_FIELD(status, CP_GFX_HPD_STATUS0, QUEUE_STATE);
+ hqd->connected =
+ state >= GFX12_HPD_QUEUE_STATE_CONNECTED_MIN &&
+ state <= GFX12_HPD_QUEUE_STATE_CONNECTED_MAX &&
+ REG_GET_FIELD(status, CP_GFX_HPD_STATUS0, MAPPED_QUEUE) == queue;
+out:
+ soc24_grbm_select(adev, 0, 0, 0, 0);
+ mutex_unlock(&adev->srbm_mutex);
+ amdgpu_gfx_off_ctrl(adev, true);
+
+ return true;
+}
+
+static bool gfx_v12_0_restore_hqd(struct amdgpu_device *adev, void *m,
+ u32 ring_size,
+ const struct amdgpu_gfx_saved_hqd *hqd)
+{
+ struct v12_gfx_mqd *mqd = m;
+ u32 wptr = lower_32_bits(hqd->wptr) & ((ring_size >> 2) - 1);
+ u32 *status;
+
+ /*
+ * MQD dwords 32-41 (reserved_32..41) are the PFP preemption status,
+ * mcbp_status_pfp: the offset and chained IB size and address of IB1
+ * (32-35) and IB2 (36-39), rb_preempt (40: preempted in the ring) and
+ * completion_status (41: 0 IB not started, 1 preempted inside an IB,
+ * 2 IB completed, 3 IB resumed). The PFP saves it when the queue is
+ * switched out of the pipe and resumes from it when the queue runs
+ * again, at the HQD offset. That survives the reset for a queue that
+ * was switched out. The queue the pipe executed has its state in the
+ * PFP, which the reset cleared: restart it at the write pointer with
+ * no IB to resume, and drop its work in flight.
+ */
+ if (hqd->connected) {
+ mqd->cp_gfx_hqd_offset = wptr;
+ mqd->cp_gfx_hqd_csmd_rptr = wptr;
+ for (status = &mqd->reserved_32; status <= &mqd->reserved_41; status++)
+ *status = 0;
+ } else {
+ mqd->cp_gfx_hqd_offset = hqd->offset;
+ mqd->cp_gfx_hqd_csmd_rptr = hqd->csmd_rptr;
+ }
+ mqd->cp_gfx_hqd_wptr = lower_32_bits(hqd->wptr);
+ mqd->cp_gfx_hqd_wptr_hi = upper_32_bits(hqd->wptr);
+ mqd->cp_gfx_hqd_active = 0;
+
+ return hqd->connected;
+}
+
static uint64_t gfx_v12_0_get_gpu_clock_counter(struct amdgpu_device *adev)
{
uint64_t clock = 0;
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 06/13] drm/amdgpu/gfx11: save and restore a gfx HQD
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (3 preceding siblings ...)
2026-11-05 3:05 ` [PATCH v4 05/13] drm/amdgpu/gfx12: " Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:36 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 07/13] drm/amdgpu/userq: add a helper to signal the fences of a queue up to a point Jesse Zhang
` (8 subsequent siblings)
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
Implement the gfx callbacks to save and restore a gfx HQD for gfx11:
- save_hqd() saves the HQD offset, CSMD read pointer and write pointer
of the gfx HQD of a doorbell, and whether the queue is the one
connected to its pipe;
- restore_hqd() writes them into the MQD after a reset, for MES to map
the queue again where it was. A queue switched out of the pipe resumes
from the preemption status the PFP saved in its MQD, also in the
middle of an IB. The queue the pipe was executing has its state in the
PFP, which the reset cleared: it restarts after the work submitted so
far instead, and that work is dropped.
v4: Rename to save_hqd()/restore_hqd() (Timur).
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 83 ++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index 430b8f3743b2..798015689f0c 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -365,6 +365,11 @@ static void gfx_v11_0_unset_safe_mode(struct amdgpu_device *adev, int xcc_id);
static void gfx_v11_0_update_spm_vmid(struct amdgpu_device *adev, int xcc_id,
unsigned int vmid);
static void gfx_v11_0_userq_priv_fault_work(struct work_struct *work);
+static bool gfx_v11_0_save_hqd(struct amdgpu_device *adev, u32 doorbell_index,
+ struct amdgpu_gfx_saved_hqd *hqd);
+static bool gfx_v11_0_restore_hqd(struct amdgpu_device *adev, void *m,
+ u32 ring_size,
+ const struct amdgpu_gfx_saved_hqd *hqd);
static void gfx_v11_0_update_perf_clk(struct amdgpu_device *adev,
bool enable);
@@ -1150,6 +1155,8 @@ static const struct amdgpu_gfx_funcs gfx_v11_0_gfx_funcs = {
.get_gfx_shadow_info = &gfx_v11_0_get_gfx_shadow_info,
.get_hdp_flush_mask = &amdgpu_gfx_get_hdp_flush_mask,
.detect_hung_queue = &gfx_v11_0_detect_hung_queue,
+ .save_hqd = &gfx_v11_0_save_hqd,
+ .restore_hqd = &gfx_v11_0_restore_hqd,
};
static int gfx_v11_0_gpu_early_init(struct amdgpu_device *adev)
@@ -6770,6 +6777,82 @@ static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)
amdgpu_ring_write(ring, gcr_cntl); /* GCR_CNTL */
}
+#define GFX11_HPD_QUEUE_STATE_CONNECTED_MIN 3
+#define GFX11_HPD_QUEUE_STATE_CONNECTED_MAX 15
+
+static bool gfx_v11_0_save_hqd(struct amdgpu_device *adev, u32 doorbell_index,
+ struct amdgpu_gfx_saved_hqd *hqd)
+{
+ u32 me, pipe, queue, status, state;
+
+ memset(hqd, 0, sizeof(*hqd));
+ hqd->doorbell_index = doorbell_index;
+ if (!gfx_v11_0_detect_hung_queue(adev, doorbell_index, &me, &pipe, &queue))
+ return true;
+
+ amdgpu_gfx_off_ctrl(adev, false);
+ mutex_lock(&adev->srbm_mutex);
+ soc21_grbm_select(adev, me, pipe, queue, 0);
+ hqd->on_hqd = RREG32_SOC15(GC, 0, regCP_GFX_HQD_ACTIVE) &
+ CP_GFX_HQD_ACTIVE__ACTIVE_MASK;
+ if (!hqd->on_hqd)
+ goto out;
+ hqd->mqd_addr = RREG32_SOC15(GC, 0, regCP_GFX_MQD_BASE_ADDR) |
+ (u64)RREG32_SOC15(GC, 0, regCP_GFX_MQD_BASE_ADDR_HI) << 32;
+ hqd->offset = RREG32_SOC15(GC, 0, regCP_GFX_HQD_OFFSET);
+ hqd->csmd_rptr = RREG32_SOC15(GC, 0, regCP_GFX_HQD_CSMD_RPTR);
+ hqd->wptr = RREG32_SOC15(GC, 0, regCP_GFX_HQD_WPTR) |
+ (u64)RREG32_SOC15(GC, 0, regCP_GFX_HQD_WPTR_HI) << 32;
+ status = RREG32_SOC15(GC, 0, regCP_GFX_HPD_STATUS0);
+ state = REG_GET_FIELD(status, CP_GFX_HPD_STATUS0, QUEUE_STATE);
+ hqd->connected =
+ state >= GFX11_HPD_QUEUE_STATE_CONNECTED_MIN &&
+ state <= GFX11_HPD_QUEUE_STATE_CONNECTED_MAX &&
+ REG_GET_FIELD(status, CP_GFX_HPD_STATUS0, MAPPED_QUEUE) == queue;
+out:
+ soc21_grbm_select(adev, 0, 0, 0, 0);
+ mutex_unlock(&adev->srbm_mutex);
+ amdgpu_gfx_off_ctrl(adev, true);
+
+ return true;
+}
+
+static bool gfx_v11_0_restore_hqd(struct amdgpu_device *adev, void *m,
+ u32 ring_size,
+ const struct amdgpu_gfx_saved_hqd *hqd)
+{
+ struct v11_gfx_mqd *mqd = m;
+ u32 wptr = lower_32_bits(hqd->wptr) & ((ring_size >> 2) - 1);
+ u32 *status;
+
+ /*
+ * MQD dwords 32-41 (reserved_32..41) are the PFP preemption status,
+ * mcbp_status_pfp: the offset and chained IB size and address of IB1
+ * (32-35) and IB2 (36-39), rb_preempt (40: preempted in the ring) and
+ * completion_status (41: 0 IB not started, 1 preempted inside an IB,
+ * 2 IB completed, 3 IB resumed). The PFP saves it when the queue is
+ * switched out of the pipe and resumes from it when the queue runs
+ * again, at the HQD offset. That survives the reset for a queue that
+ * was switched out. The queue the pipe executed has its state in the
+ * PFP, which the reset cleared: restart it at the write pointer with
+ * no IB to resume, and drop its work in flight.
+ */
+ if (hqd->connected) {
+ mqd->cp_gfx_hqd_offset = wptr;
+ mqd->cp_gfx_hqd_csmd_rptr = wptr;
+ for (status = &mqd->reserved_32; status <= &mqd->reserved_41; status++)
+ *status = 0;
+ } else {
+ mqd->cp_gfx_hqd_offset = hqd->offset;
+ mqd->cp_gfx_hqd_csmd_rptr = hqd->csmd_rptr;
+ }
+ mqd->cp_gfx_hqd_wptr = lower_32_bits(hqd->wptr);
+ mqd->cp_gfx_hqd_wptr_hi = upper_32_bits(hqd->wptr);
+ mqd->cp_gfx_hqd_active = 0;
+
+ return hqd->connected;
+}
+
static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring,
unsigned int vmid,
struct amdgpu_fence *timedout_fence)
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 07/13] drm/amdgpu/userq: add a helper to signal the fences of a queue up to a point
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (4 preceding siblings ...)
2026-11-05 3:05 ` [PATCH v4 06/13] drm/amdgpu/gfx11: " Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:36 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 08/13] drm/amdgpu/userq: add helpers to keep the user queues of one engine across a reset Jesse Zhang
` (7 subsequent siblings)
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
The fence value of a user queue is the write pointer of the queue when
the work was submitted. amdgpu_userq_fence_driver_force_completion()
signals all the fences of a queue, as after a reset that dropped all its
work.
Add amdgpu_userq_fence_driver_force_completion_with_seqno(), which only
signals the fences of the work up to a write pointer, with an error, for
a reset that drops only part of the work of a queue: the work submitted
after that write pointer still runs.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
.../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 31 +++++++++++++++++++
.../gpu/drm/amd/amdgpu/amdgpu_userq_fence.h | 2 ++
2 files changed, 33 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
index dd976a50e053..d20dce32168b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
@@ -460,6 +460,37 @@ amdgpu_userq_fence_driver_force_completion(struct amdgpu_usermode_queue *userq)
}
}
+/*
+ * Signal the fences of @userq with a seqno up to @seqno with -ECANCELED, eg.
+ * when a reset dropped the work that would have signaled them.
+ */
+void
+amdgpu_userq_fence_driver_force_completion_with_seqno(struct amdgpu_usermode_queue *userq,
+ u64 seqno)
+{
+ struct amdgpu_userq_fence_driver *fence_drv = userq->fence_drv;
+ struct amdgpu_userq_fence *fence;
+ unsigned long flags;
+
+ if (!fence_drv)
+ return;
+
+ spin_lock_irqsave(&fence_drv->fence_list_lock, flags);
+ list_for_each_entry(fence, &fence_drv->fences, link) {
+ if (fence->base.seqno > seqno)
+ break;
+ spin_lock(dma_fence_spinlock(&fence->base));
+ if (!dma_fence_is_signaled_locked(&fence->base))
+ dma_fence_set_error(&fence->base, -ECANCELED);
+ spin_unlock(dma_fence_spinlock(&fence->base));
+ }
+ if (amdgpu_userq_fence_read(fence_drv) < seqno)
+ amdgpu_userq_fence_write(fence_drv, seqno);
+ spin_unlock_irqrestore(&fence_drv->fence_list_lock, flags);
+
+ amdgpu_userq_fence_driver_process(fence_drv);
+}
+
int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
struct drm_file *filp)
{
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h
index 0bd51616cef1..0407c8c2575f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h
@@ -65,6 +65,8 @@ int amdgpu_userq_fence_driver_alloc(struct amdgpu_device *adev,
void amdgpu_userq_fence_driver_free(struct amdgpu_usermode_queue *userq);
int amdgpu_userq_fence_driver_process(struct amdgpu_userq_fence_driver *fence_drv);
void amdgpu_userq_fence_driver_force_completion(struct amdgpu_usermode_queue *userq);
+void amdgpu_userq_fence_driver_force_completion_with_seqno(struct amdgpu_usermode_queue *userq,
+ u64 seqno);
void amdgpu_userq_fence_driver_destroy(struct kref *ref);
int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
struct drm_file *filp);
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 08/13] drm/amdgpu/userq: add helpers to keep the user queues of one engine across a reset
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (5 preceding siblings ...)
2026-11-05 3:05 ` [PATCH v4 07/13] drm/amdgpu/userq: add a helper to signal the fences of a queue up to a point Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:36 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 09/13] drm/amdgpu/gfx12: add a gfx engine soft reset Jesse Zhang
` (6 subsequent siblings)
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
An engine reset, eg. of the gfx engine, only resets the queues of one
engine of the GFX IP; the queues of the other engines aren't reset.
amdgpu_userq_pre_reset() and amdgpu_userq_post_reset() handle all the
user queues for a full reset. Add separate helpers for the queues of one
engine, which keep them in the state they had:
- amdgpu_userq_save_hqds(), called after the MES suspend, saves the HQD
of the mapped queues still on a HQD: the reset clears their HQD, and
MES couldn't preempt them into their MQD. The queues MES preempted
have their state in their MQD already.
- amdgpu_userq_restore_hqds(), called after the reset but before MES
resumes, unmaps those queues, writes the saved HQD into their MQD and
maps them again: MES doesn't map a queue whose HQD the reset cleared
again on its own. The queues keep their state and their work, except
the one the pipe executed: its work in flight depends on pipe state
the reset cleared, it is dropped and its fences signaled. The queue
that hung, if any, is unmapped and hung.
- amdgpu_userq_clear_hqds() drops the saved HQDs for the full reset that
follows a failed engine reset.
The helpers walk the queues and unmap and map them as
amdgpu_userq_pre_reset() and amdgpu_userq_post_reset() do. The saved
HQDs are kept in the gfx IP, in saved_gfx_hqds[], and matched to a queue
by its doorbell and MQD address.
v2: Drop the user queue reset lock and the walk over the queues of one
type (Christian).
v4: Rename the helpers and the saved HQD array (Timur).
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 +
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 107 ++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 4 +
3 files changed, 114 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index 1c23e97fd04d..79cb6be75329 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -515,6 +515,9 @@ struct amdgpu_gfx {
/* reset mask */
uint32_t gfx_supported_reset;
+ /* HQDs of the gfx user queues, saved by an engine reset */
+ struct amdgpu_gfx_saved_hqd saved_gfx_hqds[AMDGPU_MAX_GFX_QUEUES];
+ u32 num_saved_gfx_hqds;
uint32_t compute_supported_reset;
/* gfx off */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
index ccf0ff490ac2..7d0c4e8795b4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -1594,3 +1594,110 @@ int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost)
return ret;
}
+
+/**
+ * amdgpu_userq_save_hqds - save the HQDs of the user queues before an engine reset
+ * @adev: amdgpu device
+ * @queue_type: AMDGPU_HW_IP_* type of the queues on the reset engine
+ */
+void amdgpu_userq_save_hqds(struct amdgpu_device *adev, u32 queue_type)
+{
+ struct amdgpu_gfx_saved_hqd hqd;
+ struct amdgpu_usermode_queue *queue;
+ unsigned long queue_id;
+
+ adev->gfx.num_saved_gfx_hqds = 0;
+ if (!adev->gfx.funcs->save_hqd)
+ return;
+
+ xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
+ if (adev->gfx.num_saved_gfx_hqds >= AMDGPU_MAX_GFX_QUEUES)
+ break;
+ if (queue->queue_type != queue_type ||
+ queue->state != AMDGPU_USERQ_STATE_MAPPED)
+ continue;
+ if (adev->gfx.funcs->save_hqd(adev, queue->doorbell_index, &hqd) &&
+ hqd.on_hqd)
+ adev->gfx.saved_gfx_hqds[adev->gfx.num_saved_gfx_hqds++] = hqd;
+ }
+}
+
+static struct amdgpu_gfx_saved_hqd *
+amdgpu_userq_find_saved_hqd(struct amdgpu_device *adev,
+ struct amdgpu_usermode_queue *queue)
+{
+ struct amdgpu_gfx_saved_hqd *hqd;
+ u32 i;
+
+ for (i = 0; i < adev->gfx.num_saved_gfx_hqds; i++) {
+ hqd = &adev->gfx.saved_gfx_hqds[i];
+ /* Check the MQD too: a new queue may reuse the doorbell. */
+ if (hqd->doorbell_index == queue->doorbell_index &&
+ hqd->mqd_addr == queue->mqd.gpu_addr)
+ return hqd;
+ }
+ return NULL;
+}
+
+/**
+ * amdgpu_userq_restore_hqds - restore the user queues after an engine reset
+ * @adev: amdgpu device
+ * @queue_type: AMDGPU_HW_IP_* type of the queues on the reset engine
+ * @guilty: the queue that hung, or NULL
+ *
+ * MES doesn't map a queue whose HQD the reset cleared again on its own: unmap
+ * it from MES, restore its MQD, and map it again.
+ */
+void amdgpu_userq_restore_hqds(struct amdgpu_device *adev, u32 queue_type,
+ struct amdgpu_usermode_queue *guilty)
+{
+ const struct amdgpu_userq_funcs *userq_funcs = adev->userq_funcs[queue_type];
+ struct amdgpu_usermode_queue *queue;
+ struct amdgpu_gfx_saved_hqd *hqd;
+ unsigned long queue_id;
+ int r;
+
+ xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
+ if (queue->queue_type != queue_type ||
+ queue->state != AMDGPU_USERQ_STATE_MAPPED)
+ continue;
+
+ if (queue == guilty) {
+ userq_funcs->unmap(queue);
+ amdgpu_userq_fence_driver_force_completion(queue);
+ trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_HUNG);
+ queue->state = AMDGPU_USERQ_STATE_HUNG;
+ continue;
+ }
+
+ hqd = amdgpu_userq_find_saved_hqd(adev, queue);
+ if (!hqd)
+ continue;
+
+ userq_funcs->unmap(queue);
+ if (adev->gfx.funcs->restore_hqd(adev, queue->mqd.cpu_ptr,
+ queue->userq_prop->queue_size,
+ hqd))
+ amdgpu_userq_fence_driver_force_completion_with_seqno(queue,
+ hqd->wptr);
+ r = userq_funcs->map(queue);
+ if (r) {
+ dev_err(adev->dev, "Failed to remap user queue %llu: %d\n",
+ queue->doorbell_index, r);
+ amdgpu_userq_fence_driver_force_completion(queue);
+ trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_HUNG);
+ queue->state = AMDGPU_USERQ_STATE_HUNG;
+ }
+ }
+ adev->gfx.num_saved_gfx_hqds = 0;
+}
+
+/**
+ * amdgpu_userq_clear_hqds - drop the saved HQDs after a failed engine reset
+ * @adev: amdgpu device
+ * @queue_type: AMDGPU_HW_IP_* type of the queues on the reset engine
+ */
+void amdgpu_userq_clear_hqds(struct amdgpu_device *adev, u32 queue_type)
+{
+ adev->gfx.num_saved_gfx_hqds = 0;
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
index 488dc21d7c81..b5195031877d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
@@ -181,6 +181,10 @@ int amdgpu_userq_start_sched_for_enforce_isolation(struct amdgpu_device *adev,
void amdgpu_userq_reset_work(struct work_struct *work);
void amdgpu_userq_pre_reset(struct amdgpu_device *adev);
int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost);
+void amdgpu_userq_save_hqds(struct amdgpu_device *adev, u32 queue_type);
+void amdgpu_userq_restore_hqds(struct amdgpu_device *adev, u32 queue_type,
+ struct amdgpu_usermode_queue *guilty);
+void amdgpu_userq_clear_hqds(struct amdgpu_device *adev, u32 queue_type);
void amdgpu_userq_start_hang_detect_work(struct amdgpu_usermode_queue *queue);
void amdgpu_userq_process_fence_irq(struct amdgpu_device *adev, u32 doorbell);
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 09/13] drm/amdgpu/gfx12: add a gfx engine soft reset
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (6 preceding siblings ...)
2026-11-05 3:05 ` [PATCH v4 08/13] drm/amdgpu/userq: add helpers to keep the user queues of one engine across a reset Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:42 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 10/13] drm/amdgpu/gfx11: " Jesse Zhang
` (5 subsequent siblings)
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
Some hangs leave the gfx streaming engine of the CP front-end stuck, eg.
waiting for packet data that never arrives. Neither a queue nor a pipe
reset can stop it, so they end in a full GPU reset.
Implement soft_reset_engine() for the graphics engine: halt PFP/ME,
pulse GRBM_SOFT_RESET.SOFT_RESET_CPF/CPG with
CP_SOFT_RESET_CNTL.GFX_ONLY_SOFT_RESET and GFX_HQD_REG_RESET, restart
PFP/ME and map the kernel gfx queue again.
MEC, MES and the compute queues keep running. The MES lock is held across
the pulse, as MES fetches its queues through CPF, and the CP DMA is
drained around it, as a request in flight leaves the ME busy.
MES is suspended meanwhile, and the gfx user queues the reset clears are
saved and restored around it. If the CP doesn't go idle, the reset fails
and a full reset follows.
v4: Implement soft_reset_engine() directly instead of a reset_engine gfx
callback (Timur).
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 129 +++++++++++++++++++++++++
1 file changed, 129 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
index 484e876fe235..8b96f2a29b1f 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
@@ -3860,6 +3860,134 @@ static int gfx_v12_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
return -ETIMEDOUT;
}
+/* The CP DMA and the interfaces its memory requests go through */
+#define GFX12_CP_STAT_MEM_BUSY (CP_STAT__DMA_BUSY_MASK | \
+ CP_STAT__TCIU_BUSY_MASK | \
+ CP_STAT__RCIU_BUSY_MASK | \
+ CP_STAT__UTCL2IU_BUSY_MASK)
+
+/* Reset CPF/CPG, PFP/ME and the gfx HQDs, then boot PFP/ME again. */
+static int gfx_v12_0_soft_reset_gfx_cp(struct amdgpu_device *adev)
+{
+ u32 tmp, cntl, me_cntl, ib_control;
+ int i;
+
+ amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
+ /* MES fetches its queues through CPF: keep it out of the reset. */
+ amdgpu_mes_lock(&adev->mes);
+
+ me_cntl = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
+ ib_control = RREG32_SOC15(GC, 0, regCP_PFP_IB_CONTROL); /* cleared by the reset */
+
+ tmp = REG_SET_FIELD(me_cntl, CP_ME_CNTL, ME_HALT, 1);
+ tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 1);
+ WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
+ udelay(50);
+
+ /* A CP DMA in flight during the reset leaves the ME busy after it. */
+ for (i = 0; i < adev->usec_timeout; i++) {
+ if (!(RREG32_SOC15(GC, 0, regCP_STAT) & GFX12_CP_STAT_MEM_BUSY))
+ break;
+ udelay(1);
+ }
+
+ /* GFX_ONLY keeps compute and MES out; CPF alone leaves the stream stuck. */
+ cntl = RREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL);
+ tmp = REG_SET_FIELD(cntl, CP_SOFT_RESET_CNTL, GFX_ONLY_SOFT_RESET, 1);
+ tmp = REG_SET_FIELD(tmp, CP_SOFT_RESET_CNTL, GFX_HQD_REG_RESET, 1);
+ WREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL, tmp);
+
+ tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
+ tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPF, 1);
+ tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPG, 1);
+ WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
+ tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
+ udelay(50);
+ tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPF, 0);
+ tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPG, 0);
+ WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
+ tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
+
+ WREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL, cntl);
+
+ /* The halted PFP stays busy: only wait for the memory requests. */
+ for (i = 0; i < adev->usec_timeout; i++) {
+ if (!(RREG32_SOC15(GC, 0, regCP_STAT) & GFX12_CP_STAT_MEM_BUSY))
+ break;
+ udelay(1);
+ }
+ amdgpu_mes_unlock(&adev->mes);
+
+ gfx_v12_0_set_pfp_ucode_start_addr(adev);
+ gfx_v12_0_set_me_ucode_start_addr(adev);
+ tmp = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
+ tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, CE_HALT,
+ REG_GET_FIELD(me_cntl, CP_ME_CNTL, CE_HALT));
+ WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
+ WREG32_SOC15(GC, 0, regCP_PFP_IB_CONTROL, ib_control);
+ amdgpu_gfx_rlc_exit_safe_mode(adev, 0);
+
+ tmp = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
+ tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, ME_HALT, 0);
+ tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 0);
+ WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
+ for (i = 0; i < adev->usec_timeout; i++) {
+ if (!RREG32_SOC15(GC, 0, regCP_STAT))
+ return 0;
+ udelay(1);
+ }
+ return -ETIMEDOUT;
+}
+
+static int gfx_v12_0_soft_reset_engine(struct amdgpu_ip_block *ip_block,
+ enum amdgpu_ring_type ring_type,
+ struct amdgpu_usermode_queue *guilty_queue)
+{
+ struct amdgpu_device *adev = ip_block->adev;
+ int i, r;
+
+ if (ring_type != AMDGPU_RING_TYPE_GFX)
+ return -EOPNOTSUPP;
+
+ mutex_lock(&adev->gfx.mec.reset_mutex);
+ amdgpu_gfx_off_ctrl(adev, false);
+
+ /* A hung gfx stream can keep MES from suspending: reset anyway. */
+ amdgpu_mes_suspend(adev, 0);
+ amdgpu_userq_save_hqds(adev, AMDGPU_HW_IP_GFX);
+
+ r = gfx_v12_0_soft_reset_gfx_cp(adev);
+ if (r) {
+ dev_err(adev->dev, "gfx CP still busy after reset, CP_STAT 0x%08x\n",
+ RREG32_SOC15(GC, 0, regCP_STAT));
+ goto fail;
+ }
+
+ /* The reset cleared the HQD of the kernel gfx queue: map it again. */
+ r = amdgpu_gfx_disable_kgq(adev, 0);
+ if (r)
+ goto fail;
+ for (i = 0; i < adev->gfx.num_gfx_rings; i++)
+ amdgpu_gfx_mqd_reset_restore(&adev->gfx.gfx_ring[i]);
+ r = amdgpu_gfx_enable_kgq(adev, 0);
+ if (!r)
+ r = gfx_v12_0_cp_gfx_start(adev);
+ if (r)
+ goto fail;
+
+ amdgpu_userq_restore_hqds(adev, AMDGPU_HW_IP_GFX, guilty_queue);
+ r = amdgpu_mes_resume(adev, 0);
+ goto out;
+
+fail:
+ amdgpu_userq_clear_hqds(adev, AMDGPU_HW_IP_GFX);
+ amdgpu_mes_resume(adev, 0);
+out:
+ amdgpu_gfx_off_ctrl(adev, true);
+ mutex_unlock(&adev->gfx.mec.reset_mutex);
+ return r;
+}
+
#define GFX12_HPD_QUEUE_STATE_CONNECTED_MIN 3
#define GFX12_HPD_QUEUE_STATE_CONNECTED_MAX 15
@@ -5375,6 +5503,7 @@ static const struct amd_ip_funcs gfx_v12_0_ip_funcs = {
.suspend = gfx_v12_0_suspend,
.resume = gfx_v12_0_resume,
.wait_for_idle = gfx_v12_0_wait_for_idle,
+ .soft_reset_engine = gfx_v12_0_soft_reset_engine,
.set_clockgating_state = gfx_v12_0_set_clockgating_state,
.set_powergating_state = gfx_v12_0_set_powergating_state,
.get_clockgating_state = gfx_v12_0_get_clockgating_state,
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 10/13] drm/amdgpu/gfx11: add a gfx engine soft reset
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (7 preceding siblings ...)
2026-11-05 3:05 ` [PATCH v4 09/13] drm/amdgpu/gfx12: add a gfx engine soft reset Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:47 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 11/13] drm/amdgpu/userq: reset the gfx engine when a gfx user queue reset fails Jesse Zhang
` (4 subsequent siblings)
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
Implement soft_reset_engine() for the graphics engine of gfx11, as for
gfx12, with two differences:
- clear CP_VMID_RESET: a VMID reset the hung PFP didn't handle survives
the CPF/CPG reset;
- boot PFP/ME with CP_PFP_IB_CONTROL cleared and restore it afterwards:
set, it makes the F32 PFP of the APUs resume from power gating and wait
for a clear state that never comes.
The CPF/CPG reset already puts PFP/ME back at their firmware start
address, so unhalting them restarts the RS64 and F32 firmware alike.
v4: Implement soft_reset_engine() directly instead of a reset_engine gfx
callback, drop gfx_v11_0_restart_gfx_rs64(), and boot with
CP_PFP_IB_CONTROL cleared for the F32 firmware (Timur).
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 134 +++++++++++++++++++++++++
1 file changed, 134 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index 798015689f0c..80b91459f5b0 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -6777,6 +6777,139 @@ static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)
amdgpu_ring_write(ring, gcr_cntl); /* GCR_CNTL */
}
+/* The CP DMA and the interfaces its memory requests go through */
+#define GFX11_CP_STAT_MEM_BUSY (CP_STAT__DMA_BUSY_MASK | \
+ CP_STAT__TCIU_BUSY_MASK | \
+ CP_STAT__RCIU_BUSY_MASK | \
+ CP_STAT__UTCL2IU_BUSY_MASK)
+
+/* Reset CPF/CPG, PFP/ME and the gfx HQDs, then boot PFP/ME again. */
+static int gfx_v11_0_soft_reset_gfx_cp(struct amdgpu_device *adev)
+{
+ u32 tmp, cntl, me_cntl, ib_control;
+ int i;
+
+ amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
+ /* MES fetches its queues through CPF: keep it out of the reset. */
+ amdgpu_mes_lock(&adev->mes);
+
+ me_cntl = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
+ ib_control = RREG32_SOC15(GC, 0, regCP_PFP_IB_CONTROL); /* cleared by the reset */
+
+ tmp = REG_SET_FIELD(me_cntl, CP_ME_CNTL, ME_HALT, 1);
+ tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 1);
+ WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
+ udelay(50);
+
+ /* A CP DMA in flight during the reset leaves the ME busy after it. */
+ for (i = 0; i < adev->usec_timeout; i++) {
+ if (!(RREG32_SOC15(GC, 0, regCP_STAT) & GFX11_CP_STAT_MEM_BUSY))
+ break;
+ udelay(1);
+ }
+
+ /* GFX_ONLY keeps compute and MES out; CPF alone leaves the stream stuck. */
+ cntl = RREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL);
+ tmp = REG_SET_FIELD(cntl, CP_SOFT_RESET_CNTL, GFX_ONLY_SOFT_RESET, 1);
+ tmp = REG_SET_FIELD(tmp, CP_SOFT_RESET_CNTL, GFX_HQD_REG_RESET, 1);
+ WREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL, tmp);
+
+ tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
+ tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPF, 1);
+ tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPG, 1);
+ WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
+ tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
+ udelay(50);
+ tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPF, 0);
+ tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPG, 0);
+ WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
+ tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
+
+ WREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL, cntl);
+
+ /* The halted PFP stays busy: only wait for the memory requests. */
+ for (i = 0; i < adev->usec_timeout; i++) {
+ if (!(RREG32_SOC15(GC, 0, regCP_STAT) & GFX11_CP_STAT_MEM_BUSY))
+ break;
+ udelay(1);
+ }
+ /* A VMID reset the hung PFP didn't handle survives the reset. */
+ WREG32_SOC15(GC, 0, regCP_VMID_RESET, 0);
+ amdgpu_mes_unlock(&adev->mes);
+
+ tmp = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
+ tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, CE_HALT,
+ REG_GET_FIELD(me_cntl, CP_ME_CNTL, CE_HALT));
+ WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
+ amdgpu_gfx_rlc_exit_safe_mode(adev, 0);
+
+ /*
+ * Boot with CP_PFP_IB_CONTROL cleared: set, it makes the F32 PFP resume
+ * from power gating and wait for a clear state that never comes.
+ */
+ tmp = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
+ tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, ME_HALT, 0);
+ tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 0);
+ WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
+ for (i = 0; i < adev->usec_timeout; i++) {
+ if (!RREG32_SOC15(GC, 0, regCP_STAT))
+ break;
+ udelay(1);
+ }
+ WREG32_SOC15(GC, 0, regCP_PFP_IB_CONTROL, ib_control);
+
+ return i < adev->usec_timeout ? 0 : -ETIMEDOUT;
+}
+
+static int gfx_v11_0_soft_reset_engine(struct amdgpu_ip_block *ip_block,
+ enum amdgpu_ring_type ring_type,
+ struct amdgpu_usermode_queue *guilty_queue)
+{
+ struct amdgpu_device *adev = ip_block->adev;
+ int i, r;
+
+ if (ring_type != AMDGPU_RING_TYPE_GFX)
+ return -EOPNOTSUPP;
+
+ mutex_lock(&adev->gfx.mec.reset_mutex);
+ amdgpu_gfx_off_ctrl(adev, false);
+
+ /* A hung gfx stream can keep MES from suspending: reset anyway. */
+ amdgpu_mes_suspend(adev, 0);
+ amdgpu_userq_save_hqds(adev, AMDGPU_HW_IP_GFX);
+
+ r = gfx_v11_0_soft_reset_gfx_cp(adev);
+ if (r) {
+ dev_err(adev->dev, "gfx CP still busy after reset, CP_STAT 0x%08x\n",
+ RREG32_SOC15(GC, 0, regCP_STAT));
+ goto fail;
+ }
+
+ /* The reset cleared the HQD of the kernel gfx queue: map it again. */
+ r = amdgpu_gfx_disable_kgq(adev, 0);
+ if (r)
+ goto fail;
+ for (i = 0; i < adev->gfx.num_gfx_rings; i++)
+ amdgpu_gfx_mqd_reset_restore(&adev->gfx.gfx_ring[i]);
+ r = amdgpu_gfx_enable_kgq(adev, 0);
+ if (!r)
+ r = gfx_v11_0_cp_gfx_start(adev);
+ if (r)
+ goto fail;
+
+ amdgpu_userq_restore_hqds(adev, AMDGPU_HW_IP_GFX, guilty_queue);
+ r = amdgpu_mes_resume(adev, 0);
+ goto out;
+
+fail:
+ amdgpu_userq_clear_hqds(adev, AMDGPU_HW_IP_GFX);
+ amdgpu_mes_resume(adev, 0);
+out:
+ amdgpu_gfx_off_ctrl(adev, true);
+ mutex_unlock(&adev->gfx.mec.reset_mutex);
+ return r;
+}
+
#define GFX11_HPD_QUEUE_STATE_CONNECTED_MIN 3
#define GFX11_HPD_QUEUE_STATE_CONNECTED_MAX 15
@@ -7045,6 +7178,7 @@ static const struct amd_ip_funcs gfx_v11_0_ip_funcs = {
.suspend = gfx_v11_0_suspend,
.resume = gfx_v11_0_resume,
.wait_for_idle = gfx_v11_0_wait_for_idle,
+ .soft_reset_engine = gfx_v11_0_soft_reset_engine,
.soft_reset = gfx_v11_0_soft_reset,
.set_clockgating_state = gfx_v11_0_set_clockgating_state,
.set_powergating_state = gfx_v11_0_set_powergating_state,
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 11/13] drm/amdgpu/userq: reset the gfx engine when a gfx user queue reset fails
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (8 preceding siblings ...)
2026-11-05 3:05 ` [PATCH v4 10/13] drm/amdgpu/gfx11: " Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:47 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 12/13] drm/amdgpu/gfx12: enable the gfx engine soft reset Jesse Zhang
` (3 subsequent siblings)
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
When neither the queue nor the pipe reset recovered a gfx user queue,
fall back to a soft reset of the gfx engine before a full reset, when
the GFX IP supports it. A hung kernel gfx queue gets there through the
IP block soft reset of the job timeout handler; a user queue has no
kernel ring, so call amdgpu_device_ip_soft_reset() directly, with the
gfx ring type and no guilty ring.
The hung queue can't be unmapped before the reset: pass it to the engine
reset, which unmaps it once the reset cleared its HQD, and hangs it,
while the other gfx user queues keep their state.
v4: Call amdgpu_device_ip_soft_reset(), which now takes the ring type
(Timur).
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 27 +++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index 7abb9d95ef59..4f2dea21ad54 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
@@ -235,11 +235,25 @@ int mes_userq_reset_hw(struct amdgpu_usermode_queue *queue,
return 0;
}
+/* The hung queue can't be unmapped now: the engine reset unmaps it after. */
+static int mes_userq_reset_gfx_engine(struct amdgpu_usermode_queue *queue)
+{
+ return amdgpu_device_ip_soft_reset(queue->userq_mgr->adev,
+ AMDGPU_RING_TYPE_GFX, NULL, NULL, queue);
+}
+
+static bool mes_userq_gfx_engine_reset_supported(struct amdgpu_device *adev)
+{
+ return adev->gfx.gfx_supported_reset &
+ AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET;
+}
+
int mes_userq_reset(struct amdgpu_usermode_queue *queue)
{
struct amdgpu_userq_mgr *uq_mgr = queue->userq_mgr;
struct amdgpu_device *adev = uq_mgr->adev;
struct mes_reset_queue_input queue_input;
+ int r;
/* already reset by an earlier job's hang-detect; just signal and bail */
if (queue->state == AMDGPU_USERQ_STATE_HUNG)
@@ -248,8 +262,10 @@ int mes_userq_reset(struct amdgpu_usermode_queue *queue)
/* A GFX pipe reset also affects the kernel rings on that pipe. */
if (queue->queue_type == AMDGPU_HW_IP_GFX &&
adev->gfx.funcs->detect_hung_queue &&
- amdgpu_gfx_me_pipe_reset_supported(adev))
- return amdgpu_gfx_reset_mes_gfx(adev, NULL, NULL, queue, 0, true);
+ amdgpu_gfx_me_pipe_reset_supported(adev)) {
+ r = amdgpu_gfx_reset_mes_gfx(adev, NULL, NULL, queue, 0, true);
+ goto out;
+ }
memset(&queue_input, 0x0, sizeof(struct mes_reset_queue_input));
queue_input.doorbell_offset = queue->doorbell_index;
@@ -277,7 +293,12 @@ int mes_userq_reset(struct amdgpu_usermode_queue *queue)
}
}
- return mes_userq_reset_hw(queue, &queue_input);
+ r = mes_userq_reset_hw(queue, &queue_input);
+out:
+ if (r && queue->queue_type == AMDGPU_HW_IP_GFX &&
+ mes_userq_gfx_engine_reset_supported(adev))
+ r = mes_userq_reset_gfx_engine(queue);
+ return r;
}
int mes_userq_reset_queue(struct amdgpu_device *adev,
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 12/13] drm/amdgpu/gfx12: enable the gfx engine soft reset
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (9 preceding siblings ...)
2026-11-05 3:05 ` [PATCH v4 11/13] drm/amdgpu/userq: reset the gfx engine when a gfx user queue reset fails Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:47 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 13/13] drm/amdgpu/gfx11: " Jesse Zhang
` (2 subsequent siblings)
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
Report AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET for the gfx rings with MES,
which the reset uses to map the kernel gfx queue again. Not on SR-IOV
VFs.
The kernel gfx queue and gfx user queue resets then fall back to a soft
reset of the gfx engine before a full reset.
v4: The soft_reset_engine() callback is set by the patch that adds it.
No async gfx ring check: they are always used now.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
index 8b96f2a29b1f..55baeda02d6f 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
@@ -1593,6 +1593,11 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
break;
}
+ /* The reset remaps the kernel gfx queue through MES. */
+ if (!amdgpu_sriov_vf(adev) && adev->enable_mes &&
+ !adev->debug_disable_ip_block_soft_reset)
+ adev->gfx.gfx_supported_reset |= AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET;
+
if (!adev->enable_mes_kiq) {
r = amdgpu_gfx_kiq_init(adev, GFX12_MEC_HPD_SIZE, 0);
if (r) {
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v4 13/13] drm/amdgpu/gfx11: enable the gfx engine soft reset
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (10 preceding siblings ...)
2026-11-05 3:05 ` [PATCH v4 12/13] drm/amdgpu/gfx12: enable the gfx engine soft reset Jesse Zhang
@ 2026-11-05 3:05 ` Jesse Zhang
2026-11-19 11:47 ` Timur Kristóf
2026-11-10 2:06 ` [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Zhang, Jesse(Jie)
2026-11-19 11:33 ` Timur Kristóf
13 siblings, 1 reply; 29+ messages in thread
From: Jesse Zhang @ 2026-11-05 3:05 UTC (permalink / raw)
To: amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, timur.kristof,
Mario.Novales, Manu.Rastogi, Jiongyu.Zhu, Jesse Zhang
Report AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET for the gfx rings with MES,
which the reset uses to map the kernel gfx queue again. Not on SR-IOV
VFs.
The kernel gfx queue and gfx user queue resets then fall back to a soft
reset of the gfx engine before a full reset. The IP block soft reset of
gfx11 only resets the gfx engine then; the whole IP block soft_reset()
isn't used.
v4: Not limited to the RS64 firmware anymore, the reset restarts the F32
PFP and ME of the APUs too (Timur). The soft_reset_engine() callback
is set by the patch that adds it. No async gfx ring check: they are
always used now.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index 80b91459f5b0..396fe3f6678a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -1941,6 +1941,11 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block)
break;
}
+ /* The reset remaps the kernel gfx queue through MES. */
+ if (!amdgpu_sriov_vf(adev) && adev->enable_mes &&
+ !adev->debug_disable_ip_block_soft_reset)
+ adev->gfx.gfx_supported_reset |= AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET;
+
if (!adev->enable_mes_kiq) {
r = amdgpu_gfx_kiq_init(adev, GFX11_MEC_HPD_SIZE, 0);
if (r) {
--
2.50.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* RE: [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (11 preceding siblings ...)
2026-11-05 3:05 ` [PATCH v4 13/13] drm/amdgpu/gfx11: " Jesse Zhang
@ 2026-11-10 2:06 ` Zhang, Jesse(Jie)
2026-11-11 15:28 ` Timur Kristóf
2026-11-19 11:33 ` Timur Kristóf
13 siblings, 1 reply; 29+ messages in thread
From: Zhang, Jesse(Jie) @ 2026-11-10 2:06 UTC (permalink / raw)
To: Zhang, Jesse(Jie), amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander, Koenig, Christian, Lazar, Lijo,
timur.kristof@gmail.com, Mario Sopena-Novales, Rastogi, Manu,
Zhu, Jiongyu (Joey)
AMD General
Ping on the series
> -----Original Message-----
> From: Jesse Zhang <Jesse.Zhang@amd.com>
> Sent: Thursday, November 5, 2026 11:06 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>;
> timur.kristof@gmail.com; Mario Sopena-Novales
> <Mario.Novales@amd.com>; Rastogi, Manu <Manu.Rastogi@amd.com>;
> Zhu, Jiongyu (Joey) <Jiongyu.Zhu@amd.com>; Zhang, Jesse(Jie)
> <Jesse.Zhang@amd.com>
> Subject: [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring
> reset helpers
>
> amdgpu_multi_ring_reset_helper_begin() and _end() take the device from the
> guilty ring. A reset triggered by a hung user queue has no guilty kernel ring, so
> pass the device explicitly and allow a NULL guilty ring.
>
> No functional change.
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c | 4 ++--
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 14 ++++++++------
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 6 ++++--
> 3 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> index 734f2a0bc79a..d0b0d3eaffc5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> @@ -465,11 +465,11 @@ int amdgpu_device_ip_soft_reset(struct
> amdgpu_ring *guilty_ring,
> ring_type_mask = amdgpu_ring_mask_from_ip(ip_type);
>
> amdgpu_device_lock_reset_domain(adev->reset_domain);
> - amdgpu_multi_ring_reset_helper_begin(ring_type_mask, guilty_ring,
> guilty_fence);
> + amdgpu_multi_ring_reset_helper_begin(adev, ring_type_mask,
> +guilty_ring, guilty_fence);
>
> r = ip_block->version->funcs->soft_reset(ip_block);
>
> - r = amdgpu_multi_ring_reset_helper_end(ring_type_mask,
> guilty_ring, r);
> + r = amdgpu_multi_ring_reset_helper_end(adev, ring_type_mask,
> +guilty_ring, r);
> amdgpu_device_unlock_reset_domain(adev->reset_domain);
>
> if (r) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> index 7b67e8cecca2..edae764eb0c4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> @@ -919,8 +919,9 @@ int amdgpu_ring_reset_helper_end(struct
> amdgpu_ring *ring,
> /**
> * amdgpu_multi_ring_reset_helper_begin() - Prepare multiple rings for a
> reset.
> *
> + * @adev: amdgpu device
> * @ring_type_mask: Bitmask of affected ring types
> - * @guilty_ring: The ring which is guilty of causing a reset.
> + * @guilty_ring: The ring which is guilty of causing a reset, or NULL.
> * @guilty_fence: The fence which didn't signal on the guilty ring.
> *
> * Useful when performing a GPU reset method that affects @@ -938,11
> +939,11 @@ int amdgpu_ring_reset_helper_end(struct amdgpu_ring *ring,
> * After the reset is complete, the caller should then call
> * amdgpu_multi_ring_reset_helper_end() to restore the rings.
> */
> -void amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
> +void amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device *adev,
> + const u32 ring_type_mask,
> struct amdgpu_ring *guilty_ring,
> struct amdgpu_fence *guilty_fence)
> {
> - struct amdgpu_device *adev = guilty_ring->adev;
> struct amdgpu_fence *ring_guilty_fence;
> struct amdgpu_ring *ring;
> bool rings_busy;
> @@ -1034,8 +1035,9 @@ void
> amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
> /**
> * amdgpu_multi_ring_reset_helper_end() - Prepare multiple rings for a reset.
> *
> + * @adev: amdgpu device
> * @ring_type_mask: Bitmask of affected ring types
> - * @guilty_ring: The ring which is guilty of causing a reset.
> + * @guilty_ring: The ring which is guilty of causing a reset, or NULL.
> * @ret: Return code from the reset function.
> *
> * After calling amdgpu_multi_ring_reset_helper_begin()
> @@ -1046,10 +1048,10 @@ void
> amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
> * be called to restore preemption state, but it won't attempt to
> * fully restore the ring contents.
> */
> -int amdgpu_multi_ring_reset_helper_end(const u32 ring_type_mask,
> +int amdgpu_multi_ring_reset_helper_end(struct amdgpu_device *adev,
> + const u32 ring_type_mask,
> struct amdgpu_ring *guilty_ring, int ret) {
> - struct amdgpu_device *adev = guilty_ring->adev;
> struct amdgpu_ring *ring;
> int i, r;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> index b2040f80b7f2..7e6ed43771f2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> @@ -637,10 +637,12 @@ void amdgpu_ring_reset_helper_begin(struct
> amdgpu_ring *ring,
> struct amdgpu_fence *guilty_fence); int
> amdgpu_ring_reset_helper_end(struct amdgpu_ring *ring,
> struct amdgpu_fence *guilty_fence); -void
> amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
> +void amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device *adev,
> + const u32 ring_type_mask,
> struct amdgpu_ring *guilty_ring,
> struct amdgpu_fence *guilty_fence);
> -int amdgpu_multi_ring_reset_helper_end(const u32 ring_type_mask,
> +int amdgpu_multi_ring_reset_helper_end(struct amdgpu_device *adev,
> + const u32 ring_type_mask,
> struct amdgpu_ring *guilty_ring, int ret);
> bool amdgpu_ring_is_reset_type_supported(struct amdgpu_ring *ring,
> u32 reset_type);
> --
> 2.50.1
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers
2026-11-10 2:06 ` [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Zhang, Jesse(Jie)
@ 2026-11-11 15:28 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-11 15:28 UTC (permalink / raw)
To: Zhang, Jesse(Jie), amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander, Koenig, Christian, Lazar, Lijo,
Mario Sopena-Novales, Rastogi, Manu, Zhu, Jiongyu (Joey)
On Tue, 2026-11-10 at 02:06 +0000, Zhang, Jesse(Jie) wrote:
> AMD General
>
> Ping on the series
Hi Jesse,
I apologize for the late reply. I'm reviewing the new version too, just
need some time to finish my review.
Best regards,
Timur
>
> > -----Original Message-----
> > From: Jesse Zhang <Jesse.Zhang@amd.com>
> > Sent: Thursday, November 5, 2026 11:06 AM
> > To: amd-gfx@lists.freedesktop.org
> > Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig,
> > Christian
> > <Christian.Koenig@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>;
> > timur.kristof@gmail.com; Mario Sopena-Novales
> > <Mario.Novales@amd.com>; Rastogi, Manu <Manu.Rastogi@amd.com>;
> > Zhu, Jiongyu (Joey) <Jiongyu.Zhu@amd.com>; Zhang, Jesse(Jie)
> > <Jesse.Zhang@amd.com>
> > Subject: [PATCH v4 01/13] drm/amdgpu: pass the device to the multi
> > ring
> > reset helpers
> >
> > amdgpu_multi_ring_reset_helper_begin() and _end() take the device
> > from the
> > guilty ring. A reset triggered by a hung user queue has no guilty
> > kernel ring, so
> > pass the device explicitly and allow a NULL guilty ring.
> >
> > No functional change.
> >
> > Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
> > ---
> > drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c | 4 ++--
> > drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 14 ++++++++------
> > drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 6 ++++--
> > 3 files changed, 14 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> > index 734f2a0bc79a..d0b0d3eaffc5 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> > @@ -465,11 +465,11 @@ int amdgpu_device_ip_soft_reset(struct
> > amdgpu_ring *guilty_ring,
> > ring_type_mask = amdgpu_ring_mask_from_ip(ip_type);
> >
> > amdgpu_device_lock_reset_domain(adev->reset_domain);
> > - amdgpu_multi_ring_reset_helper_begin(ring_type_mask,
> > guilty_ring,
> > guilty_fence);
> > + amdgpu_multi_ring_reset_helper_begin(adev, ring_type_mask,
> > +guilty_ring, guilty_fence);
> >
> > r = ip_block->version->funcs->soft_reset(ip_block);
> >
> > - r = amdgpu_multi_ring_reset_helper_end(ring_type_mask,
> > guilty_ring, r);
> > + r = amdgpu_multi_ring_reset_helper_end(adev, ring_type_mask,
> > +guilty_ring, r);
> > amdgpu_device_unlock_reset_domain(adev->reset_domain);
> >
> > if (r) {
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> > index 7b67e8cecca2..edae764eb0c4 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> > @@ -919,8 +919,9 @@ int amdgpu_ring_reset_helper_end(struct
> > amdgpu_ring *ring,
> > /**
> > * amdgpu_multi_ring_reset_helper_begin() - Prepare multiple rings
> > for a
> > reset.
> > *
> > + * @adev: amdgpu device
> > * @ring_type_mask: Bitmask of affected ring types
> > - * @guilty_ring: The ring which is guilty of causing a reset.
> > + * @guilty_ring: The ring which is guilty of causing a reset, or
> > NULL.
> > * @guilty_fence: The fence which didn't signal on the guilty
> > ring.
> > *
> > * Useful when performing a GPU reset method that affects @@ -
> > 938,11
> > +939,11 @@ int amdgpu_ring_reset_helper_end(struct amdgpu_ring
> > *ring,
> > * After the reset is complete, the caller should then call
> > * amdgpu_multi_ring_reset_helper_end() to restore the rings.
> > */
> > -void amdgpu_multi_ring_reset_helper_begin(const u32
> > ring_type_mask,
> > +void amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device
> > *adev,
> > + const u32 ring_type_mask,
> > struct amdgpu_ring
> > *guilty_ring,
> > struct amdgpu_fence
> > *guilty_fence)
> > {
> > - struct amdgpu_device *adev = guilty_ring->adev;
> > struct amdgpu_fence *ring_guilty_fence;
> > struct amdgpu_ring *ring;
> > bool rings_busy;
> > @@ -1034,8 +1035,9 @@ void
> > amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
> > /**
> > * amdgpu_multi_ring_reset_helper_end() - Prepare multiple rings
> > for a reset.
> > *
> > + * @adev: amdgpu device
> > * @ring_type_mask: Bitmask of affected ring types
> > - * @guilty_ring: The ring which is guilty of causing a reset.
> > + * @guilty_ring: The ring which is guilty of causing a reset, or
> > NULL.
> > * @ret: Return code from the reset function.
> > *
> > * After calling amdgpu_multi_ring_reset_helper_begin()
> > @@ -1046,10 +1048,10 @@ void
> > amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
> > * be called to restore preemption state, but it won't attempt to
> > * fully restore the ring contents.
> > */
> > -int amdgpu_multi_ring_reset_helper_end(const u32 ring_type_mask,
> > +int amdgpu_multi_ring_reset_helper_end(struct amdgpu_device *adev,
> > + const u32 ring_type_mask,
> > struct amdgpu_ring
> > *guilty_ring, int ret) {
> > - struct amdgpu_device *adev = guilty_ring->adev;
> > struct amdgpu_ring *ring;
> > int i, r;
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> > index b2040f80b7f2..7e6ed43771f2 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> > @@ -637,10 +637,12 @@ void amdgpu_ring_reset_helper_begin(struct
> > amdgpu_ring *ring,
> > struct amdgpu_fence
> > *guilty_fence); int
> > amdgpu_ring_reset_helper_end(struct amdgpu_ring *ring,
> > struct amdgpu_fence *guilty_fence);
> > -void
> > amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
> > +void amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device
> > *adev,
> > + const u32 ring_type_mask,
> > struct amdgpu_ring
> > *guilty_ring,
> > struct amdgpu_fence
> > *guilty_fence);
> > -int amdgpu_multi_ring_reset_helper_end(const u32 ring_type_mask,
> > +int amdgpu_multi_ring_reset_helper_end(struct amdgpu_device *adev,
> > + const u32 ring_type_mask,
> > struct amdgpu_ring
> > *guilty_ring, int ret);
> > bool amdgpu_ring_is_reset_type_supported(struct amdgpu_ring *ring,
> > u32 reset_type);
> > --
> > 2.50.1
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 02/13] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed
2026-11-05 3:05 ` [PATCH v4 02/13] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed Jesse Zhang
@ 2026-11-11 23:52 ` Daniel Campos Ramos
2026-11-19 11:34 ` Timur Kristóf
1 sibling, 0 replies; 29+ messages in thread
From: Daniel Campos Ramos @ 2026-11-11 23:52 UTC (permalink / raw)
To: Jesse Zhang
Cc: amd-gfx, Alexander.Deucher, Christian Koenig, Lijo.Lazar,
timur.kristof, Mario.Novales, Manu.Rastogi, Jiongyu.Zhu
Hi Timur, Jesse,
A test result from gfx6 (Southern Islands), where no ring reset runs
before the IP block soft reset. I found and tested this with the help of
an AI assistant, on my own laptop.
Machine: Radeon R5 M330/M430 (Hainan, 1002:6660) beside a Carrizo iGPU.
Test: a plain Vulkan program with one compute dispatch that runs past the
2 s lockup timeout (a counted ALU loop, no bad memory access), then one
short job to see whether the context was marked lost.
On 7.3.1 as released, one such job puts the ring into this loop until a
reboot, every 3.45 s (a WebGPU page did the same: 1,449 timeouts of one
sequence number):
amdgpu 0000:03:00.0: ring gfx timeout, signaled seq=30, emitted seq=31
amdgpu 0000:03:00.0: Starting gfx_v6_0 IP block soft reset
amdgpu 0000:03:00.0: Successful gfx_v6_0 IP block soft reset
amdgpu 0000:03:00.0: [drm] device wedged, but no recovery needed
The devcoredumps show why: after the first soft reset the replayed
stream is consumed (Rptr == Wptr) but the fence is not written within
the next 2 s; at the next timeout the backup helper sees the same guilty
fence, clears ring->guilty_fence and backs up nothing, and
amdgpu_multi_ring_reset_helper_end() passes that NULL on, so nothing
ever completes the fence.
With this patch (v4 02/13) on 7.3.1, same program, same machine:
- two 8 s jobs: 2 timeouts each, then nothing more;
- one 60 s job: 3 timeouts, the job ended 10.8 s after it was submitted.
In all three the next submission returned VK_ERROR_DEVICE_LOST, nothing
was left in D state, and the session kept running.
For comparison, v3 02/15 ("complete the guilty fence at the end of a
multi ring reset") on the same 7.3.1: 2 timeouts for each 8 s job, 1 for
the 60 s job (ended after 3.4 s), the same result otherwise.
So on this chip both end the loop. One run of each case; I backported
only this patch's single hunk (01/13 not needed for it to apply).
I can send the test program and the dumps if they are useful.
Thanks,
Daniel
Tested-by: Daniel Campos Ramos <Capitain_Jack@yahoo.com> # gfx6, Hainan
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
` (12 preceding siblings ...)
2026-11-10 2:06 ` [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Zhang, Jesse(Jie)
@ 2026-11-19 11:33 ` Timur Kristóf
13 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:33 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> amdgpu_multi_ring_reset_helper_begin() and _end() take the device
> from
> the guilty ring. A reset triggered by a hung user queue has no guilty
> kernel ring, so pass the device explicitly and allow a NULL guilty
> ring.
>
> No functional change.
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c | 4 ++--
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 14 ++++++++------
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 6 ++++--
> 3 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> index 734f2a0bc79a..d0b0d3eaffc5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> @@ -465,11 +465,11 @@ int amdgpu_device_ip_soft_reset(struct
> amdgpu_ring *guilty_ring,
> ring_type_mask = amdgpu_ring_mask_from_ip(ip_type);
>
> amdgpu_device_lock_reset_domain(adev->reset_domain);
> - amdgpu_multi_ring_reset_helper_begin(ring_type_mask,
> guilty_ring, guilty_fence);
> + amdgpu_multi_ring_reset_helper_begin(adev, ring_type_mask,
> guilty_ring, guilty_fence);
>
> r = ip_block->version->funcs->soft_reset(ip_block);
>
> - r = amdgpu_multi_ring_reset_helper_end(ring_type_mask,
> guilty_ring, r);
> + r = amdgpu_multi_ring_reset_helper_end(adev, ring_type_mask,
> guilty_ring, r);
> amdgpu_device_unlock_reset_domain(adev->reset_domain);
>
> if (r) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> index 7b67e8cecca2..edae764eb0c4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> @@ -919,8 +919,9 @@ int amdgpu_ring_reset_helper_end(struct
> amdgpu_ring *ring,
> /**
> * amdgpu_multi_ring_reset_helper_begin() - Prepare multiple rings
> for a reset.
> *
> + * @adev: amdgpu device
> * @ring_type_mask: Bitmask of affected ring types
> - * @guilty_ring: The ring which is guilty of causing a reset.
> + * @guilty_ring: The ring which is guilty of causing a reset, or
> NULL.
> * @guilty_fence: The fence which didn't signal on the guilty ring.
> *
> * Useful when performing a GPU reset method that affects
> @@ -938,11 +939,11 @@ int amdgpu_ring_reset_helper_end(struct
> amdgpu_ring *ring,
> * After the reset is complete, the caller should then call
> * amdgpu_multi_ring_reset_helper_end() to restore the rings.
> */
> -void amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
> +void amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device
> *adev,
> + const u32 ring_type_mask,
> struct amdgpu_ring
> *guilty_ring,
> struct amdgpu_fence
> *guilty_fence)
> {
> - struct amdgpu_device *adev = guilty_ring->adev;
> struct amdgpu_fence *ring_guilty_fence;
> struct amdgpu_ring *ring;
> bool rings_busy;
> @@ -1034,8 +1035,9 @@ void amdgpu_multi_ring_reset_helper_begin(const
> u32 ring_type_mask,
> /**
> * amdgpu_multi_ring_reset_helper_end() - Prepare multiple rings for
> a reset.
> *
> + * @adev: amdgpu device
> * @ring_type_mask: Bitmask of affected ring types
> - * @guilty_ring: The ring which is guilty of causing a reset.
> + * @guilty_ring: The ring which is guilty of causing a reset, or
> NULL.
> * @ret: Return code from the reset function.
> *
> * After calling amdgpu_multi_ring_reset_helper_begin()
> @@ -1046,10 +1048,10 @@ void
> amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
> * be called to restore preemption state, but it won't attempt to
> * fully restore the ring contents.
> */
> -int amdgpu_multi_ring_reset_helper_end(const u32 ring_type_mask,
> +int amdgpu_multi_ring_reset_helper_end(struct amdgpu_device *adev,
> + const u32 ring_type_mask,
> struct amdgpu_ring
> *guilty_ring, int ret)
> {
> - struct amdgpu_device *adev = guilty_ring->adev;
> struct amdgpu_ring *ring;
> int i, r;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> index b2040f80b7f2..7e6ed43771f2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> @@ -637,10 +637,12 @@ void amdgpu_ring_reset_helper_begin(struct
> amdgpu_ring *ring,
> struct amdgpu_fence
> *guilty_fence);
> int amdgpu_ring_reset_helper_end(struct amdgpu_ring *ring,
> struct amdgpu_fence *guilty_fence);
> -void amdgpu_multi_ring_reset_helper_begin(const u32 ring_type_mask,
> +void amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device
> *adev,
> + const u32 ring_type_mask,
> struct amdgpu_ring
> *guilty_ring,
> struct amdgpu_fence
> *guilty_fence);
> -int amdgpu_multi_ring_reset_helper_end(const u32 ring_type_mask,
> +int amdgpu_multi_ring_reset_helper_end(struct amdgpu_device *adev,
> + const u32 ring_type_mask,
> struct amdgpu_ring
> *guilty_ring, int ret);
> bool amdgpu_ring_is_reset_type_supported(struct amdgpu_ring *ring,
> u32 reset_type);
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 02/13] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed
2026-11-05 3:05 ` [PATCH v4 02/13] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed Jesse Zhang
2026-11-11 23:52 ` Daniel Campos Ramos
@ 2026-11-19 11:34 ` Timur Kristóf
1 sibling, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:34 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> From: Timur Kristóf <timur.kristof@gmail.com>
>
> This is necessary to make soft reset work after a failed queue
> reset. Otherwise the ring reset begin helper would clear out
> the guilty fence and the backed up ring contents.
>
> v2: skip the begin helper only for the guilty ring already backed up
> by
> the failed ring reset, and keep backing up the other rings
> (Jesse).
>
> Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Thanks for including this patch.
Considering that this fixes a real issue with repeated soft reset, I
recommend adding a Fixes tag to this commit:
Fixes: 1fc76380c6ce ("drm/amdgpu: Add IP block soft reset as a GPU recovery method")
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> index edae764eb0c4..c71e1c3b6d7b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> @@ -1027,8 +1027,10 @@ void
> amdgpu_multi_ring_reset_helper_begin(struct amdgpu_device *adev,
> * Backup current contents of the ring.
> * The helper takes care to only reemit unsignalled
> fences
> * so we don't have to worry about that here.
> + * A failed ring reset of the same job already
> backed it up.
> */
> - amdgpu_ring_reset_helper_begin(ring,
> ring_guilty_fence);
> + if (ring != guilty_ring || ring->guilty_fence !=
> guilty_fence)
> + amdgpu_ring_reset_helper_begin(ring,
> ring_guilty_fence);
> }
> }
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 03/13] drm/amdgpu: add an engine scope to the IP block soft reset
2026-11-05 3:05 ` [PATCH v4 03/13] drm/amdgpu: add an engine scope to the IP block soft reset Jesse Zhang
@ 2026-11-19 11:35 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:35 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> Some IP blocks have engines the hardware can reset on their own, eg.
> the graphics and compute engines of the GFX IP. Add an optional
> soft_reset_engine() callback, which resets the engine of a ring type
> and
> recovers its user queues. amdgpu_device_ip_soft_reset() uses it
> instead
> of soft_reset(), and then only stops and replays the rings of that
> type,
> holding the reset domain for read: KFD can still add and remove
> queues
> on the other engines.
>
> A hung user queue has no kernel ring, so
> amdgpu_device_ip_soft_reset()
> now takes the device and the ring type, and an optional guilty ring
> and
> user queue.
>
> v3: New patch, replaces the separate engine reset type and helper
> (Timur).
> v4: Fold the engine reset into amdgpu_device_ip_soft_reset(), and
> take
> the ring type instead of a new engine enum (Timur).
>
> Suggested-by: Timur Kristóf <timur.kristof@gmail.com>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c | 59 ++++++++++++++++------
> --
> drivers/gpu/drm/amd/amdgpu/amdgpu_ip.h | 7 ++-
> drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 3 +-
> drivers/gpu/drm/amd/include/amd_shared.h | 6 +++
> 4 files changed, 52 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> index d0b0d3eaffc5..9d75bdb2c14b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c
> @@ -421,8 +421,11 @@ static u32 amdgpu_ring_mask_from_ip(const enum
> amd_ip_block_type ip_type)
> /**
> * amdgpu_device_ip_soft_reset() - Perform a graceful soft reset on
> an IP block.
> *
> - * @guilty_ring: The ring which is guilty of causing a reset.
> - * @guilty_fence: The fence which didn't signal.
> + * @adev: amdgpu device
> + * @ring_type: The type of the ring or user queue that hung.
> + * @guilty_ring: The ring which is guilty of causing a reset, or
> NULL.
> + * @guilty_fence: The fence which didn't signal on @guilty_ring.
> + * @guilty_queue: The user queue which is guilty of causing a reset,
> or NULL.
> *
> * IP block soft reset is used when attempting to recover
> * from a GPU hang in a situation where a more fine grained
> @@ -430,55 +433,71 @@ static u32 amdgpu_ring_mask_from_ip(const enum
> amd_ip_block_type ip_type)
> * resets all rings that belong to the same device IP block
> * and re-initializes the device IP block.
> *
> + * IP blocks implementing soft_reset_engine() only reset the engine
> of
> + * @ring_type and its rings, and recover its user queues.
> + *
> * The reset is handled gracefully, meaning that we try to
> * minimize collateral damage (ie. avoid rejecting non-guilty jobs)
> * as well as back up and restore the contents of all rings
> * so that the system can move on from the hang.
> */
> -int amdgpu_device_ip_soft_reset(struct amdgpu_ring *guilty_ring,
> - struct amdgpu_fence *guilty_fence)
> +int amdgpu_device_ip_soft_reset(struct amdgpu_device *adev,
> + enum amdgpu_ring_type ring_type,
> + struct amdgpu_ring *guilty_ring,
> + struct amdgpu_fence *guilty_fence,
> + struct amdgpu_usermode_queue
> *guilty_queue)
> {
> - struct amdgpu_device *adev = guilty_ring->adev;
> + const struct amd_ip_funcs *funcs;
> struct amdgpu_ip_block *ip_block;
> enum amd_ip_block_type ip_type;
> u32 ring_type_mask;
> + bool engine;
> int r;
>
> - ip_type = amdgpu_ip_from_ring(guilty_ring->funcs->type);
> + ip_type = amdgpu_ip_from_ring(ring_type);
> ip_block = amdgpu_device_ip_get_ip_block(adev, ip_type);
>
> if (unlikely(!ip_block)) {
> - dev_warn(adev->dev, "IP block not found for ring
> %s\n",
> - guilty_ring->name);
> + dev_warn(adev->dev, "IP block not found for ring
> type %d\n",
> + ring_type);
> return -EOPNOTSUPP;
> }
>
> - if (!ip_block->version->funcs->soft_reset) {
> + funcs = ip_block->version->funcs;
> + engine = funcs->soft_reset_engine;
> + if (!engine && (!funcs->soft_reset || !guilty_ring)) {
> dev_warn(adev->dev, "IP block soft reset not
> supported on %s\n",
> - ip_block->version->funcs->name);
> + funcs->name);
> return -EOPNOTSUPP;
> }
>
> - dev_err(adev->dev, "Starting %s IP block soft reset\n",
> - ip_block->version->funcs->name);
> -
> - ring_type_mask = amdgpu_ring_mask_from_ip(ip_type);
> + dev_err(adev->dev, "Starting %s IP block soft reset\n",
> funcs->name);
>
> - amdgpu_device_lock_reset_domain(adev->reset_domain);
> + /* An engine reset leaves the others running: let KFD
> add/remove queues. */
> + if (engine) {
> + ring_type_mask = BIT(ring_type);
> + down_read(&adev->reset_domain->sem);
> + } else {
> + ring_type_mask = amdgpu_ring_mask_from_ip(ip_type);
> + amdgpu_device_lock_reset_domain(adev->reset_domain);
> + }
> amdgpu_multi_ring_reset_helper_begin(adev, ring_type_mask,
> guilty_ring, guilty_fence);
>
> - r = ip_block->version->funcs->soft_reset(ip_block);
> + r = engine ? funcs->soft_reset_engine(ip_block, ring_type,
> guilty_queue) :
> + funcs->soft_reset(ip_block);
>
> r = amdgpu_multi_ring_reset_helper_end(adev, ring_type_mask,
> guilty_ring, r);
> - amdgpu_device_unlock_reset_domain(adev->reset_domain);
> + if (engine)
> + up_read(&adev->reset_domain->sem);
> + else
> + amdgpu_device_unlock_reset_domain(adev-
> >reset_domain);
>
> if (r) {
> dev_err(adev->dev, "Failed %s IP block soft reset:
> %d\n",
> - ip_block->version->funcs->name, r);
> + funcs->name, r);
> return r;
> }
>
> - dev_err(adev->dev, "Successful %s IP block soft reset\n",
> - ip_block->version->funcs->name);
> + dev_err(adev->dev, "Successful %s IP block soft reset\n",
> funcs->name);
> return 0;
> }
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.h
> index 5dd6273982c4..6532c16b1a15 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ip.h
> @@ -158,7 +158,10 @@ int amdgpu_device_ip_wait_for_idle(struct
> amdgpu_device *adev,
> enum amd_ip_block_type
> block_type);
> bool amdgpu_device_ip_is_valid(struct amdgpu_device *adev,
> enum amd_ip_block_type block_type);
> -int amdgpu_device_ip_soft_reset(struct amdgpu_ring *guilty_ring,
> - struct amdgpu_fence *guilty_fence);
> +int amdgpu_device_ip_soft_reset(struct amdgpu_device *adev,
> + enum amdgpu_ring_type ring_type,
> + struct amdgpu_ring *guilty_ring,
> + struct amdgpu_fence *guilty_fence,
> + struct amdgpu_usermode_queue
> *guilty_queue);
>
> #endif /* __AMDGPU_IP_H__ */
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> index 8689a3c933b2..cb72d273bd52 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> @@ -154,7 +154,8 @@ static enum drm_gpu_sched_stat
> amdgpu_job_timedout(struct drm_sched_job *s_job)
> /* Attempt an IP block soft reset, if supported. */
> if (amdgpu_gpu_recovery &&
> amdgpu_ring_is_reset_type_supported(ring,
> AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET)) {
> - r = amdgpu_device_ip_soft_reset(ring, job-
> >hw_fence);
> + r = amdgpu_device_ip_soft_reset(adev, ring->funcs-
> >type, ring,
> + job->hw_fence,
> NULL);
> if (!r) {
> atomic_inc(&ring->adev->gpu_reset_counter);
> drm_dev_wedged_event(adev_to_drm(adev),
> DRM_WEDGE_RECOVERY_NONE, info);
> diff --git a/drivers/gpu/drm/amd/include/amd_shared.h
> b/drivers/gpu/drm/amd/include/amd_shared.h
> index e81ce9d79009..06874a338b27 100644
> --- a/drivers/gpu/drm/amd/include/amd_shared.h
> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
> @@ -29,6 +29,7 @@
>
> #define AMD_MAX_USEC_TIMEOUT 1000000 /* 1000 ms */
> struct amdgpu_ip_block;
> +struct amdgpu_usermode_queue;
>
>
> /*
> @@ -421,6 +422,7 @@ enum DC_DEBUG_MASK {
> };
>
> enum amd_dpm_forced_level;
> +enum amdgpu_ring_type;
>
> /**
> * struct amd_ip_funcs - general hooks for managing amdgpu IP Blocks
> @@ -441,6 +443,7 @@ enum amd_dpm_forced_level;
> * @complete: handles IP specific changes after resume
> * @wait_for_idle: poll for idle
> * @soft_reset: soft reset the IP block
> + * @soft_reset_engine: soft reset the engine of a ring type and its
> user queues
> * @set_clockgating_state: enable/disable cg for the IP block
> * @set_powergating_state: enable/disable pg for the IP block
> * @get_clockgating_state: get current clockgating status
> @@ -469,6 +472,9 @@ struct amd_ip_funcs {
> void (*complete)(struct amdgpu_ip_block *ip_block);
> int (*wait_for_idle)(struct amdgpu_ip_block *ip_block);
> int (*soft_reset)(struct amdgpu_ip_block *ip_block);
> + int (*soft_reset_engine)(struct amdgpu_ip_block *ip_block,
> + enum amdgpu_ring_type ring_type,
> + struct amdgpu_usermode_queue
> *guilty_queue);
> int (*set_clockgating_state)(struct amdgpu_ip_block
> *ip_block,
> enum amd_clockgating_state
> state);
> int (*set_powergating_state)(struct amdgpu_ip_block
> *ip_block,
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 04/13] drm/amdgpu/gfx: add callbacks to save and restore a gfx HQD
2026-11-05 3:05 ` [PATCH v4 04/13] drm/amdgpu/gfx: add callbacks to save and restore a gfx HQD Jesse Zhang
@ 2026-11-19 11:35 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:35 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> A gfx engine reset clears the HQD registers of the gfx queues,
> including
> the only copy of the ring position of the queues MES didn't preempt.
> MES doesn't save them in the MQD either when the engine hangs.
>
> Add struct amdgpu_gfx_saved_hqd for that state, and gfx callbacks for
> the gfx IP, which knows its registers and the layout of its MQD:
> - save_hqd() saves the state of the gfx HQD of a doorbell;
> - restore_hqd() writes it into the MQD after the reset, for MES to
> load
> it into the HQD when it maps the queue again.
>
> v4: Rename to save_hqd()/restore_hqd() and struct
> amdgpu_gfx_saved_hqd
> (Timur).
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> index 5939e1fb3b24..1c23e97fd04d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> @@ -345,6 +345,17 @@ struct amdgpu_gfx_shadow_info {
> u32 eop_alignment;
> };
>
> +/* State of a gfx HQD that a gfx engine reset clears. */
> +struct amdgpu_gfx_saved_hqd {
> + u32 doorbell_index;
> + u64 mqd_addr; /* the MQD loaded in the HQD */
> + bool on_hqd;
> + u64 wptr;
> + u32 offset;
> + u32 csmd_rptr;
> + bool connected; /* the queue the pipe executes */
> +};
> +
> struct amdgpu_gfx_funcs {
> /* get the gpu clock counter */
> uint64_t (*get_gpu_clock_counter)(struct amdgpu_device
> *adev);
> @@ -376,6 +387,17 @@ struct amdgpu_gfx_funcs {
> /* find the gfx HQD slot (me/pipe/queue) for a doorbell */
> bool (*detect_hung_queue)(struct amdgpu_device *adev, u32
> doorbell_index,
> u32 *me, u32 *pipe, u32 *queue);
> + /* save the state of the gfx HQD of a doorbell, if it has
> one */
> + bool (*save_hqd)(struct amdgpu_device *adev, u32
> doorbell_index,
> + struct amdgpu_gfx_saved_hqd *hqd);
> + /*
> + * write the HQD state saved by save_hqd() into a gfx MQD,
> for MES to
> + * load it into the HQD when it maps the queue again;
> + * true if the work up to hqd->wptr was dropped
> + */
> + bool (*restore_hqd)(struct amdgpu_device *adev, void *mqd,
> + u32 ring_size,
> + const struct amdgpu_gfx_saved_hqd *hqd);
> };
>
> struct sq_work {
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 05/13] drm/amdgpu/gfx12: save and restore a gfx HQD
2026-11-05 3:05 ` [PATCH v4 05/13] drm/amdgpu/gfx12: " Jesse Zhang
@ 2026-11-19 11:35 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:35 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> Implement the gfx callbacks to save and restore a gfx HQD for gfx12:
> - save_hqd() saves the HQD offset, CSMD read pointer and write
> pointer
> of the gfx HQD of a doorbell, and whether the queue is the one
> connected to its pipe;
> - restore_hqd() writes them into the MQD after a reset, for MES to
> map
> the queue again where it was. A queue switched out of the pipe
> resumes
> from the preemption status the PFP saved in its MQD, also in the
> middle of an IB. The queue the pipe was executing has its state in
> the
> PFP, which the reset cleared: it restarts after the work submitted
> so
> far instead, and that work is dropped.
>
> v4: Rename to save_hqd()/restore_hqd() (Timur).
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
The code looks good, though I didn't test the series yet on GFX12 yet.
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 83
> ++++++++++++++++++++++++++
> 1 file changed, 83 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> index cb15dad0e57b..484e876fe235 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> @@ -274,6 +274,11 @@ static void gfx_v12_0_set_imu_funcs(struct
> amdgpu_device *adev);
> static int gfx_v12_0_get_cu_info(struct amdgpu_device *adev,
> struct amdgpu_cu_info *cu_info);
> static uint64_t gfx_v12_0_get_gpu_clock_counter(struct amdgpu_device
> *adev);
> +static bool gfx_v12_0_save_hqd(struct amdgpu_device *adev, u32
> doorbell_index,
> + struct amdgpu_gfx_saved_hqd *hqd);
> +static bool gfx_v12_0_restore_hqd(struct amdgpu_device *adev, void
> *m,
> + u32 ring_size,
> + const struct amdgpu_gfx_saved_hqd
> *hqd);
> static void gfx_v12_0_select_se_sh(struct amdgpu_device *adev, u32
> se_num,
> u32 sh_num, u32 instance, int
> xcc_id);
> static u32 gfx_v12_0_get_wgp_active_bitmap_per_sh(struct
> amdgpu_device *adev);
> @@ -962,6 +967,8 @@ static const struct amdgpu_gfx_funcs
> gfx_v12_0_gfx_funcs = {
> .update_perfmon_mgcg = &gfx_v12_0_update_perf_clk,
> .get_gfx_shadow_info = &gfx_v12_0_get_gfx_shadow_info,
> .get_hdp_flush_mask = &amdgpu_gfx_get_hdp_flush_mask,
> + .save_hqd = &gfx_v12_0_save_hqd,
> + .restore_hqd = &gfx_v12_0_restore_hqd,
> };
>
> static int gfx_v12_0_gpu_early_init(struct amdgpu_device *adev)
> @@ -3853,6 +3860,82 @@ static int gfx_v12_0_wait_for_idle(struct
> amdgpu_ip_block *ip_block)
> return -ETIMEDOUT;
> }
>
> +#define GFX12_HPD_QUEUE_STATE_CONNECTED_MIN 3
> +#define GFX12_HPD_QUEUE_STATE_CONNECTED_MAX 15
> +
> +static bool gfx_v12_0_save_hqd(struct amdgpu_device *adev, u32
> doorbell_index,
> + struct amdgpu_gfx_saved_hqd *hqd)
> +{
> + u32 me, pipe, queue, status, state;
> +
> + memset(hqd, 0, sizeof(*hqd));
> + hqd->doorbell_index = doorbell_index;
> + if (!gfx_v12_0_detect_hung_queue(adev, doorbell_index, &me,
> &pipe, &queue))
> + return true;
> +
> + amdgpu_gfx_off_ctrl(adev, false);
> + mutex_lock(&adev->srbm_mutex);
> + soc24_grbm_select(adev, me, pipe, queue, 0);
> + hqd->on_hqd = RREG32_SOC15(GC, 0, regCP_GFX_HQD_ACTIVE) &
> + CP_GFX_HQD_ACTIVE__ACTIVE_MASK;
> + if (!hqd->on_hqd)
> + goto out;
> + hqd->mqd_addr = RREG32_SOC15(GC, 0, regCP_GFX_MQD_BASE_ADDR)
> |
> + (u64)RREG32_SOC15(GC, 0,
> regCP_GFX_MQD_BASE_ADDR_HI) << 32;
> + hqd->offset = RREG32_SOC15(GC, 0, regCP_GFX_HQD_OFFSET);
> + hqd->csmd_rptr = RREG32_SOC15(GC, 0,
> regCP_GFX_HQD_CSMD_RPTR);
> + hqd->wptr = RREG32_SOC15(GC, 0, regCP_GFX_HQD_WPTR) |
> + (u64)RREG32_SOC15(GC, 0, regCP_GFX_HQD_WPTR_HI)
> << 32;
> + status = RREG32_SOC15(GC, 0, regCP_GFX_HPD_STATUS0);
> + state = REG_GET_FIELD(status, CP_GFX_HPD_STATUS0,
> QUEUE_STATE);
> + hqd->connected =
> + state >= GFX12_HPD_QUEUE_STATE_CONNECTED_MIN &&
> + state <= GFX12_HPD_QUEUE_STATE_CONNECTED_MAX &&
> + REG_GET_FIELD(status, CP_GFX_HPD_STATUS0,
> MAPPED_QUEUE) == queue;
> +out:
> + soc24_grbm_select(adev, 0, 0, 0, 0);
> + mutex_unlock(&adev->srbm_mutex);
> + amdgpu_gfx_off_ctrl(adev, true);
> +
> + return true;
> +}
> +
> +static bool gfx_v12_0_restore_hqd(struct amdgpu_device *adev, void
> *m,
> + u32 ring_size,
> + const struct amdgpu_gfx_saved_hqd
> *hqd)
> +{
> + struct v12_gfx_mqd *mqd = m;
> + u32 wptr = lower_32_bits(hqd->wptr) & ((ring_size >> 2) -
> 1);
> + u32 *status;
> +
> + /*
> + * MQD dwords 32-41 (reserved_32..41) are the PFP preemption
> status,
> + * mcbp_status_pfp: the offset and chained IB size and
> address of IB1
> + * (32-35) and IB2 (36-39), rb_preempt (40: preempted in the
> ring) and
> + * completion_status (41: 0 IB not started, 1 preempted
> inside an IB,
> + * 2 IB completed, 3 IB resumed). The PFP saves it when the
> queue is
> + * switched out of the pipe and resumes from it when the
> queue runs
> + * again, at the HQD offset. That survives the reset for a
> queue that
> + * was switched out. The queue the pipe executed has its
> state in the
> + * PFP, which the reset cleared: restart it at the write
> pointer with
> + * no IB to resume, and drop its work in flight.
> + */
> + if (hqd->connected) {
> + mqd->cp_gfx_hqd_offset = wptr;
> + mqd->cp_gfx_hqd_csmd_rptr = wptr;
> + for (status = &mqd->reserved_32; status <= &mqd-
> >reserved_41; status++)
> + *status = 0;
> + } else {
> + mqd->cp_gfx_hqd_offset = hqd->offset;
> + mqd->cp_gfx_hqd_csmd_rptr = hqd->csmd_rptr;
> + }
> + mqd->cp_gfx_hqd_wptr = lower_32_bits(hqd->wptr);
> + mqd->cp_gfx_hqd_wptr_hi = upper_32_bits(hqd->wptr);
> + mqd->cp_gfx_hqd_active = 0;
> +
> + return hqd->connected;
> +}
> +
> static uint64_t gfx_v12_0_get_gpu_clock_counter(struct amdgpu_device
> *adev)
> {
> uint64_t clock = 0;
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 06/13] drm/amdgpu/gfx11: save and restore a gfx HQD
2026-11-05 3:05 ` [PATCH v4 06/13] drm/amdgpu/gfx11: " Jesse Zhang
@ 2026-11-19 11:36 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:36 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> Implement the gfx callbacks to save and restore a gfx HQD for gfx11:
> - save_hqd() saves the HQD offset, CSMD read pointer and write
> pointer
> of the gfx HQD of a doorbell, and whether the queue is the one
> connected to its pipe;
> - restore_hqd() writes them into the MQD after a reset, for MES to
> map
> the queue again where it was. A queue switched out of the pipe
> resumes
> from the preemption status the PFP saved in its MQD, also in the
> middle of an IB. The queue the pipe was executing has its state in
> the
> PFP, which the reset cleared: it restarts after the work submitted
> so
> far instead, and that work is dropped.
>
> v4: Rename to save_hqd()/restore_hqd() (Timur).
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 83
> ++++++++++++++++++++++++++
> 1 file changed, 83 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index 430b8f3743b2..798015689f0c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -365,6 +365,11 @@ static void gfx_v11_0_unset_safe_mode(struct
> amdgpu_device *adev, int xcc_id);
> static void gfx_v11_0_update_spm_vmid(struct amdgpu_device *adev,
> int xcc_id,
> unsigned int vmid);
> static void gfx_v11_0_userq_priv_fault_work(struct work_struct
> *work);
> +static bool gfx_v11_0_save_hqd(struct amdgpu_device *adev, u32
> doorbell_index,
> + struct amdgpu_gfx_saved_hqd *hqd);
> +static bool gfx_v11_0_restore_hqd(struct amdgpu_device *adev, void
> *m,
> + u32 ring_size,
> + const struct amdgpu_gfx_saved_hqd
> *hqd);
> static void gfx_v11_0_update_perf_clk(struct amdgpu_device *adev,
> bool enable);
>
> @@ -1150,6 +1155,8 @@ static const struct amdgpu_gfx_funcs
> gfx_v11_0_gfx_funcs = {
> .get_gfx_shadow_info = &gfx_v11_0_get_gfx_shadow_info,
> .get_hdp_flush_mask = &amdgpu_gfx_get_hdp_flush_mask,
> .detect_hung_queue = &gfx_v11_0_detect_hung_queue,
> + .save_hqd = &gfx_v11_0_save_hqd,
> + .restore_hqd = &gfx_v11_0_restore_hqd,
> };
>
> static int gfx_v11_0_gpu_early_init(struct amdgpu_device *adev)
> @@ -6770,6 +6777,82 @@ static void gfx_v11_0_emit_mem_sync(struct
> amdgpu_ring *ring)
> amdgpu_ring_write(ring, gcr_cntl); /* GCR_CNTL */
> }
>
> +#define GFX11_HPD_QUEUE_STATE_CONNECTED_MIN 3
> +#define GFX11_HPD_QUEUE_STATE_CONNECTED_MAX 15
> +
> +static bool gfx_v11_0_save_hqd(struct amdgpu_device *adev, u32
> doorbell_index,
> + struct amdgpu_gfx_saved_hqd *hqd)
> +{
> + u32 me, pipe, queue, status, state;
> +
> + memset(hqd, 0, sizeof(*hqd));
> + hqd->doorbell_index = doorbell_index;
> + if (!gfx_v11_0_detect_hung_queue(adev, doorbell_index, &me,
> &pipe, &queue))
> + return true;
> +
> + amdgpu_gfx_off_ctrl(adev, false);
> + mutex_lock(&adev->srbm_mutex);
> + soc21_grbm_select(adev, me, pipe, queue, 0);
> + hqd->on_hqd = RREG32_SOC15(GC, 0, regCP_GFX_HQD_ACTIVE) &
> + CP_GFX_HQD_ACTIVE__ACTIVE_MASK;
> + if (!hqd->on_hqd)
> + goto out;
> + hqd->mqd_addr = RREG32_SOC15(GC, 0, regCP_GFX_MQD_BASE_ADDR)
> |
> + (u64)RREG32_SOC15(GC, 0,
> regCP_GFX_MQD_BASE_ADDR_HI) << 32;
> + hqd->offset = RREG32_SOC15(GC, 0, regCP_GFX_HQD_OFFSET);
> + hqd->csmd_rptr = RREG32_SOC15(GC, 0,
> regCP_GFX_HQD_CSMD_RPTR);
> + hqd->wptr = RREG32_SOC15(GC, 0, regCP_GFX_HQD_WPTR) |
> + (u64)RREG32_SOC15(GC, 0, regCP_GFX_HQD_WPTR_HI)
> << 32;
> + status = RREG32_SOC15(GC, 0, regCP_GFX_HPD_STATUS0);
> + state = REG_GET_FIELD(status, CP_GFX_HPD_STATUS0,
> QUEUE_STATE);
> + hqd->connected =
> + state >= GFX11_HPD_QUEUE_STATE_CONNECTED_MIN &&
> + state <= GFX11_HPD_QUEUE_STATE_CONNECTED_MAX &&
> + REG_GET_FIELD(status, CP_GFX_HPD_STATUS0,
> MAPPED_QUEUE) == queue;
> +out:
> + soc21_grbm_select(adev, 0, 0, 0, 0);
> + mutex_unlock(&adev->srbm_mutex);
> + amdgpu_gfx_off_ctrl(adev, true);
> +
> + return true;
> +}
> +
> +static bool gfx_v11_0_restore_hqd(struct amdgpu_device *adev, void
> *m,
> + u32 ring_size,
> + const struct amdgpu_gfx_saved_hqd
> *hqd)
> +{
> + struct v11_gfx_mqd *mqd = m;
> + u32 wptr = lower_32_bits(hqd->wptr) & ((ring_size >> 2) -
> 1);
> + u32 *status;
> +
> + /*
> + * MQD dwords 32-41 (reserved_32..41) are the PFP preemption
> status,
> + * mcbp_status_pfp: the offset and chained IB size and
> address of IB1
> + * (32-35) and IB2 (36-39), rb_preempt (40: preempted in the
> ring) and
> + * completion_status (41: 0 IB not started, 1 preempted
> inside an IB,
> + * 2 IB completed, 3 IB resumed). The PFP saves it when the
> queue is
> + * switched out of the pipe and resumes from it when the
> queue runs
> + * again, at the HQD offset. That survives the reset for a
> queue that
> + * was switched out. The queue the pipe executed has its
> state in the
> + * PFP, which the reset cleared: restart it at the write
> pointer with
> + * no IB to resume, and drop its work in flight.
> + */
> + if (hqd->connected) {
> + mqd->cp_gfx_hqd_offset = wptr;
> + mqd->cp_gfx_hqd_csmd_rptr = wptr;
> + for (status = &mqd->reserved_32; status <= &mqd-
> >reserved_41; status++)
> + *status = 0;
> + } else {
> + mqd->cp_gfx_hqd_offset = hqd->offset;
> + mqd->cp_gfx_hqd_csmd_rptr = hqd->csmd_rptr;
> + }
> + mqd->cp_gfx_hqd_wptr = lower_32_bits(hqd->wptr);
> + mqd->cp_gfx_hqd_wptr_hi = upper_32_bits(hqd->wptr);
> + mqd->cp_gfx_hqd_active = 0;
> +
> + return hqd->connected;
> +}
> +
> static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring,
> unsigned int vmid,
> struct amdgpu_fence *timedout_fence)
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 07/13] drm/amdgpu/userq: add a helper to signal the fences of a queue up to a point
2026-11-05 3:05 ` [PATCH v4 07/13] drm/amdgpu/userq: add a helper to signal the fences of a queue up to a point Jesse Zhang
@ 2026-11-19 11:36 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:36 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> The fence value of a user queue is the write pointer of the queue
> when
> the work was submitted. amdgpu_userq_fence_driver_force_completion()
> signals all the fences of a queue, as after a reset that dropped all
> its
> work.
>
> Add amdgpu_userq_fence_driver_force_completion_with_seqno(), which
> only
> signals the fences of the work up to a write pointer, with an error,
> for
> a reset that drops only part of the work of a queue: the work
> submitted
> after that write pointer still runs.
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
> .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 31
> +++++++++++++++++++
> .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.h | 2 ++
> 2 files changed, 33 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> index dd976a50e053..d20dce32168b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> @@ -460,6 +460,37 @@
> amdgpu_userq_fence_driver_force_completion(struct
> amdgpu_usermode_queue *userq)
> }
> }
>
> +/*
> + * Signal the fences of @userq with a seqno up to @seqno with -
> ECANCELED, eg.
> + * when a reset dropped the work that would have signaled them.
> + */
> +void
> +amdgpu_userq_fence_driver_force_completion_with_seqno(struct
> amdgpu_usermode_queue *userq,
> + u64 seqno)
> +{
> + struct amdgpu_userq_fence_driver *fence_drv = userq-
> >fence_drv;
> + struct amdgpu_userq_fence *fence;
> + unsigned long flags;
> +
> + if (!fence_drv)
> + return;
> +
> + spin_lock_irqsave(&fence_drv->fence_list_lock, flags);
> + list_for_each_entry(fence, &fence_drv->fences, link) {
> + if (fence->base.seqno > seqno)
> + break;
> + spin_lock(dma_fence_spinlock(&fence->base));
> + if (!dma_fence_is_signaled_locked(&fence->base))
> + dma_fence_set_error(&fence->base, -
> ECANCELED);
> + spin_unlock(dma_fence_spinlock(&fence->base));
> + }
> + if (amdgpu_userq_fence_read(fence_drv) < seqno)
> + amdgpu_userq_fence_write(fence_drv, seqno);
> + spin_unlock_irqrestore(&fence_drv->fence_list_lock, flags);
> +
> + amdgpu_userq_fence_driver_process(fence_drv);
> +}
> +
> int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
> struct drm_file *filp)
> {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h
> index 0bd51616cef1..0407c8c2575f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h
> @@ -65,6 +65,8 @@ int amdgpu_userq_fence_driver_alloc(struct
> amdgpu_device *adev,
> void amdgpu_userq_fence_driver_free(struct amdgpu_usermode_queue
> *userq);
> int amdgpu_userq_fence_driver_process(struct
> amdgpu_userq_fence_driver *fence_drv);
> void amdgpu_userq_fence_driver_force_completion(struct
> amdgpu_usermode_queue *userq);
> +void amdgpu_userq_fence_driver_force_completion_with_seqno(struct
> amdgpu_usermode_queue *userq,
> + u64
> seqno);
> void amdgpu_userq_fence_driver_destroy(struct kref *ref);
> int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
> struct drm_file *filp);
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 08/13] drm/amdgpu/userq: add helpers to keep the user queues of one engine across a reset
2026-11-05 3:05 ` [PATCH v4 08/13] drm/amdgpu/userq: add helpers to keep the user queues of one engine across a reset Jesse Zhang
@ 2026-11-19 11:36 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:36 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> An engine reset, eg. of the gfx engine, only resets the queues of one
> engine of the GFX IP; the queues of the other engines aren't reset.
> amdgpu_userq_pre_reset() and amdgpu_userq_post_reset() handle all the
> user queues for a full reset. Add separate helpers for the queues of
> one
> engine, which keep them in the state they had:
>
> - amdgpu_userq_save_hqds(), called after the MES suspend, saves the
> HQD
> of the mapped queues still on a HQD: the reset clears their HQD,
> and
> MES couldn't preempt them into their MQD. The queues MES preempted
> have their state in their MQD already.
> - amdgpu_userq_restore_hqds(), called after the reset but before MES
> resumes, unmaps those queues, writes the saved HQD into their MQD
> and
> maps them again: MES doesn't map a queue whose HQD the reset
> cleared
> again on its own. The queues keep their state and their work,
> except
> the one the pipe executed: its work in flight depends on pipe state
> the reset cleared, it is dropped and its fences signaled. The queue
> that hung, if any, is unmapped and hung.
> - amdgpu_userq_clear_hqds() drops the saved HQDs for the full reset
> that
> follows a failed engine reset.
>
> The helpers walk the queues and unmap and map them as
> amdgpu_userq_pre_reset() and amdgpu_userq_post_reset() do. The saved
> HQDs are kept in the gfx IP, in saved_gfx_hqds[], and matched to a
> queue
> by its doorbell and MQD address.
>
> v2: Drop the user queue reset lock and the walk over the queues of
> one
> type (Christian).
> v4: Rename the helpers and the saved HQD array (Timur).
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 107
> ++++++++++++++++++++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 4 +
> 3 files changed, 114 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> index 1c23e97fd04d..79cb6be75329 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> @@ -515,6 +515,9 @@ struct amdgpu_gfx {
>
> /* reset mask */
> uint32_t gfx_supported_reset;
> + /* HQDs of the gfx user queues, saved by an engine reset */
> + struct
> amdgpu_gfx_saved_hqd saved_gfx_hqds[AMDGPU_MAX_GFX_QUEUES];
> + u32 num_saved_gfx_hqds;
> uint32_t compute_supported_reset;
>
> /* gfx off */
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index ccf0ff490ac2..7d0c4e8795b4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -1594,3 +1594,110 @@ int amdgpu_userq_post_reset(struct
> amdgpu_device *adev, bool vram_lost)
>
> return ret;
> }
> +
> +/**
> + * amdgpu_userq_save_hqds - save the HQDs of the user queues before
> an engine reset
> + * @adev: amdgpu device
> + * @queue_type: AMDGPU_HW_IP_* type of the queues on the reset
> engine
> + */
> +void amdgpu_userq_save_hqds(struct amdgpu_device *adev, u32
> queue_type)
> +{
> + struct amdgpu_gfx_saved_hqd hqd;
> + struct amdgpu_usermode_queue *queue;
> + unsigned long queue_id;
> +
> + adev->gfx.num_saved_gfx_hqds = 0;
> + if (!adev->gfx.funcs->save_hqd)
> + return;
> +
> + xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
> + if (adev->gfx.num_saved_gfx_hqds >=
> AMDGPU_MAX_GFX_QUEUES)
> + break;
> + if (queue->queue_type != queue_type ||
> + queue->state != AMDGPU_USERQ_STATE_MAPPED)
> + continue;
> + if (adev->gfx.funcs->save_hqd(adev, queue-
> >doorbell_index, &hqd) &&
> + hqd.on_hqd)
> + adev->gfx.saved_gfx_hqds[adev-
> >gfx.num_saved_gfx_hqds++] = hqd;
> + }
> +}
> +
> +static struct amdgpu_gfx_saved_hqd *
> +amdgpu_userq_find_saved_hqd(struct amdgpu_device *adev,
> + struct amdgpu_usermode_queue *queue)
> +{
> + struct amdgpu_gfx_saved_hqd *hqd;
> + u32 i;
> +
> + for (i = 0; i < adev->gfx.num_saved_gfx_hqds; i++) {
> + hqd = &adev->gfx.saved_gfx_hqds[i];
> + /* Check the MQD too: a new queue may reuse the
> doorbell. */
> + if (hqd->doorbell_index == queue->doorbell_index &&
> + hqd->mqd_addr == queue->mqd.gpu_addr)
> + return hqd;
> + }
> + return NULL;
> +}
> +
> +/**
> + * amdgpu_userq_restore_hqds - restore the user queues after an
> engine reset
> + * @adev: amdgpu device
> + * @queue_type: AMDGPU_HW_IP_* type of the queues on the reset
> engine
> + * @guilty: the queue that hung, or NULL
> + *
> + * MES doesn't map a queue whose HQD the reset cleared again on its
> own: unmap
> + * it from MES, restore its MQD, and map it again.
> + */
> +void amdgpu_userq_restore_hqds(struct amdgpu_device *adev, u32
> queue_type,
> + struct amdgpu_usermode_queue *guilty)
> +{
> + const struct amdgpu_userq_funcs *userq_funcs = adev-
> >userq_funcs[queue_type];
> + struct amdgpu_usermode_queue *queue;
> + struct amdgpu_gfx_saved_hqd *hqd;
> + unsigned long queue_id;
> + int r;
> +
> + xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
> + if (queue->queue_type != queue_type ||
> + queue->state != AMDGPU_USERQ_STATE_MAPPED)
> + continue;
> +
> + if (queue == guilty) {
> + userq_funcs->unmap(queue);
> + amdgpu_userq_fence_driver_force_completion(q
> ueue);
> + trace_amdgpu_userq_state_changed(queue,
> AMDGPU_USERQ_STATE_HUNG);
> + queue->state = AMDGPU_USERQ_STATE_HUNG;
> + continue;
> + }
> +
> + hqd = amdgpu_userq_find_saved_hqd(adev, queue);
> + if (!hqd)
> + continue;
> +
> + userq_funcs->unmap(queue);
> + if (adev->gfx.funcs->restore_hqd(adev, queue-
> >mqd.cpu_ptr,
> + queue->userq_prop-
> >queue_size,
> + hqd))
> + amdgpu_userq_fence_driver_force_completion_w
> ith_seqno(queue,
> +
> hqd->wptr);
> + r = userq_funcs->map(queue);
> + if (r) {
> + dev_err(adev->dev, "Failed to remap user
> queue %llu: %d\n",
> + queue->doorbell_index, r);
> + amdgpu_userq_fence_driver_force_completion(q
> ueue);
> + trace_amdgpu_userq_state_changed(queue,
> AMDGPU_USERQ_STATE_HUNG);
> + queue->state = AMDGPU_USERQ_STATE_HUNG;
> + }
> + }
> + adev->gfx.num_saved_gfx_hqds = 0;
> +}
> +
> +/**
> + * amdgpu_userq_clear_hqds - drop the saved HQDs after a failed
> engine reset
> + * @adev: amdgpu device
> + * @queue_type: AMDGPU_HW_IP_* type of the queues on the reset
> engine
> + */
> +void amdgpu_userq_clear_hqds(struct amdgpu_device *adev, u32
> queue_type)
> +{
> + adev->gfx.num_saved_gfx_hqds = 0;
> +}
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
> index 488dc21d7c81..b5195031877d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
> @@ -181,6 +181,10 @@ int
> amdgpu_userq_start_sched_for_enforce_isolation(struct amdgpu_device
> *adev,
> void amdgpu_userq_reset_work(struct work_struct *work);
> void amdgpu_userq_pre_reset(struct amdgpu_device *adev);
> int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool
> vram_lost);
> +void amdgpu_userq_save_hqds(struct amdgpu_device *adev, u32
> queue_type);
> +void amdgpu_userq_restore_hqds(struct amdgpu_device *adev, u32
> queue_type,
> + struct amdgpu_usermode_queue
> *guilty);
> +void amdgpu_userq_clear_hqds(struct amdgpu_device *adev, u32
> queue_type);
> void amdgpu_userq_start_hang_detect_work(struct
> amdgpu_usermode_queue *queue);
> void amdgpu_userq_process_fence_irq(struct amdgpu_device *adev, u32
> doorbell);
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 09/13] drm/amdgpu/gfx12: add a gfx engine soft reset
2026-11-05 3:05 ` [PATCH v4 09/13] drm/amdgpu/gfx12: add a gfx engine soft reset Jesse Zhang
@ 2026-11-19 11:42 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:42 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> Some hangs leave the gfx streaming engine of the CP front-end stuck,
> eg.
> waiting for packet data that never arrives. Neither a queue nor a
> pipe
> reset can stop it, so they end in a full GPU reset.
>
> Implement soft_reset_engine() for the graphics engine: halt PFP/ME,
> pulse GRBM_SOFT_RESET.SOFT_RESET_CPF/CPG with
> CP_SOFT_RESET_CNTL.GFX_ONLY_SOFT_RESET and GFX_HQD_REG_RESET, restart
> PFP/ME and map the kernel gfx queue again.
> MEC, MES and the compute queues keep running. The MES lock is held
> across
> the pulse, as MES fetches its queues through CPF, and the CP DMA is
> drained around it, as a request in flight leaves the ME busy.
>
> MES is suspended meanwhile, and the gfx user queues the reset clears
> are
> saved and restored around it. If the CP doesn't go idle, the reset
> fails
> and a full reset follows.
>
> v4: Implement soft_reset_engine() directly instead of a reset_engine
> gfx
> callback (Timur).
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 129
> +++++++++++++++++++++++++
> 1 file changed, 129 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> index 484e876fe235..8b96f2a29b1f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> @@ -3860,6 +3860,134 @@ static int gfx_v12_0_wait_for_idle(struct
> amdgpu_ip_block *ip_block)
> return -ETIMEDOUT;
> }
>
> +/* The CP DMA and the interfaces its memory requests go through */
> +#define GFX12_CP_STAT_MEM_BUSY (CP_STAT__DMA_BUSY_MASK | \
> + CP_STAT__TCIU_BUSY_MASK | \
> + CP_STAT__RCIU_BUSY_MASK | \
> + CP_STAT__UTCL2IU_BUSY_MASK)
> +
> +/* Reset CPF/CPG, PFP/ME and the gfx HQDs, then boot PFP/ME again.
> */
> +static int gfx_v12_0_soft_reset_gfx_cp(struct amdgpu_device *adev)
> +{
> + u32 tmp, cntl, me_cntl, ib_control;
> + int i;
> +
> + amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
> + /* MES fetches its queues through CPF: keep it out of the
> reset. */
> + amdgpu_mes_lock(&adev->mes);
> +
> + me_cntl = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
> + ib_control = RREG32_SOC15(GC, 0,
> regCP_PFP_IB_CONTROL); /* cleared by the reset */
> +
> + tmp = REG_SET_FIELD(me_cntl, CP_ME_CNTL, ME_HALT, 1);
> + tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 1);
> + WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
> + udelay(50);
> +
> + /* A CP DMA in flight during the reset leaves the ME busy
> after it. */
> + for (i = 0; i < adev->usec_timeout; i++) {
> + if (!(RREG32_SOC15(GC, 0, regCP_STAT) &
> GFX12_CP_STAT_MEM_BUSY))
> + break;
> + udelay(1);
> + }
> +
> + /* GFX_ONLY keeps compute and MES out; CPF alone leaves the
> stream stuck. */
> + cntl = RREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL);
> + tmp = REG_SET_FIELD(cntl, CP_SOFT_RESET_CNTL,
> GFX_ONLY_SOFT_RESET, 1);
> + tmp = REG_SET_FIELD(tmp, CP_SOFT_RESET_CNTL,
> GFX_HQD_REG_RESET, 1);
> + WREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL, tmp);
> +
> + tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPF,
> 1);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPG,
> 1);
I still think that this needs the SOFT_RESET_GFX bit too.
> + WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
> + tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
This should be moved below the delay.
> + udelay(50);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPF,
> 0);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPG,
> 0);
> + WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
> + tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
> +
> + WREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL, cntl);
> +
> + /* The halted PFP stays busy: only wait for the memory
> requests. */
> + for (i = 0; i < adev->usec_timeout; i++) {
> + if (!(RREG32_SOC15(GC, 0, regCP_STAT) &
> GFX12_CP_STAT_MEM_BUSY))
> + break;
> + udelay(1);
> + }
> + amdgpu_mes_unlock(&adev->mes);
We should clear the CP_VMID_RESET register here, same as we do on
GFX11. It makes no sense for the CP to be doing a VMID reset while we
are soft-resetting it.
> +
> + gfx_v12_0_set_pfp_ucode_start_addr(adev);
> + gfx_v12_0_set_me_ucode_start_addr(adev);
> + tmp = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
> + tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, CE_HALT,
> + REG_GET_FIELD(me_cntl, CP_ME_CNTL,
> CE_HALT));
> + WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
> + WREG32_SOC15(GC, 0, regCP_PFP_IB_CONTROL, ib_control);
Why is it important to restore the CP_PFP_IB_CONTROL register?
The kernel driver currently never writes this register, isn't the
default value good enough?
> + amdgpu_gfx_rlc_exit_safe_mode(adev, 0);
> +
> + tmp = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
> + tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, ME_HALT, 0);
> + tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 0);
> + WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
> + for (i = 0; i < adev->usec_timeout; i++) {
> + if (!RREG32_SOC15(GC, 0, regCP_STAT))
> + return 0;
> + udelay(1);
> + }
> + return -ETIMEDOUT;
> +}
> +
> +static int gfx_v12_0_soft_reset_engine(struct amdgpu_ip_block
> *ip_block,
> + enum amdgpu_ring_type
> ring_type,
> + struct amdgpu_usermode_queue
> *guilty_queue)
> +{
> + struct amdgpu_device *adev = ip_block->adev;
> + int i, r;
> +
> + if (ring_type != AMDGPU_RING_TYPE_GFX)
> + return -EOPNOTSUPP;
> +
> + mutex_lock(&adev->gfx.mec.reset_mutex);
> + amdgpu_gfx_off_ctrl(adev, false);
> +
> + /* A hung gfx stream can keep MES from suspending: reset
> anyway. */
> + amdgpu_mes_suspend(adev, 0);
> + amdgpu_userq_save_hqds(adev, AMDGPU_HW_IP_GFX);
> +
> + r = gfx_v12_0_soft_reset_gfx_cp(adev);
> + if (r) {
> + dev_err(adev->dev, "gfx CP still busy after reset,
> CP_STAT 0x%08x\n",
> + RREG32_SOC15(GC, 0, regCP_STAT));
> + goto fail;
> + }
> +
> + /* The reset cleared the HQD of the kernel gfx queue: map it
> again. */
> + r = amdgpu_gfx_disable_kgq(adev, 0);
> + if (r)
> + goto fail;
> + for (i = 0; i < adev->gfx.num_gfx_rings; i++)
> + amdgpu_gfx_mqd_reset_restore(&adev-
> >gfx.gfx_ring[i]);
> + r = amdgpu_gfx_enable_kgq(adev, 0);
> + if (!r)
> + r = gfx_v12_0_cp_gfx_start(adev);
> + if (r)
> + goto fail;
> +
> + amdgpu_userq_restore_hqds(adev, AMDGPU_HW_IP_GFX,
> guilty_queue);
> + r = amdgpu_mes_resume(adev, 0);
> + goto out;
> +
> +fail:
> + amdgpu_userq_clear_hqds(adev, AMDGPU_HW_IP_GFX);
> + amdgpu_mes_resume(adev, 0);
> +out:
> + amdgpu_gfx_off_ctrl(adev, true);
> + mutex_unlock(&adev->gfx.mec.reset_mutex);
> + return r;
> +}
> +
> #define GFX12_HPD_QUEUE_STATE_CONNECTED_MIN 3
> #define GFX12_HPD_QUEUE_STATE_CONNECTED_MAX 15
>
> @@ -5375,6 +5503,7 @@ static const struct amd_ip_funcs
> gfx_v12_0_ip_funcs = {
> .suspend = gfx_v12_0_suspend,
> .resume = gfx_v12_0_resume,
> .wait_for_idle = gfx_v12_0_wait_for_idle,
> + .soft_reset_engine = gfx_v12_0_soft_reset_engine,
> .set_clockgating_state = gfx_v12_0_set_clockgating_state,
> .set_powergating_state = gfx_v12_0_set_powergating_state,
> .get_clockgating_state = gfx_v12_0_get_clockgating_state,
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 10/13] drm/amdgpu/gfx11: add a gfx engine soft reset
2026-11-05 3:05 ` [PATCH v4 10/13] drm/amdgpu/gfx11: " Jesse Zhang
@ 2026-11-19 11:47 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:47 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> Implement soft_reset_engine() for the graphics engine of gfx11, as
> for
> gfx12, with two differences:
> - clear CP_VMID_RESET: a VMID reset the hung PFP didn't handle
> survives
> the CPF/CPG reset;
> - boot PFP/ME with CP_PFP_IB_CONTROL cleared and restore it
> afterwards:
> set, it makes the F32 PFP of the APUs resume from power gating and
> wait
> for a clear state that never comes.
>
> The CPF/CPG reset already puts PFP/ME back at their firmware start
> address, so unhalting them restarts the RS64 and F32 firmware alike.
>
> v4: Implement soft_reset_engine() directly instead of a reset_engine
> gfx
> callback, drop gfx_v11_0_restart_gfx_rs64(), and boot with
> CP_PFP_IB_CONTROL cleared for the F32 firmware (Timur).
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 134
> +++++++++++++++++++++++++
> 1 file changed, 134 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index 798015689f0c..80b91459f5b0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -6777,6 +6777,139 @@ static void gfx_v11_0_emit_mem_sync(struct
> amdgpu_ring *ring)
> amdgpu_ring_write(ring, gcr_cntl); /* GCR_CNTL */
> }
>
> +/* The CP DMA and the interfaces its memory requests go through */
> +#define GFX11_CP_STAT_MEM_BUSY (CP_STAT__DMA_BUSY_MASK | \
> + CP_STAT__TCIU_BUSY_MASK | \
> + CP_STAT__RCIU_BUSY_MASK | \
> + CP_STAT__UTCL2IU_BUSY_MASK)
> +
> +/* Reset CPF/CPG, PFP/ME and the gfx HQDs, then boot PFP/ME again.
> */
> +static int gfx_v11_0_soft_reset_gfx_cp(struct amdgpu_device *adev)
> +{
> + u32 tmp, cntl, me_cntl, ib_control;
> + int i;
> +
> + amdgpu_gfx_rlc_enter_safe_mode(adev, 0);
> + /* MES fetches its queues through CPF: keep it out of the
> reset. */
> + amdgpu_mes_lock(&adev->mes);
I wonder if we should lock the SRBM mutex here. What do you think?
> +
> + me_cntl = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
> + ib_control = RREG32_SOC15(GC, 0,
> regCP_PFP_IB_CONTROL); /* cleared by the reset */
> +
> + tmp = REG_SET_FIELD(me_cntl, CP_ME_CNTL, ME_HALT, 1);
> + tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 1);
> + WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
> + udelay(50);
> +
> + /* A CP DMA in flight during the reset leaves the ME busy
> after it. */
> + for (i = 0; i < adev->usec_timeout; i++) {
> + if (!(RREG32_SOC15(GC, 0, regCP_STAT) &
> GFX11_CP_STAT_MEM_BUSY))
> + break;
> + udelay(1);
> + }
> +
> + /* GFX_ONLY keeps compute and MES out; CPF alone leaves the
> stream stuck. */
> + cntl = RREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL);
> + tmp = REG_SET_FIELD(cntl, CP_SOFT_RESET_CNTL,
> GFX_ONLY_SOFT_RESET, 1);
> + tmp = REG_SET_FIELD(tmp, CP_SOFT_RESET_CNTL,
> GFX_HQD_REG_RESET, 1);
> + WREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL, tmp);
> +
> + tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPF,
> 1);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPG,
> 1);
I just tested this on Strix Halo (GFX11.5).
We need to set the SOFT_RESET_GFX bit here in order to reset the fixed-
function graphics pipeline. Otherwise this can't recover from cases
when the fixed-function pipeline hangs, for example a buggy NGG shader.
> + WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
> + tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
This line should be moved below the delay.
> + udelay(50);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPF,
> 0);
> + tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_CPG,
> 0);
> + WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
> + tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
> +
> + WREG32_SOC15(GC, 0, regCP_SOFT_RESET_CNTL, cntl);
> +
> + /* The halted PFP stays busy: only wait for the memory
> requests. */
> + for (i = 0; i < adev->usec_timeout; i++) {
> + if (!(RREG32_SOC15(GC, 0, regCP_STAT) &
> GFX11_CP_STAT_MEM_BUSY))
> + break;
> + udelay(1);
> + }
> + /* A VMID reset the hung PFP didn't handle survives the
> reset. */
> + WREG32_SOC15(GC, 0, regCP_VMID_RESET, 0);
Does this introduce a race condition between per-queue resets and the
soft reset? I mean, what happens if we are doing a queue reset on a
compute queue at the same time while this function is resetting the GFX
engine?
> + amdgpu_mes_unlock(&adev->mes);
> +
> + tmp = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
> + tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, CE_HALT,
> + REG_GET_FIELD(me_cntl, CP_ME_CNTL,
> CE_HALT));
> + WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
> + amdgpu_gfx_rlc_exit_safe_mode(adev, 0);
> +
> + /*
> + * Boot with CP_PFP_IB_CONTROL cleared: set, it makes the
> F32 PFP resume
> + * from power gating and wait for a clear state that never
> comes.
> + */
> + tmp = RREG32_SOC15(GC, 0, regCP_ME_CNTL);
> + tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, ME_HALT, 0);
> + tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 0);
> + WREG32_SOC15(GC, 0, regCP_ME_CNTL, tmp);
> + for (i = 0; i < adev->usec_timeout; i++) {
> + if (!RREG32_SOC15(GC, 0, regCP_STAT))
> + break;
> + udelay(1);
> + }
> + WREG32_SOC15(GC, 0, regCP_PFP_IB_CONTROL, ib_control);
> +
> + return i < adev->usec_timeout ? 0 : -ETIMEDOUT;
> +}
> +
> +static int gfx_v11_0_soft_reset_engine(struct amdgpu_ip_block
> *ip_block,
> + enum amdgpu_ring_type
> ring_type,
> + struct amdgpu_usermode_queue
> *guilty_queue)
> +{
> + struct amdgpu_device *adev = ip_block->adev;
> + int i, r;
> +
> + if (ring_type != AMDGPU_RING_TYPE_GFX)
> + return -EOPNOTSUPP;
> +
> + mutex_lock(&adev->gfx.mec.reset_mutex);
> + amdgpu_gfx_off_ctrl(adev, false);
> +
> + /* A hung gfx stream can keep MES from suspending: reset
> anyway. */
> + amdgpu_mes_suspend(adev, 0);
> + amdgpu_userq_save_hqds(adev, AMDGPU_HW_IP_GFX);
> +
> + r = gfx_v11_0_soft_reset_gfx_cp(adev);
> + if (r) {
> + dev_err(adev->dev, "gfx CP still busy after reset,
> CP_STAT 0x%08x\n",
> + RREG32_SOC15(GC, 0, regCP_STAT));
> + goto fail;
> + }
> +
> + /* The reset cleared the HQD of the kernel gfx queue: map it
> again. */
> + r = amdgpu_gfx_disable_kgq(adev, 0);
> + if (r)
> + goto fail;
> + for (i = 0; i < adev->gfx.num_gfx_rings; i++)
> + amdgpu_gfx_mqd_reset_restore(&adev-
> >gfx.gfx_ring[i]);
> + r = amdgpu_gfx_enable_kgq(adev, 0);
> + if (!r)
> + r = gfx_v11_0_cp_gfx_start(adev);
> + if (r)
> + goto fail;
> +
> + amdgpu_userq_restore_hqds(adev, AMDGPU_HW_IP_GFX,
> guilty_queue);
> + r = amdgpu_mes_resume(adev, 0);
> + goto out;
> +
> +fail:
> + amdgpu_userq_clear_hqds(adev, AMDGPU_HW_IP_GFX);
> + amdgpu_mes_resume(adev, 0);
> +out:
> + amdgpu_gfx_off_ctrl(adev, true);
> + mutex_unlock(&adev->gfx.mec.reset_mutex);
> + return r;
> +}
> +
> #define GFX11_HPD_QUEUE_STATE_CONNECTED_MIN 3
> #define GFX11_HPD_QUEUE_STATE_CONNECTED_MAX 15
>
> @@ -7045,6 +7178,7 @@ static const struct amd_ip_funcs
> gfx_v11_0_ip_funcs = {
> .suspend = gfx_v11_0_suspend,
> .resume = gfx_v11_0_resume,
> .wait_for_idle = gfx_v11_0_wait_for_idle,
> + .soft_reset_engine = gfx_v11_0_soft_reset_engine,
> .soft_reset = gfx_v11_0_soft_reset,
> .set_clockgating_state = gfx_v11_0_set_clockgating_state,
> .set_powergating_state = gfx_v11_0_set_powergating_state,
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 11/13] drm/amdgpu/userq: reset the gfx engine when a gfx user queue reset fails
2026-11-05 3:05 ` [PATCH v4 11/13] drm/amdgpu/userq: reset the gfx engine when a gfx user queue reset fails Jesse Zhang
@ 2026-11-19 11:47 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:47 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> When neither the queue nor the pipe reset recovered a gfx user queue,
> fall back to a soft reset of the gfx engine before a full reset, when
> the GFX IP supports it. A hung kernel gfx queue gets there through
> the
> IP block soft reset of the job timeout handler; a user queue has no
> kernel ring, so call amdgpu_device_ip_soft_reset() directly, with the
> gfx ring type and no guilty ring.
>
> The hung queue can't be unmapped before the reset: pass it to the
> engine
> reset, which unmaps it once the reset cleared its HQD, and hangs it,
> while the other gfx user queues keep their state.
>
> v4: Call amdgpu_device_ip_soft_reset(), which now takes the ring type
> (Timur).
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 27 +++++++++++++++++++-
> --
> 1 file changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> index 7abb9d95ef59..4f2dea21ad54 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> @@ -235,11 +235,25 @@ int mes_userq_reset_hw(struct
> amdgpu_usermode_queue *queue,
> return 0;
> }
>
> +/* The hung queue can't be unmapped now: the engine reset unmaps it
> after. */
> +static int mes_userq_reset_gfx_engine(struct amdgpu_usermode_queue
> *queue)
> +{
> + return amdgpu_device_ip_soft_reset(queue->userq_mgr->adev,
> + AMDGPU_RING_TYPE_GFX,
> NULL, NULL, queue);
> +}
> +
> +static bool mes_userq_gfx_engine_reset_supported(struct
> amdgpu_device *adev)
> +{
> + return adev->gfx.gfx_supported_reset &
> + AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET;
> +}
> +
> int mes_userq_reset(struct amdgpu_usermode_queue *queue)
> {
> struct amdgpu_userq_mgr *uq_mgr = queue->userq_mgr;
> struct amdgpu_device *adev = uq_mgr->adev;
> struct mes_reset_queue_input queue_input;
> + int r;
>
> /* already reset by an earlier job's hang-detect; just
> signal and bail */
> if (queue->state == AMDGPU_USERQ_STATE_HUNG)
> @@ -248,8 +262,10 @@ int mes_userq_reset(struct amdgpu_usermode_queue
> *queue)
> /* A GFX pipe reset also affects the kernel rings on that
> pipe. */
> if (queue->queue_type == AMDGPU_HW_IP_GFX &&
> adev->gfx.funcs->detect_hung_queue &&
> - amdgpu_gfx_me_pipe_reset_supported(adev))
> - return amdgpu_gfx_reset_mes_gfx(adev, NULL, NULL,
> queue, 0, true);
> + amdgpu_gfx_me_pipe_reset_supported(adev)) {
> + r = amdgpu_gfx_reset_mes_gfx(adev, NULL, NULL,
> queue, 0, true);
> + goto out;
> + }
>
> memset(&queue_input, 0x0, sizeof(struct
> mes_reset_queue_input));
> queue_input.doorbell_offset = queue->doorbell_index;
> @@ -277,7 +293,12 @@ int mes_userq_reset(struct amdgpu_usermode_queue
> *queue)
> }
> }
>
> - return mes_userq_reset_hw(queue, &queue_input);
> + r = mes_userq_reset_hw(queue, &queue_input);
> +out:
> + if (r && queue->queue_type == AMDGPU_HW_IP_GFX &&
> + mes_userq_gfx_engine_reset_supported(adev))
> + r = mes_userq_reset_gfx_engine(queue);
> + return r;
> }
>
> int mes_userq_reset_queue(struct amdgpu_device *adev,
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 12/13] drm/amdgpu/gfx12: enable the gfx engine soft reset
2026-11-05 3:05 ` [PATCH v4 12/13] drm/amdgpu/gfx12: enable the gfx engine soft reset Jesse Zhang
@ 2026-11-19 11:47 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:47 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> Report AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET for the gfx rings with
> MES,
> which the reset uses to map the kernel gfx queue again. Not on SR-IOV
> VFs.
>
> The kernel gfx queue and gfx user queue resets then fall back to a
> soft
> reset of the gfx engine before a full reset.
>
> v4: The soft_reset_engine() callback is set by the patch that adds
> it.
> No async gfx ring check: they are always used now.
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> index 8b96f2a29b1f..55baeda02d6f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> @@ -1593,6 +1593,11 @@ static int gfx_v12_0_sw_init(struct
> amdgpu_ip_block *ip_block)
> break;
> }
>
> + /* The reset remaps the kernel gfx queue through MES. */
> + if (!amdgpu_sriov_vf(adev) && adev->enable_mes &&
> + !adev->debug_disable_ip_block_soft_reset)
> + adev->gfx.gfx_supported_reset |=
> AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET;
> +
> if (!adev->enable_mes_kiq) {
> r = amdgpu_gfx_kiq_init(adev, GFX12_MEC_HPD_SIZE,
> 0);
> if (r) {
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v4 13/13] drm/amdgpu/gfx11: enable the gfx engine soft reset
2026-11-05 3:05 ` [PATCH v4 13/13] drm/amdgpu/gfx11: " Jesse Zhang
@ 2026-11-19 11:47 ` Timur Kristóf
0 siblings, 0 replies; 29+ messages in thread
From: Timur Kristóf @ 2026-11-19 11:47 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx
Cc: Alexander.Deucher, Christian Koenig, Lijo.Lazar, Mario.Novales,
Manu.Rastogi, Jiongyu.Zhu
On Thu, 2026-11-05 at 11:05 +0800, Jesse Zhang wrote:
> Report AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET for the gfx rings with
> MES,
> which the reset uses to map the kernel gfx queue again. Not on SR-IOV
> VFs.
>
> The kernel gfx queue and gfx user queue resets then fall back to a
> soft
> reset of the gfx engine before a full reset. The IP block soft reset
> of
> gfx11 only resets the gfx engine then; the whole IP block
> soft_reset()
> isn't used.
>
> v4: Not limited to the RS64 firmware anymore, the reset restarts the
> F32
> PFP and ME of the APUs too (Timur). The soft_reset_engine()
> callback
> is set by the patch that adds it. No async gfx ring check: they
> are
> always used now.
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index 80b91459f5b0..396fe3f6678a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -1941,6 +1941,11 @@ static int gfx_v11_0_sw_init(struct
> amdgpu_ip_block *ip_block)
> break;
> }
>
> + /* The reset remaps the kernel gfx queue through MES. */
> + if (!amdgpu_sriov_vf(adev) && adev->enable_mes &&
> + !adev->debug_disable_ip_block_soft_reset)
> + adev->gfx.gfx_supported_reset |=
> AMDGPU_RESET_TYPE_IP_BLOCK_SOFT_RESET;
> +
> if (!adev->enable_mes_kiq) {
> r = amdgpu_gfx_kiq_init(adev, GFX11_MEC_HPD_SIZE,
> 0);
> if (r) {
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2026-11-19 11:47 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-05 3:05 [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Jesse Zhang
2026-11-05 3:05 ` [PATCH v4 02/13] drm/amdgpu/ring: During multi-queue reset, only call begin helper if needed Jesse Zhang
2026-11-11 23:52 ` Daniel Campos Ramos
2026-11-19 11:34 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 03/13] drm/amdgpu: add an engine scope to the IP block soft reset Jesse Zhang
2026-11-19 11:35 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 04/13] drm/amdgpu/gfx: add callbacks to save and restore a gfx HQD Jesse Zhang
2026-11-19 11:35 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 05/13] drm/amdgpu/gfx12: " Jesse Zhang
2026-11-19 11:35 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 06/13] drm/amdgpu/gfx11: " Jesse Zhang
2026-11-19 11:36 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 07/13] drm/amdgpu/userq: add a helper to signal the fences of a queue up to a point Jesse Zhang
2026-11-19 11:36 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 08/13] drm/amdgpu/userq: add helpers to keep the user queues of one engine across a reset Jesse Zhang
2026-11-19 11:36 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 09/13] drm/amdgpu/gfx12: add a gfx engine soft reset Jesse Zhang
2026-11-19 11:42 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 10/13] drm/amdgpu/gfx11: " Jesse Zhang
2026-11-19 11:47 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 11/13] drm/amdgpu/userq: reset the gfx engine when a gfx user queue reset fails Jesse Zhang
2026-11-19 11:47 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 12/13] drm/amdgpu/gfx12: enable the gfx engine soft reset Jesse Zhang
2026-11-19 11:47 ` Timur Kristóf
2026-11-05 3:05 ` [PATCH v4 13/13] drm/amdgpu/gfx11: " Jesse Zhang
2026-11-19 11:47 ` Timur Kristóf
2026-11-10 2:06 ` [PATCH v4 01/13] drm/amdgpu: pass the device to the multi ring reset helpers Zhang, Jesse(Jie)
2026-11-11 15:28 ` Timur Kristóf
2026-11-19 11:33 ` Timur Kristóf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.