dmaengine: axi-dmac: check cache coherency register
Subsystems (2)
PATCH v2 1/1 dmaengine: axi-dmac: check cache coherency register
Marking the DMA as cache coherent (dma-coherent in devicetree) is only safe with versions of axi_dmac that have this feature enabled.
Cc Lars-Peter Clausen <[email protected]>
Cc Vinod Koul <[email protected]>
Acked-by Nuno Sá <[email protected]>
Signed-off-by Mathias Tausen <[email protected]>
---
Changelog:
v2: Cc: Vinod, Acked-by: Nuno
For context, this patch is related to a recent change to the HDL:
https://github.com/analogdevicesinc/hdl/pull/925
And has been discussed in the Analog Devices tree:
https://github.com/analogdevicesinc/linux/pull/1908
drivers/dma/dma-axi-dmac.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/dma/dma-axi-dmac.c +16 -0
@@ -18,6 +18,7 @@#include <linux/module.h> #include <linux/of.h> #include <linux/of_dma.h> +#include <linux/of_address.h> #include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/slab.h>
@@ -55,6 +56,9 @@#define AXI_DMAC_DMA_DST_TYPE_GET (x) FIELD_GET(AXI_DMAC_DMA_DST_TYPE_MSK, x)#define AXI_DMAC_DMA_DST_WIDTH_MSK GENMASK(3, 0)#define AXI_DMAC_DMA_DST_WIDTH_GET (x) FIELD_GET(AXI_DMAC_DMA_DST_WIDTH_MSK, x) +#define AXI_DMAC_REG_COHERENCY_DESC 0x14 +#define AXI_DMAC_DST_COHERENT_MSK BIT(0) +#define AXI_DMAC_DST_COHERENT_GET (x) FIELD_GET(AXI_DMAC_DST_COHERENT_MSK, x)#define AXI_DMAC_REG_IRQ_MASK 0x80#define AXI_DMAC_REG_IRQ_PENDING 0x84
@@ -979,6 +983,18 @@ static int axi_dmac_probe(struct platform_device *pdev)axi_dmac_write (dmac,AXI_DMAC_REG_IRQ_MASK ,0x00 ); +if (of_dma_is_coherent (pdev->dev.of_node)) { + ret =axi_dmac_read (dmac,AXI_DMAC_REG_COHERENCY_DESC ); + +if (version <ADI_AXI_PCORE_VER (4 ,4 ,'a' ) || + !AXI_DMAC_DST_COHERENT_GET (ret)) { +dev_err (dmac->dma_dev.dev, +"Coherent DMA not supported in hardware" ); + ret = -EINVAL ; + goto err_clk_disable; + } + } + ret =dma_async_device_register (dma_dev);if (ret) goto err_clk_disable;
Signature · 1 line
2.36.1
Quoted 2 lines · Mathias Tausen
Marking the DMA as cache coherent (dma-coherent in devicetree) is only safe with versions of
axi_dmacthat have this feature enabled.
Applied, thanks
Signature · 1 line
~Vinod