[PATCH 24/34] powerpc/dma: move pci_dma_dev_setup_swiotlb to fsl_pci.c

2018-11-14 Thread Christoph Hellwig
pci_dma_dev_setup_swiotlb is only used by the fsl_pci code, and closely related to it, so fsl_pci.c seems like a better place for it. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/swiotlb.h | 2 -- arch/powerpc/kernel/dma-swiotlb.c | 11 ---

[PATCH 19/34] cxl: drop the dma_set_mask callback from vphb

2018-11-14 Thread Christoph Hellwig
The CXL code never even looks at the dma mask, so there is no good reason for this sanity check. Remove it because it gets in the way of the dma ops refactoring. Signed-off-by: Christoph Hellwig --- drivers/misc/cxl/vphb.c | 12 1 file changed, 12 deletions(-) diff --git

[PATCH 22/34] powerpc/dma: remove the iommu fallback for coherent allocations

2018-11-14 Thread Christoph Hellwig
All iommu capable platforms now always use the iommu code with the internal bypass, so there is not need for this magic anymore. Signed-off-by: Christoph Hellwig --- arch/powerpc/Kconfig | 4 --- arch/powerpc/kernel/dma.c | 68 ++- 2 files changed, 2

[PATCH 18/34] powerpc/powernv: use the generic iommu bypass code

2018-11-14 Thread Christoph Hellwig
Use the generic iommu bypass code instead of overriding set_dma_mask. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/powernv/pci-ioda.c | 95 ++- 1 file changed, 25 insertions(+), 70 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c

[PATCH 25/34] powerpc/dma: remove max_direct_dma_addr

2018-11-14 Thread Christoph Hellwig
The max_direct_dma_addr duplicates the bus_dma_mask field in struct device. Use the generic field instead. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/device.h | 3 --- arch/powerpc/include/asm/dma-direct.h | 4 +--- arch/powerpc/kernel/dma-swiotlb.c | 20

[PATCH 15/34] powerpc/dart: use the generic iommu bypass code

2018-11-14 Thread Christoph Hellwig
Use the generic iommu bypass code instead of overriding set_dma_mask. Signed-off-by: Christoph Hellwig --- arch/powerpc/sysdev/dart_iommu.c | 45 +++- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/sysdev/dart_iommu.c

[PATCH 07/34] powerpc/dma: remove the no-op dma_nommu_unmap_{page, sg} routines

2018-11-14 Thread Christoph Hellwig
These methods are optional, no need to implement no-op versions. Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/kernel/dma.c | 16 1 file changed, 16 deletions(-) diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index

[PATCH 09/34] powerpc/dma: handle iommu bypass in dma_iommu_ops

2018-11-14 Thread Christoph Hellwig
Add a new iommu_bypass flag to struct dev_archdata so that the dma_iommu implementation can handle the direct mapping transparently instead of switiching ops around. Setting of this flag is controlled by new pci_controller_ops method. Signed-off-by: Christoph Hellwig ---

[PATCH 14/34] powerpc/dart: remove dead cleanup code in iommu_init_early_dart

2018-11-14 Thread Christoph Hellwig
If dart_init failed we didn't have a chance to setup dma or controller ops yet, so there is no point in resetting them. Signed-off-by: Christoph Hellwig --- arch/powerpc/sysdev/dart_iommu.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git

[PATCH 10/34] powerpc/pseries: unwind dma_get_required_mask_pSeriesLP a bit

2018-11-14 Thread Christoph Hellwig
Call dma_get_required_mask_pSeriesLP directly instead of dma_iommu_ops to simply the code a bit. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/pseries/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c

[PATCH 20/34] powerpc/dma: stop overriding dma_get_required_mask

2018-11-14 Thread Christoph Hellwig
The ppc_md and pci_controller_ops methods are unused now and can be removed. The dma_nommu implementation is generic to the generic one except for using max_pfn instead of calling into the memblock API, and all other dma_map_ops instances implement a method of their own. Signed-off-by: Christoph

[PATCH 16/34] powerpc/powernv: remove pnv_pci_ioda_pe_single_vendor

2018-11-14 Thread Christoph Hellwig
This function is completely bogus - the fact that two PCIe devices come from the same vendor has absolutely nothing to say about the DMA capabilities and characteristics. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/powernv/pci-ioda.c | 28 ++- 1 file changed,

[PATCH 32/34] powerpc/dma: remove get_dma_offset

