From: Tan En De <endeneer@gmail.com>
To: dmaengine@vger.kernel.org
Cc: Eugeniy.Paltsev@synopsys.com, vkoul@kernel.org,
leyfoon.tan@starfivetech.com, jeeheng.sia@starfivetech.com,
jiajie.ho@starfivetech.com, Tan En De <ende.tan@starfivetech.com>
Subject: [v4,1/1] dmaengine: dw-axi-dmac: Support src_maxburst and dst_maxburst
Date: Wed, 8 May 2024 09:42:16 +0800 [thread overview]
Message-ID: <20240508014217.1411-1-ende.tan@starfivetech.com> (raw)
Current implementation has hardcoded CHx_CTL.SRC_MSIZE and
CHx_CTL.DST_MSIZE with a constant, namely DWAXIDMAC_BURST_TRANS_LEN_4.
However, to support hardware with different source/destination burst
transaction length, the aforementioned values shall be configurable
based on dma_slave_config set by client driver.
So, this commit is to allow client driver to configure
- CHx_CTL.SRC_MSIZE via dma_slave_config.src_maxburst
- CHx_CTL.DST_MSIZE via dma_slave_config.dst_maxburst
Signed-off-by: Tan En De <ende.tan@starfivetech.com>
---
v3 -> v4: Update patch after rebase with dmaengine/next
---
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 18 +++++++++++++++---
drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 3 ++-
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index fffafa86d964..18ce7d64958b 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -657,7 +657,7 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
size_t axi_block_ts;
size_t block_ts;
u32 ctllo, ctlhi;
- u32 burst_len;
+ u32 burst_len, src_burst_trans_len, dst_burst_trans_len;
axi_block_ts = chan->chip->dw->hdata->block_size[chan->id];
@@ -721,8 +721,20 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
hw_desc->lli->block_ts_lo = cpu_to_le32(block_ts - 1);
- ctllo |= DWAXIDMAC_BURST_TRANS_LEN_4 << CH_CTL_L_DST_MSIZE_POS |
- DWAXIDMAC_BURST_TRANS_LEN_4 << CH_CTL_L_SRC_MSIZE_POS;
+ dst_burst_trans_len = chan->config.dst_maxburst ?
+ __ffs(chan->config.dst_maxburst) - 1 :
+ DWAXIDMAC_BURST_TRANS_LEN_4;
+ if (dst_burst_trans_len > DWAXIDMAC_BURST_TRANS_LEN_MAX)
+ return -EINVAL;
+ ctllo |= dst_burst_trans_len << CH_CTL_L_DST_MSIZE_POS;
+
+ src_burst_trans_len = chan->config.src_maxburst ?
+ __ffs(chan->config.src_maxburst) - 1 :
+ DWAXIDMAC_BURST_TRANS_LEN_4;
+ if (src_burst_trans_len > DWAXIDMAC_BURST_TRANS_LEN_MAX)
+ return -EINVAL;
+ ctllo |= src_burst_trans_len << CH_CTL_L_SRC_MSIZE_POS;
+
hw_desc->lli->ctl_lo = cpu_to_le32(ctllo);
set_desc_src_master(hw_desc);
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
index b842e6a8d90d..d76d3d88ceb6 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
@@ -270,7 +270,8 @@ enum {
DWAXIDMAC_BURST_TRANS_LEN_128,
DWAXIDMAC_BURST_TRANS_LEN_256,
DWAXIDMAC_BURST_TRANS_LEN_512,
- DWAXIDMAC_BURST_TRANS_LEN_1024
+ DWAXIDMAC_BURST_TRANS_LEN_1024,
+ DWAXIDMAC_BURST_TRANS_LEN_MAX = DWAXIDMAC_BURST_TRANS_LEN_1024
};
#define CH_CTL_L_DST_WIDTH_POS 11
--
2.34.1
reply other threads:[~2024-05-08 1:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240508014217.1411-1-ende.tan@starfivetech.com \
--to=endeneer@gmail.com \
--cc=Eugeniy.Paltsev@synopsys.com \
--cc=dmaengine@vger.kernel.org \
--cc=ende.tan@starfivetech.com \
--cc=jeeheng.sia@starfivetech.com \
--cc=jiajie.ho@starfivetech.com \
--cc=leyfoon.tan@starfivetech.com \
--cc=vkoul@kernel.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).