[PATCH v8 00/13] DMA Mapping P2PDMA Pages

2022-07-10 Thread Logan Gunthorpe
by Bjorn, Jason and Max. -- Logan Gunthorpe (13): lib/scatterlist: add flag for indicating P2PDMA segments in an SGL PCI/P2PDMA: Attempt to set map_type if it has not been set PCI/P2PDMA: Introduce helpers for dma_map_sg implementations dma-mapping: allow EREMOTEIO return code for P2PDMA

[PATCH v8 08/13] iommu/dma: support PCI P2PDMA pages in dma-iommu map_sg

2022-07-10 Thread Logan Gunthorpe
segments. On unmap, P2PDMA segments are skipped over when determining the start and end IOVA addresses. With this change, the flags variable in the dma_map_ops is set to DMA_F_PCI_P2PDMA_SUPPORTED to indicate support for P2PDMA pages. Signed-off-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c

[PATCH v8 03/13] PCI/P2PDMA: Introduce helpers for dma_map_sg implementations

2022-07-10 Thread Logan Gunthorpe
-ops.h as it is only useful to dma map implementations and don't need to pollute the public pci-p2pdma header. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Christoph Hellwig --- drivers/pci/p2pdma.c| 44 +- include/linux/dma-map-ops.h | 53

[PATCH v8 06/13] dma-mapping: add flags to dma_map_ops to indicate PCI P2PDMA support

2022-07-10 Thread Logan Gunthorpe
Add a flags member to the dma_map_ops structure with one flag to indicate support for PCI P2PDMA. Also, add a helper to check if a device supports PCI P2PDMA. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe Reviewed-by: Christoph Hellwig --- include/linux/dma-map-ops.h | 10

[PATCH v8 04/13] dma-mapping: allow EREMOTEIO return code for P2PDMA transfers

2022-07-10 Thread Logan Gunthorpe
Add EREMOTEIO error return to dma_map_sgtable() which will be used by .map_sg() implementations that detect P2PDMA pages that the underlying DMA device cannot access. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe Reviewed-by: Christoph Hellwig --- kernel/dma/mapping.c | 5

[PATCH v8 10/13] nvme-pci: convert to using dma_map_sgtable()

2022-07-10 Thread Logan Gunthorpe
P2PDMA transfer is requested. When this happens, return BLK_STS_TARGET so the request isn't retried. Signed-off-by: Logan Gunthorpe Reviewed-by: Max Gurtovoy Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- drivers/nvme/host/pci.c | 69

[PATCH v8 05/13] dma-direct: support PCI P2PDMA pages in dma-direct map_sg

2022-07-10 Thread Logan Gunthorpe
the mapping operation should fail (and it will return -EREMOTEIO). SGL segments that contain PCI bus addresses are marked with sg_dma_mark_pci_p2pdma() and are ignored when unmapped. P2PDMA mappings are also failed if swiotlb needs to be used on the mapping. Signed-off-by: Logan Gunthorpe

[PATCH v8 09/13] nvme-pci: check DMA ops when indicating support for PCI P2PDMA

2022-07-10 Thread Logan Gunthorpe
Introduce a supports_pci_p2pdma() operation in nvme_ctrl_ops to replace the fixed NVME_F_PCI_P2PDMA flag such that the dma_map_ops flags can be checked for PCI P2PDMA support. Signed-off-by: Logan Gunthorpe Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- drivers/nvme/host

[PATCH v8 12/13] RDMA/rw: drop pci_p2pdma_[un]map_sg()

2022-07-10 Thread Logan Gunthorpe
dma_map_sg() now supports the use of P2PDMA pages so pci_p2pdma_map_sg() is no longer necessary and may be dropped. This means the rdma_rw_[un]map_sg() helpers are no longer necessary. Remove it all. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe Reviewed-by: Christoph Hellwig

[PATCH v8 01/13] lib/scatterlist: add flag for indicating P2PDMA segments in an SGL

2022-07-10 Thread Logan Gunthorpe
to newer root complexes and roughly require the extra address space for memory BARs used in the transactions. Signed-off-by: Logan Gunthorpe --- drivers/pci/Kconfig | 5 +++ include/linux/scatterlist.h | 69 + 2 files changed, 74 insertions(+) diff

[PATCH v8 07/13] iommu: Explicitly skip bus address marked segments in __iommu_map_sg()

2022-07-10 Thread Logan Gunthorpe
In order to support PCI P2PDMA mappings with dma-iommu, explicitly skip any segments marked with sg_dma_mark_bus_address() in __iommu_map_sg(). These segments should not be mapped into the IOVA and will be handled separately in as subsequent patch for dma-iommu. Signed-off-by: Logan Gunthorpe

[PATCH v8 13/13] PCI/P2PDMA: Remove pci_p2pdma_[un]map_sg()

2022-07-10 Thread Logan Gunthorpe
This interface is superseded by support in dma_map_sg() which now supports heterogeneous scatterlists. There are no longer any users, so remove it. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe Reviewed-by: Max Gurtovoy Reviewed-by: Christoph Hellwig

[PATCH v8 02/13] PCI/P2PDMA: Attempt to set map_type if it has not been set

2022-07-10 Thread Logan Gunthorpe
. This change will calculate the mapping type if it hasn't pre-calculated so it is no longer invalid to call pci_p2pdma_map_sg() before the mapping type is calculated, so drop the WARN_ON when that is the case. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Chaitanya Kulkarni

