[PATCH v2] dma-debug: Kconfig for PREALLOC_DMA_DEBUG_ENTRIES

2018-11-30 Thread Qian Cai
The amount of DMA mappings from Hisilicon HNS ethernet devices is huge, so it could trigger "DMA-API: debugging out of memory - disabling". hnae_get_handle [1] hnae_init_queue hnae_init_ring hnae_alloc_buffers [2] debug_dma_map_page dma_entry_alloc [1] for (i = 0; i

Re: remove the ->mapping_error method from dma_map_ops V3

2018-11-30 Thread Linus Torvalds
On Fri, Nov 30, 2018 at 5:23 AM Christoph Hellwig wrote: > > Error reporting for the dma_map_single and dma_map_page operations is > currently a mess. [..] I don't see anything objectionable there, but it's not like I checked any of the context of the patches. For all I know there are odd corner

Re: [PATCH] dma-debug: Kconfig for PREALLOC_DMA_DEBUG_ENTRIES

2018-11-30 Thread Robin Murphy
On 30/11/2018 17:54, Qian Cai wrote: The amount of DMA mappings from Hisilicon HNS ethernet devices is huge, so it could trigger "DMA-API: debugging out of memory - disabling". hnae_get_handle [1] hnae_init_queue hnae_init_ring hnae_alloc_buffers [2] debug_dma_map_page

Re: [PATCH 6/9] dma-remap: support DMA_ATTR_NO_KERNEL_MAPPING

2018-11-30 Thread Robin Murphy
On 05/11/2018 12:19, Christoph Hellwig wrote: Do not waste vmalloc space on allocations that do not require a mapping into the kernel address space. Signed-off-by: Christoph Hellwig --- kernel/dma/remap.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/

Re: [PATCH 4/9] dma-mapping: move the arm64 ncoherent alloc/free support to common code

2018-11-30 Thread Robin Murphy
On 05/11/2018 12:19, Christoph Hellwig wrote: The arm64 codebase to implement coherent dma allocation for architectures with non-coherent DMA is a good start for a generic implementation, given that is uses the generic remap helpers, provides the atomic pool for allocations that can't sleep and s

Re: [PATCH 3/9] dma-mapping: move the remap helpers to a separate file

2018-11-30 Thread Robin Murphy
On 05/11/2018 12:19, Christoph Hellwig wrote: The dma remap code only really makes sense for not cache coherent architectures, And coherent ones with highmem, presumably? That can at least be the case on 32-bit Arm, where coherent LPAE systems do exist (e.g. Calxeda Midway). and currently

Re: [PATCH 5/9] dma-mapping: support highmem in the generic remap allocator

2018-11-30 Thread Robin Murphy
On 05/11/2018 12:19, Christoph Hellwig wrote: By using __dma_direct_alloc_pages we can deal entirely with struct page instead of having to derive a kernel virtual address. Simple enough :) Reviewed-by: Robin Murphy Signed-off-by: Christoph Hellwig --- kernel/dma/remap.c | 14 +++-

Re: [PATCH 2/9] dma-direct: reject highmem pages from dma_alloc_from_contiguous

2018-11-30 Thread Robin Murphy
On 05/11/2018 12:19, Christoph Hellwig wrote: dma_alloc_from_contiguous can return highmem pages depending on the setup, which a plain non-remapping DMA allocator can't handle. Detect this case and try the normal page allocator instead. ...except the actual implementation is "Detect this case

Re: [PATCH 1/9] dma-direct: provide page based alloc/free helpers

2018-11-30 Thread Robin Murphy
On 05/11/2018 12:19, Christoph Hellwig wrote: Some architectures support remapping highmem into DMA coherent allocations. To use the common code for them we need variants of dma_direct_{alloc,free}_pages that do not use kernel virtual addresses. FWIW it's as much about non-cacheable remapping

Re: remove the ->mapping_error method from dma_map_ops V3

2018-11-30 Thread Russell King - ARM Linux
On Fri, Nov 30, 2018 at 02:22:08PM +0100, Christoph Hellwig wrote: > Error reporting for the dma_map_single and dma_map_page operations is > currently a mess. Both APIs directly return the dma_addr_t to be used for > the DMA, with a magic error escape that is specific to the instance and > checked

