UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Participant a7458969
Participant
9,417 Views
Registered: ‎11-09-2014

problem with axi dma engine linux driver

hi everyone,

I desigin a data capture system use AXI DMA IPCORE. I write a simple test program to test it.when I start the dma rx chanel  ,the interrupt only enter for one time.and I can only get the first 2Kb data.

Any one can slove my problem ,thanks!

 

My problem is based on the simple transfer example ,as flows


#include"zdma.h"

#include <linux/dmaengine.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include<linux/init.h>

static bool xdma_filter(struct dma_chan *chan, void *param){
   if (*((int *)chan->private) == *(int *)param)
      return true;
   
   return false;
}


static void dmatest_slave_tx_callback(void *completion)
{
    complete(completion);
}

static void dmatest_slave_rx_callback(void *completion)
{
    printk("callback called!");
    complete(completion);
}

static int  axi_dma_init(void ) {
   int i,cnt;
   dma_cap_mask_t mask;
   struct dma_chan *tx_chan,*rx_chan;
   struct xilinx_dma_config config;
   unsigned long tx_tmo = msecs_to_jiffies(1000);
   unsigned long rx_tmo = msecs_to_jiffies(1000);
    dma_cookie_t tx_cookie,rx_cookie;
    enum dma_status status;
    struct completion tx_cmp,rx_cmp;
    struct dma_async_tx_descriptor *txd = NULL, *rxd = NULL;
    enum dma_ctrl_flags flags;
   printk(KERN_INFO   "enter dma chanel \r\n");    
   //enum dma_data_direction direction;
   u32 tx_match,rx_match;

   dma_cap_zero(mask);

   dma_cap_set(DMA_SLAVE, mask);
   dma_cap_set(DMA_PRIVATE, mask);

   tx_match = (DMA_MEM_TO_DEV & 0xFF) | XILINX_DMA_IP_DMA|0;
   rx_match = (DMA_DEV_TO_MEM & 0xFF) | XILINX_DMA_IP_DMA|0;

   printk(KERN_INFO  "zfdriver: tx match is %x\n", tx_match);
   printk(KERN_INFO  "zfdriver: rx match is %x\n", rx_match);

   tx_chan = dma_request_channel(mask, xdma_filter, (void *)&tx_match);
   rx_chan = dma_request_channel(mask, xdma_filter, (void *)&rx_match);

   if (tx_chan) printk(KERN_INFO "zfdriver: Found tx device\n");
   else      printk(KERN_INFO "zfdriver: Did not find tx device\n");
   if (rx_chan) printk(KERN_INFO "zfdriver: Found rx device\n");
   else      printk(KERN_INFO "zfdriver: Did not find rx device\n");
   
   // alloc memory in kernel space
   struct device *tx_dev = tx_chan->device->dev;
   struct device *rx_dev = rx_chan->device->dev;
   dma_addr_t tx_phy,rx_phy;
   u8 *tx_vir,*rx_vir;
   
   tx_vir = dma_alloc_coherent(tx_dev, LENGTH, &tx_phy, GFP_ATOMIC); //GFP_KERNEL
   if (tx_vir == NULL) {
      printk(KERN_INFO "zfdriver: DMA tx alloc error\n");
      return -1;
   }
   memset(tx_vir, 3, LENGTH);          // fill tx with 0s
   printk(KERN_INFO "zfdriver: tx vir address = %x \n", (u_int)tx_vir);
   printk(KERN_INFO "zfdriver: tx phy address = %x \n", (u_int)tx_phy);
   
   rx_vir = dma_alloc_coherent(rx_dev, LENGTH, &rx_phy, GFP_ATOMIC); //GFP_KERNEL
   if (rx_vir == NULL) {
      printk(KERN_INFO "zfdriver: DMA rx alloc error\n");
      return -1;
   }
   memset(rx_vir, 1, LENGTH);          // fill rx with a value
   printk(KERN_INFO "zfdriver: rx vir address = %x \n", (u_int)rx_vir);
   printk(KERN_INFO "zfdriver: rx phy address = %x \n", (u_int)rx_phy);
   
   // test before transfer:
   printk(KERN_INFO "zfdriver: rx buffer before transmit:\n");
   for (i = 0; i < LENGTH; i++)   {
      printk("%x", rx_vir[i]);
   }
    // setup interrupts:
    config.coalesc = 3;
    config.delay = 0;
    rx_chan->device->device_control(rx_chan, DMA_SLAVE_CONFIG, (unsigned long)&config);
    tx_chan->device->device_control(tx_chan, DMA_SLAVE_CONFIG, (unsigned long)&config);
    
    //transfer:
    printk(KERN_INFO "zfdriver: dmaengine_prep_slave_single\n");
    flags = DMA_CTRL_ACK | DMA_COMPL_SKIP_DEST_UNMAP | DMA_PREP_INTERRUPT;
    rxd = dmaengine_prep_slave_single(rx_chan, rx_phy, LENGTH, DMA_DEV_TO_MEM, flags);
    //txd = dmaengine_prep_slave_single(tx_chan, tx_phy, LENGTH, DMA_MEM_TO_DEV, flags);
    if (!rxd) {
        printk(KERN_INFO  "zfdriver: dmaengine_prep_slave_single error");
    }
   printk(KERN_INFO  "zfdriver: init completion\n");
   init_completion(&rx_cmp);
    rxd->callback = dmatest_slave_rx_callback;
    rxd->callback_param = &rx_cmp;
    //rx_cookie = rxd->tx_submit(rxd);
    
    rx_cookie = dmaengine_submit(rxd);
   /*init_completion(&tx_cmp);
    txd->callback = dmatest_slave_tx_callback;
    txd->callback_param = &tx_cmp;
    tx_cookie = txd->tx_submit(txd);
   if (dma_submit_error(tx_cookie) || dma_submit_error(tx_cookie)) {
        printk(KERN_INFO "zfdriver: submit error");
    }
    printk(KERN_INFO  "zfdriver: dma_issue_pending\n");*/
    //dma_async_issue_pending(tx_chan);
   printk(KERN_INFO  "zfdriver: wait_for_completion\n");
for(cnt=0;cnt<2;cnt++)              //I want to capture data  twice But it doesn't work
{
    dma_async_issue_pending(rx_chan);
    rx_tmo = msecs_to_jiffies(1000);
    rx_tmo = wait_for_completion_timeout(&rx_cmp, rx_tmo);
   status = dma_async_is_tx_complete(rx_chan, rx_cookie, NULL, NULL);
   if (rx_tmo == 0) {
        printk(KERN_INFO "zfdriver: rx test timed out\n");
        if(status!=DMA_SUCCESS)
        printk(KERN_INFO "zfdriver: rx got completion callback. Status: \'%s\'\n",
           status == DMA_ERROR ? "error" : "in progress");
    }
    else if (status != DMA_SUCCESS) {
        printk(KERN_INFO "zfdriver: rx got completion callback. Status: \'%s\'\n",
           status == DMA_ERROR ? "error" : "in progress");
    }
/*    tx_tmo = wait_for_completion_timeout(&tx_cmp, tx_tmo);
   status = dma_async_is_tx_complete(tx_chan, tx_cookie, NULL, NULL);
   if (tx_tmo == 0) {
        printk(KERN_INFO "zfdriver: tx test timed out\n");
    }
    else if (status != DMA_SUCCESS) {
        printk(KERN_INFO "zfdriver: tx got completion callback. Status is \'%s\'\n",
           status == DMA_ERROR ? "error" : "in progress");
    }
   */
   // test after transfer:
   printk(KERN_INFO "zfdriver: rx buffer after transfer:\n");
   for (i = 0; i < LENGTH; i++)   {
      printk("%x", rx_vir[i]);
   }

}
   // release/free buffers:
   dma_free_coherent(tx_dev, LENGTH, tx_vir, tx_phy);
   dma_free_coherent(rx_dev, LENGTH, rx_vir, rx_phy);
   // release channels after test:
   if (tx_chan) dma_release_channel(tx_chan);
   if (rx_chan) dma_release_channel(rx_chan);
   return 0;
}