[PATCH v8 11/13] RDMA/core: introduce ib_dma_pci_p2p_dma_supported()

2022-07-10 Thread Logan Gunthorpe
for ib_uses_virt_dma(). Adding the dma_pci_p2pdma_supported() check allows switching away from pci_p2pdma_[un]map_sg(). Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe Reviewed-by: Max Gurtovoy Reviewed-by: Christoph Hellwig --- drivers/nvme/target/rdma.c | 2 +- include/rdma

Re: [PATCH v7 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-07-06 Thread Logan Gunthorpe
On 2022-07-06 01:04, Greg Kroah-Hartman wrote: > On Wed, Jul 06, 2022 at 08:51:27AM +0200, Christoph Hellwig wrote: >> On Tue, Jul 05, 2022 at 12:16:45PM -0600, Logan Gunthorpe wrote: >>> The current version does it through a char device, but that requires >&g

Re: [PATCH v7 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-07-05 Thread Logan Gunthorpe
On 2022-07-05 11:42, Greg Kroah-Hartman wrote: > On Tue, Jul 05, 2022 at 11:32:23AM -0600, Logan Gunthorpe wrote: >> >> >> On 2022-07-05 11:21, Greg Kroah-Hartman wrote: >>> On Tue, Jul 05, 2022 at 06:50:39PM +0200, Christoph Hellwig wrote: >>>> [note

Re: [PATCH v7 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-07-05 Thread Logan Gunthorpe
o revoke it on device removal] > > We allow mmap on PCIe config space today, right? Why is this different > from what pci_create_legacy_files() does today? > >> On Tue, Jul 05, 2022 at 10:44:49AM -0600, Logan Gunthorpe wrote: >>> We might be able to. I'm not sure. I'

Re: [PATCH v7 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-07-05 Thread Logan Gunthorpe
On 2022-07-05 10:43, Christoph Hellwig wrote: > On Tue, Jul 05, 2022 at 10:41:52AM -0600, Logan Gunthorpe wrote: >> Using sysfs means we don't need all the messy callbacks from the nvme >> driver, which is a plus. But I'm not sure how we'd get or unmap the >> mapping of

Re: [PATCH v7 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-07-05 Thread Logan Gunthorpe
On 2022-07-05 10:12, Christoph Hellwig wrote: > On Tue, Jul 05, 2022 at 10:51:02AM -0300, Jason Gunthorpe wrote: >>> In fact I'm not even sure this should be a character device, it seems >>> to fit it way better with the PCI sysfs hierchacy, just like how we >>> map MMIO resources, which these

Re: [PATCH v7 16/21] block: add check when merging zone device pages

2022-06-30 Thread Logan Gunthorpe
On 2022-06-29 10:06, Logan Gunthorpe wrote: > > > > On 2022-06-29 00:46, Christoph Hellwig wrote: >> On Wed, Jun 15, 2022 at 10:12:28AM -0600, Logan Gunthorpe wrote: >>> Consecutive zone device pages should not be merged into the same sgl >>> or bv

Re: [PATCH v7 08/21] iommu/dma: support PCI P2PDMA pages in dma-iommu map_sg

2022-06-30 Thread Logan Gunthorpe
On 2022-06-30 08:56, Robin Murphy wrote: > On 2022-06-29 23:41, Logan Gunthorpe wrote: >> >> >> On 2022-06-29 13:15, Robin Murphy wrote: >>> On 2022-06-29 16:57, Logan Gunthorpe wrote: >>>> >>>> >>>> >>>> On 2022-06-

Re: [PATCH v7 08/21] iommu/dma: support PCI P2PDMA pages in dma-iommu map_sg

2022-06-29 Thread Logan Gunthorpe
On 2022-06-29 13:15, Robin Murphy wrote: > On 2022-06-29 16:57, Logan Gunthorpe wrote: >> >> >> >> On 2022-06-29 06:07, Robin Murphy wrote: >>> On 2022-06-15 17:12, Logan Gunthorpe wrote: >>>> When a PCI P2PDMA page is seen, se

Re: [PATCH v7 01/21] lib/scatterlist: add flag for indicating P2PDMA segments in an SGL

2022-06-29 Thread Logan Gunthorpe
On 2022-06-29 12:02, Robin Murphy wrote: > On 2022-06-29 16:39, Logan Gunthorpe wrote: >> On 2022-06-29 03:05, Robin Murphy wrote: >>> On 2022-06-15 17:12, Logan Gunthorpe wrote: >>> Does this serve any useful purpose? If a page is determined to be device >>>

Re: [PATCH v7 16/21] block: add check when merging zone device pages

2022-06-29 Thread Logan Gunthorpe
On 2022-06-29 00:46, Christoph Hellwig wrote: > On Wed, Jun 15, 2022 at 10:12:28AM -0600, Logan Gunthorpe wrote: >> Consecutive zone device pages should not be merged into the same sgl >> or bvec segment with other types of pages or if they belong to different >> pgma

Re: [PATCH v7 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-29 Thread Logan Gunthorpe
On 2022-06-29 00:48, Christoph Hellwig wrote: > On Wed, Jun 15, 2022 at 10:12:32AM -0600, Logan Gunthorpe wrote: >> A pseudo mount is used to allocate an inode for each PCI device. The >> inode's address_space is used in the file doing the mmap so that all >> VMAs

Re: [PATCH v7 08/21] iommu/dma: support PCI P2PDMA pages in dma-iommu map_sg

2022-06-29 Thread Logan Gunthorpe
On 2022-06-29 06:07, Robin Murphy wrote: > On 2022-06-15 17:12, Logan Gunthorpe wrote: >> When a PCI P2PDMA page is seen, set the IOVA length of the segment >> to zero so that it is not mapped into the IOVA. Then, in finalise_sg(), >> apply the appropriate bus address to

Re: [PATCH v7 01/21] lib/scatterlist: add flag for indicating P2PDMA segments in an SGL

2022-06-29 Thread Logan Gunthorpe
On 2022-06-29 03:05, Robin Murphy wrote: > On 2022-06-15 17:12, Logan Gunthorpe wrote: >> Make use of the third free LSB in scatterlist's page_link on 64bit >> systems. >> >> The extra bit will be used by dma_[un]map_sg_p2pdma() to determine when a >> give

[PATCH v7 05/21] dma-mapping: allow EREMOTEIO return code for P2PDMA transfers

2022-06-15 Thread Logan Gunthorpe
Add EREMOTEIO error return to dma_map_sgtable() which will be used by .map_sg() implementations that detect P2PDMA pages that the underlying DMA device cannot access. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- kernel/dma/mapping.c | 4 +++- 1 file changed, 3 insertions

[PATCH v7 15/21] iov_iter: introduce iov_iter_get_pages_[alloc_]flags()

2022-06-15 Thread Logan Gunthorpe
Add iov_iter_get_pages_flags() and iov_iter_get_pages_alloc_flags() which take a flags argument that is passed to get_user_pages_fast(). This is so that FOLL_PCI_P2PDMA can be passed when appropriate. Signed-off-by: Logan Gunthorpe --- include/linux/uio.h | 6 ++ lib/iov_iter.c | 25

[PATCH v7 03/21] PCI/P2PDMA: Expose pci_p2pdma_map_type()

2022-06-15 Thread Logan Gunthorpe
implementations and don't need to pollute the public pci-p2pdma header Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe Reviewed-by: Chaitanya Kulkarni --- drivers/pci/p2pdma.c| 25 + include/linux/dma-map-ops.h | 45

[PATCH v7 09/21] nvme-pci: check DMA ops when indicating support for PCI P2PDMA

2022-06-15 Thread Logan Gunthorpe
Introduce a supports_pci_p2pdma() operation in nvme_ctrl_ops to replace the fixed NVME_F_PCI_P2PDMA flag such that the dma_map_ops flags can be checked for PCI P2PDMA support. Signed-off-by: Logan Gunthorpe Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/core.c | 3 ++- drivers/nvme

[PATCH v7 10/21] nvme-pci: convert to using dma_map_sgtable()

2022-06-15 Thread Logan Gunthorpe
P2PDMA transfer is requested. When this happens, return BLK_STS_TARGET so the request isn't retried. Signed-off-by: Logan Gunthorpe Reviewed-by: Max Gurtovoy Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/pci.c | 69 + 1 file changed, 29

[PATCH v7 08/21] iommu/dma: support PCI P2PDMA pages in dma-iommu map_sg

2022-06-15 Thread Logan Gunthorpe
addresses. With this change, the flags variable in the dma_map_ops is set to DMA_F_PCI_P2PDMA_SUPPORTED to indicate support for P2PDMA pages. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- drivers/iommu/dma-iommu.c | 68 +++ 1 file changed, 61

[PATCH v7 17/21] lib/scatterlist: add check when merging zone device pages

2022-06-15 Thread Logan Gunthorpe
are not zone device pages or both pages are zone device pages with the same pgmap. Factor out the check for page mergability into a pages_are_mergable() helper and add a check with zone_device_pages_are_mergeable(). Signed-off-by: Logan Gunthorpe --- lib/scatterlist.c | 25

[PATCH v7 06/21] dma-direct: support PCI P2PDMA pages in dma-direct map_sg

2022-06-15 Thread Logan Gunthorpe
the mapping operation should fail (and it will return -EREMOTEIO). SGL segments that contain PCI bus addresses are marked with sg_dma_mark_pci_p2pdma() and are ignored when unmapped. P2PDMA mappings are also failed if swiotlb needs to be used on the mapping. Signed-off-by: Logan Gunthorpe

[PATCH v7 16/21] block: add check when merging zone device pages

2022-06-15 Thread Logan Gunthorpe
are not zone device pages or both pages are zone device pages with the same pgmap. Add a helper to determine if zone device pages are mergeable and use this helper in page_is_mergeable(). Signed-off-by: Logan Gunthorpe --- block/bio.c| 2 ++ include/linux/mm.h | 23

[PATCH v7 01/21] lib/scatterlist: add flag for indicating P2PDMA segments in an SGL

2022-06-15 Thread Logan Gunthorpe
in the transactions. Signed-off-by: Logan Gunthorpe Reviewed-by: Chaitanya Kulkarni --- drivers/pci/Kconfig | 5 + include/linux/scatterlist.h | 44 - 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/pci/Kconfig b/drivers/pci

[PATCH v7 04/21] PCI/P2PDMA: Introduce helpers for dma_map_sg implementations

2022-06-15 Thread Logan Gunthorpe
header. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas --- drivers/pci/p2pdma.c| 59 + include/linux/dma-map-ops.h | 21 + 2 files changed, 80 insertions(+) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index

[PATCH v7 19/21] block: set FOLL_PCI_P2PDMA in bio_map_user_iov()

2022-06-15 Thread Logan Gunthorpe
When a bio's queue supports PCI P2PDMA, set FOLL_PCI_P2PDMA for iov_iter_get_pages_flags(). This allows PCI P2PDMA pages to be passed from userspace and enables the NVMe passthru requests to use P2PDMA pages. Signed-off-by: Logan Gunthorpe --- block/blk-map.c | 7 ++- 1 file changed, 6

[PATCH v7 14/21] mm: introduce FOLL_PCI_P2PDMA to gate getting PCI P2PDMA pages

2022-06-15 Thread Logan Gunthorpe
GUP Callers that expect PCI P2PDMA pages can now set FOLL_PCI_P2PDMA to allow obtaining P2PDMA pages. If GUP is called without the flag and a P2PDMA page is found, it will return an error. FOLL_PCI_P2PDMA cannot be set if FOLL_LONGTERM is set. Signed-off-by: Logan Gunthorpe --- include/linux

[PATCH v7 13/21] PCI/P2PDMA: Remove pci_p2pdma_[un]map_sg()

2022-06-15 Thread Logan Gunthorpe
This interface is superseded by support in dma_map_sg() which now supports heterogeneous scatterlists. There are no longer any users, so remove it. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe Reviewed-by: Max Gurtovoy --- drivers/pci/p2pdma.c

[PATCH v7 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-15 Thread Logan Gunthorpe
in a SIGBUS error. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas --- drivers/pci/p2pdma.c | 210 - include/linux/pci-p2pdma.h | 16 +++ include/uapi/linux/magic.h | 1 + 3 files changed, 225 insertions(+), 2 deletions(-) diff --git a/drivers/pci

[PATCH v7 02/21] PCI/P2PDMA: Attempt to set map_type if it has not been set

2022-06-15 Thread Logan Gunthorpe
. This change will calculate the mapping type if it hasn't pre-calculated so it is no longer invalid to call pci_p2pdma_map_sg() before the mapping type is calculated, so drop the WARN_ON when that is the case. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Chaitanya Kulkarni

[PATCH v7 00/21] Userspace P2PDMA with O_DIRECT NVMe devices

2022-06-15 Thread Logan Gunthorpe
by Bjorn, Jason and Max. -- Logan Gunthorpe (21): lib/scatterlist: add flag for indicating P2PDMA segments in an SGL PCI/P2PDMA: Attempt to set map_type if it has not been set PCI/P2PDMA: Expose pci_p2pdma_map_type() PCI/P2PDMA: Introduce helpers for dma_map_sg implementations dma-mapping

[PATCH v7 07/21] dma-mapping: add flags to dma_map_ops to indicate PCI P2PDMA support

2022-06-15 Thread Logan Gunthorpe
Add a flags member to the dma_map_ops structure with one flag to indicate support for PCI P2PDMA. Also, add a helper to check if a device supports PCI P2PDMA. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- include/linux/dma-map-ops.h | 10 ++ include/linux/dma

[PATCH v7 11/21] RDMA/core: introduce ib_dma_pci_p2p_dma_supported()

2022-06-15 Thread Logan Gunthorpe
for ib_uses_virt_dma(). Adding the dma_pci_p2pdma_supported() check allows switching away from pci_p2pdma_[un]map_sg(). Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe Reviewed-by: Max Gurtovoy --- drivers/nvme/target/rdma.c | 2 +- include/rdma/ib_verbs.h| 11 +++ 2 files

[PATCH v7 21/21] nvme-pci: allow mmaping the CMB in userspace

2022-06-15 Thread Logan Gunthorpe
FOLL_PCI_P2PDMA when calling GUP. And inter-device support will be checked the first time the pages are mapped for DMA. Currently this is only supported by O_DIRECT to an PCI NVMe device or through the NVMe passthrough IOCTL. Signed-off-by: Logan Gunthorpe --- drivers/nvme/host/core.c | 35

[PATCH v7 18/21] block: set FOLL_PCI_P2PDMA in __bio_iov_iter_get_pages()

2022-06-15 Thread Logan Gunthorpe
When a bio's queue supports PCI P2PDMA, set FOLL_PCI_P2PDMA for iov_iter_get_pages_flags(). This allows PCI P2PDMA pages to be passed from userspace and enables the O_DIRECT path in iomap based filesystems and direct to block devices. Signed-off-by: Logan Gunthorpe --- block/bio.c | 8

[PATCH v7 12/21] RDMA/rw: drop pci_p2pdma_[un]map_sg()

2022-06-15 Thread Logan Gunthorpe
dma_map_sg() now supports the use of P2PDMA pages so pci_p2pdma_map_sg() is no longer necessary and may be dropped. This means the rdma_rw_[un]map_sg() helpers are no longer necessary. Remove it all. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- drivers/infiniband/core/rw.c

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-02 Thread Logan Gunthorpe
On 2022-06-02 11:28, Jason Gunthorpe wrote: > On Thu, Jun 02, 2022 at 10:49:15AM -0600, Logan Gunthorpe wrote: >> >> >> On 2022-06-02 10:30, Jason Gunthorpe wrote: >>> On Thu, Jun 02, 2022 at 10:16:10AM -0600, Logan Gunthorpe wrote: >>> >>>>&g

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-02 Thread Logan Gunthorpe
On 2022-06-02 10:30, Jason Gunthorpe wrote: > On Thu, Jun 02, 2022 at 10:16:10AM -0600, Logan Gunthorpe wrote: > >>> Just stuff the pages into the mmap, and your driver unprobe will >>> automatically block until all the mmaps are closed - no different than >>&g

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-02 Thread Logan Gunthorpe
On 2022-06-02 10:30, Jason Gunthorpe wrote: > On Thu, Jun 02, 2022 at 10:16:10AM -0600, Logan Gunthorpe wrote: > >>> Just stuff the pages into the mmap, and your driver unprobe will >>> automatically block until all the mmaps are closed - no different than >>&g

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-02 Thread Logan Gunthorpe
On 2022-06-01 18:00, Jason Gunthorpe wrote: > On Fri, May 27, 2022 at 04:41:08PM -0600, Logan Gunthorpe wrote: >>> >>> IIRC this is the last part: >>> >>> https://lore.kernel.org/linux-mm/20220524190632.3304-1-alex.sie...@amd.com/ >>> >>&g

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-05-27 Thread Logan Gunthorpe
On 2022-05-27 13:03, Jason Gunthorpe wrote: > On Fri, May 27, 2022 at 09:35:07AM -0600, Logan Gunthorpe wrote: >> >> >> On 2022-05-27 06:55, Jason Gunthorpe wrote: >>> On Thu, Apr 07, 2022 at 09:47:16AM -0600, Logan Gunthorpe wrote: >>>> +static

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-05-27 Thread Logan Gunthorpe
On 2022-05-27 06:55, Jason Gunthorpe wrote: > On Thu, Apr 07, 2022 at 09:47:16AM -0600, Logan Gunthorpe wrote: >> +static void pci_p2pdma_unmap_mappings(void *data) >> +{ >> +struct pci_dev *pdev = data; >> +struct pci_p2pdma *p2pdma = rcu_dereferenc

Re: [PATCH v6 00/21] Userspace P2PDMA with O_DIRECT NVMe devices

2022-05-16 Thread Logan Gunthorpe
On 2022-05-16 16:31, Chaitanya Kulkarni wrote: > Do you have any plans to re-spin this ? I didn't get any feedback this cycle, so there haven't been any changes. I'll probably do a rebase and resend after the merge window. Logan ___ iommu mailing

[PATCH v6 21/21] nvme-pci: allow mmaping the CMB in userspace

2022-04-07 Thread Logan Gunthorpe
FOLL_PCI_P2PDMA when calling GUP. And inter-device support will be checked the first time the pages are mapped for DMA. Currently this is only supported by O_DIRECT to an PCI NVMe device or through the NVMe passthrough IOCTL. Signed-off-by: Logan Gunthorpe --- drivers/nvme/host/core.c | 15

[PATCH v6 12/21] RDMA/rw: drop pci_p2pdma_[un]map_sg()

2022-04-07 Thread Logan Gunthorpe
dma_map_sg() now supports the use of P2PDMA pages so pci_p2pdma_map_sg() is no longer necessary and may be dropped. This means the rdma_rw_[un]map_sg() helpers are no longer necessary. Remove it all. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- drivers/infiniband/core/rw.c

[PATCH v6 16/21] block: add check when merging zone device pages

2022-04-07 Thread Logan Gunthorpe
are not zone device pages or both pages are zone device pages with the same pgmap. Add a helper to determine if zone device pages are mergeable and use this helper in page_is_mergeable(). Signed-off-by: Logan Gunthorpe --- block/bio.c| 2 ++ include/linux/mm.h | 23

[PATCH v6 00/21] Userspace P2PDMA with O_DIRECT NVMe devices

2022-04-07 Thread Logan Gunthorpe
ks and Reviews by Bjorn, Jason and Max. Logan Gunthorpe (21): lib/scatterlist: add flag for indicating P2PDMA segments in an SGL PCI/P2PDMA: Attempt to set map_type if it has not been set PCI/P2PDMA: Expose pci_p2pdma_map_type() PCI/P2PDMA: Introduce helpers for dma_map_sg implementations

[PATCH v6 02/21] PCI/P2PDMA: Attempt to set map_type if it has not been set

2022-04-07 Thread Logan Gunthorpe
. This change will calculate the mapping type if it hasn't pre-calculated so it is no longer invalid to call pci_p2pdma_map_sg() before the mapping type is calculated, so drop the WARN_ON when that is the case. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Chaitanya Kulkarni

[PATCH v6 14/21] mm: introduce FOLL_PCI_P2PDMA to gate getting PCI P2PDMA pages

2022-04-07 Thread Logan Gunthorpe
GUP Callers that expect PCI P2PDMA pages can now set FOLL_PCI_P2PDMA to allow obtaining P2PDMA pages. If GUP is called without the flag and a P2PDMA page is found, it will return an error. FOLL_PCI_P2PDMA cannot be set if FOLL_LONGTERM is set. Signed-off-by: Logan Gunthorpe --- include/linux

[PATCH v6 19/21] block: set FOLL_PCI_P2PDMA in bio_map_user_iov()

2022-04-07 Thread Logan Gunthorpe
When a bio's queue supports PCI P2PDMA, set FOLL_PCI_P2PDMA for iov_iter_get_pages_flags(). This allows PCI P2PDMA pages to be passed from userspace and enables the NVMe passthru requests to use P2PDMA pages. Signed-off-by: Logan Gunthorpe --- block/blk-map.c | 7 ++- 1 file changed, 6

[PATCH v6 04/21] PCI/P2PDMA: Introduce helpers for dma_map_sg implementations

2022-04-07 Thread Logan Gunthorpe
header. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas --- drivers/pci/p2pdma.c| 59 + include/linux/dma-map-ops.h | 21 + 2 files changed, 80 insertions(+) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index

[PATCH v6 01/21] lib/scatterlist: add flag for indicating P2PDMA segments in an SGL

2022-04-07 Thread Logan Gunthorpe
in the transactions. Signed-off-by: Logan Gunthorpe Reviewed-by: Chaitanya Kulkarni --- drivers/pci/Kconfig | 5 + include/linux/scatterlist.h | 44 - 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/pci/Kconfig b/drivers/pci

[PATCH v6 07/21] dma-mapping: add flags to dma_map_ops to indicate PCI P2PDMA support

2022-04-07 Thread Logan Gunthorpe
Add a flags member to the dma_map_ops structure with one flag to indicate support for PCI P2PDMA. Also, add a helper to check if a device supports PCI P2PDMA. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- include/linux/dma-map-ops.h | 10 ++ include/linux/dma

[PATCH v6 08/21] iommu/dma: support PCI P2PDMA pages in dma-iommu map_sg

2022-04-07 Thread Logan Gunthorpe
addresses. With this change, the flags variable in the dma_map_ops is set to DMA_F_PCI_P2PDMA_SUPPORTED to indicate support for P2PDMA pages. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- drivers/iommu/dma-iommu.c | 68 +++ 1 file changed, 61

[PATCH v6 13/21] PCI/P2PDMA: Remove pci_p2pdma_[un]map_sg()

2022-04-07 Thread Logan Gunthorpe
This interface is superseded by support in dma_map_sg() which now supports heterogeneous scatterlists. There are no longer any users, so remove it. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe Reviewed-by: Max Gurtovoy --- drivers/pci/p2pdma.c

[PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-04-07 Thread Logan Gunthorpe
in a SIGBUS error. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas --- drivers/pci/p2pdma.c | 340 - include/linux/pci-p2pdma.h | 11 ++ include/uapi/linux/magic.h | 1 + 3 files changed, 350 insertions(+), 2 deletions(-) diff --git a/drivers/pci

[PATCH v6 18/21] block: set FOLL_PCI_P2PDMA in __bio_iov_iter_get_pages()

2022-04-07 Thread Logan Gunthorpe
When a bio's queue supports PCI P2PDMA, set FOLL_PCI_P2PDMA for iov_iter_get_pages_flags(). This allows PCI P2PDMA pages to be passed from userspace and enables the O_DIRECT path in iomap based filesystems and direct to block devices. Signed-off-by: Logan Gunthorpe --- block/bio.c | 8

[PATCH v6 15/21] iov_iter: introduce iov_iter_get_pages_[alloc_]flags()

2022-04-07 Thread Logan Gunthorpe
Add iov_iter_get_pages_flags() and iov_iter_get_pages_alloc_flags() which take a flags argument that is passed to get_user_pages_fast(). This is so that FOLL_PCI_P2PDMA can be passed when appropriate. Signed-off-by: Logan Gunthorpe --- include/linux/uio.h | 6 ++ lib/iov_iter.c | 25

[PATCH v6 03/21] PCI/P2PDMA: Expose pci_p2pdma_map_type()

2022-04-07 Thread Logan Gunthorpe
implementations and don't need to pollute the public pci-p2pdma header Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe Reviewed-by: Chaitanya Kulkarni --- drivers/pci/p2pdma.c| 25 + include/linux/dma-map-ops.h | 45

[PATCH v6 10/21] nvme-pci: convert to using dma_map_sgtable()

2022-04-07 Thread Logan Gunthorpe
P2PDMA transfer is requested. When this happens, return BLK_STS_TARGET so the request isn't retried. Signed-off-by: Logan Gunthorpe Reviewed-by: Max Gurtovoy Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/pci.c | 69 + 1 file changed, 29

[PATCH v6 05/21] dma-mapping: allow EREMOTEIO return code for P2PDMA transfers

2022-04-07 Thread Logan Gunthorpe
Add EREMOTEIO error return to dma_map_sgtable() which will be used by .map_sg() implementations that detect P2PDMA pages that the underlying DMA device cannot access. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- kernel/dma/mapping.c | 4 +++- 1 file changed, 3 insertions

[PATCH v6 06/21] dma-direct: support PCI P2PDMA pages in dma-direct map_sg

2022-04-07 Thread Logan Gunthorpe
the mapping operation should fail (and it will return -EREMOTEIO). SGL segments that contain PCI bus addresses are marked with sg_dma_mark_pci_p2pdma() and are ignored when unmapped. P2PDMA mappings are also failed if swiotlb needs to be used on the mapping. Signed-off-by: Logan Gunthorpe

[PATCH v6 17/21] lib/scatterlist: add check when merging zone device pages

2022-04-07 Thread Logan Gunthorpe
are not zone device pages or both pages are zone device pages with the same pgmap. Factor out the check for page mergability into a pages_are_mergable() helper and add a check with zone_device_pages_are_mergeable(). Signed-off-by: Logan Gunthorpe --- lib/scatterlist.c | 25

[PATCH v6 11/21] RDMA/core: introduce ib_dma_pci_p2p_dma_supported()

2022-04-07 Thread Logan Gunthorpe
for ib_uses_virt_dma(). Adding the dma_pci_p2pdma_supported() check allows switching away from pci_p2pdma_[un]map_sg(). Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe Reviewed-by: Max Gurtovoy --- drivers/nvme/target/rdma.c | 2 +- include/rdma/ib_verbs.h| 11 +++ 2 files

[PATCH v6 09/21] nvme-pci: check DMA ops when indicating support for PCI P2PDMA

2022-04-07 Thread Logan Gunthorpe
Introduce a supports_pci_p2pdma() operation in nvme_ctrl_ops to replace the fixed NVME_F_PCI_P2PDMA flag such that the dma_map_ops flags can be checked for PCI P2PDMA support. Signed-off-by: Logan Gunthorpe Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/core.c | 3 ++- drivers/nvme

Re: [PATCH v5 08/24] dma-direct: support PCI P2PDMA pages in dma-direct map_sg

2022-02-01 Thread Logan Gunthorpe
On 2022-02-01 1:53 p.m., Jonathan Derrick wrote: > > > On 1/27/2022 5:25 PM, Logan Gunthorpe wrote: >> Add PCI P2PDMA support for dma_direct_map_sg() so that it can map >> PCI P2PDMA pages directly without a hack in the callers. This allows >> for heterogeneous SG

Re: [PATCH v5 00/24] Userspace P2PDMA with O_DIRECT NVMe devices

2022-01-31 Thread Logan Gunthorpe
On 2022-01-31 11:56 a.m., Jonathan Derrick wrote: >> This is relatively straightforward, however the one significant >> problem is that, presently, pci_p2pdma_map_sg() requires a homogeneous >> SGL with all P2PDMA pages or all regular pages. Enhancing GUP to >> support enforcing this rule would

Re: [PATCH v5 22/24] mm: use custom page_free for P2PDMA pages

2022-01-28 Thread Logan Gunthorpe
On 2022-01-28 7:22 a.m., Jason Gunthorpe wrote: > On Thu, Jan 27, 2022 at 05:26:12PM -0700, Logan Gunthorpe wrote: >> When P2PDMA pages are passed to userspace, they will need to be >> reference counted properly and returned to their genalloc after their >> referen

Re: [PATCH v5 02/24] mm: remove extra ZONE_DEVICE struct page refcount

2022-01-28 Thread Logan Gunthorpe
On 2022-01-28 7:21 a.m., Jason Gunthorpe wrote: > On Thu, Jan 27, 2022 at 05:25:52PM -0700, Logan Gunthorpe wrote: >> From: Ralph Campbell >> >> ZONE_DEVICE struct pages have an extra reference count that complicates the >> code for put_page() and several pla

[PATCH v5 17/24] iov_iter: introduce iov_iter_get_pages_[alloc_]flags()

2022-01-27 Thread Logan Gunthorpe
Add iov_iter_get_pages_flags() and iov_iter_get_pages_alloc_flags() which take a flags argument that is passed to get_user_pages_fast(). This is so that FOLL_PCI_P2PDMA can be passed when appropriate. Signed-off-by: Logan Gunthorpe --- include/linux/uio.h | 6 ++ lib/iov_iter.c | 25

[PATCH v5 13/24] RDMA/core: introduce ib_dma_pci_p2p_dma_supported()

2022-01-27 Thread Logan Gunthorpe
for ib_uses_virt_dma(). Adding the dma_pci_p2pdma_supported() check allows switching away from pci_p2pdma_[un]map_sg(). Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe Reviewed-by: Max Gurtovoy --- drivers/nvme/target/rdma.c | 2 +- include/rdma/ib_verbs.h| 11 +++ 2 files

[PATCH v5 08/24] dma-direct: support PCI P2PDMA pages in dma-direct map_sg

2022-01-27 Thread Logan Gunthorpe
the mapping operation should fail (and it will return -EREMOTEIO). SGL segments that contain PCI bus addresses are marked with sg_dma_mark_pci_p2pdma() and are ignored when unmapped. P2PDMA mappings are also failed if swiotlb needs to be used on the mapping. Signed-off-by: Logan Gunthorpe

[PATCH v5 10/24] iommu/dma: support PCI P2PDMA pages in dma-iommu map_sg

2022-01-27 Thread Logan Gunthorpe
addresses. With this change, the flags variable in the dma_map_ops is set to DMA_F_PCI_P2PDMA_SUPPORTED to indicate support for P2PDMA pages. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- drivers/iommu/dma-iommu.c | 67 +++ 1 file changed, 60

[PATCH v5 12/24] nvme-pci: convert to using dma_map_sgtable()

2022-01-27 Thread Logan Gunthorpe
P2PDMA transfer is requested. When this happens, return BLK_STS_TARGET so the request isn't retried. Signed-off-by: Logan Gunthorpe Reviewed-by: Max Gurtovoy --- drivers/nvme/host/pci.c | 69 + 1 file changed, 29 insertions(+), 40 deletions(-) diff --git

[PATCH v5 06/24] PCI/P2PDMA: Introduce helpers for dma_map_sg implementations

2022-01-27 Thread Logan Gunthorpe
header. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas --- drivers/pci/p2pdma.c| 59 + include/linux/dma-map-ops.h | 21 + 2 files changed, 80 insertions(+) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index

[PATCH v5 09/24] dma-mapping: add flags to dma_map_ops to indicate PCI P2PDMA support

2022-01-27 Thread Logan Gunthorpe
Add a flags member to the dma_map_ops structure with one flag to indicate support for PCI P2PDMA. Also, add a helper to check if a device supports PCI P2PDMA. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- include/linux/dma-map-ops.h | 10 ++ include/linux/dma

[PATCH v5 05/24] PCI/P2PDMA: Expose pci_p2pdma_map_type()

2022-01-27 Thread Logan Gunthorpe
implementations and don't need to pollute the public pci-p2pdma header Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe Reviewed-by: Chaitanya Kulkarni --- drivers/pci/p2pdma.c| 25 + include/linux/dma-map-ops.h | 45

[PATCH v5 16/24] mm: introduce FOLL_PCI_P2PDMA to gate getting PCI P2PDMA pages

2022-01-27 Thread Logan Gunthorpe
if pte_devmap() is set. FOLL_PCI_P2PDMA cannot be set if FOLL_LONGTERM is set. Signed-off-by: Logan Gunthorpe --- include/linux/mm.h | 1 + mm/gup.c | 22 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index

[PATCH v5 18/24] block: add check when merging zone device pages

2022-01-27 Thread Logan Gunthorpe
are not zone device pages or both pages are zone device pages with the same pgmap. Add a helper to determine if zone device pages are mergeable and use this helper in page_is_mergeable(). Signed-off-by: Logan Gunthorpe --- block/bio.c| 2 ++ include/linux/mm.h | 23

[PATCH v5 15/24] PCI/P2PDMA: Remove pci_p2pdma_[un]map_sg()

2022-01-27 Thread Logan Gunthorpe
This interface is superseded by support in dma_map_sg() which now supports heterogeneous scatterlists. There are no longer any users, so remove it. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe Reviewed-by: Max Gurtovoy --- drivers/pci/p2pdma.c

[PATCH v5 14/24] RDMA/rw: drop pci_p2pdma_[un]map_sg()

2022-01-27 Thread Logan Gunthorpe
dma_map_sg() now supports the use of P2PDMA pages so pci_p2pdma_map_sg() is no longer necessary and may be dropped. This means the rdma_rw_[un]map_sg() helpers are no longer necessary. Remove it all. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- drivers/infiniband/core/rw.c

[PATCH v5 07/24] dma-mapping: allow EREMOTEIO return code for P2PDMA transfers

2022-01-27 Thread Logan Gunthorpe
Add EREMOTEIO error return to dma_map_sgtable() which will be used by .map_sg() implementations that detect P2PDMA pages that the underlying DMA device cannot access. Signed-off-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- kernel/dma/mapping.c | 4 +++- 1 file changed, 3 insertions

[PATCH v5 11/24] nvme-pci: check DMA ops when indicating support for PCI P2PDMA

2022-01-27 Thread Logan Gunthorpe
Introduce a supports_pci_p2pdma() operation in nvme_ctrl_ops to replace the fixed NVME_F_PCI_P2PDMA flag such that the dma_map_ops flags can be checked for PCI P2PDMA support. Signed-off-by: Logan Gunthorpe Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/core.c | 3 ++- drivers/nvme

[PATCH v5 02/24] mm: remove extra ZONE_DEVICE struct page refcount

2022-01-27 Thread Logan Gunthorpe
count doesn't need to be treated specially for ZONE_DEVICE. [logang: dropped no longer used section from mm.h including page_is_devmap_managed, rebased on v5.17-rc1 (possibly poorly)] Signed-off-by: Ralph Campbell Signed-off-by: Alex Sierra Signed-off-by: Logan Gunthorpe Reviewed-by: Christoph

[PATCH v5 00/24] Userspace P2PDMA with O_DIRECT NVMe devices

2022-01-27 Thread Logan Gunthorpe
after an RCU grace period, and that synchronize_rcu() was likely too slow to use in the vma close operation. - Collected Acks and Reviews by Bjorn, Jason and Max. Logan Gunthorpe (22): lib/scatterlist: add flag for indicating P2PDMA segments in an SGL PCI/P2PDMA: Attempt to set map_type

[PATCH v5 03/24] lib/scatterlist: add flag for indicating P2PDMA segments in an SGL

2022-01-27 Thread Logan Gunthorpe
cases are restricted to newer root complexes and roughly require the extra address space for memory BARs used in the transactions. Signed-off-by: Logan Gunthorpe Reviewed-by: Chaitanya Kulkarni --- drivers/pci/Kconfig | 5 + include/linux/scatterlist.h | 44

[PATCH v5 23/24] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-01-27 Thread Logan Gunthorpe
is synchronized with concurrent access with an RCU lock. The VMAs and inode will survive after the unbind of the device, but no pages will be present in the VMA and a subsequent access will result in a SIGBUS error. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas --- drivers/pci/p2pdma.c

  1   2   3   4   5   6   >