Commit 9ed9e7e5 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ppc64: DMA API updates

From: Anton Blanchard <anton@samba.org>

DMA API updates, in particular adding the new cache flush interfaces.
parent b7ceb145
......@@ -131,27 +131,3 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
BUG();
}
EXPORT_SYMBOL(dma_unmap_sg);
void dma_sync_single(struct device *dev, dma_addr_t dma_handle, size_t size,
enum dma_data_direction direction)
{
if (dev->bus == &pci_bus_type)
pci_dma_sync_single(to_pci_dev(dev), dma_handle, size, (int)direction);
else if (dev->bus == &vio_bus_type)
vio_dma_sync_single(to_vio_dev(dev), dma_handle, size, direction);
else
BUG();
}
EXPORT_SYMBOL(dma_sync_single);
void dma_sync_sg(struct device *dev, struct scatterlist *sg, int nelems,
enum dma_data_direction direction)
{
if (dev->bus == &pci_bus_type)
pci_dma_sync_sg(to_pci_dev(dev), sg, nelems, (int)direction);
else if (dev->bus == &vio_bus_type)
vio_dma_sync_sg(to_vio_dev(dev), sg, nelems, direction);
else
BUG();
}
EXPORT_SYMBOL(dma_sync_sg);
......@@ -36,10 +36,43 @@ extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
enum dma_data_direction direction);
extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
int nhwentries, enum dma_data_direction direction);
extern void dma_sync_single(struct device *dev, dma_addr_t dma_handle,
size_t size, enum dma_data_direction direction);
extern void dma_sync_sg(struct device *dev, struct scatterlist *sg, int nelems,
enum dma_data_direction direction);
static inline void
dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
enum dma_data_direction direction)
{
BUG_ON(direction == DMA_NONE);
/* nothing to do */
}
static inline void
dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
enum dma_data_direction direction)
{
BUG_ON(direction == DMA_NONE);
/* nothing to do */
}
static inline void
dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
enum dma_data_direction direction)
{
BUG_ON(direction == DMA_NONE);
/* nothing to do */
}
static inline void
dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
enum dma_data_direction direction)
{
BUG_ON(direction == DMA_NONE);
/* nothing to do */
}
static inline int dma_mapping_error(dma_addr_t dma_addr)
{
return (dma_addr == DMA_ERROR_CODE);
}
/* Now for the API extensions over the pci_ one */
......@@ -56,27 +89,29 @@ dma_get_cache_alignment(void)
}
static inline void
dma_sync_single_range(struct device *dev, dma_addr_t dma_handle,
unsigned long offset, size_t size,
enum dma_data_direction direction)
dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
unsigned long offset, size_t size,
enum dma_data_direction direction)
{
/* just sync everything, that's all the pci API can do */
dma_sync_single(dev, dma_handle, offset+size, direction);
BUG_ON(direction == DMA_NONE);
/* nothing to do */
}
static inline void
dma_cache_sync(void *vaddr, size_t size,
enum dma_data_direction direction)
dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
unsigned long offset, size_t size,
enum dma_data_direction direction)
{
/* could define this in terms of the dma_cache ... operations,
* but if you get this on a platform, you should convert the platform
* to using the generic device DMA API */
BUG();
BUG_ON(direction == DMA_NONE);
/* nothing to do */
}
static inline int dma_mapping_error(dma_addr_t dma_addr)
static inline void
dma_cache_sync(void *vaddr, size_t size,
enum dma_data_direction direction)
{
return (dma_addr == DMA_ERROR_CODE);
BUG_ON(direction == DMA_NONE);
/* nothing to do */
}
#endif /* _ASM_DMA_MAPPING_H */
......@@ -78,23 +78,10 @@ static inline int vio_dma_supported(struct vio_dev *hwdev, u64 mask)
vio_map_single(dev, (page_address(page) + (off)), size, dir)
#define vio_unmap_page(dev,addr,sz,dir) vio_unmap_single(dev,addr,sz,dir)
static inline void vio_dma_sync_single(struct vio_dev *hwdev,
dma_addr_t dma_handle, size_t size,
enum dma_data_direction direction)
{
BUG_ON(direction == DMA_NONE);
/* nothing to do */
}
static inline void vio_dma_sync_sg(struct vio_dev *hwdev,
struct scatterlist *sg, int nelems,
enum dma_data_direction direction)
static inline int vio_set_dma_mask(struct vio_dev *dev, u64 mask)
{
BUG_ON(direction == DMA_NONE);
/* nothing to do */
return -EIO;
}
static inline int vio_set_dma_mask(struct vio_dev *dev, u64 mask) { return -EIO; }
extern struct bus_type vio_bus_type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment