[PATCH v3 00/13] dmaengine: introduce sg_nents_for_dma() and convert users

Andy Shevchenko posted 13 patches 2 months, 3 weeks ago
There is a newer version of this series
drivers/dma/altera-msgdma.c                   |  5 ++--
drivers/dma/bcm2835-dma.c                     | 19 +-------------
drivers/dma/dma-axi-dmac.c                    |  5 +---
.../dma/dw-axi-dmac/dw-axi-dmac-platform.c    |  6 ++---
drivers/dma/k3dma.c                           |  9 ++-----
drivers/dma/lgm/lgm-dma.c                     |  9 ++-----
drivers/dma/pxa_dma.c                         |  5 ++--
drivers/dma/qcom/bam_dma.c                    |  9 ++-----
drivers/dma/qcom/qcom_adm.c                   |  9 +++----
drivers/dma/sa11x0-dma.c                      |  6 ++---
drivers/dma/sh/shdma-base.c                   |  5 ++--
drivers/dma/xilinx/xdma.c                     |  6 ++---
include/linux/scatterlist.h                   |  2 ++
lib/scatterlist.c                             | 26 +++++++++++++++++++
14 files changed, 52 insertions(+), 69 deletions(-)
[PATCH v3 00/13] dmaengine: introduce sg_nents_for_dma() and convert users
Posted by Andy Shevchenko 2 months, 3 weeks ago
A handful of the DMAengine drivers use same routine to calculate the number of
SG entries needed for the given DMA transfer. Provide a common helper for them
and convert.

I left the new helper on SG level of API because brief grepping shows potential
candidates outside of DMA engine, e.g.:

  drivers/crypto/chelsio/chcr_algo.c:154:  nents += DIV_ROUND_UP(less, entlen);
  drivers/spi/spi-stm32.c:1495:  /* Count the number of entries needed */

Changelog v3:
- added missed EXPORT_SYMBOL() (Bjorn)
- left the return type as signed int (as agreed with Bjorn)
- collected tags (Bjorn)

v2: <20251110103805.3562136-1-andriy.shevchenko@linux.intel.com>

Changelog v2:
- dropped outdated patches (only 9 years passed :-)
- rebased on top of the current kernel
- left API SG wide It might

v1: https://patchwork.kernel.org/project/linux-dmaengine/patch/20161021173535.100245-1-andriy.shevchenko@linux.intel.com/

Andy Shevchenko (13):
  scatterlist: introduce sg_nents_for_dma() helper
  dmaengine: altera-msgdma: use sg_nents_for_dma() helper
  dmaengine: axi-dmac: use sg_nents_for_dma() helper
  dmaengine: bcm2835-dma: use sg_nents_for_dma() helper
  dmaengine: dw-axi-dmac: use sg_nents_for_dma() helper
  dmaengine: k3dma: use sg_nents_for_dma() helper
  dmaengine: lgm: use sg_nents_for_dma() helper
  dmaengine: pxa-dma: use sg_nents_for_dma() helper
  dmaengine: qcom: adm: use sg_nents_for_dma() helper
  dmaengine: qcom: bam_dma: use sg_nents_for_dma() helper
  dmaengine: sa11x0: use sg_nents_for_dma() helper
  dmaengine: sh: use sg_nents_for_dma() helper
  dmaengine: xilinx: xdma: use sg_nents_for_dma() helper

 drivers/dma/altera-msgdma.c                   |  5 ++--
 drivers/dma/bcm2835-dma.c                     | 19 +-------------
 drivers/dma/dma-axi-dmac.c                    |  5 +---
 .../dma/dw-axi-dmac/dw-axi-dmac-platform.c    |  6 ++---
 drivers/dma/k3dma.c                           |  9 ++-----
 drivers/dma/lgm/lgm-dma.c                     |  9 ++-----
 drivers/dma/pxa_dma.c                         |  5 ++--
 drivers/dma/qcom/bam_dma.c                    |  9 ++-----
 drivers/dma/qcom/qcom_adm.c                   |  9 +++----
 drivers/dma/sa11x0-dma.c                      |  6 ++---
 drivers/dma/sh/shdma-base.c                   |  5 ++--
 drivers/dma/xilinx/xdma.c                     |  6 ++---
 include/linux/scatterlist.h                   |  2 ++
 lib/scatterlist.c                             | 26 +++++++++++++++++++
 14 files changed, 52 insertions(+), 69 deletions(-)

-- 
2.50.1
Re: [PATCH v3 00/13] dmaengine: introduce sg_nents_for_dma() and convert users
Posted by Vinod Koul 4 weeks, 1 day ago
On Thu, 13 Nov 2025 16:12:56 +0100, Andy Shevchenko wrote:
> A handful of the DMAengine drivers use same routine to calculate the number of
> SG entries needed for the given DMA transfer. Provide a common helper for them
> and convert.
> 
> I left the new helper on SG level of API because brief grepping shows potential
> candidates outside of DMA engine, e.g.:
> 
> [...]

