coherent_dma_mask :用来分配连续一致性dma。 dma_mask:在dma_map_single->dma_map_page,dma_capable用。 先看默认设置。后续可以通过pci_set_dma_mask/pci_set_consistent_dma_mask分别设置 设置: int pci_setup_device(struct pci_dev *dev) { u32 class; u16 cmd; u8 hdr_type; int pos = 0; stru...
对于primaII而言,绝大多少的外设的dma_coherent_mask都设置为0XffffffffULL(4GB内存全覆盖),但是SD那个则设置为256MB-1对应的数字。这样当primaII的SD驱动调用dma_alloc_coherent()的时候,GFP_DMA标记被设置,以指挥内核从DMA ZONE申请内存。但是,其他的外设,mask覆盖了整个4GB,调用dma_alloc_coherent()获得的内存就...
staticintetnaviv_pdev_probe(struct platform_device *pdev){structdevice*dev= &pdev->dev;structdevice_node*node=dev->of_node;structcomponent_match*match=NULL;dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));if(node) {structdevice_node*core_node;inti;for(i =0; ; i++) { core_nod...
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp) { void *ret; if (!dev || *dev->dma_mask >= 0xffffffffUL) gfp &= ~GFP_DMA; ret = (void *)__get_free_pages(gfp, get_order(size)); //(1) if (ret) { memset(ret, 0, size); *...
A =dma_alloc_writecombine(B,C,D,GFP_KERNEL); 含义: A: 内存的虚拟起始地址,在内核要用此地址来操作所分配的内存 B: struct device指针,可以平台初始化里指定,主要是dma_mask之类,可参考framebuffer C: 实际分配大小,传入dma_map_size即可 D: 返回的内存物理地址,dma就可以用。
dma_addr_t *dma_handle, gfp_t gfp) { void *ret; if (!dev || *dev->dma_mask >= 0xffffffffUL) gfp &= ~GFP_DMA; ret = (void *)__get_free_pages(gfp, get_order(size)); //(1) if (ret) { memset(ret, 0, size); ...
这里的consistent实际上是coherent的概念,不能保证consistent,也就是说需要memory barrier来保证memory order。...2.指定DMA设备的寻址范围 include/linux/dma-mapping.h // 用于一致性内存映射的映射范围 static inline int dma_set_coherent_mask...buffer大小 // dma_handle 返回DMA buf的物理地址 // flag 分配...
A future change will convert the DMA API implementation from the architecture specific arch/s390/pci/pci_dma.c to using the common code drivers/iommu/dma-iommu.c which the utilizes the same IOMMU hardware through the s390-iommu driver. Unlike the s390 specific DMA API this requires devices to...
* Set both the DMA mask and the coherent DMA mask to the same thing. * Note that we don't check the return value from dma_set_coherent_mask() * as the DMA API guarantees that the coherent DMA mask can be set to * the same or smaller than the streaming DMA mask. */ static inli...
dma_mask = DMA_BIT_MASK(8 * sizeof(dma_addr_t)); if (dma_set_coherent_mask(dev->device, dma_mask)) { axidma_err("Unable to set the DMA coherent mask.\n"); goto device_cleanup; } Then the character device would be created. ...