2024-01-22 20:38:25

by Isaac J. Manjarres

[permalink] [raw]
Subject: [PATCH 5.15.y] iommu/dma: Trace bounce buffer usage when mapping buffers

When commit 82612d66d51d ("iommu: Allow the dma-iommu api to
use bounce buffers") was introduced, it did not add the logic
for tracing the bounce buffer usage from iommu_dma_map_page().

All of the users of swiotlb_tbl_map_single() trace their bounce
buffer usage, except iommu_dma_map_page(). This makes it difficult
to track SWIOTLB usage from that function. Thus, trace bounce buffer
usage from iommu_dma_map_page().

Fixes: 82612d66d51d ("iommu: Allow the dma-iommu api to use bounce buffers")
Cc: [email protected] # v5.15+
Cc: Tom Murphy <[email protected]>
Cc: Lu Baolu <[email protected]>
Cc: Saravana Kannan <[email protected]>
Signed-off-by: Isaac J. Manjarres <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Joerg Roedel <[email protected]>
(cherry picked from commit a63c357b9fd56ad5fe64616f5b22835252c6a76a)
Signed-off-by: Isaac J. Manjarres <[email protected]>
---
drivers/iommu/dma-iommu.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 48c6f7ff4aef..8cd63e6ccd2c 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -25,6 +25,7 @@
#include <linux/vmalloc.h>
#include <linux/crash_dump.h>
#include <linux/dma-direct.h>
+#include <trace/events/swiotlb.h>

struct iommu_dma_msi_page {
struct list_head list;
@@ -817,6 +818,8 @@ static dma_addr_t iommu_dma_map_page(struct device *dev, struct page *page,
void *padding_start;
size_t padding_size, aligned_size;

+ trace_swiotlb_bounced(dev, phys, size, swiotlb_force);
+
aligned_size = iova_align(iovad, size);
phys = swiotlb_tbl_map_single(dev, phys, size, aligned_size,
iova_mask(iovad), dir, attrs);
--
2.43.0.429.g432eaa2c6b-goog



2024-01-22 20:46:55

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 5.15.y] iommu/dma: Trace bounce buffer usage when mapping buffers

On Mon, Jan 22, 2024 at 12:37:54PM -0800, Isaac J. Manjarres wrote:
> When commit 82612d66d51d ("iommu: Allow the dma-iommu api to
> use bounce buffers") was introduced, it did not add the logic
> for tracing the bounce buffer usage from iommu_dma_map_page().
>
> All of the users of swiotlb_tbl_map_single() trace their bounce
> buffer usage, except iommu_dma_map_page(). This makes it difficult
> to track SWIOTLB usage from that function. Thus, trace bounce buffer
> usage from iommu_dma_map_page().
>
> Fixes: 82612d66d51d ("iommu: Allow the dma-iommu api to use bounce buffers")
> Cc: [email protected] # v5.15+
> Cc: Tom Murphy <[email protected]>
> Cc: Lu Baolu <[email protected]>
> Cc: Saravana Kannan <[email protected]>
> Signed-off-by: Isaac J. Manjarres <[email protected]>
> Link: https://lore.kernel.org/r/[email protected]
> Signed-off-by: Joerg Roedel <[email protected]>
> (cherry picked from commit a63c357b9fd56ad5fe64616f5b22835252c6a76a)
> Signed-off-by: Isaac J. Manjarres <[email protected]>

Now queued up, thanks.

greg k-h