From: "Nuno Sá" <nuno.sa@analog.com>
To: linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
linux-arm-msm@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org, linux-iio@vger.kernel.org,
linux-sound@vger.kernel.org, linux-spi@vger.kernel.org
Cc: "Vinod Koul" <vkoul@kernel.org>, "Frank Li" <Frank.Li@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Eugeniy Paltsev" <Eugeniy.Paltsev@synopsys.com>,
"Amélie Delaunay" <amelie.delaunay@foss.st.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"Mark Brown" <broonie@kernel.org>, "Frank Li" <Frank.Li@nxp.com>
Subject: [PATCH v7 7/9] ALSA: pcm_dmaengine: Use dma_slave_caps bus width helpers
Date: Tue, 24 Nov 2026 11:19:47 +0000 [thread overview]
Message-ID: <20261124-dmaengine-support-wider-dma-masks-v7-7-5d57df2c3ebd@analog.com> (raw)
In-Reply-To: <20261124-dmaengine-support-wider-dma-masks-v7-0-5d57df2c3ebd@analog.com>
Use the dma_slave_caps bus width helpers instead of reading the legacy
src_addr_widths and dst_addr_widths masks directly.
Keep the existing default assumption of 1, 2 and 4 byte widths when the
DMA channel does not report slave capabilities.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
Andy, I decided to not go with the implicit call to bitmap_zero() in
_set() and _set_many(). The reason is that almost all the users are dma
controllers where the bitmap is initialized (given it's part of the
dma_device struct) so it seems unnecessary churn just to make one caller
"happy". These APIs also follow bitmap (set_bit() included) semantics so
it makes sense to me to leave as-is. Added a note on the kernel doc
though.
And it's easier to add the implicit call in the future (if it proves
necessary). Removing it, not so easy...
---
sound/core/pcm_dmaengine.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c
index 1306b04be171..c859e98e944d 100644
--- a/sound/core/pcm_dmaengine.c
+++ b/sound/core/pcm_dmaengine.c
@@ -408,16 +408,24 @@ int snd_dmaengine_pcm_refine_runtime_hwparams(
struct snd_pcm_hardware *hw,
struct dma_chan *chan)
{
+ enum dma_slave_buswidth default_widths[] = {
+ DMA_SLAVE_BUSWIDTH_1_BYTE,
+ DMA_SLAVE_BUSWIDTH_2_BYTES,
+ DMA_SLAVE_BUSWIDTH_4_BYTES,
+ };
struct dma_slave_caps dma_caps;
- u32 addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
- BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
- BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
+ dma_buswidth_mask_t bus_widths = {};
snd_pcm_format_t i;
int ret = 0;
if (!hw || !chan || !dma_data)
return -EINVAL;
+ ret = dmaengine_bus_width_set_many(&bus_widths, default_widths,
+ ARRAY_SIZE(default_widths));
+ if (ret)
+ return ret;
+
ret = dma_get_slave_caps(chan, &dma_caps);
if (ret == 0) {
if (dma_caps.cmd_pause && dma_caps.cmd_resume)
@@ -426,9 +434,9 @@ int snd_dmaengine_pcm_refine_runtime_hwparams(
hw->info |= SNDRV_PCM_INFO_BATCH;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- addr_widths = dma_caps.dst_addr_widths;
+ dmaengine_bus_width_copy(&bus_widths, &dma_caps.dst_bus_widths);
else
- addr_widths = dma_caps.src_addr_widths;
+ dmaengine_bus_width_copy(&bus_widths, &dma_caps.src_bus_widths);
}
/*
@@ -460,7 +468,7 @@ int snd_dmaengine_pcm_refine_runtime_hwparams(
case 24:
case 32:
case 64:
- if (addr_widths & (1 << (bits / 8)))
+ if (dmaengine_bus_width_test(&bus_widths, bits / 8))
hw->formats |= pcm_format_to_bits(i);
break;
default:
--
2.56.0
next prev parent reply other threads:[~2026-11-24 11:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 11:19 [PATCH v7 0/9] dmaengine: Support bus widths of 32 bytes and above Nuno Sá
2026-11-24 11:19 ` [PATCH v7 1/9] " Nuno Sá
2026-11-24 11:19 ` [PATCH v7 2/9] dmaengine: dma-axi-dmac: Use bus width capability helpers Nuno Sá
2026-11-24 11:19 ` [PATCH v7 3/9] dmaengine: dw-axi-dmac: " Nuno Sá
2026-11-24 11:19 ` [PATCH v7 4/9] dmaengine: qcom: gpi: " Nuno Sá
2026-11-24 11:19 ` [PATCH v7 5/9] dmaengine: stm32-dma3: " Nuno Sá
2026-11-24 11:19 ` [PATCH v7 6/9] iio: buffer-dmaengine: Use dma_slave_caps bus width accessors Nuno Sá
2026-11-24 11:19 ` Nuno Sá [this message]
2026-11-24 11:19 ` [PATCH v7 8/9] spi: dw: Use dma_slave_caps bus width helpers Nuno Sá
2026-11-24 11:19 ` [PATCH v7 9/9] dmaengine: Drop legacy bus width fields from dma_slave_caps Nuno Sá
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=20261124-dmaengine-support-wider-dma-masks-v7-7-5d57df2c3ebd@analog.com \
--to=nuno.sa@analog.com \
--cc=Eugeniy.Paltsev@synopsys.com \
--cc=Frank.Li@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=alexandre.torgue@foss.st.com \
--cc=amelie.delaunay@foss.st.com \
--cc=andy@kernel.org \
--cc=broonie@kernel.org \
--cc=dlechner@baylibre.com \
--cc=dmaengine@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.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®