Re: [PATCH v3 0/3] create sysfs representation of ACPI HMAT

2017-12-29 Thread Matthew Wilcox
On Wed, Dec 27, 2017 at 10:10:34AM +0100, Brice Goglin wrote: > > Perhaps we can enlist /proc/iomem or a similar enumeration interface > > to tell userspace the NUMA node and whether the kernel thinks it has > > better or worse performance characteristics relative to base > > system-RAM, i.e. new I

[PATCH] pci/hotplug: Delete error messages for a failed memory allocation in four functions

2017-12-29 Thread SF Markus Elfring
From: Markus Elfring Date: Fri, 29 Dec 2017 15:47:00 +0100 Omit extra messages for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/pci/hotplug/pciehp_hpc.c | 5 ++--- drivers/pci/hotplug/pnv_p

Re: [PATCH 27/67] dma-direct: add dma address sanity checks

2017-12-29 Thread Geert Uytterhoeven
Hi Christoph, On Fri, Dec 29, 2017 at 9:18 AM, Christoph Hellwig wrote: > Roughly based on the x86 pci-nommu implementation. > > Signed-off-by: Christoph Hellwig Thanks for your patch! > --- a/lib/dma-direct.c > +++ b/lib/dma-direct.c > @@ -9,6 +9,24 @@ > #include > #include > > +#define D

Re: consolidate direct dma mapping and swiotlb support

2017-12-29 Thread Vladimir Murzin
On 29/12/17 08:18, Christoph Hellwig wrote: > Almost every architecture supports a direct dma mapping implementation, > where no iommu is used and the device dma address is a 1:1 mapping to > the physical address or has a simple linear offset. Currently the > code for this implementation is most d

Re: [PATCH 17/67] microblaze: rename dma_direct to dma_microblaze

2017-12-29 Thread Julian Calaby
Hi Christoph, On Fri, Dec 29, 2017 at 7:18 PM, Christoph Hellwig wrote: > This frees the dma_direct_* namespace for a generic implementation. Don't you mean "dma_nommu" not "dma_microblaze" in the subject line? Thanks, -- Julian Calaby Email: julian.cal...@gmail.com Profile: http://www.googl

[PATCH 67/67] swiotlb: remove various exports

2017-12-29 Thread Christoph Hellwig
All these symbols are only used by arch dma_ops implementations or xen-swiotlb. None of which can be modular. Signed-off-by: Christoph Hellwig --- lib/swiotlb.c | 13 - 1 file changed, 13 deletions(-) diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 77a40b508db8..823e1055a394 10064

[PATCH 66/67] swiotlb: remove swiotlb_{alloc,free}_coherent

2017-12-29 Thread Christoph Hellwig
Unused now that everyone uses swiotlb_{alloc,free}. Signed-off-by: Christoph Hellwig --- include/linux/swiotlb.h | 8 lib/swiotlb.c | 41 - 2 files changed, 49 deletions(-) diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h

[PATCH 65/67] arm64: use swiotlb_alloc and swiotlb_free

2017-12-29 Thread Christoph Hellwig
The generic swiotlb_alloc and swiotlb_free routines already take care of CMA allocations and adding GFP_DMA32 where needed, so use them instead of the arm specific helpers. Signed-off-by: Christoph Hellwig --- arch/arm64/Kconfig | 1 + arch/arm64/mm/dma-mapping.c | 46 +++--

[PATCH 64/67] arm64: replace ZONE_DMA with ZONE_DMA32

2017-12-29 Thread Christoph Hellwig
arm64 uses ZONE_DMA for allocations below 32-bits. These days we name the zone for that ZONE_DMA32, which will allow to use the dma-direct and generic swiotlb code as-is, so rename it. Signed-off-by: Christoph Hellwig --- arch/arm64/Kconfig | 2 +- arch/arm64/mm/dma-mapping.c | 6 +++

[PATCH 63/67] mips: use swiotlb_{alloc,free}

2017-12-29 Thread Christoph Hellwig
These already include the GFP_DMA/GFP_DMA32 usage, and will use CMA memory if enabled, thus avoiding the GFP_NORETRY hack. Signed-off-by: Christoph Hellwig --- arch/mips/cavium-octeon/Kconfig | 1 + arch/mips/cavium-octeon/dma-octeon.c | 26 +++--- arch/mips/l

[PATCH 62/67] mips/netlogic: remove swiotlb support

