drm/msm: Preemption timeout should be greater than hangcheck
Subsystems (4)
Rob Clark
maintainerPATCH 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
@@ -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
@@ -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
@@ -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]
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@@ -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 toDRM_MSM_HANGCHECK_PROGRESS_RETRIESextra cycles.If a user sets a large hangcheck period via debugfs to allow for long compute shaders, wouldn't using
priv->hangcheck_perioddirectly 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