mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>,
	"Andy Shevchenko" <andriy.shevchenko@intel.com>
Subject: [PATCH v7 8/9] spi: dw: Use dma_slave_caps bus width helpers
Date: Tue, 24 Nov 2026 11:19:48 +0000	[thread overview]
Message-ID: <20261124-dmaengine-support-wider-dma-masks-v7-8-5d57df2c3ebd@analog.com> (raw)
In-Reply-To: <20261124-dmaengine-support-wider-dma-masks-v7-0-5d57df2c3ebd@analog.com>

Store the common TX destination and RX source bus widths in a
driver-owned DMA bus width bitmap and populate it through the
dma_slave_caps helper.

This avoids depending on the legacy src_addr_widths and dst_addr_widths
masks returned by dma_get_slave_caps().

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/spi/spi-dw-dma.c | 13 +++++++------
 drivers/spi/spi-dw.h     |  3 ++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/spi-dw-dma.c b/drivers/spi/spi-dw-dma.c
index b706770334a6..f151dac59174 100644
--- a/drivers/spi/spi-dw-dma.c
+++ b/drivers/spi/spi-dw-dma.c
@@ -103,13 +103,13 @@ static int dw_spi_dma_caps_init(struct dw_spi *dws)
 	/* With a single channel only one direction is available at a time */
 	if (!dws->rxchan) {
 		dws->dma_sg_burst = tx.max_sg_burst;
-		dws->dma_addr_widths = tx.dst_addr_widths;
+		dmaengine_bus_width_copy(&dws->dma_bus_widths, &tx.dst_bus_widths);
 		return 0;
 	}
 
 	if (!dws->txchan) {
 		dws->dma_sg_burst = rx.max_sg_burst;
-		dws->dma_addr_widths = rx.src_addr_widths;
+		dmaengine_bus_width_copy(&dws->dma_bus_widths, &rx.src_bus_widths);
 		return 0;
 	}
 
@@ -124,10 +124,11 @@ static int dw_spi_dma_caps_init(struct dw_spi *dws)
 
 	/*
 	 * Assuming both channels belong to the same DMA controller hence the
-	 * peripheral side address width capabilities most likely would be
+	 * peripheral side bus width capabilities most likely would be
 	 * the same.
 	 */
-	dws->dma_addr_widths = tx.dst_addr_widths & rx.src_addr_widths;
+	dmaengine_bus_width_and(&dws->dma_bus_widths, &tx.dst_bus_widths,
+				&rx.src_bus_widths);
 
 	return 0;
 }
@@ -292,7 +293,7 @@ static bool dw_spi_can_dma(struct spi_controller *ctlr,
 
 	dma_bus_width = dw_spi_dma_convert_width(n_bytes);
 
-	return dws->dma_addr_widths & BIT(dma_bus_width);
+	return dmaengine_bus_width_test(&dws->dma_bus_widths, dma_bus_width);
 }
 
 static int dw_spi_dma_wait(struct dw_spi *dws, unsigned int len, u32 speed)
@@ -845,7 +846,7 @@ static bool dw_spi_enh_mem_can_dma(struct spi_controller *ctlr)
 
 	dma_bus_width = dw_spi_dma_convert_width(dws->n_bytes);
 
-	return dws->dma_addr_widths & BIT(dma_bus_width);
+	return dmaengine_bus_width_test(&dws->dma_bus_widths, dma_bus_width);
 }
 
 static int dw_spi_enh_mem_dma_transfer(struct spi_mem *mem, const struct spi_mem_op *op)
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index c16225c5c887..ecbcca50026e 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -5,6 +5,7 @@
 #include <linux/bits.h>
 #include <linux/completion.h>
 #include <linux/debugfs.h>
+#include <linux/dmaengine.h>
 #include <linux/irqreturn.h>
 #include <linux/io.h>
 #include <linux/scatterlist.h>
@@ -220,7 +221,7 @@ struct dw_spi {
 	unsigned int		dma_nr_chans;
 	bool			tx_dir;
 	u32			dma_sg_burst;
-	u32			dma_addr_widths;
+	dma_buswidth_mask_t	dma_bus_widths;
 	unsigned long		dma_chan_busy;
 	dma_addr_t		dma_addr; /* phy address of the Data register */
 	const struct dw_spi_dma_ops *dma_ops;

-- 
2.56.0


  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 ` [PATCH v7 7/9] ALSA: pcm_dmaengine: Use dma_slave_caps bus width helpers Nuno Sá
2026-11-24 11:19 ` Nuno Sá [this message]
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-8-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=andriy.shevchenko@intel.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®