2017-12-29 Thread Christoph Hellwig
nlm_swiotlb_dma_ops is unused code, so the whole swiotlb support is dead. If it gets resurrected at some point it should use the generic swiotlb_dma_ops instead. Signed-off-by: Christoph Hellwig --- arch/mips/include/asm/netlogic/common.h | 3 -- arch/mips/netlogic/Kconfig | 5 --

[PATCH 61/67] tile: use generic swiotlb_ops

2017-12-29 Thread Christoph Hellwig
These are identical to the tile ops, and would also support CMA if enabled on tile. Signed-off-by: Christoph Hellwig --- arch/tile/Kconfig | 1 + arch/tile/kernel/pci-dma.c | 36 +++- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/arch/t

[PATCH 60/67] tile: replace ZONE_DMA with ZONE_DMA32

2017-12-29 Thread Christoph Hellwig
tile uses ZONE_DMA for allocations below 32-bits. These days we name the zone for that ZONE_DMA32, which will allow to use the dma-direct and generic swiotlb code as-is, so rename it. Signed-off-by: Christoph Hellwig --- arch/tile/Kconfig | 2 +- arch/tile/kernel/pci-dma.c | 4 ++-- ar

[PATCH 59/67] unicore32: use generic swiotlb_ops

2017-12-29 Thread Christoph Hellwig
These are identical to the unicore32 ops, and would also support CMA if enabled on unicore32. Signed-off-by: Christoph Hellwig --- arch/unicore32/include/asm/dma-mapping.h | 9 +- arch/unicore32/mm/Kconfig| 1 + arch/unicore32/mm/Makefile | 2 -- arch/unicore

[PATCH 58/67] ia64: remove an ifdef around the content of pci-dma.c

2017-12-29 Thread Christoph Hellwig
The file is only compiled if CONFIG_INTEL_IOMMU is set to start with. Signed-off-by: Christoph Hellwig --- arch/ia64/kernel/pci-dma.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c index 35e0cad33b7d..b5df084c0af4 100644 --- a/ar

[PATCH 57/67] ia64: clean up swiotlb support

2017-12-29 Thread Christoph Hellwig
Move the few remaining bits of swiotlb glue towards their callers, and remove the pointless on ia64 swiotlb variable. Signed-off-by: Christoph Hellwig --- arch/ia64/include/asm/dma-mapping.h | 1 - arch/ia64/include/asm/swiotlb.h | 18 -- arch/ia64/kernel/dma-mapping.c

[PATCH 56/67] ia64: use generic swiotlb_ops

2017-12-29 Thread Christoph Hellwig
These are identical to the ia64 ops, and would also support CMA if enabled on ia64. Signed-off-by: Christoph Hellwig --- arch/ia64/Kconfig| 5 + arch/ia64/hp/common/hwsw_iommu.c | 4 ++-- arch/ia64/hp/common/sba_iommu.c | 6 +++--- arch/ia64/kernel/pci-swiotlb.c | 38 ++

[PATCH 55/67] ia64: replace ZONE_DMA with ZONE_DMA32

2017-12-29 Thread Christoph Hellwig
ia64 uses ZONE_DMA for allocations below 32-bits. These days we name the zone for that ZONE_DMA32, which will allow to use the dma-direct and generic swiotlb code as-is, so rename it. Signed-off-by: Christoph Hellwig --- arch/ia64/Kconfig | 2 +- arch/ia64/kernel/pci-swiotlb.c | 2

[PATCH 54/67] x86: remove sta2x11_dma_ops

2017-12-29 Thread Christoph Hellwig
Both the swiotlb and the dma-direct code already call into phys_to_dma to translate the DMA address. So the sta2x11 into phys_to_dma and dma_to_phys are enough to handle this "special" device, and we can use the plain old swiotlb ops. Signed-off-by: Christoph Hellwig --- arch/x86/include/asm/de

[PATCH 53/67] swiotlb: remove swiotlb_set_mem_attributes