2018-11-14 Thread Christoph Hellwig
Just fold the calculation into __phys_to_dma/__dma_to_phys as those are the only places that should know about it. Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/include/asm/dma-direct.h | 8 ++-- arch/powerpc/include/asm/dma-mapping.h | 16

[PATCH 33/34] powerpc/dma: remove set_dma_offset

2018-11-14 Thread Christoph Hellwig
There is no good reason for this helper, just opencode it. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h| 6 -- arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/platforms/cell/iommu.c | 4 ++-- arch/powerpc/platforms/powernv/pci-ioda.c |

[PATCH 26/34] powerpc/dma: fix an off-by-one in dma_capable

2018-11-14 Thread Christoph Hellwig
We need to compare the last byte in the dma range and not the one after it for the bus_dma_mask, just like we do for the regular dma_mask. Fix this cleanly by merging the two comparisms into one. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-direct.h | 8 ++-- 1 file

[PATCH 29/34] powerpc/dma: use phys_to_dma instead of get_dma_offset

2018-11-14 Thread Christoph Hellwig
Use the standard portable helper instead of the powerpc specific one, which is about to go away. Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/kernel/dma.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git

[PATCH 21/34] powerpc/pci: remove the dma_set_mask pci_controller ops methods

2018-11-14 Thread Christoph Hellwig
Unused now. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/pci-bridge.h | 2 -- arch/powerpc/kernel/dma.c | 7 --- 2 files changed, 9 deletions(-) diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h index

[PATCH 30/34] powerpc/dma: remove dma_nommu_mmap_coherent

2018-11-14 Thread Christoph Hellwig
The coherent cache version of this function already is functionally identicall to the default version, and by defining the arch_dma_coherent_to_pfn hook the same is ture for the noncoherent version as well. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h | 4

[PATCH 28/34] dma-mapping, powerpc: simplify the arch dma_set_mask override

2018-11-14 Thread Christoph Hellwig
Instead of letting the architecture supply all of dma_set_mask just give it an additional hook selected by Kconfig. Signed-off-by: Christoph Hellwig --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/dma-mapping.h | 3 --- arch/powerpc/kernel/dma-swiotlb.c | 8

[PATCH 27/34] powerpc/fsl_pci: simplify fsl_pci_dma_set_mask

2018-11-14 Thread Christoph Hellwig
swiotlb will only bounce buffer the effectice dma address for the device is smaller than the actual DMA range. Instead of flipping between the swiotlb and nommu ops for FSL SOCs that have the second outbound window just don't set the bus dma_mask in this case. Signed-off-by: Christoph Hellwig

[PATCH 23/34] powerpc/dma: remove get_pci_dma_ops

2018-11-14 Thread Christoph Hellwig
This function is only used by the Cell iommu code, which can keep track if it is using the iommu internally just as good. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/pci.h | 2 -- arch/powerpc/kernel/pci-common.c| 6 -- arch/powerpc/platforms/cell/iommu.c | 17

[PATCH 31/34] powerpc/dma: use generic direct and swiotlb ops

2018-11-14 Thread Christoph Hellwig
- The ppc32 case of dma_nommu_dma_supported already was a no-op, and the 64-bit case came to the same conclusion as dma_direct_supported, so replace it with the generic version. - supports CMA - Note that the cache maintainance in the existing code is a bit odd as it implements both

[PATCH 34/34] powerpc/dma: trim the fat from

2018-11-14 Thread Christoph Hellwig
There is no need to provide anything but get_arch_dma_ops to . More the remaining declarations to and drop all the includes. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h| 29 --- arch/powerpc/include/asm/iommu.h | 10 +++

[PATCH 13/34] powerpc/cell: use the generic iommu bypass code

2018-11-14 Thread Christoph Hellwig
This gets rid of a lot of clumsy code and finally allows us to mark dma_iommu_ops const. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h | 2 +- arch/powerpc/include/asm/iommu.h | 6 ++ arch/powerpc/kernel/dma-iommu.c| 7 +-

[PATCH 08/34] powerpc/dma: untangle vio_dma_mapping_ops from dma_iommu_ops

2018-11-14 Thread Christoph Hellwig
vio_dma_mapping_ops currently does a lot of indirect calls through dma_iommu_ops, which not only make the code harder to follow but are also expensive in the post-spectre world. Unwind the indirect calls by calling the ppc_iommu_* or iommu_* APIs directly applicable, or just use the dma_iommu_*

