Skip to content

dmaengine: at_hdmac: Fix concurrency bugs and then convert to virt-dma

Tudor Ambarus dmaengine linux-arm-kernel lkml stable 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest32 patches 9 repliesIn review
  2. v133 patches 6 repliesSuperseded

Changes in v2 from the cover letter

- reorder patches so that fixes come first -> easier to backport to stable kernels.
- drop the devm_request_irq() patch as we had to disable the irq anyway in remove() in order to avoid spurios IRQs. Using devm variant brings no palpable benefit.
- reword pm_ptr commit message

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/32dmaengine: at_hdmac: Fix at_lli struct definitiondrivers/dma/at_hdmac_regs.h+5 -50 replies
2/32dmaengine: at_hdmac: Don't start transactions at tx_submit leveldrivers/dma/at_hdmac.c+3 -110 replies
3/32dmaengine: at_hdmac: Start transfer for cyclic channels in issue_pendingdrivers/dma/at_hdmac.c+0 -40 replies
4/32dmaengine: at_hdmac: Fix premature completion of desc in issue_pendingdrivers/dma/at_hdmac.c+13 -30 replies
5/32dmaengine: at_hdmac: Do not call the complete callback on device_terminate_alldrivers/dma/at_hdmac.c+2 -90 replies
6/32dmaengine: at_hdmac: Protect atchan->status with the channel lockdrivers/dma/at_hdmac.c+2 -20 replies
7/32dmaengine: at_hdmac: Fix concurrency problems by removing atc_complete_all()drivers/dma/at_hdmac.c+4 -450 replies
8/32dmaengine: at_hdmac: Fix concurrency over descriptordrivers/dma/at_hdmac.c+9 -50 replies
9/32dmaengine: at_hdmac: Free the memset buf without holding the chan lockdrivers/dma/at_hdmac.c+7 -70 replies
10/32dmaengine: at_hdmac: Fix concurrency over the active listdrivers/dma/at_hdmac.c+6 -40 replies
11/32dmaengine: at_hdmac: Fix descriptor handling when issuing it to hardwaredrivers/dma/at_hdmac.c+11 -40 replies
12/32dmaengine: at_hdmac: Fix completion of unissued descriptor in case of errorsdrivers/dma/at_hdmac.c+0 -40 replies
13/32dmaengine: at_hdmac: Don't allow CPU to reorder channel enabledrivers/dma/at_hdmac.c+2 -00 replies
14/32dmaengine: at_hdmac: Fix impossible conditiondrivers/dma/at_hdmac.c+4 -30 replies
15/32dmaengine: at_hdmac: Check return code of dma_async_device_registerdrivers/dma/at_hdmac.c+6 -10 replies
16/32dmaengine: at_hdmac: Do not print messages on console while holding the lockdrivers/dma/at_hdmac.c+2 -20 replies
17/32dmaengine: at_hdmac: Return dma_cookie_status()'s ret code when txstate is NULLdrivers/dma/at_hdmac.c+1 -70 replies
18/32dmaengine: at_hdmac: Remove superfluous castdrivers/dma/at_hdmac.c+1 -10 replies
19/32dmaengine: at_hdmac: Pass residue by address to avoid unnecessary implicit castsdrivers/dma/at_hdmac.c+30 -240 replies
20/32dmaengine: at_hdmac: s/atc_get_bytes_left/atc_get_residuedrivers/dma/at_hdmac.c+4 -70 replies
21/32dmaengine: at_hdmac: Introduce atc_get_llis_residue()drivers/dma/at_hdmac.c+110 -1110 replies
22/32dmaengine: at_hdmac: Use devm_kzalloc() and struct_size()drivers/dma/at_hdmac.c+9 -140 replies
23/32dmaengine: at_hdmac: Use devm_platform_ioremap_resourcedrivers/dma/at_hdmac.c+6 -310 replies
24/32dmaengine: at_hdmac: Use devm_clk_get()drivers/dma/at_hdmac.c+2 -50 replies
25/32dmaengine: at_hdmac: Use pm_ptr()drivers/dma/at_hdmac.c+2 -20 replies
26/32dmaengine: at_hdmac: Set include entries in alphabetic orderdrivers/dma/at_hdmac.c+3 -30 replies
27/32dmaengine: at_hdmac: Keep register definitions and structures private to at_hdmac.cMAINTAINERS drivers/dma/at_hdmac.c drivers/dma/at_hdmac_regs.h+468 -4800 replies
28/32dmaengine: at_hdmac: Use bitfield access macrosdrivers/dma/at_hdmac.c+198 -2100 replies
29/32dmaengine: at_hdmac: Rename "dma_common" to "dma_device"drivers/dma/at_hdmac.c+46 -460 replies
30/32dmaengine: at_hdmac: Rename "chan_common" to "dma_chan"drivers/dma/at_hdmac.c+31 -310 replies
31/32dmaengine: at_hdmac: Remove unused member of at_dma_chandrivers/dma/at_hdmac.c+0 -20 replies
32/32dmaengine: at_hdmac: Convert driver to use virt-dmadrivers/dma/Kconfig drivers/dma/at_hdmac.c+403 -7061 reply

