[PATCH 05/16] dma-mapping: Introduce dma_map_sg_p2pdma()

2021-04-08 Thread Logan Gunthorpe
to inform the lower level implementations that P2PDMA pages are allowed and to warn if a caller introduces them into the regular dma_map_sg() interface. Signed-off-by: Logan Gunthorpe --- include/linux/dma-mapping.h | 15 +++ kernel/dma/mapping.c| 52

[PATCH 06/16] lib/scatterlist: Add flag for indicating P2PDMA segments in an SGL

2021-04-08 Thread Logan Gunthorpe
-off-by: Logan Gunthorpe --- drivers/pci/Kconfig | 2 +- include/linux/scatterlist.h | 49 ++--- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 0c473d75e625..90b4bddb3300 100644 --- a/drivers

[PATCH 07/16] PCI/P2PDMA: Make pci_p2pdma_map_type() non-static

2021-04-08 Thread Logan Gunthorpe
pci_p2pdma_map_type() will be needed by the dma-iommu map_sg implementation because it will need to determine the mapping type ahead of actually doing the mapping to create the actual iommu mapping. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 34

[PATCH 02/16] PCI/P2PDMA: Avoid pci_get_slot() which sleeps

2021-04-08 Thread Logan Gunthorpe
ice list. It should be impossible for the host bridge's device to go away while references are held on child devices, so the first element should not be able to change and, thus, this should be safe. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 14 -- 1 file changed,

[PATCH 08/16] PCI/P2PDMA: Introduce helpers for dma_map_sg implementations

2021-04-08 Thread Logan Gunthorpe
is useful for IOMMU dma_map_sg() implementations where the sg segment containing the page differs from the sg segment containing the DMA address. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 65 ++ include/linux/pci-p2pdma.h | 21

[PATCH 13/16] nvme-pci: Convert to using dma_map_sg_p2pdma for p2pdma pages

2021-04-08 Thread Logan Gunthorpe
-by: Logan Gunthorpe --- drivers/nvme/host/pci.c | 28 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 14f092973792..a1ed07ff38b7 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -577,17

[PATCH 09/16] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg

2021-04-08 Thread Logan Gunthorpe
() and are ignored when unmapped. Signed-off-by: Logan Gunthorpe --- kernel/dma/direct.c | 25 ++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 002268262c9a..108dfb4ecbd5 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma

[PATCH 11/16] iommu/dma: Support PCI P2PDMA pages in dma-iommu map_sg

2021-04-08 Thread Logan Gunthorpe
-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 66 ++- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index af765c813cc8..ef49635f9819 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers

[PATCH 14/16] nvme-rdma: Ensure dma support when using p2pdma

2021-04-08 Thread Logan Gunthorpe
Ensure the dma operations support p2pdma before using the RDMA device for P2PDMA. This allows switching the RDMA driver from pci_p2pdma_map_sg() to dma_map_sg_p2pdma(). Signed-off-by: Logan Gunthorpe --- drivers/nvme/target/rdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff

[PATCH 12/16] nvme-pci: Check DMA ops when indicating support for PCI P2PDMA

2021-04-08 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 --- drivers/nvme/host/core.c | 3 ++- drivers/nvme/host/nvme.h | 2 +- drivers/nvme

[PATCH 10/16] dma-mapping: Add flags to dma_map_ops to indicate PCI P2PDMA support

2021-04-08 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 --- include/linux/dma-map-ops.h | 3 +++ include/linux/dma-mapping.h | 5 + kernel/dma/mapping.c

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

2021-04-08 Thread Logan Gunthorpe
This interface is superseded by the new dma_map_sg_p2pdma() interface which supports heterogeneous scatterlists. There are no longer any users, so remove it. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 67 -- include/linux/pci-p2pdma.h

[PATCH 00/16] Add new DMA mapping operation for P2PDMA

2021-04-08 Thread Logan Gunthorpe
) * Finished off using the new dma_map_sg_p2pdma() call in rdma_rw and removed the old pci_p2pdma_[un]map_sg(). (per Jason) -- Logan Gunthorpe (16): PCI/P2PDMA: Pass gfp_mask flags to upstream_bridge_distance_warn() PCI/P2PDMA: Avoid pci_get_slot() which sleeps PCI/P2PDMA: Attempt to set

[PATCH 15/16] RDMA/rw: use dma_map_sg_p2pdma()

2021-04-08 Thread Logan Gunthorpe
Drop the use of pci_p2pdma_map_sg() in favour of dma_map_sg_p2pdma(). The new interface allows mapping scatterlists that mix both regular and P2PDMA pages and will verify that the dma device can communicate with the device the pages are on. Signed-off-by: Logan Gunthorpe --- drivers/infiniband

[PATCH 01/16] PCI/P2PDMA: Pass gfp_mask flags to upstream_bridge_distance_warn()

