I've got a pci device driver that currently uses dma_map_page
to map a userspace address to a dma address. This is working fine but I'm trying to port this to the iommu api to get some of the benefits using groups and domains give.
Current Code: This works fine
ret = get_user_pages_fast(user_addr, one_page, flags, page);
dma_addr = dma_map_page(dev, off, size, *page, DMA_BIDIRECTIONAL);
IOMMU Code: This doesn't work
ret = get_user_pages_fast(...);
pfn = page_to_pfn(*page);
group = iommu_group_get(dev);
domain = iommu_domain_alloc(dev->bus);
iommu_attach_device(domain, dev);
iommu_attach_group(domain, group);
iommu_map(domain, iova, pfn << PAGE_SHIFT, size, IOMMU_READ|IOMMU_WRITE);
All functions return successfully, but when I pass the iova to the device the device can't use it. Has anyone worked with the iommu before and know where my problem is or where I can look? I haven't been able to find much on Linux's iommu implementation anywhere.
Edit: There were some entries in dmesg that I missed the first time around:
DEBUG: phys addr 0x7738de000
DEBUG: iova 0xdeadb000
DMAR: DRHD: handling fault status reg 2
DMAR: DMAR:[DMA Read] Request device [50:00.0] fault addr 1fdaee4000
DMAR:[fault reason 06] PTE Read access is not set