Slave peripheral driver to DMA PL081, not able to transfer my complete 16KB data from peripheral to memory buffer?

Hi All,

I m programming a linux device driver for custom IP, the SoC has ARM PL081 DMA controller. The custom-IP is mapped to request line 3 of PL081. below is the slave configuration.

struct dma_slave_config rx_conf = {
	.src_addr = hsrx_local->phy_rx_addr,
	.direction = DMA_DEV_TO_MEM,
	.device_fc = false,
	.src_maxburst = 256,
	.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
};


I have programmed the DMA slave_sg transfer sequence as follows:

dmaengine_slave_config(hsrx_local->dma_rx_channel, &rx_conf);
pages = DIV_ROUND_UP(HSRX_FIFO_SIZE, PAGE_SIZE);
ret = sg_alloc_table(&sgt_rx, 5, GFP_ATOMIC);

for_each_sg(sgtab->sgl, sg, sgtab->nents, i) {

	if (bytesleft < (PAGE_SIZE - offset_in_page(hsrx_local->membuff)))
		mapbytes = bytesleft;
	else
		mapbytes = PAGE_SIZE - offset_in_page(hsrx_local->membuff);
	phy_addr = virt_to_page(bufp);
	dev_info(hsrx_local->dev,"virtAddr: %8p\tphy-addr: %8p\n", (void *)hsrx_local->membuff, (void *)phy_addr);
	sg_set_page(sg, phy_addr,
		mapbytes, offset_in_page(hsrx_local->membuff));
    bufp += mapbytes;
	bytesleft -= mapbytes;
	dev_info(hsrx_local->dev,
		"set RX/TX target page @ %p, %d bytes, %d left\n",
		hsrx_local->membuff, mapbytes, bytesleft);
}

rx_sglen = dma_map_sg(hsrx_local->dma_rx_channel->device->dev,
	sgt_rx.sgl,
	sgt_rx.nents, DMA_FROM_DEVICE);
if (!rx_sglen)
	goto err_rx_sgmap;

rxdesc = dmaengine_prep_slave_sg(hsrx_local->dma_rx_channel,
    	sgt_rx.sgl,
		rx_sglen,
		DMA_DEV_TO_MEM,
		DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!rxdesc)
	goto err_rxdesc;

rxdesc->callback = axidma_sync_callback;
rxdesc->callback_param = &rx_cmp;

rx_cookie = dmaengine_submit(rxdesc);
ret = dma_submit_error(rx_cookie);

The data size to be transfer from peripheral to Memory is 16KB. But only data of size max burst(256bytes) is copied to destination buffer.

why i am not able to transfer my complete 16KB data from peripheral to memory buffer?

below is the runtime log: throw out by DMA 

