Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 172400
b: refs/heads/master
c: 31ebf94
h: refs/heads/master
v: v3
  • Loading branch information
Russell King committed Nov 24, 2009
1 parent cb63625 commit f1aebfa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 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: ebd7a845fa4332da3ebcbe8cf1b09bb43413420e
refs/heads/master: 31ebf94435f74294523683867fe0b89000e61521
45 changes: 15 additions & 30 deletions trunk/arch/arm/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,27 +183,13 @@ static int __init consistent_init(void)
core_initcall(consistent_init);

static void *
__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
pgprot_t prot)
__dma_alloc_remap(struct page *page, size_t size, gfp_t gfp, pgprot_t prot)
{
struct page *page;
struct arm_vmregion *c;

size = PAGE_ALIGN(size);

page = __dma_alloc_buffer(dev, size, gfp);
if (!page)
goto no_page;

if (arch_is_coherent()) {
*handle = page_to_dma(dev, page);
return page_address(page);
}

if (!consistent_pte[0]) {
printk(KERN_ERR "%s: not initialised\n", __func__);
dump_stack();
__dma_free_buffer(page, size);
return NULL;
}

Expand All @@ -220,11 +206,6 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
pte = consistent_pte[idx] + off;
c->vm_pages = page;

/*
* Set the "dma handle"
*/
*handle = page_to_dma(dev, page);

do {
BUG_ON(!pte_none(*pte));

Expand All @@ -244,11 +225,6 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,

return (void *)c->vm_start;
}

if (page)
__dma_free_buffer(page, size);
no_page:
*handle = ~0;
return NULL;
}

Expand Down Expand Up @@ -315,11 +291,17 @@ static void __dma_free_remap(void *cpu_addr, size_t size)

#else /* !CONFIG_MMU */

#define __dma_alloc_remap(page, size, gfp, prot) page_address(page)
#define __dma_free_remap(addr, size) do { } while (0)

#endif /* CONFIG_MMU */

static void *
__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
pgprot_t prot)
{
struct page *page;
void *addr;

*handle = ~0;
size = PAGE_ALIGN(size);
Expand All @@ -328,13 +310,16 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
if (!page)
return NULL;

*handle = page_to_dma(dev, page);
return page_address(page);
}
if (!arch_is_coherent())
addr = __dma_alloc_remap(page, size, gfp, prot);
else
addr = page_address(page);

#define __dma_free_remap(addr, size) do { } while (0)
if (addr)
*handle = page_to_dma(dev, page);

#endif /* CONFIG_MMU */
return addr;
}

/*
* Allocate DMA-coherent memory space and return both the kernel remapped
Expand Down

0 comments on commit f1aebfa

Please sign in to comment.