DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nuno Sá" <nuno.sa@analog.com>
Cc: Frank.Li@kernel.org, dmaengine@vger.kernel.org, vkoul@kernel.org
Subject: Re: [PATCH 1/9] dmaengine: Support bus widths of 32 bytes and above
Date: Thu, 30 Jul 2026 14:38:33 +0000	[thread overview]
Message-ID: <20260730143834.36A071F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260730-dmaengine-support-wider-dma-masks-v1-1-3732f1f9d9ca@analog.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Legacy `device_caps()` callbacks cause desynchronization between the legacy `u32` capability masks and the newly introduced bitmap fields in `struct dma_slave_caps`, leading to unsupported bus widths being falsely advertised to consumers.
--

--- Patch [1]: [PATCH 1/9] dmaengine: Support bus widths of 32 bytes and above ---
commit 2d5a426ace9eaa0310bd634be5edc8e4ed522c24
Author: Nuno Sá <nuno.sa@analog.com>

dmaengine: Support bus widths of 32 bytes and above

Introduces bitmap-based bus width capabilities that span the full enum
range to support widths of 32 bytes and above. Retains the legacy u32
fields alongside the new bitmaps to allow incremental conversion of
producers.

> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index 9049171df8578..7be23ba769d0d 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -593,7 +593,25 @@ int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps)
[ ... ]
>  	caps->dst_addr_widths = device->dst_addr_widths;
> +	if (bitmap_empty(device->dst_bus_widths, DMA_SLAVE_BUSWIDTH_MAX)) {
> +		bitmap_zero(caps->dst_bus_widths, DMA_SLAVE_BUSWIDTH_MAX);
> +		bitmap_from_arr32(caps->dst_bus_widths,
> +				  &device->dst_addr_widths, 32);
> +	} else {
> +		bitmap_copy(caps->dst_bus_widths, device->dst_bus_widths,
> +			    DMA_SLAVE_BUSWIDTH_MAX);
> +	}
> +
>  	caps->directions = device->directions;
>  	caps->min_burst = device->min_burst;
>  	caps->max_burst = device->max_burst;

[Severity: High]
Does this setup cause a desynchronization between the new bitmaps and the
legacy u32 fields after device_caps() is invoked?

Looking at the end of dma_get_slave_caps() in drivers/dma/dmaengine.c:

	if (device->device_caps)
		device->device_caps(chan, caps);

	return 0;

Legacy drivers dynamically modify the u32 fields in their device_caps()
callback. For example, stm32_dma3_caps() in drivers/dma/stm32/stm32-dma3.c
modifies the capabilities:

	caps->src_addr_widths &= ~BIT(DMA_SLAVE_BUSWIDTH_8_BYTES);

Since the new bitmaps are initialized before device_caps() is called, and
there is no re-synchronization of the legacy u32 fields back to the bitmaps
after it returns, won't consumers querying capabilities using new helpers
like dma_slave_caps_intersect_widths() read the unmodified, stale bitmaps?

Could this result in consumer drivers configuring a DMA transfer with an
unsupported bus width?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260730-dmaengine-support-wider-dma-masks-v1-0-3732f1f9d9ca@analog.com?part=1

  reply	other threads:[~2026-07-30 14:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 14:23 [PATCH 0/9] dmaengine: Support bus widths of 32 bytes and above Nuno Sá via B4 Relay
2026-07-30 14:23 ` [PATCH 1/9] " Nuno Sá via B4 Relay
2026-07-30 14:38   ` sashiko-bot [this message]
2026-07-30 19:16   ` Frank Li
2026-07-30 14:23 ` [PATCH 2/9] dmaengine: dma-axi-dmac: Use bus width capability helpers Nuno Sá via B4 Relay
2026-07-30 14:39   ` sashiko-bot
2026-07-30 19:23   ` Frank Li
2026-07-30 14:23 ` [PATCH 3/9] dmaengine: dw-axi-dmac: " Nuno Sá via B4 Relay
2026-07-30 14:36   ` sashiko-bot
2026-07-30 19:24   ` Frank Li
2026-07-30 14:23 ` [PATCH 4/9] dmaengine: qcom: gpi: " Nuno Sá via B4 Relay
2026-07-30 14:43   ` sashiko-bot
2026-07-30 19:25   ` Frank Li
2026-07-30 14:23 ` [PATCH 5/9] dmaengine: stm32-dma3: " Nuno Sá via B4 Relay
2026-07-30 14:35   ` sashiko-bot
2026-07-30 19:26   ` Frank Li
2026-07-30 14:23 ` [PATCH 6/9] iio: buffer-dmaengine: Use dma_slave_caps bus width accessors Nuno Sá via B4 Relay
2026-07-30 19:27   ` Frank Li
2026-07-30 14:23 ` [PATCH 7/9] ALSA: pcm_dmaengine: Use dma_slave_caps bus width helpers Nuno Sá via B4 Relay
2026-07-30 19:30   ` Frank Li
2026-07-30 14:23 ` [PATCH 8/9] spi: dw: " Nuno Sá via B4 Relay
2026-07-30 14:43   ` sashiko-bot
2026-07-30 19:31   ` Frank Li
2026-07-30 14:23 ` [PATCH 9/9] dmaengine: Drop legacy bus width fields from dma_slave_caps Nuno Sá via B4 Relay
2026-07-30 19:05 ` [PATCH 0/9] dmaengine: Support bus widths of 32 bytes and above 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=20260730143834.36A071F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --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