mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wei Huang <wei.huang2@amd.com>
To: <dmaengine@vger.kernel.org>
Cc: <vkoul@kernel.org>, <Frank.Li@kernel.org>, <shuah@kernel.org>,
	<nathan.lynch@amd.com>, <wei.huang2@amd.com>,
	<mario.limonciello@amd.com>, <Stephen.Bates@amd.com>,
	<tycho@kernel.org>, <suravee.suthikulpanit@amd.com>,
	<rientjes@google.com>, <John.Kariuki@amd.com>, <jic23@kernel.org>,
	<weixugc@google.com>, <bhelgaas@google.com>,
	<Shyam.Iyer@dell.com>, <linux-kernel@vger.kernel.org>,
	<linux-kselftest@vger.kernel.org>, <linux-pci@vger.kernel.org>
Subject: [PATCH v1 26/44] dmaengine: sdxi: add SDXI trace events
Date: Thu, 19 Nov 2026 14:23:02 -0600	[thread overview]
Message-ID: <20261119202321.1734355-27-wei.huang2@amd.com> (raw)
In-Reply-To: <20261119202321.1734355-1-wei.huang2@amd.com>

Add trace events for context and submission queue creation and
destruction, along with process SVA bind and unbind operations. Insert
the trace points into the corresponding call sites in SDXI driver.

Co-developed-by: Nathan Lynch <nathan.lynch@amd.com>
Signed-off-by: Nathan Lynch <nathan.lynch@amd.com>
Signed-off-by: Wei Huang <wei.huang2@amd.com>
---
 drivers/dma/sdxi/Makefile  |   1 +
 drivers/dma/sdxi/context.c |  31 ++++++---
 drivers/dma/sdxi/process.c |   6 +-
 drivers/dma/sdxi/trace.c   |   9 +++
 drivers/dma/sdxi/trace.h   | 137 +++++++++++++++++++++++++++++++++++++
 5 files changed, 173 insertions(+), 11 deletions(-)
 create mode 100644 drivers/dma/sdxi/trace.c
 create mode 100644 drivers/dma/sdxi/trace.h

diff --git a/drivers/dma/sdxi/Makefile b/drivers/dma/sdxi/Makefile
index 019038cc91bc..34f62b7366eb 100644
--- a/drivers/dma/sdxi/Makefile
+++ b/drivers/dma/sdxi/Makefile
@@ -14,6 +14,7 @@ sdxi-core-y := \
 	process.o     \
 	ring.o        \
 	sysfs.o       \
+	trace.o       \
 	vendor.o
 
 obj-$(CONFIG_SDXI_PCI) += sdxi-pci.o
diff --git a/drivers/dma/sdxi/context.c b/drivers/dma/sdxi/context.c
index 43ffe132cf2e..91c2837bbe82 100644
--- a/drivers/dma/sdxi/context.c
+++ b/drivers/dma/sdxi/context.c
@@ -36,6 +36,7 @@
 #include "ring.h"
 #include "sdxi.h"
 #include "submission.h"
+#include "trace.h"
 
 #define DEFAULT_DESC_RING_ENTRIES 1024
 #define SDXI_CXT_QUIESCE_TIMEOUT_MS 5000U
