LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Clark Williams <williams@redhat.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	David Airlie <airlied@linux.ie>,
	LKML <linux-kernel@vger.kernel.org>,
	RT <linux-rt-users@vger.kernel.org>,
	Daniel Vetter <daniel@ffwll.ch>
Subject: [PATCH PREEMPT_RT] i915: fix PREEMPT_RT locking splats
Date: Mon, 23 Aug 2021 15:00:15 -0500	[thread overview]
Message-ID: <20210823150015.61ebc7d6@theseus> (raw)

Found two separate spots where i915 was throwing "sleeping
function called from invalid context" when running on a
PREEMPT_RT kernel. In both cases it was from calling
local_irq_disable prior to taking a spin_lock. Since spin
locks are converted to rt_mutex_t on PREEMPT_RT this means
that we might sleep with interrupts disabled.

Since in both cases the calls were in threaded context on RT
(irq or ksoftirqd) and in no danger of reentrance, change the
code to only disable interrupts on non-PREEMPT_RT kernels.

Signed-off-by: Clark Williams <williams@redhat.com>
---
 drivers/gpu/drm/i915/gt/intel_breadcrumbs.c          | 6 ++++--
 drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
index 38cc42783dfb..b8bf8d6d3c61 100644
--- a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
+++ b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
@@ -318,9 +318,11 @@ void __intel_breadcrumbs_park(struct intel_breadcrumbs *b)
 	/* Kick the work once more to drain the signalers, and disarm the irq */
 	irq_work_sync(&b->irq_work);
 	while (READ_ONCE(b->irq_armed) && !atomic_read(&b->active)) {
-		local_irq_disable();
+		if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+			local_irq_disable();
 		signal_irq_work(&b->irq_work);
-		local_irq_enable();
+		if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+			local_irq_enable();
 		cond_resched();
 	}
 }
diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
index fc77592d88a9..0e918831b69f 100644
--- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
+++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
@@ -1580,9 +1580,11 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
 
 static void execlists_dequeue_irq(struct intel_engine_cs *engine)
 {
-	local_irq_disable(); /* Suspend interrupts across request submission */
+	if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+		local_irq_disable(); /* Suspend interrupts across request submission */
 	execlists_dequeue(engine);
-	local_irq_enable(); /* flush irq_work (e.g. breadcrumb enabling) */
+	if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+		local_irq_enable(); /* flush irq_work (e.g. breadcrumb enabling) */
 }
 
 static void clear_ports(struct i915_request **ports, int count)
-- 
2.31.1

-- 
The United States Coast Guard
Ruining Natural Selection since 1790


             reply	other threads:[~2021-08-23 20:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 20:00 Clark Williams [this message]
2021-08-26 15:32 ` Sebastian Andrzej Siewior
2021-09-08 19:05 ` Sebastian Andrzej Siewior

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=20210823150015.61ebc7d6@theseus \
    --to=williams@redhat.com \
    --cc=airlied@linux.ie \
    --cc=bigeasy@linutronix.de \
    --cc=daniel@ffwll.ch \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --subject='Re: [PATCH PREEMPT_RT] i915: fix PREEMPT_RT locking splats' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).