Jason Gunthorpe
2024-Oct-16 15:44 UTC
[PATCH v1 1/4] mm/hmm: HMM API for P2P DMA to device zone pages
On Tue, Oct 15, 2024 at 09:49:30PM -0700, Christoph Hellwig wrote:> > + /* > > + * Used for private (un-addressable) device memory only. Return a > > + * corresponding struct page, that can be mapped to device > > + * (e.g using dma_map_page) > > + */ > > + struct page *(*get_dma_page_for_device)(struct page *private_page); > > We are talking about P2P memory here. How do you manage to get a page > that dma_map_page can be used on? All P2P memory needs to use the P2P > aware dma_map_sg as the pages for P2P memory are just fake zone device > pages.FWIW, I've been expecting this series to be rebased on top of Leon's new DMA API series so it doesn't have this issue.. I think this series is at RFC quality, but shows more of the next steps. I'm guessing they got their testing done so far on a system without an iommu translation?> which also makes it clear that returning a page from the method is > not that great, a PFN might work a lot better, e.g. > > unsigned long (*device_private_dma_pfn)(struct page *page);Ideally I think we should not have the struct page * at all through these APIs if we can avoid it.. Jason
Christoph Hellwig
2024-Oct-16 16:41 UTC
[PATCH v1 1/4] mm/hmm: HMM API for P2P DMA to device zone pages
On Wed, Oct 16, 2024 at 12:44:28PM -0300, Jason Gunthorpe wrote:> > We are talking about P2P memory here. How do you manage to get a page > > that dma_map_page can be used on? All P2P memory needs to use the P2P > > aware dma_map_sg as the pages for P2P memory are just fake zone device > > pages. > > FWIW, I've been expecting this series to be rebased on top of Leon's > new DMA API series so it doesn't have this issue..That's not going to make a difference at this level.> I'm guessing they got their testing done so far on a system without an > iommu translation?IOMMU or not doens't matter much for P2P. The important difference is through the host bridge or through a switch. dma_map_page will work for P2P through the host brige (assuming the host bridge even support it as it also lacks the error handling for when not), but it lacks the handling for P2P through a switch.> > > which also makes it clear that returning a page from the method is > > not that great, a PFN might work a lot better, e.g. > > > > unsigned long (*device_private_dma_pfn)(struct page *page); > > Ideally I think we should not have the struct page * at all through > these APIs if we can avoid it..The input page is the device private page that we have at hand anyway. Until that scheme is complete redone it is the right kind of parameter.