Skip to contentSkip to conversation

drm/amdgpu: Remove separate guilty compute userq reset

PATCH In review Prike Liang 2 participants 16 messages Jul 15 – Aug 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: Remove separate guilty compute userq reset

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via mes_userq_reset() is unnecessary, so remove it to unify the compute userq reset.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int amdgpu_gfx_reset_mes_compute(struct amdgpu_device *adev,
 		deferred_end[n_deferred].fence = guilty_fence;
 		n_deferred++;
 	}
-	if (uq) {
-		r = mes_userq_reset(uq);
-		if (r)
-			goto out;
-	}
 	for (i = 0; i < num_hung; i++) {
 		struct amdgpu_ring *hr = NULL;
 		struct amdgpu_fence *hf = NULL;
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
index b6bfa3974839..fab21d4275f3 100644
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct amdgpu_device *adev,
 
 	xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
 		if (uq->queue_type == queue_type) {
-			if (uq == guilty_uq)
-				continue;
 			if (uq->doorbell_index == db) {
 				uq->state = AMDGPU_USERQ_STATE_HUNG;
 				if (use_mmio)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 drm/amdgpu: clean up the userq support redundant check

If the userq doesn't support in a system. then there's no valid userq_doorbell_xa entry to walk over and then has a no-op.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -8
index d34572bb6fd4..439d4047a085 100644
@@ -1308,15 +1308,11 @@ void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr)
 
 int amdgpu_userq_suspend(struct amdgpu_device *adev)
 {
-	u32 ip_mask = amdgpu_userq_get_supported_ip_mask(adev);
 	struct amdgpu_usermode_queue *queue;
 	struct amdgpu_userq_mgr *uqm;
 	unsigned long queue_id;
 	int r;
 
-	if (!ip_mask)
-		return 0;
-
 	xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
 		uqm = queue->userq_mgr;
 		cancel_delayed_work_sync(&uqm->resume_work);
@@ -1333,15 +1329,11 @@ int amdgpu_userq_suspend(struct amdgpu_device *adev)
 
 int amdgpu_userq_resume(struct amdgpu_device *adev)
 {
-	u32 ip_mask = amdgpu_userq_get_supported_ip_mask(adev);
 	struct amdgpu_usermode_queue *queue;
 	struct amdgpu_userq_mgr *uqm;
 	unsigned long queue_id;
 	int r;
 
-	if (!ip_mask)
-		return 0;
-
 	xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
 		uqm = queue->userq_mgr;
 		guard(mutex)(&uqm->userq_mutex);
Signature · 1 line
2.34.1
#2 lore raw
In reply to Prike Liang

AMD General

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report correctly. @Zhang, Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be cleaned sooner or later.

Regards,
Prike

Quoted 52 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via mes_userq_reset() is unnecessary, so remove it to unify the compute userq reset.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int amdgpu_gfx_reset_mes_compute(struct
 amdgpu_device *adev,
              deferred_end[n_deferred].fence = guilty_fence;
              n_deferred++;
      }
-     if (uq) {
-             r = mes_userq_reset(uq);
-             if (r)
-                     goto out;
-     }
      for (i = 0; i < num_hung; i++) {
              struct amdgpu_ring *hr = NULL;
              struct amdgpu_fence *hf = NULL;
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -3
index b6bfa3974839..fab21d4275f3 100644
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct amdgpu_device *adev,
 
      xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
              if (uq->queue_type == queue_type) {
-                     if (uq == guilty_uq)
-                             continue;
                      if (uq->doorbell_index == db) {
                              uq->state = AMDGPU_USERQ_STATE_HUNG;
                              if (use_mmio)
--

2.34.1

#3 lore raw

AMD General

As for the hung userq, it should be identified by the MES reset API with the hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been implemented yet.

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung queues?

Regards,
Prike

Quoted 76 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report correctly. @Zhang, Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be cleaned sooner or later.

Regards,
Prike

Quoted 55 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via
mes_userq_reset() is unnecessary, so remove it to unify the compute userq reset.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int amdgpu_gfx_reset_mes_compute(struct
 amdgpu_device *adev,
            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL;
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
index b6bfa3974839..fab21d4275f3 100644
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct amdgpu_device
 *adev,
 
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state = AMDGPU_USERQ_STATE_HUNG;

if (use_mmio)
--
2.34.1

#4 lore raw
Quoted 7 lines · Prike

AMD General

As for the hung userq, it should be identified by the MES reset API with the hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been implemented yet.

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung queues?

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will never signal.

Alex

Quoted 80 lines

Regards,
Prike

Quoted 76 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report correctly. @Zhang, Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be cleaned sooner or later.

Regards,
Prike

Quoted 55 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via
mes_userq_reset() is unnecessary, so remove it to unify the compute userq reset.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int amdgpu_gfx_reset_mes_compute(struct
 amdgpu_device *adev,
            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL;
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
index b6bfa3974839..fab21d4275f3 100644
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct amdgpu_device
 *adev,
 
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state = AMDGPU_USERQ_STATE_HUNG;

if (use_mmio)
--
2.34.1

#5 lore raw

AMD General

Regards,
Prike

Quoted 23 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 4 lines · Prike

AMD General

As for the hung userq, it should be identified by the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been implemented yet.

Quoted 2 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung queues?

Quoted 1 line
Quoted 5 lines

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will never signal.

Thank you for the input. However, for fake timeout cases such as the long shader scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether the queue rptr is still updating? If so, preempt the queue rather than resetting it?

Quoted 87 lines

Alex

Quoted 20 lines

Regards,
Prike

Quoted 17 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report correctly. @Zhang, Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be

cleaned sooner or later.

Quoted 15 lines
Quoted 15 lines

Regards,
Prike

Quoted 10 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via mes_userq_reset() is unnecessary, so remove it to unify the compute userq

reset.

Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int amdgpu_gfx_reset_mes_compute(struct
 amdgpu_device *adev,
            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL; diff --git

a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index b6bfa3974839..fab21d4275f3 100644

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct amdgpu_device
 *adev,
 
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state = AMDGPU_USERQ_STATE_HUNG;

if (use_mmio)
--
2.34.1

#6 lore raw
Quoted 29 lines · Prike

AMD General

Regards,
Prike

Quoted 23 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 4 lines · Prike

AMD General

As for the hung userq, it should be identified by the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been implemented yet.

Quoted 2 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung queues?

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will never signal.

Thank you for the input. However, for fake timeout cases such as the long shader scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether the queue rptr is still updating? If so, preempt the queue rather than resetting it?

We have to assume that if we end up in the queue reset path that the queue is hung. The fences have to signal in finite time. If we preempt the queue that won't signal the fence so we'll just end up in the queue reset path again. Preemption of a queue that won't make progress only makes sense if fences are not involved.

Alex

Quoted 87 lines
Quoted 87 lines

Alex

Quoted 20 lines

Regards,
Prike

Quoted 17 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report correctly. @Zhang, Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be

cleaned sooner or later.

Quoted 15 lines
Quoted 15 lines

Regards,
Prike

Quoted 10 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via mes_userq_reset() is unnecessary, so remove it to unify the compute userq

reset.

Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int amdgpu_gfx_reset_mes_compute(struct
 amdgpu_device *adev,
            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL; diff --git

a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index b6bfa3974839..fab21d4275f3 100644

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct amdgpu_device
 *adev,
 
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state = AMDGPU_USERQ_STATE_HUNG;

if (use_mmio)
--
2.34.1

#7 lore raw

AMD General

Regards,
Prike

Quoted 56 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:40 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 31 lines · Prike

AMD General

Regards,
Prike

Quoted 25 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 5 lines · Prike

AMD General

As for the hung userq, it should be identified by the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been implemented yet.

Quoted 3 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung

queues?

Quoted 9 lines
Quoted 7 lines
Quoted 1 line

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will never signal.

Thank you for the input. However, for fake timeout cases such as the long shader

scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether the queue rptr is still updating? If so, preempt the queue rather than resetting it?

Quoted 1 line
Quoted 4 lines

We have to assume that if we end up in the queue reset path that the queue is hung. The fences have to signal in finite time. If we preempt the queue that won't signal the fence so we'll just end up in the queue reset path again. Preemption of a queue that won't make progress only makes sense if fences are not involved.

The most cases relevant to userq fence timeout and reset worker likely to be scheduled when a userq fence polling period expires. If a long running shader is detected, the driver may need to try preempting the queue within a few retry cycles. If the userq fence remains unsignaled after the retries are exhausted, the driver can either return -ETIME to userspace for further handling or fall back to resetting the queue directly. Meanwhile, If the preemption succeeds and the queue completes its work during the subsequent restore process, no further reset is necessary for the guilty queue?

In the longer term, we may need to introduce a more robust mechanism to distinguish slow queue cases from genuine hangs, handling them appropriately via extending time slice for completing the queue submission, userspace driven resubmission, or dropping the work through a queue reset. If it makes sense and right way to do, then I will work on implementing the solution for such slow/long queue cases.

Thanks,
Prike

Quoted 92 lines

Alex

Quoted 90 lines
Quoted 90 lines

Alex

Quoted 22 lines

Regards,
Prike

Quoted 19 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report correctly. @Zhang,
Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be

cleaned sooner or later.

Quoted 15 lines
Quoted 15 lines

Regards,
Prike

Quoted 10 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via mes_userq_reset() is unnecessary, so remove it to unify the compute userq

reset.

Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int amdgpu_gfx_reset_mes_compute(struct
 amdgpu_device *adev,
            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL; diff --git

a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index b6bfa3974839..fab21d4275f3 100644

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct
 amdgpu_device *adev,
 
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state = AMDGPU_USERQ_STATE_HUNG;

if (use_mmio)
--
2.34.1

#8 lore raw
Quoted 62 lines · Prike

AMD General

Regards,
Prike

Quoted 56 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:40 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 31 lines · Prike

AMD General

Regards,
Prike

Quoted 25 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 5 lines · Prike

AMD General

As for the hung userq, it should be identified by the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been implemented yet.

Quoted 3 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung

queues?

Quoted 9 lines
Quoted 7 lines
Quoted 1 line

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will never signal.

Thank you for the input. However, for fake timeout cases such as the long shader

scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether the queue rptr is still updating? If so, preempt the queue rather than resetting it?

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

We have to assume that if we end up in the queue reset path that the queue is hung. The fences have to signal in finite time. If we preempt the queue that won't signal the fence so we'll just end up in the queue reset path again. Preemption of a queue that won't make progress only makes sense if fences are not involved.

The most cases relevant to userq fence timeout and reset worker likely to be scheduled when a userq fence polling period expires. If a long running shader is detected, the driver may need to try preempting the queue within a few retry cycles. If the userq fence remains unsignaled after the retries are exhausted, the driver can either return -ETIME to userspace for further handling or fall back to resetting the queue directly. Meanwhile, If the preemption succeeds and the queue completes its work during the subsequent restore process, no further reset is necessary for the guilty queue?

If an application wants to run long running jobs they shouldn't use protected fences in the first place. If they don't use protected fences, then it should behave like KFD queues. If there is some operation that needs to happen the queues will get preempted and then will continue later. DMA fences need to signal in finite time so we can't just keep pushing them off. Other kernel paging operations may depend on them signalling.

Alex

Quoted 97 lines

In the longer term, we may need to introduce a more robust mechanism to distinguish slow queue cases from genuine hangs, handling them appropriately via extending time slice for completing the queue submission, userspace driven resubmission, or dropping the work through a queue reset. If it makes sense and right way to do, then I will work on implementing the solution for such slow/long queue cases.

Thanks,
Prike

Quoted 92 lines

Alex

Quoted 90 lines
Quoted 90 lines

Alex

Quoted 22 lines

Regards,
Prike

Quoted 19 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report correctly. @Zhang,
Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be

cleaned sooner or later.

Quoted 15 lines
Quoted 15 lines

Regards,
Prike

Quoted 10 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via mes_userq_reset() is unnecessary, so remove it to unify the compute userq

reset.

Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int amdgpu_gfx_reset_mes_compute(struct
 amdgpu_device *adev,
            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL; diff --git

a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index b6bfa3974839..fab21d4275f3 100644

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct
 amdgpu_device *adev,
 
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state = AMDGPU_USERQ_STATE_HUNG;

if (use_mmio)
--
2.34.1

#9 lore raw

AMD General

Regards,
Prike

Quoted 95 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, August 4, 2026 10:18 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 36 lines · On Tue, Aug 4, 2026 at 4:16 AM Liang, Prike…

AMD General

Regards,
Prike

Quoted 30 lines

-----Original Message-----
From: Alex Deucher <[email protected]<mailto:[email protected]>>
Sent: Monday, August 3, 2026 9:40 PM
To: Liang, Prike <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; Zhang, Jesse(Jie) <[email protected]<mailto:[email protected]>>; Liu, Shaoyun <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>; Koenig, Christian <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute
userq reset

Quoted 18 lines · On Mon, Aug 3, 2026 at 9:36 AM Liang, Prike…

AMD General

Regards,
Prike

Quoted 12 lines

-----Original Message-----
From: Alex Deucher <[email protected]<mailto:[email protected]>>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; Zhang, Jesse(Jie) <[email protected]<mailto:[email protected]>>; Liu, Shaoyun <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>; Koenig, Christian <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty
compute userq reset

On Mon, Aug 3, 2026 at 5:25 AM Liang, Prike <[email protected]<mailto:[email protected]>>

Quoted 14 lines · wrote:
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 5 lines

AMD General

As for the hung userq, it should be identified by the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been implemented yet.

Quoted 3 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung

Quoted 8 lines
Quoted 8 lines

queues?

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will

never signal.

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

Thank you for the input. However, for fake timeout cases such as the long shader

scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether the queue rptr is still updating? If so, preempt the queue rather than resetting it?

Quoted 1 line

We have to assume that if we end up in the queue reset path that the queue is

hung.

Quoted 3 lines
Quoted 3 lines

The fences have to signal in finite time. If we preempt the queue that won't signal the fence so we'll just end up in the queue reset path again. Preemption of a queue that won't make progress only makes sense

if fences are not involved.

Quoted 2 lines

The most cases relevant to userq fence timeout and reset worker likely to be

scheduled when a userq fence polling period expires. If a long running shader is detected, the driver may need to try preempting the queue within a few retry cycles. If the userq fence remains unsignaled after the retries are exhausted, the driver can either return -ETIME to userspace for further handling or fall back to resetting the queue directly. Meanwhile, If the preemption succeeds and the queue completes its work during the subsequent restore process, no further reset is necessary for the guilty queue?

Quoted 1 line
Quoted 6 lines

If an application wants to run long running jobs they shouldn't use protected fences in the first place. If they don't use protected fences, then it should behave like KFD queues. If there is some operation that needs to happen the queues will get preempted and then will continue later. DMA fences need to signal in finite time so we can't just keep pushing them off. Other kernel paging operations may depend on them signalling.

Regarding the protected fences, do you mean the userq fence that triggers the hang detection work queue?

If so, the current implementation calls amdgpu_userq_fence_init() at fence emit time (i.e., at each queue submission), which both initializes the dma_fence structure and starts the hang detection timer for that submission. Once the timeout expires, amdgpu_userq_hang_detect_work() fires and triggers a queue reset regardless of whether the queue is actually hung or simply long-running. But there's a core problem for the kernel to distinguish a hung queue from a slow one at fence emit time, since both look identical an unsignaled fence with an active queue.

However, we can defer that determination to the first timeout expiry in amdgpu_userq_hang_detect_work(). At that point we have more information to work with:

• Check for real hang: query rptr and rptr has not updated since the fence was emitted, the queue is genuinely stuck (frozen waves, infinite loop). This is a real hang, reset immediately and forcing completing the fences.
• Check for forward progress: if rptr has updated but the fence is still unsignaled, the queue is making progress, so it is long running, not hung. In this case:
o Extend the timeout (reschedule hang_detect_work with a longer interval)
o Track retry count if the queue still has not completed after N extended cycles, escalate: Preempt the queue, force completing the fence and return -ETIME to userspace then let the application decide: resubmit, split the workload, or drop.
• Avoid unnecessary resets: if preemption succeeds and the queue resumes and completes within the extended window, cancel the reset entirely since the queue was slow, not broken.

Do you think this is the right way for handling long-running tasks to resolve the userq timeout issue, or does it align with your idea?

Thanks,
Prike

Avoid unnecessary resets: if preemption succeeds and the queue resumes and completes within the extended window, cancel the reset entirely — the queue was slow, not broken.>

Quoted 105 lines

Alex

Quoted 1 line

In the longer term, we may need to introduce a more robust mechanism to

distinguish slow queue cases from genuine hangs, handling them appropriately via extending time slice for completing the queue submission, userspace driven resubmission, or dropping the work through a queue reset. If it makes sense and right way to do, then I will work on implementing the solution for such slow/long queue cases.

Quoted 97 lines

Thanks,
Prike

Quoted 93 lines

Alex

Quoted 91 lines
Quoted 91 lines

Alex

Quoted 22 lines

Regards,
Prike

Quoted 19 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]<mailto:[email protected]>; Zhang, Jesse(Jie) <[email protected]<mailto:[email protected]>>
Cc: Deucher, Alexander <[email protected]<mailto:[email protected]>>; Koenig, Christian <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty
compute userq reset

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report correctly. @Zhang,
Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be

cleaned sooner or later.

Quoted 15 lines
Quoted 15 lines

Regards,
Prike

Quoted 10 lines

-----Original Message-----
From: Liang, Prike <[email protected]<mailto:[email protected]>>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]<mailto:[email protected]>
Cc: Deucher, Alexander <[email protected]<mailto:[email protected]>>; Koenig, Christian <[email protected]<mailto:[email protected]>>; Liang, Prike <[email protected]<mailto:[email protected]>>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty
compute userq reset

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via mes_userq_reset() is unnecessary, so remove it to unify the compute userq

reset.

Quoted 44 lines
Quoted 43 lines
Quoted 43 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -0
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int

amdgpu_gfx_reset_mes_compute(struct
amdgpu_device *adev,

            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL; diff --git

a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index b6bfa3974839..fab21d4275f3 100644

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct
 amdgpu_device *adev,
 
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state = AMDGPU_USERQ_STATE_HUNG;

if (use_mmio)
--
2.34.1

#10 lore raw
Quoted 103 lines · Prike

AMD General

Regards,
Prike

Quoted 95 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, August 4, 2026 10:18 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 36 lines · Prike

AMD General

Regards,
Prike

Quoted 30 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:40 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 18 lines · Prike

AMD General

Regards,
Prike

Quoted 12 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 5:25 AM Liang, Prike <[email protected]>

Quoted 14 lines · wrote:
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 5 lines

AMD General

As for the hung userq, it should be identified by the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been implemented yet.

Quoted 3 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung

Quoted 8 lines
Quoted 8 lines

queues?

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will

never signal.

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

Thank you for the input. However, for fake timeout cases such as the long shader

scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether the queue rptr is still updating? If so, preempt the queue rather than resetting it?

Quoted 1 line

We have to assume that if we end up in the queue reset path that the queue is

hung.

Quoted 3 lines
Quoted 3 lines

The fences have to signal in finite time. If we preempt the queue that won't signal the fence so we'll just end up in the queue reset path again. Preemption of a queue that won't make progress only makes sense

if fences are not involved.

Quoted 2 lines

The most cases relevant to userq fence timeout and reset worker likely to be

scheduled when a userq fence polling period expires. If a long running shader is detected, the driver may need to try preempting the queue within a few retry cycles. If the userq fence remains unsignaled after the retries are exhausted, the driver can either return -ETIME to userspace for further handling or fall back to resetting the queue directly. Meanwhile, If the preemption succeeds and the queue completes its work during the subsequent restore process, no further reset is necessary for the guilty queue?

Quoted 1 line
Quoted 9 lines
Quoted 6 lines

If an application wants to run long running jobs they shouldn't use protected fences in the first place. If they don't use protected fences, then it should behave like KFD queues. If there is some operation that needs to happen the queues will get preempted and then will continue later. DMA fences need to signal in finite time so we can't just keep pushing them off. Other kernel paging operations may depend on them signalling.

Regarding the protected fences, do you mean the userq fence that triggers the hang detection work queue?

Yes.

Quoted 2 lines

If so, the current implementation calls amdgpu_userq_fence_init() at fence emit time (i.e., at each queue submission), which both initializes the dma_fence structure and starts the hang detection timer for that submission. Once the timeout expires, amdgpu_userq_hang_detect_work() fires and triggers a queue reset regardless of whether the queue is actually hung or simply long-running. But there's a core problem for the kernel to distinguish a hung queue from a slow one at fence emit time, since both look identical an unsignaled fence with an active queue.

That is the intended behavior. If you opt into using a dma fence, you need to abide by its semantics.

Quoted 6 lines

However, we can defer that determination to the first timeout expiry in amdgpu_userq_hang_detect_work(). At that point we have more information to work with:

Check for real hang: query rptr and rptr has not updated since the fence was emitted, the queue is genuinely stuck (frozen waves, infinite loop). This is a real hang, reset immediately and forcing completing the fences. Check for forward progress: if rptr has updated but the fence is still unsignaled, the queue is making progress, so it is long running, not hung. In this case:

Quoted 7 lines

Extend the timeout (reschedule hang_detect_work with a longer interval)
Track retry count if the queue still has not completed after N extended cycles, escalate: Preempt the queue, force completing the fence and return -ETIME to userspace then let the application decide: resubmit, split the workload, or drop.

Avoid unnecessary resets: if preemption succeeds and the queue resumes and completes within the extended window, cancel the reset entirely since the queue was slow, not broken.

Do you think this is the right way for handling long-running tasks to resolve the userq timeout issue, or does it align with your idea?

If you want to run a super long running job, then you shouldn't use a dma fence in the first place. There might be a job that takes 2 minutes or even an hour to run, but you can't wait that long for a dma fence. If you do, the kernel might run out of memory and the OOM killer will start killing processes or you could deadlock. If you want to run a long job, don't use a dma fence. If you don't use a dma fence, then the kernel can preempt the queues, do whatever memory management it needs to and then it can resume the queues. dma fences have to signal in finite time.

Alex

Quoted 110 lines

Thanks,
Prike

Avoid unnecessary resets: if preemption succeeds and the queue resumes and completes within the extended window, cancel the reset entirely — the queue was slow, not broken.>

Quoted 105 lines

Alex

Quoted 1 line

In the longer term, we may need to introduce a more robust mechanism to

distinguish slow queue cases from genuine hangs, handling them appropriately via extending time slice for completing the queue submission, userspace driven resubmission, or dropping the work through a queue reset. If it makes sense and right way to do, then I will work on implementing the solution for such slow/long queue cases.

Quoted 97 lines

Thanks,
Prike

Quoted 93 lines

Alex

Quoted 91 lines
Quoted 91 lines

Alex

Quoted 22 lines

Regards,
Prike

Quoted 19 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report correctly. @Zhang,
Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be

cleaned sooner or later.

Quoted 15 lines
Quoted 15 lines

Regards,
Prike

Quoted 10 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via mes_userq_reset() is unnecessary, so remove it to unify the compute userq

reset.

Quoted 44 lines
Quoted 43 lines
Quoted 43 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -0
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int

amdgpu_gfx_reset_mes_compute(struct
amdgpu_device *adev,

            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL; diff --git

a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c index b6bfa3974839..fab21d4275f3 100644

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct
 amdgpu_device *adev,
 
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state = AMDGPU_USERQ_STATE_HUNG;

if (use_mmio)
--
2.34.1

#11 lore raw

AMD General

Regards,
Prike

Quoted 174 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 7, 2026 9:47 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 38 lines · Prike

AMD General

Regards,
Prike

Quoted 30 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, August 4, 2026 10:18 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 18 lines · Prike

AMD General

Regards,
Prike

Quoted 12 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:40 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 9:36 AM Liang, Prike <[email protected]>

Quoted 43 lines · wrote:
Quoted 43 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

AMD General

Regards,
Prike

Quoted 13 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 5:25 AM Liang, Prike
<[email protected]>

Quoted 23 lines · wrote:
Quoted 23 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

AMD General

As for the hung userq, it should be identified by the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been implemented yet.

Quoted 1 line
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung

queues?

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will

Quoted 7 lines
Quoted 7 lines

never signal.

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Thank you for the input. However, for fake timeout cases such as the long shader

scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether
the queue rptr is still updating? If so, preempt the queue rather than resetting

it?

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

We have to assume that if we end up in the queue reset path that the queue is

hung.

Quoted 4 lines
Quoted 4 lines

The fences have to signal in finite time. If we preempt the queue that won't signal the fence so we'll just end up in the queue reset path again. Preemption of a queue that won't make progress only makes sense

Quoted 6 lines
Quoted 6 lines

if fences are not involved.

Quoted 3 lines

The most cases relevant to userq fence timeout and reset worker likely to be

scheduled when a userq fence polling period expires. If a long running shader is detected, the driver may need to try preempting the queue

within a few retry cycles.

Quoted 5 lines
Quoted 5 lines

If the userq fence remains unsignaled after the retries are exhausted, the driver can either return -ETIME to userspace for further handling or fall back to resetting the queue directly. Meanwhile, If the preemption succeeds and the queue completes its work during the subsequent restore process, no further reset is necessary for the

guilty queue?

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

If an application wants to run long running jobs they shouldn't use protected fences in the first place. If they don't use protected fences, then it should behave like KFD queues. If there is some operation that needs to happen the queues will get preempted and then will continue later. DMA fences need to signal in finite time so we can't just keep pushing them off. Other kernel paging operations may

depend on them signalling.

Quoted 2 lines

Regarding the protected fences, do you mean the userq fence that triggers the

hang detection work queue?

Quoted 1 line

Yes.

Quoted 1 line

If so, the current implementation calls amdgpu_userq_fence_init() at fence emit

time (i.e., at each queue submission), which both initializes the dma_fence structure and starts the hang detection timer for that submission. Once the timeout expires, amdgpu_userq_hang_detect_work() fires and triggers a queue reset regardless of whether the queue is actually hung or simply long-running. But there's a core problem for the kernel to distinguish a hung queue from a slow one at fence emit time, since both look identical an unsignaled fence with an active queue.

Quoted 1 line

That is the intended behavior. If you opt into using a dma fence, you need to abide by its semantics.

Quoted 1 line

However, we can defer that determination to the first timeout expiry in

amdgpu_userq_hang_detect_work(). At that point we have more information to work with:

Quoted 3 lines

Check for real hang: query rptr and rptr has not updated since the fence was

emitted, the queue is genuinely stuck (frozen waves, infinite loop). This is a real hang, reset immediately and forcing completing the fences.

Quoted 1 line

Check for forward progress: if rptr has updated but the fence is still unsignaled, the

queue is making progress, so it is long running, not hung. In this case:

Quoted 3 lines

Extend the timeout (reschedule hang_detect_work with a longer interval) Track retry count if the queue still has not completed after N extended

cycles, escalate: Preempt the queue, force completing the fence and return -ETIME to userspace then let the application decide: resubmit, split the workload, or drop.

Quoted 2 lines

Avoid unnecessary resets: if preemption succeeds and the queue resumes and

completes within the extended window, cancel the reset entirely since the queue was slow, not broken.

Quoted 3 lines

Do you think this is the right way for handling long-running tasks to resolve the

userq timeout issue, or does it align with your idea?

Quoted 7 lines

If you want to run a super long running job, then you shouldn't use a dma fence in the first place. There might be a job that takes 2 minutes or even an hour to run, but you can't wait that long for a dma fence. If you do, the kernel might run out of memory and the OOM killer will start killing processes or you could deadlock. If you want to run a long job, don't use a dma fence. If you don't use a dma fence, then the kernel can preempt the queues, do whatever memory management it needs to and then it can resume the queues. dma fences have to signal in finite time.

Got it. So to skip attaching a dma_fence to a long-running submission, does this require an explicit flag from userspace at queue creation, or is there another mechanism to identify it on the kernel side?

Thanks,
Prike

Quoted 117 lines

Alex

Quoted 40 lines

Thanks,
Prike

Avoid unnecessary resets: if preemption succeeds and the queue resumes and completes within the extended window, cancel the reset entirely — the queue was slow, not broken.>

Quoted 33 lines

Alex

Quoted 2 lines

In the longer term, we may need to introduce a more robust mechanism to

distinguish slow queue cases from genuine hangs, handling them appropriately via extending time slice for completing the queue submission, userspace driven resubmission, or dropping the work through a queue reset. If it makes sense and right way to do, then I will work on implementing the solution for such slow/long queue cases.

Quoted 24 lines

Thanks,
Prike

Quoted 20 lines

Alex

Quoted 18 lines
Quoted 18 lines

Alex

Quoted 15 lines

Regards,
Prike

Quoted 12 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report

correctly.

Quoted 74 lines
Quoted 74 lines
Quoted 74 lines
Quoted 74 lines
Quoted 74 lines
Quoted 74 lines
Quoted 7 lines
Quoted 7 lines

@Zhang,
Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be

cleaned sooner or later.

Quoted 15 lines
Quoted 15 lines

Regards,
Prike

Quoted 10 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via
mes_userq_reset() is unnecessary, so remove it to unify the compute userq

reset.

Quoted 44 lines
Quoted 43 lines
Quoted 43 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -0
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int

amdgpu_gfx_reset_mes_compute(struct
amdgpu_device *adev,

            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL; diff --git

a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c index b6bfa3974839..fab21d4275f3 100644

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct
 amdgpu_device *adev,
 
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state = AMDGPU_USERQ_STATE_HUNG;

if (use_mmio)
--
2.34.1

#12 lore raw
Quoted 188 lines · Prike

AMD General

Regards,
Prike

Quoted 174 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 7, 2026 9:47 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 38 lines · Prike

AMD General

Regards,
Prike

Quoted 30 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, August 4, 2026 10:18 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 18 lines · Prike

AMD General

Regards,
Prike

Quoted 12 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:40 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 9:36 AM Liang, Prike <[email protected]>

Quoted 43 lines · wrote:
Quoted 43 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

AMD General

Regards,
Prike

Quoted 13 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 5:25 AM Liang, Prike
<[email protected]>

Quoted 23 lines · wrote:
Quoted 23 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

AMD General

As for the hung userq, it should be identified by the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been implemented yet.

Quoted 1 line
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung

queues?

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will

Quoted 7 lines
Quoted 7 lines

never signal.

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Thank you for the input. However, for fake timeout cases such as the long shader

scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether
the queue rptr is still updating? If so, preempt the queue rather than resetting

it?

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

We have to assume that if we end up in the queue reset path that the queue is

hung.

Quoted 4 lines
Quoted 4 lines

The fences have to signal in finite time. If we preempt the queue that won't signal the fence so we'll just end up in the queue reset path again. Preemption of a queue that won't make progress only makes sense

Quoted 6 lines
Quoted 6 lines

if fences are not involved.

Quoted 3 lines

The most cases relevant to userq fence timeout and reset worker likely to be

scheduled when a userq fence polling period expires. If a long running shader is detected, the driver may need to try preempting the queue

within a few retry cycles.

Quoted 5 lines
Quoted 5 lines

If the userq fence remains unsignaled after the retries are exhausted, the driver can either return -ETIME to userspace for further handling or fall back to resetting the queue directly. Meanwhile, If the preemption succeeds and the queue completes its work during the subsequent restore process, no further reset is necessary for the

guilty queue?

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

If an application wants to run long running jobs they shouldn't use protected fences in the first place. If they don't use protected fences, then it should behave like KFD queues. If there is some operation that needs to happen the queues will get preempted and then will continue later. DMA fences need to signal in finite time so we can't just keep pushing them off. Other kernel paging operations may

depend on them signalling.

Quoted 2 lines

Regarding the protected fences, do you mean the userq fence that triggers the

hang detection work queue?

Quoted 1 line

Yes.

Quoted 1 line

If so, the current implementation calls amdgpu_userq_fence_init() at fence emit

time (i.e., at each queue submission), which both initializes the dma_fence structure and starts the hang detection timer for that submission. Once the timeout expires, amdgpu_userq_hang_detect_work() fires and triggers a queue reset regardless of whether the queue is actually hung or simply long-running. But there's a core problem for the kernel to distinguish a hung queue from a slow one at fence emit time, since both look identical an unsignaled fence with an active queue.

Quoted 1 line

That is the intended behavior. If you opt into using a dma fence, you need to abide by its semantics.

Quoted 1 line

However, we can defer that determination to the first timeout expiry in

amdgpu_userq_hang_detect_work(). At that point we have more information to work with:

Quoted 3 lines

Check for real hang: query rptr and rptr has not updated since the fence was

emitted, the queue is genuinely stuck (frozen waves, infinite loop). This is a real hang, reset immediately and forcing completing the fences.

Quoted 1 line

Check for forward progress: if rptr has updated but the fence is still unsignaled, the

queue is making progress, so it is long running, not hung. In this case:

Quoted 3 lines

Extend the timeout (reschedule hang_detect_work with a longer interval) Track retry count if the queue still has not completed after N extended

cycles, escalate: Preempt the queue, force completing the fence and return -ETIME to userspace then let the application decide: resubmit, split the workload, or drop.

Quoted 2 lines

Avoid unnecessary resets: if preemption succeeds and the queue resumes and

completes within the extended window, cancel the reset entirely since the queue was slow, not broken.

Quoted 3 lines

Do you think this is the right way for handling long-running tasks to resolve the

userq timeout issue, or does it align with your idea?

Quoted 7 lines

If you want to run a super long running job, then you shouldn't use a dma fence in the first place. There might be a job that takes 2 minutes or even an hour to run, but you can't wait that long for a dma fence. If you do, the kernel might run out of memory and the OOM killer will start killing processes or you could deadlock. If you want to run a long job, don't use a dma fence. If you don't use a dma fence, then the kernel can preempt the queues, do whatever memory management it needs to and then it can resume the queues. dma fences have to signal in finite time.

Quoted 2 lines

Got it. So to skip attaching a dma_fence to a long-running submission, does this require an explicit flag from userspace at queue creation, or is there another mechanism to identify it on the kernel side?

Userspace would simply not call the userq signal IOCTL if they want to run long running jobs.

Alex

Quoted 119 lines

Thanks,
Prike

Quoted 117 lines

Alex

Quoted 40 lines

Thanks,
Prike

Avoid unnecessary resets: if preemption succeeds and the queue resumes and completes within the extended window, cancel the reset entirely — the queue was slow, not broken.>

Quoted 33 lines

Alex

Quoted 2 lines

In the longer term, we may need to introduce a more robust mechanism to

distinguish slow queue cases from genuine hangs, handling them appropriately via extending time slice for completing the queue submission, userspace driven resubmission, or dropping the work through a queue reset. If it makes sense and right way to do, then I will work on implementing the solution for such slow/long queue cases.

Quoted 24 lines

Thanks,
Prike

Quoted 20 lines

Alex

Quoted 18 lines
Quoted 18 lines

Alex

Quoted 15 lines

Regards,
Prike

Quoted 12 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report

correctly.

Quoted 74 lines
Quoted 74 lines
Quoted 74 lines
Quoted 74 lines
Quoted 74 lines
Quoted 74 lines
Quoted 7 lines
Quoted 7 lines

@Zhang,
Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be

cleaned sooner or later.

Quoted 15 lines
Quoted 15 lines

Regards,
Prike

Quoted 10 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via
mes_userq_reset() is unnecessary, so remove it to unify the compute userq

reset.

Quoted 44 lines
Quoted 43 lines
Quoted 43 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -0
index 1e275c2e7dd3..4f2d5ff2f7be 100644
@@ -2315,11 +2315,6 @@ int

amdgpu_gfx_reset_mes_compute(struct
amdgpu_device *adev,

            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -5
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL; diff --git

a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c index b6bfa3974839..fab21d4275f3 100644

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
@@ -226,8 +226,6 @@ int mes_userq_reset_queue(struct
 amdgpu_device *adev,
 
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state = AMDGPU_USERQ_STATE_HUNG;

if (use_mmio)
--
2.34.1

#13 lore raw

AMD General

Regards,
Prike

Quoted 222 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 7, 2026 10:38 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 38 lines · Prike

AMD General

Regards,
Prike

Quoted 32 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 7, 2026 9:47 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 20 lines · Prike

AMD General

Regards,
Prike

Quoted 12 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, August 4, 2026 10:18 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Tue, Aug 4, 2026 at 4:16 AM Liang, Prike <[email protected]>

Quoted 42 lines · wrote:
Quoted 42 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

AMD General

Regards,
Prike

Quoted 13 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:40 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 9:36 AM Liang, Prike
<[email protected]>

Quoted 22 lines · wrote:
Quoted 22 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

AMD General

Regards,
Prike

Quoted 14 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 5:25 AM Liang, Prike
<[email protected]>

Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

AMD General

As for the hung userq, it should be identified by the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been

implemented yet.

Quoted 68 lines
Quoted 68 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung

queues?

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will

Quoted 8 lines
Quoted 8 lines

never signal.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

Thank you for the input. However, for fake timeout cases such as the long shader

scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether the queue rptr is still updating? If so, preempt the queue rather than resetting

it?

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

We have to assume that if we end up in the queue reset path that the queue is

hung.

Quoted 4 lines
Quoted 4 lines

The fences have to signal in finite time. If we preempt the queue that won't signal the fence so we'll just end up in the queue reset path again. Preemption of a queue that won't make progress only makes sense

Quoted 7 lines
Quoted 7 lines

if fences are not involved.

Quoted 3 lines

The most cases relevant to userq fence timeout and reset worker likely to be

scheduled when a userq fence polling period expires. If a long running shader is detected, the driver may need to try preempting the queue

within a few retry cycles.

Quoted 6 lines
Quoted 6 lines

If the userq fence remains unsignaled after the retries are exhausted, the driver can either return -ETIME to userspace for further handling or fall back to resetting the queue directly. Meanwhile, If the preemption succeeds and the queue completes its work during the subsequent restore process, no further reset is necessary for the

guilty queue?

Quoted 9 lines
Quoted 9 lines
Quoted 1 line

If an application wants to run long running jobs they shouldn't use protected fences in the first place. If they don't use protected fences, then it should behave like KFD queues. If there is some operation that needs to happen the queues will get preempted and then will continue later. DMA fences need to signal in finite time so we can't just keep pushing them off. Other kernel paging operations may

depend on them signalling.

Quoted 3 lines

Regarding the protected fences, do you mean the userq fence that triggers the

hang detection work queue?

Quoted 1 line

Yes.

Quoted 2 lines

If so, the current implementation calls amdgpu_userq_fence_init() at fence emit

Quoted 7 lines
Quoted 7 lines

time (i.e., at each queue submission), which both initializes the dma_fence structure and starts the hang detection timer for that submission. Once the timeout expires, amdgpu_userq_hang_detect_work() fires and triggers a queue reset regardless of whether the queue is actually hung or simply long-running. But there's a core problem for the kernel to distinguish a hung queue from a slow one at fence emit time, since both look

identical an unsignaled fence with an active queue.

Quoted 18 lines
Quoted 18 lines
Quoted 1 line

That is the intended behavior. If you opt into using a dma fence, you need to abide by its semantics.

Quoted 2 lines

However, we can defer that determination to the first timeout expiry in

amdgpu_userq_hang_detect_work(). At that point we have more information to work
with:

Quoted 4 lines

Check for real hang: query rptr and rptr has not updated since the fence was

emitted, the queue is genuinely stuck (frozen waves, infinite loop). This is a real hang, reset immediately and forcing completing the fences.

Quoted 2 lines

Check for forward progress: if rptr has updated but the fence is still unsignaled, the

Quoted 7 lines
Quoted 7 lines

queue is making progress, so it is long running, not hung. In this case:

Quoted 4 lines

Extend the timeout (reschedule hang_detect_work with a longer interval) Track retry count if the queue still has not completed after N extended

cycles, escalate: Preempt the queue, force completing the fence and return -ETIME to userspace then let the application decide: resubmit, split the

workload, or drop.

Quoted 11 lines
Quoted 11 lines
Quoted 3 lines

Avoid unnecessary resets: if preemption succeeds and the queue resumes and

completes within the extended window, cancel the reset entirely since the queue was slow, not broken.

Quoted 4 lines

Do you think this is the right way for handling long-running tasks to resolve the

userq timeout issue, or does it align with your idea?

Quoted 7 lines
Quoted 7 lines

If you want to run a super long running job, then you shouldn't use a dma fence in the first place. There might be a job that takes 2 minutes or even an hour to run, but you can't wait that long for a dma fence. If you do, the kernel might run out of memory and the OOM killer will start killing processes or you could deadlock. If you want to run a long job, don't use a dma fence. If you don't use a dma fence, then the kernel can preempt the queues, do whatever memory

management it needs to and then it can resume the queues. dma fences have to signal in finite time.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

Got it. So to skip attaching a dma_fence to a long-running submission, does this

require an explicit flag from userspace at queue creation, or is there another mechanism to identify it on the kernel side?

Quoted 1 line

Userspace would simply not call the userq signal IOCTL if they want to run long running jobs.

Yes, this approach can also handle long-running jobs submitted from userspace. However, after revisiting the Mesa code, it appears that a fence is always emitted for each userq submission, and I could not find any code for identifying long-running submissions. How should long-running submissions be identified in userspace?

If a long-running submission does not use a protected fence, hang_detect_work should not be scheduled for that submission, and this cleanup patch should not affect the corresponding long-running userq. This should therefore be treated as a separate case requiring further investigation, including how to identify long-running userq submissions and avoid attaching protected fences to them.

Regarding the cleanup, if all hung user queues can be identified through hang_detect_only, do we still need to handle the guilty userq separately? Could we simply reset all guilty queues by traversing the list of hung doorbells, as proposed in this cleanup patch?

Regards,
Prike

Quoted 126 lines

Alex

Quoted 20 lines

Thanks,
Prike

Quoted 18 lines

Alex

Quoted 16 lines

Thanks,
Prike

Avoid unnecessary resets: if preemption succeeds and the queue resumes and completes within the extended window, cancel the reset entirely — the queue was slow, not broken.>

Quoted 9 lines

Alex

Quoted 2 lines

In the longer term, we may need to introduce a more robust mechanism to

distinguish slow queue cases from genuine hangs, handling them appropriately via extending time slice for completing the queue submission, userspace driven resubmission, or dropping the work through a queue reset. If it makes sense and right way to do, then I will work on implementing the solution for such slow/long queue

cases.

Quoted 92 lines
Quoted 92 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

Thanks,
Prike

Quoted 18 lines

Alex

Quoted 16 lines
Quoted 16 lines

Alex

Quoted 13 lines

Regards,
Prike

Quoted 10 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report

correctly.

Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
Quoted 7 lines
Quoted 7 lines

@Zhang,
Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be

cleaned sooner or later.

Quoted 16 lines
Quoted 16 lines

Regards,
Prike

Quoted 11 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

amdgpu_mes_detect_and_reset_hung_queues() already detects the guilty compute user queue and resets it through mes_userq_reset_queue(). The additional reset via
mes_userq_reset() is unnecessary, so remove it to unify the compute userq

reset.

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 5 -----
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
 2 files changed, 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c index 1e275c2e7dd3..4f2d5ff2f7be 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -0
@@ -2315,11 +2315,6 @@ int

amdgpu_gfx_reset_mes_compute(struct
amdgpu_device *adev,

            deferred_end[n_deferred].fence = guilty_fence;
            n_deferred++;
    }
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -6
-   if (uq) {
-           r = mes_userq_reset(uq);
-           if (r)
-                   goto out;
-   }
    for (i = 0; i < num_hung; i++) {
            struct amdgpu_ring *hr = NULL;
            struct amdgpu_fence *hf = NULL; diff
--git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c

b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c index b6bfa3974839..fab21d4275f3 100644

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -0
@@ -226,8 +226,6 @@ int
 mes_userq_reset_queue(struct amdgpu_device *adev,
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/mes_userqueue.c int · line 231

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0 -2
    xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
            if (uq->queue_type == queue_type) {
-                   if (uq == guilty_uq)
-                           continue;
                    if (uq->doorbell_index == db) {
                            uq->state =

AMDGPU_USERQ_STATE_HUNG;

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

if (use_mmio)
--
2.34.1

#14 lore raw
Quoted 229 lines · Prike

AMD General

Regards,
Prike

Quoted 223 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 7, 2026 10:38 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 38 lines · Prike

AMD General

Regards,
Prike

Quoted 32 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 7, 2026 9:47 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 20 lines · Prike

AMD General

Regards,
Prike

Quoted 12 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, August 4, 2026 10:18 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Tue, Aug 4, 2026 at 4:16 AM Liang, Prike <[email protected]>

Quoted 42 lines · wrote:
Quoted 42 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

AMD General

Regards,
Prike

Quoted 13 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:40 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 9:36 AM Liang, Prike
<[email protected]>

Quoted 22 lines · wrote:
Quoted 22 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

AMD General

Regards,
Prike

Quoted 14 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 5:25 AM Liang, Prike
<[email protected]>

Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

AMD General

As for the hung userq, it should be identified by the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been

implemented yet.

Quoted 68 lines
Quoted 68 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung

queues?

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will

Quoted 8 lines
Quoted 8 lines

never signal.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

Thank you for the input. However, for fake timeout cases such as the long shader

scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether the queue rptr is still updating? If so, preempt the queue rather than resetting

it?

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

We have to assume that if we end up in the queue reset path that the queue is

hung.

Quoted 4 lines
Quoted 4 lines

The fences have to signal in finite time. If we preempt the queue that won't signal the fence so we'll just end up in the queue reset path again. Preemption of a queue that won't make progress only makes sense

Quoted 7 lines
Quoted 7 lines

if fences are not involved.

Quoted 3 lines

The most cases relevant to userq fence timeout and reset worker likely to be

scheduled when a userq fence polling period expires. If a long running shader is detected, the driver may need to try preempting the queue

within a few retry cycles.

Quoted 6 lines
Quoted 6 lines

If the userq fence remains unsignaled after the retries are exhausted, the driver can either return -ETIME to userspace for further handling or fall back to resetting the queue directly. Meanwhile, If the preemption succeeds and the queue completes its work during the subsequent restore process, no further reset is necessary for the

guilty queue?

Quoted 9 lines
Quoted 9 lines
Quoted 1 line

If an application wants to run long running jobs they shouldn't use protected fences in the first place. If they don't use protected fences, then it should behave like KFD queues. If there is some operation that needs to happen the queues will get preempted and then will continue later. DMA fences need to signal in finite time so we can't just keep pushing them off. Other kernel paging operations may

depend on them signalling.

Quoted 3 lines

Regarding the protected fences, do you mean the userq fence that triggers the

hang detection work queue?

Quoted 1 line

Yes.

Quoted 2 lines

If so, the current implementation calls amdgpu_userq_fence_init() at fence emit

Quoted 7 lines
Quoted 7 lines

time (i.e., at each queue submission), which both initializes the dma_fence structure and starts the hang detection timer for that submission. Once the timeout expires, amdgpu_userq_hang_detect_work() fires and triggers a queue reset regardless of whether the queue is actually hung or simply long-running. But there's a core problem for the kernel to distinguish a hung queue from a slow one at fence emit time, since both look

identical an unsignaled fence with an active queue.

Quoted 18 lines
Quoted 18 lines
Quoted 1 line

That is the intended behavior. If you opt into using a dma fence, you need to abide by its semantics.

Quoted 2 lines

However, we can defer that determination to the first timeout expiry in

amdgpu_userq_hang_detect_work(). At that point we have more information to work
with:

Quoted 4 lines

Check for real hang: query rptr and rptr has not updated since the fence was

emitted, the queue is genuinely stuck (frozen waves, infinite loop). This is a real hang, reset immediately and forcing completing the fences.

Quoted 2 lines

Check for forward progress: if rptr has updated but the fence is still unsignaled, the

Quoted 7 lines
Quoted 7 lines

queue is making progress, so it is long running, not hung. In this case:

Quoted 4 lines

Extend the timeout (reschedule hang_detect_work with a longer interval) Track retry count if the queue still has not completed after N extended

cycles, escalate: Preempt the queue, force completing the fence and return -ETIME to userspace then let the application decide: resubmit, split the

workload, or drop.

Quoted 11 lines
Quoted 11 lines
Quoted 3 lines

Avoid unnecessary resets: if preemption succeeds and the queue resumes and

completes within the extended window, cancel the reset entirely since the queue was slow, not broken.

Quoted 4 lines

Do you think this is the right way for handling long-running tasks to resolve the

userq timeout issue, or does it align with your idea?

Quoted 7 lines
Quoted 7 lines

If you want to run a super long running job, then you shouldn't use a dma fence in the first place. There might be a job that takes 2 minutes or even an hour to run, but you can't wait that long for a dma fence. If you do, the kernel might run out of memory and the OOM killer will start killing processes or you could deadlock. If you want to run a long job, don't use a dma fence. If you don't use a dma fence, then the kernel can preempt the queues, do whatever memory

management it needs to and then it can resume the queues. dma fences have to signal in finite time.

Quoted 2 lines

Got it. So to skip attaching a dma_fence to a long-running submission, does this

Quoted 8 lines
Quoted 6 lines

require an explicit flag from userspace at queue creation, or is there another mechanism to identify it on the kernel side?

Quoted 1 line

Userspace would simply not call the userq signal IOCTL if they want to run long running jobs.

Yes, this approach can also handle long-running jobs submitted from userspace. However, after revisiting the Mesa code, it appears that a fence is always emitted for each userq submission, and I could not find any code for identifying long-running submissions. How should long-running submissions be identified in userspace?

Userspace should not use protected fences in that case. In theory compositors that use explicit sync do not need to use the protected fence. Someone just needs to handle this case in mesa.

Quoted 3 lines

If a long-running submission does not use a protected fence, hang_detect_work should not be scheduled for that submission, and this cleanup patch should not affect the corresponding long-running userq. This should therefore be treated as a separate case requiring further investigation, including how to identify long-running userq submissions and avoid attaching protected fences to them.

All we need to do is check for the presence of a fence on the queue (the application would have called the fence IOCTL). If the fence is present, then we'd reset the queue. If no fence, and MES hang_detect doesn't detect the queue as hung, then there is no need to reset it.

Quoted 1 line

Regarding the cleanup, if all hung user queues can be identified through hang_detect_only, do we still need to handle the guilty userq separately? Could we simply reset all guilty queues by traversing the list of hung doorbells, as proposed in this cleanup patch?

If there are no protected fences, then yes, all we need is MES hang detect.

Alex

Quoted 130 lines

Regards,
Prike

Quoted 126 lines

Alex

Quoted 20 lines

Thanks,
Prike

Quoted 18 lines

Alex

Quoted 16 lines

Thanks,
Prike

Avoid unnecessary resets: if preemption succeeds and the queue resumes and completes within the extended window, cancel the reset entirely — the queue was slow, not broken.>

Quoted 9 lines

Alex

Quoted 2 lines

In the longer term, we may need to introduce a more robust mechanism to

distinguish slow queue cases from genuine hangs, handling them appropriately via extending time slice for completing the queue submission, userspace driven resubmission, or dropping the work through a queue reset. If it makes sense and right way to do, then I will work on implementing the solution for such slow/long queue

cases.

Quoted 92 lines
Quoted 92 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

Thanks,
Prike

Quoted 18 lines

Alex

Quoted 16 lines
Quoted 16 lines

Alex

Quoted 13 lines

Regards,
Prike

Quoted 10 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I checked each different userq hang cases, and the guilty userq can be identified by the MES firmware and report

correctly.

Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
Quoted 7 lines
Quoted 7 lines

@Zhang,
Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by MES firmware, then the correct thing is to further debug from MES firmware side rather than have such strange reset sequence and this reset workaround should be

cleaned sooner or later.

Quoted 16 lines
Quoted 16 lines

Regards,
Prike

Quoted 11 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander
<[email protected]>; Koenig, Christian
<[email protected]>; Liang, Prike
<[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove separate
guilty compute userq reset

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

amdgpu_mes_detect_and_reset_hung_queues() already
detects the guilty compute user queue and resets
it through mes_userq_reset_queue(). The additional
reset via
mes_userq_reset() is unnecessary, so remove it to
unify the compute userq

reset.

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines

Signed-off-by: Prike Liang <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 5 -----
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 2 --
2 files changed, 7 deletions(-)

diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 1e275c2e7dd3..4f2d5ff2f7be 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -2315,11 +2315,6 @@ int
amdgpu_gfx_reset_mes_compute(struct
amdgpu_device *adev,
deferred_end[n_deferred].fence = guilty_fence;
n_deferred++;
}
- if (uq) {
- r = mes_userq_reset(uq);
- if (r)
- goto out;
- }
for (i = 0; i < num_hung; i++) {
struct amdgpu_ring *hr = NULL;
struct amdgpu_fence *hf = NULL; diff
--git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index b6bfa3974839..fab21d4275f3 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
@@ -226,8 +226,6 @@ int
mes_userq_reset_queue(struct amdgpu_device *adev,

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
if (uq->queue_type == queue_type) {
- if (uq == guilty_uq)
- continue;
if (uq->doorbell_index == db) {
uq->state =

AMDGPU_USERQ_STATE_HUNG;

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

if (use_mmio)
--
2.34.1

#15 lore raw

AMD General

Regards,
Prike

Quoted 257 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, August 12, 2026 8:47 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 167 lines · Prike

AMD General

Regards,
Prike

Quoted 161 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 7, 2026 10:38 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 39 lines · Prike

AMD General

Regards,
Prike

Quoted 33 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, August 7, 2026 9:47 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

Quoted 21 lines · Prike

AMD General

Regards,
Prike

Quoted 13 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, August 4, 2026 10:18 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Tue, Aug 4, 2026 at 4:16 AM Liang, Prike
<[email protected]>

Quoted 43 lines · wrote:
Quoted 43 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

AMD General

Regards,
Prike

Quoted 14 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:40 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 9:36 AM Liang, Prike
<[email protected]>

Quoted 22 lines · wrote:
Quoted 22 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

AMD General

Regards,
Prike

Quoted 14 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, August 3, 2026 9:23 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Zhang, Jesse(Jie) <[email protected]>; Liu, Shaoyun <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Remove separate guilty compute userq reset

On Mon, Aug 3, 2026 at 5:25 AM Liang, Prike <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

AMD General

As for the hung userq, it should be identified by
the MES reset API with the

hang_detect_only setting. However, it is unlikely to miss detecting the invalid opcode hang case, especially given that the userq invalid opcode IGT test has not been

implemented yet.

Quoted 57 lines
Quoted 57 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Hi @Liu, Shaoyun, are you aware of any known userq hang scenarios that cannot

be identified by MES API hang_detect_only? If not, could you please help review the following patch, which unifies the userq reset path for hung

queues?

Quoted 9 lines
Quoted 9 lines
Quoted 1 line

We added it in the first place to deal with those cases. There can be queues which are not hung, but will never complete and hence never signal their fence. E.g., you can have a queue that is waiting on a memory location that MES can preempt, but due to a bug elsewhere that memory location will never change so the fence will

Quoted 8 lines
Quoted 8 lines

never signal.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

Thank you for the input. However, for fake timeout cases such as the long shader

scenario, we should identify the fake hang cases by checking whether the guilty queue appears in the hang list, or whether the queue rptr is still updating? If so, preempt the queue rather than resetting

it?

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

We have to assume that if we end up in the queue reset path that the queue is

hung.

Quoted 4 lines
Quoted 4 lines

The fences have to signal in finite time. If we preempt the queue that won't signal the fence so we'll just end up in the queue reset path again. Preemption of a queue that won't make progress only makes sense

Quoted 7 lines
Quoted 7 lines

if fences are not involved.

Quoted 3 lines

The most cases relevant to userq fence timeout and reset worker likely to be

scheduled when a userq fence polling period expires. If a long running shader is detected, the driver may need to try preempting the queue

within a few retry cycles.

Quoted 6 lines
Quoted 6 lines

If the userq fence remains unsignaled after the retries are exhausted, the driver can either return -ETIME to userspace for further handling or fall back to resetting the queue directly. Meanwhile, If the preemption succeeds and the queue completes its work during the subsequent restore process, no further reset is necessary for the

guilty queue?

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

If an application wants to run long running jobs they shouldn't use protected fences in the first place. If they don't use protected fences, then it should behave like KFD queues. If there is some operation that needs to happen the queues will get preempted and then will continue later. DMA fences need to signal in finite time so we can't just keep pushing them

off.

Quoted 79 lines
Quoted 78 lines
Quoted 12 lines
Quoted 12 lines
Quoted 1 line
Quoted 1 line

Other kernel paging operations may

depend on them signalling.

Quoted 3 lines

Regarding the protected fences, do you mean the userq fence that triggers the

hang detection work queue?

Quoted 1 line

Yes.

Quoted 2 lines

If so, the current implementation calls
amdgpu_userq_fence_init() at fence emit

Quoted 8 lines
Quoted 8 lines

time (i.e., at each queue submission), which both initializes the dma_fence structure and starts the hang detection timer for that submission. Once the timeout expires, amdgpu_userq_hang_detect_work() fires and triggers a queue reset regardless of whether the queue is actually hung or simply long-running. But there's a core problem for the kernel to distinguish a hung queue from a slow one at fence emit time, since both look

identical an unsignaled fence with an active queue.

Quoted 18 lines
Quoted 18 lines
Quoted 1 line

That is the intended behavior. If you opt into using a dma fence, you need to abide by its semantics.

Quoted 2 lines

However, we can defer that determination to the first timeout expiry in

amdgpu_userq_hang_detect_work(). At that point we have more information to work
with:

Quoted 4 lines

Check for real hang: query rptr and rptr has not updated since the fence was

emitted, the queue is genuinely stuck (frozen waves, infinite loop). This is a real hang, reset immediately and forcing completing the fences.

Quoted 2 lines

Check for forward progress: if rptr has updated but the fence is still unsignaled, the

Quoted 8 lines
Quoted 8 lines

queue is making progress, so it is long running, not hung. In this case:

Quoted 4 lines

Extend the timeout (reschedule hang_detect_work with a longer interval) Track retry count if the queue still has not completed after N extended

cycles, escalate: Preempt the queue, force completing the fence and return -ETIME to userspace then let the application decide:
resubmit, split the

workload, or drop.

Quoted 11 lines
Quoted 11 lines
Quoted 3 lines

Avoid unnecessary resets: if preemption succeeds and the queue resumes and

completes within the extended window, cancel the reset entirely since the queue was slow, not broken.

Quoted 4 lines

Do you think this is the right way for handling long-running tasks to resolve the

userq timeout issue, or does it align with your idea?

Quoted 8 lines
Quoted 8 lines

If you want to run a super long running job, then you shouldn't use a dma fence in the first place. There might be a job that takes 2 minutes or even an hour to run, but you can't wait that long for a dma fence. If you do, the kernel might run out of memory and the OOM killer will start killing processes or you could deadlock. If you want to run a long job, don't use a dma fence. If you don't use a dma fence, then the kernel can preempt the queues, do whatever memory

management it needs to and then it can resume the queues. dma fences have to signal in finite time.

Quoted 3 lines

Got it. So to skip attaching a dma_fence to a long-running submission, does this

require an explicit flag from userspace at queue creation, or is there another mechanism to identify it on the kernel side?

Quoted 1 line

Userspace would simply not call the userq signal IOCTL if they want to run long running jobs.

Quoted 8 lines
Quoted 1 line

Yes, this approach can also handle long-running jobs submitted from userspace.

However, after revisiting the Mesa code, it appears that a fence is always emitted for each userq submission, and I could not find any code for identifying long-running submissions. How should long-running submissions be identified in userspace?

Userspace should not use protected fences in that case. In theory compositors that use explicit sync do not need to use the protected fence. Someone just needs to handle this case in mesa.

Understanding, I will create a new thread for tracking the long running submission work item.

Quoted 13 lines
Quoted 2 lines

If a long-running submission does not use a protected fence, hang_detect_work

should not be scheduled for that submission, and this cleanup patch should not affect the corresponding long-running userq. This should therefore be treated as a separate case requiring further investigation, including how to identify long-running userq submissions and avoid attaching protected fences to them.

Quoted 1 line

All we need to do is check for the presence of a fence on the queue (the application would have called the fence IOCTL). If the fence is present, then we'd reset the queue. If no fence, and MES hang_detect doesn't detect the queue as hung, then there is no need to reset it.

Quoted 6 lines
Quoted 1 line

Regarding the cleanup, if all hung user queues can be identified through

hang_detect_only, do we still need to handle the guilty userq separately? Could we simply reset all guilty queues by traversing the list of hung doorbells, as proposed in this cleanup patch?

If there are no protected fences, then yes, all we need is MES hang detect.

Per this cleanup for the guilty reset handling, may I have a review or ack for those clean up series?

Quoted 141 lines

Alex

Quoted 139 lines

Regards,
Prike

Quoted 135 lines

Alex

Quoted 21 lines

Thanks,
Prike

Quoted 19 lines

Alex

Quoted 17 lines

Thanks,
Prike

Avoid unnecessary resets: if preemption succeeds and the queue resumes and completes within the extended window, cancel the reset entirely — the queue was slow, not broken.>

Quoted 10 lines

Alex

Quoted 2 lines

In the longer term, we may need to introduce a more robust mechanism to

distinguish slow queue cases from genuine hangs, handling them appropriately via extending time slice for completing the queue submission, userspace driven resubmission, or dropping the work through a queue reset. If it makes sense and right way to do, then I will work on implementing the solution for such slow/long queue

cases.

Quoted 100 lines
Quoted 100 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

Thanks,
Prike

Quoted 19 lines

Alex

Quoted 17 lines
Quoted 17 lines

Alex

Quoted 14 lines

Regards,
Prike

Quoted 11 lines

-----Original Message-----
From: Liang, Prike
Sent: Thursday, July 23, 2026 2:38 PM
To: [email protected]; Zhang,
Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander
<[email protected]>; Koenig, Christian
<[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Remove
separate guilty compute userq reset

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I checked each different userq hang cases, and
the guilty userq can be identified by the MES
firmware and report

correctly.

Quoted 73 lines
Quoted 73 lines
Quoted 73 lines
Quoted 73 lines
Quoted 73 lines
Quoted 73 lines
Quoted 8 lines
Quoted 8 lines

@Zhang,
Jesse(Jie) could you further check as well at you side?

If there're some hang queues miss identified by
MES firmware, then the correct thing is to
further debug from MES firmware side rather than
have such strange reset sequence and this reset
workaround should be

cleaned sooner or later.

Quoted 16 lines
Quoted 16 lines

Regards,
Prike

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, July 15, 2026 2:31 PM
To: [email protected]
Cc: Deucher, Alexander
<[email protected]>; Koenig, Christian
<[email protected]>; Liang, Prike
<[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Remove
separate guilty compute userq reset

Quoted 6 lines
Quoted 6 lines

amdgpu_mes_detect_and_reset_hung_queues()
already detects the guilty compute user queue
and resets it through mes_userq_reset_queue().
The additional reset via
mes_userq_reset() is unnecessary, so remove it
to unify the compute userq

reset.

Quoted 41 lines
Quoted 41 lines

Signed-off-by: Prike Liang
<[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 5 -----
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c |
2 --
2 files changed, 7 deletions(-)

diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 1e275c2e7dd3..4f2d5ff2f7be 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -2315,11 +2315,6 @@ int
amdgpu_gfx_reset_mes_compute(struct
amdgpu_device *adev,
deferred_end[n_deferred].fence = guilty_fence;
n_deferred++;
}
- if (uq) {
- r = mes_userq_reset(uq);
- if (r)
- goto out;
- }
for (i = 0; i < num_hung; i++) {
struct amdgpu_ring *hr = NULL;
struct amdgpu_fence *hf = NULL;
diff --git
a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index b6bfa3974839..fab21d4275f3 100644
---
a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue
+++ .c
@@ -226,8 +226,6 @@ int
mes_userq_reset_queue(struct amdgpu_device
*adev,

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

xa_for_each(&adev->userq_doorbell_xa, uq_id, uq) {
if (uq->queue_type == queue_type) {
- if (uq == guilty_uq)
- continue;
if (uq->doorbell_index == db) {
uq->state =

AMDGPU_USERQ_STATE_HUNG;

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

if (use_mmio)
--
2.34.1