mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arun Iyengar via B4 Relay <devnull+aiyengar1990.gmail.com@kernel.org>
To: "Boris Brezillon" <boris.brezillon@collabora.com>,
	"Rob Herring" <robh@kernel.org>,
	"Steven Price" <steven.price@arm.com>,
	"Adrián Larumbe" <adrian.larumbe@collabora.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	 Arun Iyengar <aiyengar1990@gmail.com>
Subject: [PATCH v5 13/17] drm/panfrost: Wait for the soft-stopped slots with the live slot status
Date: Sat, 28 Nov 2026 17:26:44 +0000	[thread overview]
Message-ID: <20261128-panfrost-long-jobs-v5-13-e7d62045a676@gmail.com> (raw)
In-Reply-To: <20261128-panfrost-long-jobs-v5-0-e7d62045a676@gmail.com>

From: Arun Iyengar <aiyengar1990@gmail.com>

panfrost_reset() waits for the soft-stopped slots by polling
JOB_INT_JS_STATE, a snapshot taken at the last JOB_INT_CLEAR write. A
job started into an idle slot shows as idle, and the wait ends at once.
The GPU reset hides this. With the job resumed instead (patch 16), its
resubmission ran while the first run was still stopping (Mali-G31,
OpenCL CTS Integer Ops):

  Unable to handle kernel NULL pointer dereference at virtual address 00000000000000f8
  pc : panfrost_dequeue_job+0x2c/0xd8 [panfrost]

Wait until no JS_STATUS reads ACTIVE, and make panfrost_dequeue_job()
return NULL for an empty slot (a WARN, not an Oops).

Fixes: 030761e097b4 ("drm/panfrost: Queue jobs on the hardware")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_job.c | 34 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
index 0946da3af..722f87ebe 100644
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -173,7 +173,8 @@ panfrost_dequeue_job(struct panfrost_device *pfdev, int slot)
 {
 	struct panfrost_job *job = pfdev->jobs[slot][0];
 
-	WARN_ON(!job);
+	if (WARN_ON(!job))
+		return NULL;
 
 	if (job->is_profiled && job->engine_usage) {
 		job->engine_usage->elapsed_ns[slot] +=
@@ -645,25 +646,18 @@ static void panfrost_jm_handle_irqs(struct panfrost_device *pfdev)
 	}
 }
 
-static u32 panfrost_active_slots(struct panfrost_device *pfdev,
-				 u32 *js_state_mask, u32 js_state)
+/* JOB_INT_JS_STATE is a snapshot: it can show a busy slot as idle. */
+static bool panfrost_slots_idle(struct panfrost_device *pfdev)
 {
-	u32 rawstat;
-
-	if (!(js_state & *js_state_mask))
-		return 0;
-
-	rawstat = job_read(pfdev, JOB_INT_RAWSTAT);
-	if (rawstat) {
-		unsigned int i;
+	unsigned int i;
 
-		for (i = 0; i < NUM_JOB_SLOTS; i++) {
-			if (rawstat & MK_JS_MASK(i))
-				*js_state_mask &= ~MK_JS_MASK(i);
-		}
+	for (i = 0; i < NUM_JOB_SLOTS; i++) {
+		if (job_read(pfdev, JS_STATUS(i)) ==
+		    DRM_PANFROST_EXCEPTION_ACTIVE)
+			return false;
 	}
 
-	return js_state & *js_state_mask;
+	return true;
 }
 
 static void
@@ -671,9 +665,8 @@ panfrost_reset(struct panfrost_device *pfdev,
 	       struct drm_sched_job *bad)
 {
 	struct panfrost_job *evicted[NUM_JOB_SLOTS] = {};
-	u32 js_state, js_state_mask = 0xffffffff;
 	unsigned int i, j;
-	bool cookie;
+	bool cookie, idle;
 	int ret;
 
 	if (!atomic_read(&pfdev->reset.pending))
@@ -724,9 +717,8 @@ panfrost_reset(struct panfrost_device *pfdev,
 	spin_unlock(&pfdev->js->job_lock);
 
 	/* Wait at most 10ms for soft-stops to complete */
-	ret = readl_poll_timeout(pfdev->iomem + JOB_INT_JS_STATE, js_state,
-				 !panfrost_active_slots(pfdev, &js_state_mask, js_state),
-				 10, 10000);
+	ret = read_poll_timeout(panfrost_slots_idle, idle, idle, 10, 10000,
+				false, pfdev);
 
 	if (ret)
 		dev_err(pfdev->base.dev, "Soft-stop failed\n");

-- 
2.55.0



  parent reply	other threads:[~2026-11-28 17:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 17:26 [PATCH v5 00/17] drm/panfrost: Resume long jobs instead of resetting, and mapping error path fixes Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 01/17] drm/panfrost: Freeze the reset workqueue during system sleep Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 02/17] drm/panfrost: Power the GPU up for a reset queued from the MMU code Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 03/17] drm/panfrost: Refuse to sync the CPU caches of a heap BO Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 04/17] drm/panfrost: Don't take a reference on a mapping that is being freed Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 05/17] drm/panfrost: Don't WARN when a GEM mapping cannot get its pages Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 06/17] drm/panfrost: Unwind a failed GPU mapping without dropping " Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 07/17] drm/panfrost: Give back the pages of a heap chunk that failed to map Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 08/17] drm/panfrost: Don't WARN for a heap folio a neighbouring chunk filled Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 09/17] drm/panfrost: Don't signal a job cancelled from _NEXT at a reset as done Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 10/17] drm/panfrost: Don't cancel a job that completed during a reset Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 11/17] drm/panfrost: Drop the cycle counter only for a job that holds it Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 12/17] drm/panfrost: Don't take a job that was never started for done Arun Iyengar via B4 Relay
2026-11-28 17:26 ` Arun Iyengar via B4 Relay [this message]
2026-11-28 17:26 ` [PATCH v5 14/17] drm/panfrost: Keep the GPU powered in the job timeout handler Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 15/17] drm/panfrost: Keep the job interrupts masked during a reset Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 16/17] drm/panfrost: Soft-stop and resume a job that outlives the timeout Arun Iyengar via B4 Relay
2026-11-28 17:26 ` [PATCH v5 17/17] drm/panfrost: Name the BOs around an unhandled page fault Arun Iyengar via B4 Relay

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=20261128-panfrost-long-jobs-v5-13-e7d62045a676@gmail.com \
    --to=devnull+aiyengar1990.gmail.com@kernel.org \
    --cc=adrian.larumbe@collabora.com \
    --cc=airlied@gmail.com \
    --cc=aiyengar1990@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=robh@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --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

all inboxes | Powered by JetHome®