int dma_open(void) {
   return 0;
}

int dma_start(void) {
   return 0;
}

int dma_release(void) {
   return 0;
}

static void __exit axi_dma_exit(void )
{
   //return 0;
}

module_init(axi_dma_init);

module_exit(axi_dma_exit);

MODULE_LICENSE("GPL");

 

 

My test result is:

 

fdriver: tx match is 100001
zfdriver: rx match is 100002
zfdriver: Found tx device
zfdriver: Found rx device
zfdriver: tx vir address = ee800000
zfdriver: tx phy address = 2e800000
zfdriver: rx vir address = ee801000
zfdriver: rx phy address = 2e801000
zfdriver: rx buffer before transmit:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
zfdriver: dmaengine_prep_slave_single
zfdriver: init completion
zfdriver: wait_for_completion
xilinx_dma_start_transfer::simple DMA mode
xilinx-dma 40400000.axidma: Channel ee252e40 has errors 11, cdr 0 tdr 0
callback called!zfdriver: rx buffer after transfer:

0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff8899aabbccddeeff0112233445566770112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff
zfdriver: rx test timed out              //it will not enter interrupt
zfdriver: rx buffer after transfer:
0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff8899aabbccddeeff0112233445566770112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0112233445566778899aabbccddeeff

0 Kudos
9 Replies
Participant a7458969
Participant
9,397 Views
Registered: ‎11-09-2014

