DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nuno Sá via B4 Relay" <devnull+nuno.sa.analog.com@kernel.org>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH RFC 2/3] dmaengine: dma-axi-dmac: Switch to bitmap-based address width masks
Date: Tue, 16 Jun 2026 15:52:03 +0000	[thread overview]
Message-ID: <20260616155203.916701F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260616-dmaengine-support-wider-dma-masks-v1-2-da23a8dcb756@analog.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Undefined behavior in core DMA alignment evaluation due to `dma_dev->copy_align` being assigned a linear byte count instead of a log2 `enum dmaengine_alignment` value.
--

commit 2d09a8a33c5c8dffff764bd74b8c4ad0ea6d4224
Author: Nuno Sá <nuno.sa@analog.com>

dmaengine: dma-axi-dmac: Switch to bitmap-based address width masks

This commit advertises the source and destination bus widths through the new
address mask helpers instead of open-coding the legacy mask. It moves the
driver onto a representation that can express widths of 32 bytes and above.

> diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
> index d47ff27e1408f..19c258d511ca3 100644
> --- a/drivers/dma/dma-axi-dmac.c
> +++ b/drivers/dma/dma-axi-dmac.c
[ ... ]
> @@ -1262,8 +1262,12 @@ static int axi_dmac_probe(struct platform_device *pdev)
>  	dma_dev->device_terminate_all = axi_dmac_terminate_all;
>  	dma_dev->device_synchronize = axi_dmac_synchronize;
>  	dma_dev->dev = &pdev->dev;
> -	dma_dev->src_addr_widths = BIT(dmac->chan.src_width);
> -	dma_dev->dst_addr_widths = BIT(dmac->chan.dest_width);
> +	ret = dma_set_src_addr_mask(dma_dev, &dmac->chan.src_width, 1);
> +	if (ret)
> +		return ret;
> +	ret = dma_set_dst_addr_mask(dma_dev, &dmac->chan.dest_width, 1);
> +	if (ret)
> +		return ret;
>  	dma_dev->directions = BIT(dmac->chan.direction);
>  	dma_dev->residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
>  	dma_dev->max_sg_burst = 31; /* 31 SGs maximum in one burst */

[Severity: High]
This is a pre-existing issue, but does assigning a linear byte count to
copy_align cause undefined behavior now that bus widths of 32 bytes and
above are supported?

Looking further down in axi_dmac_probe():

	dma_dev->copy_align = (dmac->chan.address_align_mask + 1);

The copy_align field expects an enum dmaengine_alignment representing the
log2 of the required alignment bytes, rather than a linear byte count.

If a bus width of 32 bytes is used, copy_align evaluates to 32. When the
DMA core uses is_dma_copy_aligned(), it calculates (1 << copy_align) - 1.
Could shifting a 32-bit integer by 32 cause undefined behavior and wrap
around to 1 on some architectures, completely bypassing DMA alignment
constraints?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260616-dmaengine-support-wider-dma-masks-v1-0-da23a8dcb756@analog.com?part=2

  reply	other threads:[~2026-06-16 15:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 15:40 [PATCH RFC 0/3] dmaengine: Support address bus widths of 32 bytes and above Nuno Sá via B4 Relay
2026-06-16 15:40 ` [PATCH RFC 1/3] " Nuno Sá via B4 Relay
2026-06-16 15:55   ` sashiko-bot
2026-06-16 16:19   ` Frank Li
2026-06-16 15:40 ` [PATCH RFC 2/3] dmaengine: dma-axi-dmac: Switch to bitmap-based address width masks Nuno Sá via B4 Relay
2026-06-16 15:52   ` sashiko-bot [this message]
2026-06-16 16:23   ` Frank Li
2026-06-16 15:40 ` [PATCH RFC 3/3] iio: buffer-dmaengine: Use dma_slave_caps width accessors Nuno Sá via B4 Relay
2026-06-16 16:25   ` 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=20260616155203.916701F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=devnull+nuno.sa.analog.com@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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