2021-04-08 Thread Logan Gunthorpe
to be allocated. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas --- drivers/pci/p2pdma.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 196382630363..bd89437faf06 100644 --- a/drivers/pci

[PATCH 03/16] PCI/P2PDMA: Attempt to set map_type if it has not been set

2021-04-08 Thread Logan Gunthorpe
. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 473a08940fbc..2574a062a255 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -825,11 +825,18

[PATCH 04/16] PCI/P2PDMA: Refactor pci_p2pdma_map_type() to take pagmap and device

2021-04-08 Thread Logan Gunthorpe
All callers of pci_p2pdma_map_type() have a struct dev_pgmap and a struct device (of the client doing the DMA transfer). Thus move the conversion to struct pci_devs for the provider and client into this function. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 29

Re: [PATCH] dmaengine: plx_dma: add a missing put_device() on error path

2021-03-23 Thread Logan Gunthorpe
penter Good catch. Thanks Dan! Reviewed-by: Logan Gunthorpe Logan

Re: [RFC PATCH v2 09/11] block: Add BLK_STS_P2PDMA

2021-03-16 Thread Logan Gunthorpe
On 2021-03-16 2:00 a.m., Christoph Hellwig wrote: > On Thu, Mar 11, 2021 at 04:31:39PM -0700, Logan Gunthorpe wrote: >> Create a specific error code for when P2PDMA pages are passed to a block >> devices that cannot map them (due to no IOMMU support or ACS protections). >>

Re: [RFC PATCH v2 06/11] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg

2021-03-16 Thread Logan Gunthorpe
On 2021-03-16 1:58 a.m., Christoph Hellwig wrote: > On Fri, Mar 12, 2021 at 11:27:46AM -0700, Logan Gunthorpe wrote: >> So then we reject the patches that make that change. Seems like an odd >> argument to say that we can't do something that won't cause problems >> beca

Re: [RFC PATCH v2 07/11] dma-mapping: Add flags to dma_map_ops to indicate PCI P2PDMA support

