All of lore.kernel.org
 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 4/9] drm/panthor: capture CSG state for devcoredump
Date: Sat, 19 Jul 2025 17:01:41 -0700	[thread overview]
Message-ID: <20250720000146.1405060-5-olvaffe@gmail.com> (raw)
In-Reply-To: <20250720000146.1405060-1-olvaffe@gmail.com>

Capture interesting panthor_fw_csg_iface fields for devcoredump.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
---
 drivers/gpu/drm/panthor/panthor_coredump.c | 58 ++++++++++++++++++++++
 drivers/gpu/drm/panthor/panthor_coredump.h | 23 +++++++++
 drivers/gpu/drm/panthor/panthor_sched.c    | 13 +++++
 3 files changed, 94 insertions(+)

diff --git a/drivers/gpu/drm/panthor/panthor_coredump.c b/drivers/gpu/drm/panthor/panthor_coredump.c
index 44d711e2f310..e08bd33b3554 100644
--- a/drivers/gpu/drm/panthor/panthor_coredump.c
+++ b/drivers/gpu/drm/panthor/panthor_coredump.c
@@ -24,6 +24,7 @@ enum panthor_coredump_mask {
 	PANTHOR_COREDUMP_GROUP = BIT(0),
 	PANTHOR_COREDUMP_GPU = BIT(1),
 	PANTHOR_COREDUMP_GLB = BIT(2),
+	PANTHOR_COREDUMP_CSG = BIT(3),
 };
 
 /**
@@ -53,6 +54,7 @@ struct panthor_coredump {
 	struct panthor_coredump_group_state group;
 	struct panthor_coredump_gpu_state gpu;
 	struct panthor_coredump_glb_state glb;
+	struct panthor_coredump_csg_state csg;
 
 	/* @data: Serialized coredump data. */
 	void *data;
@@ -85,6 +87,28 @@ static const char *reason_str(enum panthor_coredump_reason reason)
 	}
 }
 