[PATCH 11/34] powerpc/pseries: use the generic iommu bypass code

2018-11-14 Thread Christoph Hellwig
Use the generic iommu bypass code instead of overriding set_dma_mask. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/pseries/iommu.c | 100 +++-- 1 file changed, 27 insertions(+), 73 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c

[PATCH 17/34] powerpc/powernv: remove pnv_npu_dma_set_mask

2018-11-14 Thread Christoph Hellwig
These devices are not PCIe devices and do not have associated dma map ops, so this is just dead code. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/powernv/pci-ioda.c | 9 - 1 file changed, 9 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c

[PATCH 12/34] powerpc/cell: move dma direct window setup out of dma_configure

2018-11-14 Thread Christoph Hellwig
Configure the dma settings at device setup time, and stop playing games with get_pci_dma_ops. This prepares for using the common dma_configure code later on. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/cell/iommu.c | 20 +++- 1 file changed, 11 insertions(+), 9

[PATCH 06/34] powerpc/dma: split the two __dma_alloc_coherent implementations

2018-11-14 Thread Christoph Hellwig
The implemementation for the CONFIG_NOT_COHERENT_CACHE case doesn't share any code with the one for systems with coherent caches. Split it off and merge it with the helpers in dma-noncoherent.c that have no other callers. Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt ---

[PATCH 01/34] powerpc: use mm zones more sensibly

2018-11-14 Thread Christoph Hellwig
Powerpc has somewhat odd usage where ZONE_DMA is used for all memory on common 64-bit configfs, and ZONE_DMA32 is used for 31-bit schemes. Move to a scheme closer to what other architectures use (and I dare to say the intent of the system): - ZONE_DMA: optionally for memory < 31-bit (64-bit

[PATCH 04/34] powerpc/dma: remove the unused ISA_DMA_THRESHOLD export

2018-11-14 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/kernel/setup_32.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 81909600013a..07f7e6aaf104 100644 --- a/arch/powerpc/kernel/setup_32.c

[PATCH 03/34] powerpc/dma: remove the unused ARCH_HAS_DMA_MMAP_COHERENT define

2018-11-14 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig Acked-by: Benjamin Herrenschmidt --- arch/powerpc/include/asm/dma-mapping.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index 8fa394520af6..f2a4a7142b1e 100644 ---

[PATCH 05/34] powerpc/dma: remove the unused dma_iommu_ops export

2018-11-14 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/powerpc/kernel/dma-iommu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c index f9fe2080ceb9..2ca6cfaebf65 100644 --- a/arch/powerpc/kernel/dma-iommu.c +++

[PATCH 02/34] powerpc: allow NOT_COHERENT_CACHE for amigaone

2018-11-14 Thread Christoph Hellwig
AMIGAONE select NOT_COHERENT_CACHE, so we better allow it. Signed-off-by: Christoph Hellwig --- arch/powerpc/platforms/Kconfig.cputype | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index

use generic DMA mapping code in powerpc V4

2018-11-14 Thread Christoph Hellwig
Hi all, this series switches the powerpc port to use the generic swiotlb and noncoherent dma ops, and to use more generic code for the coherent direct mapping, as well as removing a lot of dead code. As this series is very large and depends on the dma-mapping tree I've also published a git tree:

Re: [PATCH 06/10] swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs

2018-11-14 Thread Christoph Hellwig
Does the patch below make a difference for you? Assigning an address to the S/G list is the only functional difference I could spot. Drivers really should never look at the S/G list on an error return, but.. diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index

RE: [PATCH v2 1/5] iommu/arm-smmu: rearrange arm-smmu.c code

2018-11-14 Thread Krishna Reddy
Hi Will, Could you provide feedback on this V2 patch set? Your early feedback and direction on how to Tegra194 SMMU driver into upstream would be highly appreciated. Thanks, -KR -Original Message- From: Krishna Reddy Sent: Wednesday, October 31, 2018 4:49 PM To: will.dea...@arm.com;

Re: [PATCH 06/10] swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs

2018-11-14 Thread Christoph Hellwig
On Wed, Nov 14, 2018 at 03:13:11PM +0100, Christoph Hellwig wrote: > Does the patch below make a difference for you? Assigning an > address to the S/G list is the only functional difference I could > spot. Drivers really should never look at the S/G list on an > error return, but.. And that was