Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / drivers / iommu / iova.c
index a3dbba8caa19f8a77d3031624b7d4f76a0674b7d..9dd8208312c2e75874ce70dcc6008a166eb5ffca 100644 (file)
@@ -55,12 +55,20 @@ void free_iova_mem(struct iova *iova)
 }
 
 void
-init_iova_domain(struct iova_domain *iovad, unsigned long start_pfn,
-       unsigned long pfn_32bit)
+init_iova_domain(struct iova_domain *iovad, unsigned long granule,
+       unsigned long start_pfn, unsigned long pfn_32bit)
 {
+       /*
+        * IOVA granularity will normally be equal to the smallest
+        * supported IOMMU page size; both *must* be capable of
+        * representing individual CPU pages exactly.
+        */
+       BUG_ON((granule > PAGE_SIZE) || !is_power_of_2(granule));
+
        spin_lock_init(&iovad->iova_rbtree_lock);
        iovad->rbroot = RB_ROOT;
        iovad->cached32_node = NULL;
+       iovad->granule = granule;
        iovad->start_pfn = start_pfn;
        iovad->dma_32bit_pfn = pfn_32bit;
 }