From: "Nuno Sá" <nuno.sa@analog.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: dmaengine@vger.kernel.org, linux-iio@vger.kernel.org,
Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>, Frank Li <Frank.Li@nxp.com>
Subject: Re: [PATCH v2 1/9] dmaengine: Support bus widths of 32 bytes and above
Date: Tue, 11 Aug 2026 09:46:04 +0100 [thread overview]
Message-ID: <anrgDskNdV7PG-T-@nsa> (raw)
In-Reply-To: <anoHMANpRU744hPp@ashevche-desk.local>
On Mon, Aug 10, 2026 at 08:15:28PM +0300, Andy Shevchenko wrote:
> On Mon, Aug 10, 2026 at 04:06:42PM +0100, Nuno Sá wrote:
> > The src_addr_widths and dst_addr_widths capability masks encode each
> > supported width as a bit whose position equals the corresponding
> > enum dma_slave_buswidth value (e.g. DMA_SLAVE_BUSWIDTH_4_BYTES sets bit
> > 4). As these masks are plain u32, widths of 32 bytes and above
> > (DMA_SLAVE_BUSWIDTH_32/64/128_BYTES map to bits 32, 64 and 128) cannot
> > be represented at all.
> >
> > Introduce bitmap-based bus width capabilities that span the full enum
> > range. To allow DMA controller producers to be converted incrementally,
> > keep the legacy dma_device u32 fields alongside the new bitmaps:
> > producers using the new helpers populate the bitmap and mirror the low
> > 32 bits back into the legacy field, while dma_get_slave_caps() folds a
> > legacy-only producer's u32 into the returned bitmap.
> >
> > Add helpers for producers and consumers so users do not need to depend
> > on the bitmap layout directly. Once the remaining producers are
> > converted, the legacy dma_device u32 fields can be dropped.
>
> ...
>
> > +++ b/include/linux/dmaengine.h
>
> > #ifndef LINUX_DMAENGINE_H
> > #define LINUX_DMAENGINE_H
> >
> > +#include <linux/bitops.h>
>
> Ah, this is unfortunate, this is a wrong header, the correct one is bitmap.h
> and I think we may not include it here (see below on why).
>
> > #include <linux/device.h>
> > #include <linux/err.h>
> > #include <linux/uio.h>
>
> ...
>
> > +static inline enum dma_slave_buswidth
> > +__dma_slave_caps_get_width_min(const unsigned long *bus_widths)
> > +{
> > + enum dma_slave_buswidth width = find_first_bit(bus_widths,
> > + DMA_SLAVE_BUSWIDTH_MAX);
>
> This is from find.h which is internals of bitmap.h.
>
> > + if (width == DMA_SLAVE_BUSWIDTH_MAX)
> > + return DMA_SLAVE_BUSWIDTH_UNDEFINED;
> > +
> > + return width;
> > +}
>
> The (big) problem is quite a header dependencies hell we have. All my cleanup
> work of kernel.h I started on the simplest thing I wanted, id est to make
> bitmap_zalloc() and similar to be static inlines. But it's impossible to achieve
> (and I think that no one, except may be Ingo, see his 2000+ patch series a few
> years back, is capable of fix that at once). That's why having bitmap.h in the
> kernel wide public _header_ is bad, bad idea (at least at the current state of
> affairs). So, make it exported function instead and keep bitmap.h in dmaengine.c.
>
> ...
>
> > +/**
> > + * dma_slave_caps_copy_src_widths - copy source bus width capabilities
> > + * @caps: DMA slave capabilities
> > + * @bus_widths: destination bitmap declared with DECLARE_DMA_BUS_WIDTHS()
> > + */
> > +static inline void
> > +dma_slave_caps_copy_src_widths(const struct dma_slave_caps *caps,
> > + unsigned long *bus_widths)
> > +{
> > + bitmap_copy(bus_widths, caps->src_bus_widths, DMA_SLAVE_BUSWIDTH_MAX);
> > +}
>
> > +/**
> > + * dma_slave_caps_copy_dst_widths - copy destination bus width capabilities
> > + * @caps: DMA slave capabilities
> > + * @bus_widths: destination bitmap declared with DECLARE_DMA_BUS_WIDTHS()
> > + */
> > +static inline void
> > +dma_slave_caps_copy_dst_widths(const struct dma_slave_caps *caps,
> > + unsigned long *bus_widths)
> > +{
> > + bitmap_copy(bus_widths, caps->dst_bus_widths, DMA_SLAVE_BUSWIDTH_MAX);
> > +}
>
> As per above.
>
> ...
>
> Another (compromise approach) is to split the header that includes bitmap.h to
> something like dmaengine-width.h, but I don't know how spread this use is. Do
> we have all the users of the current dmaengine.h to use these APIs? If not,
> split, if yes, then comment on this in the cover letter and perhaps that will
> justify including bitmap.h in the dmaengine.h (but personally I am fully
> against that).
>
Hmm I don't think all dmaengine.h will use this API. Maybe on the
producer side but even in that case I don't think so. These are all tiny
wrappers that make sense to be inlined but OTOH, I don't think any of
these needs to be called in any fastpath. And I do understand the header
pain in here but honestly, no strong feelings. So, I'll pretty much
defer this to Frank or Vinod.
Frank, Vinod any preference?
- Nuno Sá
> --
> With Best Regards,
> Andy Shevchenko
>
>
next prev parent reply other threads:[~2026-08-11 8:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 15:06 [PATCH v2 0/9] dmaengine: Support bus widths of 32 bytes and above Nuno Sá
2026-08-10 15:06 ` [PATCH v2 1/9] " Nuno Sá
2026-08-10 17:15 ` Andy Shevchenko
2026-08-11 8:46 ` Nuno Sá [this message]
2026-08-11 17:58 ` Vinod Koul
2026-08-10 15:06 ` [PATCH v2 2/9] dmaengine: dma-axi-dmac: Use bus width capability helpers Nuno Sá
2026-08-10 15:06 ` [PATCH v2 3/9] dmaengine: dw-axi-dmac: " Nuno Sá
2026-08-10 15:06 ` [PATCH v2 4/9] dmaengine: qcom: gpi: " Nuno Sá
2026-08-10 15:06 ` [PATCH v2 5/9] dmaengine: stm32-dma3: " Nuno Sá
2026-08-10 15:06 ` [PATCH v2 6/9] iio: buffer-dmaengine: Use dma_slave_caps bus width accessors Nuno Sá
2026-08-12 4:48 ` Jonathan Cameron
2026-08-10 15:06 ` [PATCH v2 7/9] ALSA: pcm_dmaengine: Use dma_slave_caps bus width helpers Nuno Sá
2026-08-10 15:06 ` [PATCH v2 8/9] spi: dw: " Nuno Sá
2026-08-10 15:06 ` [PATCH v2 9/9] dmaengine: Drop legacy bus width fields from dma_slave_caps Nuno Sá
2026-08-10 16:56 ` 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=anrgDskNdV7PG-T-@nsa \
--to=nuno.sa@analog.com \
--cc=Frank.Li@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=dmaengine@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--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