Reviews trailers per patch

1 of 32 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNicolas Ferre
SeriesA-b
1/32
2/32
3/32
4/32
5/32
6/32
7/32
8/32
9/32
10/32
11/32
12/32
13/32
14/32
15/32
16/32
17/32
18/32
19/32
20/32
21/32
22/32
23/32
24/32
25/32
26/32
27/32
28/32
29/32
30/32
31/32
32/32A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/32] dmaengine: at_hdmac: Fix concurrency bugs and then convert to virt-dma

v2:
- reorder patches so that fixes come first -> easier to backport to stable kernels.
- drop the devm_request_irq() patch as we had to disable the irq anyway in remove() in order to avoid spurios IRQs. Using devm variant brings no palpable benefit.
- reword pm_ptr commit message

at_hdmac driver had poor list handling and concurrency bugs. We experienced calling of the completion call twice for the same descriptor. Peter Rosin encountered the same while reporting a different bug:
https://lore.kernel.org/lkml/[email protected]/

Two sets of tests were performed:
1/ tested just the fixes, to make sure everything is fine and the concurrency bugs are squashed even without the conversion to virt-dma. All went fine.
2/ tested the entire series including the conversion the virt-dma All went fine.

I tested NAND (prep_dma_memcpy), MMC (prep_dma_slave_sg), usart (cyclic mode), dmatest (memcpy, memset).
With the conversion to virt-dma I replaced the election of a new transfer in the tasklet with the election of the new transfer in the interrupt handler. We should have a shorter idle window as we remove the scheduling latency of the tasklet. Using mtd_speedtest showed similar performances when using NAND with DMA. That could be because of using a low timming mode on NAND.

Tudor Ambarus (32):
dmaengine: at_hdmac: Fix at_lli struct definition
dmaengine: at_hdmac: Don't start transactions at tx_submit level
dmaengine: at_hdmac: Start transfer for cyclic channels in
issue_pending
dmaengine: at_hdmac: Fix premature completion of desc in issue_pending
dmaengine: at_hdmac: Do not call the complete callback on
device_terminate_all
dmaengine: at_hdmac: Protect atchan->status with the channel lock
dmaengine: at_hdmac: Fix concurrency problems by removing
atc_complete_all()
dmaengine: at_hdmac: Fix concurrency over descriptor
dmaengine: at_hdmac: Free the memset buf without holding the chan lock
dmaengine: at_hdmac: Fix concurrency over the active list
dmaengine: at_hdmac: Fix descriptor handling when issuing it to
hardware
dmaengine: at_hdmac: Fix completion of unissued descriptor in case of
errors
dmaengine: at_hdmac: Don't allow CPU to reorder channel enable
dmaengine: at_hdmac: Fix impossible condition
dmaengine: at_hdmac: Check return code of dma_async_device_register
dmaengine: at_hdmac: Do not print messages on console while holding
the lock
dmaengine: at_hdmac: Return dma_cookie_status()'s ret code when
txstate is NULL
dmaengine: at_hdmac: Remove superfluous cast
dmaengine: at_hdmac: Pass residue by address to avoid unnecessary
implicit casts
dmaengine: at_hdmac: s/atc_get_bytes_left/atc_get_residue
dmaengine: at_hdmac: Introduce atc_get_llis_residue()
dmaengine: at_hdmac: Use devm_kzalloc() and struct_size()
dmaengine: at_hdmac: Use devm_platform_ioremap_resource
dmaengine: at_hdmac: Use devm_clk_get()
dmaengine: at_hdmac: Use pm_ptr()
dmaengine: at_hdmac: Set include entries in alphabetic order
dmaengine: at_hdmac: Keep register definitions and structures private
to at_hdmac.c
dmaengine: at_hdmac: Use bitfield access macros
dmaengine: at_hdmac: Rename "dma_common" to "dma_device"
dmaengine: at_hdmac: Rename "chan_common" to "dma_chan"
dmaengine: at_hdmac: Remove unused member of at_dma_chan
dmaengine: at_hdmac: Convert driver to use virt-dma

 MAINTAINERS                 |    1 -
 drivers/dma/Kconfig         |    1 +
 drivers/dma/at_hdmac.c      | 1899 ++++++++++++++++++-----------------
 drivers/dma/at_hdmac_regs.h |  478 ---------
 4 files changed, 990 insertions(+), 1389 deletions(-)
 delete mode 100644 drivers/dma/at_hdmac_regs.h
Signature · 1 line
2.25.1