[PATCH v3 0/9] dmaengine: Support bus widths of 32 bytes and above

Nuno Sá posted 9 patches 3 weeks, 5 days ago
There is a newer version of this series
MAINTAINERS                                        |   1 +
drivers/dma/dma-axi-dmac.c                         |  14 +-
drivers/dma/dmaengine.c                            |  27 +++-
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c     |  38 +++--
drivers/dma/qcom/gpi.c                             |  12 +-
drivers/dma/stm32/stm32-dma3.c                     |  34 +++--
drivers/iio/buffer/industrialio-buffer-dmaengine.c |  16 +-
drivers/spi/spi-dw-dma.c                           |   8 +-
drivers/spi/spi-dw.h                               |   3 +-
include/linux/dma/engine/types.h                   |  41 ++++++
include/linux/dma/engine/widthmask.h               | 164 +++++++++++++++++++++
include/linux/dmaengine.h                          |  47 +++---
sound/core/pcm_dmaengine.c                         |  21 ++-
13 files changed, 342 insertions(+), 84 deletions(-)
[PATCH v3 0/9] dmaengine: Support bus widths of 32 bytes and above
Posted by Nuno Sá 3 weeks, 5 days ago
The DMA engine slave capabilities advertise the supported source and
destination bus widths through src_addr_widths / dst_addr_widths. These
are plain u32 bitmasks where a set bit's position equals the
corresponding enum dma_slave_buswidth value, e.g.
DMA_SLAVE_BUSWIDTH_4_BYTES sets bit 4.

The consequence is that widths of 32 bytes and above cannot be
represented at all: DMA_SLAVE_BUSWIDTH_32/64/128_BYTES would need bits
32, 64 and 128, which do not fit in a u32. Hardware with wider data
paths is becoming common, so add a representation that can express these
widths while still using enum dma_slave_buswidth.

This series switches consumers and a small set of producers to the new
bus width capabilities, represented by a dma_buswidth_mask_t modeled
after dma_cap_mask_t. The legacy dma_device u32 fields are kept for now
so the remaining DMA controller drivers can be converted incrementally:
dma_async_device_register() folds a legacy-only producer's u32 into the
mask, so consumers only ever have to look at the mask.

The new interface lives in include/linux/dma/engine/{types,widthmask}.h
rather than in linux/dmaengine.h, so that only its users pay for the
linux/bitmap.h include. Every accessor takes a dma_buswidth_mask_t,
which means the interface will not change when the legacy fields are
eventually dropped.

Once the remaining producers are converted, the legacy dma_device
src/dst_addr_widths fields can be removed as a final cleanup.

This issue was discussed before here:

https://lore.kernel.org/dmaengine/abkoXXbaxaiqbBuX@vaman/

Changes in v3:
- Patch 1:
  - Move the new interface out of linux/dmaengine.h into two new headers,
    include/linux/dma/engine/types.h (enum dma_slave_buswidth and the new
    dma_buswidth_mask_t) and include/linux/dma/engine/widthmask.h (the
    accessors). Only the latter includes linux/bitmap.h and it is not
    included back into linux/dmaengine.h (Andy).
  - Replace the raw bitmap with a dma_buswidth_mask_t type modeled after
    dma_cap_mask_t, so linux/dmaengine.h does not need linux/bitmap.h for
    the struct members.
  - Every accessor now takes a dma_buswidth_mask_t instead of a
    struct dma_device / struct dma_slave_caps, so the interface stays the
    same once the legacy fields are dropped. Consequently
    dma_slave_caps_{get,copy,intersect,clear}_*_width() are gone.
  - Fold the legacy producer masks once in dma_async_device_register()
    instead of on every dma_get_slave_caps() call. On top of that, only
    when a device_caps() callback adjusted the masks, derive the legacy
    dma_slave_caps masks from them, so that a converted controller driver
    is also seen by the consumers not converted yet, while a driver still
    adjusting the legacy masks directly keeps working.
- Patch 5:
  - Also convert the driver's own read of the legacy capabilities in
    stm32_dma3_chan_prep_hw(); besides completing the conversion this
    stops BIT() from being fed an unvalidated device tree bus width.
  - Drop the stm32_dma3 prefix from the local buswidths[] array and move
    it below the struct declarations (Amelie).
- Link to v2: https://patch.msgid.link/20260810-dmaengine-support-wider-dma-masks-v2-0-1f7b798d035f@analog.com

---
Nuno Sá (9):
      dmaengine: Support bus widths of 32 bytes and above
      dmaengine: dma-axi-dmac: Use bus width capability helpers
      dmaengine: dw-axi-dmac: Use bus width capability helpers
      dmaengine: qcom: gpi: Use bus width capability helpers
      dmaengine: stm32-dma3: Use bus width capability helpers
      iio: buffer-dmaengine: Use dma_slave_caps bus width accessors
      ALSA: pcm_dmaengine: Use dma_slave_caps bus width helpers
      spi: dw: Use dma_slave_caps bus width helpers
      dmaengine: Drop legacy bus width fields from dma_slave_caps

 MAINTAINERS                                        |   1 +
 drivers/dma/dma-axi-dmac.c                         |  14 +-
 drivers/dma/dmaengine.c                            |  27 +++-
 drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c     |  38 +++--
 drivers/dma/qcom/gpi.c                             |  12 +-
 drivers/dma/stm32/stm32-dma3.c                     |  34 +++--
 drivers/iio/buffer/industrialio-buffer-dmaengine.c |  16 +-
 drivers/spi/spi-dw-dma.c                           |   8 +-
 drivers/spi/spi-dw.h                               |   3 +-
 include/linux/dma/engine/types.h                   |  41 ++++++
 include/linux/dma/engine/widthmask.h               | 164 +++++++++++++++++++++
 include/linux/dmaengine.h                          |  47 +++---
 sound/core/pcm_dmaengine.c                         |  21 ++-
 13 files changed, 342 insertions(+), 84 deletions(-)
