Skip to content

Commit ae80969

Browse files
radheyxilinxvinodkoul
authored andcommitted
dmaengine: xilinx_dma: program hardware supported buffer length
AXI-DMA IP supports configurable (c_sg_length_width) buffer length register width, hence read buffer length (xlnx,sg-length-width) DT property and ensure that driver doesn't program buffer length exceeding the supported limit. For VDMA and CDMA there is no change. Cc: Rob Herring <robh+dt@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: devicetree@vger.kernel.org Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Andrea Merello <andrea.merello@gmail.com> [rebase, reword] Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 7df54db commit ae80969

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

drivers/dma/xilinx/xilinx_dma.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@
161161
#define XILINX_DMA_REG_BTT 0x28
162162

163163
/* AXI DMA Specific Masks/Bit fields */
164-
#define XILINX_DMA_MAX_TRANS_LEN GENMASK(22, 0)
164+
#define XILINX_DMA_MAX_TRANS_LEN_MIN 8
165+
#define XILINX_DMA_MAX_TRANS_LEN_MAX 23
166+
#define XILINX_DMA_V2_MAX_TRANS_LEN_MAX 26
165167
#define XILINX_DMA_CR_COALESCE_MAX GENMASK(23, 16)
166168
#define XILINX_DMA_CR_CYCLIC_BD_EN_MASK BIT(4)
167169
#define XILINX_DMA_CR_COALESCE_SHIFT 16
@@ -2626,7 +2628,7 @@ static int xilinx_dma_probe(struct platform_device *pdev)
26262628
struct xilinx_dma_device *xdev;
26272629
struct device_node *child, *np = pdev->dev.of_node;
26282630
struct resource *io;
2629-
u32 num_frames, addr_width;
2631+
u32 num_frames, addr_width, len_width;
26302632
int i, err;
26312633

26322634
/* Allocate and initialize the DMA engine structure */
@@ -2658,10 +2660,24 @@ static int xilinx_dma_probe(struct platform_device *pdev)
26582660

26592661
/* Retrieve the DMA engine properties from the device tree */
26602662
xdev->has_sg = of_property_read_bool(node, "xlnx,include-sg");
2661-
xdev->max_buffer_len = XILINX_DMA_MAX_TRANS_LEN;
2663+
xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0);
26622664

2663-
if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA)
2665+
if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) {
26642666
xdev->mcdma = of_property_read_bool(node, "xlnx,mcdma");
2667+
if (!of_property_read_u32(node, "xlnx,sg-length-width",
2668+
&len_width)) {
2669+
if (len_width < XILINX_DMA_MAX_TRANS_LEN_MIN ||
2670+
len_width > XILINX_DMA_V2_MAX_TRANS_LEN_MAX) {
2671+
dev_warn(xdev->dev,
2672+
"invalid xlnx,sg-length-width property value. Using default width\n");
2673+
} else {
2674+
if (len_width > XILINX_DMA_MAX_TRANS_LEN_MAX)
2675+
dev_warn(xdev->dev, "Please ensure that IP supports buffer length > 23 bits\n");
2676+
xdev->max_buffer_len =
2677+
GENMASK(len_width - 1, 0);
2678+
}
2679+
}
2680+
}
26652681

26662682
if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) {
26672683
err = of_property_read_u32(node, "xlnx,num-fstores",

0 commit comments

Comments
 (0)