On 09/04/2019 23:47, Nicolin Chen wrote:
Hi all, According to the routine of iommu_dma_alloc(), it allocates an iova then does iommu_map() to map the iova to a physical address of new allocated pages. However, in remoteproc_core.c, I see its code try to iommu_map() without having an alloc_iova() or alloc_iova_fast(). Is it safe to do so? If an iova range is not allocated but mapped, would a later iommu_dma_alloc() happen to hit this iova range when doing its alloc_iova() and then fail to map? And I am not very familiar with remoteproc code, so if I am missing something, please kindly educate me.
AFAICS that area of the remoteproc code is using its own IOMMU domain, so it's free to manage that domain's address space however it wants - the generic IOVA allocator is a good option for the DMA API where the only constraint is that the address we get fits within a mask, but drivers with more specific requirements may well be better off using other allocation methods. See also various DRM drivers (Tegra/Rockchip/etc.) that do similar, using a drm_mm to manage the address space.
Robin.