@@ -50,6 +51,16 @@ enum {
 
 static void sdxi_cxt_cleanup_workfn(struct work_struct *work);
 
+static void sdxi_cxt_free_sq(struct sdxi_cxt *cxt)
+{
+	if (!cxt->sq)
+		return;
+
+	trace_sdxi_free_sq(cxt, cxt->sq);
+	sdxi_sq_free(cxt->sdxi, cxt->sq);
+	cxt->sq = NULL;
+}
+
 /*
  * Free context and its resources. @cxt may be partially allocated but
  * must have ->sdxi set.
@@ -70,8 +81,7 @@ static void sdxi_free_cxt(struct sdxi_cxt *cxt)
 				  cxt->akey_table, cxt->akey_table_dma);
 	if (cxt->cst_pool)
 		sdxi_cst_pool_destroy(sdxi, cxt->cst_pool);
-	if (cxt->sq)
-		sdxi_sq_free(sdxi, cxt->sq);
+	sdxi_cxt_free_sq(cxt);
 	ida_destroy(&cxt->akey_ida);
 	mutex_destroy(&cxt->akey_lock);
 	mutex_destroy(&cxt->cleanup_lock);
@@ -205,6 +215,7 @@ static int sdxi_alloc_kernel_submission(struct sdxi_cxt *cxt)
 	cxt->sq = sdxi_sq_alloc(cxt->sdxi, DEFAULT_DESC_RING_ENTRIES);
 	if (!cxt->sq)
 		return -ENOMEM;
+	trace_sdxi_create_sq(cxt, cxt->sq);
 
 	cxt->cst_pool = sdxi_cst_pool_create(cxt->sdxi,
 					     DEFAULT_DESC_RING_ENTRIES);
@@ -434,11 +445,13 @@ static int sdxi_publish_cxt(struct sdxi_cxt *cxt,
 	mutex_unlock(&cxt->sdxi->cxt_lock);
 	if (err) {
 		invalidate_cxt_ctl(cxt->cxt_ctl);
-	} else {
-		cxt->published = true;
-		cxt->update_pending = false;
+		return err;
 	}
-	return err;
+
+	cxt->published = true;
+	cxt->update_pending = false;
+	trace_sdxi_create_cxt(cxt->sdxi, cxt);
+	return 0;
 }
 
 /* Invalidate a context. */
@@ -451,6 +464,7 @@ static void sdxi_rescind_cxt(struct sdxi_cxt *cxt)
 
 	if (!cxt->published)
 		return;
+	trace_sdxi_free_cxt(sdxi, cxt);
 
 	mutex_lock(&sdxi->cxt_lock);
 	L1_table = sdxi->L1_tables[l2_idx];
@@ -575,10 +589,7 @@ static void sdxi_cxt_release_resources(struct sdxi_cxt *cxt)
 		sdxi_cst_pool_destroy(sdxi, cxt->cst_pool);
 		cxt->cst_pool = NULL;
 	}
-	if (cxt->sq) {
-		sdxi_sq_free(sdxi, cxt->sq);
-		cxt->sq = NULL;
-	}
+	sdxi_cxt_free_sq(cxt);
 	kfree(cxt->ring_state);
 	cxt->ring_state = NULL;
 }
diff --git a/drivers/dma/sdxi/process.c b/drivers/dma/sdxi/process.c
index b64f2307e4e3..31847af18e83 100644
--- a/drivers/dma/sdxi/process.c
+++ b/drivers/dma/sdxi/process.c
@@ -14,6 +14,7 @@
 #include "context.h"
 #include "process.h"
 #include "sdxi.h"
+#include "trace.h"
 
 static void sdxi_process_cleanup(struct sdxi_process *process)
 {
@@ -95,8 +96,10 @@ void sdxi_process_unbind_sva(struct sdxi_process *process,
 		mmu_notifier_unregister(&process->notifier, process->mm);
 	}
 
-	if (sva)
+	if (sva) {
 		iommu_sva_unbind_device(sva);
+		trace_sdxi_unbind_process(process->sdxi, pasid);
+	}
 }
 
 static void sdxi_process_free(struct sdxi_process *process)
@@ -157,6 +160,7 @@ int sdxi_process_bind(struct sdxi_process *process)
 
 	process->pasid = pasid;
 	process->sva = sva;
+	trace_sdxi_bind_process(process->sdxi, pasid);
 	return 0;
 
 unbind:
