Add set_arch_dma_coherent_ops() for architectures to setup coherent dma_ops. Update dt_dma_configure() to look for a "dma-coherent" property in the device's node, and its ancestors If this property is found, we call set_arch_dma_coherent_ops() per device to apply coherent DMA configuartion. The set_arch_dma_coherent_ops() is declared as __weak and it's expected that the arch's needing it will imlepment it. Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Russell King <linux@xxxxxxxxxxxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Olof Johansson <olof@xxxxxxxxx> Cc: Grant Likely <grant.likely@xxxxxxxxxx> Cc: Rob Herring <robh+dt@xxxxxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Linus Walleij <linus.walleij@xxxxxxxxxx> Signed-off-by: Grygorii Strashko <grygorii.strashko@xxxxxx> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@xxxxxx> --- drivers/of/platform.c | 5 +++++ include/linux/dma-mapping.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 53bb12f..272e390 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -255,6 +255,11 @@ static void dt_dma_configure(struct device *dev) dev_err(dev, "failed to set coherent DMA mask %pad\n", &dma_mask); } + + if (of_dma_is_coherent(dev->of_node)) { + set_arch_dma_coherent_ops(dev); + dev_dbg(dev, "device is dma coherent\n"); + } } /** diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index fd4aee2..c7d9b1b 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -123,6 +123,13 @@ static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask) extern u64 dma_get_required_mask(struct device *dev); +#ifndef set_arch_dma_coherent_ops +static inline int set_arch_dma_coherent_ops(struct device *dev) +{ + return 0; +} +#endif + static inline unsigned int dma_get_max_seg_size(struct device *dev) { return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html