From: Frank Li <Frank.li@oss.nxp.com>
To: Sergey Matsievskiy <matsievskiysv@gmail.com>
Cc: dmaengine@vger.kernel.org, lars@metafoo.de, vkoul@kernel.org,
Frank.Li@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: axi-dmac: fix incorrect segment size calculation
Date: Thu, 5 Nov 2026 11:16:04 -0600 [thread overview]
Message-ID: <auy51OzXH3VKZk8a@SMW015318> (raw)
In-Reply-To: <20261105131547.305510-1-matsievskiysv@gmail.com>
On Thu, Nov 05, 2026 at 04:15:47PM +0300, Sergey Matsievskiy wrote:
> [You don't often get email from matsievskiysv@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> 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>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.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
>
prev parent reply other threads:[~2026-11-05 17:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 13:15 Sergey Matsievskiy
2026-11-05 17:16 ` Frank Li [this message]
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=auy51OzXH3VKZk8a@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=matsievskiysv@gmail.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
all inboxes | Powered by JetHome®