On Tue, Jan 28, 2025 at 09:51:52AM +0100, Thomas Hellström wrote: > How would the pgmap device know whether P2P is actually possible > without knowing the client device, (like calling pci_p2pdma_distance) > and also if looking into access control, whether it is allowed? The DMA API will do this, this happens after this patch is put on top of Leon's DMA API patches. The mapping operation will fail and it will likely be fatal to whatever is going on. get_dma_pfn_for_device() returns a new PFN, but that is not a DMA mapped address, it is just a PFN that has another struct page under it. There is an implicit assumption here that P2P will work and we don't need a 3rd case to handle non-working P2P.. > but leaves any dma- mapping or pfn mangling to be done after the > call to hmm_range_fault(), since hmm_range_fault() really only needs > to know whether it has to migrate to system or not. See above, this is already the case.. > One benefit of using this alternative > approach is that struct hmm_range can be subclassed by the caller and > for example cache device pairs for which p2p is allowed. If you want to directly address P2P non-uniformity I'd rather do it directly in the core code than using a per-driver callback. Every driver needs exactly the same logic for such a case. Jason