From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>,
Linux trace kernel <linux-trace-kernel@vger.kernel.org>,
iommu@lists.linux.dev
Cc: Christoph Hellwig <hch@infradead.org>,
Robin Murphy <robin.murphy@arm.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>
Subject: [PATCH] swiotlb: iommu/dma: Move trace_swiotlb_bounced() into swiotlb_tbl_map_single()
Date: Wed, 11 Jun 2025 10:01:03 -0400 [thread overview]
Message-ID: <20250611100103.7b3c28c8@batman.local.home> (raw)
From: Steven Rostedt <rostedt@goodmis.org>
I'm working on code that will warn when a tracepoint is defined but not
used. As the TRACE_EVENT() logic still creates all the code regardless if
something calls the trace_<event>() function. It wastes around 5K per trace
event (less for tracepoints).
But it seems that the code in drivers/iommu/dma-iommu.c does the opposite.
It calls the trace_swiotlb_bounced() tracepoint without it being defined.
The tracepoint is defined in kernel/dma/swiotlb.c when CONFIG_SWIOTLB is
defined, but this code exists when that config is not defined.
This now fails with my work because I have all the callers reference the
tracepoint that they will call.
Thanks to the kernel test robot, it found this:
https://lore.kernel.org/all/202506091015.7zd87kI7-lkp@intel.com/
Instead of calling trace_swiotlb_bounced() from drivers/iommu/dma-iommu.c
where it is useless when CONFIG_SWIOTLB is not defined, move the
tracepoint into swiotlb_tbl_map_single(). This also makes it consistent
with which memory is being traced (physical as supposed to dma address).
Fixes: ed18a46262be4 ("iommu/dma: Factor out a iommu_dma_map_swiotlb helper")
Closes: https://lore.kernel.org/all/20250610202457.5a599336@gandalf.local.home/
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
drivers/iommu/dma-iommu.c | 2 --
kernel/dma/swiotlb.c | 2 ++
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index ea2ef53bd4fe..1935b360cc94 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -1153,8 +1153,6 @@ static phys_addr_t iommu_dma_map_swiotlb(struct device *dev, phys_addr_t phys,
return (phys_addr_t)DMA_MAPPING_ERROR;
}
- trace_swiotlb_bounced(dev, phys, size);
-
phys = swiotlb_tbl_map_single(dev, phys, size, iova_mask(iovad), dir,
attrs);
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index abcf3fa63a56..c112f1d98861 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -1379,6 +1379,8 @@ phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr,
phys_addr_t tlb_addr;
unsigned short pad_slots;
+ trace_swiotlb_bounced(dev, orig_addr, mapping_size);
+
if (!mem || !mem->nslabs) {
dev_warn_ratelimited(dev,
"Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer");
--
2.47.2
next reply other threads:[~2025-06-11 14:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 14:01 Steven Rostedt [this message]
2025-06-11 14:28 ` [PATCH] swiotlb: iommu/dma: Move trace_swiotlb_bounced() into swiotlb_tbl_map_single() Robin Murphy
2025-06-11 15:56 ` Steven Rostedt
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=20250611100103.7b3c28c8@batman.local.home \
--to=rostedt@goodmis.org \
--cc=hch@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/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