Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 322567
b: refs/heads/master
c: 21d0a75
h: refs/heads/master
i:
  322565: e6e9a16
  322563: 2de3936
  322559: 0be7cf4
v: v3
  • Loading branch information
Hiroshi Doyu authored and Marek Szyprowski committed Aug 28, 2012
1 parent b3b3ca2 commit 2535e79
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 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: 6b3fe47264262fa082897ebe8ae01041eae65e14
refs/heads/master: 21d0a75951ccf71f671eb24b61a8ad2b497be4b4
26 changes: 20 additions & 6 deletions trunk/arch/arm/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,20 +482,34 @@ static void *__alloc_from_pool(size_t size, struct page **ret_page)
return ptr;
}

static bool __in_atomic_pool(void *start, size_t size)
{
struct dma_pool *pool = &atomic_pool;
void *end = start + size;
void *pool_start = pool->vaddr;
void *pool_end = pool->vaddr + pool->size;

if (start < pool_start || start > pool_end)
return false;

if (end <= pool_end)
return true;

WARN(1, "Wrong coherent size(%p-%p) from atomic pool(%p-%p)\n",
start, end - 1, pool_start, pool_end - 1);

return false;
}

static int __free_from_pool(void *start, size_t size)
{
struct dma_pool *pool = &atomic_pool;
unsigned long pageno, count;
unsigned long flags;

if (start < pool->vaddr || start > pool->vaddr + pool->size)
if (!__in_atomic_pool(start, size))
return 0;

if (start + size > pool->vaddr + pool->size) {
WARN(1, "freeing wrong coherent size from pool\n");
return 0;
}

pageno = (start - pool->vaddr) >> PAGE_SHIFT;
count = size >> PAGE_SHIFT;

Expand Down

0 comments on commit 2535e79

Please sign in to comment.