From: andrea.merello@gmail.com (Andrea Merello)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/6] dmaengine: xilinx_dma: fix hardcoded maximum transfer length may be wrong
Date: Wed, 20 Jun 2018 10:36:51 +0200 [thread overview]
Message-ID: <20180620083653.17010-4-andrea.merello@gmail.com> (raw)
In-Reply-To: <20180620083653.17010-1-andrea.merello@gmail.com>
The maximum transfer length is currently hardcoded in the driver, but
it depends by how the soft-IP is actually configured.
This seems to affect also max possible length for SG transfers.
This patch introduce a new DT property in order to operate with proper
maximum transfer length.
Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
---
drivers/dma/xilinx/xilinx_dma.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index cf12f7147f07..bdbc8ba9092a 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -439,6 +439,7 @@ struct xilinx_dma_device {
struct clk *rxs_clk;
u32 nr_channels;
u32 chan_id;
+ int max_transfer;
};
/* Macros */
@@ -1806,8 +1807,8 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_slave_sg(
* the next chuck start address is aligned
*/
copy = sg_dma_len(sg) - sg_used;
- if (copy > XILINX_DMA_MAX_TRANS_LEN)
- copy = XILINX_DMA_MAX_TRANS_LEN &
+ if (copy > chan->xdev->max_transfer)
+ copy = chan->xdev->max_transfer &
chan->copy_mask;
hw = &segment->hw;
@@ -1914,8 +1915,8 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_dma_cyclic(
* the next chuck start address is aligned
*/
copy = period_len - sg_used;
- if (copy > XILINX_DMA_MAX_TRANS_LEN)
- copy = XILINX_DMA_MAX_TRANS_LEN &
+ if (copy > chan->xdev->max_transfer)
+ copy = chan->xdev->max_transfer &
chan->copy_mask;
hw = &segment->hw;
@@ -2594,7 +2595,7 @@ static int xilinx_dma_probe(struct platform_device *pdev)
struct xilinx_dma_device *xdev;
struct device_node *child, *np = pdev->dev.of_node;
struct resource *io;
- u32 num_frames, addr_width;
+ u32 num_frames, addr_width, lenreg_width;
int i, err;
/* Allocate and initialize the DMA engine structure */
@@ -2625,9 +2626,18 @@ static int xilinx_dma_probe(struct platform_device *pdev)
return PTR_ERR(xdev->regs);
/* Retrieve the DMA engine properties from the device tree */
- xdev->has_sg = of_property_read_bool(node, "xlnx,include-sg");
- if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA)
+
+ if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) {
xdev->mcdma = of_property_read_bool(node, "xlnx,mcdma");
+ err = of_property_read_u32(node, "xlnx,lengthregwidth",
+ &lenreg_width);
+ if (err < 0) {
+ dev_err(xdev->dev,
+ "missing xlnx,lengthregwidth property\n");
+ return err;
+ }
+ xdev->max_transfer = GENMASK(lenreg_width - 1, 0);
+ }
if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) {
err = of_property_read_u32(node, "xlnx,num-fstores",
--
2.17.1
next prev parent reply other threads:[~2018-06-20 8:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 8:36 [PATCH 1/6] dmaengine: xilinx_dma: fix splitting transfer causes misalignments Andrea Merello
2018-06-20 8:36 ` [PATCH 2/6] dmaengine: xilinx_dma: fix completion callback is not invoked for each DMA operation Andrea Merello
2018-06-20 12:36 ` Radhey Shyam Pandey
2018-06-20 13:32 ` Andrea Merello
2018-06-21 13:46 ` Radhey Shyam Pandey
2018-06-20 8:36 ` [PATCH 3/6] dt-bindings: xilinx_dma: add required xlnx, lengthregwidth property Andrea Merello
2018-06-20 13:42 ` [PATCH 3/6] dt-bindings: xilinx_dma: add required xlnx,lengthregwidth property Radhey Shyam Pandey
2018-06-20 14:37 ` Radhey Shyam Pandey
2018-06-20 8:36 ` Andrea Merello [this message]
2018-06-20 8:36 ` [PATCH 5/6] dmaengine: xilinx_dma: autodetect whether the HW supports scatter-gather Andrea Merello
2018-06-20 14:43 ` Radhey Shyam Pandey
2018-06-20 14:57 ` Andrea Merello
2018-06-20 8:36 ` [PATCH 6/6] dt-bindings: xilinx_dma: drop has-sg property Andrea Merello
2018-06-20 11:37 ` [PATCH 1/6] dmaengine: xilinx_dma: fix splitting transfer causes misalignments Radhey Shyam Pandey
2018-06-20 13:15 ` Andrea Merello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180620083653.17010-4-andrea.merello@gmail.com \
--to=andrea.merello@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).