2017-12-29 Thread Christoph Hellwig
Now that set_memory_decrypted is always available we can just call it directly. Signed-off-by: Christoph Hellwig --- arch/x86/include/asm/mem_encrypt.h | 2 -- arch/x86/mm/mem_encrypt.c | 9 - lib/swiotlb.c | 12 ++-- 3 files changed, 6 insertions(

[PATCH 52/67] dma-direct: handle the memory encryption bit in common code

2017-12-29 Thread Christoph Hellwig
Gіve the basic phys_to_dma and dma_to_phys helpers a __-prefix and add the memory encryption mask to the non-prefixed versions. Use the __-prefixed versions directly instead of clearing the mask again in various places. With that in place the generic dma-direct routines can be used to allocate no

[PATCH 51/67] set_memory.h: provide set_memory_{en,de}crypted stubs

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- include/linux/set_memory.h | 12 1 file changed, 12 insertions(+) diff --git a/include/linux/set_memory.h b/include/linux/set_memory.h index e5140648f638..da5178216da5 100644 --- a/include/linux/set_memory.h +++ b/include/linux/set_memory.h @@ -1

[PATCH 50/67] swiotlb: refactor coherent buffer allocation

2017-12-29 Thread Christoph Hellwig
Factor out a new swiotlb_alloc_buffer helper that allocates DMA coherent memory from the swiotlb bounce buffer. This allows to simplify the swiotlb_alloc implemenation that uses dma_direct_alloc to try to allocate a reachable buffer first. Signed-off-by: Christoph Hellwig --- lib/swiotlb.c | 10

[PATCH 49/67] swiotlb: refactor coherent buffer freeing

2017-12-29 Thread Christoph Hellwig
Factor out a new swiotlb_free_buffer helper that checks if an address is allocated from the swiotlb bounce buffer, and if yes frees it. This allows to simplify the swiotlb_free implemenation that uses dma_direct_free to free the non-bounce buffer allocations. Signed-off-by: Christoph Hellwig ---

[PATCH 48/67] swiotlb: rely on dev->coherent_dma_mask

2017-12-29 Thread Christoph Hellwig
These days the coherent DMA mask is always set, so don't work around the lack of it. Signed-off-by: Christoph Hellwig --- lib/swiotlb.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/swiotlb.c b/lib/swiotlb.c index e0b8980334c3..a14fff30ee9d 100644 --- a/lib/s

[PATCH 47/67] swiotlb: wire up ->dma_supported in swiotlb_dma_ops

2017-12-29 Thread Christoph Hellwig
To properly reject too small DMA masks based on the addressability of the bounce buffer. Signed-off-by: Christoph Hellwig --- lib/swiotlb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 9c100f0173bf..e0b8980334c3 100644 --- a/lib/swiotlb.c +++ b/lib/swio

[PATCH 46/67] swiotlb: lift x86 swiotlb_dma_ops to common code

2017-12-29 Thread Christoph Hellwig
Including the useful helpers for coherent allocations that first try the full blown direct mapping. Signed-off-by: Christoph Hellwig --- arch/x86/include/asm/swiotlb.h | 8 arch/x86/kernel/pci-swiotlb.c | 45 -- arch/x86/pci/sta2x11-fixup.c |

[PATCH 45/67] swiotlb: rename swiotlb_free to swiotlb_exit

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/powerpc/kernel/dma-swiotlb.c | 2 +- arch/x86/kernel/pci-swiotlb.c | 2 +- include/linux/swiotlb.h | 4 ++-- lib/swiotlb.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/dma-swi

[PATCH 44/67] powerpc: rename swiotlb_dma_ops

2017-12-29 Thread Christoph Hellwig
We'll need that name for a generic implementation soon. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/swiotlb.h | 2 +- arch/powerpc/kernel/dma-swiotlb.c | 4 ++-- arch/powerpc/kernel/dma.c | 2 +- arch/powerpc/sysdev/fsl_pci.c | 2 +- 4 files changed, 5 insertions

[PATCH 43/67] ia64: rename swiotlb_dma_ops

2017-12-29 Thread Christoph Hellwig
We'll need that name for a generic implementation soon. Signed-off-by: Christoph Hellwig --- arch/ia64/hp/common/hwsw_iommu.c | 4 ++-- arch/ia64/hp/common/sba_iommu.c | 6 +++--- arch/ia64/kernel/pci-swiotlb.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/ia

[PATCH 42/67] arm64: rename swiotlb_dma_ops

2017-12-29 Thread Christoph Hellwig
We'll need that name for a generic implementation soon. Signed-off-by: Christoph Hellwig --- arch/arm64/mm/dma-mapping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index f3a637b98487..6840426bbe77 100644 --- a

[PATCH 41/67] x86: remove dma_alloc_coherent_gfp_flags

2017-12-29 Thread Christoph Hellwig
All dma_ops implementations used on x86 now take care of setting their own required GFP_ masks for the allocation. And given that the common code now clears harmful flags itself that means we can stop the flags in all the iommu implementations as well. Signed-off-by: Christoph Hellwig --- arch/

[PATCH 40/67] iommu/intel-iommu: use dma_direct_* helpers for the direct mapping case

2017-12-29 Thread Christoph Hellwig
This simplifies the code a bit, and prepares for future cleanups. Signed-off-by: Christoph Hellwig --- drivers/iommu/Kconfig | 1 + drivers/iommu/intel-iommu.c | 17 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kcon

[PATCH 38/67] x86/amd_gart: clean up gart_alloc_coherent

2017-12-29 Thread Christoph Hellwig
Don't rely on the gfp mask from dma_alloc_coherent_gfp_flags to make the fallback decision, and streamline the code flow a bit. Signed-off-by: Christoph Hellwig --- arch/x86/kernel/amd_gart_64.c | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --

[PATCH 39/67] iommu/amd_iommu: use dma_direct_* helpers for the direct mapping case

2017-12-29 Thread Christoph Hellwig
This adds support for CMA allocations, but is otherwise identical. Signed-off-by: Christoph Hellwig --- drivers/iommu/Kconfig | 1 + drivers/iommu/amd_iommu.c | 27 +-- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/i

[PATCH 37/67] x86: use dma-direct

2017-12-29 Thread Christoph Hellwig
The generic dma-direct implementation is now functionally equivalent to the x86 nommu dma_map implementation, so switch over to using it. Note that the various iommu drivers are switched from x86_dma_supported to dma_direct_supported to provide identical functionality, although the checks looks fa

[PATCH 36/67] x86: remove dma_alloc_coherent_mask

2017-12-29 Thread Christoph Hellwig
These days all devices (including the ISA fallback device) have a coherent DMA mask set, so remove the workaround. Signed-off-by: Christoph Hellwig --- arch/x86/include/asm/dma-mapping.h | 18 ++ arch/x86/kernel/pci-dma.c | 10 -- arch/x86/mm/mem_encrypt.c

[PATCH 35/67] h8300: use dma-direct

2017-12-29 Thread Christoph Hellwig
Replace the bare-bones h8300 direct dma mapping implementation with the fully featured generic dma-direct one. Signed-off-by: Christoph Hellwig --- arch/h8300/Kconfig | 1 + arch/h8300/include/asm/Kbuild| 1 + arch/h8300/include/asm/dma-mapping.h | 12 --- arch/h8

[PATCH 34/67] cris: use dma-direct

2017-12-29 Thread Christoph Hellwig
cris currently has an incomplete direct mapping dma_map_ops implementation is PCI support is enabled. Replace it with the fully feature generic dma-direct implementation. Signed-off-by: Christoph Hellwig --- arch/cris/Kconfig | 4 ++ arch/cris/arch-v32/drivers/pci/Makefil

[PATCH 33/67] dma-direct: reject too small dma masks

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- include/linux/dma-direct.h | 1 + lib/dma-direct.c | 19 +++ 2 files changed, 20 insertions(+) diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h index 4788bf0bf683..bcdb1a3e4b1f 100644 --- a/include/linux/dma-dire

[PATCH 32/67] dma-direct: add support for allocation from ZONE_DMA and ZONE_DMA32

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- lib/dma-direct.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/lib/dma-direct.c b/lib/dma-direct.c index 7e913728e099..2e9b9494610c 100644 --- a/lib/dma-direct.c +++ b/lib/dma-direct.c @@ -12,6 +12,14 @@ #define DIRECT_MAPPING_ERROR

[PATCH 31/67] dma-direct: make dma_direct_{alloc, free} available to other implementations

2017-12-29 Thread Christoph Hellwig
So that they don't need to indirect through the operation vector. Signed-off-by: Christoph Hellwig --- arch/arm/mm/dma-mapping-nommu.c | 9 +++-- include/linux/dma-direct.h | 5 + lib/dma-direct.c| 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --g

[PATCH 30/67] dma-direct: retry allocations using GFP_DMA for small masks

2017-12-29 Thread Christoph Hellwig
If we got back an allocation that wasn't inside the support coherent mask, retry the allocation using GFP_DMA. Based on the x86 code. Signed-off-by: Christoph Hellwig --- lib/dma-direct.c | 25 - 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/dma-direc

[PATCH 29/67] dma-direct: use node local allocations for coherent memory

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- lib/dma-direct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dma-direct.c b/lib/dma-direct.c index d0266b39788b..ab81de3ac1d3 100644 --- a/lib/dma-direct.c +++ b/lib/dma-direct.c @@ -39,7 +39,7 @@ static void *dma_direct_alloc(struc

[PATCH 28/67] dma-direct: add support for CMA allocation

2017-12-29 Thread Christoph Hellwig
Try the CMA allocator for coherent allocations if supported. Roughly modelled after the x86 code. Signed-off-by: Christoph Hellwig --- lib/dma-direct.c | 24 ++-- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/dma-direct.c b/lib/dma-direct.c index ddd9dcf

[PATCH 27/67] dma-direct: add dma address sanity checks

2017-12-29 Thread Christoph Hellwig
Roughly based on the x86 pci-nommu implementation. Signed-off-by: Christoph Hellwig --- lib/dma-direct.c | 32 +++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/dma-direct.c b/lib/dma-direct.c index 0e087650e86b..ddd9dcf4e663 100644 --- a/lib/dma-

[PATCH 26/67] dma-direct: use phys_to_dma

2017-12-29 Thread Christoph Hellwig
This means it uses whatever linear remapping scheme that the architecture provides is used in the generic dma_direct ops. Signed-off-by: Christoph Hellwig --- lib/dma-direct.c | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/dma-direct.c b/lib/dma-direc

[PATCH 25/67] dma-direct: rename dma_noop to dma_direct

2017-12-29 Thread Christoph Hellwig
The trivial direct mapping implementation already does a virtual to physical translation which isn't strictly a noop, and will soon learn to do non-direct but linear physical to dma translations through the device offset and a few small tricks. Rename it to a better fitting name. Signed-off-by: C

[PATCH 24/67] dma-mapping: provide a generic asm/dma-mapping.h

2017-12-29 Thread Christoph Hellwig
For architectures that just use the generic dma_noop_ops we can provide a generic version of dma-mapping.h. Signed-off-by: Christoph Hellwig --- MAINTAINERS | 1 + arch/m32r/include/asm/Kbuild | 1 + arch/m32r/include/asm/dma-mapping.h | 17 -

[PATCH 23/67] dma-mapping: add an arch_dma_supported hook

2017-12-29 Thread Christoph Hellwig
To implement the x86 forbid_dac and iommu_sac_force we want an arch hook so that it can apply the global options across all dma_map_ops implementations. Signed-off-by: Christoph Hellwig --- arch/x86/include/asm/dma-mapping.h | 3 +++ arch/x86/kernel/pci-dma.c | 19 ---

[PATCH 22/67] dma-mapping: clear harmful GFP_* flags in common code

2017-12-29 Thread Christoph Hellwig
Life the code from x86 so that we behave consistently. In the future we should probably warn if any of these is set. Signed-off-by: Christoph Hellwig --- arch/cris/arch-v32/drivers/pci/dma.c | 3 --- arch/h8300/kernel/dma.c | 3 --- arch/m68k/kernel/dma.c

[PATCH 21/67] dma-mapping: warn when there is no coherent_dma_mask

2017-12-29 Thread Christoph Hellwig
These days all devices should have a DMA coherent mask, and most dma_ops implementations rely on that fact. But just to be sure add an assert to ring the warning bell if that is not the case. Signed-off-by: Christoph Hellwig --- include/linux/dma-mapping.h | 1 + 1 file changed, 1 insertion(+)

[PATCH 20/67] s390: move s390_pci_dma_ops to asm/pci_dma.h

2017-12-29 Thread Christoph Hellwig
This is not needed in drivers, so move it to a private header. Signed-off-by: Christoph Hellwig --- arch/s390/include/asm/dma-mapping.h | 2 -- arch/s390/include/asm/pci_dma.h | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/dma-mapping.h b/arch/

[PATCH 19/67] microblaze: remove the dead !NOT_COHERENT_CACHE dma code

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/microblaze/kernel/dma.c | 28 1 file changed, 28 deletions(-) diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c index 49b09648679b..031d889670f5 100644 --- a/arch/microblaze/kernel/dma.c +++ b/arch/micr

[PATCH 18/67] microblaze: remove dma_nommu_dma_supported

2017-12-29 Thread Christoph Hellwig
Always returning 1 is the same behavior as not supplying a method at all. Signed-off-by: Christoph Hellwig --- arch/microblaze/kernel/dma.c | 6 -- arch/parisc/kernel/pci-dma.c | 7 --- 2 files changed, 13 deletions(-) diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/d

[PATCH 17/67] microblaze: rename dma_direct to dma_microblaze

2017-12-29 Thread Christoph Hellwig
This frees the dma_direct_* namespace for a generic implementation. Signed-off-by: Christoph Hellwig --- arch/microblaze/include/asm/dma-mapping.h | 4 +-- arch/microblaze/kernel/dma.c | 50 +++ 2 files changed, 27 insertions(+), 27 deletions(-) diff --

[PATCH 16/67] powerpc: rename dma_direct_ to dma_nommu_

2017-12-29 Thread Christoph Hellwig
We want to use the dma_direct_ namespace for a generic implementation, so rename powerpc to the second best choice: dma_nommu_. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h| 8 ++-- arch/powerpc/kernel/dma-iommu.c | 2 +- arch/powerpc/kernel/dma-swi

[PATCH 15/67] hexagon: use the generic dma_capable helper

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/hexagon/include/asm/dma-mapping.h | 7 --- arch/hexagon/kernel/dma.c | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/hexagon/include/asm/dma-mapping.h b/arch/hexagon/include/asm/dma-mapping.h index 5208de242e79.

[PATCH 14/67] dma-mapping: move dma_mark_clean to dma-direct.h

2017-12-29 Thread Christoph Hellwig
And unlike the other helpers we don't require a as this helper is a special case for ia64 only, and this keeps it as simple as possible. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/dma-mapping.h | 2 -- arch/arm64/include/asm/dma-mapping.h | 4 arch/ia64/Kconfig

[PATCH 13/67] dma-mapping: move swiotlb arch helpers to a new header

2017-12-29 Thread Christoph Hellwig
phys_to_dma, dma_to_phys and dma_capable are helpers published by architecture code for use of swiotlb and xen-swiotlb only. Drivers are not supposed to use these directly, but use the DMA API instead. Move these to a new asm/dma-direct.h helper, included by a linux/dma-direct.h wrapper that prov

[PATCH 12/67] s390: remove the unused dma_capable helper

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/s390/include/asm/dma-mapping.h | 7 --- 1 file changed, 7 deletions(-) diff --git a/arch/s390/include/asm/dma-mapping.h b/arch/s390/include/asm/dma-mapping.h index eaf490f9c5bc..2ec7240c1ada 100644 --- a/arch/s390/include/asm/dma-mapping.h +++ b/arc

[PATCH 11/67] riscv: remove the unused dma_capable helper

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/riscv/include/asm/dma-mapping.h | 8 1 file changed, 8 deletions(-) diff --git a/arch/riscv/include/asm/dma-mapping.h b/arch/riscv/include/asm/dma-mapping.h index 3eec1000196d..73849e2cc761 100644 --- a/arch/riscv/include/asm/dma-mapping.h +++

[PATCH 10/67] m32r: remove the unused dma_capable helper

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/m32r/include/asm/dma-mapping.h | 7 --- 1 file changed, 7 deletions(-) diff --git a/arch/m32r/include/asm/dma-mapping.h b/arch/m32r/include/asm/dma-mapping.h index 336ffe60814b..8967fb659691 100644 --- a/arch/m32r/include/asm/dma-mapping.h +++ b/arc

[PATCH 09/67] arc: remove CONFIG_ARC_PLAT_NEEDS_PHYS_TO_DMA

2017-12-29 Thread Christoph Hellwig
We always use the stub definitions, so remove the unused other code. Signed-off-by: Christoph Hellwig --- arch/arc/Kconfig | 3 --- arch/arc/include/asm/dma-mapping.h | 7 --- arch/arc/mm/dma.c | 14 +++--- 3 files changed, 7 insertions(+), 17 del

[PATCH 08/67] powerpc: remove unused flush_write_buffers definition

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index 5a6cbe11db6f..592c7f418aa0 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +

[PATCH 06/67] hexagon: remove unused flush_write_buffers definition

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/hexagon/include/asm/io.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h index 66f5e9a61efc..9e8621d94ee9 100644 --- a/arch/hexagon/include/asm/io.h +++ b/arch/hexagon/include/asm/io.h @@

[PATCH 05/67] dma-mapping: replace PCI_DMA_BUS_IS_PHYS with a flag in struct dma_map_ops

2017-12-29 Thread Christoph Hellwig
The current PCI_DMA_BUS_IS_PHYS decided if a dma implementation is bound by the dma mask in the device because it directly maps to a physical address range (modulo an offset in the device), or if it is virtualized by an iommu and can map any address (that includes virtual iommus like swiotlb). The

[PATCH 07/67] m32r: remove unused flush_write_buffers definition

2017-12-29 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/m32r/include/asm/io.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/m32r/include/asm/io.h b/arch/m32r/include/asm/io.h index 1b653bb16f9a..a4272d8f0d9c 100644 --- a/arch/m32r/include/asm/io.h +++ b/arch/m32r/include/asm/io.h @@ -191,8 +191,6 @

[PATCH 04/67] arm64: don't override dma_max_pfn

2017-12-29 Thread Christoph Hellwig
The generic version now takes dma_pfn_offset into account, so there is no more need for an architecture override. Signed-off-by: Christoph Hellwig --- arch/arm64/include/asm/dma-mapping.h | 9 - 1 file changed, 9 deletions(-) diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm

[PATCH 03/67] dma-mapping: take dma_pfn_offset into account in dma_max_pfn

2017-12-29 Thread Christoph Hellwig
This makes sure the generic version can be used with architectures / devices that have a DMA offset in the direct mapping. Signed-off-by: Christoph Hellwig --- include/linux/dma-mapping.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/dma-mapping.h b/include/li

[PATCH 02/67] alpha: mark jensen as broken

2017-12-29 Thread Christoph Hellwig
CONFIG_ALPHA_JENSEN has failed to compile since commit aca05038 ("alpha/dma: use common noop dma ops"), so mark it as broken. Signed-off-by: Christoph Hellwig --- arch/alpha/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index b31b974a03cb..e9

[PATCH 01/67] x86: remove X86_PPRO_FENCE

2017-12-29 Thread Christoph Hellwig
There were only a few Pentium Pro multiprocessors systems where this errata applied. They are more than 20 years old now, and we've slowly dropped places where put the workarounds in and discuraged anyone from enabling the workaround. Get rid of it for good. Signed-off-by: Christoph Hellwig ---

consolidate direct dma mapping and swiotlb support

2017-12-29 Thread Christoph Hellwig
Almost every architecture supports a direct dma mapping implementation, where no iommu is used and the device dma address is a 1:1 mapping to the physical address or has a simple linear offset. Currently the code for this implementation is most duplicated over the architectures, and the duplicated

[PATCH 17/17] memremap: merge find_dev_pagemap into get_dev_pagemap

2017-12-29 Thread Christoph Hellwig
There is only one caller of the trivial function find_dev_pagemap left, so just merge it into the caller. Signed-off-by: Christoph Hellwig Reviewed-by: Dan Williams --- kernel/memremap.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/kernel/memremap.c b/kernel/mem

[PATCH 16/17] memremap: change devm_memremap_pages interface to use struct dev_pagemap

2017-12-29 Thread Christoph Hellwig
This new interface is similar to how struct device (and many others) work. The caller initializes a 'struct dev_pagemap' as required and calls 'devm_memremap_pages'. This allows the pagemap structure to be embedded in another structure and thus container_of can be used. In this way application spec

[PATCH 15/17] memremap: drop private struct page_map

2017-12-29 Thread Christoph Hellwig
From: Logan Gunthorpe 'struct page_map' is a private structure of 'struct dev_pagemap' but the latter replicates all the same fields as the former so there isn't much value in it. Thus drop it in favour of a completely public struct. This is a clean up in preperation for a more generally useful

[PATCH 14/17] memremap: simplify duplicate region handling in devm_memremap_pages

2017-12-29 Thread Christoph Hellwig
__radix_tree_insert already checks for duplicates and returns -EEXIST in that case, so remove the duplicate (and racy) duplicates check. Signed-off-by: Christoph Hellwig Reviewed-by: Logan Gunthorpe --- kernel/memremap.c | 11 --- 1 file changed, 11 deletions(-) diff --git a/kernel/mem

[PATCH 13/17] memremap: remove to_vmem_altmap

2017-12-29 Thread Christoph Hellwig
All callers are gone now. Signed-off-by: Christoph Hellwig Reviewed-by: Dan Williams --- include/linux/memremap.h | 9 - kernel/memremap.c| 26 -- 2 files changed, 35 deletions(-) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 26

[PATCH 12/17] mm: optimize dev_pagemap reference counting around get_dev_pagemap

2017-12-29 Thread Christoph Hellwig
Change the calling convention so that get_dev_pagemap always consumes the previous reference instead of doing this using an explicit earlier call to put_dev_pagemap in the callers. The callers will still need to put the final reference after finishing the loop over the pages. Signed-off-by: Chris

[PATCH 11/17] mm: move get_dev_pagemap out of line

2017-12-29 Thread Christoph Hellwig
This is a pretty big function, which should be out of line in general, and a no-op stub if CONFIG_ZONE_DEVICЕ is not set. Signed-off-by: Christoph Hellwig Reviewed-by: Logan Gunthorpe Reviewed-by: Dan Williams --- include/linux/memremap.h | 39 --- kernel/me

[PATCH 10/17] mm: merge vmem_altmap_alloc into altmap_alloc_block_buf

2017-12-29 Thread Christoph Hellwig
There is no clear separation between the two, so merge them. Signed-off-by: Christoph Hellwig Reviewed-by: Logan Gunthorpe Reviewed-by: Dan Williams --- mm/sparse-vmemmap.c | 45 - 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/mm/sp

[PATCH 09/17] mm: split altmap memory map allocation from normal case

2017-12-29 Thread Christoph Hellwig
No functional changes, just untangling the call chain and document why the altmap is passed around the hotplug code. Signed-off-by: Christoph Hellwig Reviewed-by: Logan Gunthorpe Reviewed-by: Dan Williams --- arch/powerpc/mm/init_64.c | 5 - arch/x86/mm/init_64.c | 5 - include/l

[PATCH 08/17] mm: pass the vmem_altmap to memmap_init_zone

2017-12-29 Thread Christoph Hellwig
Pass the vmem_altmap two levels down instead of needing a lookup. Signed-off-by: Christoph Hellwig Reviewed-by: Dan Williams --- arch/ia64/mm/init.c| 9 + include/linux/memory_hotplug.h | 2 +- include/linux/mm.h | 4 ++-- kernel/memremap.c | 2 +- m

[PATCH 07/17] mm: pass the vmem_altmap to vmemmap_free

2017-12-29 Thread Christoph Hellwig
We can just pass this on instead of having to do a radix tree lookup without proper locking a few levels into the callchain. Signed-off-by: Christoph Hellwig Reviewed-by: Dan Williams --- arch/arm64/mm/mmu.c| 3 +- arch/ia64/mm/discontig.c | 3 +- arch/powerpc/mm/init_64.c

[PATCH 06/17] mm: pass the vmem_altmap to arch_remove_memory and __remove_pages

2017-12-29 Thread Christoph Hellwig
We can just pass this on instead of having to do a radix tree lookup without proper locking 2 levels into the callchain. Signed-off-by: Christoph Hellwig Reviewed-by: Dan Williams --- arch/ia64/mm/init.c| 4 ++-- arch/powerpc/mm/mem.c | 6 ++ arch/s390/mm/init.c

[PATCH 05/17] mm: pass the vmem_altmap to vmemmap_populate

2017-12-29 Thread Christoph Hellwig
We can just pass this on instead of having to do a radix tree lookup without proper locking a few levels into the callchain. Signed-off-by: Christoph Hellwig Reviewed-by: Dan Williams --- arch/arm64/mm/mmu.c| 6 -- arch/ia64/mm/discontig.c | 3 ++- arch/powerpc/mm/init_6

revamp vmem_altmap / dev_pagemap handling V3

2017-12-29 Thread Christoph Hellwig
Hi all, this series started with two patches from Logan that now are in the middle of the series to kill the memremap-internal pgmap structure and to redo the dev_memreamp_pages interface to be better suitable for future PCI P2P uses. I reviewed them and noticed that there isn't really any good r

[PATCH 03/17] mm: don't export __add_pages

2017-12-29 Thread Christoph Hellwig
This function isn't used by any modules, and is only to be called from core MM code. This includes the calls for the add_pages wrapper that might be inlined. Signed-off-by: Christoph Hellwig Reviewed-by: Dan Williams --- mm/memory_hotplug.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm

[PATCH 04/17] mm: pass the vmem_altmap to arch_add_memory and __add_pages

2017-12-29 Thread Christoph Hellwig
We can just pass this on instead of having to do a radix tree lookup without proper locking 2 levels into the callchain. Signed-off-by: Christoph Hellwig --- arch/ia64/mm/init.c| 5 +++-- arch/powerpc/mm/mem.c | 5 +++-- arch/s390/mm/init.c| 5 +++-- arch/sh/m