From 72b891ab7f27fcf6baf0c2317f800fa4c3bf2a84 Mon Sep 17 00:00:00 2001 From: Sukadev Bhattiprolu Date: Thu, 22 Dec 2022 13:48:15 -0800 Subject: [PATCH] ANDROID: iommu: Add vendor hook to select alloc_iova algorithm Add a vendor hook that allows initializing the iovad->android_vendor_data1 field to indicate whether to use the first-fit or best-fit algorithm for this device when allocating IOVAs. Bug: 263499813 Bug: 190519428 Bug: 149544392 Change-Id: I0c894b32416a459d7a58aa076770daedcce67cc3 Signed-off-by: Sukadev Bhattiprolu --- drivers/android/vendor_hooks.c | 5 +++++ drivers/iommu/dma-iommu.c | 3 +++ include/trace/hooks/iommu.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index d4cb5666ee69..d41c18cc3407 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -6,6 +6,10 @@ * Copyright 2020 Google LLC */ +#ifndef __GENKSYSMS__ +#include +#endif + #define CREATE_TRACE_POINTS #include #include @@ -83,6 +87,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_iommu_setup_dma_ops); 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_iommu_iovad_init_alloc_algo); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ptype_head); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_allow_domain_state); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpuidle_psci_enter); diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 851bfc2cf074..7ac6dc205984 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -579,6 +579,9 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, } init_iova_domain(iovad, 1UL << order, base_pfn); + + trace_android_rvh_iommu_iovad_init_alloc_algo(dev, iovad); + ret = iova_domain_init_rcaches(iovad); if (ret) goto done_unlock; diff --git a/include/trace/hooks/iommu.h b/include/trace/hooks/iommu.h index 6357a6bc8f96..86b12dbb6d59 100644 --- a/include/trace/hooks/iommu.h +++ b/include/trace/hooks/iommu.h @@ -23,6 +23,10 @@ DECLARE_HOOK(android_vh_iommu_iovad_free_iova, TP_PROTO(struct iova_domain *iovad, dma_addr_t iova, size_t size), TP_ARGS(iovad, iova, size)); +DECLARE_RESTRICTED_HOOK(android_rvh_iommu_iovad_init_alloc_algo, + TP_PROTO(struct device *dev, struct iova_domain *iovad), + TP_ARGS(dev, iovad), 1); + #endif /* _TRACE_HOOK_IOMMU_H */ /* This part must be outside protection */