Re: [PATCH v18 1/5] iommu/arm-smmu: Add pm_runtime/sleep ops

2018-11-30 Thread Will Deacon
On Thu, Nov 29, 2018 at 08:25:20PM +0530, Vivek Gautam wrote: > On Wed, Nov 28, 2018 at 10:07 PM Robin Murphy wrote: > > > > On 28/11/2018 16:24, Stephen Boyd wrote: > > > Quoting Vivek Gautam (2018-11-27 02:11:41) > > >> @@ -1966,6 +1970,23 @@ static const struct of_device_id > > >> arm_smmu_of_

[PATCH] dma-debug: Kconfig for PREALLOC_DMA_DEBUG_ENTRIES

2018-11-30 Thread Qian Cai
The amount of DMA mappings from Hisilicon HNS ethernet devices is huge, so it could trigger "DMA-API: debugging out of memory - disabling". hnae_get_handle [1] hnae_init_queue hnae_init_ring hnae_alloc_buffers [2] debug_dma_map_page dma_entry_alloc [1] for (i = 0; i

Re: PCI passthrough with multiple devices in same iommu group

2018-11-30 Thread Alex Williamson
On Fri, 30 Nov 2018 12:04:26 +0530 gokul cg wrote: > Thanks for info > > See inline > On Wed, Nov 28, 2018 at 8:56 PM Alex Williamson > wrote: > > > On Wed, 28 Nov 2018 20:21:02 +0530 > > gokul cg wrote: > > > > > Hi Folks, > > > > > > Please excuse me , I just writing to you as i could see

Re: use generic DMA mapping code in powerpc V4

2018-11-30 Thread Christian Zigotzky
Hello Christoph, Thanks for your reply. On 30 November 2018 at 2:10PM, Christoph Hellwig wrote: On Fri, Nov 30, 2018 at 01:23:20PM +0100, Christian Zigotzky wrote: Yes, of course. I patched your Git kernel and after that I compiled it again. U-Boot loads the kernel and the dtb file. Then the k

[PATCH] irq_remapping: Remove unused header files

2018-11-30 Thread Yangtao Li
seq_file.h does not need to be included,so remove it. Signed-off-by: Yangtao Li --- drivers/iommu/irq_remapping.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c index 7d0f3074d41d..b94ebd42edd8 100644 --- a/drivers/iommu/irq_remap

[PATCH 16/23] x86/calgary: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Return DMA_MAPPING_ERROR instead of the magic bad_dma_addr on a dma mapping failure and let the core dma-mapping code handle the rest. Remove the magic EMERGENCY_PAGES that the bad_dma_addr gets redirected to. Signed-off-by: Christoph Hellwig --- arch/x86/kernel/pci-calgary_64.c | 29 +++---

[PATCH 23/23] dma-mapping: return an error code from dma_mapping_error

2018-11-30 Thread Christoph Hellwig
Currently dma_mapping_error returns a boolean as int, with 1 meaning error. This is rather unusual and many callers have to convert it to errno value. The callers are highly inconsistent with error codes ranging from -ENOMEM over -EIO, -EINVAL and -EFAULT ranging to -EAGAIN. Return -ENOMEM which

[PATCH 20/23] iommu/dma-iommu: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Return DMA_MAPPING_ERROR instead of 0 on a dma mapping failure and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/arm64/mm/dma-mapping.c | 7 +++ drivers/iommu/dma-iommu.c | 23 --- include/linux/dma-iommu.h | 1 - 3 files c

[PATCH 19/23] iommu/vt-d: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Return DMA_MAPPING_ERROR instead of 0 on a dma mapping failure and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- drivers/iommu/intel-iommu.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/driver

[PATCH 17/23] iommu: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Return DMA_MAPPING_ERROR instead of 0 on a dma mapping failure and let the core dma-mapping code handle the rest. Note that the existing code used AMD_IOMMU_MAPPING_ERROR to check from a 0 return from the IOVA allocator, which is replaced with an explicit 0 as in the implementation and other users

[PATCH 22/23] dma-mapping: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
No users left except for vmd which just forwards it. Signed-off-by: Christoph Hellwig --- drivers/pci/controller/vmd.c | 6 -- include/linux/dma-mapping.h | 7 --- 2 files changed, 13 deletions(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index e50b0b5815

[PATCH 18/23] iommu/intel: small map_page cleanup

2018-11-30 Thread Christoph Hellwig
Pass the page + offset to the low-level __iommu_map_single helper (which gets renamed to fit the new calling conventions) as both callers have the page at hand. Signed-off-by: Christoph Hellwig --- drivers/iommu/intel-iommu.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-)

[PATCH 21/23] xen-swiotlb: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Return DMA_MAPPING_ERROR instead of 0 on a dma mapping failure and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- drivers/xen/swiotlb-xen.c | 12 ++-- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/xen/swiotlb-xen.c b/drivers/x

[PATCH 15/23] x86/amd_gart: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Return DMA_MAPPING_ERROR instead of the magic bad_dma_addr on a dma mapping failure and let the core dma-mapping code handle the rest. Remove the magic EMERGENCY_PAGES that the bad_dma_addr gets redirected to. Signed-off-by: Christoph Hellwig --- arch/x86/kernel/amd_gart_64.c | 39 ++---

[PATCH 14/23] ia64/sn: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Return DMA_MAPPING_ERROR instead of 0 on a dma mapping failure and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/ia64/sn/pci/pci_dma.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/p

[PATCH 13/23] ia64/sba_iommu: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Return DMA_MAPPING_ERROR instead of 0 on a dma mapping failure and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/ia64/hp/common/sba_iommu.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch

[PATCH 12/23] ia64/sba_iommu: improve internal map_page users

2018-11-30 Thread Christoph Hellwig
Remove the odd sba_{un,}map_single_attrs wrappers, check errors everywhere. Signed-off-by: Christoph Hellwig --- arch/ia64/hp/common/sba_iommu.c | 73 + 1 file changed, 29 insertions(+), 44 deletions(-) diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/

[PATCH 09/23] parisc/sba_iommu: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
The SBA iommu code already returns (~(dma_addr_t)0x0) on mapping failures, so we can switch over to returning DMA_MAPPING_ERROR and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- drivers/parisc/sba_iommu.c | 10 +- 1 file changed, 1 insertion(+), 9 de

[PATCH 11/23] alpha: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Return DMA_MAPPING_ERROR instead of 0 on a dma mapping failure and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/alpha/kernel/pci_iommu.c | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/alpha/kernel/pci_iommu.c b

[PATCH 08/23] parisc/ccio: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
The CCIO iommu code already returns (~(dma_addr_t)0x0) on mapping failures, so we can switch over to returning DMA_MAPPING_ERROR and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- drivers/parisc/ccio-dma.c | 10 +- 1 file changed, 1 insertion(+), 9 de

[PATCH 10/23] arm64: remove the dummy_dma_ops mapping_error method

2018-11-30 Thread Christoph Hellwig
Just return DMA_MAPPING_ERROR from __dummy_map_page and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/arm64/mm/dma-mapping.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mappi

[PATCH 06/23] s390: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
S390 already returns (~(dma_addr_t)0x0) on mapping failures, so we can switch over to returning DMA_MAPPING_ERROR and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/s390/pci/pci_dma.c | 18 +- 1 file changed, 5 insertions(+), 13 deletions

[PATCH 07/23] sparc: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Sparc already returns (~(dma_addr_t)0x0) on mapping failures, so we can switch over to returning DMA_MAPPING_ERROR and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/sparc/kernel/iommu.c| 12 +++- arch/sparc/kernel/iommu_common.h | 2 --

[PATCH 04/23] powerpc/iommu: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
The powerpc iommu code already returns (~(dma_addr_t)0x0) on mapping failures, so we can switch over to returning DMA_MAPPING_ERROR and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/iommu.h | 4 arch/powerpc/kernel/dma-iomm

[PATCH 05/23] mips/jazz: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
The Jazz iommu code already returns (~(dma_addr_t)0x0) on mapping failures, so we can switch over to returning DMA_MAPPING_ERROR and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/mips/include/asm/jazzdma.h | 6 -- arch/mips/jazz/jazzdma.c|

[PATCH 03/23] arm: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
Arm already returns (~(dma_addr_t)0x0) on mapping failures, so we can switch over to returning DMA_MAPPING_ERROR and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/arm/common/dmabounce.c | 12 +++--- arch/arm/include/asm/dma-iommu.h | 2 -- arc

[PATCH 02/23] dma-direct: remove the mapping_error dma_map_ops method

2018-11-30 Thread Christoph Hellwig
The dma-direct code already returns (~(dma_addr_t)0x0) on mapping failures, so we can switch over to returning DMA_MAPPING_ERROR and let the core dma-mapping code handle the rest. Signed-off-by: Christoph Hellwig --- arch/powerpc/kernel/dma-swiotlb.c | 1 - include/linux/dma-direct.h|

remove the ->mapping_error method from dma_map_ops V3

2018-11-30 Thread Christoph Hellwig
Error reporting for the dma_map_single and dma_map_page operations is currently a mess. Both APIs directly return the dma_addr_t to be used for the DMA, with a magic error escape that is specific to the instance and checked by another method provided. This has a few downsides: - the error check

[PATCH 01/23] dma-mapping: provide a generic DMA_MAPPING_ERROR

2018-11-30 Thread Christoph Hellwig
Error handling of the dma_map_single and dma_map_page APIs is a little problematic at the moment, in that we use different encodings in the returned dma_addr_t to indicate an error. That means we require an additional indirect call to figure out if a dma mapping call returned an error, and a lot o

Re: use generic DMA mapping code in powerpc V4

2018-11-30 Thread Christoph Hellwig
On Fri, Nov 30, 2018 at 01:23:20PM +0100, Christian Zigotzky wrote: > Hi Christoph, > > Thanks a lot for your fast reply. > > On 30 November 2018 at 11:53AM, Christoph Hellwig wrote: >> Hi Christian, >> >> for such a diverse architecture like powerpc we'll have to rely on >> users / non core develo

Re: use generic DMA mapping code in powerpc V4

2018-11-30 Thread Christian Zigotzky
Hi Christoph, Thanks a lot for your fast reply. On 30 November 2018 at 11:53AM, Christoph Hellwig wrote: Hi Christian, for such a diverse architecture like powerpc we'll have to rely on users / non core developers like you to help with testing. I see. I will help as good as I can. Can you t

Re: [PATCH] dma-debug: hns_enet_drv could use more DMA entries

2018-11-30 Thread Robin Murphy
On 30/11/2018 08:42, Christoph Hellwig wrote: On Thu, Nov 29, 2018 at 10:54:56PM -0500, Qian Cai wrote: /* allow architectures to override this if absolutely required */ #ifndef PREALLOC_DMA_DEBUG_ENTRIES +/* amount of DMA mappings on this driver is huge. */ +#ifdef HNS_ENET +#define PREALLO

[PATCH v4] iommu/dma: Use NUMA aware memory allocations in __iommu_dma_alloc_pages()

2018-11-30 Thread John Garry
From: Ganapatrao Kulkarni Change function __iommu_dma_alloc_pages() to allocate pages for DMA from respective device NUMA node. The ternary operator which would be for alloc_pages_node() is tidied along with this. The motivation for this change is to have a policy for page allocation consistent

Re: use generic DMA mapping code in powerpc V4

2018-11-30 Thread Christoph Hellwig
Hi Christian, for such a diverse architecture like powerpc we'll have to rely on users / non core developers like you to help with testing. Can you try the patch below for he cyrus config? For the nemo one I have no idea yet, there is no chance I could trick you into a git bisect to see which pa

Re: [PATCH] dma-debug: hns_enet_drv could use more DMA entries

2018-11-30 Thread John Garry
+ Pasting original message at bottom. On 30/11/2018 08:42, Christoph Hellwig wrote: On Thu, Nov 29, 2018 at 10:54:56PM -0500, Qian Cai wrote: /* allow architectures to override this if absolutely required */ #ifndef PREALLOC_DMA_DEBUG_ENTRIES +/* amount of DMA mappings on this driver is hug

Re: [PATCH] dma-debug: hns_enet_drv could use more DMA entries

2018-11-30 Thread Christoph Hellwig
On Thu, Nov 29, 2018 at 10:54:56PM -0500, Qian Cai wrote: > /* allow architectures to override this if absolutely required */ > #ifndef PREALLOC_DMA_DEBUG_ENTRIES > +/* amount of DMA mappings on this driver is huge. */ > +#ifdef HNS_ENET > +#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 17) > +#e