Re: problem with axi dma engine linux driver

No reply??

0 Kudos
Xilinx Employee
Xilinx Employee
9,395 Views
Registered: ‎09-10-2008

Re: problem with axi dma engine linux driver

Did you look at the driver source code to better understand the error that's happening?

 

xilinx-dma 40400000.axidma: Channel ee252e40 has errors 11, cdr 0 tdr 0

 

The length register of the AXI DMA is configurable when you build the h/w.  Will it support the transfer lengths you are trying to use?  I was thinking it defaults to 16KB, but you should check it.

 

0 Kudos
Participant a7458969
Participant
9,387 Views
Registered: ‎11-09-2014

Re: problem with axi dma engine linux driver

xilinx-dma 40400000.axidma: Channel ee252e40 has errors 11, cdr 0 tdr 0 

this error is reported by async_tx* api  not reported by this driver.I can't find this error code means because I have not async_tx reference

0 Kudos
Xilinx Employee
Xilinx Employee
9,376 Views
Registered: ‎09-10-2008

Re: problem with axi dma engine linux driver

It is coming from the xilinx_axidma.c as I just looked. It is just seeing the error in a register of the DMA. As I'm thinking about it more, how did you build a h/w system to support memory to memory as that's not normally what axi dma is used for. It only has a stream interface such that it's typically used to transfer to/from a stream device. For memory to memory you would need to use an AXI CDMA core rather than AXI DMA unless I'm just missing something.
0 Kudos
Participant a7458969
Participant
9,371 Views
Registered: ‎11-09-2014

Re: problem with axi dma engine linux driver

OH, My harware is a stream to memory example ,It is not build bt myself,I don't undestand it QQ图片20141110101321.jpg

the black box generate test data ,and pass it to S2MM chanel

0 Kudos
Participant a7458969
Participant
9,365 Views
Registered: ‎11-09-2014

Re: problem with axi dma engine linux driver

I put my EDK project here 

0 Kudos
Participant a7458969
Participant
9,363 Views
Registered: ‎11-09-2014

Re: problem with axi dma engine linux driver

my device tree is
axi_dma_0: axidma@40400000 {
compatible = "xlnx,axi-dma";
reg = < 0x40400000 0x10000 >;
dma-channel@40400000 {
compatible = "xlnx,axi-dma-mm2s-channel";
interrupts = < 0 59 4 >;
} ;
dma-channel@40030030 {
compatible = "xlnx,axi-dma-s2mm-channel";
interrupts = < 0 58 4 >;
} ;
0 Kudos
Xilinx Employee
Xilinx Employee
9,363 Views
Registered: ‎09-10-2008

Re: problem with axi dma engine linux driver

Not 100% sure, but I think you need to rethink your DMA test as your trying to use a single channel of the AXI DMA for memory to memory and normally (as the test was before you commented it all out) you would do memory to device on the tx channel and device to memory on the rx channel of the AXI DMA.
0 Kudos
Participant a7458969
Participant
9,359 Views
Registered: ‎11-09-2014

Re: problem with axi dma engine linux driver

thanks,But I really do the DEV_TO_MEM from S2MM chanel. 

the problem is the interrupt can only enter for once, So I can't get the next data.

0 Kudos