Skip to content

Commit

Permalink
sparc: use bitmap_find_next_zero_area
Browse files Browse the repository at this point in the history
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Akinobu Mita authored and Linus Torvalds committed Dec 16, 2009
1 parent 43ff8b6 commit e756fd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
16 changes: 4 additions & 12 deletions arch/sparc/kernel/ldc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/init.h>
#include <linux/bitmap.h>

#include <asm/hypervisor.h>
#include <asm/iommu.h>
Expand Down Expand Up @@ -1875,15 +1876,15 @@ EXPORT_SYMBOL(ldc_read);
static long arena_alloc(struct ldc_iommu *iommu, unsigned long npages)
{
struct iommu_arena *arena = &iommu->arena;
unsigned long n, i, start, end, limit;
unsigned long n, start, end, limit;
int pass;

limit = arena->limit;
start = arena->hint;
pass = 0;

again:
n = find_next_zero_bit(arena->map, limit, start);
n = bitmap_find_next_zero_area(arena->map, limit, start, npages, 0);
end = n + npages;
if (unlikely(end >= limit)) {
if (likely(pass < 1)) {
Expand All @@ -1896,16 +1897,7 @@ static long arena_alloc(struct ldc_iommu *iommu, unsigned long npages)
return -1;
}
}

for (i = n; i < end; i++) {
if (test_bit(i, arena->map)) {
start = i + 1;
goto again;
}
}

for (i = n; i < end; i++)
__set_bit(i, arena->map);
bitmap_set(arena->map, n, npages);

arena->hint = end;

Expand Down
17 changes: 5 additions & 12 deletions arch/sparc/mm/sun4c.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/fs.h>
#include <linux/seq_file.h>
#include <linux/scatterlist.h>
#include <linux/bitmap.h>

#include <asm/sections.h>
#include <asm/page.h>
Expand Down Expand Up @@ -1021,20 +1022,12 @@ static char *sun4c_lockarea(char *vaddr, unsigned long size)
npages = (((unsigned long)vaddr & ~PAGE_MASK) +
size + (PAGE_SIZE-1)) >> PAGE_SHIFT;

scan = 0;
local_irq_save(flags);
for (;;) {
scan = find_next_zero_bit(sun4c_iobuffer_map,
iobuffer_map_size, scan);
if ((base = scan) + npages > iobuffer_map_size) goto abend;
for (;;) {
if (scan >= base + npages) goto found;
if (test_bit(scan, sun4c_iobuffer_map)) break;
scan++;
}
}
base = bitmap_find_next_zero_area(sun4c_iobuffer_map, iobuffer_map_size,
0, npages, 0);
if (base >= iobuffer_map_size)
goto abend;

found:
high = ((base + npages) << PAGE_SHIFT) + sun4c_iobuffer_start;
high = SUN4C_REAL_PGDIR_ALIGN(high);
while (high > sun4c_iobuffer_high) {
Expand Down

0 comments on commit e756fd8

Please sign in to comment.