Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356331
b: refs/heads/master
c: c73bc70
h: refs/heads/master
i:
  356329: e8e14de
  356327: 7dc41a0
v: v3
  • Loading branch information
Akinobu Mita authored and Bob Liu committed Feb 20, 2013
1 parent 7328c25 commit 2c9d594
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c428f8eb2f473963585b0c0a31cb33dccad62b9a
refs/heads/master: c73bc7026d7785fc627a8da7bbdd9d172001a59f
23 changes: 7 additions & 16 deletions trunk/arch/blackfin/kernel/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/dma-mapping.h>
#include <linux/scatterlist.h>
#include <linux/export.h>
#include <linux/bitmap.h>

static spinlock_t dma_page_lock;
static unsigned long *dma_page;
Expand Down Expand Up @@ -46,24 +47,17 @@ static inline unsigned int get_pages(size_t size)
static unsigned long __alloc_dma_pages(unsigned int pages)
{
unsigned long ret = 0, flags;
int i, count = 0;
unsigned long start;

if (dma_initialized == 0)
dma_alloc_init(_ramend - DMA_UNCACHED_REGION, _ramend);

spin_lock_irqsave(&dma_page_lock, flags);

for (i = 0; i < dma_pages;) {
if (test_bit(i++, dma_page) == 0) {
if (++count == pages) {
while (count--)
__set_bit(--i, dma_page);

ret = dma_base + (i << PAGE_SHIFT);
break;
}
} else
count = 0;
start = bitmap_find_next_zero_area(dma_page, dma_pages, 0, pages, 0);
if (start < dma_pages) {
ret = dma_base + (start << PAGE_SHIFT);
bitmap_set(dma_page, start, pages);
}
spin_unlock_irqrestore(&dma_page_lock, flags);
return ret;
Expand All @@ -73,17 +67,14 @@ static void __free_dma_pages(unsigned long addr, unsigned int pages)
{
unsigned long page = (addr - dma_base) >> PAGE_SHIFT;
unsigned long flags;
int i;

if ((page + pages) > dma_pages) {
printk(KERN_ERR "%s: freeing outside range.\n", __func__);
BUG();
}

spin_lock_irqsave(&dma_page_lock, flags);
for (i = page; i < page + pages; i++)
__clear_bit(i, dma_page);

bitmap_clear(dma_page, page, pages);
spin_unlock_irqrestore(&dma_page_lock, flags);
}

Expand Down

0 comments on commit 2c9d594

Please sign in to comment.