use generic DMA mapping code in powerpc

2018-07-30 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 dead code. ___ iommu mailing list iommu@lists.linux-foundation.org

[PATCH 12/20] powerpc/dma: use phys_to_dma instead of get_dma_offset

2018-07-30 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 --- arch/powerpc/kernel/dma-swiotlb.c | 5 ++--- arch/powerpc/kernel/dma.c | 12 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git

[PATCH 06/20] dma-noncoherent: add an optional arch hook for ->get_required_mask

2018-07-30 Thread Christoph Hellwig
This is need for powerpc for now. Hopefully we can come up with a clean generic implementation mid-term. Signed-off-by: Christoph Hellwig --- include/linux/dma-noncoherent.h | 6 ++ kernel/dma/Kconfig | 4 kernel/dma/noncoherent.c| 1 + 3 files changed, 11

[PATCH 05/20] swiotlb: allow the architecture to provide a get_required_mask hook

2018-07-30 Thread Christoph Hellwig
For now this allows consolidating the powerpc code. In the long run we should grow a generic implementation of dma_get_required_mask that returns the dma mask required to avoid bounce buffering. Signed-off-by: Christoph Hellwig --- kernel/dma/swiotlb.c | 4 1 file changed, 4 insertions(+)

[PATCH 19/20] powerpc/dma: use the generic dma-direct map_page and map_sg routines

2018-07-30 Thread Christoph Hellwig
These are indentical except for additional error checking, so migrate to the common code, and wire up the get_mapping_error method as well. Signed-off-by: Christoph Hellwig --- arch/powerpc/kernel/dma.c | 32 1 file changed, 4 insertions(+), 28 deletions(-)

[PATCH 18/20] powerpc/dma-noncoherent: use generic dma_noncoherent_ops

2018-07-30 Thread Christoph Hellwig
The generic dma-noncoherent code provides all that is needed by powerpc. Note that the cache maintainance in the existing code is a bit odd as it implements both the sync_to_device and sync_to_cpu callouts, but never flushes caches when unmapping. This patch keeps both directions arounds, which

[PATCH 20/20] powerpc/dma: remove dma_nommu_mmap_coherent

2018-07-30 Thread Christoph Hellwig
The remaining implementation for coherent caches is functionally identical to the default provided in common code. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-mapping.h | 7 --- arch/powerpc/kernel/dma-iommu.c| 1 - arch/powerpc/kernel/dma.c | 13

[PATCH 02/20] kernel/dma/direct: refine dma_direct_alloc zone selection

2018-07-30 Thread Christoph Hellwig
We need to take the DMA offset and encryption bit into account when selecting a zone. Add a helper that takes those into account and use it. Signed-off-by: Christoph Hellwig --- kernel/dma/direct.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git

[PATCH 15/20] powerpc/dma: remove the unused unmap_page and unmap_sg methods

2018-07-30 Thread Christoph Hellwig
These methods are optional to start with, no need to implement no-op versions. Signed-off-by: Christoph Hellwig --- 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 17/20] powerpc/dma-swiotlb: use generic swiotlb_dma_ops

2018-07-30 Thread Christoph Hellwig
These are identical to the arch specific ones, so remove them. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/dma-direct.h | 4 arch/powerpc/include/asm/swiotlb.h| 2 -- arch/powerpc/kernel/dma-swiotlb.c | 28 ++-

[PATCH] sparc: use generic dma_noncoherent_ops

2018-07-30 Thread Christoph Hellwig
Switch to the generic noncoherent direct mapping implementation. This removes the previous sync_single_for_device implementation, which looks bogus given that no syncing is happening in the similar but more important map_single case. Signed-off-by: Christoph Hellwig Acked-by: Sam Ravnborg ---

[PATCH 07/20] powerpc/dma: remove the unused ARCH_HAS_DMA_MMAP_COHERENT define

2018-07-30 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- 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 --- a/arch/powerpc/include/asm/dma-mapping.h

[PATCH 10/20] powerpc/dma-noncoherent: don't disable irqs over kmap_atomic

