From 15acc8fac61185e8d511dfd485f392e4ad783cf8 Mon Sep 17 00:00:00 2001 From: Guangming Cao Date: Tue, 18 May 2021 15:31:28 +0800 Subject: [PATCH] ANDROID: iommu: Add vendor hook for iova allocation and free tracking Add vendor hook for iommu_dma_alloc_iova and iommu_dma_free_iova to allow vendor enhancement. Bug: 187861158 Change-Id: I2ebe8b24318bd5292edc66a94d7109332d478212 Signed-off-by: Guangming Cao --- drivers/android/vendor_hooks.c | 2 ++ drivers/iommu/dma-iommu.c | 5 +++++ include/trace/hooks/iommu.h | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index ed0386e4520b..f25b35274926 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -175,6 +175,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_sea); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_mem_abort); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_sp_pc_abort); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_iommu_setup_dma_ops); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_iommu_alloc_iova); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_iommu_free_iova); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_pick_next_entity); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_wakeup); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_start); diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 3d439f105c1f..0a51e7d7bfea 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -23,6 +23,7 @@ #include #include #include +#include struct iommu_dma_msi_page { struct list_head list; @@ -486,6 +487,8 @@ static dma_addr_t iommu_dma_alloc_iova(struct iommu_domain *domain, iova = alloc_iova_fast(iovad, iova_len, dma_limit >> shift, true); + trace_android_vh_iommu_alloc_iova(dev, iova, size); + return (dma_addr_t)iova << shift; } @@ -503,6 +506,8 @@ static void iommu_dma_free_iova(struct iommu_dma_cookie *cookie, else free_iova_fast(iovad, iova_pfn(iovad, iova), size >> iova_shift(iovad)); + + trace_android_vh_iommu_free_iova(iova, size); } static void __iommu_dma_unmap(struct device *dev, dma_addr_t dma_addr, diff --git a/include/trace/hooks/iommu.h b/include/trace/hooks/iommu.h index 3c5829e6f6ef..d4fbeec3844b 100644 --- a/include/trace/hooks/iommu.h +++ b/include/trace/hooks/iommu.h @@ -18,9 +18,18 @@ DECLARE_HOOK(android_vh_iommu_setup_dma_ops, TP_PROTO(struct device *dev, u64 dma_base, u64 size), TP_ARGS(dev, dma_base, size)); +DECLARE_HOOK(android_vh_iommu_alloc_iova, + TP_PROTO(struct device *dev, dma_addr_t iova, size_t size), + TP_ARGS(dev, iova, size)); + +DECLARE_HOOK(android_vh_iommu_free_iova, + TP_PROTO(dma_addr_t iova, size_t size), + TP_ARGS(iova, size)); #else #define trace_android_vh_iommu_setup_dma_ops(dev, dma_base, size) +#define trace_android_vh_iommu_alloc_iova(dev, iova, size) +#define trace_android_vh_iommu_free_iova(iova, size) #endif