forked from luck/tmp_suning_uos_patched
[ARM] dma-mapping: provide sync_range APIs
Convert the existing dma_sync_single_for_* APIs to the new range based APIs, and make the dma_sync_single_for_* API a superset of it. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
parent
98ed7d4b1a
commit
9dd4286805
|
@ -321,9 +321,8 @@ unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static int sync_single(struct device *dev, dma_addr_t dma_addr, size_t size,
|
||||||
sync_single(struct device *dev, dma_addr_t dma_addr, size_t size,
|
enum dma_data_direction dir)
|
||||||
enum dma_data_direction dir)
|
|
||||||
{
|
{
|
||||||
struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
|
struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
|
||||||
struct safe_buffer *buf = NULL;
|
struct safe_buffer *buf = NULL;
|
||||||
|
@ -383,8 +382,9 @@ sync_single(struct device *dev, dma_addr_t dma_addr, size_t size,
|
||||||
* No need to sync the safe buffer - it was allocated
|
* No need to sync the safe buffer - it was allocated
|
||||||
* via the coherent allocators.
|
* via the coherent allocators.
|
||||||
*/
|
*/
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
dma_cache_maint(dma_to_virt(dev, dma_addr), size, dir);
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,25 +474,29 @@ dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_addr,
|
||||||
dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_addr, size_t size,
|
unsigned long offset, size_t size,
|
||||||
enum dma_data_direction dir)
|
enum dma_data_direction dir)
|
||||||
{
|
{
|
||||||
dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n",
|
dev_dbg(dev, "%s(dma=%#x,off=%#lx,size=%zx,dir=%x)\n",
|
||||||
__func__, (void *) dma_addr, size, dir);
|
__func__, dma_addr, offset, size, dir);
|
||||||
|
|
||||||
sync_single(dev, dma_addr, size, dir);
|
if (sync_single(dev, dma_addr, offset + size, dir))
|
||||||
|
dma_cache_maint(dma_to_virt(dev, dma_addr) + offset, size, dir);
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(dma_sync_single_range_for_cpu);
|
||||||
|
|
||||||
void
|
void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_addr,
|
||||||
dma_sync_single_for_device(struct device *dev, dma_addr_t dma_addr, size_t size,
|
unsigned long offset, size_t size,
|
||||||
enum dma_data_direction dir)
|
enum dma_data_direction dir)
|
||||||
{
|
{
|
||||||
dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n",
|
dev_dbg(dev, "%s(dma=%#x,off=%#lx,size=%zx,dir=%x)\n",
|
||||||
__func__, (void *) dma_addr, size, dir);
|
__func__, dma_addr, offset, size, dir);
|
||||||
|
|
||||||
sync_single(dev, dma_addr, size, dir);
|
if (sync_single(dev, dma_addr, offset + size, dir))
|
||||||
|
dma_cache_maint(dma_to_virt(dev, dma_addr) + offset, size, dir);
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(dma_sync_single_range_for_device);
|
||||||
|
|
||||||
void
|
void
|
||||||
dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents,
|
dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents,
|
||||||
|
@ -644,8 +648,6 @@ EXPORT_SYMBOL(dma_map_single);
|
||||||
EXPORT_SYMBOL(dma_unmap_single);
|
EXPORT_SYMBOL(dma_unmap_single);
|
||||||
EXPORT_SYMBOL(dma_map_sg);
|
EXPORT_SYMBOL(dma_map_sg);
|
||||||
EXPORT_SYMBOL(dma_unmap_sg);
|
EXPORT_SYMBOL(dma_unmap_sg);
|
||||||
EXPORT_SYMBOL(dma_sync_single_for_cpu);
|
|
||||||
EXPORT_SYMBOL(dma_sync_single_for_device);
|
|
||||||
EXPORT_SYMBOL(dma_sync_sg_for_cpu);
|
EXPORT_SYMBOL(dma_sync_sg_for_cpu);
|
||||||
EXPORT_SYMBOL(dma_sync_sg_for_device);
|
EXPORT_SYMBOL(dma_sync_sg_for_device);
|
||||||
EXPORT_SYMBOL(dmabounce_register_dev);
|
EXPORT_SYMBOL(dmabounce_register_dev);
|
||||||
|
|
|
@ -351,11 +351,12 @@ extern void dma_unmap_sg(struct device *, struct scatterlist *, int, enum dma_da
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dma_sync_single_for_cpu
|
* dma_sync_single_range_for_cpu
|
||||||
* @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
|
* @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
|
||||||
* @handle: DMA address of buffer
|
* @handle: DMA address of buffer
|
||||||
* @size: size of buffer to map
|
* @offset: offset of region to start sync
|
||||||
* @dir: DMA transfer direction
|
* @size: size of region to sync
|
||||||
|
* @dir: DMA transfer direction (same as passed to dma_map_single)
|
||||||
*
|
*
|
||||||
* Make physical memory consistent for a single streaming mode DMA
|
* Make physical memory consistent for a single streaming mode DMA
|
||||||
* translation after a transfer.
|
* translation after a transfer.
|
||||||
|
@ -368,25 +369,41 @@ extern void dma_unmap_sg(struct device *, struct scatterlist *, int, enum dma_da
|
||||||
* device again owns the buffer.
|
* device again owns the buffer.
|
||||||
*/
|
*/
|
||||||
#ifndef CONFIG_DMABOUNCE
|
#ifndef CONFIG_DMABOUNCE
|
||||||
|
static inline void
|
||||||
|
dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t handle,
|
||||||
|
unsigned long offset, size_t size,
|
||||||
|
enum dma_data_direction dir)
|
||||||
|
{
|
||||||
|
if (!arch_is_coherent())
|
||||||
|
dma_cache_maint(dma_to_virt(dev, handle) + offset, size, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
dma_sync_single_range_for_device(struct device *dev, dma_addr_t handle,
|
||||||
|
unsigned long offset, size_t size,
|
||||||
|
enum dma_data_direction dir)
|
||||||
|
{
|
||||||
|
if (!arch_is_coherent())
|
||||||
|
dma_cache_maint(dma_to_virt(dev, handle) + offset, size, dir);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
extern void dma_sync_single_range_for_cpu(struct device *, dma_addr_t, unsigned long, size_t, enum dma_data_direction);
|
||||||
|
extern void dma_sync_single_range_for_device(struct device *, dma_addr_t, unsigned long, size_t, enum dma_data_direction);
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle, size_t size,
|
dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle, size_t size,
|
||||||
enum dma_data_direction dir)
|
enum dma_data_direction dir)
|
||||||
{
|
{
|
||||||
if (!arch_is_coherent())
|
dma_sync_single_range_for_cpu(dev, handle, 0, size, dir);
|
||||||
dma_cache_maint(dma_to_virt(dev, handle), size, dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
dma_sync_single_for_device(struct device *dev, dma_addr_t handle, size_t size,
|
dma_sync_single_for_device(struct device *dev, dma_addr_t handle, size_t size,
|
||||||
enum dma_data_direction dir)
|
enum dma_data_direction dir)
|
||||||
{
|
{
|
||||||
if (!arch_is_coherent())
|
dma_sync_single_range_for_device(dev, handle, 0, size, dir);
|
||||||
dma_cache_maint(dma_to_virt(dev, handle), size, dir);
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
extern void dma_sync_single_for_cpu(struct device*, dma_addr_t, size_t, enum dma_data_direction);
|
|
||||||
extern void dma_sync_single_for_device(struct device*, dma_addr_t, size_t, enum dma_data_direction);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user