Skip to contentSkip to conversation

drm/msm: Preemption timeout should be greater than hangcheck

PATCH In review Rob Clark 2 participants 2 messages Jul 26 – Jul 27 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

Rob Clark

author maintainer
#0 lore raw

PATCH 1/1 drm/msm: Preemption timeout should be greater than hangcheck

Long running jobs may not necessarily be able to preempt at a fine enough granularity. The hard-coded preempt timeout would otherwise kick in and kill the job even if we haven't reached the hangcheck timeout otherwise.

---
 drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 2 +-
 drivers/gpu/drm/msm/adreno/a6xx_preempt.h | 8 ++++++++
 drivers/gpu/drm/msm/adreno/a8xx_preempt.c | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +1 -1
index 1e599d4ddea1..00c239451c7b 100644
@@ -258,7 +258,7 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)
 	a6xx_gpu->next_ring = ring;
 
 	/* Start a timer to catch a stuck preemption */
-	mod_timer(&a6xx_gpu->preempt_timer, jiffies + msecs_to_jiffies(10000));
+	set_preempt_timer(a6xx_gpu);
 
 	/* Enable or disable postamble as needed */
 	sysprof = msm_gpu_sysprof_no_perfcntr_zap(gpu);
drivers/gpu/drm/msm/adreno/a6xx_preempt.h +8 -0
index df36c945b836..178017aad26e 100644
@@ -35,6 +35,14 @@ static inline void set_preempt_state(struct a6xx_gpu *gpu,
 	smp_mb__after_atomic();
 }
 
+static inline void set_preempt_timer(struct a6xx_gpu *gpu)
+{
+	struct msm_drm_private *priv = gpu->base.base.dev->dev_private;
+	unsigned t = max(10000, priv->hangcheck_period);
+
+	mod_timer(&gpu->preempt_timer, jiffies + msecs_to_jiffies(t));
+}
+
 /* Write the most recent wptr for the given ring into the hardware */
 static inline void update_wptr(struct a6xx_gpu *a6xx_gpu, struct msm_ringbuffer *ring)
 {
drivers/gpu/drm/msm/adreno/a8xx_preempt.c +1 -1
index 6cb53a071801..c94f99625ea8 100644
@@ -239,7 +239,7 @@ void a8xx_preempt_trigger(struct msm_gpu *gpu)
 	a6xx_gpu->next_ring = ring;
 
 	/* Start a timer to catch a stuck preemption */
-	mod_timer(&a6xx_gpu->preempt_timer, jiffies + msecs_to_jiffies(10000));
+	set_preempt_timer(a6xx_gpu);
 
 	/* Enable or disable postamble as needed */
 	sysprof = msm_gpu_sysprof_no_perfcntr_zap(gpu);
Signature · 1 line
2.55.0

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 33 lines · On Sun, Jul 26, 2026 at 10:57 AM <[email protected]> wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The preemption timeout calculation fails to account for the hangcheck progress multiplier, causing premature job termination for long-running jobs. --

--- Patch [1]: [PATCH] drm/msm: Preemption timeout should be greater than hangcheck --- commit 5454ddf4018869efeec2d7c8f2767056ad2612d9
Author: Rob Clark <[email protected]>

drm/msm: Preemption timeout should be greater than hangcheck

This commit changes the preemption timeout from a hard-coded 10 seconds to the maximum of 10 seconds and the configured hangcheck period. This is intended to prevent the preemption timer from prematurely killing long-running jobs that are otherwise compliant with the hangcheck timeout.

drivers/gpu/drm/msm/adreno/a6xx_preempt.h static inline void set_preempt_state(struct a6xx_gpu *gpu, · line 41

Quoted 12 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.h +4 -0
index df36c945b836b..178017aad26e6 100644
@@ -35,6 +35,14 @@ static inline void set_preempt_state(struct a6xx_gpu *gpu,
      smp_mb__after_atomic();
 }
 
+static inline void set_preempt_timer(struct a6xx_gpu *gpu)
+{
+     struct msm_drm_private *priv = gpu->base.base.dev->dev_private;
+     unsigned t = max(10000, priv->hangcheck_period);

[Severity: Medium]
Will this under-calculate the true hangcheck timeout when progress detection is enabled?

Quoted 9 lines

According to msm_ringbuffer.h, when progress detection is enabled, the hangcheck timer duration is halved and allows up to DRM_MSM_HANGCHECK_PROGRESS_RETRIES extra cycles.

If a user sets a large hangcheck period via debugfs to allow for long compute shaders, wouldn't using priv->hangcheck_period directly here result in a preemption timeout that is shorter than the actual allowed hangcheck time, potentially still killing the job prematurely?

yes, but the progress detection is based on detecting that the CP advanced, which won't be the case for long running compute shaders

BR,
-R

Quoted 10 lines

drivers/gpu/drm/msm/adreno/a6xx_preempt.h static inline void set_preempt_state(struct a6xx_gpu *gpu, · line 48

Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.h +4 -0
+
+     mod_timer(&gpu->preempt_timer, jiffies + msecs_to_jiffies(t));
+}
+
 /* Write the most recent wptr for the given ring into the hardware */
 static inline void update_wptr(struct a6xx_gpu *a6xx_gpu, struct msm_ringbuffer *ring)
 {

--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1