- 论坛徽章:
- 0
|
本帖最后由 testh 于 2012-11-30 19:11 编辑
熟悉的请讲讲。
连续调用两次dma_alloc_coherent(NULL,1024*1024,&addr,GFP_KERNEL)只有第一次成功,后面的就会失败,这是什么原因导致的呢?
代码如下:- dma_addr_t addr[2];
- unsigned char *vir[2];
- static int __init testmacro_init(void)
- {
- int i;
- printk("enter init\n");
- for(i=0;i<2;i++)
- {
- vir[i]=dma_alloc_coherent(NULL,1024,&addr[i],GFP_KERNEL);
- if(vir[i]==NULL)
- {
- printk("alloc error\n");
- return -1;
- }
- else
- {
- printk("alloc ok,addr[0]=[0x%x],vir[0]=[0x%x]\n",addr[i],vir[i]);
- }
- }
- return 0;
- }
- module_init(testmacro_init);
- static void __exit testmacro_exit(void)
- {
- int i;
- for(i=0;i<2;i++)
- {
- dma_free_coherent(NULL,1024,vir[i],addr[i]);
- }
- }
- module_exit(testmacro_exit);
复制代码 |
|