Applied, thanks!

[01/13] scatterlist: introduce sg_nents_for_dma() helper
        commit: 80c70bfb95cdbe0c644070f4ca4754a60f0a4830
[02/13] dmaengine: altera-msgdma: use sg_nents_for_dma() helper
        commit: 47f5cb7878cc62ed95981c5d02862b253eddb590
[03/13] dmaengine: axi-dmac: use sg_nents_for_dma() helper
        commit: 024ae9d3092c425f3ea6eae92086a2001ca2e0c7
[04/13] dmaengine: bcm2835-dma: use sg_nents_for_dma() helper
        commit: 39110c68500a149664bafb0c174baef0d42e2129
[05/13] dmaengine: dw-axi-dmac: use sg_nents_for_dma() helper
        commit: 5d6ceb254fa9ac1f50932c42a0a9a8bedaa3190d
[06/13] dmaengine: k3dma: use sg_nents_for_dma() helper
        commit: 3fc49d21f3a46866724ff8ef8a79c6e2cd9d7676
[07/13] dmaengine: lgm: use sg_nents_for_dma() helper
        commit: f9b0274f53a2d464e71f37e8f4d0d0dc41321259
[08/13] dmaengine: pxa-dma: use sg_nents_for_dma() helper
        commit: 068942eaa232ba752b744d98ff8ab22b26c8bff4
[09/13] dmaengine: qcom: adm: use sg_nents_for_dma() helper
        commit: 425f871d7acdb521d67c2578e6ae688a751d1e80
[10/13] dmaengine: qcom: bam_dma: use sg_nents_for_dma() helper
        commit: 107fdf0c4e944030bf544aea98e8ae8537914177
[11/13] dmaengine: sa11x0: use sg_nents_for_dma() helper
        commit: d7785661010e2fe113aec2500f988a8e73ac3e7b
[12/13] dmaengine: sh: use sg_nents_for_dma() helper
        commit: ac326dca6870f0d8e0787e94b1d9c2c91bb358d7
[13/13] dmaengine: xilinx: xdma: use sg_nents_for_dma() helper
        commit: 3c8a86ed002ab8fb287ee4ec92f0fd6ac5b291d2

Best regards,
-- 
~Vinod
Re: [PATCH v3 00/13] dmaengine: introduce sg_nents_for_dma() and convert users
Posted by Andy Shevchenko 2 months, 2 weeks ago
On Thu, Nov 13, 2025 at 04:12:56PM +0100, Andy Shevchenko wrote:
> A handful of the DMAengine drivers use same routine to calculate the number of
> SG entries needed for the given DMA transfer. Provide a common helper for them
> and convert.
> 
> I left the new helper on SG level of API because brief grepping shows potential
> candidates outside of DMA engine, e.g.:
> 
>   drivers/crypto/chelsio/chcr_algo.c:154:  nents += DIV_ROUND_UP(less, entlen);
>   drivers/spi/spi-stm32.c:1495:  /* Count the number of entries needed */

Vinod, what is your plan on the DMAengine patches? (Asking not only about this series)
Please, tell if anything needs to be done from my side to help them being pulled.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v3 00/13] dmaengine: introduce sg_nents_for_dma() and convert users
Posted by Vinod Koul 2 months, 2 weeks ago
On 20-11-25, 21:15, Andy Shevchenko wrote:
> On Thu, Nov 13, 2025 at 04:12:56PM +0100, Andy Shevchenko wrote:
> 
> Vinod, what is your plan on the DMAengine patches? (Asking not only about this series)
> Please, tell if anything needs to be done from my side to help them being pulled.

Sure would appreciate if folks can review, make it easier for me to
pick. Yeah been behind for a bit, picking things now.

Reg this series, looks okay, who would ack patch 1?

-- 
~Vinod
Re: [PATCH v3 00/13] dmaengine: introduce sg_nents_for_dma() and convert users
Posted by Andy Shevchenko 2 months, 2 weeks ago
On Fri, Nov 21, 2025 at 05:36:24PM +0530, Vinod Koul wrote:
> On 20-11-25, 21:15, Andy Shevchenko wrote:
> > On Thu, Nov 13, 2025 at 04:12:56PM +0100, Andy Shevchenko wrote:
> > 
> > Vinod, what is your plan on the DMAengine patches? (Asking not only about this series)
> > Please, tell if anything needs to be done from my side to help them being pulled.
> 
> Sure would appreciate if folks can review, make it easier for me to
> pick. Yeah been behind for a bit, picking things now.
> 
> Reg this series, looks okay, who would ack patch 1?

You. :-) For the generic headers each subsystem maintainers may apply this.

-- 
With Best Regards,
Andy Shevchenko