This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: How can I use DMA to move and disperse memory?

Part Number: AM5728


Tool/software: Linux

Hi:

Software version: ti-processor-sdk-linux-am57xx-evm-04.03.00.05,  hardware version: AM5728-ES2.0, custom board,

I found that using dmaengine_prep_interleaved_dma() can't move the scattered memory, but I can move the contiguous memory. I want to implement the distributed memory move, help me.

Thanks

  • Hi Tian,

    Check if DMA_INTERLEAVE dma transaction type will be in help for your use case.

    Supported transaction types

    DMA_INTERLEAVE

       The device supports interleaved transfer.

       These transfers can transfer data from a non-contiguous buffer to a non-contiguous buffer, opposed to DMA_SLAVE that can transfer data from a non-contiguous data set to a continuous destination buffer.

       It’s usually used for 2d content transfers, in which case you want to transfer a portion of uncompressed data directly to the display to print it

     

    DMA_SLAVE might also work for you:

     

    Our theoretical DMA controller would then only be able to do transfers that involve a single contiguous block of data. However, some of the transfers we usually have are not, and want to copy data from non-contiguous buffers to a contiguous buffer, which is called scatter-gather.

     

    DMA_SLAVE

    The device can handle device to memory transfers, including scatter-gather transfers.

     

    Regards,
    Pavel

  • Refer also to the below e2e thread:

    e2e.ti.com/.../2191463

    Regards,
    Pavel
  • Hi:

    Thank you very much for your reply.

    DMA_SLAVE is MEM_TO_DEVICE or DEVICE_TO_MEM transmission mode, and I want MEM_TO_MEM

    1、I use the dmatest test DMA in the SDK4.3 kernel.

    dmatest.c file directory “~/ti-processor-sdk-linux-am57xx-evm-04.03.00.05/board-support/linux-4.9.69+gitAUTOINC+9ce43c71ae-g9ce43c71ae/drivers/dma/dmatest.c”

    dmatest can test DMA the following transmission methods

    DMA_MEMCPY

    DMA_SG

    DMA_XOR

    DMA_PQ

    When I use the DMA_MEMCPY transfer method, I can pass the test, and the DMA_SG, DMA_XOR, and DMA_PQ transfer mode tests fail. And I want to use the DMA_SG method for transmission. help me?

     

    Run the following command:

    root@am57xx-evm:~# modprobe dmatest

    root@am57xx-evm:~# echo dma0chan0 > /sys/module/dmatest/parameters/channel

    root@am57xx-evm:~# echo 2000 > /sys/module/dmatest/parameters/timeout

    root@am57xx-evm:~# echo 1 > /sys/module/dmatest/parameters/iterations

    root@am57xx-evm:~# echo 1 > /sys/module/dmatest/parameters/run

     2、Can you give a test SLAVE_SG example? thank you very much.

    Thanks

  • Tain,

    Yes, dmatest do not support SG (scatter gather) mode. You should update this test per your needs.

    See if below patch will be in help:

    patchwork.kernel.org/.../

    Another approach you can try is to apply DMA_MEMSET_SG mode in dmatest file, you can see how DMA_MEMSET is implemented and reuse that approach for DMA_MEMSET_SG. You can even try to transform DMA_MEMSET_SG to custom DMA_MEMCPY_SG mode. DMA_MEMSET mode is available in dmatest.c in kernel 4.14.79 (PSDK v5.02), I am not sure for older kernels.

    For slave_sg example, I can provide only memory-to-device and device-to-memory example, I have no memory-to-memory example. See below:

    linux-kernel/drivers/spi/spi-omap2-mcspi.c
    linux-kernel/drivers/mtd/nand/omap2.c

    Regards,
    Pavel