2018-07-30 Thread Christoph Hellwig
The requirement to disable local irqs over kmap_atomic is long gone, so remove those calls. Signed-off-by: Christoph Hellwig --- arch/powerpc/mm/dma-noncoherent.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/powerpc/mm/dma-noncoherent.c

[PATCH 08/20] powerpc/dma: remove the unused dma_nommu_ops export

2018-07-30 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- arch/powerpc/kernel/dma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index dbfc7056d7df..3939589aab04 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -286,7 +286,6 @@

[PATCH 13/20] powerpc/dma: remove get_dma_offset

2018-07-30 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 --- arch/powerpc/include/asm/dma-direct.h | 8 ++-- arch/powerpc/include/asm/dma-mapping.h | 16 2 files changed, 6

[PATCH 14/20] powerpc/dma: replace dma_nommu_dma_supported with dma_direct_supported

2018-07-30 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. Signed-off-by: Christoph Hellwig --- arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/dma.c | 28

[PATCH 01/20] kernel/dma/direct: take DMA offset into account in dma_direct_supported

2018-07-30 Thread Christoph Hellwig
When a device has a DMA offset the dma capable result will change due to the difference between the physical and DMA address. Take that into account. Signed-off-by: Christoph Hellwig --- kernel/dma/direct.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git

[PATCH 03/20] dma-mapping: make the get_required_mask method available unconditionally

2018-07-30 Thread Christoph Hellwig
This save some duplication for ia64. In the long run this method will need some additional work including moving over to kernel/dma, but that will require some additional prep work, so let's do this minimal change for now. Signed-off-by: Christoph Hellwig --- drivers/base/platform.c | 11

[PATCH 04/20] ia64: remove get_required_mask implementation

2018-07-30 Thread Christoph Hellwig
ia64 can use the generic implementation in general, and SN2 can just override it in the dma_map_ops now. Signed-off-by: Christoph Hellwig --- arch/ia64/include/asm/dma-mapping.h | 2 -- arch/ia64/include/asm/machvec.h | 7 --- arch/ia64/include/asm/machvec_init.h | 1 -

[PATCH 11/20] powerpc/dma: split the two __dma_alloc_coherent implementations

2018-07-30 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 ---

[PATCH 09/20] powerpc/dma: remove the unused ISA_DMA_THRESHOLD export

2018-07-30 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig --- 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 74457485574b..3c2d093f74c7 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c

[PATCH 16/20] powerpc/dma: use dma_direct_{alloc,free}

2018-07-30 Thread Christoph Hellwig
These do the same functionality as the existing helpers, but do it simpler, and also allow the (optional) use of CMA. Note that the swiotlb code now calls into the dma_direct code directly, given that it doesn't work with noncoherent caches at all, and isn't called when we have an iommu either,

Re: [PATCH 2/3] dmapool: improve scalability of dma_pool_free

2018-07-30 Thread Tony Battersby
On 07/27/2018 05:27 PM, Tony Battersby wrote: > On 07/27/2018 03:38 PM, Tony Battersby wrote: >> But the bigger problem is that my first patch adds another list_head to >> the dma_page for the avail_page_link to make allocations faster.  I >> suppose we could make the lists singly-linked instead

Re: [PATCH] PCI: call dma_debug_add_bus for pci_bus_type in common code

2018-07-30 Thread Thomas Gleixner
On Mon, 30 Jul 2018, Christoph Hellwig wrote: > There is nothing arch specific about PCI or dma-debug, so move this > call to common code just after registering the bus type. > > Signed-off-by: Christoph Hellwig Acked-by: Thomas Gleixner ___ iommu

Re: [PATCH] sparc: use generic dma_noncoherent_ops

2018-07-30 Thread Sam Ravnborg
Hi Christoph. On Mon, Jul 30, 2018 at 06:17:23PM +0200, Christoph Hellwig wrote: > Switch to the generic noncoherent direct mapping implementation. > > This removes the previous sync_single_for_device implementation, which > looks bogus given that no syncing is happening in the similar but more

Re: [PATCH] PCI: call dma_debug_add_bus for pci_bus_type in common code