diff --git a/drivers/dma/sdxi/trace.c b/drivers/dma/sdxi/trace.c
new file mode 100644
index 000000000000..8fcde4538c94
--- /dev/null
+++ b/drivers/dma/sdxi/trace.c
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * SDXI tracepoints.
+ *
+ * Copyright Advanced Micro Devices, Inc.
+ */
+
+#define CREATE_TRACE_POINTS
+#include "trace.h"
diff --git a/drivers/dma/sdxi/trace.h b/drivers/dma/sdxi/trace.h
new file mode 100644
index 000000000000..e39db0e3debd
--- /dev/null
+++ b/drivers/dma/sdxi/trace.h
@@ -0,0 +1,137 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * SDXI tracepoints.
+ *
+ * Copyright Advanced Micro Devices, Inc.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM sdxi
+
+#if !defined(_TRACE_SDXI_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SDXI_H
+
+#include <linux/tracepoint.h>
+
+#include "context.h"
+
+TRACE_EVENT(sdxi_create_cxt,
+	    TP_PROTO(struct sdxi_dev *sdxi, struct sdxi_cxt *cxt),
+	    TP_ARGS(sdxi, cxt),
+	    TP_STRUCT__entry(
+		    __field(u16, sfunc)
+		    __field(unsigned int, cxt_id)
+		    __field(void *, cce)
+		    __field(u64, cce_dma_addr)
+		    __field(void *, akey)
+		    __field(u64, akey_dma_addr)
+	    ),
+	    TP_fast_assign(
+		    __entry->sfunc = sdxi->sfunc;
+		    __entry->cxt_id = cxt->id;
+		    __entry->cce = cxt->cxt_ctl;
+		    __entry->cce_dma_addr = cxt->cxt_ctl_dma;
+		    __entry->akey = cxt->akey_table;
+		    __entry->akey_dma_addr = cxt->akey_table_dma;
+	    ),
+	    TP_printk("cxt=%u sfunc=%#x cxt_ctl=%p cxt_ctl_dma=%#llx akey=%p akey_dma=%#llx",
+		      __entry->cxt_id, __entry->sfunc, __entry->cce,
+		      __entry->cce_dma_addr, __entry->akey,
+		      __entry->akey_dma_addr)
+);
+
+TRACE_EVENT(sdxi_free_cxt,
+	    TP_PROTO(struct sdxi_dev *sdxi, struct sdxi_cxt *cxt),
+	    TP_ARGS(sdxi, cxt),
+	    TP_STRUCT__entry(
+		    __field(u16, sfunc)
+		    __field(unsigned int, cxt_id)
+	    ),
+	    TP_fast_assign(
+		    __entry->sfunc = sdxi->sfunc;
+		    __entry->cxt_id = cxt->id;
+	    ),
+	    TP_printk("cxt=%u sfunc=%#x", __entry->cxt_id, __entry->sfunc)
+);
+
+TRACE_EVENT(sdxi_create_sq,
+	    TP_PROTO(struct sdxi_cxt *cxt, struct sdxi_sq *sq),
+	    TP_ARGS(cxt, sq),
+	    TP_STRUCT__entry(
+		    __field(u16, sfunc)
+		    __field(unsigned int, cxt_id)
+		    __field(void *, desc_ring)
+		    __field(u64, desc_ring_addr)
+		    __field(void *, write_index)
+		    __field(u64, write_index_addr)
+		    __field(void *, cxt_status)
+		    __field(u64, cxt_status_addr)
+	    ),
+	    TP_fast_assign(
+		    __entry->sfunc = cxt->sdxi->sfunc;
+		    __entry->cxt_id = cxt->id;
+		    __entry->desc_ring = sq->ring;
+		    __entry->desc_ring_addr = sdxi_sq_ring_dma(sq);
+		    __entry->write_index = &sq->write_index;
+		    __entry->write_index_addr = sdxi_sq_write_index_dma(sq);
+		    __entry->cxt_status = &sq->cxt_sts;
+		    __entry->cxt_status_addr = sdxi_sq_cxt_sts_dma(sq);
+	    ),
+	    TP_printk("cxt=%u sfunc=%#x ring=%p/%#llx widx=%p/%#llx sts=%p/%#llx",
+		      __entry->cxt_id, __entry->sfunc, __entry->desc_ring,
+		      __entry->desc_ring_addr, __entry->write_index,
+		      __entry->write_index_addr, __entry->cxt_status,
+		      __entry->cxt_status_addr)
+);
+
+TRACE_EVENT(sdxi_free_sq,
+	    TP_PROTO(struct sdxi_cxt *cxt, struct sdxi_sq *sq),
+	    TP_ARGS(cxt, sq),
+	    TP_STRUCT__entry(
+		    __field(u16, sfunc)
+		    __field(unsigned int, cxt_id)
+	    ),
+	    TP_fast_assign(
+		    __entry->sfunc = cxt->sdxi->sfunc;
+		    __entry->cxt_id = cxt->id;
+	    ),
+	    TP_printk("cxt=%u sfunc=%#x", __entry->cxt_id, __entry->sfunc)
+);
+
+TRACE_EVENT(sdxi_bind_process,
+	    TP_PROTO(const struct sdxi_dev *sdxi, u32 pasid),
+	    TP_ARGS(sdxi, pasid),
+	    TP_STRUCT__entry(
+		    __string(devname, dev_name(sdxi_to_dev(sdxi)))
+		    __field(u32, pasid)
+	    ),
+	    TP_fast_assign(
+		    __assign_str(devname);
+		    __entry->pasid = pasid;
+	    ),
+	    TP_printk("device=%s pasid=%u", __get_str(devname), __entry->pasid)
+);
+
+TRACE_EVENT(sdxi_unbind_process,
+	    TP_PROTO(const struct sdxi_dev *sdxi, u32 pasid),
+	    TP_ARGS(sdxi, pasid),
+	    TP_STRUCT__entry(
+		    __string(devname, dev_name(sdxi_to_dev(sdxi)))
+		    __field(u32, pasid)
+	    ),
+	    TP_fast_assign(
+		    __assign_str(devname);
+		    __entry->pasid = pasid;
+	    ),
+	    TP_printk("device=%s pasid=%u", __get_str(devname), __entry->pasid)
+);
+
+#endif /* _TRACE_SDXI_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH ../../drivers/dma/sdxi
+
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE trace
+
+#include <trace/define_trace.h>
-- 
2.56.1


  parent reply	other threads:[~2026-11-19 20:29 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 20:22 [PATCH v1 00/44] dmaengine: sdxi: add userspace control and management support Wei Huang
2026-11-19 20:22 ` [PATCH v1 01/44] dmaengine: sdxi: cache hardware version for feature gating Wei Huang
2026-11-19 20:22 ` [PATCH v1 02/44] dmaengine: sdxi: define key and error MMIO registers Wei Huang
2026-11-19 20:22 ` [PATCH v1 03/44] dmaengine: sdxi: define SDXI hardware layouts Wei Huang
2026-11-19 20:22 ` [PATCH v1 04/44] dmaengine: sdxi: encode admin descriptors Wei Huang
2026-11-19 20:22 ` [PATCH v1 05/44] dmaengine: sdxi: support timeout-aware completion waits Wei Huang
2026-11-19 20:22 ` [PATCH v1 06/44] dmaengine: sdxi: support the full context table hierarchy Wei Huang
2026-11-19 20:22 ` [PATCH v1 07/44] dmaengine: sdxi: implement synchronous admin operations Wei Huang
2026-11-19 20:22 ` [PATCH v1 08/44] dmaengine: sdxi: add core RKey table management Wei Huang
2026-11-19 20:22 ` [PATCH v1 09/44] dmaengine: sdxi: handle hardware error logs Wei Huang
2026-11-19 20:22 ` [PATCH v1 10/44] dmaengine: sdxi: separate context and submission resources Wei Huang
2026-11-19 20:22 ` [PATCH v1 11/44] dmaengine: sdxi: support userspace context lifetimes Wei Huang
2026-11-19 20:22 ` [PATCH v1 12/44] dmaengine: sdxi: route context interrupts to eventfd Wei Huang
2026-11-19 20:22 ` [PATCH v1 13/44] dmaengine: sdxi: kill user contexts on fatal errors Wei Huang
2026-11-19 20:22 ` [PATCH v1 14/44] dmaengine: sdxi: define the ioctl UAPI surface Wei Huang
2026-11-19 20:22 ` [PATCH v1 15/44] dmaengine: sdxi: add internal ioctl definitions Wei Huang
2026-11-19 20:22 ` [PATCH v1 16/44] dmaengine: sdxi: register core character devices Wei Huang
2026-11-19 20:22 ` [PATCH v1 17/44] dmaengine: sdxi: implement fixed-size ioctl dispatch Wei Huang
2026-11-19 20:22 ` [PATCH v1 18/44] dmaengine: sdxi: implement userspace context file operations Wei Huang
2026-11-19 20:22 ` [PATCH v1 19/44] dmaengine: sdxi: validate and copy key ioctl payloads Wei Huang
2026-11-19 20:22 ` [PATCH v1 20/44] dmaengine: sdxi: implement RKey management ioctls Wei Huang
2026-11-19 20:22 ` [PATCH v1 21/44] dmaengine: sdxi: implement AKey " Wei Huang
2026-11-19 20:22 ` [PATCH v1 22/44] dmaengine: sdxi: expose operation-group discovery Wei Huang
2026-11-19 20:22 ` [PATCH v1 23/44] dmaengine: sdxi: implement typed vendor admin transport Wei Huang
2026-11-19 20:23 ` [PATCH v1 24/44] dmaengine: sdxi: expose character device attributes Wei Huang
2026-11-19 20:23 ` [PATCH v1 25/44] dmaengine: sdxi: add PF and VF device naming Wei Huang
2026-11-19 20:23 ` Wei Huang [this message]
2026-11-19 20:23 ` [PATCH v1 27/44] dmaengine: sdxi: support suspend and resume Wei Huang
2026-11-19 20:23 ` [PATCH v1 28/44] dmaengine: sdxi: amd: define QoS request formats Wei Huang
2026-11-19 20:23 ` [PATCH v1 29/44] dmaengine: sdxi: amd: add QoS validation scaffolding Wei Huang
2026-11-19 20:23 ` [PATCH v1 30/44] dmaengine: sdxi: amd: build QoS admin descriptors Wei Huang
2026-11-19 20:23 ` [PATCH v1 31/44] dmaengine: sdxi: amd: prevalidate QoS operations Wei Huang
2026-11-19 20:23 ` [PATCH v1 32/44] dmaengine: sdxi: amd: execute QoS vendor operations Wei Huang
2026-11-19 20:23 ` [PATCH v1 33/44] dmaengine: sdxi: amd: register QoS vendor handler Wei Huang
2026-11-19 20:23 ` [PATCH v1 34/44] dmaengine: sdxi: amd: test QoS validation with KUnit Wei Huang
2026-11-19 20:23 ` [PATCH v1 35/44] selftests: sdxi: add build scaffold Wei Huang
2026-11-19 20:23 ` [PATCH v1 36/44] selftests: sdxi: add shared descriptor and context helpers Wei Huang
2026-11-19 20:23 ` [PATCH v1 37/44] selftests: sdxi: test context creation Wei Huang
2026-11-19 20:23 ` [PATCH v1 38/44] selftests: sdxi: test NOP descriptor submission Wei Huang
2026-11-19 20:23 ` [PATCH v1 39/44] selftests: sdxi: test copy submission and ring wrap Wei Huang
2026-11-19 20:23 ` [PATCH v1 40/44] selftests: sdxi: exercise dataplane error paths Wei Huang
2026-11-19 20:23 ` [PATCH v1 41/44] selftests: sdxi: test device ioctls Wei Huang
2026-11-19 20:23 ` [PATCH v1 42/44] selftests: sdxi: test vendor admin ioctls Wei Huang
2026-11-19 20:23 ` [PATCH v1 43/44] selftests: sdxi: test RKey ioctls Wei Huang
2026-11-19 20:23 ` [PATCH v1 44/44] MAINTAINERS: cover SDXI UAPI, vendor files, and selftests Wei Huang

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=20261119202321.1734355-27-wei.huang2@amd.com \
    --to=wei.huang2@amd.com \
    --cc=Frank.Li@kernel.org \
    --cc=John.Kariuki@amd.com \
    --cc=Shyam.Iyer@dell.com \
    --cc=Stephen.Bates@amd.com \
    --cc=bhelgaas@google.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=nathan.lynch@amd.com \
    --cc=rientjes@google.com \
    --cc=shuah@kernel.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tycho@kernel.org \
    --cc=vkoul@kernel.org \
    --cc=weixugc@google.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

all inboxes | Powered by JetHome®