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 <quic_sukadev@quicinc.com>
This commit is contained in:
Sukadev Bhattiprolu
2022-12-22 13:48:15 -08:00
committed by Isaac Manjarres
parent 3f48f34ca5
commit 72b891ab7f
3 changed files with 12 additions and 0 deletions

View File

@@ -6,6 +6,10 @@
* Copyright 2020 Google LLC
*/
#ifndef __GENKSYSMS__
#include <linux/iova.h>
#endif
#define CREATE_TRACE_POINTS
#include <trace/hooks/vendor_hooks.h>
#include <linux/tracepoint.h>
@@ -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);

View File

@@ -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;

View File

@@ -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 */