Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Radhey Shyam Pandey and committed by
Vinod Koul
ae809690 7df54dbe

+20 -4
+20 -4
drivers/dma/xilinx/xilinx_dma.c
··· 161 161 #define XILINX_DMA_REG_BTT 0x28 162 162 163 163 /* 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 165 167 #define XILINX_DMA_CR_COALESCE_MAX GENMASK(23, 16) 166 168 #define XILINX_DMA_CR_CYCLIC_BD_EN_MASK BIT(4) 167 169 #define XILINX_DMA_CR_COALESCE_SHIFT 16 ··· 2628 2626 struct xilinx_dma_device *xdev; 2629 2627 struct device_node *child, *np = pdev->dev.of_node; 2630 2628 struct resource *io; 2631 - u32 num_frames, addr_width; 2629 + u32 num_frames, addr_width, len_width; 2632 2630 int i, err; 2633 2631 2634 2632 /* Allocate and initialize the DMA engine structure */ ··· 2660 2658 2661 2659 /* Retrieve the DMA engine properties from the device tree */ 2662 2660 xdev->has_sg = of_property_read_bool(node, "xlnx,include-sg"); 2663 - xdev->max_buffer_len = XILINX_DMA_MAX_TRANS_LEN; 2661 + xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0); 2664 2662 2665 - if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) 2663 + if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { 2666 2664 xdev->mcdma = of_property_read_bool(node, "xlnx,mcdma"); 2665 + if (!of_property_read_u32(node, "xlnx,sg-length-width", 2666 + &len_width)) { 2667 + if (len_width < XILINX_DMA_MAX_TRANS_LEN_MIN || 2668 + len_width > XILINX_DMA_V2_MAX_TRANS_LEN_MAX) { 2669 + dev_warn(xdev->dev, 2670 + "invalid xlnx,sg-length-width property value. Using default width\n"); 2671 + } else { 2672 + if (len_width > XILINX_DMA_MAX_TRANS_LEN_MAX) 2673 + dev_warn(xdev->dev, "Please ensure that IP supports buffer length > 23 bits\n"); 2674 + xdev->max_buffer_len = 2675 + GENMASK(len_width - 1, 0); 2676 + } 2677 + } 2678 + } 2667 2679 2668 2680 if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) { 2669 2681 err = of_property_read_u32(node, "xlnx,num-fstores",