From: Sergey Matsievskiy <matsievskiysv@gmail.com>
To: dmaengine@vger.kernel.org
Cc: lars@metafoo.de, vkoul@kernel.org, Frank.Li@kernel.org,
linux-kernel@vger.kernel.org,
Sergey Matsievskiy <matsievskiysv@gmail.com>
Subject: [PATCH] dmaengine: axi-dmac: fix incorrect segment size calculation
Date: Thu, 5 Nov 2026 16:15:47 +0300 [thread overview]
Message-ID: <20261105131547.305510-1-matsievskiysv@gmail.com> (raw)
When chan->max_length has a value of 0xffffffff (which is a possible IP
configuration), DIV_ROUND_UP returns 0, resulting in incorrect number of
segments calculation. Fix this by using DIV_ROUND_UP_ULL division
function.
Signed-off-by: Sergey Matsievskiy <matsievskiysv@gmail.com>
---
drivers/dma/dma-axi-dmac.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
index 02acde918117..0a308630e542 100644
--- a/drivers/dma/dma-axi-dmac.c
+++ b/drivers/dma/dma-axi-dmac.c
@@ -707,7 +707,7 @@ static struct axi_dmac_sg *axi_dmac_fill_linear_sg(struct axi_dmac_chan *chan,
unsigned int len;
/* Split into multiple equally sized segments if necessary */
- num_segments = DIV_ROUND_UP(period_len, chan->max_length);
+ num_segments = DIV_ROUND_UP_ULL(period_len, chan->max_length);
segment_size = DIV_ROUND_UP(period_len, num_segments);
/* Take care of alignment */
segment_size = ((segment_size - 1) | chan->length_align_mask) + 1;
@@ -753,7 +753,7 @@ axi_dmac_prep_peripheral_dma_vec(struct dma_chan *c, const struct dma_vec *vecs,
return NULL;
for (i = 0; i < nb; i++)
- num_sgs += DIV_ROUND_UP(vecs[i].len, chan->max_length);
+ num_sgs += DIV_ROUND_UP_ULL(vecs[i].len, chan->max_length);
desc = axi_dmac_alloc_desc(chan, num_sgs);
if (!desc)
@@ -840,7 +840,7 @@ static struct dma_async_tx_descriptor *axi_dmac_prep_dma_cyclic(
return NULL;
num_periods = buf_len / period_len;
- num_segments = DIV_ROUND_UP(period_len, chan->max_length);
+ num_segments = DIV_ROUND_UP_ULL(period_len, chan->max_length);
num_sgs = num_periods * num_segments;
desc = axi_dmac_alloc_desc(chan, num_sgs);
--
2.47.3
next reply other threads:[~2026-11-05 13:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 13:15 Sergey Matsievskiy [this message]
2026-11-05 17:16 ` Frank Li
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=20261105131547.305510-1-matsievskiysv@gmail.com \
--to=matsievskiysv@gmail.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®