On Thu, Nov 07, 2024 at 09:32:56AM +0100, Christoph Hellwig wrote: > On Tue, Nov 05, 2024 at 03:53:57PM -0400, Jason Gunthorpe wrote: > > > Yeah, I don't really get the struct page argument. In fact if we look > > > at the nitty-gritty details of dma_map_page it doesn't really need a > > > page at all. > > > > Today, if you want to map a P2P address you must have a struct page, > > because page->pgmap is the only source of information on the P2P > > topology. > > > > So the logic is, to get P2P without struct page we need a way to have > > all the features of dma_map_sg() but without a mandatory scatterlist > > because we cannot remove struct page from scatterlist. > > Well, that is true but also not the point. The hard part is to > find the P2P routing information without the page. After that > any physical address based interface will work, including a trivial > dma_map_phys. Once we are freed from scatterlist we can explore a design that would pass the P2P routing information directly. For instance imagine something like: dma_map_p2p(dev, phys, p2p_provider); Then dma_map_page(dev, page) could be something like if (is_pci_p2pdma_page(page)) dev_map_p2p(dev, page_to_phys(page), page->pgmap->p2p_provider)