forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'dma-mapping-5.7' of git://git.infradead.org/users/hch/dma-…
…mapping Pull dma-mapping updates from Christoph Hellwig: - fix an integer overflow in the coherent pool (Kevin Grandemange) - provide support for in-place uncached remapping and use that for openrisc - fix the arm coherent allocator to take the bus limit into account * tag 'dma-mapping-5.7' of git://git.infradead.org/users/hch/dma-mapping: ARM/dma-mapping: merge __dma_supported into arm_dma_supported ARM/dma-mapping: take the bus limit into account in __dma_alloc ARM/dma-mapping: remove get_coherent_dma_mask openrisc: use the generic in-place uncached DMA allocator dma-direct: provide a arch_dma_clear_uncached hook dma-direct: make uncached_kernel_address more general dma-direct: consolidate the error handling in dma_direct_alloc_pages dma-direct: remove the cached_kernel_address hook dma-coherent: fix integer overflow in the reserved-memory dma allocation
- Loading branch information
Showing
16 changed files
with
76 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,6 @@ | |
* Copyright (C) 2010-2011 Jonas Bonn <[email protected]> | ||
* | ||
* DMA mapping callbacks... | ||
* As alloc_coherent is the only DMA callback being used currently, that's | ||
* the only thing implemented properly. The rest need looking into... | ||
*/ | ||
|
||
#include <linux/dma-noncoherent.h> | ||
|
@@ -67,62 +65,29 @@ static const struct mm_walk_ops clear_nocache_walk_ops = { | |
.pte_entry = page_clear_nocache, | ||
}; | ||
|
||
/* | ||
* Alloc "coherent" memory, which for OpenRISC means simply uncached. | ||
* | ||
* This function effectively just calls __get_free_pages, sets the | ||
* cache-inhibit bit on those pages, and makes sure that the pages are | ||
* flushed out of the cache before they are used. | ||
* | ||
* If the NON_CONSISTENT attribute is set, then this function just | ||
* returns "normal", cachable memory. | ||
* | ||
* There are additional flags WEAK_ORDERING and WRITE_COMBINE to take | ||
* into consideration here, too. All current known implementations of | ||
* the OR1K support only strongly ordered memory accesses, so that flag | ||
* is being ignored for now; uncached but write-combined memory is a | ||
* missing feature of the OR1K. | ||
*/ | ||
void * | ||
arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, | ||
gfp_t gfp, unsigned long attrs) | ||
void *arch_dma_set_uncached(void *cpu_addr, size_t size) | ||
{ | ||
unsigned long va; | ||
void *page; | ||
|
||
page = alloc_pages_exact(size, gfp | __GFP_ZERO); | ||
if (!page) | ||
return NULL; | ||
|
||
/* This gives us the real physical address of the first page. */ | ||
*dma_handle = __pa(page); | ||
|
||
va = (unsigned long)page; | ||
unsigned long va = (unsigned long)cpu_addr; | ||
int error; | ||
|
||
/* | ||
* We need to iterate through the pages, clearing the dcache for | ||
* them and setting the cache-inhibit bit. | ||
*/ | ||
if (walk_page_range(&init_mm, va, va + size, &set_nocache_walk_ops, | ||
NULL)) { | ||
free_pages_exact(page, size); | ||
return NULL; | ||
} | ||
|
||
return (void *)va; | ||
error = walk_page_range(&init_mm, va, va + size, &set_nocache_walk_ops, | ||
NULL); | ||
if (error) | ||
return ERR_PTR(error); | ||
return cpu_addr; | ||
} | ||
|
||
void | ||
arch_dma_free(struct device *dev, size_t size, void *vaddr, | ||
dma_addr_t dma_handle, unsigned long attrs) | ||
void arch_dma_clear_uncached(void *cpu_addr, size_t size) | ||
{ | ||
unsigned long va = (unsigned long)vaddr; | ||
unsigned long va = (unsigned long)cpu_addr; | ||
|
||
/* walk_page_range shouldn't be able to fail here */ | ||
WARN_ON(walk_page_range(&init_mm, va, va + size, | ||
&clear_nocache_walk_ops, NULL)); | ||
|
||
free_pages_exact(vaddr, size); | ||
} | ||
|
||
void arch_sync_dma_for_device(phys_addr_t addr, size_t size, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.