打印
[i.MX]

DMA+EIM运行时死机

[复制链接]
1133|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wwlcy|  楼主 | 2015-4-16 10:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我现在在做dma+eim与fpga通信,我参考飞思卡尔提供的mem to mem的程序,然后对其修改,将wbuf改成eimbase虚拟地址后,一运行就死机,不知道该如何解决,以下是我的read的一段程序,抱大神大腿。
ssize_t sdma_read (struct file *filp, char __user * buf, size_t count,
                                                                loff_t * offset)
{
        u8 *index1;
        int i, ret;
        struct dma_slave_config dma_m2m_config;
        struct dma_async_tx_descriptor *dma_m2m_desc;
        index1 = wbuf;

        for (i=0; i<SDMA_BUF_SIZE/4; i++) {
                *(index1 + i) = i;
        }

        dma_m2m_config.direction = DMA_MEM_TO_MEM;
        dma_m2m_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
        dmaengine_slave_config(dma_m2m_chan, &dma_m2m_config);

        sg_init_table(sg, 1);
        sg_set_buf(&sg[0], eimbase, SDMA_BUF_SIZE/4);
        ret = dma_map_sg(NULL, sg, 1, dma_m2m_config.direction);
        printk("eimbase page_link=%ld\n", sg->page_link);
        printk("eimbase offset=%d\n", sg->offset);
        printk("eimbase dma_address=%x\n", sg->dma_address);
        printk("eimbase length=%d\n", sg->length);

        dma_m2m_desc = dma_m2m_chan->device->device_prep_slave_sg(dma_m2m_chan,sg, 1, dma_m2m_config.direction, 1);

        sg_init_table(sg2, 1);
        sg_set_buf(&sg2[0], rbuf, SDMA_BUF_SIZE);
        ret = dma_map_sg(NULL, sg2, 1, dma_m2m_config.direction);
        printk("rbuf page_link=%ld\n", sg2->page_link);
        printk("rbuf offset=%d\n", sg2->offset);
        printk("rbuf dma_address=%x\n", sg2->dma_address);
        printk("rbuf length=%d\n", sg2->length);
       
        dma_m2m_desc = dma_m2m_chan->device->device_prep_slave_sg(dma_m2m_chan,sg2, 1, dma_m2m_config.direction, 0);

        dma_m2m_desc->callback = dma_m2m_callback;
        dmaengine_submit(dma_m2m_desc);

        wait_for_completion(&dma_m2m_ok);
        dma_unmap_sg(NULL, sg, 1, dma_m2m_config.direction);
        dma_unmap_sg(NULL, sg2, 1, dma_m2m_config.direction);
       
        for (i=0; i<SDMA_BUF_SIZE/4; i++) {
                if (*(rbuf+i) != *(wbuf+i)) {
                        printk("buffer 1 copy falled!\n");
                        return 0;
                }
        }
        printk("buffer 1 copy passed!\n");

        i = copy_to_user(buf, rbuf, count);
        return 0;
}

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

5

主题

10

帖子

0

粉丝