Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db67e445 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "iommu/iova: Limit IOVA alignment using CONFIG_ARM64_DMA_IOMMU_ALIGNMENT"

parents d1798b44 fe5cca37
Loading
Loading
Loading
Loading
+19 −1
Original line number Original line Diff line number Diff line
@@ -175,6 +175,24 @@ iova_insert_rbtree(struct rb_root *root, struct iova *iova,
	rb_insert_color(&iova->node, root);
	rb_insert_color(&iova->node, root);
}
}


#ifdef CONFIG_ARM64_DMA_IOMMU_ALIGNMENT
static unsigned long limit_align(struct iova_domain *iovad,
					unsigned long shift)
{
	unsigned long max;

	max = CONFIG_ARM64_DMA_IOMMU_ALIGNMENT + PAGE_SHIFT
		- iova_shift(iovad);
	return min(shift, max);
}
#else
static unsigned long limit_align(struct iova_domain *iovad,
					unsigned long shift)
{
	return shift;
}
#endif

static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
		unsigned long size, unsigned long limit_pfn,
		unsigned long size, unsigned long limit_pfn,
			struct iova *new, bool size_aligned)
			struct iova *new, bool size_aligned)
@@ -186,7 +204,7 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
	unsigned long align_mask = ~0UL;
	unsigned long align_mask = ~0UL;


	if (size_aligned)
	if (size_aligned)
		align_mask <<= fls_long(size - 1);
		align_mask <<= limit_align(iovad, fls_long(size - 1));


	/* Walk the tree backwards */
	/* Walk the tree backwards */
	spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
	spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);