[   20.760878] hsrx 48c00000.hsrx: rx-buff region  :c55a0010
[   20.760904] hsrx 48c00000.hsrx: proceeding to dma->
[   20.760937] hsrx 48c00000.hsrx: using 4 pages for transfer
[   20.760967] hsrx 48c00000.hsrx: using dma1chan3 (rx) for DMA transfers
[   20.761012] hsrx 48c00000.hsrx: func: sg_alloc_table - return :0 
[   20.761050] hsrx 48c00000.hsrx: virtAddr: c55a0010   phy-addr: c6f9b400
[   20.761089] hsrx 48c00000.hsrx: set RX/TX target page @ c55a1000, 4080 bytes, 12304 left
[   20.761126] hsrx 48c00000.hsrx: virtAddr: c55a1000   phy-addr: c6f9b420
[   20.761164] hsrx 48c00000.hsrx: set RX/TX target page @ c55a2000, 4096 bytes, 8208 left
[   20.761199] hsrx 48c00000.hsrx: virtAddr: c55a2000   phy-addr: c6f9b440
[   20.761237] hsrx 48c00000.hsrx: set RX/TX target page @ c55a3000, 4096 bytes, 4112 left
[   20.761273] hsrx 48c00000.hsrx: virtAddr: c55a3000   phy-addr: c6f9b460
[   20.761310] hsrx 48c00000.hsrx: set RX/TX target page @ c55a4000, 4096 bytes, 16 left
[   20.761345] hsrx 48c00000.hsrx: virtAddr: c55a4000   phy-addr: c6f9b480
[   20.761382] hsrx 48c00000.hsrx: set RX/TX target page @ c55a4010, 16 bytes, 0 left
[   20.761474] pl08xdmac 48200000.dma-controller: pl08x_prep_slave_sg prepare transaction of 4080 bytes from slave3
[   20.761527] pl08xdmac 48200000.dma-controller: allocated DMA request signal 3 for xfer on slave3
[   20.761636] pl08xdmac 48200000.dma-controller: src=0x2c000000/4 dst=0xc55a0010+/4 len=4080
[   20.761670] pl08xdmac 48200000.dma-controller: mbus=src sbus=dst
[   20.761709] pl08xdmac 48200000.dma-controller: pl08x_fill_llis_for_desc max bytes per lli = 16380
[   20.761754] pl08xdmac 48200000.dma-controller: pl08x_fill_llis_for_desc fill lli with single lli chunk of size 0x00000ff0 (remainder 0x00000ff0)
[   20.761810] pl08xdmac 48200000.dma-controller: src=0x2c000000/4 dst=0xc55a1000+/4 len=4096
[   20.761843] pl08xdmac 48200000.dma-controller: mbus=src sbus=dst
[   20.761877] pl08xdmac 48200000.dma-controller: pl08x_fill_llis_for_desc max bytes per lli = 16380
[   20.761919] pl08xdmac 48200000.dma-controller: pl08x_fill_llis_for_desc fill lli with single lli chunk of size 0x00001000 (remainder 0x00001000)
[   20.761970] pl08xdmac 48200000.dma-controller: src=0x2c000000/4 dst=0xc55a2000+/4 len=4096
[   20.762001] pl08xdmac 48200000.dma-controller: mbus=src sbus=dst
[   20.762035] pl08xdmac 48200000.dma-controller: pl08x_fill_llis_for_desc max bytes per lli = 16380
[   20.762077] pl08xdmac 48200000.dma-controller: pl08x_fill_llis_for_desc fill lli with single lli chunk of size 0x00001000 (remainder 0x00001000)
[   20.762127] pl08xdmac 48200000.dma-controller: src=0x2c000000/4 dst=0xc55a3000+/4 len=4096
[   20.762158] pl08xdmac 48200000.dma-controller: mbus=src sbus=dst
[   20.762192] pl08xdmac 48200000.dma-controller: pl08x_fill_llis_for_desc max bytes per lli = 16380
[   20.762234] pl08xdmac 48200000.dma-controller: pl08x_fill_llis_for_desc fill lli with single lli chunk of size 0x00001000 (remainder 0x00001000)
[   20.762284] pl08xdmac 48200000.dma-controller: src=0x2c000000/4 dst=0xc55a4000+/4 len=16
[   20.762315] pl08xdmac 48200000.dma-controller: mbus=src sbus=dst
[   20.762349] pl08xdmac 48200000.dma-controller: pl08x_fill_llis_for_desc max bytes per lli = 16380
[   20.762389] pl08xdmac 48200000.dma-controller: pl08x_fill_llis_for_desc fill lli with single lli chunk of size 0x00000010 (remainder 0x00000010)
[   20.762435] pl08xdmac 48200000.dma-controller: lli            csrc       cdst       clli       cctl
[   20.762493] pl08xdmac 48200000.dma-controller:   0 @c7000000: 0x2c000000 0xc55a0010 0xc7000010 0x184bf3fc
[   20.762548] pl08xdmac 48200000.dma-controller:   1 @c7000010: 0x2c000000 0xc55a1000 0xc7000020 0x184bf400
[   20.762604] pl08xdmac 48200000.dma-controller:   2 @c7000020: 0x2c000000 0xc55a2000 0xc7000030 0x184bf400
[   20.762659] pl08xdmac 48200000.dma-controller:   3 @c7000030: 0x2c000000 0xc55a3000 0xc7000040 0x184bf400
[   20.762712] pl08xdmac 48200000.dma-controller:   4 @c7000040: 0x2c000000 0xc55a4000 0x00000000 0x984bf004
[   20.762759] pl08xdmac 48200000.dma-controller: vchan c68ecd80: txd c5556300[2]: submitted
[   20.762828] pl08xdmac 48200000.dma-controller: allocated physical channel 0 for xfer on slave3
[   20.762894] pl08xdmac 48200000.dma-controller: WRITE channel 0: csrc=0x2c000000, cdst=0xc55a0010, clli=0xc7000010, cctl=0x184bf3fc, ccfg=0x0000d006

Any help will be deeply appreciated.

Thanks & Regards,

Vivek T

More questions in this forum