public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Xiaolei Wang <xiaolei.wang@windriver.com>
To: mwen@igalia.com, mcanal@igalia.com,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
	Xiaolei.Wang@windriver.com
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] drm/v3d: Using spin_lock_irqsave instead of spin_lock in the RT kernel
Date: Wed,  4 Mar 2026 11:17:24 +0800	[thread overview]
Message-ID: <20260304031724.246404-1-xiaolei.wang@windriver.com> (raw)

Disabling interrupts before calling 'spin_lock()' is unnecessary;
its implementation is only for satisfying lockdep's requirements.
Since preemption is disabled by default when calling 'spin_lock()'
in the standard kernel, both 'local_irq_save()' and 'preempt_disable()'
become redundant. Therefore, we can replace 'spin_lock()' with
'spin_lock_irqsave()' to ensure compatibility between the standard
kernel and the rt kernel. Avoid the following warning:

Hardware name: Raspberry Pi 5 Model B Rev 1.0 (DT)
Call trace:
dump_backtrace.part.0+0xe0/0x100
show_stack+0x20/0x40
dump_stack_lvl+0x60/0x80 dump_stack+0x18/0x28
__might_resched+0x134/0x168
rt_spin_lock+0x5c/0xe0
v3d_job_update_stats+0x64/0x1d0 [v3d]
v3d_irq+0xf0/0x410 [v3d]
irq_forced_thread_fn+0x44/0xd8
irq_thread+0x1ac/0x2d8
kthread+0x124/0x138
ret_from_fork+0x10/0x20

Fixes: fa6a20c87470 ("drm/v3d: Address race-condition between per-fd GPU stats and fd release")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
---
 drivers/gpu/drm/v3d/v3d_sched.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c
index 6dc871fc9a62..5eaacb1d1480 100644
--- a/drivers/gpu/drm/v3d/v3d_sched.c
+++ b/drivers/gpu/drm/v3d/v3d_sched.c
@@ -203,24 +203,13 @@ v3d_job_update_stats(struct v3d_job *job, enum v3d_queue q)
 	u64 now = local_clock();
 	unsigned long flags;
 
-	/* See comment in v3d_job_start_stats() */
-	if (IS_ENABLED(CONFIG_LOCKDEP))
-		local_irq_save(flags);
-	else
-		preempt_disable();
-
 	/* Don't update the local stats if the file context has already closed */
-	spin_lock(&queue->queue_lock);
+	spin_lock_irqsave(&queue->queue_lock, flags);
 	if (job->file_priv)
 		v3d_stats_update(&job->file_priv->stats[q], now);
-	spin_unlock(&queue->queue_lock);
+	spin_unlock_irqrestore(&queue->queue_lock, flags);
 
 	v3d_stats_update(global_stats, now);
-
-	if (IS_ENABLED(CONFIG_LOCKDEP))
-		local_irq_restore(flags);
-	else
-		preempt_enable();
 }
 
 static struct dma_fence *v3d_bin_job_run(struct drm_sched_job *sched_job)
-- 
2.43.0


             reply	other threads:[~2026-03-04  3:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04  3:17 Xiaolei Wang [this message]
2026-03-04 10:21 ` [PATCH] drm/v3d: Using spin_lock_irqsave instead of spin_lock in the RT kernel Maíra Canal
2026-03-05  3:49 ` Claude review: " Claude Code Review Bot
2026-03-05  3:49 ` Claude Code Review Bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260304031724.246404-1-xiaolei.wang@windriver.com \
    --to=xiaolei.wang@windriver.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mcanal@igalia.com \
    --cc=mripard@kernel.org \
    --cc=mwen@igalia.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox