From: Md Shofiqul Islam <shofiqtest@gmail.com>
To: mamin506@gmail.com
Cc: lizhi.hou@amd.com, dri-devel@lists.freedesktop.org,
Md Shofiqul Islam <shofiqtest@gmail.com>
Subject: [PATCH] drm/accel/amdxdna: add debugfs support
Date: Tue, 19 May 2026 23:32:36 +0300 [thread overview]
Message-ID: <20260519203236.252068-1-shofiqtest@gmail.com> (raw)
Expose driver state through debugfs to aid debugging and development.
Three read-only entries are created under /sys/kernel/debug/accel/<N>/:
- fw_version: firmware version as major.minor.sub.build
- device_info: device VBNV string and device type identifier
- clients: per-fd info (pid, heap usage, total BO usage)
Resolves the TODO item in drivers/accel/amdxdna/TODO.
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
drivers/accel/amdxdna/Makefile | 1 +
drivers/accel/amdxdna/amdxdna_debugfs.c | 63 +++++++++++++++++++++++++
drivers/accel/amdxdna/amdxdna_debugfs.h | 17 +++++++
drivers/accel/amdxdna/amdxdna_pci_drv.c | 3 ++
4 files changed, 84 insertions(+)
create mode 100644 drivers/accel/amdxdna/amdxdna_debugfs.c
create mode 100644 drivers/accel/amdxdna/amdxdna_debugfs.h
diff --git a/drivers/accel/amdxdna/Makefile b/drivers/accel/amdxdna/Makefile
index cf9bf19de..01a809d88 100644
--- a/drivers/accel/amdxdna/Makefile
+++ b/drivers/accel/amdxdna/Makefile
@@ -10,6 +10,7 @@ amdxdna-y := \
aie2_smu.o \
aie2_solver.o \
amdxdna_ctx.o \
+ amdxdna_debugfs.o \
amdxdna_gem.o \
amdxdna_iommu.o \
amdxdna_mailbox.o \
diff --git a/drivers/accel/amdxdna/amdxdna_debugfs.c b/drivers/accel/amdxdna/amdxdna_debugfs.c
new file mode 100644
index 000000000..6806698c3
--- /dev/null
+++ b/drivers/accel/amdxdna/amdxdna_debugfs.c
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2024, Advanced Micro Devices, Inc.
+ */
+
+#include <drm/drm_debugfs.h>
+#include <drm/drm_device.h>
+
+#include "amdxdna_debugfs.h"
+#include "amdxdna_pci_drv.h"
+
+static inline struct amdxdna_dev *seq_to_xdna(struct seq_file *s)
+{
+ struct drm_debugfs_entry *entry = s->private;
+
+ return to_xdna_dev(entry->dev);
+}
+
+static int fw_version_show(struct seq_file *s, void *v)
+{
+ struct amdxdna_dev *xdna = seq_to_xdna(s);
+
+ seq_printf(s, "%d.%d.%d.%d\n",
+ xdna->fw_ver.major, xdna->fw_ver.minor,
+ xdna->fw_ver.sub, xdna->fw_ver.build);
+ return 0;
+}
+
+static int device_info_show(struct seq_file *s, void *v)
+{
+ struct amdxdna_dev *xdna = seq_to_xdna(s);
+
+ seq_printf(s, "vbnv: %s\n", xdna->dev_info->vbnv);
+ seq_printf(s, "device_type: %d\n", xdna->dev_info->device_type);
+ return 0;
+}
+
+static int clients_show(struct seq_file *s, void *v)
+{
+ struct amdxdna_dev *xdna = seq_to_xdna(s);
+ struct amdxdna_client *client;
+
+ mutex_lock(&xdna->dev_lock);
+ list_for_each_entry(client, &xdna->client_list, node)
+ seq_printf(s, "pid %d heap_usage %zu total_bo_usage %zu\n",
+ client->pid, client->heap_usage,
+ client->total_bo_usage);
+ mutex_unlock(&xdna->dev_lock);
+
+ return 0;
+}
+
+static const struct drm_debugfs_info amdxdna_debugfs_list[] = {
+ { "fw_version", fw_version_show, 0 },
+ { "device_info", device_info_show, 0 },
+ { "clients", clients_show, 0 },
+};
+
+void amdxdna_debugfs_init(struct amdxdna_dev *xdna)
+{
+ drm_debugfs_add_files(&xdna->ddev, amdxdna_debugfs_list,
+ ARRAY_SIZE(amdxdna_debugfs_list));
+}
diff --git a/drivers/accel/amdxdna/amdxdna_debugfs.h b/drivers/accel/amdxdna/amdxdna_debugfs.h
new file mode 100644
index 000000000..e742a81fe
--- /dev/null
+++ b/drivers/accel/amdxdna/amdxdna_debugfs.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2024, Advanced Micro Devices, Inc.
+ */
+
+#ifndef _AMDXDNA_DEBUGFS_H_
+#define _AMDXDNA_DEBUGFS_H_
+
+struct amdxdna_dev;
+
+#ifdef CONFIG_DEBUG_FS
+void amdxdna_debugfs_init(struct amdxdna_dev *xdna);
+#else
+static inline void amdxdna_debugfs_init(struct amdxdna_dev *xdna) {}
+#endif
+
+#endif /* _AMDXDNA_DEBUGFS_H_ */
diff --git a/drivers/accel/amdxdna/amdxdna_pci_drv.c b/drivers/accel/amdxdna/amdxdna_pci_drv.c
index b50a7d1f8..19866dbed 100644
--- a/drivers/accel/amdxdna/amdxdna_pci_drv.c
+++ b/drivers/accel/amdxdna/amdxdna_pci_drv.c
@@ -15,6 +15,7 @@
#include <linux/pci.h>
#include "amdxdna_ctx.h"
+#include "amdxdna_debugfs.h"
#include "amdxdna_gem.h"
#include "amdxdna_pci_drv.h"
#include "amdxdna_pm.h"
@@ -319,6 +320,8 @@ static int amdxdna_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto failed_sysfs_fini;
}
+ amdxdna_debugfs_init(xdna);
+
return 0;
failed_sysfs_fini:
--
2.51.1
next reply other threads:[~2026-05-20 7:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 20:32 Md Shofiqul Islam [this message]
2026-05-21 17:34 ` [PATCH] drm/accel/amdxdna: add debugfs support Lizhi Hou
2026-05-25 12:09 ` Claude review: " Claude Code Review Bot
2026-05-25 12:09 ` 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=20260519203236.252068-1-shofiqtest@gmail.com \
--to=shofiqtest@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=lizhi.hou@amd.com \
--cc=mamin506@gmail.com \
/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