forked from luck/tmp_suning_uos_patched
20d330645c
On some MIPS systems, a subset of devices may have DMA coherent with CPU caches. For example in systems including a MIPS I/O Coherence Unit (IOCU), some devices may be connected to that IOCU whilst others are not. Prior to this patch, we have a plat_device_is_coherent() function but no implementation which does anything besides return a global true or false, optionally chosen at runtime. For devices such as those described above this is insufficient. Fix this by tracking DMA coherence on a per-device basis with a dma_coherent field in struct dev_archdata. Setting this from arch_setup_dma_ops() takes care of devices which set the dma-coherent property via device tree, and any PCI devices beneath a bridge described in DT, automatically. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/14349/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
#ifndef _ASM_DMA_MAPPING_H
|
|
#define _ASM_DMA_MAPPING_H
|
|
|
|
#include <linux/scatterlist.h>
|
|
#include <asm/dma-coherence.h>
|
|
#include <asm/cache.h>
|
|
|
|
#ifndef CONFIG_SGI_IP27 /* Kludge to fix 2.6.39 build for IP27 */
|
|
#include <dma-coherence.h>
|
|
#endif
|
|
|
|
extern struct dma_map_ops *mips_dma_map_ops;
|
|
|
|
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
|
|
{
|
|
if (dev && dev->archdata.dma_ops)
|
|
return dev->archdata.dma_ops;
|
|
else
|
|
return mips_dma_map_ops;
|
|
}
|
|
|
|
static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
|
|
{
|
|
if (!dev->dma_mask)
|
|
return false;
|
|
|
|
return addr + size <= *dev->dma_mask;
|
|
}
|
|
|
|
static inline void dma_mark_clean(void *addr, size_t size) {}
|
|
|
|
extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
|
|
enum dma_data_direction direction);
|
|
|
|
#define arch_setup_dma_ops arch_setup_dma_ops
|
|
static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
|
|
u64 size, const struct iommu_ops *iommu,
|
|
bool coherent)
|
|
{
|
|
#ifdef CONFIG_DMA_PERDEV_COHERENT
|
|
dev->archdata.dma_coherent = coherent;
|
|
#endif
|
|
}
|
|
|
|
#endif /* _ASM_DMA_MAPPING_H */
|