void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, const struct iommu_ops *iommu, bool coherent) { if (!dev->dma_ops) dev->dma_ops = &arm64_swiotlb_dma_ops; //使用该ops dev->archdata.dma_coherent = coherent; __iommu_setup_dma_ops(dev, dma_base, size, io...
req-\>dma = dma_map_single(&gadget-\>dev, req-\>buf, req-\>length, is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); DMA_TO_DEVICE从内存搬移数据到device,DMA_FROM_DEVICE从device搬移数据到内存 return 0; } dma_map_single—》dma_map_single_attrs—》dma_map_single—》ops-\>map_page-》_...
iommu的dma_map_ops是drivers\iommu\Dma-iommu.c中定义的iommu_dma_ops。 iommu的dma_map_ops是drivers/xen/swiotlb-xen.c中定义的xen_swiotlb_dma_ops。 #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0) #define dma_unmap_single(d, a, s, r) dma_unmap_single_...
看图中解映射的部分就是在iommu_unmap_fast流程中处理的就是调用iommu的unmap然后通过ops 调用到arm smmu v3驱动的 unmap函数:__iommu_dma_unmap->iommu_unmap_fast->(ops->unmap: arm_smmu_unmap)->arm_lpae_unmap; 我们进入函数arm_lpae_unmap中看看是干啥的,见下图: 这个函数采用递归的方式来查找io page ...
if (dma_is_direct(ops)) addr = dma_direct_map_page(dev, page, offset, size, dir, attrs); else addr = ops->map_page(dev, page, offset, size, dir, attrs); debug_dma_map_page(dev, page, offset, size, dir, addr); return addr; ...
dma_map_single/dma_unmap_single的定义 dma_map_single()和dma_unmap_single()都在include\linux\dma-mapping.h里定义。如果没有特殊情况,会调用dma_direct_map_page()、dma_direct_unmap_page()。 arm64的特殊情况包括iommu和Xen虚拟机。 iommu和Xen虚拟机都需要提供dma_map_ops,于是使用其中的map、unmap函数...
老规矩,直接撸代码,我们看到dma的释放流程也是很简单的,首先将iova和pa进行解映射处理,然后将iova结构给释放掉; 看图中解映射的部分就是在iommu_unmap_fast流程中处理的就是调用iommu的unmap然后通过ops 调用到arm smmu v3驱动的 unmap函数:__iommu_dma_unmap->iommu_unmap_fast->(ops->unmap: arm_smmu_unmap)...
(dev, "Adding to IOMMU failed: %d\n", err); ops = NULL; } return ops; } */ int pci_for_each_dma_alias(struct pci_dev *pdev, int (*fn)(struct pci_dev *pdev, u16 alias, void *data), void *data) { ... struct pci_bus *bus; int ret; ret = fn(pdev, PCI_DEVID(pdev...
dma_map_single()和dma_unmap_single()都在include\linux\dma-mapping.h里定义。如果没有特殊情况,会调用dma_direct_map_page()、dma_direct_unmap_page()。 arm64的特殊情况包括iommu和Xen虚拟机。 iommu和Xen虚拟机都需要提供dma_map_ops,于是使用其中的map、unmap函数。iommu的dma_map_ops是drivers\iommu\D...
Would dma_alloc_coherent make a difference? (Of course, I'll try this out) I'm unable to figure out the problem. Is this is a PCIe driver issue or an issue with the device or is there a fix/patch available for ARM PCIe DMA ops? Any help would be appreciated!!