Merge branch 'drm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[firefly-linux-kernel-4.4.55.git] / drivers / pci / iova.c
index 7914951ef29a9bab0b4bf4371f6d396503abd4ac..c5c274ab5c5a034abe91fb1f1f5dcf6380c9315e 100644 (file)
@@ -63,8 +63,16 @@ __cached_rbnode_delete_update(struct iova_domain *iovad, struct iova *free)
        curr = iovad->cached32_node;
        cached_iova = container_of(curr, struct iova, node);
 
-       if (free->pfn_lo >= cached_iova->pfn_lo)
-               iovad->cached32_node = rb_next(&free->node);
+       if (free->pfn_lo >= cached_iova->pfn_lo) {
+               struct rb_node *node = rb_next(&free->node);
+               struct iova *iova = container_of(node, struct iova, node);
+
+               /* only cache if it's below 32bit pfn */
+               if (node && iova->pfn_lo < iovad->dma_32bit_pfn)
+                       iovad->cached32_node = node;
+               else
+                       iovad->cached32_node = NULL;
+       }
 }
 
 /* Computes the padding size required, to make the
@@ -391,7 +399,7 @@ reserve_iova(struct iova_domain *iovad,
                                break;
        }
 
-       /* We are here either becasue this is the first reserver node
+       /* We are here either because this is the first reserver node
         * or need to insert remaining non overlap addr range
         */
        iova = __insert_new_range(iovad, pfn_lo, pfn_hi);