本来拟定是想直接在x86的服务器上测试,但是发现执行时一直获取不到dma通道,只能在arm架构下尝试。
1.测试代码,如下,网上找的,驱动的环境搭建之前
/*
* DMA test module
*
* Copyright (C) 2007 KEDACOM Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/delay.h>
#include <linux/dmaengine.h>
#include <linux/init.h>
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/random.h>
#include <linux/slab.h>
#include <linux/wait.h>
#include <linux/gfp.h>
#include <linux/kernel.h>
#include <linux/highmem.h>
#include <linux/mm.h>
#include <linux/dma-mapping.h>
#include <linux/async_tx.h>
#include <linux/jiffies.h>
#define XFER_TIMES 4000
#define XFER_LEN 1<<20
void *dma_src,*dma_dest;
struct dma_chan *chan = NULL;
static int __init dmatest_init(void)
{
int xfer_order = get_order(XFER_LEN);
int i,ret ;
dma_cap_mask_t mask;
dma_cookie_t cookie;
enum dma_status status;
u64 j1,j2;
dma_src = __get_free_pages(GFP_KERNEL | GFP_DMA, xfer_order);
if (!dma_src) {
printk(KERN_ALERT "dma_src :alloc memory fail.n");
ret = -ENOMEM;
goto CLEAN;
}
dma_dest = __get_free_pages(GFP_KERNEL | GFP_DMA, xfer_order);
if (!dma_dest) {
printk(KERN_ALERT "dma_dest :alloc memory fail.n");
ret = -ENOMEM;
goto CLEAN;
}
printk(KERN_NOTICE"dma_src=%#x,dma_dest=%#xn",dma_src,dma_dest);
dma_cap_zero(mask);
dma_cap_set(DMA_MEMCPY, mask);
chan = dma_request_channel(mask, NULL, NULL);
if (chan) {
printk(KERN_NOTICE "dma_request_channel ok,current channel is : %