+static void print_csg(struct drm_printer *p,
+		      const struct panthor_coredump_csg_state *csg, u32 csg_id)
+{
+	drm_printf(p, "csg%d:\n", csg_id);
+	drm_printf(p, "  GROUP_FEATURES: 0x%x\n", csg->features);
+	drm_printf(p, "  GROUP_STREAM_NUM: 0x%x\n", csg->stream_num);
+
+	drm_printf(p, "  CSG_REQ: 0x%x\n", csg->req);
+	drm_printf(p, "  CSG_ALLOW_COMPUTE: 0x%llx\n", csg->allow_compute);
+	drm_printf(p, "  CSG_ALLOW_FRAGMENT: 0x%llx\n", csg->allow_fragment);
+	drm_printf(p, "  CSG_ALLOW_OTHER: 0x%x\n", csg->allow_other);
+	drm_printf(p, "  CSG_EP_REQ: 0x%x\n", csg->ep_req);
+	drm_printf(p, "  CSG_CONFIG: 0x%x\n", csg->config);
+
+	drm_printf(p, "  CSG_ACK: 0x%x\n", csg->ack);
+	drm_printf(p, "  CSG_STATUS_EP_CURRENT: 0x%x\n",
+		   csg->status_ep_current);
+	drm_printf(p, "  CSG_STATUS_EP_REQ: 0x%x\n", csg->status_ep_req);
+	drm_printf(p, "  CSG_STATUS_STATE: 0x%x\n", csg->status_state);
+	drm_printf(p, "  CSG_RESOURCE_DEP: 0x%x\n", csg->resource_dep);
+}
+
 static void print_glb(struct drm_printer *p,
 		      const struct panthor_coredump_glb_state *glb)
 {
@@ -193,6 +217,10 @@ static void print_cd(struct drm_printer *p, const struct panthor_coredump *cd)
 
 	if (cd->mask & PANTHOR_COREDUMP_GLB)
 		print_glb(p, &cd->glb);
+
+	if (cd->mask & PANTHOR_COREDUMP_CSG) {
+		print_csg(p, &cd->csg, cd->group.csg_id);
+	}
 }
 
 static void process_cd(struct panthor_device *ptdev,
@@ -219,6 +247,29 @@ static void process_cd(struct panthor_device *ptdev,
 	print_cd(&p, cd);
 }
 
+static void capture_csg(struct panthor_device *ptdev,
+			struct panthor_coredump_csg_state *csg, u32 csg_id)
+{
+	const struct panthor_fw_csg_iface *csg_iface =
+		panthor_fw_get_csg_iface(ptdev, csg_id);
+
+	csg->features = csg_iface->control->features;
+	csg->stream_num = csg_iface->control->stream_num;
+
+	csg->req = csg_iface->input->req;
+	csg->allow_compute = csg_iface->input->allow_compute;
+	csg->allow_fragment = csg_iface->input->allow_fragment;
+	csg->allow_other = csg_iface->input->allow_other;
+	csg->ep_req = csg_iface->input->endpoint_req;
+	csg->config = csg_iface->input->config;
+
+	csg->ack = csg_iface->output->ack;
+	csg->status_ep_current = csg_iface->output->status_endpoint_current;
+	csg->status_ep_req = csg_iface->output->status_endpoint_req;
+	csg->status_state = csg_iface->output->status_state;
+	csg->resource_dep = csg_iface->output->resource_dep;
+}
+
 static void capture_glb(struct panthor_device *ptdev,
 			struct panthor_coredump_glb_state *glb)
 {
@@ -264,6 +315,13 @@ static void capture_cd(struct panthor_device *ptdev,
 
 	capture_glb(ptdev, &cd->glb);
 	cd->mask |= PANTHOR_COREDUMP_GLB;
+
+	/* remaining states require an active group */
+	if (!group || cd->group.csg_id < 0)
+		return;
+
+	capture_csg(ptdev, &cd->csg, cd->group.csg_id);
+	cd->mask |= PANTHOR_COREDUMP_CSG;
 }
 
 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 e578298e9b57..d965ebc545d3 100644
--- a/drivers/gpu/drm/panthor/panthor_coredump.h
+++ b/drivers/gpu/drm/panthor/panthor_coredump.h
@@ -69,6 +69,29 @@ struct panthor_coredump_glb_state {
 	u32 ack;
 };
 
+/**
+ * struct panthor_coredump_csg_state - Coredump CSG state
+ *
+ * Interesting panthor_fw_csg_iface fields.
+ */
+struct panthor_coredump_csg_state {
+	u32 features;
+	u32 stream_num;
+
+	u32 req;
+	u64 allow_compute;
+	u64 allow_fragment;
+	u32 allow_other;
+	u32 ep_req;
+	u32 config;
+
+	u32 ack;
+	u32 status_ep_current;
+	u32 status_ep_req;
+	u32 status_state;
+	u32 resource_dep;
+};
+
 #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 a9fd71fa984b..504fc097ebfe 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.c
+++ b/drivers/gpu/drm/panthor/panthor_sched.c
@@ -3681,6 +3681,19 @@ static void panthor_sched_coredump_locked(struct panthor_device *ptdev,
 
 	pm_active = pm_runtime_get_if_active(ptdev->base.dev);
 
+	/* force a CSG_STATUS_UPDATE */
+	if (pm_active && group && group->csg_id >= 0) {
+		struct panthor_fw_csg_iface *csg_iface;
+		u32 acked;
+
+		csg_iface = panthor_fw_get_csg_iface(ptdev, group->csg_id);
+
+		panthor_fw_toggle_reqs(csg_iface, req, ack, CSG_STATUS_UPDATE);
+		panthor_fw_ring_csg_doorbells(ptdev, BIT(group->csg_id));
+		panthor_fw_csg_wait_acks(ptdev, group->csg_id,
+					 CSG_STATUS_UPDATE, &acked, 100);
+	}
+
 	panthor_coredump_capture(cd, group);
 
 	if (pm_active == 1)
-- 
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 ` Chia-I Wu [this message]
2025-07-20  0:01 ` [PATCH 5/9] drm/panthor: capture CS " Chia-I Wu
2025-07-20  0:01 ` [PATCH 6/9] drm/panthor: capture AS " Chia-I Wu
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-5-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.