]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ppc64: Fix thinko in iommu allocator
authorOlof Johansson <olof@austin.ibm.com>
Sun, 28 Mar 2004 03:27:55 +0000 (19:27 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sun, 28 Mar 2004 03:27:55 +0000 (19:27 -0800)
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.

arch/ppc64/kernel/iommu.c

index c34bbbc2455f6ddbebe709027fcfbe541f6523aa..a9097cac35de9ed7ae8cefed140c7aa281be1ab7 100644 (file)
@@ -100,12 +100,13 @@ static unsigned long iommu_range_alloc(struct iommu_table *tbl, unsigned long np
        end = n + npages;
 
        if (unlikely(end >= limit)) {
-               if (likely(pass++ < 2)) {
+               if (likely(pass < 2)) {
                        /* First failure, just rescan the half of the table.
                         * Second failure, rescan the other half of the table.
                         */
                        start = (largealloc ^ pass) ? tbl->it_halfpoint : 0;
                        limit = pass ? tbl->it_mapsize : limit;
+                       pass++;
                        goto again;
                } else {
                        /* Third failure, give up */