Merge tag 'm68k-for-v5.3-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k
Pull m68k updates from Geert Uytterhoeven: - switch to using the generic remapping DMA allocator - defconfig updates * tag 'm68k-for-v5.3-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k: m68k: Implement arch_dma_prep_coherent() m68k: Use the generic dma coherent remap allocator m68k: defconfig: Update defconfigs for v5.2-rc1
This commit is contained in:
@@ -18,57 +18,22 @@
|
||||
#include <asm/pgalloc.h>
|
||||
|
||||
#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
|
||||
|
||||
void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
|
||||
gfp_t flag, unsigned long attrs)
|
||||
void arch_dma_prep_coherent(struct page *page, size_t size)
|
||||
{
|
||||
struct page *page, **map;
|
||||
pgprot_t pgprot;
|
||||
void *addr;
|
||||
int i, order;
|
||||
cache_push(page_to_phys(page), size);
|
||||
}
|
||||
|
||||
pr_debug("dma_alloc_coherent: %d,%x\n", size, flag);
|
||||
|
||||
size = PAGE_ALIGN(size);
|
||||
order = get_order(size);
|
||||
|
||||
page = alloc_pages(flag | __GFP_ZERO, order);
|
||||
if (!page)
|
||||
return NULL;
|
||||
|
||||
*handle = page_to_phys(page);
|
||||
map = kmalloc(sizeof(struct page *) << order, flag & ~__GFP_DMA);
|
||||
if (!map) {
|
||||
__free_pages(page, order);
|
||||
return NULL;
|
||||
pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot,
|
||||
unsigned long attrs)
|
||||
{
|
||||
if (CPU_IS_040_OR_060) {
|
||||
pgprot_val(prot) &= ~_PAGE_CACHE040;
|
||||
pgprot_val(prot) |= _PAGE_GLOBAL040 | _PAGE_NOCACHE_S;
|
||||
} else {
|
||||
pgprot_val(prot) |= _PAGE_NOCACHE030;
|
||||
}
|
||||
split_page(page, order);
|
||||
|
||||
order = 1 << order;
|
||||
size >>= PAGE_SHIFT;
|
||||
map[0] = page;
|
||||
for (i = 1; i < size; i++)
|
||||
map[i] = page + i;
|
||||
for (; i < order; i++)
|
||||
__free_page(page + i);
|
||||
pgprot = __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY);
|
||||
if (CPU_IS_040_OR_060)
|
||||
pgprot_val(pgprot) |= _PAGE_GLOBAL040 | _PAGE_NOCACHE_S;
|
||||
else
|
||||
pgprot_val(pgprot) |= _PAGE_NOCACHE030;
|
||||
addr = vmap(map, size, VM_MAP, pgprot);
|
||||
kfree(map);
|
||||
|
||||
return addr;
|
||||
return prot;
|
||||
}
|
||||
|
||||
void arch_dma_free(struct device *dev, size_t size, void *addr,
|
||||
dma_addr_t handle, unsigned long attrs)
|
||||
{
|
||||
pr_debug("dma_free_coherent: %p, %x\n", addr, handle);
|
||||
vfree(addr);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <asm/cacheflush.h>
|
||||
|
Reference in New Issue
Block a user