mirror of https://gitee.com/openkylin/linux.git
microblaze: Implement __dma_sync_page
There is necessary to do some cache handling for dma operations. Signed-off-by: Michal Simek <monstr@monstr.eu>
This commit is contained in:
parent
ccfe27d700
commit
2549edd353
|
@ -34,7 +34,6 @@
|
||||||
#define __dma_alloc_coherent(dev, gfp, size, handle) NULL
|
#define __dma_alloc_coherent(dev, gfp, size, handle) NULL
|
||||||
#define __dma_free_coherent(size, addr) ((void)0)
|
#define __dma_free_coherent(size, addr) ((void)0)
|
||||||
#define __dma_sync(addr, size, rw) ((void)0)
|
#define __dma_sync(addr, size, rw) ((void)0)
|
||||||
#define __dma_sync_page(pg, off, sz, rw) ((void)0)
|
|
||||||
|
|
||||||
static inline unsigned long device_to_mask(struct device *dev)
|
static inline unsigned long device_to_mask(struct device *dev)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <linux/dma-mapping.h>
|
#include <linux/dma-mapping.h>
|
||||||
#include <linux/dma-debug.h>
|
#include <linux/dma-debug.h>
|
||||||
#include <asm/bug.h>
|
#include <asm/bug.h>
|
||||||
|
#include <asm/cacheflush.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic direct DMA implementation
|
* Generic direct DMA implementation
|
||||||
|
@ -20,6 +21,23 @@
|
||||||
* default the offset is PCI_DRAM_OFFSET.
|
* default the offset is PCI_DRAM_OFFSET.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static inline void __dma_sync_page(void *vaddr, unsigned long offset,
|
||||||
|
size_t size, enum dma_data_direction direction)
|
||||||
|
{
|
||||||
|
unsigned long start = virt_to_phys(vaddr);
|
||||||
|
|
||||||
|
switch (direction) {
|
||||||
|
case DMA_TO_DEVICE:
|
||||||
|
flush_dcache_range(start + offset, start + offset + size);
|
||||||
|
break;
|
||||||
|
case DMA_FROM_DEVICE:
|
||||||
|
invalidate_dcache_range(start + offset, start + offset + size);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BUG();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned long get_dma_direct_offset(struct device *dev)
|
static unsigned long get_dma_direct_offset(struct device *dev)
|
||||||
{
|
{
|
||||||
if (dev)
|
if (dev)
|
||||||
|
@ -85,11 +103,11 @@ static inline dma_addr_t dma_direct_map_page(struct device *dev,
|
||||||
struct page *page,
|
struct page *page,
|
||||||
unsigned long offset,
|
unsigned long offset,
|
||||||
size_t size,
|
size_t size,
|
||||||
enum dma_data_direction dir,
|
enum dma_data_direction direction,
|
||||||
struct dma_attrs *attrs)
|
struct dma_attrs *attrs)
|
||||||
{
|
{
|
||||||
BUG_ON(dir == DMA_NONE);
|
BUG_ON(direction == DMA_NONE);
|
||||||
__dma_sync_page(page, offset, size, dir);
|
__dma_sync_page(page, offset, size, direction);
|
||||||
return page_to_phys(page) + offset + get_dma_direct_offset(dev);
|
return page_to_phys(page) + offset + get_dma_direct_offset(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +117,8 @@ static inline void dma_direct_unmap_page(struct device *dev,
|
||||||
enum dma_data_direction direction,
|
enum dma_data_direction direction,
|
||||||
struct dma_attrs *attrs)
|
struct dma_attrs *attrs)
|
||||||
{
|
{
|
||||||
|
/* There is not necessary to do cache cleanup */
|
||||||
|
/* __dma_sync_page(dma_address, 0 , size, direction); */
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dma_map_ops dma_direct_ops = {
|
struct dma_map_ops dma_direct_ops = {
|
||||||
|
|
Loading…
Reference in New Issue