Commit d403ba51 authored by Olof Johansson's avatar Olof Johansson Committed by Linus Torvalds

[PATCH] ppc64: Fix thinko in iommu allocator

This fixes a bug in the iommu allocator that causes it to behave
strangely when a fair size of the table is allocated. 

Thanks to Andrew Gallatin for finding this.
parent 34e01aa2
...@@ -100,12 +100,13 @@ static unsigned long iommu_range_alloc(struct iommu_table *tbl, unsigned long np ...@@ -100,12 +100,13 @@ static unsigned long iommu_range_alloc(struct iommu_table *tbl, unsigned long np
end = n + npages; end = n + npages;
if (unlikely(end >= limit)) { if (unlikely(end >= limit)) {
if (likely(pass++ < 2)) { if (likely(pass < 2)) {
/* First failure, just rescan the half of the table. /* First failure, just rescan the half of the table.
* Second failure, rescan the other half of the table. * Second failure, rescan the other half of the table.
*/ */
start = (largealloc ^ pass) ? tbl->it_halfpoint : 0; start = (largealloc ^ pass) ? tbl->it_halfpoint : 0;
limit = pass ? tbl->it_mapsize : limit; limit = pass ? tbl->it_mapsize : limit;
pass++;
goto again; goto again;
} else { } else {
/* Third failure, give up */ /* Third failure, give up */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment