Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/v3d: Disable preemption while updating GPU stats

We forgot to disable preemption around the write_seqcount_begin/end() pair
while updating GPU stats:

[ ] WARNING: CPU: 2 PID: 12 at include/linux/seqlock.h:221 __seqprop_assert.isra.0+0x128/0x150 [v3d]
[ ] Workqueue: v3d_bin drm_sched_run_job_work [gpu_sched]
<...snip...>
[ ] Call trace:
[ ] __seqprop_assert.isra.0+0x128/0x150 [v3d]
[ ] v3d_job_start_stats.isra.0+0x90/0x218 [v3d]
[ ] v3d_bin_job_run+0x23c/0x388 [v3d]
[ ] drm_sched_run_job_work+0x520/0x6d0 [gpu_sched]
[ ] process_one_work+0x62c/0xb48
[ ] worker_thread+0x468/0x5b0
[ ] kthread+0x1c4/0x1e0
[ ] ret_from_fork+0x10/0x20

Fix it.

Cc: Maíra Canal <mcanal@igalia.com>
Cc: stable@vger.kernel.org # v6.10+
Fixes: 6abe93b621ab ("drm/v3d: Fix race-condition between sysfs/fdinfo and interrupt handler")
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Acked-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240813102505.80512-1-tursulin@igalia.com

authored by

Tvrtko Ursulin and committed by
Maíra Canal
9d824c7f b49420d6

+6
+6
drivers/gpu/drm/v3d/v3d_sched.c
··· 134 134 struct v3d_stats *local_stats = &file->stats[queue]; 135 135 u64 now = local_clock(); 136 136 137 + preempt_disable(); 138 + 137 139 write_seqcount_begin(&local_stats->lock); 138 140 local_stats->start_ns = now; 139 141 write_seqcount_end(&local_stats->lock); ··· 143 141 write_seqcount_begin(&global_stats->lock); 144 142 global_stats->start_ns = now; 145 143 write_seqcount_end(&global_stats->lock); 144 + 145 + preempt_enable(); 146 146 } 147 147 148 148 static void ··· 166 162 struct v3d_stats *local_stats = &file->stats[queue]; 167 163 u64 now = local_clock(); 168 164 165 + preempt_disable(); 169 166 v3d_stats_update(local_stats, now); 170 167 v3d_stats_update(global_stats, now); 168 + preempt_enable(); 171 169 } 172 170 173 171 static struct dma_fence *v3d_bin_job_run(struct drm_sched_job *sched_job)