From 7d3b2c27d02a411ec98955f34d1b6286bceaa182 Mon Sep 17 00:00:00 2001 From: Janghyuck Kim Date: Tue, 27 Feb 2024 15:56:07 +0900 Subject: [PATCH] ANDROID: iommu: add vendor hooks for change dma property A vendor hook was added that allows the property value to vary depending on the dma attribute. Bug: 327086402 Change-Id: Ic415f019b861730feb40e10ada856ee63327153e Signed-off-by: Janghyuck Kim --- drivers/android/vendor_hooks.c | 1 + drivers/iommu/dma-iommu.c | 2 ++ include/trace/hooks/iommu.h | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index a779a150f63c..6e54123c015c 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -110,6 +110,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_io_statistics); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_iommu_setup_dma_ops); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_iommu_alloc_insert_iova); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_iommu_dma_info_to_prot); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_iommu_iovad_alloc_iova); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_iommu_iovad_free_iova); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_psci_tos_resident_on); diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 87978ce84bd2..57a9fb96323a 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -751,6 +751,8 @@ static int dma_info_to_prot(enum dma_data_direction dir, bool coherent, if (attrs & DMA_ATTR_PRIVILEGED) prot |= IOMMU_PRIV; + trace_android_rvh_iommu_dma_info_to_prot(attrs, &prot); + switch (dir) { case DMA_BIDIRECTIONAL: return prot | IOMMU_READ | IOMMU_WRITE; diff --git a/include/trace/hooks/iommu.h b/include/trace/hooks/iommu.h index 41d08e8abe04..8dc0cfbedbd2 100644 --- a/include/trace/hooks/iommu.h +++ b/include/trace/hooks/iommu.h @@ -23,6 +23,10 @@ DECLARE_RESTRICTED_HOOK(android_rvh_iommu_alloc_insert_iova, TP_ARGS(iovad, size, limit_pfn, new_iova, size_aligned, ret), 1); +DECLARE_RESTRICTED_HOOK(android_rvh_iommu_dma_info_to_prot, + TP_PROTO(unsigned long attrs, int *prot), + TP_ARGS(attrs, prot), 1); + DECLARE_HOOK(android_vh_iommu_iovad_alloc_iova, TP_PROTO(struct device *dev, struct iova_domain *iovad, dma_addr_t iova, size_t size), TP_ARGS(dev, iovad, iova, size));