[PATCH v4 10/10] dmaengine: Drop legacy bus width fields from dma_slave_caps

From: Nuno Sá

Date: Fri Sep 11 2026 - 13:44:24 EST


All users of dma_get_slave_caps() that inspect bus width capabilities now
use the bitmap helpers.

Hence, remove the legacy u32 src_addr_widths and dst_addr_widths fields
from struct dma_slave_caps and stop copying the dma_device masks into
them.

Note the legacy u32 src_addr_widths and dst_addr_widths fields in struct
dma_device are kept for now as every DMA controller driver setting them
still has to be converted to the new helpers. dma_get_slave_caps() keeps
folding those masks into the bitmaps it returns so unconverted producers
continue to work during the transition.

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
---
drivers/dma/dmaengine.c | 31 +------------------------------
include/linux/dmaengine.h | 13 ++-----------
2 files changed, 3 insertions(+), 41 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 8e68921cf01d..945079c677b1 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -596,8 +596,6 @@ int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps)

dma_bus_width_copy(caps->src_bus_widths, device->src_bus_widths);
dma_bus_width_copy(caps->dst_bus_widths, device->dst_bus_widths);
- caps->src_addr_widths = device->src_addr_widths;
- caps->dst_addr_widths = device->dst_addr_widths;

caps->directions = device->directions;
caps->min_burst = device->min_burst;
@@ -616,31 +614,9 @@ int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps)
* callback to override the generic capabilities with
* channel-specific ones.
*/
- if (device->device_caps) {
+ if (device->device_caps)
device->device_caps(chan, caps);

- /*
- * A driver already converted to the bus width interface
- * adjusts the masks, so derive the legacy capabilities from
- * them for the consumers not converted yet. Drivers not
- * converted adjust the legacy capabilities directly, in which
- * case there is nothing to do.
- *
- * Goes away with the legacy dma_slave_caps fields.
- */
- if (!bitmap_equal(caps->src_bus_widths.bits,
- device->src_bus_widths.bits,
- DMA_SLAVE_BUSWIDTH_MAX))
- caps->src_addr_widths = bitmap_read(caps->src_bus_widths.bits,
- 0, 32);
-
- if (!bitmap_equal(caps->dst_bus_widths.bits,
- device->dst_bus_widths.bits,
- DMA_SLAVE_BUSWIDTH_MAX))
- caps->dst_addr_widths = bitmap_read(caps->dst_bus_widths.bits,
- 0, 32);
- }
-
return 0;
}
EXPORT_SYMBOL_GPL(dma_get_slave_caps);
@@ -1208,14 +1184,9 @@ static void dma_device_fold_legacy_bus_widths(struct dma_device *device)
{
if (bitmap_empty(device->src_bus_widths.bits, DMA_SLAVE_BUSWIDTH_MAX))
bitmap_from_arr32(device->src_bus_widths.bits, &device->src_addr_widths, 32);
- /* consumers not converted yet still read the legacy caps */
- else if (!device->src_addr_widths)
- device->src_addr_widths = bitmap_read(device->src_bus_widths.bits, 0, 32);

if (bitmap_empty(device->dst_bus_widths.bits, DMA_SLAVE_BUSWIDTH_MAX))
bitmap_from_arr32(device->dst_bus_widths.bits, &device->dst_addr_widths, 32);
- else if (!device->dst_addr_widths)
- device->dst_addr_widths = bitmap_read(device->dst_bus_widths.bits, 0, 32);
}

/**
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 8236a1b274fb..657d3a1ee976 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -483,10 +483,7 @@ enum dma_residue_granularity {
/**
* struct dma_slave_caps - expose capabilities of a slave channel only
* @src_bus_widths: mask of source bus widths the channel supports.
- * @src_addr_widths: legacy bit mask of source bus widths the channel supports.
* @dst_bus_widths: mask of destination bus widths the channel supports.
- * @dst_addr_widths: legacy bit mask of destination bus widths the channel
- * supports.
* @directions: bit mask of slave directions the channel supports.
* Since the enum dma_transfer_direction is not defined as bit flag for
* each type, the dma controller should set BIT(<TYPE>) and same
@@ -505,14 +502,8 @@ enum dma_residue_granularity {
* resubmitted multiple times
*/
struct dma_slave_caps {
- struct {
- dma_buswidth_mask_t src_bus_widths;
- u32 src_addr_widths;
- };
- struct {
- dma_buswidth_mask_t dst_bus_widths;
- u32 dst_addr_widths;
- };
+ dma_buswidth_mask_t src_bus_widths;
+ dma_buswidth_mask_t dst_bus_widths;
u32 directions;
u32 min_burst;
u32 max_burst;

--
2.55.0