2018-07-30 Thread Bjorn Helgaas
[+cc Joerg] On Mon, Jul 30, 2018 at 09:38:42AM +0200, Christoph Hellwig wrote: > There is nothing arch specific about PCI or dma-debug, so move this > call to common code just after registering the bus type. I assume that previously, even if the user set CONFIG_DMA_API_DEBUG=y we only got PCI

Re: [PATCH] iommu/iova: Update cached node pointer when current node fails to get any free IOVA

2018-07-30 Thread Ganapatrao Kulkarni
Hi Robin, On Mon, Jul 30, 2018 at 12:40 PM, Ganapatrao Kulkarni wrote: > On Fri, Jul 27, 2018 at 9:48 PM, Robin Murphy wrote: >> On 27/07/18 13:56, Ganapatrao Kulkarni wrote: >> [...] > > did you get any chance to look in to this issue? > i am waiting for your suggestion/patch for

Re: use the generic dma-noncoherent code for sh V2

2018-07-30 Thread Christoph Hellwig
On Fri, Jul 27, 2018 at 11:20:21AM -0500, Rob Landley wrote: > Speaking of DMA: Which really has nothing to do with the dma mapping code, which also means I can't help you much unfortunately. That being said sh is the last pending of the initial dma-noncoherent conversion, I'd greatly appreciate

Re: use the generic dma-noncoherent code for sh V2

2018-07-30 Thread Geert Uytterhoeven
Hi Rob, CC Guennadi On Fri, Jul 27, 2018 at 6:21 PM Rob Landley wrote: > On 07/24/2018 03:21 PM, Christoph Hellwig wrote: > > On Tue, Jul 24, 2018 at 02:01:42PM +0200, Christoph Hellwig wrote: > >> can you review these patches to switch sh to use the generic > >> dma-noncoherent code? All the

[PATCH] iommu: remove the ->map_sg indirection

2018-07-30 Thread Christoph Hellwig
All iommu drivers use the default_iommu_map_sg implementation, and there is no good reason to ever override it. Just expose it as iommu_map_sg directly and remove the indirection, specially in our post-spectre world where indirect calls are horribly expensive. Signed-off-by: Christoph Hellwig

[PATCH] PCI: call dma_debug_add_bus for pci_bus_type in common code

2018-07-30 Thread Christoph Hellwig
There is nothing arch specific about PCI or dma-debug, so move this call to common code just after registering the bus type. Signed-off-by: Christoph Hellwig --- arch/powerpc/kernel/dma.c | 3 --- arch/sh/drivers/pci/pci.c | 2 -- arch/x86/kernel/pci-dma.c | 3 --- drivers/pci/pci-driver.c | 2

Re: [PATCH] iommu/iova: Update cached node pointer when current node fails to get any free IOVA

2018-07-30 Thread Ganapatrao Kulkarni
On Fri, Jul 27, 2018 at 9:48 PM, Robin Murphy wrote: > On 27/07/18 13:56, Ganapatrao Kulkarni wrote: > [...] did you get any chance to look in to this issue? i am waiting for your suggestion/patch for this issue! >>> >>> >>> >>> I got as far as [1], but I wasn't sure how much I

[PATCH] powerpc: do not redefined NEED_DMA_MAP_STATE

2018-07-30 Thread Christoph Hellwig
kernel/dma/Kconfig already defines NEED_DMA_MAP_STATE, just select it from PPC64 and NOT_COHERENT_CACHE instead. Signed-off-by: Christoph Hellwig --- arch/powerpc/Kconfig | 3 --- arch/powerpc/platforms/Kconfig.cputype | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-)

Re: [PATCH] sparc: use generic dma_noncoherent_ops

2018-07-30 Thread Christoph Hellwig
On Fri, Jul 27, 2018 at 11:05:48PM +0200, Sam Ravnborg wrote: > Hi Christoph. > > Some observations below - nitpick and bikeshedding only. > > The parameter of phys_addr_t is sometimes renamed > to use the same name as in the original prototype (good), > and sometimes uses the old name (bad). >