linux/drivers/dma/dw-edma
LUO Haowen 3f63297ff6 dmaengine: dw-edma: Fix multiple times setting of the CYCLE_STATE and CYCLE_BIT bits for HDMA.
Others have submitted this issue (https://lore.kernel.org/dmaengine/
20240722030405.3385-1-zhengdongxiong@gxmicro.cn/),
but it has not been fixed yet. Therefore, more supplementary information
is provided here.

As mentioned in the "PCS-CCS-CB-TCB" Producer-Consumer Synchronization of
"DesignWare Cores PCI Express Controller Databook, version 6.00a":

1. The Consumer CYCLE_STATE (CCS) bit in the register only needs to be
initialized once; the value will update automatically to be
~CYCLE_BIT (CB) in the next chunk.
2. The Consumer CYCLE_BIT bit in the register is loaded from the LL
element and tested against CCS. When CB = CCS, the data transfer is
executed. Otherwise not.

The current logic sets customer (HDMA) CS and CB bits to 1 in each chunk
while setting the producer (software) CB of odd chunks to 0 and even
chunks to 1 in the linked list. This is leading to a mismatch between
the producer CB and consumer CS bits.

This issue can be reproduced by setting the transmission data size to
exceed one chunk. By the way, in the EDMA using the same "PCS-CCS-CB-TCB"
mechanism, the CS bit is only initialized once and this issue was not
found. Refer to
drivers/dma/dw-edma/dw-edma-v0-core.c:dw_edma_v0_core_start.

So fix this issue by initializing the CYCLE_STATE and CYCLE_BIT bits
only once.

Fixes: e74c39573d ("dmaengine: dw-edma: Add support for native HDMA")
Signed-off-by: LUO Haowen <luo-hw@foxmail.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/tencent_CB11AA9F3920C1911AF7477A9BD8EFE0AD05@qq.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2026-03-09 08:15:54 +01:00
..
Kconfig dmaengine: dw-edma: Depend on DW_EDMA instead of selecting it 2023-02-22 13:46:04 -06:00
Makefile dmaengine: dw-edma: Add HDMA DebugFS support 2023-05-24 12:20:45 +05:30
dw-edma-core.c dmaengine: dw-edma: fix MSI data programming for multi-IRQ case 2026-02-25 16:32:11 +05:30
dw-edma-core.h dmaengine: dw-edma: Create a new dw_edma_core_ops structure to abstract controller operation 2023-05-24 12:20:45 +05:30
dw-edma-pcie.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dw-edma-v0-core.c dmaengine: dw-edma: eDMA: Add sync read before starting the DMA transfer in remote setup 2024-02-07 09:30:52 +01:00
dw-edma-v0-core.h dmaengine: dw-edma: Create a new dw_edma_core_ops structure to abstract controller operation 2023-05-24 12:20:45 +05:30
dw-edma-v0-debugfs.c dmaengine: dw-edma: increase size of 'name' in debugfs code 2024-01-19 18:17:34 +05:30
dw-edma-v0-debugfs.h dmaengine: dw-edma: Use DMA engine device debugfs subdirectory 2023-02-10 17:15:23 -06:00
dw-edma-v0-regs.h dmaengine: dw-edma: Fix comments offset characters' alignment 2021-03-16 22:58:52 +05:30
dw-hdma-v0-core.c dmaengine: dw-edma: Fix multiple times setting of the CYCLE_STATE and CYCLE_BIT bits for HDMA. 2026-03-09 08:15:54 +01:00
dw-hdma-v0-core.h dmaengine: dw-edma: Add support for native HDMA 2023-05-24 12:20:45 +05:30
dw-hdma-v0-debugfs.c dmaengine: dw-edma: increase size of 'name' in debugfs code 2024-01-19 18:17:34 +05:30
dw-hdma-v0-debugfs.h dmaengine: dw-edma: Add HDMA DebugFS support 2023-05-24 12:20:45 +05:30
dw-hdma-v0-regs.h dmaengine: dw-edma: HDMA_V0_REMOTEL_STOP_INT_EN typo fix 2024-02-07 09:30:51 +01:00