Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C Raspbian Linux 4.1 dma_map_sg():填充.page_链接?_C_Linux_Driver_Raspbian_Dma - Fatal编程技术网

C Raspbian Linux 4.1 dma_map_sg():填充.page_链接?

C Raspbian Linux 4.1 dma_map_sg():填充.page_链接?,c,linux,driver,raspbian,dma,C,Linux,Driver,Raspbian,Dma,我需要在Raspbian Linux 4.1字符模式驱动程序中设置dma_map_sg()调用。根据我所能确定的,需要在sg_列表[]中设置的条目有: .page_link .offset .length 我遇到的问题是.page_链接成员。我有一些用户模式的虚拟内存指针。由于这是一个dma引擎接口,我认为这里需要一个内核虚拟地址。问题是如何填充.page\u链接 用户模式虚拟地址是来自GPU的内存映射区域(为了避免CPU缓存)。这些是在用户模式程序中设置

我需要在Raspbian Linux 4.1字符模式驱动程序中设置dma_map_sg()调用。根据我所能确定的,需要在sg_列表[]中设置的条目有:

.page_link
.offset                   
.length
我遇到的问题是.page_链接成员。我有一些用户模式的虚拟内存指针。由于这是一个dma引擎接口,我认为这里需要一个内核虚拟地址。问题是如何填充.page\u链接

用户模式虚拟地址是来自GPU的内存映射区域(为了避免CPU缓存)。这些是在用户模式程序中设置的,并使用ioctl(2)传递到char驱动程序中

这是针对Raspberry Pi 2的,目标是DMA将GPIO位捕获到内存块中进行捕获(逻辑分析仪)。我在3.X内核下工作,但是4.X内核已经改为使用dma引擎

字符驱动程序代码片段:

struct s_my_ioctl {
    uint32_t    slave_id;   /* Slave ID to assign */
    uint32_t    page_sz;    /* Size of each page */
    uint32_t    src_addr;   /* One source address */
    uint32_t    n_dst;      /* # of destination addresses */
    uint32_t    *pdst_addr; /* Ptr to first designation address */
} sarg; /* Copied with copy_from_user() in an ioctl call */

/* allocate dma (successful)... */
rc = dmaengine_slave_config(dma_chan,&config); /* OK */
...
sglist = kmalloc(sarg.n_dst * sizeof(uint32_t),GFP_KERNEL);
n_sglist = sarg.n_dst;

/* Populate sg_list */
for ( x=0; x<n_sglist; ++x ) {
    sglist[x].page_link = (unsigned long)usr_ptrs[x]; /* ?? */
    sglist[x].offset = 0;
    sglist[x].length = sarg.page_sz;
}

/* Fails */
sgn = dma_map_sg(dma_chan->device->dev,sglist,n_sglist,DMA_DEV_TO_MEM);
更新(为子孙后代):

  • 我错过了对sg_init_table()的调用,该调用现已就位
  • 要填充该表,我需要使用sg_set_buf()(或sg_set_page())
所以我现在离你越来越近了

(v7_dma_inv_range) from [..] (dma_cache_maint_page+0x84/0x88)         
(dma_cache_maint_page) from [..] (arm_dma_map_page+0x98/0xa4)         
(arm_dma_map_page) from [..] (arm_dma_map_sg+0x88/0xfc)                     
(arm_dma_map_sg) from [..] (rpidma_ioctl+0x348/0x4b0 [rpidma4x])        
(rpidma_ioctl [rpidma4x]) from [..] (do_vfs_ioctl+0x88/0x60c)        
(do_vfs_ioctl) from [..] (SyS_ioctl+0x44/0x68)        
(SyS_ioctl) from [..] (ret_fast_syscall+0x0/0x54)