[英]How do I use dma_alloc_attr() with DMA_ATTR_NO_KERNEL_MAPPING?
I want to use DMA_ATTR_NO_KERNEL_MAPPING
for memory allocation. 我想使用DMA_ATTR_NO_KERNEL_MAPPING
进行内存分配。 According to the kernel documentation , I have to use dma_mmap_attrs()
, but it requires struct vm_area_struct
as one of its argument. 根据内核文档 ,我必须使用dma_mmap_attrs()
,但是它需要struct vm_area_struct
作为其参数之一。 How can I use it? 如何使用?
dma_addr_t phys;
void *virt;
void *tmp_virt;
struct vm_area_struct *vma;
pr_debug("pmap: cma: request to alloc %s for size 0x%08x\n",
info->name, info->size);
if(strcmp(info->name,"video") == 0)
{
pr_debug("video allocation.....\n");
tmp_virt = dma_alloc_attrs(pmap_device, info->size, &phys, GFP_KERNEL,
DMA_ATTR_NO_KERNEL_MAPPING | DMA_ATTR_FORCE_CONTIGUOUS);
virt = dma_mmap_attrs(pmap_device, vma, tmp_virt, &phys, info->size,
DMA_ATTR_NO_KERNEL_MAPPING | DMA_ATTR_FORCE_CONTIGUOUS);
}
I am requesting memory allocation using the ioctl call from user space, and then a kernel panic occurs with a system reboot. 我正在从用户空间使用ioctl调用来请求内存分配,然后在系统重新引导时发生内核恐慌。
How do I use DMA_ATTR_NO_KERNEL_MAPPING
for user space allocation using ioctl? 如何使用ioctl将DMA_ATTR_NO_KERNEL_MAPPING
用于用户空间分配?
In my sample driver code I am declaring struct vm_area_struct *vma
. 在我的示例驱动程序代码中,我声明了struct vm_area_struct *vma
。 Is that correct? 那是对的吗?
if you used DMA_ATTR_NO_KERNEL_MAPPING in dma_alloc_attr(), it means that you dont want virtual mapping for the allocated area. 如果在dma_alloc_attr()中使用了DMA_ATTR_NO_KERNEL_MAPPING,则意味着您不希望为分配的区域进行虚拟映射。 DMA_ATTR_NO_KERNEL_MAPPING only used again to mapped with user space memory, no direct api to mapped it with kernel space memory. DMA_ATTR_NO_KERNEL_MAPPING仅再次用于与用户空间内存进行映射,而没有直接api将其与内核空间内存进行映射。
if user space want to mapped it virtually, below are the options. 如果用户空间要虚拟映射,则下面是选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.