> -----Original Message----- > From: Mark Hounschell [mailto:markh@xxxxxxxxxx] > Sent: Wednesday, May 20, 2015 3:07 PM > To: William Davis; Bjorn Helgaas > Cc: joro@xxxxxxxxxx; iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx; linux-pci@xxxxxxxxxxxxxxx; Terence Ripperda; > John Hubbard; jglisse@xxxxxxxxxx; konrad.wilk@xxxxxxxxxx; Jonathan Corbet; David S. Miller > Subject: Re: [PATCH v2 4/7] DMA-API: Add dma_(un)map_resource() documentation > > >> > >> I currently just do > >> > >> page = virt_to_page(__va(bus_address)); > >> > >> then just use the normal API. Works for writes anyway. > >> > > > > What platform is this on? I don't understand how that could work for > > peer-to-peer. As I understand it, there are no 'struct page's for MMIO > > regions, and you could actually end up with a very different page as a > > result of that unchecked translation (e.g., a "valid" struct page, but > > not in the peer's MMIO range at all). > > > > This is an x86-64 AMD 990FX chip set. Works fine. Every time. I do have > the peers memory that is being written to mmap'd by the task that is > doing this, but this works. > > Mark > I spent some time looking into this, and I was surprised to find it worked for me too. At least, it seems like it works, but it is a dangerous accident that it did, and so I think the patch is still necessary. In the IOMMU mapping paths, the IOMMU drivers (at least on x86) only really use the struct page * to get the physical address that it references, and I think that's usually done exclusively with pointer arithmetic these days. So you are getting a pointer to a struct page that actually doesn't exist, because it's either in a hole or off the end of the memory map. You can verify this by calling dump_page() on the struct page * returned by this calculation. On my Intel machine, this BUGs, unable to handle the paging request when looking at the struct page fields. If I just use the pointer without dereferencing it, the IOMMU paths can get the correct physical address without any issues, but this is by accident and not by design, nor is it portable, so we shouldn't rely on this technique. Thanks, Will -- nvpublic -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html