Skip to content

Commit 80ef446

Browse files
Robert Richterjoergroedel
authored andcommitted
iommu/iova: Fix tracking of recently failed iova address
If a 32 bit allocation request is too big to possibly succeed, it early exits with a failure and then should never update max32_alloc_ size. This patch fixes current code, now the size is only updated if the slow path failed while walking the tree. Without the fix the allocation may enter the slow path again even if there was a failure before of a request with the same or a smaller size. Cc: <stable@vger.kernel.org> # 4.20+ Fixes: bee60e9 ("iommu/iova: Optimise attempts to allocate iova from 32bit address range") Reviewed-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Robert Richter <rrichter@marvell.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 4e50ce0 commit 80ef446

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/iommu/iova.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
207207
curr_iova = rb_entry(curr, struct iova, node);
208208
} while (curr && new_pfn <= curr_iova->pfn_hi);
209209

210-
if (limit_pfn < size || new_pfn < iovad->start_pfn)
210+
if (limit_pfn < size || new_pfn < iovad->start_pfn) {
211+
iovad->max32_alloc_size = size;
211212
goto iova32_full;
213+
}
212214

213215
/* pfn_lo will point to size aligned address if size_aligned is set */
214216
new->pfn_lo = new_pfn;
@@ -222,7 +224,6 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
222224
return 0;
223225

224226
iova32_full:
225-
iovad->max32_alloc_size = size;
226227
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
227228
return -ENOMEM;
228229
}

0 commit comments

Comments
 (0)