I have a pci device driver that currently uses dma_map_page to map the user space address to the dma address. This works fine, but I'm trying to port this to iommu api to get some of the benefits provided by groups and domains.
Current code: this works great
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 does not 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 transfer iova to the device, the device cannot use it. Has anyone worked with iommu before and knew where my problem is or where I can look? I could not find much in Linux iommu anywhere.
Edit : There were some entries in dmesg that I missed for the first time:
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
source share