---
base-commit: 0613e7934ee233d726af8d8c89f251a1c4df738d
change-id: 20260615-dmaengine-support-wider-dma-masks-5aac12497e27
--

Thanks!
- Nuno Sá

Re: [PATCH v3 0/9] dmaengine: Support bus widths of 32 bytes and above
Posted by Andy Shevchenko 3 weeks, 5 days ago
On Mon, Aug 31, 2026 at 12:46:37PM +0100, Nuno Sá wrote:
> The DMA engine slave capabilities advertise the supported source and
> destination bus widths through src_addr_widths / dst_addr_widths. These
> are plain u32 bitmasks where a set bit's position equals the
> corresponding enum dma_slave_buswidth value, e.g.
> DMA_SLAVE_BUSWIDTH_4_BYTES sets bit 4.
> 
> The consequence is that widths of 32 bytes and above cannot be
> represented at all: DMA_SLAVE_BUSWIDTH_32/64/128_BYTES would need bits
> 32, 64 and 128, which do not fit in a u32. Hardware with wider data
> paths is becoming common, so add a representation that can express these
> widths while still using enum dma_slave_buswidth.
> 
> This series switches consumers and a small set of producers to the new
> bus width capabilities, represented by a dma_buswidth_mask_t modeled
> after dma_cap_mask_t. The legacy dma_device u32 fields are kept for now
> so the remaining DMA controller drivers can be converted incrementally:
> dma_async_device_register() folds a legacy-only producer's u32 into the
> mask, so consumers only ever have to look at the mask.
> 
> The new interface lives in include/linux/dma/engine/{types,widthmask}.h
> rather than in linux/dmaengine.h, so that only its users pay for the
> linux/bitmap.h include. Every accessor takes a dma_buswidth_mask_t,
> which means the interface will not change when the legacy fields are
> eventually dropped.
> 
> Once the remaining producers are converted, the legacy dma_device
> src/dst_addr_widths fields can be removed as a final cleanup.
> 
> This issue was discussed before here:
> 
> https://lore.kernel.org/dmaengine/abkoXXbaxaiqbBuX@vaman/

Thanks, this version looks like the right approach. I have looked at a couple
of patches and only the first one needs a bit of work, the rest looks nice!

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v3 0/9] dmaengine: Support bus widths of 32 bytes and above
Posted by Nuno Sá 3 weeks, 5 days ago
On Mon, Aug 31, 2026 at 04:50:33PM +0300, Andy Shevchenko wrote:
> On Mon, Aug 31, 2026 at 12:46:37PM +0100, Nuno Sá wrote:
> > The DMA engine slave capabilities advertise the supported source and
> > destination bus widths through src_addr_widths / dst_addr_widths. These
> > are plain u32 bitmasks where a set bit's position equals the
> > corresponding enum dma_slave_buswidth value, e.g.
> > DMA_SLAVE_BUSWIDTH_4_BYTES sets bit 4.
> > 
> > The consequence is that widths of 32 bytes and above cannot be
> > represented at all: DMA_SLAVE_BUSWIDTH_32/64/128_BYTES would need bits
> > 32, 64 and 128, which do not fit in a u32. Hardware with wider data
> > paths is becoming common, so add a representation that can express these
> > widths while still using enum dma_slave_buswidth.
> > 
> > This series switches consumers and a small set of producers to the new
> > bus width capabilities, represented by a dma_buswidth_mask_t modeled
> > after dma_cap_mask_t. The legacy dma_device u32 fields are kept for now
> > so the remaining DMA controller drivers can be converted incrementally:
> > dma_async_device_register() folds a legacy-only producer's u32 into the
> > mask, so consumers only ever have to look at the mask.
> > 
> > The new interface lives in include/linux/dma/engine/{types,widthmask}.h
> > rather than in linux/dmaengine.h, so that only its users pay for the
> > linux/bitmap.h include. Every accessor takes a dma_buswidth_mask_t,
> > which means the interface will not change when the legacy fields are
> > eventually dropped.
> > 
> > Once the remaining producers are converted, the legacy dma_device
> > src/dst_addr_widths fields can be removed as a final cleanup.
> > 
> > This issue was discussed before here:
> > 
> > https://lore.kernel.org/dmaengine/abkoXXbaxaiqbBuX@vaman/
> 
> Thanks, this version looks like the right approach. I have looked at a couple
> of patches and only the first one needs a bit of work, the rest looks nice!

It does! Once this lands, I do intend to do the same separation for the
caps_mask so that we can drop bitmap from dmaengine.h

- Nuno Sá

> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
>