Re: [Nouveau] [PATCH v1] ACPI: Switch to use generic UUID API

2017-05-06 Thread Christoph Hellwig
On Fri, May 05, 2017 at 10:06:06AM +0300, Amir Goldstein wrote: > I much rather that you sort out uuid helpers in a way that will > satisfy the filesystem > needs (just provide the helpers don't need to convert filesystems code). Yeah. > IMO, you should acknowledge that the common use case for

Re: [Nouveau] [PATCH v1] ACPI: Switch to use generic UUID API

2017-05-06 Thread Christoph Hellwig
On Fri, May 05, 2017 at 12:50:31PM +0300, Amir Goldstein wrote: > To complete the picture for folks not cc'ed on my patches, > xfs use case suggests there is also justification for the additional helpers: > > uuid_is_null() / uuid_equal() > guid_is_null() / guid_equal() The is_null is useful and

Re: [Nouveau] [PATCH v2 5/5] ARM: Unconditionally enable ARM_DMA_USE_IOMMU

2018-04-27 Thread Christoph Hellwig
On Wed, Apr 25, 2018 at 11:25:11AM +0100, Russell King - ARM Linux wrote: > > config ARM_DMA_USE_IOMMU > > - bool > > + def_bool y > > select ARM_HAS_SG_CHAIN > > select NEED_SG_DMA_LENGTH > > This doesn't work - as has recently been discussed with hch, we can't > globally enable

Re: [Nouveau] [PATCH v2 1/5] drm/nouveau: tegra: Detach from ARM DMA/IOMMU mapping

2018-04-27 Thread Christoph Hellwig
The series seems to miss a cover letter. Also I really think this patch original patch shouldn't be in the proper series. ___ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau

Re: [Nouveau] [PATCH v2 2/5] dma-mapping: Introduce dma_iommu_detach_device() API

2018-04-27 Thread Christoph Hellwig
On Wed, Apr 25, 2018 at 12:10:48PM +0200, Thierry Reding wrote: > From: Thierry Reding > > The dma_iommu_detach_device() API can be used by drivers to forcibly > detach a device from an IOMMU that architecture code might have attached > to. This is useful for drivers that

Re: [Nouveau] [PATCH v2 3/5] ARM: dma-mapping: Implement arch_iommu_detach_device()

2018-04-27 Thread Christoph Hellwig
> +void arch_iommu_detach_device(struct device *dev) > +{ > +#ifdef CONFIG_ARM_DMA_USE_IOMMU > + struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); > + const struct dma_map_ops *dma_ops; > + > + if (!mapping) > + return; > + > +

Re: [Nouveau] [PATCH v4 2/2] drm/nouveau: tegra: Detach from ARM DMA/IOMMU mapping

2018-05-31 Thread Christoph Hellwig
} > +#endif Having this hidden in a helper would be nicer, but anything that doesn't directly expose the dma_map_ops to a driver is fine with me. So from the dma-mapping POV: Acked-by: Christoph Hellwig ___ Nouveau mailing list Nouveau@

Re: [Nouveau] [PATCH v4 1/2] ARM: dma-mapping: Set proper DMA ops in arm_iommu_detach_device()

2018-07-02 Thread Christoph Hellwig
Looks good: Acked-by: Christoph Hellwig ___ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau

[Nouveau] [PATCH 13/22] device-dax: use the dev_pagemap internal refcount

2019-06-13 Thread Christoph Hellwig
The functionality is identical to the one currently open coded in device-dax. Signed-off-by: Christoph Hellwig --- drivers/dax/dax-private.h | 4 --- drivers/dax/device.c | 52 +-- 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/drivers

[Nouveau] [PATCH 16/22] mm: remove hmm_vma_alloc_locked_page

2019-06-13 Thread Christoph Hellwig
The only user of it has just been removed, and there wasn't really any need to wrap a basic memory allocator to start with. Signed-off-by: Christoph Hellwig --- include/linux/hmm.h | 3 --- mm/hmm.c| 14 -- 2 files changed, 17 deletions(-) diff --git a/include/linux

[Nouveau] [PATCH 14/22] nouveau: use alloc_page_vma directly

2019-06-13 Thread Christoph Hellwig
hmm_vma_alloc_locked_page is scheduled to go away, use the proper mm function directly. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm

[Nouveau] [PATCH 07/22] memremap: move dev_pagemap callbacks into a separate structure

2019-06-13 Thread Christoph Hellwig
The dev_pagemap is a growing too many callbacks. Move them into a separate ops structure so that they are not duplicated for multiple instances, and an attacker can't easily overwrite them. Signed-off-by: Christoph Hellwig --- drivers/dax/device.c | 6 +- drivers/nvdimm

[Nouveau] [PATCH 15/22] nouveau: use devm_memremap_pages directly

2019-06-13 Thread Christoph Hellwig
Just use devm_memremap_pages instead of hmm_devmem_add pages to allow killing that wrapper which doesn't provide a whole lot of benefits. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 80 -- 1 file changed, 38 insertions(+), 42 deletions

[Nouveau] [PATCH 12/22] memremap: provide an optional internal refcount in struct dev_pagemap

2019-06-13 Thread Christoph Hellwig
Provide an internal refcounting logic if no ->ref field is provided in the pagemap passed into devm_memremap_pages so that callers don't have to reinvent it poorly. Signed-off-by: Christoph Hellwig --- include/linux/memremap.h | 4 +++ kernel/memremap.c |

[Nouveau] [PATCH 06/22] mm: factor out a devm_request_free_mem_region helper

2019-06-13 Thread Christoph Hellwig
Keep the physical address allocation that hmm_add_device does with the rest of the resource code, and allow future reuse of it without the hmm wrapper. Signed-off-by: Christoph Hellwig --- include/linux/ioport.h | 2 ++ kernel/resource.c | 39 +++ mm

[Nouveau] [PATCH 08/22] memremap: pass a struct dev_pagemap to ->kill

2019-06-13 Thread Christoph Hellwig
Passing the actual typed structure leads to more understandable code vs the actual references. Signed-off-by: Christoph Hellwig --- drivers/dax/device.c | 7 +++ drivers/nvdimm/pmem.c | 6 +++--- drivers/pci/p2pdma.c | 6 +++--- include/linux/memremap.h

[Nouveau] [PATCH 02/22] mm: remove the struct hmm_device infrastructure

2019-06-13 Thread Christoph Hellwig
This code is a trivial wrapper around device model helpers, which should have been integrated into the driver device model usage from the start. Assuming it actually had users, which it never had since the code was added more than 1 1/2 years ago. Signed-off-by: Christoph Hellwig --- include

[Nouveau] [PATCH 03/22] mm: remove hmm_devmem_add_resource

2019-06-13 Thread Christoph Hellwig
This function has never been used since it was first added to the kernel more than a year and a half ago, and if we ever grow a consumer of the MEMORY_DEVICE_PUBLIC infrastructure it can easily use devm_memremap_pages directly now that we've simplified the API for it. Signed-off-by: Christoph

[Nouveau] [PATCH 04/22] mm: don't clear ->mapping in hmm_devmem_free

2019-06-13 Thread Christoph Hellwig
igned-off-by: Christoph Hellwig --- mm/hmm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index 0c62426d1257..e1dc98407e7b 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1347,8 +1347,6 @@ static void hmm_devmem_free(struct page *page, void *data) { struct hmm_devmem *devm

[Nouveau] [PATCH 05/22] mm: export alloc_pages_vma

2019-06-13 Thread Christoph Hellwig
noveau is currently using this through an odd hmm wrapper, and I plan to switch it to the real thing later in this series. Signed-off-by: Christoph Hellwig --- mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 01600d80ae01..f9023b5fba37

[Nouveau] [PATCH 01/22] mm: remove the unused ARCH_HAS_HMM_DEVICE Kconfig option

2019-06-13 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- mm/Kconfig | 10 -- 1 file changed, 10 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index f0c76ba47695..0d2ba7e1f43e 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -675,16 +675,6 @@ config ARCH_HAS_HMM_MIRROR depends on (X86_64 || PPC64

[Nouveau] dev_pagemap related cleanups

2019-06-13 Thread Christoph Hellwig
Hi Dan, Jérôme and Jason, below is a series that cleans up the dev_pagemap interface so that it is more easily usable, which removes the need to wrap it in hmm and thus allowing to kill a lot of code Diffstat: 22 files changed, 245 insertions(+), 802 deletions(-) Git tree:

[Nouveau] [PATCH 10/22] memremap: add a migrate callback to struct dev_pagemap_ops

2019-06-13 Thread Christoph Hellwig
This replaces the hacky ->fault callback, which is currently directly called from common code through a hmm specific data structure as an exercise in layering violations. Signed-off-by: Christoph Hellwig --- include/linux/hmm.h | 6 -- include/linux/memremap.h | 6 ++ incl

[Nouveau] [PATCH 19/22] mm: simplify ZONE_DEVICE page private data

2019-06-13 Thread Christoph Hellwig
Remove the clumsy hmm_devmem_page_{get,set}_drvdata helpers, and instead just access the page directly. Also make the page data a void pointer, and thus much easier to use. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 18 +++-- include/linux/hmm.h

[Nouveau] [PATCH 09/22] memremap: lift the devmap_enable manipulation into devm_memremap_pages

2019-06-13 Thread Christoph Hellwig
Just check if there is a ->page_free operation set and take care of the static key enable, as well as the put using device managed resources. Signed-off-by: Christoph Hellwig --- drivers/nvdimm/pmem.c | 23 +++-- include/linux/mm.h| 10 kernel/memremap.c |

[Nouveau] [PATCH 18/22] mm: mark DEVICE_PUBLIC as broken

2019-06-13 Thread Christoph Hellwig
The code hasn't been used since it was added to the tree, and doesn't appear to actually be usable. Mark it as BROKEN until either a user comes along or we finally give up on it. Signed-off-by: Christoph Hellwig --- mm/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/Kconfig b/mm

[Nouveau] [PATCH 17/22] mm: remove hmm_devmem_add

2019-06-13 Thread Christoph Hellwig
There isn't really much value add in the hmm_devmem_add wrapper. Just factor out a little helper to find the resource, and otherwise let the driver implement the dev_pagemap_ops directly. Signed-off-by: Christoph Hellwig --- Documentation/vm/hmm.rst | 26 include/linux/hmm.h

[Nouveau] [PATCH 22/22] mm: don't select MIGRATE_VMA_HELPER from HMM_MIRROR

2019-06-13 Thread Christoph Hellwig
The migrate_vma helper is only used by noveau to migrate device private pages around. Other HMM_MIRROR users like amdgpu or infiniband don't need it. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/Kconfig | 1 + mm/Kconfig | 1 - 2 files changed, 1 insertion

[Nouveau] [PATCH 21/22] mm: remove the HMM config option

2019-06-13 Thread Christoph Hellwig
All the mm/hmm.c code is better keyed off HMM_MIRROR. Also let nouveau depend on it instead of the mix of a dummy dependency symbol plus the actually selected one. Drop various odd dependencies, as the code is pretty portable. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau

[Nouveau] [PATCH 11/22] memremap: remove the data field in struct dev_pagemap

2019-06-13 Thread Christoph Hellwig
struct dev_pagemap is always embedded into a containing structure, so there is no need to an additional private data field. Signed-off-by: Christoph Hellwig --- drivers/nvdimm/pmem.c| 2 +- include/linux/memremap.h | 3 +-- kernel/memremap.c| 2 +- mm/hmm.c | 9

[Nouveau] [PATCH 20/22] mm: sort out the DEVICE_PRIVATE Kconfig mess

2019-06-13 Thread Christoph Hellwig
The ZONE_DEVICE support doesn't depend on anything HMM related, just on various bits of arch support as indicated by the architecture. Also don't select the option from nouveau as it isn't present in many setups, and depend on it instead. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm

Re: dev_pagemap related cleanups

2019-06-15 Thread Christoph Hellwig
On Fri, Jun 14, 2019 at 06:14:45PM -0700, Dan Williams wrote: > On Thu, Jun 13, 2019 at 11:14 PM Christoph Hellwig wrote: > > > > On Thu, Jun 13, 2019 at 11:27:39AM -0700, Dan Williams wrote: > > > It also turns out the nvdimm unit tests crash with this signature on >

[Nouveau] [PATCH 12/25] memremap: remove the data field in struct dev_pagemap

2019-06-17 Thread Christoph Hellwig
struct dev_pagemap is always embedded into a containing structure, so there is no need to an additional private data field. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- drivers/nvdimm/pmem.c| 2 +- include/linux/memremap.h | 3 +-- kernel/memremap.c| 2 +- mm

[Nouveau] [PATCH 06/25] mm: factor out a devm_request_free_mem_region helper

2019-06-17 Thread Christoph Hellwig
Keep the physical address allocation that hmm_add_device does with the rest of the resource code, and allow future reuse of it without the hmm wrapper. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: John Hubbard --- include/linux/ioport.h | 2 ++ kernel/resource.c

[Nouveau] [PATCH 08/25] memremap: move dev_pagemap callbacks into a separate structure

2019-06-17 Thread Christoph Hellwig
The dev_pagemap is a growing too many callbacks. Move them into a separate ops structure so that they are not duplicated for multiple instances, and an attacker can't easily overwrite them. Signed-off-by: Christoph Hellwig Reviewed-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- drivers

[Nouveau] [PATCH 01/25] mm: remove the unused ARCH_HAS_HMM_DEVICE Kconfig option

2019-06-17 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- mm/Kconfig | 10 -- 1 file changed, 10 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index f0c76ba47695..0d2ba7e1f43e 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -675,16 +675,6 @@ config ARCH_HAS_HMM_MIRROR

[Nouveau] [PATCH 14/25] memremap: provide an optional internal refcount in struct dev_pagemap

2019-06-17 Thread Christoph Hellwig
Provide an internal refcounting logic if no ->ref field is provided in the pagemap passed into devm_memremap_pages so that callers don't have to reinvent it poorly. Signed-off-by: Christoph Hellwig --- include/linux/memremap.h | 4 ++ kernel/memremap.c |

[Nouveau] [PATCH 22/25] mm: simplify ZONE_DEVICE page private data

2019-06-17 Thread Christoph Hellwig
Remove the clumsy hmm_devmem_page_{get,set}_drvdata helpers, and instead just access the page directly. Also make the page data a void pointer, and thus much easier to use. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 18 +++-- include/linux/hmm.h

[Nouveau] [PATCH 19/25] mm: remove hmm_vma_alloc_locked_page

2019-06-17 Thread Christoph Hellwig
The only user of it has just been removed, and there wasn't really any need to wrap a basic memory allocator to start with. Signed-off-by: Christoph Hellwig --- include/linux/hmm.h | 3 --- mm/hmm.c| 14 -- 2 files changed, 17 deletions(-) diff --git a/include/linux

[Nouveau] [PATCH 21/25] mm: mark DEVICE_PUBLIC as broken

2019-06-17 Thread Christoph Hellwig
The code hasn't been used since it was added to the tree, and doesn't appear to actually be usable. Mark it as BROKEN until either a user comes along or we finally give up on it. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- mm/Kconfig | 1 + 1 file changed, 1 insertion

[Nouveau] [PATCH 11/25] memremap: add a migrate_to_ram method to struct dev_pagemap_ops

2019-06-17 Thread Christoph Hellwig
This replaces the hacky ->fault callback, which is currently directly called from common code through a hmm specific data structure as an exercise in layering violations. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- include/linux/hmm.h | 6 -- include/li

[Nouveau] [PATCH 10/25] memremap: lift the devmap_enable manipulation into devm_memremap_pages

2019-06-17 Thread Christoph Hellwig
s also fixes the fact that hmm never called dev_pagemap_put_ops and thus would leave the slow path enabled forever, even after a device driver unload or disable. Signed-off-by: Christoph Hellwig --- drivers/nvdimm/pmem.c | 23 +++-- include/linux/mm.h| 10 kernel/memr

[Nouveau] [PATCH 02/25] mm: remove the struct hmm_device infrastructure

2019-06-17 Thread Christoph Hellwig
This code is a trivial wrapper around device model helpers, which should have been integrated into the driver device model usage from the start. Assuming it actually had users, which it never had since the code was added more than 1 1/2 years ago. Signed-off-by: Christoph Hellwig Reviewed

[Nouveau] [PATCH 13/25] memremap: replace the altmap_valid field with a PGMAP_ALTMAP_VALID flag

2019-06-17 Thread Christoph Hellwig
Add a flags field to struct dev_pagemap to replace the altmap_valid boolean to be a little more extensible. Also add a pgmap_altmap() helper to find the optional altmap and clean up the code using the altmap using it. Signed-off-by: Christoph Hellwig --- arch/powerpc/mm/mem.c | 10

[Nouveau] [PATCH 09/25] memremap: pass a struct dev_pagemap to ->kill and ->cleanup

2019-06-17 Thread Christoph Hellwig
Passing the actual typed structure leads to more understandable code vs just passing the ref member. Reported-by: Logan Gunthorpe Signed-off-by: Christoph Hellwig Reviewed-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe Reviewed-by: Dan Williams --- drivers/dax/device.c | 12

[PATCH 23/25] mm: sort out the DEVICE_PRIVATE Kconfig mess

2019-06-17 Thread Christoph Hellwig
The ZONE_DEVICE support doesn't depend on anything HMM related, just on various bits of arch support as indicated by the architecture. Also don't select the option from nouveau as it isn't present in many setups, and depend on it instead. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm

[Nouveau] [PATCH 25/25] mm: don't select MIGRATE_VMA_HELPER from HMM_MIRROR

2019-06-17 Thread Christoph Hellwig
The migrate_vma helper is only used by noveau to migrate device private pages around. Other HMM_MIRROR users like amdgpu or infiniband don't need it. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- drivers/gpu/drm/nouveau/Kconfig | 1 + mm/Kconfig | 1

[Nouveau] [PATCH 15/25] device-dax: use the dev_pagemap internal refcount

2019-06-17 Thread Christoph Hellwig
The functionality is identical to the one currently open coded in device-dax. Signed-off-by: Christoph Hellwig --- drivers/dax/dax-private.h | 4 drivers/dax/device.c | 43 --- 2 files changed, 47 deletions(-) diff --git a/drivers/dax/dax

[PATCH 24/25] mm: remove the HMM config option

2019-06-17 Thread Christoph Hellwig
All the mm/hmm.c code is better keyed off HMM_MIRROR. Also let nouveau depend on it instead of the mix of a dummy dependency symbol plus the actually selected one. Drop various odd dependencies, as the code is pretty portable. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau

[PATCH 20/25] mm: remove hmm_devmem_add

2019-06-17 Thread Christoph Hellwig
There isn't really much value add in the hmm_devmem_add wrapper and more, as using devm_memremap_pages directly now is just as simple. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- Documentation/vm/hmm.rst | 26 include/linux/hmm.h | 129

[Nouveau] [PATCH 18/25] nouveau: use devm_memremap_pages directly

2019-06-17 Thread Christoph Hellwig
Just use devm_memremap_pages instead of hmm_devmem_add pages to allow killing that wrapper which doesn't provide a whole lot of benefits. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 82 -- 1 file changed, 38 insertions(+), 44 deletions

[Nouveau] [PATCH 16/25] PCI/P2PDMA: use the dev_pagemap internal refcount

2019-06-17 Thread Christoph Hellwig
The functionality is identical to the one currently open coded in p2pdma.c. Signed-off-by: Christoph Hellwig --- drivers/pci/p2pdma.c | 56 1 file changed, 4 insertions(+), 52 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c

[Nouveau] [PATCH 17/25] nouveau: use alloc_page_vma directly

2019-06-17 Thread Christoph Hellwig
hmm_vma_alloc_locked_page is scheduled to go away, use the proper mm function directly. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau

[Nouveau] [PATCH 04/25] mm: don't clear ->mapping in hmm_devmem_free

2019-06-17 Thread Christoph Hellwig
igned-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: John Hubbard --- mm/hmm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index dc251c51803a..64e788bb1211 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1380,8 +1380,6 @@ static void hmm_devmem_free(struct page *p

[Nouveau] [PATCH 05/25] mm: export alloc_pages_vma

2019-06-17 Thread Christoph Hellwig
nouveau is currently using this through an odd hmm wrapper, and I plan to switch it to the real thing later in this series. Signed-off-by: Christoph Hellwig Reviewed-by: John Hubbard --- mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index

[Nouveau] [PATCH 07/25] memremap: validate the pagemap type passed to devm_memremap_pages

2019-06-17 Thread Christoph Hellwig
Most pgmap types are only supported when certain config options are enabled. Check for a type that is valid for the current configuration before setting up the pagemap. Signed-off-by: Christoph Hellwig --- kernel/memremap.c | 27 +++ 1 file changed, 27 insertions

[Nouveau] [PATCH 03/25] mm: remove hmm_devmem_add_resource

2019-06-17 Thread Christoph Hellwig
This function has never been used since it was first added to the kernel more than a year and a half ago, and if we ever grow a consumer of the MEMORY_DEVICE_PUBLIC infrastructure it can easily use devm_memremap_pages directly. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe

dev_pagemap related cleanups v2

2019-06-17 Thread Christoph Hellwig
Hi Dan, Jérôme and Jason, below is a series that cleans up the dev_pagemap interface so that it is more easily usable, which removes the need to wrap it in hmm and thus allowing to kill a lot of code Note: this series is on top of the rdma/hmm branch + the dev_pagemap releas fix series from Dan

Re: [Nouveau] [PATCH 07/25] memremap: validate the pagemap type passed to devm_memremap_pages

2019-06-17 Thread Christoph Hellwig
On Mon, Jun 17, 2019 at 12:02:09PM -0700, Dan Williams wrote: > Need a lead in patch that introduces MEMORY_DEVICE_DEVDAX, otherwise: Or maybe a MEMORY_DEVICE_DEFAULT = 0 shared by fsdax and p2pdma? ___ Nouveau mailing list Nouveau@lists.freedesktop.org

Re: [Nouveau] [PATCH 08/25] memremap: move dev_pagemap callbacks into a separate structure

2019-06-17 Thread Christoph Hellwig
On Mon, Jun 17, 2019 at 10:51:35AM -0700, Dan Williams wrote: > > - struct dev_pagemap *pgmap = _pgmap; > > Whoops, needed to keep this line to avoid: > > tools/testing/nvdimm/test/iomap.c:109:11: error: ‘pgmap’ undeclared > (first use in this function); did you mean ‘_pgmap’? So I really

Re: [Nouveau] [PATCH 08/25] memremap: move dev_pagemap callbacks into a separate structure

2019-06-17 Thread Christoph Hellwig
On Mon, Jun 17, 2019 at 02:08:14PM -0600, Logan Gunthorpe wrote: > I just noticed this is missing a line to set pgmap->ops to > pci_p2pdma_pagemap_ops. I must have gotten confused by the other users > in my original review. Though I'm not sure how this compiles as the new > struct is static and

Re: [Nouveau] [PATCH 05/22] mm: export alloc_pages_vma

2019-06-25 Thread Christoph Hellwig
On Mon, Jun 24, 2019 at 11:24:48AM -0700, Dan Williams wrote: > I asked for this simply because it was not exported historically. In > general I want to establish explicit export-type criteria so the > community can spend less time debating when to use EXPORT_SYMBOL_GPL > [1]. > > The thought in

Re: [Nouveau] [PATCH 18/22] mm: mark DEVICE_PUBLIC as broken

2019-06-25 Thread Christoph Hellwig
On Thu, Jun 20, 2019 at 09:26:48PM +0200, Michal Hocko wrote: > On Thu 13-06-19 11:43:21, Christoph Hellwig wrote: > > The code hasn't been used since it was added to the tree, and doesn't > > appear to actually be usable. Mark it as BROKEN until either a user > > comes alo

Re: [Nouveau] [PATCH 18/22] mm: mark DEVICE_PUBLIC as broken

2019-06-25 Thread Christoph Hellwig
On Tue, Jun 25, 2019 at 11:44:28AM +, Jason Gunthorpe wrote: > Which tree and what does the resolution look like? Looks like in -mm. The current commit in linux-next is: commit 0d23b042f26955fb35721817beb98ba7f1d9ed9f Author: Robin Murphy Date: Fri Jun 14 10:42:14 2019 +1000 mm:

Re: dev_pagemap related cleanups

2019-06-13 Thread Christoph Hellwig
On Thu, Jun 13, 2019 at 08:40:46PM +, Jason Gunthorpe wrote: > > Perhaps we should pull those out and resend them through hmm.git? > > It could be done - but how bad is the conflict resolution? Trivial. All but one patch just apply using git-am, and the other one just has a few lines of

Re: [Nouveau] dev_pagemap related cleanups

2019-06-14 Thread Christoph Hellwig
On Thu, Jun 13, 2019 at 02:16:27PM +, Jason Gunthorpe wrote: > On Thu, Jun 13, 2019 at 11:43:03AM +0200, Christoph Hellwig wrote: > > Hi Dan, Jérôme and Jason, > > > > below is a series that cleans up the dev_pagemap interface so that > > it is more easily usa

Re: [PATCH 04/22] mm: don't clear ->mapping in hmm_devmem_free

2019-06-14 Thread Christoph Hellwig
On Thu, Jun 13, 2019 at 07:05:07PM +, Jason Gunthorpe wrote: > Hurm, is hmm following this comment from mm_types.h? > > * If you allocate the page using alloc_pages(), you can use some of the > * space in struct page for your own purposes. The five words in the main > * union are

Re: [PATCH 09/22] memremap: lift the devmap_enable manipulation into devm_memremap_pages

2019-06-14 Thread Christoph Hellwig
On Thu, Jun 13, 2019 at 07:34:31PM +, Jason Gunthorpe wrote: > Reviewed-by: Christoph Hellwig Really? :)

Re: [Nouveau] [PATCH 13/22] device-dax: use the dev_pagemap internal refcount

2019-06-14 Thread Christoph Hellwig
On Thu, Jun 13, 2019 at 05:22:17PM -0700, Ira Weiny wrote: > > - dev_dax->pgmap.ref = _dax->ref; > > I don't think this exactly correct. pgmap.ref is a pointer to the dev_dax ref > structure. Taking it away will cause devm_memremap_pages() to fail AFAICS. > > I think you need to change

Re: [Nouveau] [PATCH 18/22] mm: mark DEVICE_PUBLIC as broken

2019-06-14 Thread Christoph Hellwig
On Thu, Jun 13, 2019 at 05:43:15PM -0700, Ira Weiny wrote: > yes but the earlier patch: > > [PATCH 03/22] mm: remove hmm_devmem_add_resource > > Removes the only place type is set to MEMORY_DEVICE_PUBLIC. > > So I think it is ok. Frankly I was wondering if we should remove the public > type

Re: [Nouveau] [PATCH 22/22] mm: don't select MIGRATE_VMA_HELPER from HMM_MIRROR

2019-06-14 Thread Christoph Hellwig
On Thu, Jun 13, 2019 at 06:53:15PM -0700, John Hubbard wrote: > For those who have out of tree drivers that need migrate_vma(), but are not > Nouveau, could we pretty please allow a way to select that independently? No. The whole point is to not build this fairly big chunk of code in unless we

Re: [PATCH 06/25] mm: factor out a devm_request_free_mem_region helper

2019-06-17 Thread Christoph Hellwig
On Mon, Jun 17, 2019 at 10:37:12AM -0700, Dan Williams wrote: > > +struct resource *devm_request_free_mem_region(struct device *dev, > > + struct resource *base, unsigned long size); > > This appears to need a 'static inline' helper stub in the > CONFIG_DEVICE_PRIVATE=n case,

Re: [Nouveau] [PATCH 06/25] mm: factor out a devm_request_free_mem_region helper

2019-06-17 Thread Christoph Hellwig
On Mon, Jun 17, 2019 at 07:40:18PM +0200, Christoph Hellwig wrote: > On Mon, Jun 17, 2019 at 10:37:12AM -0700, Dan Williams wrote: > > > +struct resource *devm_request_free_mem_region(struct device *dev, > > > + struct resource *base, unsigned long size);

Re: [Nouveau] dev_pagemap related cleanups v2

2019-06-20 Thread Christoph Hellwig
On Wed, Jun 19, 2019 at 03:19:23PM -0300, Jason Gunthorpe wrote: > > Just make sure that when you backmerge v5.2-rc5 you have a clear > > reason in the merge commit message about why you needed to do it. > > While needless rebasing is top of the pet peeve list, second place, as > > I found out, is

Re: dev_pagemap related cleanups v2

2019-06-19 Thread Christoph Hellwig
On Tue, Jun 18, 2019 at 12:47:10PM -0700, Dan Williams wrote: > > Git tree: > > > > git://git.infradead.org/users/hch/misc.git hmm-devmem-cleanup.2 > > > > Gitweb: > > > > > > http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/hmm-devmem-cleanup.2 > > Attached is my

Re: [Nouveau] [PATCH 06/22] mm: factor out a devm_request_free_mem_region helper

2019-06-15 Thread Christoph Hellwig
On Fri, Jun 14, 2019 at 07:21:54PM -0700, John Hubbard wrote: > On 6/13/19 2:43 AM, Christoph Hellwig wrote: > > Keep the physical address allocation that hmm_add_device does with the > > rest of the resource code, and allow future reuse of it without the hmm > > wrapper

[Nouveau] [PATCH 05/25] mm: don't clear ->mapping in hmm_devmem_free

2019-06-26 Thread Christoph Hellwig
igned-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: John Hubbard --- mm/hmm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index 376159a769fb..e7dd2ab8f9ab 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -1383,8 +1383,6 @@ static void hmm_devmem_free(struct page *p

[Nouveau] [PATCH 09/25] memremap: move dev_pagemap callbacks into a separate structure

2019-06-26 Thread Christoph Hellwig
The dev_pagemap is a growing too many callbacks. Move them into a separate ops structure so that they are not duplicated for multiple instances, and an attacker can't easily overwrite them. Signed-off-by: Christoph Hellwig Reviewed-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe --- drivers

[Nouveau] [PATCH 01/25] mm: remove the unused ARCH_HAS_HMM_DEVICE Kconfig option

2019-06-26 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- mm/Kconfig | 10 -- 1 file changed, 10 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index f0c76ba47695..0d2ba7e1f43e 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -675,16 +675,6 @@ config ARCH_HAS_HMM_MIRROR

[Nouveau] [PATCH 11/25] memremap: lift the devmap_enable manipulation into devm_memremap_pages

2019-06-26 Thread Christoph Hellwig
s also fixes the fact that hmm never called dev_pagemap_put_ops and thus would leave the slow path enabled forever, even after a device driver unload or disable. Signed-off-by: Christoph Hellwig --- drivers/nvdimm/pmem.c | 23 +++-- include/linux/mm.h| 10 kernel/memr

[Nouveau] [PATCH 07/25] mm: factor out a devm_request_free_mem_region helper

2019-06-26 Thread Christoph Hellwig
Keep the physical address allocation that hmm_add_device does with the rest of the resource code, and allow future reuse of it without the hmm wrapper. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: John Hubbard --- include/linux/ioport.h | 2 ++ kernel/resource.c

[Nouveau] [PATCH 03/25] mm: remove hmm_devmem_add_resource

2019-06-26 Thread Christoph Hellwig
This function has never been used since it was first added to the kernel more than a year and a half ago, and if we ever grow a consumer of the MEMORY_DEVICE_PUBLIC infrastructure it can easily use devm_memremap_pages directly. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe

[Nouveau] [PATCH 08/25] memremap: validate the pagemap type passed to devm_memremap_pages

2019-06-26 Thread Christoph Hellwig
-by: Christoph Hellwig --- drivers/dax/device.c | 1 + include/linux/memremap.h | 8 kernel/memremap.c| 22 ++ 3 files changed, 31 insertions(+) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 8465d12fecba..79014baa782d 100644 --- a/drivers/dax

[PATCH 04/25] mm: remove MEMORY_DEVICE_PUBLIC support

2019-06-26 Thread Christoph Hellwig
The code hasn't been used since it was added to the tree, and doesn't appear to actually be usable. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Acked-by: Michal Hocko --- include/linux/hmm.h | 4 ++-- include/linux/ioport.h | 1 - include/linux/memremap.h | 8

Re: [Nouveau] [PATCH 03/25] mm: remove hmm_devmem_add_resource

2019-06-27 Thread Christoph Hellwig
On Thu, Jun 27, 2019 at 04:18:22PM +, Jason Gunthorpe wrote: > On Wed, Jun 26, 2019 at 02:27:02PM +0200, Christoph Hellwig wrote: > > This function has never been used since it was first added to the kernel > > more than a year and a half ago, and if we ever

Re: [Nouveau] [PATCH 12/25] memremap: add a migrate_to_ram method to struct dev_pagemap_ops

2019-06-27 Thread Christoph Hellwig
On Thu, Jun 27, 2019 at 04:29:45PM +, Jason Gunthorpe wrote: > I'ver heard there are some other use models for fault() here beyond > migrate to ram, but we can rename it if we ever see them. Well, it absolutely needs to migrate to some piece of addressable and coherent memory, so ram might be

[PATCH 22/25] mm: simplify ZONE_DEVICE page private data

2019-06-26 Thread Christoph Hellwig
Remove the clumsy hmm_devmem_page_{get,set}_drvdata helpers, and instead just access the page directly. Also make the page data a void pointer, and thus much easier to use. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 18 ++- include/linux/hmm.h

[Nouveau] [PATCH 12/25] memremap: add a migrate_to_ram method to struct dev_pagemap_ops

2019-06-26 Thread Christoph Hellwig
This replaces the hacky ->fault callback, which is currently directly called from common code through a hmm specific data structure as an exercise in layering violations. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- include/linux/hmm.h | 6 -- include/li

[Nouveau] [PATCH 10/25] memremap: pass a struct dev_pagemap to ->kill and ->cleanup

2019-06-26 Thread Christoph Hellwig
Passing the actual typed structure leads to more understandable code vs just passing the ref member. Reported-by: Logan Gunthorpe Signed-off-by: Christoph Hellwig Reviewed-by: Logan Gunthorpe Reviewed-by: Jason Gunthorpe Reviewed-by: Dan Williams --- drivers/dax/device.c | 12

[Nouveau] [PATCH 06/25] mm: export alloc_pages_vma

2019-06-26 Thread Christoph Hellwig
nouveau is currently using this through an odd hmm wrapper, and I plan to switch it to the real thing later in this series. Signed-off-by: Christoph Hellwig Reviewed-by: John Hubbard --- mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index

[Nouveau] dev_pagemap related cleanups v3

2019-06-26 Thread Christoph Hellwig
Hi Dan, Jérôme and Jason, below is a series that cleans up the dev_pagemap interface so that it is more easily usable, which removes the need to wrap it in hmm and thus allowing to kill a lot of code Note: this series is on top of Linux 5.2-rc5 and has some minor conflicts with the hmm tree that

[Nouveau] [PATCH 14/25] memremap: replace the altmap_valid field with a PGMAP_ALTMAP_VALID flag

2019-06-26 Thread Christoph Hellwig
Add a flags field to struct dev_pagemap to replace the altmap_valid boolean to be a little more extensible. Also add a pgmap_altmap() helper to find the optional altmap and clean up the code using the altmap using it. Signed-off-by: Christoph Hellwig --- arch/powerpc/mm/mem.c | 10

[Nouveau] [PATCH 13/25] memremap: remove the data field in struct dev_pagemap

2019-06-26 Thread Christoph Hellwig
struct dev_pagemap is always embedded into a containing structure, so there is no need to an additional private data field. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe --- drivers/nvdimm/pmem.c| 2 +- include/linux/memremap.h | 3 +-- kernel/memremap.c| 2 +- mm

[Nouveau] [PATCH 02/25] mm: remove the struct hmm_device infrastructure

2019-06-26 Thread Christoph Hellwig
This code is a trivial wrapper around device model helpers, which should have been integrated into the driver device model usage from the start. Assuming it actually had users, which it never had since the code was added more than 1 1/2 years ago. Signed-off-by: Christoph Hellwig Reviewed

[Nouveau] [PATCH 19/25] nouveau: use devm_memremap_pages directly

2019-06-26 Thread Christoph Hellwig
Just use devm_memremap_pages instead of hmm_devmem_add pages to allow killing that wrapper which doesn't provide a whole lot of benefits. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 82 -- 1 file changed, 38 insertions(+), 44 deletions

[Nouveau] [PATCH 24/25] mm: remove the HMM config option

2019-06-26 Thread Christoph Hellwig
All the mm/hmm.c code is better keyed off HMM_MIRROR. Also let nouveau depend on it instead of the mix of a dummy dependency symbol plus the actually selected one. Drop various odd dependencies, as the code is pretty portable. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau

[PATCH 16/25] device-dax: use the dev_pagemap internal refcount

2019-06-26 Thread Christoph Hellwig
The functionality is identical to the one currently open coded in device-dax. Signed-off-by: Christoph Hellwig --- drivers/dax/dax-private.h | 4 drivers/dax/device.c | 43 --- 2 files changed, 47 deletions(-) diff --git a/drivers/dax/dax

[PATCH 20/25] mm: remove hmm_vma_alloc_locked_page

2019-06-26 Thread Christoph Hellwig
The only user of it has just been removed, and there wasn't really any need to wrap a basic memory allocator to start with. Signed-off-by: Christoph Hellwig --- include/linux/hmm.h | 3 --- mm/hmm.c| 14 -- 2 files changed, 17 deletions(-) diff --git a/include/linux

[Nouveau] [PATCH 17/25] PCI/P2PDMA: use the dev_pagemap internal refcount

2019-06-26 Thread Christoph Hellwig
The functionality is identical to the one currently open coded in p2pdma.c. Signed-off-by: Christoph Hellwig --- drivers/pci/p2pdma.c | 57 1 file changed, 4 insertions(+), 53 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c

[Nouveau] [PATCH 15/25] memremap: provide an optional internal refcount in struct dev_pagemap

2019-06-26 Thread Christoph Hellwig
Provide an internal refcounting logic if no ->ref field is provided in the pagemap passed into devm_memremap_pages so that callers don't have to reinvent it poorly. Signed-off-by: Christoph Hellwig --- include/linux/memremap.h | 4 ++ kernel/memremap.c |

  1   2   3   4   5   6   >