dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Chia-I Wu <olvaffe@gmail.com>
To: Boris Brezillon <boris.brezillon@collabora.com>,
	Steven Price <steven.price@arm.com>,
	Liviu Dudau <liviu.dudau@arm.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>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 6/9] drm/panthor: capture AS state for devcoredump
Date: Sat, 19 Jul 2025 17:01:43 -0700	[thread overview]
Message-ID: <20250720000146.1405060-7-olvaffe@gmail.com> (raw)
In-Reply-To: <20250720000146.1405060-1-olvaffe@gmail.com>

Capture interesting MMU_AS_CONTROL regs for devcoredump.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
---
 drivers/gpu/drm/panthor/panthor_coredump.c | 33 ++++++++++++++++++++++
 drivers/gpu/drm/panthor/panthor_coredump.h | 11 ++++++++
 drivers/gpu/drm/panthor/panthor_sched.c    |  5 ++++
 drivers/gpu/drm/panthor/panthor_sched.h    |  2 ++
 4 files changed, 51 insertions(+)

diff --git a/drivers/gpu/drm/panthor/panthor_coredump.c b/drivers/gpu/drm/panthor/panthor_coredump.c
index 60d651a8468a..acc8ad4cc498 100644
--- a/drivers/gpu/drm/panthor/panthor_coredump.c
+++ b/drivers/gpu/drm/panthor/panthor_coredump.c
@@ -14,6 +14,7 @@
 #include "panthor_coredump.h"
 #include "panthor_device.h"
 #include "panthor_fw.h"
+#include "panthor_mmu.h"
 #include "panthor_regs.h"
 #include "panthor_sched.h"
 
@@ -26,6 +27,7 @@ enum panthor_coredump_mask {
 	PANTHOR_COREDUMP_GLB = BIT(2),
 	PANTHOR_COREDUMP_CSG = BIT(3),
 	PANTHOR_COREDUMP_CS = BIT(4),
+	PANTHOR_COREDUMP_AS = BIT(5),
 };
 
 /**
@@ -57,6 +59,7 @@ struct panthor_coredump {
 	struct panthor_coredump_glb_state glb;
 	struct panthor_coredump_csg_state csg;
 	struct panthor_coredump_cs_state cs[MAX_CS_PER_CSG];
+	struct panthor_coredump_as_state as;
 
 	/* @data: Serialized coredump data. */
 	void *data;
@@ -89,6 +92,15 @@ static const char *reason_str(enum panthor_coredump_reason reason)
 	}
 }
 
+static void print_as(struct drm_printer *p,
+		     const struct panthor_coredump_as_state *as, u32 as_id)
+{
+	drm_printf(p, "as%d:\n", as_id);
+	drm_printf(p, "  FAULTSTATUS: 0x%x\n", as->faultstatus);
+	drm_printf(p, "  FAULTADDRESS: 0x%llx\n", as->faultaddress);
+	drm_printf(p, "  FAULTEXTRA: 0x%llx\n", as->faultextra);
+}
+
 static void print_cs(struct drm_printer *p,
 		     const struct panthor_coredump_cs_state *cs, u32 cs_id)
 {
@@ -259,6 +271,12 @@ static void print_cd(struct drm_printer *p, const struct panthor_coredump *cd)
 		for (u32 i = 0; i < cd->group.queue_count; i++)
 			print_cs(p, &cd->cs[i], i);
 	}
