On 2021-09-28 2:05 p.m., Jason Gunthorpe wrote: > On Thu, Sep 16, 2021 at 05:40:59PM -0600, Logan Gunthorpe wrote: > >> +static void pci_p2pdma_unmap_mappings(void *data) >> +{ >> + struct pci_dev *pdev = data; >> + struct pci_p2pdma *p2pdma = rcu_dereference_protected(pdev->p2pdma, 1); >> + >> + p2pdma->active = false; >> + synchronize_rcu(); >> + unmap_mapping_range(p2pdma->inode->i_mapping, 0, 0, 1); >> + pci_p2pdma_free_mappings(p2pdma->inode->i_mapping); >> +} > > If this is going to rely on unmap_mapping_range then GUP should also > reject this memory for FOLL_LONGTERM.. Right, makes sense. > > What along this control flow: > >> + error = devm_add_action_or_reset(&pdev->dev, >> pci_p2pdma_unmap_mappings, >> + pdev); > > Waits for all the page refcounts to go to zero? That's already in the existing code as part of memunmap_pages() which puts the original reference to all the pages and then waits for the reference to go to zero. This new action unmaps all the VMAs so that the subsequent call to memunmap_pages() doesn't block on userspace processes. Logan _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
- [PATCH v3 10/20] nvme-pci: convert to using dma_map_sgtabl... Logan Gunthorpe
- [PATCH v3 09/20] nvme-pci: check DMA ops when indicating s... Logan Gunthorpe
- [PATCH v3 19/20] PCI/P2PDMA: introduce pci_mmap_p2pmem() Logan Gunthorpe
- Re: [PATCH v3 19/20] PCI/P2PDMA: introduce pci_mmap_p... Bjorn Helgaas
- Re: [PATCH v3 19/20] PCI/P2PDMA: introduce pci_mmap_p... Jason Gunthorpe
- Re: [PATCH v3 19/20] PCI/P2PDMA: introduce pci_mm... Logan Gunthorpe
- Re: [PATCH v3 19/20] PCI/P2PDMA: introduce pc... Jason Gunthorpe
- Re: [PATCH v3 19/20] PCI/P2PDMA: introduc... Logan Gunthorpe
- Re: [PATCH v3 19/20] PCI/P2PDMA: int... Jason Gunthorpe
- Re: [PATCH v3 19/20] PCI/P2PDMA: introduce pci_mmap_p... Jason Gunthorpe
- Re: [PATCH v3 19/20] PCI/P2PDMA: introduce pci_mm... Logan Gunthorpe
- [PATCH v3 08/20] iommu/dma: support PCI P2PDMA pages in dm... Logan Gunthorpe
- Re: [PATCH v3 08/20] iommu/dma: support PCI P2PDMA pa... Jason Gunthorpe
- [PATCH v3 18/20] mm: use custom page_free for P2PDMA pages Logan Gunthorpe
- [PATCH v3 20/20] nvme-pci: allow mmaping the CMB in usersp... Logan Gunthorpe
- [PATCH v3 17/20] block: set FOLL_PCI_P2PDMA in bio_map_use... Logan Gunthorpe
- Re: [PATCH v3 00/20] Userspace P2PDMA with O_DIRECT NVMe d... Jason Gunthorpe
- Re: [PATCH v3 00/20] Userspace P2PDMA with O_DIRECT N... Logan Gunthorpe
- Re: [PATCH v3 00/20] Userspace P2PDMA with O_DIRE... Jason Gunthorpe
- Re: [PATCH v3 00/20] Userspace P2PDMA with O_... Logan Gunthorpe
- Re: [PATCH v3 00/20] Userspace P2PDMA wit... Jason Gunthorpe