Skip to content

Commit 9327c7e

Browse files
tausenvinodkoul
authored andcommitted
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]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 7d3a3aa commit 9327c7e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/dma/dma-axi-dmac.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/module.h>
1919
#include <linux/of.h>
2020
#include <linux/of_dma.h>
21+
#include <linux/of_address.h>
2122
#include <linux/platform_device.h>
2223
#include <linux/regmap.h>
2324
#include <linux/slab.h>
@@ -55,6 +56,9 @@
5556
#define AXI_DMAC_DMA_DST_TYPE_GET(x) FIELD_GET(AXI_DMAC_DMA_DST_TYPE_MSK, x)
5657
#define AXI_DMAC_DMA_DST_WIDTH_MSK GENMASK(3, 0)
5758
#define AXI_DMAC_DMA_DST_WIDTH_GET(x) FIELD_GET(AXI_DMAC_DMA_DST_WIDTH_MSK, x)
59+
#define AXI_DMAC_REG_COHERENCY_DESC 0x14
60+
#define AXI_DMAC_DST_COHERENT_MSK BIT(0)
61+
#define AXI_DMAC_DST_COHERENT_GET(x) FIELD_GET(AXI_DMAC_DST_COHERENT_MSK, x)
5862

5963
#define AXI_DMAC_REG_IRQ_MASK 0x80
6064
#define AXI_DMAC_REG_IRQ_PENDING 0x84
@@ -979,6 +983,18 @@ static int axi_dmac_probe(struct platform_device *pdev)
979983

980984
axi_dmac_write(dmac, AXI_DMAC_REG_IRQ_MASK, 0x00);
981985

986+
if (of_dma_is_coherent(pdev->dev.of_node)) {
987+
ret = axi_dmac_read(dmac, AXI_DMAC_REG_COHERENCY_DESC);
988+
989+
if (version < ADI_AXI_PCORE_VER(4, 4, 'a') ||
990+
!AXI_DMAC_DST_COHERENT_GET(ret)) {
991+
dev_err(dmac->dma_dev.dev,
992+
"Coherent DMA not supported in hardware");
993+
ret = -EINVAL;
994+
goto err_clk_disable;
995+
}
996+
}
997+
982998
ret = dma_async_device_register(dma_dev);
983999
if (ret)
9841000
goto err_clk_disable;

0 commit comments

Comments
 (0)