+
+	if (cd->mask & PANTHOR_COREDUMP_AS) {
+		const u32 as_id = cd->csg.config & 0xf;
+
+		print_as(p, &cd->as, as_id);
+	}
 }
 
 static void process_cd(struct panthor_device *ptdev,
@@ -285,6 +303,14 @@ static void process_cd(struct panthor_device *ptdev,
 	print_cd(&p, cd);
 }
 
+static void capture_as(struct panthor_device *ptdev,
+		       struct panthor_coredump_as_state *as, u32 as_id)
+{
+	as->faultstatus = gpu_read(ptdev, AS_FAULTSTATUS(as_id));
+	as->faultaddress = gpu_read64(ptdev, AS_FAULTADDRESS(as_id));
+	as->faultextra = gpu_read64(ptdev, AS_FAULTEXTRA(as_id));
+}
+
 static void capture_cs(struct panthor_device *ptdev,
 		       struct panthor_coredump_cs_state *cs, u32 csg_id,
 		       u32 cs_id, const struct panthor_group *group)
@@ -374,6 +400,8 @@ static void capture_gpu(struct panthor_device *ptdev,
 static void capture_cd(struct panthor_device *ptdev,
 		       struct panthor_coredump *cd, struct panthor_group *group)
 {
+	struct panthor_vm *vm;
+
 	drm_info(&ptdev->base, "capturing coredump states\n");
 
 	if (group) {
@@ -401,6 +429,11 @@ static void capture_cd(struct panthor_device *ptdev,
 	for (u32 i = 0; i < cd->group.queue_count; i++)
 		capture_cs(ptdev, &cd->cs[i], cd->group.csg_id, i, group);
 	cd->mask |= PANTHOR_COREDUMP_CS;
+
+	vm = panthor_group_vm(group);
+
+	capture_as(ptdev, &cd->as, panthor_vm_as(vm));
+	cd->mask |= PANTHOR_COREDUMP_AS;
 }
 
 static void panthor_coredump_free(void *data)
diff --git a/drivers/gpu/drm/panthor/panthor_coredump.h b/drivers/gpu/drm/panthor/panthor_coredump.h
index 44402c6142cb..8aceb0c7d0d4 100644
--- a/drivers/gpu/drm/panthor/panthor_coredump.h
+++ b/drivers/gpu/drm/panthor/panthor_coredump.h
@@ -124,6 +124,17 @@ struct panthor_coredump_cs_state {
 	u32 active;
 };
 
+/**
+ * struct panthor_coredump_as_state - Coredump AS state
+ *
+ * Interesting MMU_AS_CONTROL regs.
+ */
+struct panthor_coredump_as_state {
+	u32 faultstatus;
+	u64 faultaddress;
+	u64 faultextra;
+};
+
 #ifdef CONFIG_DEV_COREDUMP
 
 struct panthor_coredump *
diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
index 4bc31c5f667d..82e43b7ca7aa 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.c
+++ b/drivers/gpu/drm/panthor/panthor_sched.c
@@ -3726,6 +3726,11 @@ void panthor_group_get_ringbuf_iface(
 	*output_iface = queue->iface.output;
 }
 
+struct panthor_vm *panthor_group_vm(struct panthor_group *group)
+{
+	return group->vm;
+}
+
 int panthor_group_pool_create(struct panthor_file *pfile)
 {
 	struct panthor_group_pool *gpool;
diff --git a/drivers/gpu/drm/panthor/panthor_sched.h b/drivers/gpu/drm/panthor/panthor_sched.h
index 284ba39f958a..0cb58212fd44 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.h
+++ b/drivers/gpu/drm/panthor/panthor_sched.h
@@ -38,6 +38,8 @@ void panthor_group_get_ringbuf_iface(
 	const struct panthor_fw_ringbuf_input_iface **input_iface,
 	const struct panthor_fw_ringbuf_output_iface **output_iface);
 
+struct panthor_vm *panthor_group_vm(struct panthor_group *group);
+
 struct drm_sched_job *
 panthor_job_create(struct panthor_file *pfile,
 		   u16 group_handle,
-- 
2.50.0.727.gbf7dc18ff4-goog


  parent reply	other threads:[~2025-07-20  0:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-20  0:01 [PATCH 0/9] drm/panthor: add devcoredump support Chia-I Wu
2025-07-20  0:01 ` [PATCH 1/9] " Chia-I Wu
2025-07-20  3:17   ` kernel test robot
2025-07-28 11:24   ` Steven Price
2025-08-21  8:16     ` Boris Brezillon
2025-07-20  0:01 ` [PATCH 2/9] drm/panthor: capture GPU state for devcoredump Chia-I Wu
2025-07-20  4:29   ` kernel test robot
2025-07-20  0:01 ` [PATCH 3/9] drm/panthor: capture GLB " Chia-I Wu
2025-07-20  5:41   ` kernel test robot
2025-07-20  0:01 ` [PATCH 4/9] drm/panthor: capture CSG " Chia-I Wu
2025-07-20  0:01 ` [PATCH 5/9] drm/panthor: capture CS " Chia-I Wu
2025-07-20  0:01 ` Chia-I Wu [this message]
2025-07-20  0:01 ` [PATCH 7/9] drm/panthor: capture VMA " Chia-I Wu
2025-07-20  0:01 ` [PATCH 8/9] drm/panthor: check bo offset alignment in vm bind Chia-I Wu
2025-08-21  7:33   ` Boris Brezillon
2025-07-20  0:01 ` [PATCH 9/9] drm/panthor: add DRM_PANTHOR_VM_BIND_OP_MAP_DUMPABLE Chia-I Wu
2025-08-21  7:55   ` Boris Brezillon
2025-07-20  0:41 ` [PATCH 0/9] drm/panthor: add devcoredump support Daniel Almeida
2025-07-20  1:13   ` Chia-I Wu

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=20250720000146.1405060-7-olvaffe@gmail.com \
    --to=olvaffe@gmail.com \
    --cc=airlied@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@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;
as well as URLs for NNTP newsgroup(s).