提交 e756fd80 编写于 作者: A Akinobu Mita 提交者: Linus Torvalds

sparc: use bitmap_find_next_zero_area

Signed-off-by: NAkinobu Mita <akinobu.mita@gmail.com>
Acked-by: N"David S. Miller" <davem@davemloft.net>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 43ff8b60
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/bitmap.h>
#include <asm/hypervisor.h> #include <asm/hypervisor.h>
#include <asm/iommu.h> #include <asm/iommu.h>
...@@ -1875,7 +1876,7 @@ EXPORT_SYMBOL(ldc_read); ...@@ -1875,7 +1876,7 @@ EXPORT_SYMBOL(ldc_read);
static long arena_alloc(struct ldc_iommu *iommu, unsigned long npages) static long arena_alloc(struct ldc_iommu *iommu, unsigned long npages)
{ {
struct iommu_arena *arena = &iommu->arena; struct iommu_arena *arena = &iommu->arena;
unsigned long n, i, start, end, limit; unsigned long n, start, end, limit;
int pass; int pass;
limit = arena->limit; limit = arena->limit;
...@@ -1883,7 +1884,7 @@ static long arena_alloc(struct ldc_iommu *iommu, unsigned long npages) ...@@ -1883,7 +1884,7 @@ static long arena_alloc(struct ldc_iommu *iommu, unsigned long npages)
pass = 0; pass = 0;
again: 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; end = n + npages;
if (unlikely(end >= limit)) { if (unlikely(end >= limit)) {
if (likely(pass < 1)) { if (likely(pass < 1)) {
...@@ -1896,16 +1897,7 @@ static long arena_alloc(struct ldc_iommu *iommu, unsigned long npages) ...@@ -1896,16 +1897,7 @@ static long arena_alloc(struct ldc_iommu *iommu, unsigned long npages)
return -1; return -1;
} }
} }
bitmap_set(arena->map, n, npages);
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);
arena->hint = end; arena->hint = end;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/bitmap.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -1021,20 +1022,12 @@ static char *sun4c_lockarea(char *vaddr, unsigned long size) ...@@ -1021,20 +1022,12 @@ static char *sun4c_lockarea(char *vaddr, unsigned long size)
npages = (((unsigned long)vaddr & ~PAGE_MASK) + npages = (((unsigned long)vaddr & ~PAGE_MASK) +
size + (PAGE_SIZE-1)) >> PAGE_SHIFT; size + (PAGE_SIZE-1)) >> PAGE_SHIFT;
scan = 0;
local_irq_save(flags); local_irq_save(flags);
for (;;) { base = bitmap_find_next_zero_area(sun4c_iobuffer_map, iobuffer_map_size,
scan = find_next_zero_bit(sun4c_iobuffer_map, 0, npages, 0);
iobuffer_map_size, scan); if (base >= iobuffer_map_size)
if ((base = scan) + npages > iobuffer_map_size) goto abend; goto abend;
for (;;) {
if (scan >= base + npages) goto found;
if (test_bit(scan, sun4c_iobuffer_map)) break;
scan++;
}
}
found:
high = ((base + npages) << PAGE_SHIFT) + sun4c_iobuffer_start; high = ((base + npages) << PAGE_SHIFT) + sun4c_iobuffer_start;
high = SUN4C_REAL_PGDIR_ALIGN(high); high = SUN4C_REAL_PGDIR_ALIGN(high);
while (high > sun4c_iobuffer_high) { while (high > sun4c_iobuffer_high) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册