ANDROID: iommu: Define vendor hook to limit max alignment

When the IOVA framework applies IOVA alignment it aligns all IOVAs
to the smallest PAGE_SIZE order which is greater than or equal to
the requested IOVA size.

We support use cases that requires large buffers (> 64 MB in size)
to be allocated and mapped in their stage 1 page tables.  However,
with this alignment scheme we find ourselves running out of IOVA
space for 32 bit devices,

Define a vendor hook to allow limiting the alignment value used when
allocating IOVAs.

We addressed this issue in Android13-5.15 with commit 989b762eb159
("FROMLIST: iommu/iova: Add support for IOVA max alignment tuning")

Bug: 190519428
Change-Id: I13032c1b440c050860109aae23f96c0b52782664
Link: https://lore.kernel.org/r/1634148667-409263-1-git-send-email-quic_c_gdjako@quicinc.com/
Signed-off-by: Sukadev Bhattiprolu <quic_sukadev@quicinc.com>
This commit is contained in:
Sukadev Bhattiprolu 2023-01-11 19:04:25 -08:00 committed by Treehugger Robot
parent 0f95c27659
commit 7b49f180f9
3 changed files with 11 additions and 2 deletions

View File

@ -96,6 +96,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_iommu_alloc_insert_iova);
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_rvh_iommu_limit_align_shift);
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

@ -188,8 +188,11 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
unsigned long align_mask = ~0UL;
unsigned long high_pfn = limit_pfn, low_pfn = iovad->start_pfn;
if (size_aligned)
align_mask <<= fls_long(size - 1);
if (size_aligned) {
unsigned long shift = fls_long(size - 1);
trace_android_rvh_iommu_limit_align_shift(iovad, size, &shift);
align_mask <<= shift;
}
/* Walk the tree backwards */
spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);

View File

@ -35,6 +35,11 @@ DECLARE_RESTRICTED_HOOK(android_rvh_iommu_iovad_init_alloc_algo,
TP_PROTO(struct device *dev, struct iova_domain *iovad),
TP_ARGS(dev, iovad), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_iommu_limit_align_shift,
TP_PROTO(struct iova_domain *iovad, unsigned long size,
unsigned long *shift),
TP_ARGS(iovad, size, shift), 1);
#endif /* _TRACE_HOOK_IOMMU_H */
/* This part must be outside protection */