2021-03-15 Thread Logan Gunthorpe
On 2021-03-12 7:36 p.m., Ira Weiny wrote: > On Thu, Mar 11, 2021 at 04:31:37PM -0700, Logan Gunthorpe wrote: > >> +int dma_pci_p2pdma_supported(struct device *dev) >^^^ > bool? Sure. > >> +{ >> +const struct dma_map_ops *ops = get_dma_ops(dev)

Re: [RFC PATCH v2 04/11] PCI/P2PDMA: Introduce pci_p2pdma_should_map_bus() and pci_p2pdma_bus_offset()

2021-03-15 Thread Logan Gunthorpe
On 2021-03-12 7:32 p.m., Ira Weiny wrote: > On Thu, Mar 11, 2021 at 04:31:34PM -0700, Logan Gunthorpe wrote: >> Introduce pci_p2pdma_should_map_bus() which is meant to be called by > ^ > pci_p2pdma_dma_map_type() ??? > >

Re: [RFC PATCH v2 04/11] PCI/P2PDMA: Introduce pci_p2pdma_should_map_bus() and pci_p2pdma_bus_offset()

2021-03-15 Thread Logan Gunthorpe
On 2021-03-12 6:38 p.m., Ira Weiny wrote: > On Thu, Mar 11, 2021 at 04:31:34PM -0700, Logan Gunthorpe wrote: >> Introduce pci_p2pdma_should_map_bus() which is meant to be called by >> DMA map functions to determine how to map a given p2pdma page. >> >> pci_p2pdma

Re: [RFC PATCH v2 02/11] PCI/P2PDMA: Avoid pci_get_slot() which sleeps

2021-03-12 Thread Logan Gunthorpe
On 2021-03-12 1:57 p.m., Bjorn Helgaas wrote: > On Thu, Mar 11, 2021 at 04:31:32PM -0700, Logan Gunthorpe wrote: >> In order to use upstream_bridge_distance_warn() from a dma_map function, >> it must not sleep. However, pci_get_slot() takes the pci_bus_sem so it >> might

Re: [RFC PATCH v2 01/11] PCI/P2PDMA: Pass gfp_mask flags to upstream_bridge_distance_warn()

2021-03-12 Thread Logan Gunthorpe
On 2021-03-12 1:39 p.m., Bjorn Helgaas wrote: On Thu, Mar 11, 2021 at 04:31:31PM -0700, Logan Gunthorpe wrote: In order to call this function from a dma_map function, it must not sleep. The only reason it does sleep so to allocate the seqbuf to print which devices are within the ACS path

Re: [RFC PATCH v2 08/11] iommu/dma: Support PCI P2PDMA pages in dma-iommu map_sg

2021-03-12 Thread Logan Gunthorpe
On 2021-03-12 12:47 p.m., Robin Murphy wrote:    {    struct scatterlist *s, *cur = sg;    unsigned long seg_mask = dma_get_seg_boundary(dev); @@ -864,6 +865,20 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents,    sg_dma_address(s) =

Re: [RFC PATCH v2 06/11] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg

2021-03-12 Thread Logan Gunthorpe
On 2021-03-12 11:11 a.m., Robin Murphy wrote: > On 2021-03-12 16:24, Logan Gunthorpe wrote: >> >> >> On 2021-03-12 8:52 a.m., Robin Murphy wrote: >>>> + >>>>    sg->dma_address = dma_direct_map_page(dev, sg_page(sg), >>&g

Re: [RFC PATCH v2 00/11] Add support to dma_map_sg for P2PDMA

2021-03-12 Thread Logan Gunthorpe
On 2021-03-12 10:46 a.m., Robin Murphy wrote: > On 2021-03-12 16:18, Logan Gunthorpe wrote: >> >> >> On 2021-03-12 8:51 a.m., Robin Murphy wrote: >>> On 2021-03-11 23:31, Logan Gunthorpe wrote: >>>> Hi, >>>> >>>> This is a rew

Re: [RFC PATCH v2 08/11] iommu/dma: Support PCI P2PDMA pages in dma-iommu map_sg

2021-03-12 Thread Logan Gunthorpe
On 2021-03-12 8:52 a.m., Robin Murphy wrote: > On 2021-03-11 23:31, 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 a

Re: [RFC PATCH v2 06/11] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg

2021-03-12 Thread Logan Gunthorpe
On 2021-03-12 8:52 a.m., Robin Murphy wrote: >> + >>   sg->dma_address = dma_direct_map_page(dev, sg_page(sg), >>   sg->offset, sg->length, dir, attrs); >>   if (sg->dma_address == DMA_MAPPING_ERROR) >> @@ -411,7 +440,7 @@ int dma_direct_map_sg(struct device

Re: [RFC PATCH v2 00/11] Add support to dma_map_sg for P2PDMA

2021-03-12 Thread Logan Gunthorpe
On 2021-03-12 8:51 a.m., Robin Murphy wrote: > On 2021-03-11 23:31, Logan Gunthorpe wrote: >> Hi, >> >> This is a rework of the first half of my RFC for doing P2PDMA in >> userspace >> with O_DIRECT[1]. >> >> The largest issue with that serie

Re: [RFC PATCH v2 11/11] nvme-pci: Convert to using dma_map_sg for p2pdma pages

2021-03-11 Thread Logan Gunthorpe
On 2021-03-11 4:59 p.m., Jason Gunthorpe wrote: > On Thu, Mar 11, 2021 at 04:31:41PM -0700, Logan Gunthorpe wrote: >> Convert to using dma_[un]map_sg() for PCI p2pdma pages. >> >> This should be equivalent, though support will be somewhat less >> (only dma-direct

[RFC PATCH v2 03/11] PCI/P2PDMA: Attempt to set map_type if it has not been set

2021-03-11 Thread Logan Gunthorpe
. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 2135fe69bb07..7f6836732bce 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -819,11 +819,18

[RFC PATCH v2 11/11] nvme-pci: Convert to using dma_map_sg for p2pdma pages

2021-03-11 Thread Logan Gunthorpe
Convert to using dma_[un]map_sg() for PCI p2pdma pages. This should be equivalent, though support will be somewhat less (only dma-direct and dma-iommu are currently supported). Signed-off-by: Logan Gunthorpe --- drivers/nvme/host/pci.c | 27 +++ 1 file changed, 7

[RFC PATCH v2 01/11] PCI/P2PDMA: Pass gfp_mask flags to upstream_bridge_distance_warn()

2021-03-11 Thread Logan Gunthorpe
. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 196382630363..bd89437faf06 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -267,7

[RFC PATCH v2 06/11] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg

2021-03-11 Thread Logan Gunthorpe
() and are ignored when unmapped. Signed-off-by: Logan Gunthorpe --- kernel/dma/direct.c | 35 --- kernel/dma/mapping.c | 13 ++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 002268262c9a..f326d32062dd

[RFC PATCH v2 00/11] Add support to dma_map_sg for P2PDMA

2021-03-11 Thread Logan Gunthorpe
ee.com/ [2] https://lore.kernel.org/linux-block/capcyv4ifgcrdotut8qr7pmfhmecghqgvre9g0rorgczcgve...@mail.gmail.com/ -- Logan Gunthorpe (11): PCI/P2PDMA: Pass gfp_mask flags to upstream_bridge_distance_warn() PCI/P2PDMA: Avoid pci_get_slot() which sleeps PCI/P2PDMA: Attempt to set map_type

[RFC PATCH v2 09/11] block: Add BLK_STS_P2PDMA

2021-03-11 Thread Logan Gunthorpe
Create a specific error code for when P2PDMA pages are passed to a block devices that cannot map them (due to no IOMMU support or ACS protections). This makes request errors in these cases more informative of as to what caused the error. Signed-off-by: Logan Gunthorpe --- block/blk-core.c

[RFC PATCH v2 05/11] lib/scatterlist: Add flag for indicating P2PDMA segments in an SGL

2021-03-11 Thread Logan Gunthorpe
requires adding an additional dependency on CONFIG_64BIT to CONFIG_PCI_P2PDMA. This should be acceptable as the majority of P2PDMA use 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

[RFC PATCH v2 04/11] PCI/P2PDMA: Introduce pci_p2pdma_should_map_bus() and pci_p2pdma_bus_offset()

2021-03-11 Thread Logan Gunthorpe
Introduce pci_p2pdma_should_map_bus() which is meant to be called by DMA map functions to determine how to map a given p2pdma page. pci_p2pdma_bus_offset() is also added to allow callers to get the bus offset if they need to map the bus address. Signed-off-by: Logan Gunthorpe --- drivers/pci

[RFC PATCH v2 02/11] PCI/P2PDMA: Avoid pci_get_slot() which sleeps

2021-03-11 Thread Logan Gunthorpe
ist. It should be impossible for the host bridges device to go away while references are held on child devices, so the first element should not change and this should be safe. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --

[RFC PATCH v2 07/11] dma-mapping: Add flags to dma_map_ops to indicate PCI P2PDMA support

2021-03-11 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 --- include/linux/dma-map-ops.h | 3 +++ include/linux/dma-mapping.h | 5 + kernel/dma/mapping.c

[RFC PATCH v2 10/11] nvme-pci: Check DMA ops when indicating support for PCI P2PDMA

2021-03-11 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 --- drivers/nvme/host/core.c | 3 ++- drivers/nvme/host/nvme.h | 2 +- drivers/nvme

[RFC PATCH v2 08/11] iommu/dma: Support PCI P2PDMA pages in dma-iommu map_sg

2021-03-11 Thread Logan Gunthorpe
-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 63 --- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index af765c813cc8..c0821e9051a9 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers

Re: [PATCH 1/3] cdev: Finish the cdev api with queued mode support

2021-01-20 Thread Logan Gunthorpe
On 2021-01-20 12:38 p.m., Dan Williams wrote: > ...common reference count handling scenarios were addressed, but the > shutdown-synchronization problem was only mentioned as something driver > developers need to be aware in the following note: > > NOTE: This guarantees that associated

Re: [patch 17/30] NTB/msi: Use irq_has_action()

2020-12-10 Thread Logan Gunthorpe
On 2020-12-10 12:25 p.m., Thomas Gleixner wrote: > Use the proper core function. > > Signed-off-by: Thomas Gleixner > Cc: Jon Mason > Cc: Dave Jiang > Cc: Allen Hubbe > Cc: linux-...@googlegroups.com Looks good to me. Reviewed-by: Logan Gunthorpe > --- >

Re: [RFC PATCH 04/15] lib/scatterlist: Add flag for indicating P2PDMA segments in an SGL

2020-12-10 Thread Logan Gunthorpe
On 2020-12-09 9:04 p.m., Dan Williams wrote: > On Wed, Dec 9, 2020 at 6:07 PM Logan Gunthorpe wrote: >> >> >> >> On 2020-12-09 6:22 p.m., Dan Williams wrote: >>> On Mon, Nov 9, 2020 at 8:47 AM Logan Gunthorpe wrote: >>>> >>>>

Re: [RFC PATCH 04/15] lib/scatterlist: Add flag for indicating P2PDMA segments in an SGL

2020-12-09 Thread Logan Gunthorpe
On 2020-12-09 6:22 p.m., Dan Williams wrote: > On Mon, Nov 9, 2020 at 8:47 AM Logan Gunthorpe wrote: >> >> >> >> On 2020-11-09 2:12 a.m., Christoph Hellwig wrote: >>> On Fri, Nov 06, 2020 at 10:00:25AM -0700, Logan Gunthorpe wrote: >>>> We make

Re: [PATCH v3 3/6] mm: support THP migration to device private memory

2020-12-02 Thread Logan Gunthorpe
On 2020-12-02 3:14 a.m., Christoph Hellwig wrote:>> MEMORY_DEVICE_PCI_P2PDMA: >> Struct pages are created in pci_p2pdma_add_resource() and represent device >> memory accessible by PCIe bar address space. Memory is allocated with >> pci_alloc_p2pmem() based on a byte length but the

Re: [PATCH][V2] PCI: Fix a potential uninitentional integer overflow issue

2020-11-10 Thread Logan Gunthorpe
ly need to make different patches for the other two vintages. > Signed-off-by: Colin Ian King Besides that, the change makes sense to me. Reviewed-by: Logan Gunthorpe Thanks, Logan

Re: [RFC PATCH 03/15] PCI/P2PDMA: Introduce pci_p2pdma_should_map_bus() and pci_p2pdma_bus_offset()

2020-11-10 Thread Logan Gunthorpe
On 2020-11-10 4:25 p.m., Bjorn Helgaas wrote: > On Fri, Nov 06, 2020 at 10:00:24AM -0700, Logan Gunthorpe wrote: >> Introduce pci_p2pdma_should_map_bus() which is meant to be called by >> dma map functions to determine how to map a given p2pdma page. > > s/dma/DMA/ for co

Re: [RFC PATCH 15/15] nvme-pci: Allow mmaping the CMB in userspace

2020-11-09 Thread Logan Gunthorpe
On 2020-11-09 8:03 a.m., Keith Busch wrote: > On Fri, Nov 06, 2020 at 10:00:36AM -0700, Logan Gunthorpe wrote: >> Allow userspace to obtain CMB memory by mmaping the controller's >> char device. The mmap call allocates and returns a hunk of CMB memory, >> (the offset is

Re: [RFC PATCH 04/15] lib/scatterlist: Add flag for indicating P2PDMA segments in an SGL

2020-11-09 Thread Logan Gunthorpe
On 2020-11-09 2:12 a.m., Christoph Hellwig wrote: > On Fri, Nov 06, 2020 at 10:00:25AM -0700, Logan Gunthorpe wrote: >> We make use of the top bit of the dma_length to indicate a P2PDMA >> segment. > > I don't think "we" can. There is nothing limiting the s

Re: [RFC PATCH 14/15] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2020-11-06 Thread Logan Gunthorpe
On 2020-11-06 5:14 p.m., Jason Gunthorpe wrote: > On Fri, Nov 06, 2020 at 01:03:26PM -0700, Logan Gunthorpe wrote: >> I don't think a function like that will work for the p2pmem use case. In >> order to implement proper page freeing I expect I'll need a loop around &

Re: [RFC PATCH 14/15] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2020-11-06 Thread Logan Gunthorpe
On 2020-11-06 12:53 p.m., Jason Gunthorpe wrote: > On Fri, Nov 06, 2020 at 12:44:59PM -0700, Logan Gunthorpe wrote: >> >> >> On 2020-11-06 12:30 p.m., Jason Gunthorpe wrote: >>>> I certainly can't make decisions for code that isn't currently >>>&g

Re: [RFC PATCH 14/15] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2020-11-06 Thread Logan Gunthorpe
On 2020-11-06 12:30 p.m., Jason Gunthorpe wrote: >> I certainly can't make decisions for code that isn't currently >> upstream. > > The rdma drivers are all upstream, what are you thinking about? Really? I feel like you should know what I mean here... I mean upstream code that actually uses

Re: [RFC PATCH 14/15] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2020-11-06 Thread Logan Gunthorpe
On 2020-11-06 11:09 a.m., Jason Gunthorpe wrote: >> Ah, hmm, yes. I guess the pages have to be hooked and returned to the >> genalloc through free_devmap_managed_page(). > > That sounds about right, but in this case it doesn't need the VMA > operations. > >> Seems like it might be doable...

Re: [RFC PATCH 14/15] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2020-11-06 Thread Logan Gunthorpe
On 2020-11-06 10:42 a.m., Jason Gunthorpe wrote: > On Fri, Nov 06, 2020 at 10:28:00AM -0700, Logan Gunthorpe wrote: >> >> >> On 2020-11-06 10:22 a.m., Jason Gunthorpe wrote: >>> On Fri, Nov 06, 2020 at 10:00:35AM -0700, Logan Gunthorpe wrote: >>>> Int

Re: [RFC PATCH 15/15] nvme-pci: Allow mmaping the CMB in userspace

2020-11-06 Thread Logan Gunthorpe
On 2020-11-06 10:39 a.m., Jason Gunthorpe wrote: > On Fri, Nov 06, 2020 at 10:00:36AM -0700, Logan Gunthorpe wrote: >> Allow userspace to obtain CMB memory by mmaping the controller's >> char device. The mmap call allocates and returns a hunk of CMB memory, >> (the

Re: [RFC PATCH 14/15] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2020-11-06 Thread Logan Gunthorpe
On 2020-11-06 10:22 a.m., Jason Gunthorpe wrote: > On Fri, Nov 06, 2020 at 10:00:35AM -0700, Logan Gunthorpe wrote: >> Introduce pci_mmap_p2pmem() which is a helper to allocate and mmap >> a hunk of p2pmem into userspace. >> >> Signed-off-by: Logan Gunthorp

[RFC PATCH 05/15] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg

2020-11-06 Thread Logan Gunthorpe
-by: Logan Gunthorpe --- include/linux/dma-mapping.h | 11 +++ kernel/dma/direct.c | 33 +++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 956151052d45..8d028e15b531 100644

[RFC PATCH 06/15] dma-mapping: Add flags to dma_map_ops to indicate PCI P2PDMA support

2020-11-06 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 --- include/linux/dma-map-ops.h | 3 +++ include/linux/dma-mapping.h | 5 + kernel/dma/mapping.c

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

2020-11-06 Thread Logan Gunthorpe
. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 94583779c36e..ea8472278b11 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -824,11 +824,17

[RFC PATCH 13/15] block: Set FOLL_PCI_P2PDMA in bio_map_user_iov()

2020-11-06 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

[RFC PATCH 12/15] block: Set FOLL_PCI_P2PDMA in __bio_iov_iter_get_pages()

2020-11-06 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 | 7

[RFC PATCH 09/15] nvme-pci: Convert to using dma_map_sg for p2pdma pages

2020-11-06 Thread Logan Gunthorpe
). Using DMA_ATTR_P2PDMA is safe because the block layer restricts requests to be much less than 2GB, thus there's no way for a segment to be greater than 2GB. Signed-off-by: Logan Gunthorpe --- drivers/nvme/host/pci.c | 30 -- 1 file changed, 12 insertions(+), 18

[RFC PATCH 11/15] iov_iter: Introduce iov_iter_get_pages_[alloc_]flags()

2020-11-06 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 | 21 + lib

[RFC PATCH 14/15] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2020-11-06 Thread Logan Gunthorpe
Introduce pci_mmap_p2pmem() which is a helper to allocate and mmap a hunk of p2pmem into userspace. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 104 + include/linux/pci-p2pdma.h | 6 +++ 2 files changed, 110 insertions(+) diff --git

[RFC PATCH 08/15] nvme-pci: Check DMA ops when indicating support for PCI P2PDMA

2020-11-06 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 --- drivers/nvme/host/core.c | 3 ++- drivers/nvme/host/nvme.h | 2 +- drivers/nvme

[RFC PATCH 07/15] iommu/dma: Support PCI P2PDMA pages in dma-iommu map_sg

2020-11-06 Thread Logan Gunthorpe
to DMA_F_PCI_P2PDMA_SUPPORTED to indicate support for P2PDMA pages. Signed-off-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 63 --- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 5591d6593583

[RFC PATCH 00/15] Userspace P2PDMA with O_DIRECT NVMe devices

2020-11-06 Thread Logan Gunthorpe
for converting the Intel IOMMU to dma-iommu[1]. A git branch is available here: https://github.com/sbates130272/linux-p2pmem/ p2pdma_user_cmb_rfc Thanks, Logan [1] https://lkml.kernel.org/lkml/20200927063437.13988-1-baolu...@linux.intel.com/T/#u. Logan Gunthorpe (15): PCI/P2PDMA: Don't

[RFC PATCH 01/15] PCI/P2PDMA: Don't sleep in upstream_bridge_distance_warn()

2020-11-06 Thread Logan Gunthorpe
. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index de1c331dbed4..94583779c36e 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -267,7 +267,7

[RFC PATCH 10/15] mm: Introduce FOLL_PCI_P2PDMA to gate getting PCI P2PDMA pages

2020-11-06 Thread Logan Gunthorpe
Callers that expect PCI P2PDMA pages can now set FOLL_PCI_P2PDMA to allow obtaining P2PDMA pages. If a caller does not set this flag and tries to map P2PDMA pages it will fail. This is implemented by adding a flag and a check to get_dev_pagemap(). Signed-off-by: Logan Gunthorpe --- drivers/dax

[RFC PATCH 03/15] PCI/P2PDMA: Introduce pci_p2pdma_should_map_bus() and pci_p2pdma_bus_offset()

2020-11-06 Thread Logan Gunthorpe
Introduce pci_p2pdma_should_map_bus() which is meant to be called by dma map functions to determine how to map a given p2pdma page. pci_p2pdma_bus_offset() is also added to allow callers to get the bus offset if they need to map the bus address. Signed-off-by: Logan Gunthorpe --- drivers/pci

[RFC PATCH 15/15] nvme-pci: Allow mmaping the CMB in userspace

2020-11-06 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 | 11

[RFC PATCH 04/15] lib/scatterlist: Add flag for indicating P2PDMA segments in an SGL

2020-11-06 Thread Logan Gunthorpe
We make use of the top bit of the dma_length to indicate a P2PDMA segment. Code that uses this will need to use sg_dma_p2pdma_len() to get the length and ensure no lengths exceed 2GB. An sg_dma_is_p2pdma() helper is included to check if a particular segment is p2pdma(). Signed-off-by: Logan

Re: [PATCH blktests v3 00/11] NVMe Target Passthru Block Tests

2020-10-22 Thread Logan Gunthorpe
On 2020-10-22 4:04 p.m., Omar Sandoval wrote: > On Thu, Oct 22, 2020 at 12:45:25PM -0600, Logan Gunthorpe wrote: >> >> On 2020-10-08 10:40 a.m., Logan Gunthorpe wrote: >>> Hi, >>> >>> This series adds blktests for the nvmet passthru feature that wa

Re: [PATCH blktests v3 00/11] NVMe Target Passthru Block Tests

2020-10-22 Thread Logan Gunthorpe
On 2020-10-08 10:40 a.m., Logan Gunthorpe wrote: > Hi, > > This series adds blktests for the nvmet passthru feature that was merged > for 5.9. It's been reconciled with Sagi's blktest series that Omar > recently merged. Bump. This has been around for a while now. Omar, can you

[PATCH blktests v3 00/11] NVMe Target Passthru Block Tests

2020-10-08 Thread Logan Gunthorpe
- Collected Chaitanya's reviewed-by tag -- Logan Gunthorpe (11): common/fio: Remove state file in common helper common/xfs: Create common helper to check for XFS support common/xfs: Create common helper to verify block device with xfs nvme: Search for specific subsysnqn

[PATCH blktests v3 01/11] common/fio: Remove state file in common helper

2020-10-08 Thread Logan Gunthorpe
Instead of each individual test removing this file, just do it in the common helper. Signed-off-by: Logan Gunthorpe Reviewed-by: Chaitanya Kulkarni --- common/fio | 1 + tests/nvme/010 | 1 - tests/nvme/011 | 1 - tests/nvme/012 | 1 - tests/nvme/013 | 1 - 5 files changed, 1 insertion

[PATCH blktests v3 06/11] nvme/033: Simple test to create and connect to a passthru target

2020-10-08 Thread Logan Gunthorpe
This tests creates and connects to a passthru controller backed by a test NVMe namespace. It then verifies that some common fields in id-ctrl and id-ns are the same in the target and the orginial device. Signed-off-by: Logan Gunthorpe --- tests/nvme/033 | 67

[PATCH blktests v3 03/11] common/xfs: Create common helper to verify block device with xfs

2020-10-08 Thread Logan Gunthorpe
Make a common helper from the code in tests nvme/012 and nvme/013 to run an fio verify on a XFS file system backed by the specified block device. While we are at it, all the output is redirected to $FULL instead of /dev/null. Signed-off-by: Logan Gunthorpe --- common/xfs | 22

[PATCH blktests v3 02/11] common/xfs: Create common helper to check for XFS support

2020-10-08 Thread Logan Gunthorpe
Two nvme tests create and mount XFS filesystems and check for mkfs.xfs. They should also check for XFS support in the kernel so create a common helper for this. Signed-off-by: Logan Gunthorpe --- common/rc | 8 common/xfs | 11 +++ tests/nvme/012 | 6 -- tests

[PATCH blktests v3 11/11] nvme/038: Test removal of un-enabled subsystem and ports

2020-10-08 Thread Logan Gunthorpe
Test that we can remove a subsystem that has not been enabled by passthru or any ns. Do the same for ports while we are at it. This was an issue in the original passthru patches and is not commonly tested. So this test will ensure we don't regress this. Signed-off-by: Logan Gunthorpe --- tests

[PATCH blktests v3 05/11] nvme: Add common helpers for passthru tests

2020-10-08 Thread Logan Gunthorpe
Add some simple helpers to setup a passthru target that passes through to a nvme test device. Signed-off-by: Logan Gunthorpe --- tests/nvme/rc | 75 +++ 1 file changed, 75 insertions(+) diff --git a/tests/nvme/rc b/tests/nvme/rc index

[PATCH blktests v3 10/11] nvme/037: Add test which loops passthru connect and disconnect

2020-10-08 Thread Logan Gunthorpe
Similar to test nvme/031 except for passthru controllers. Note: it's normal to get I/O errors in this test as when the controller disconnects it races with the partition table read. Signed-off-by: Logan Gunthorpe --- tests/nvme/037 | 35 +++ tests/nvme/037

[PATCH blktests v3 04/11] nvme: Search for specific subsysnqn in _find_nvme_loop_dev

2020-10-08 Thread Logan Gunthorpe
This ensures we find the correct nvme loop device if others exist on a given system (which is generally not expected on test systems). Additionally, this will be required in the upcomming test nvme/037 which will have controllers racing with ones being destroyed. Signed-off-by: Logan Gunthorpe

[PATCH blktests v3 08/11] nvme/035: Add test to verify passthru controller with a filesystem

2020-10-08 Thread Logan Gunthorpe
This is a similar test as nvme/012 and nvme/013, except with a passthru controller. Signed-off-by: Logan Gunthorpe --- tests/nvme/035 | 37 + tests/nvme/035.out | 3 +++ 2 files changed, 40 insertions(+) create mode 100755 tests/nvme/035 create mode

[PATCH blktests v3 09/11] nvme/036: Add test for testing reset command on nvme-passthru

2020-10-08 Thread Logan Gunthorpe
Similar to test 022 but for passthru controllers. Signed-off-by: Logan Gunthorpe --- tests/nvme/036 | 37 + tests/nvme/036.out | 3 +++ 2 files changed, 40 insertions(+) create mode 100755 tests/nvme/036 create mode 100644 tests/nvme/036.out diff

[PATCH blktests v3 07/11] nvme/034: Add test for passthru data verification

2020-10-08 Thread Logan Gunthorpe
Similar to test nvme/010 and nvme/011 but for a passthru controller Signed-off-by: Logan Gunthorpe --- tests/nvme/034 | 35 +++ tests/nvme/034.out | 3 +++ 2 files changed, 38 insertions(+) create mode 100755 tests/nvme/034 create mode 100644 tests/nvme

Re: [PATCH blktests v2 04/11] nvme: Search for specific subsysnqn in _find_nvme_loop_dev

2020-10-07 Thread Logan Gunthorpe
On 2020-10-06 6:24 p.m., Chaitanya Kulkarni wrote: > On 10/6/20 17:10, Logan Gunthorpe wrote: >>> With this patch or this series will I be able to write the testcase ? >> This patch helps with that but other helpers introduced in this series >> would require minor change

Re: [PATCH blktests v2 03/11] common/xfs: Create common helper to verify block device with xfs

2020-10-07 Thread Logan Gunthorpe
On 2020-10-06 6:20 p.m., Chaitanya Kulkarni wrote: > On 10/6/20 16:59, Logan Gunthorpe wrote: >>> The mount dir should be a parameter and not the hardcode value >>> to make it reusable. >> I also disagree here. It is already reusable and is used in a number of >

Re: [PATCH blktests v2 05/11] nvme: Add common helpers for passthru tests

2020-10-06 Thread Logan Gunthorpe
On 2020-10-06 6:02 p.m., Chaitanya Kulkarni wrote: > On 9/30/20 12:01, Logan Gunthorpe wrote: >> Add some simple helpers to setup a passthru target that passes through >> to a nvme test device. >> >> Signed-off-by: Logan Gunthorpe &g

Re: [PATCH blktests v2 04/11] nvme: Search for specific subsysnqn in _find_nvme_loop_dev

2020-10-06 Thread Logan Gunthorpe
On 2020-10-06 5:55 p.m., Chaitanya Kulkarni wrote: > On 9/30/20 11:54, Logan Gunthorpe wrote: >> This ensures we find the correct nvme loop device if others exist on a >> given system (which is generally not expected on test systems). >> >> Additionally, this will b

Re: [PATCH blktests v2 03/11] common/xfs: Create common helper to verify block device with xfs

2020-10-06 Thread Logan Gunthorpe
On 2020-10-06 5:50 p.m., Chaitanya Kulkarni wrote: > On 9/30/20 11:54, Logan Gunthorpe wrote: >> Make a common helper from the code in tests nvme/012 and nvme/013 >> to run an fio verify on a XFS file system backed by the >> specified block device. >> >> W

Re: [PATCH blktests v2 02/11] common/xfs: Create common helper to check for XFS support

2020-10-06 Thread Logan Gunthorpe
On 2020-10-06 5:44 p.m., Chaitanya Kulkarni wrote: > On 9/30/20 11:54, Logan Gunthorpe wrote: >> >> requires() { >> _nvme_requires >> -_have_program mkfs.xfs && _have_fio >> +_have_xfs >> +_have_fio > Can you ma

Re: [PATCH v4 0/7] Convert the intel iommu driver to the dma-iommu api

2020-10-01 Thread Logan Gunthorpe
I've sent to that maintainer). Tested-By: Logan Gunthorpe Thanks, Logan

[PATCH blktests v2 09/11] nvme/036: Add test for testing reset command on nvme-passthru

2020-09-30 Thread Logan Gunthorpe
Similar to test 022 but for passthru controllers. Signed-off-by: Logan Gunthorpe --- tests/nvme/036 | 37 + tests/nvme/036.out | 3 +++ 2 files changed, 40 insertions(+) create mode 100755 tests/nvme/036 create mode 100644 tests/nvme/036.out diff

[PATCH blktests v2 02/11] common/xfs: Create common helper to check for XFS support

2020-09-30 Thread Logan Gunthorpe
Two nvme tests create and mount XFS filesystems and check for mkfs.xfs. They should also check for XFS support in the kernel so create a common helper for this. Signed-off-by: Logan Gunthorpe --- common/rc | 8 common/xfs | 11 +++ tests/nvme/012 | 6 -- tests

[PATCH blktests v2 08/11] nvme/035: Add test to verify passthru controller with a filesystem

2020-09-30 Thread Logan Gunthorpe
This is a similar test as nvme/012 and nvme/013, except with a passthru controller. Signed-off-by: Logan Gunthorpe --- tests/nvme/035 | 37 + tests/nvme/035.out | 3 +++ 2 files changed, 40 insertions(+) create mode 100755 tests/nvme/035 create mode

  1   2   3   4   5   6   7   8   9   10   >