linux/drivers/dma/dw-edma
Serge Semin 7ad06f2184 dmaengine: dw-edma: Fix invalid interleaved xfers semantics
The interleaved DMA transfer support added by 85e7518f42 ("dmaengine:
dw-edma: Add device_prep_interleave_dma() support") seems contradictory to
what the DMA engine defines. The next conditional statements:

  if (!xfer->xfer.il->numf)
    return NULL;
  if (xfer->xfer.il->numf > 0 && xfer->xfer.il->frame_size > 0)
    return NULL;

mean that numf can't be zero and frame_size must always be zero, otherwise
the transfer won't be executed. Furthermore, the transfer execution method
takes the frame size from the dma_interleaved_template.sgl[] array for each
frame. That array in accordance with [1] is supposed to be of
dma_interleaved_template.frame_size size, which as we discovered before the
code expects to be zero. So judging by the dw_edma_device_transfer()
implementation, the method implies the dma_interleaved_template.sgl[] array
being of dma_interleaved_template.numf size, which is wrong. Since the
dw_edma_device_transfer() method doesn't permit
dma_interleaved_template.frame_size being non-zero, the multi-chunk
interleaved transfer turns to be unsupported even though the code implies
having it supported.

Add fully functioning support of interleaved DMA transfers.

First of all, dma_interleaved_template.frame_size is supposed to be greater
or equal to one thus having at least simple linear chunked frames.
Secondly, we can create a walk-through over all the chunks and frames by
initializing the number of the eDMA burst transactions as a multiple of
dma_interleaved_template.numf and dma_interleaved_template.frame_size and
getting the frame_size-modulo of the iteration step as an index of the
dma_interleaved_template.sgl[] array.

[1] include/linux/dmaengine.h: doc struct dma_interleaved_template

Link: https://lore.kernel.org/r/20230113171409.30470-7-Sergey.Semin@baikalelectronics.ru
Fixes: 85e7518f42 ("dmaengine: dw-edma: Add device_prep_interleave_dma() support")
Tested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Acked-by: Vinod Koul <vkoul@kernel.org>
2023-01-27 17:15:33 +01:00
..
dw-edma-core.c dmaengine: dw-edma: Fix invalid interleaved xfers semantics 2023-01-27 17:15:33 +01:00
dw-edma-core.h dmaengine: dw-edma: Detach the private data and chip info structures 2022-06-23 14:49:30 -05:00
dw-edma-pcie.c dmaengine: dw-edma: Convert ll/dt phys address to PCI bus/DMA address 2023-01-27 17:15:33 +01:00
dw-edma-v0-core.c pci-v5.20-changes 2022-08-04 19:30:35 -07:00
dw-edma-v0-core.h dmaengine: dw-edma: Detach the private data and chip info structures 2022-06-23 14:49:30 -05:00
dw-edma-v0-debugfs.c dmaengine: dw-edma: Change rg_region to reg_base in struct dw_edma_chip 2022-06-23 14:56:34 -05:00
dw-edma-v0-debugfs.h dmaengine: dw-edma: Detach the private data and chip info structures 2022-06-23 14:49:30 -05:00
dw-edma-v0-regs.h dmaengine: dw-edma: Fix comments offset characters' alignment 2021-03-16 22:58:52 +05:30
Kconfig dmaengine: dw-edma: Fix build error without CONFIG_PCI_MSI 2019-06-12 10:22:02 +05:30
Makefile dmaengine: Add Synopsys eDMA IP PCIe glue-logic 2019-06-10 13:10:39 +05:30