generic DMA bypass flag v4
Subsystems (16)
Hi all,
I've recently beeing chatting with Lu about using dma-iommu and per-device DMA ops in the intel IOMMU driver, and one missing feature in dma-iommu is a bypass mode where the direct mapping is used even when an iommu is attached to improve performance. The powerpc code already has a similar mode, so I'd like to move it to the core DMA mapping code. As part of that I noticed that the current powerpc code has a little bug in that it used the wrong check in the dma_sync_* routines to see if the direct mapping code is used.
These two patches just add the generic code and move powerpc over, the intel IOMMU bits will require a separate discussion.
The x86 AMD Gart code also has a bypass mode, but it is a lot strange, so I'm not going to touch it for now.
Note that as-is this breaks the XSK buffer pool, which unfortunately poked directly into DMA internals. A fix for that is already queued up in the netdev tree.
Jesper and XDP gang: this should not regress any performance as the dma-direct calls are now inlined into the out of line DMA mapping calls. But if you can verify the performance numbers that would be greatly appreciated.
A git tree is available here:
git://git.infradead.org/users/hch/misc.git dma-bypass.4
Gitweb:
git.infradead.org/users/hch/misc.git/shortlog/refs/heads/dma-bypass.4
Changes since v3:
- add config options for the dma ops bypass and dma ops themselves to not increase the size of tinyconfig builds
Changes since v2:
- move the dma mapping helpers out of line
- check for possible direct mappings using the dma mask
Changes since v1:
- rebased to the current dma-mapping-for-next tree
Diffstat:
arch/alpha/Kconfig | 1 arch/arm/Kconfig | 1 arch/ia64/Kconfig | 1 arch/mips/Kconfig | 1 arch/parisc/Kconfig | 1 arch/powerpc/Kconfig | 2 arch/powerpc/include/asm/device.h | 5 arch/powerpc/kernel/dma-iommu.c | 90 +------------ arch/s390/Kconfig | 1 arch/sparc/Kconfig | 1 arch/x86/Kconfig | 1 drivers/iommu/Kconfig | 2 drivers/misc/mic/Kconfig | 1 drivers/vdpa/Kconfig | 1 drivers/xen/Kconfig | 1 include/linux/device.h | 11 + include/linux/dma-direct.h | 104 +++++++++++++++ include/linux/dma-mapping.h | 251 ++++---------------------------------- kernel/dma/Kconfig | 12 + kernel/dma/Makefile | 3 kernel/dma/direct.c | 74 ----------- kernel/dma/mapping.c | 214 ++++++++++++++++++++++++++++++-- 22 files changed, 385 insertions(+), 394 deletions(-)
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 1/5 dma-mapping: move the remaining DMA API calls out of line
For a long time the DMA API has been implemented inline in dma-mapping.h, but the function bodies can be quite large. Move them all out of line.
This also removes all the dma_direct_* exports as those are just implementation details and should never be used by drivers directly.
--- include/linux/dma-direct.h | 58 +++++++++ include/linux/dma-mapping.h | 247 ++++-------------------------------- kernel/dma/direct.c | 9 -- kernel/dma/mapping.c | 164 ++++++++++++++++++++++++ 4 files changed, 244 insertions(+), 234 deletions(-)
include/linux/dma-direct.h +58 -0
@@ -86,4 +86,62 @@ int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma, unsigned long attrs);int dma_direct_supported (struct device *dev,u64 mask);bool dma_direct_need_sync (struct device *dev,dma_addr_t dma_addr); +dma_addr_t dma_direct_map_page (struct device *dev,struct page *page, +unsigned long offset,size_t size,enum dma_data_direction dir, +unsigned long attrs); +int dma_direct_map_sg (struct device *dev,struct scatterlist *sgl,int nents, +enum dma_data_direction dir,unsigned long attrs); +dma_addr_t dma_direct_map_resource (struct device *dev,phys_addr_t paddr, +size_t size,enum dma_data_direction dir,unsigned long attrs); + +#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE ) || \ + defined(CONFIG_SWIOTLB ) +void dma_direct_sync_single_for_device (struct device *dev, +dma_addr_t addr,size_t size,enum dma_data_direction dir); +void dma_direct_sync_sg_for_device (struct device *dev, +struct scatterlist *sgl,int nents,enum dma_data_direction dir); +#else +static inline void dma_direct_sync_single_for_device (struct device *dev, +dma_addr_t addr,size_t size,enum dma_data_direction dir) +{ +} +static inline void dma_direct_sync_sg_for_device (struct device *dev, +struct scatterlist *sgl,int nents,enum dma_data_direction dir) +{ +} +#endif + +#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU ) || \ + defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL ) || \ + defined(CONFIG_SWIOTLB ) +void dma_direct_unmap_page (struct device *dev,dma_addr_t addr, +size_t size,enum dma_data_direction dir,unsigned long attrs); +void dma_direct_unmap_sg (struct device *dev,struct scatterlist *sgl, +int nents,enum dma_data_direction dir,unsigned long attrs); +void dma_direct_sync_single_for_cpu (struct device *dev, +dma_addr_t addr,size_t size,enum dma_data_direction dir); +void dma_direct_sync_sg_for_cpu (struct device *dev, +struct scatterlist *sgl,int nents,enum dma_data_direction dir); +#else +static inline void dma_direct_unmap_page (struct device *dev,dma_addr_t addr, +size_t size,enum dma_data_direction dir,unsigned long attrs) +{ +} +static inline void dma_direct_unmap_sg (struct device *dev, +struct scatterlist *sgl,int nents,enum dma_data_direction dir, +unsigned long attrs) +{ +} +static inline void dma_direct_sync_single_for_cpu (struct device *dev, +dma_addr_t addr,size_t size,enum dma_data_direction dir) +{ +} +static inline void dma_direct_sync_sg_for_cpu (struct device *dev, +struct scatterlist *sgl,int nents,enum dma_data_direction dir) +{ +} +#endif + +size_t dma_direct_max_mapping_size (struct device *dev); +#endif /* _LINUX_DMA_DIRECT_H */
include/linux/dma-mapping.h +22 -225
265 lines not on this page · raw message
kernel/dma/direct.c +0 -9
@@ -315,7 +315,6 @@ void dma_direct_sync_single_for_device(struct device *dev,if (!dev_is_dma_coherent (dev))arch_sync_dma_for_device (paddr, size, dir); } -EXPORT_SYMBOL (dma_direct_sync_single_for_device);void dma_direct_sync_sg_for_device (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction dir)
@@ -335,7 +334,6 @@ void dma_direct_sync_sg_for_device(struct device *dev, dir); } } -EXPORT_SYMBOL (dma_direct_sync_sg_for_device);#endif #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
@@ -354,7 +352,6 @@ void dma_direct_sync_single_for_cpu(struct device *dev,if (unlikely (is_swiotlb_buffer (paddr)))swiotlb_tbl_sync_single (dev, paddr, size, dir,SYNC_FOR_CPU ); } -EXPORT_SYMBOL (dma_direct_sync_single_for_cpu);void dma_direct_sync_sg_for_cpu (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction dir)
@@ -376,7 +373,6 @@ void dma_direct_sync_sg_for_cpu(struct device *dev,if (!dev_is_dma_coherent (dev))arch_sync_dma_for_cpu_all (); } -EXPORT_SYMBOL (dma_direct_sync_sg_for_cpu);void dma_direct_unmap_page (struct device *dev,dma_addr_t addr,size_t size,enum dma_data_direction dir,unsigned long attrs)
@@ -389,7 +385,6 @@ void dma_direct_unmap_page(struct device *dev, dma_addr_t addr,if (unlikely (is_swiotlb_buffer (phys)))swiotlb_tbl_unmap_single (dev, phys, size, size, dir, attrs); } -EXPORT_SYMBOL (dma_direct_unmap_page);void dma_direct_unmap_sg (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction dir,unsigned long attrs)
@@ -401,7 +396,6 @@ void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sgl,dma_direct_unmap_page (dev, sg->dma_address,sg_dma_len (sg), dir, attrs); } -EXPORT_SYMBOL (dma_direct_unmap_sg);#endif dma_addr_t dma_direct_map_page(struct device *dev, struct page *page,
@@ -428,7 +422,6 @@ dma_addr_t dma_direct_map_page(struct device *dev, struct page *page,arch_sync_dma_for_device (phys, size, dir);return dma_addr; } -EXPORT_SYMBOL (dma_direct_map_page);int dma_direct_map_sg (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction dir,unsigned long attrs)
@@ -450,7 +443,6 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,dma_direct_unmap_sg (dev, sgl, i, dir, attrs |DMA_ATTR_SKIP_CPU_SYNC );return 0 ; } -EXPORT_SYMBOL (dma_direct_map_sg);dma_addr_t dma_direct_map_resource (struct device *dev,phys_addr_t paddr,size_t size,enum dma_data_direction dir,unsigned long attrs)
@@ -467,7 +459,6 @@ dma_addr_t dma_direct_map_resource(struct device *dev, phys_addr_t paddr,return dma_addr; } -EXPORT_SYMBOL (dma_direct_map_resource); int dma_direct_get_sgtable(struct device *dev, struct sg_table *sgt, void *cpu_addr, dma_addr_t dma_addr, size_t size,
kernel/dma/mapping.c +164 -0
170 lines not on this page · raw message
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 2/5 dma-mapping: inline the fast path dma-direct calls
In reply to Christoph HellwigInline the single page map/unmap/sync dma-direct calls into the now out of line generic wrappers. This restores the behavior of a single function call that we had before moving the generic calls out of line. Besides the dma-mapping callers there are just a few callers in IOMMU drivers that have a bypass mode, and more of those are going to be switched to the generic bypass soon.
--- include/linux/dma-direct.h | 92 ++++++++++++++++++++++++++++---------- kernel/dma/direct.c | 65 --------------------------- 2 files changed, 69 insertions(+), 88 deletions(-)
include/linux/dma-direct.h +69 -23
@@ -1,10 +1,16 @@/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Internals of the DMA direct mapping implementation. Only for use by the +* DMA mapping code and IOMMU drivers. +*/ #ifndef _LINUX_DMA_DIRECT_H#define _LINUX_DMA_DIRECT_H 1#include <linux/dma-mapping.h> +#include <linux/dma-noncoherent.h> #include <linux/memblock.h> /* for min_low_pfn */ #include <linux/mem_encrypt.h> +#include <linux/swiotlb.h> extern unsigned int zone_dma_bits;
@@ -86,25 +92,17 @@ int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma, unsigned long attrs);int dma_direct_supported (struct device *dev,u64 mask);bool dma_direct_need_sync (struct device *dev,dma_addr_t dma_addr); -dma_addr_t dma_direct_map_page (struct device *dev,struct page *page, -unsigned long offset,size_t size,enum dma_data_direction dir, -unsigned long attrs);int dma_direct_map_sg (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction dir,unsigned long attrs);dma_addr_t dma_direct_map_resource (struct device *dev,phys_addr_t paddr,size_t size,enum dma_data_direction dir,unsigned long attrs); +size_t dma_direct_max_mapping_size (struct device *dev);#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE ) || \ defined(CONFIG_SWIOTLB ) -void dma_direct_sync_single_for_device (struct device *dev, -dma_addr_t addr,size_t size,enum dma_data_direction dir); -void dma_direct_sync_sg_for_device (struct device *dev, -struct scatterlist *sgl,int nents,enum dma_data_direction dir); +void dma_direct_sync_sg_for_device (struct device *dev,struct scatterlist *sgl, +int nents,enum dma_data_direction dir);#else -static inline void dma_direct_sync_single_for_device (struct device *dev, -dma_addr_t addr,size_t size,enum dma_data_direction dir) -{ -}static inline void dma_direct_sync_sg_for_device (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction dir) {
@@ -114,34 +112,82 @@ static inline void dma_direct_sync_sg_for_device(struct device *dev,#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU ) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL ) || \ defined(CONFIG_SWIOTLB ) -void dma_direct_unmap_page (struct device *dev,dma_addr_t addr, -size_t size,enum dma_data_direction dir,unsigned long attrs);void dma_direct_unmap_sg (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction dir,unsigned long attrs); -void dma_direct_sync_single_for_cpu (struct device *dev, -dma_addr_t addr,size_t size,enum dma_data_direction dir);void dma_direct_sync_sg_for_cpu (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction dir);#else -static inline void dma_direct_unmap_page (struct device *dev,dma_addr_t addr, -size_t size,enum dma_data_direction dir,unsigned long attrs) -{ -}static inline void dma_direct_unmap_sg (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction dir,unsigned long attrs) { } +static inline void dma_direct_sync_sg_for_cpu (struct device *dev, +struct scatterlist *sgl,int nents,enum dma_data_direction dir) +{ +} +#endif + +static inline void dma_direct_sync_single_for_device (struct device *dev, +dma_addr_t addr,size_t size,enum dma_data_direction dir) +{ +phys_addr_t paddr =dma_to_phys (dev, addr); + +if (unlikely (is_swiotlb_buffer (paddr))) +swiotlb_tbl_sync_single (dev, paddr, size, dir,SYNC_FOR_DEVICE ); + +if (!dev_is_dma_coherent (dev)) +arch_sync_dma_for_device (paddr, size, dir); +} +static inline void dma_direct_sync_single_for_cpu (struct device *dev,dma_addr_t addr,size_t size,enum dma_data_direction dir) { +phys_addr_t paddr =dma_to_phys (dev, addr); + +if (!dev_is_dma_coherent (dev)) { +arch_sync_dma_for_cpu (paddr, size, dir); +arch_sync_dma_for_cpu_all (); + } + +if (unlikely (is_swiotlb_buffer (paddr))) +swiotlb_tbl_sync_single (dev, paddr, size, dir,SYNC_FOR_CPU ); } -static inline void dma_direct_sync_sg_for_cpu (struct device *dev, -struct scatterlist *sgl,int nents,enum dma_data_direction dir) + +static inline dma_addr_t dma_direct_map_page (struct device *dev, +struct page *page,unsigned long offset,size_t size, +enum dma_data_direction dir,unsigned long attrs) { +phys_addr_t phys =page_to_phys (page) + offset; +dma_addr_t dma_addr =phys_to_dma (dev, phys); + +if (unlikely (swiotlb_force ==SWIOTLB_FORCE )) +return swiotlb_map (dev, phys, size, dir, attrs); + +if (unlikely (!dma_capable (dev, dma_addr, size, true))) { +if (swiotlb_force !=SWIOTLB_NO_FORCE ) +return swiotlb_map (dev, phys, size, dir, attrs); + +dev_WARN_ONCE (dev,1 , +"DMA addr %pad+%zu overflow (mask %llx, bus limit %llx).\n" , + &dma_addr, size, *dev->dma_mask, dev->bus_dma_limit); +return DMA_MAPPING_ERROR ; + } + +if (!dev_is_dma_coherent (dev) && !(attrs &DMA_ATTR_SKIP_CPU_SYNC )) +arch_sync_dma_for_device (phys, size, dir); +return dma_addr; } -#endif -size_t dma_direct_max_mapping_size (struct device *dev); +static inline void dma_direct_unmap_page (struct device *dev,dma_addr_t addr, +size_t size,enum dma_data_direction dir,unsigned long attrs) +{ +phys_addr_t phys =dma_to_phys (dev, addr); +if (!(attrs &DMA_ATTR_SKIP_CPU_SYNC )) +dma_direct_sync_single_for_cpu (dev, addr, size, dir); + +if (unlikely (is_swiotlb_buffer (phys))) +swiotlb_tbl_unmap_single (dev, phys, size, size, dir, attrs); +}#endif /* _LINUX_DMA_DIRECT_H */
kernel/dma/direct.c +0 -65
98 lines not on this page · raw message
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH 3/5 dma-mapping: make support for dma ops optional
In reply to Christoph HellwigAvoid the overhead of the dma ops support for tiny builds that only use the direct mapping.
--- arch/alpha/Kconfig | 1 + arch/arm/Kconfig | 1 + arch/ia64/Kconfig | 1 + arch/mips/Kconfig | 1 + arch/parisc/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/x86/Kconfig | 1 + drivers/iommu/Kconfig | 2 ++ drivers/misc/mic/Kconfig | 1 + drivers/vdpa/Kconfig | 1 + drivers/xen/Kconfig | 1 + include/linux/device.h | 3 ++- include/linux/dma-mapping.h | 12 +++++++++++- kernel/dma/Kconfig | 4 ++++ kernel/dma/Makefile | 3 ++- 17 files changed, 33 insertions(+), 3 deletions(-)
arch/alpha/Kconfig +1 -0
@@ -7,6 +7,7 @@ config ALPHA select ARCH_NO_PREEMPT select ARCH_NO_SG_CHAIN select ARCH_USE_CMPXCHG_LOCKREF + select DMA_OPS if PCI select FORCE_PCI if !ALPHA_JENSEN select PCI_DOMAINS if PCI select PCI_SYSCALL if PCI
arch/arm/Kconfig +1 -0
@@ -41,6 +41,7 @@ config ARM select CPU_PM if SUSPEND || CPU_IDLE select DCACHE_WORD_ACCESS if HAVE_EFFICIENT_UNALIGNED_ACCESS select DMA_DECLARE_COHERENT + select DMA_OPS select DMA_REMAP if MMU select EDAC_SUPPORT select EDAC_ATOMIC_SCRUB
arch/ia64/Kconfig +1 -0
@@ -192,6 +192,7 @@ config IA64_SGI_UV config IA64_HP_SBA_IOMMU bool "HP SBA IOMMU support" + select DMA_OPS default y help Say Y here to add support for the SBA IOMMU found on HP zx1 and
arch/mips/Kconfig +1 -0
@@ -367,6 +367,7 @@ config MACH_JAZZ select ARC_PROMLIB select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO + select DMA_OPS select FW_ARC select FW_ARC32 select ARCH_MAY_HAVE_PC_FDC
arch/parisc/Kconfig +1 -0
@@ -14,6 +14,7 @@ config PARISC select ARCH_HAS_UBSAN_SANITIZE_ALL select ARCH_NO_SG_CHAIN select ARCH_SUPPORTS_MEMORY_FAILURE + select DMA_OPS select RTC_CLASS select RTC_DRV_GENERIC select INIT_ALL_POSSIBLE
arch/powerpc/Kconfig +1 -0
@@ -151,6 +151,7 @@ config PPC select BUILDTIME_TABLE_SORT select CLONE_BACKWARDS select DCACHE_WORD_ACCESS if PPC64 && CPU_LITTLE_ENDIAN + select DMA_OPS if PPC64 select DYNAMIC_FTRACE if FUNCTION_TRACER select EDAC_ATOMIC_SCRUB select EDAC_SUPPORT
arch/s390/Kconfig +1 -0
@@ -113,6 +113,7 @@ config S390 select ARCH_WANT_IPC_PARSE_VERSION select BUILDTIME_TABLE_SORT select CLONE_BACKWARDS2 + select DMA_OPS if PCI select DYNAMIC_FTRACE if FUNCTION_TRACER select GENERIC_CLOCKEVENTS select GENERIC_CPU_AUTOPROBE
arch/sparc/Kconfig +1 -0
@@ -15,6 +15,7 @@ config SPARC default y select ARCH_MIGHT_HAVE_PC_PARPORT if SPARC64 && PCI select ARCH_MIGHT_HAVE_PC_SERIO + select DMA_OPS select OF select OF_PROMTREE select HAVE_ASM_MODVERSIONS
arch/x86/Kconfig +1 -0
@@ -909,6 +909,7 @@ config DMI config GART_IOMMU bool "Old AMD GART IOMMU support" + select DMA_OPS select IOMMU_HELPER select SWIOTLB depends on X86_64 && PCI && AMD_NB
drivers/iommu/Kconfig +2 -0
@@ -97,6 +97,7 @@ config OF_IOMMU # IOMMU-agnostic DMA-mapping layer config IOMMU_DMA bool + select DMA_OPS select IOMMU_API select IOMMU_IOVA select IRQ_MSI_IOMMU
@@ -183,6 +184,7 @@ config DMAR_TABLE config INTEL_IOMMU bool "Support for Intel IOMMU using DMA Remapping Devices" depends on PCI_MSI && ACPI && (X86 || IA64) + select DMA_OPS select IOMMU_API select IOMMU_IOVA select NEED_DMA_MAP_STATE
drivers/misc/mic/Kconfig +1 -0
@@ -49,6 +49,7 @@ config INTEL_MIC_HOST tristate "Intel MIC Host Driver" depends on 64BIT && PCI && X86 depends on INTEL_MIC_BUS && SCIF_BUS && MIC_COSM && VOP_BUS + select DMA_OPS help This enables Host Driver support for the Intel Many Integrated Core (MIC) family of PCIe form factor coprocessor devices that
drivers/vdpa/Kconfig +1 -0
@@ -11,6 +11,7 @@ if VDPA config VDPA_SIM tristate "vDPA device simulator" depends on RUNTIME_TESTING_MENU && HAS_DMA + select DMA_OPS select VHOST_RING default n help
drivers/xen/Kconfig +1 -0
@@ -179,6 +179,7 @@ config XEN_GRANT_DMA_ALLOC config SWIOTLB_XEN def_bool y + select DMA_OPS select SWIOTLB config XEN_PCIDEV_BACKEND
include/linux/device.h +2 -1
@@ -568,8 +568,9 @@ struct device {#ifdef CONFIG_GENERIC_MSI_IRQ struct list_head msi_list;#endif - +#ifdef CONFIG_DMA_OPS const struct dma_map_ops *dma_ops; +#endif u64 *dma_mask;/* dma mask (if dma'able device) */ u64 coherent_dma_mask;/* Like dma_mask, but for alloc_coherent mappings as
include/linux/dma-mapping.h +11 -1
@@ -191,6 +191,7 @@ static inline int dma_mmap_from_global_coherent(struct vm_area_struct *vma, #ifdef CONFIG_HAS_DMA #include <asm/dma-mapping.h> +#ifdef CONFIG_DMA_OPS static inline const struct dma_map_ops *get_dma_ops(struct device *dev) { if (dev->dma_ops)
@@ -203,7 +204,16 @@ static inline void set_dma_ops(struct device *dev, { dev->dma_ops = dma_ops; } - +#else /* CONFIG_DMA_OPS */ +static inline const struct dma_map_ops *get_dma_ops (struct device *dev) +{ +return NULL ; +} +static inline void set_dma_ops (struct device *dev, +const struct dma_map_ops *dma_ops) +{ +} +#endif /* CONFIG_DMA_OPS */ static inline int dma_mapping_error (struct device *dev,dma_addr_t dma_addr) {
kernel/dma/Kconfig +4 -0
@@ -5,6 +5,9 @@ config HAS_DMA depends on !NO_DMA default y +config DMA_OPS + bool + config NEED_SG_DMA_LENGTH bool
@@ -60,6 +63,7 @@ config DMA_NONCOHERENT_CACHE_SYNC config DMA_VIRT_OPS bool depends on HAS_DMA + select DMA_OPS config SWIOTLB bool
kernel/dma/Makefile +2 -1
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_HAS_DMA) += mapping.o direct.o dummy.o +obj-$(CONFIG_HAS_DMA) += mapping.o direct.o +obj-$(CONFIG_DMA_OPS) += dummy.o obj-$(CONFIG_DMA_CMA) += contiguous.o obj-$(CONFIG_DMA_DECLARE_COHERENT) += coherent.o obj-$(CONFIG_DMA_VIRT_OPS) += virt.o
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
kernel test robot
build botRe: [PATCH 3/5] dma-mapping: make support for dma ops optional
I love your patch! Yet something to improve:
Hi Christoph,
I love your patch! Yet something to improve:
[auto build test ERROR on next-20200707]
[cannot apply to powerpc/next hp-parisc/for-next s390/features sparc-next/master sparc/master tip/x86/core iommu/next char-misc/char-misc-testing linus/master ia64/next v5.8-rc4 v5.8-rc3 v5.8-rc2 v5.8-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Christoph-Hellwig/dma-mapping-move-the-remaining-DMA-API-calls-out-of-line/20200709-002621 base: 5b2a702f85b3285fcde0309aadacc13a36c70fc7 config: x86_64-randconfig-r004-20200709 (attached as .config) compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
>> drivers/misc/mic/bus/vop_bus.c:148:12: error: no member named 'dma_ops' in 'struct device'
vdev->dev.dma_ops = dma_ops;
~~~~~~~~~ ^
>> drivers/misc/mic/bus/vop_bus.c:150:27: warning: shift count >= width of type [-Wshift-count-overflow]
dma_set_mask(&vdev->dev, DMA_BIT_MASK(64));
^~~~~~~~~~~~~~~~
include/linux/dma-mapping.h:139:54: note: expanded from macro 'DMA_BIT_MASK'
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
^ ~~~1 warning and 1 error generated.
vim +148 drivers/misc/mic/bus/vop_bus.c
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 131
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 132 struct vop_device *
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 133 vop_register_device(struct device *pdev, int id,
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 134 const struct dma_map_ops *dma_ops,
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 135 struct vop_hw_ops *hw_ops, u8 dnode, struct mic_mw *aper,
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 136 struct dma_chan *chan)
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 137 {
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 138 int ret;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 139 struct vop_device *vdev;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 140
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 141 vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 142 if (!vdev)
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 143 return ERR_PTR(-ENOMEM);
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 144
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 145 vdev->dev.parent = pdev;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 146 vdev->id.device = id;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 147 vdev->id.vendor = VOP_DEV_ANY_ID;
5657933dbb6e25 Bart Van Assche 2017-01-20 @148 vdev->dev.dma_ops = dma_ops;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 149 vdev->dev.dma_mask = &vdev->dev.coherent_dma_mask;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 @150 dma_set_mask(&vdev->dev, DMA_BIT_MASK(64));
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 151 vdev->dev.release = vop_release_dev;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 152 vdev->hw_ops = hw_ops;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 153 vdev->dev.bus = &vop_bus;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 154 vdev->dnode = dnode;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 155 vdev->aper = aper;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 156 vdev->dma_ch = chan;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 157 vdev->index = dnode - 1;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 158 dev_set_name(&vdev->dev, "vop-dev%u", vdev->index);
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 159 /*
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 160 * device_register() causes the bus infrastructure to look for a
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 161 * matching driver.
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 162 */
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 163 ret = device_register(&vdev->dev);
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 164 if (ret)
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 165 goto free_vdev;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 166 return vdev;
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 167 free_vdev:
5fbe9f35dfcd83 Arvind Yadav 2018-03-12 168 put_device(&vdev->dev);
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 169 return ERR_PTR(ret);
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 170 }
a19ddd6fd260d6 Sudeep Dutt 2016-02-08 171 EXPORT_SYMBOL_GPL(vop_register_device);a19ddd6fd260d6 Sudeep Dutt 2016-02-08 172
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH 3/5] dma-mapping: make support for dma ops optional
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Avoid the overhead of the dma ops support for tiny builds that only use the direct mapping.
Signed-off-by Christoph Hellwig <[email protected]>
For ppc:pmac32_defconfig and other configurations, this patch results in:
Error log:drivers/macintosh/macio_asic.c: In function 'macio_add_one_device':drivers/macintosh/macio_asic.c:393:16: error: 'struct device' has no member named 'dma_ops'
393 | dev->ofdev.dev.dma_ops = chip->lbus.pdev->dev.dma_ops;
| ^drivers/macintosh/macio_asic.c:393:47: error: 'struct device' has no member named 'dma_ops'
393 | dev->ofdev.dev.dma_ops = chip->lbus.pdev->dev.dma_ops;
| ^
Bisect log attached.
Guenter
---
# bad: [aab7ee9f8ff0110bfcd594b33dc33748dc1baf46] Add linux-next specific files for 20200717
# good: [11ba468877bb23f28956a35e896356252d63c983] Linux 5.8-rc5
git bisect start 'HEAD' 'v5.8-rc5'
# bad: [4d55a7a1298d197755c1a0f4512f56917e938a83] Merge remote-tracking branch 'crypto/master'
git bisect bad 4d55a7a1298d197755c1a0f4512f56917e938a83
# bad: [49485850238eb3fc72aac951e47e33e367aafbab] Merge remote-tracking branch 'hid/for-next'
git bisect bad 49485850238eb3fc72aac951e47e33e367aafbab
# bad: [4406fe306759d700f2b2aa8adf890a7d7ef064ae] Merge remote-tracking branch 'tegra/for-next'
git bisect bad 4406fe306759d700f2b2aa8adf890a7d7ef064ae
# bad: [27f18f0e00ed1f15ee55d479216c874561b6b70a] Merge remote-tracking branch 'arm-soc/for-next' git bisect bad 27f18f0e00ed1f15ee55d479216c874561b6b70a
# good: [a23a793b03f465cf2222fa29e7f81d732a6f6fdf] Merge remote-tracking branch 'usb-chipidea-fixes/ci-for-usb-stable' git bisect good a23a793b03f465cf2222fa29e7f81d732a6f6fdf
# good: [05d94a2de41e8d9840d9749d553febdcf99cb0e5] Merge branch 'arm/drivers' into for-next
git bisect good 05d94a2de41e8d9840d9749d553febdcf99cb0e5
# good: [5fef5dc17f097794288acb098ccc80eb91142bf4] Merge branch 'for-next/mte' into for-next/core git bisect good 5fef5dc17f097794288acb098ccc80eb91142bf4
# good: [3c7f84b2248457030a903813e4af71d80141d663] Merge remote-tracking branch 'fpga-fixes/fixes' git bisect good 3c7f84b2248457030a903813e4af71d80141d663
# bad: [88ff79e455afa3ac90739da27e24f655a965e3cf] Merge remote-tracking branch 'dma-mapping/for-next' git bisect bad 88ff79e455afa3ac90739da27e24f655a965e3cf
# good: [7c4d50d4973b40c53ef6c592b41b0473127e6762] kbuild: do not export LDFLAGS_vmlinux
git bisect good 7c4d50d4973b40c53ef6c592b41b0473127e6762
# good: [c45db534668104ed5112ed371526db6096ac5742] Merge remote-tracking branch 'kbuild/for-next' git bisect good c45db534668104ed5112ed371526db6096ac5742
# bad: [249542813648f7a278895ad25674d3e147f49ad6] dma-mapping: make support for dma ops optional git bisect bad 249542813648f7a278895ad25674d3e147f49ad6
# good: [b4174173005972f8f6497883d08d87e0aba1b604] dma-mapping: inline the fast path dma-direct calls git bisect good b4174173005972f8f6497883d08d87e0aba1b604
# first bad commit: [249542813648f7a278895ad25674d3e147f49ad6] dma-mapping: make support for dma ops optional
Re: [PATCH 3/5] dma-mapping: make support for dma ops optional
Quoted 7 lines · Guenter Roeck
Quoted 4 lines · Christoph Hellwig
Avoid the overhead of the dma ops support for tiny builds that only use the direct mapping.
Signed-off-by Christoph Hellwig <[email protected]>For ppc:pmac32_defconfig and other configurations, this patch results in:
Fixed and force pushed.
PATCH 4/5 dma-mapping: add a dma_ops_bypass flag to struct device
In reply to Christoph HellwigSeveral IOMMU drivers have a bypass mode where they can use a direct mapping if the devices DMA mask is large enough. Add generic support to the core dma-mapping code to do that to switch those drivers to a common solution.
--- include/linux/device.h | 8 +++++ kernel/dma/Kconfig | 8 +++++ kernel/dma/mapping.c | 74 +++++++++++++++++++++++++++++------------- 3 files changed, 68 insertions(+), 22 deletions(-)
include/linux/device.h +8 -0
@@ -523,6 +523,11 @@ struct dev_links_info {* sync_state() callback. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. +* @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the +* streaming DMA operations (->map_* / ->unmap_* / ->sync_*), +* and optionall (if the coherent mask is large enough) also +* for dma allocations. This flag is managed by the dma ops +* instance from ->dma_supported. * * At the lowest level, every device in a Linux system is represented by an * instance of struct device. The device structure contains the information
@@ -623,6 +628,9 @@ struct device {defined (CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) bool dma_coherent:1;#endif +#ifdef CONFIG_DMA_OPS_BYPASS + bool dma_ops_bypass : 1; +#endif };static inline struct device *kobj_to_dev (struct kobject *kobj)
kernel/dma/Kconfig +8 -0
@@ -8,6 +8,14 @@ config HAS_DMA config DMA_OPS bool +# +# IOMMU drivers that can bypass the IOMMU code and optionally use the direct +# mapping fast path should select this option and set the dma_ops_bypass +# flag in struct device where applicable +# +config DMA_OPS_BYPASS + bool + config NEED_SG_DMA_LENGTH bool
kernel/dma/mapping.c +52 -22
201 lines not on this page · raw message
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 4/5] dma-mapping: add a dma_ops_bypass flag to struct device
Quoted 17 lines · Christoph Hellwig
Several IOMMU drivers have a bypass mode where they can use a direct mapping if the devices DMA mask is large enough. Add generic support to the core dma-mapping code to do that to switch those drivers to a common solution.
Signed-off-by Christoph Hellwig <[email protected]>--- include/linux/device.h | 8 +++++ kernel/dma/Kconfig | 8 +++++ kernel/dma/mapping.c | 74 +++++++++++++++++++++++++++++------------- 3 files changed, 68 insertions(+), 22 deletions(-)include/linux/device.h +0
-0
include/linux/device.h struct dev_links_info { · line 528
Quoted 6 lines
include/linux/device.h +3
-0@@ -523,6 +523,11 @@ struct dev_links_info {* sync_state() callback. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. +* @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the +* streaming DMA operations (->map_* / ->unmap_* / ->sync_*), +* and optionall (if the coherent mask is large enough) also
s/optionall/optional/g
Otherwise the series looks good and works well on powernv and pseries. Thanks,
Signature · 1 line
Alexey
Re: [PATCH 4/5] dma-mapping: add a dma_ops_bypass flag to struct device
Quoted 30 lines · Alexey Kardashevskiy
Quoted 17 lines · Christoph Hellwig
Several IOMMU drivers have a bypass mode where they can use a direct mapping if the devices DMA mask is large enough. Add generic support to the core dma-mapping code to do that to switch those drivers to a common solution.
Signed-off-by Christoph Hellwig <[email protected]>--- include/linux/device.h | 8 +++++ kernel/dma/Kconfig | 8 +++++ kernel/dma/mapping.c | 74 +++++++++++++++++++++++++++++------------- 3 files changed, 68 insertions(+), 22 deletions(-)include/linux/device.h +0
-0include/linux/device.h struct dev_links_info { · line 528
Quoted 6 lines
include/linux/device.h +3
-0@@ -523,6 +523,11 @@ struct dev_links_info {* sync_state() callback. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. +* @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the +* streaming DMA operations (->map_* / ->unmap_* / ->sync_*), +* and optionall (if the coherent mask is large enough) also s/optionall/optional/g
Quoted 2 lines
Otherwise the series looks good and works well on powernv and pseries. Thanks,
Can you give a formal ACK?
Re: [PATCH 4/5] dma-mapping: add a dma_ops_bypass flag to struct device
Quoted 31 lines · Christoph Hellwig
Quoted 30 lines · Alexey Kardashevskiy
Quoted 17 lines · Christoph Hellwig
Several IOMMU drivers have a bypass mode where they can use a direct mapping if the devices DMA mask is large enough. Add generic support to the core dma-mapping code to do that to switch those drivers to a common solution.
Signed-off-by Christoph Hellwig <[email protected]>--- include/linux/device.h | 8 +++++ kernel/dma/Kconfig | 8 +++++ kernel/dma/mapping.c | 74 +++++++++++++++++++++++++++++------------- 3 files changed, 68 insertions(+), 22 deletions(-)include/linux/device.h +0
-0include/linux/device.h struct dev_links_info { · line 528
Quoted 6 lines
include/linux/device.h +3
-0@@ -523,6 +523,11 @@ struct dev_links_info {* sync_state() callback. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. +* @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the +* streaming DMA operations (->map_* / ->unmap_* / ->sync_*), +* and optionall (if the coherent mask is large enough) also s/optionall/optional/g
Quoted 4 lines
Quoted 2 lines
Otherwise the series looks good and works well on powernv and pseries. Thanks,
Can you give a formal ACK?
It did never matter before but sure :)
or you want me to reply to individual patches? Thanks,
Signature · 1 line
Alexey
PATCH 5/5 powerpc: use the generic dma_ops_bypass mode
In reply to Christoph HellwigUse the DMA API bypass mechanism for direct window mappings. This uses common code and speed up the direct mapping case by avoiding indirect calls just when not using dma ops at all. It also fixes a problem where the sync_* methods were using the bypass check for DMA allocations, but those are part of the streaming ops.
Note that this patch loses the DMA_ATTR_WEAK_ORDERING override, which has never been well defined, as is only used by a few drivers, which IIRC never showed up in the typical Cell blade setups that are affected by the ordering workaround.
--- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/device.h | 5 -- arch/powerpc/kernel/dma-iommu.c | 90 ++++--------------------------- 3 files changed, 10 insertions(+), 86 deletions(-)
arch/powerpc/Kconfig +1 -0
@@ -152,6 +152,7 @@ config PPC select CLONE_BACKWARDS select DCACHE_WORD_ACCESS if PPC64 && CPU_LITTLE_ENDIAN select DMA_OPS if PPC64 + select DMA_OPS_BYPASS if PPC64 select DYNAMIC_FTRACE if FUNCTION_TRACER select EDAC_ATOMIC_SCRUB select EDAC_SUPPORT
arch/powerpc/include/asm/device.h +0 -5
@@ -18,11 +18,6 @@ struct iommu_table;* drivers/macintosh/macio_asic.c */ struct dev_archdata { -/* -* Set to %true if the dma_iommu_ops are requested to use a direct -* window instead of dynamically mapping memory. -*/ -bool iommu_bypass :1 ;/* * These two used to be a union. However, with the hybrid ops we need * both so here we store both a DMA offset for direct mappings and
arch/powerpc/kernel/dma-iommu.c +9 -81
169 lines not on this page · raw message
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 5/5] powerpc: use the generic dma_ops_bypass mode
Hello,
Quoted 11 lines · Christoph Hellwig
Use the DMA API bypass mechanism for direct window mappings. This uses common code and speed up the direct mapping case by avoiding indirect calls just when not using dma ops at all. It also fixes a problem where the sync_* methods were using the bypass check for DMA allocations, but those are part of the streaming ops.
Note that this patch loses the
DMA_ATTR_WEAK_ORDERINGoverride, which has never been well defined, as is only used by a few drivers, which IIRC never showed up in the typical Cell blade setups that are affected by the ordering workaround.
Quoted 7 lines
Fixes efd176a04bef ("powerpc/pseries/dma: Allow SWIOTLB")Signed-off-by Christoph Hellwig <[email protected]>--- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/device.h | 5 -- arch/powerpc/kernel/dma-iommu.c | 90 ++++--------------------------- 3 files changed, 10 insertions(+), 86 deletions(-)
I am seeing corruptions on a couple of POWER9 systems (boston) when stressed with IO. stress-ng gives some results but I have first seen it when compiling the kernel in a guest and this is still the best way to raise the issue.
These systems have of a SAS Adaptec controller :
0003:01:00.0 Serial Attached SCSI controller: Adaptec Series 8 12G SAS/PCIe 3 (rev 01)
When the failure occurs, the POWERPC EEH interrupt fires and dumps lowlevel PHB4 registers among which :
[ 2179.251069490,3] PHB#0003[0:3]: phbErrorStatus = 0000028000000000
[ 2179.251117476,3] PHB#0003[0:3]: phbFirstErrorStatus = 0000020000000000
The bits raised identify a PPC 'TCE' error, which means it is related to DMAs. See below for more details.
Reverting this patch "fixes" the issue but it is probably else where, in some other layers or in the aacraid driver. How should I proceed to get more information ?
Thanks,
C.
[ 2054.970339] EEH: Frozen PE#1fd on PHB#3 detected [ 2054.970375] EEH: PE location: UOPWR.BOS0019-Node0-Onboard SAS, PHB location: N/A
[ 2179.249415973,3] PHB#0003[0:3]: brdgCtl = 00000002
[ 2179.249515795,3] PHB#0003[0:3]: deviceStatus = 00060040
[ 2179.249596452,3] PHB#0003[0:3]: slotStatus = 00402000
[ 2179.249633728,3] PHB#0003[0:3]: linkStatus = a0830008
[ 2179.249674807,3] PHB#0003[0:3]: devCmdStatus = 00100107
[ 2179.249725974,3] PHB#0003[0:3]: devSecStatus = 00100107
[ 2179.249773550,3] PHB#0003[0:3]: rootErrorStatus = 00000000
[ 2179.249809823,3] PHB#0003[0:3]: corrErrorStatus = 00000000
[ 2179.249850439,3] PHB#0003[0:3]: uncorrErrorStatus = 00000000
[ 2179.249887411,3] PHB#0003[0:3]: devctl = 00000040
[ 2179.249928677,3] PHB#0003[0:3]: devStat = 00000006 [ 2179.249967150,3] PHB#0003[0:3]: tlpHdr1 = 00000000 [ 2179.250054987,3] PHB#0003[0:3]: tlpHdr2 = 00000000 [ 2179.250146600,3] PHB#0003[0:3]: tlpHdr3 = 00000000 [ 2179.250262780,3] PHB#0003[0:3]: tlpHdr4 = 00000000
[ 2179.250343101,3] PHB#0003[0:3]: sourceId = 00000000
[ 2179.250514264,3] PHB#0003[0:3]: nFir = 0000000000000000
[ 2179.250717971,3] PHB#0003[0:3]: nFirMask = 0030001c00000000
[ 2179.250791474,3] PHB#0003[0:3]: nFirWOF = 0000000000000000
[ 2179.250842054,3] PHB#0003[0:3]: phbPlssr = 0000001c00000000
[ 2179.250886003,3] PHB#0003[0:3]: phbCsr = 0000001c00000000
[ 2179.250929859,3] PHB#0003[0:3]: lemFir = 0000000100000080
[ 2179.250973720,3] PHB#0003[0:3]: lemErrorMask = 0000000000000000
[ 2179.251018622,3] PHB#0003[0:3]: lemWOF = 0000000000000080
[ 2179.251069490,3] PHB#0003[0:3]: phbErrorStatus = 0000028000000000
[ 2179.251117476,3] PHB#0003[0:3]: phbFirstErrorStatus = 0000020000000000
[ 2179.251162218,3] PHB#0003[0:3]: phbErrorLog0 = 2148000098000240
[ 2179.251206251,3] PHB#0003[0:3]: phbErrorLog1 = a008400000000000
[ 2179.251253096,3] PHB#0003[0:3]: phbTxeErrorStatus = 0000000000000000
[ 2179.265087656,3] PHB#0003[0:3]: phbTxeFirstErrorStatus = 0000000000000000
[ 2179.265142247,3] PHB#0003[0:3]: phbTxeErrorLog0 = 0000000000000000
[ 2179.265189734,3] PHB#0003[0:3]: phbTxeErrorLog1 = 0000000000000000
[ 2179.266335296,3] PHB#0003[0:3]: phbRxeArbErrorStatus = 0000000000000000
[ 2179.266380366,3] PHB#0003[0:3]: phbRxeArbFrstErrorStatus = 0000000000000000
[ 2179.266426523,3] PHB#0003[0:3]: phbRxeArbErrorLog0 = 0000000000000000
[ 2179.267537283,3] PHB#0003[0:3]: phbRxeArbErrorLog1 = 0000000000000000
[ 2179.267581708,3] PHB#0003[0:3]: phbRxeMrgErrorStatus = 0000000000000000
[ 2179.267628324,3] PHB#0003[0:3]: phbRxeMrgFrstErrorStatus = 0000000000000000
[ 2179.268748771,3] PHB#0003[0:3]: phbRxeMrgErrorLog0 = 0000000000000000
[ 2179.268794753,3] PHB#0003[0:3]: phbRxeMrgErrorLog1 = 0000000000000000
[ 2179.268841144,3] PHB#0003[0:3]: phbRxeTceErrorStatus = 6000000000000000
[ 2179.269945557,3] PHB#0003[0:3]: phbRxeTceFrstErrorStatus = 2000000000000000
[ 2179.269997896,3] PHB#0003[0:3]: phbRxeTceErrorLog0 = c0000000000001fd
[ 2179.270094740,3] PHB#0003[0:3]: phbRxeTceErrorLog1 = 0000000000000000
[ 2179.270144030,3] PHB#0003[0:3]: phbPblErrorStatus = 0000000000020000
[ 2179.281523166,3] PHB#0003[0:3]: phbPblFirstErrorStatus = 0000000000020000
[ 2179.281575378,3] PHB#0003[0:3]: phbPblErrorLog0 = 0000000000000000
[ 2179.281627897,3] PHB#0003[0:3]: phbPblErrorLog1 = 0000000000000000
[ 2179.282710177,3] PHB#0003[0:3]: phbPcieDlpErrorLog1 = 0000000000000000
[ 2179.282761495,3] PHB#0003[0:3]: phbPcieDlpErrorLog2 = 0000000000000000
[ 2179.282813999,3] PHB#0003[0:3]: phbPcieDlpErrorStatus = 0000000000000000
[ 2179.283926192,3] PHB#0003[0:3]: phbRegbErrorStatus = 0000004000000000
[ 2179.283978457,3] PHB#0003[0:3]: phbRegbFirstErrorStatus = 0000004000000000
[ 2179.284033525,3] PHB#0003[0:3]: phbRegbErrorLog0 = 8800005800000000
[ 2179.285123005,3] PHB#0003[0:3]: phbRegbErrorLog1 = 0000000007011000
[ 2179.285178505,3] PHB#0003[0:3]: PEST[1fd] = 8300b03800000000 8000000000000000
[ 2055.043233] EEH: Recovering PHB#3-PE#1fd [ 2055.043274] EEH: PE location: UOPWR.BOS0019-Node0-Onboard SAS, PHB location: N/A [ 2055.043423] aacraid 0003:01:00.0: aacraid: PCI error detected 2 [ 2055.099306] blk_update_request: I/O error, dev sda, sector 510949048 op 0x1:(WRITE) flags 0xc800 phys_seg 4 prio class 0
Re: [PATCH 5/5] powerpc: use the generic dma_ops_bypass mode
Quoted 37 lines · Cédric Le Goater
Hello,
Quoted 11 lines · Christoph Hellwig
Use the DMA API bypass mechanism for direct window mappings. This uses common code and speed up the direct mapping case by avoiding indirect calls just when not using dma ops at all. It also fixes a problem where the sync_* methods were using the bypass check for DMA allocations, but those are part of the streaming ops.
Note that this patch loses the
DMA_ATTR_WEAK_ORDERINGoverride, which has never been well defined, as is only used by a few drivers, which IIRC never showed up in the typical Cell blade setups that are affected by the ordering workaround.Quoted 7 lines
Fixes efd176a04bef ("powerpc/pseries/dma: Allow SWIOTLB")Signed-off-by Christoph Hellwig <[email protected]>--- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/device.h | 5 -- arch/powerpc/kernel/dma-iommu.c | 90 ++++--------------------------- 3 files changed, 10 insertions(+), 86 deletions(-)I am seeing corruptions on a couple of POWER9 systems (boston) when stressed with IO. stress-ng gives some results but I have first seen it when compiling the kernel in a guest and this is still the best way to raise the issue.
These systems have of a SAS Adaptec controller :
0003:01:00.0 Serial Attached SCSI controller: Adaptec Series 8 12G SAS/PCIe 3 (rev 01)
When the failure occurs, the POWERPC EEH interrupt fires and dumps lowlevel PHB4 registers among which :
[ 2179.251069490,3] PHB#0003[0:3]: phbErrorStatus = 0000028000000000
[ 2179.251117476,3] PHB#0003[0:3]: phbFirstErrorStatus = 0000020000000000
Quoted 7 lines
The bits raised identify a PPC 'TCE' error, which means it is related to DMAs. See below for more details.
Reverting this patch "fixes" the issue but it is probably else where, in some other layers or in the aacraid driver. How should I proceed to get more information ?
The aacraid DMA masks look like a mess. Can you try the hack below and see it it helps?
drivers/scsi/aacraid/aachba.c +0 -12
@@ -2228,18 +2228,6 @@ int aac_get_adapter_info(struct aac_dev* dev) expose_physicals =0 ; } -if (dev->dac_support) { -if (!pci_set_dma_mask (dev->pdev,DMA_BIT_MASK (64 ))) { -if (!dev->in_reset) -dev_info (&dev->pdev->dev,"64 Bit DAC enabled\n" ); - }else if (!pci_set_dma_mask (dev->pdev,DMA_BIT_MASK (32 ))) { -dev_info (&dev->pdev->dev,"DMA mask set failed, 64 Bit DAC disabled\n" ); - dev->dac_support =0 ; - }else { -dev_info (&dev->pdev->dev,"No suitable DMA available\n" ); - rcode = -ENOMEM ; - } - }/* * Deal with configuring for the individualized limits of each packet * interface.
drivers/scsi/aacraid/commsup.c +0 -16
@@ -1479,7 +1479,6 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type)struct Scsi_Host *host = aac->scsi_host_ptr;int jafo =0 ;int bled; -u64 dmamask;int num_of_fibs =0 ;/*
@@ -1558,22 +1557,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type)kfree (aac->fsa_dev); aac->fsa_dev =NULL ; - dmamask =DMA_BIT_MASK (32 ); quirks =aac_get_driver_ident (index)->quirks; -if (quirks &AAC_QUIRK_31BIT ) - retval =pci_set_dma_mask (aac->pdev, dmamask); -else if (!(quirks &AAC_QUIRK_SRC )) - retval =pci_set_dma_mask (aac->pdev, dmamask); -else - retval =pci_set_consistent_dma_mask (aac->pdev, dmamask); - -if (quirks &AAC_QUIRK_31BIT && !retval) { - dmamask =DMA_BIT_MASK (31 ); - retval =pci_set_consistent_dma_mask (aac->pdev, dmamask); - } - -if (retval) - goto out;if ((retval = (*(aac_get_driver_ident (index)->init))(aac))) goto out;
drivers/scsi/aacraid/linit.c +0 -29
@@ -1634,8 +1634,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)struct list_head *insert = &aac_devices;int error;int unique_id =0 ; -u64 dmamask; -int mask_bits =0 ;extern int aac_sync_mode;/*
@@ -1658,33 +1656,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)if (error) goto out; -if (!(aac_drivers[index].quirks &AAC_QUIRK_SRC )) { - error =pci_set_dma_mask (pdev,DMA_BIT_MASK (32 )); -if (error) { -dev_err (&pdev->dev,"PCI 32 BIT dma mask set failed" ); - goto out_disable_pdev; - } - } - -/* -* If the quirk31 bit is set, the adapter needs adapter -* to driver communication memory to be allocated below 2gig -*/ -if (aac_drivers[index].quirks &AAC_QUIRK_31BIT ) { - dmamask =DMA_BIT_MASK (31 ); - mask_bits =31 ; - }else { - dmamask =DMA_BIT_MASK (32 ); - mask_bits =32 ; - } - - error =pci_set_consistent_dma_mask (pdev, dmamask); -if (error) { -dev_err (&pdev->dev,"PCI %d B consistent dma mask set failed\n" - , mask_bits); - goto out_disable_pdev; - } -pci_set_master (pdev); shost =scsi_host_alloc (&aac_driver_template,sizeof (struct aac_dev ));
Re: [PATCH 5/5] powerpc: use the generic dma_ops_bypass mode
Quoted 42 lines · Christoph Hellwig
Quoted 41 lines · Cédric Le Goater
Hello,
Quoted 11 lines · Christoph Hellwig
Use the DMA API bypass mechanism for direct window mappings. This uses common code and speed up the direct mapping case by avoiding indirect calls just when not using dma ops at all. It also fixes a problem where the sync_* methods were using the bypass check for DMA allocations, but those are part of the streaming ops.
Note that this patch loses the
DMA_ATTR_WEAK_ORDERINGoverride, which has never been well defined, as is only used by a few drivers, which IIRC never showed up in the typical Cell blade setups that are affected by the ordering workaround.Quoted 7 lines
Fixes efd176a04bef ("powerpc/pseries/dma: Allow SWIOTLB")Signed-off-by Christoph Hellwig <[email protected]>--- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/device.h | 5 -- arch/powerpc/kernel/dma-iommu.c | 90 ++++--------------------------- 3 files changed, 10 insertions(+), 86 deletions(-)I am seeing corruptions on a couple of POWER9 systems (boston) when stressed with IO. stress-ng gives some results but I have first seen it when compiling the kernel in a guest and this is still the best way to raise the issue.
These systems have of a SAS Adaptec controller :
0003:01:00.0 Serial Attached SCSI controller: Adaptec Series 8 12G SAS/PCIe 3 (rev 01)
When the failure occurs, the POWERPC EEH interrupt fires and dumps lowlevel PHB4 registers among which :
[ 2179.251069490,3] PHB#0003[0:3]: phbErrorStatus = 0000028000000000
[ 2179.251117476,3] PHB#0003[0:3]: phbFirstErrorStatus = 0000020000000000The bits raised identify a PPC 'TCE' error, which means it is related to DMAs. See below for more details.
Quoted 6 lines
Quoted 3 lines
Reverting this patch "fixes" the issue but it is probably else where, in some other layers or in the aacraid driver. How should I proceed to get more information ?
The aacraid DMA masks look like a mess. Can you try the hack below and see it it helps?
No effect. The system crashes the same. But Alexey spotted some issue with swiotlb.
C.
Re: [PATCH 5/5] powerpc: use the generic dma_ops_bypass mode
In reply to Christoph HellwigQuoted 42 lines · Christoph Hellwig
Quoted 41 lines · Cédric Le Goater
Hello,
Quoted 11 lines · Christoph Hellwig
Use the DMA API bypass mechanism for direct window mappings. This uses common code and speed up the direct mapping case by avoiding indirect calls just when not using dma ops at all. It also fixes a problem where the sync_* methods were using the bypass check for DMA allocations, but those are part of the streaming ops.
Note that this patch loses the
DMA_ATTR_WEAK_ORDERINGoverride, which has never been well defined, as is only used by a few drivers, which IIRC never showed up in the typical Cell blade setups that are affected by the ordering workaround.Quoted 7 lines
Fixes efd176a04bef ("powerpc/pseries/dma: Allow SWIOTLB")Signed-off-by Christoph Hellwig <[email protected]>--- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/device.h | 5 -- arch/powerpc/kernel/dma-iommu.c | 90 ++++--------------------------- 3 files changed, 10 insertions(+), 86 deletions(-)I am seeing corruptions on a couple of POWER9 systems (boston) when stressed with IO. stress-ng gives some results but I have first seen it when compiling the kernel in a guest and this is still the best way to raise the issue.
These systems have of a SAS Adaptec controller :
0003:01:00.0 Serial Attached SCSI controller: Adaptec Series 8 12G SAS/PCIe 3 (rev 01)When the failure occurs, the POWERPC EEH interrupt fires and dumps lowlevel PHB4 registers among which :
[ 2179.251069490,3] PHB#0003[0:3]: phbErrorStatus = 0000028000000000 [ 2179.251117476,3] PHB#0003[0:3]: phbFirstErrorStatus = 0000020000000000The bits raised identify a PPC 'TCE' error, which means it is related to DMAs. See below for more details.
Quoted 5 lines
Quoted 3 lines
Reverting this patch "fixes" the issue but it is probably else where, in some other layers or in the aacraid driver. How should I proceed to get more information ?
The aacraid DMA masks look like a mess.
It kinds does and is. The thing is that after f1565c24b596 the driver sets 32 bit DMA mask which in turn enables the small DMA window (not bypass) and since the aacraid driver has at least one bug with double unmap of the same DMA handle, this somehow leads to EEH (PCI DMA error).
The driver sets 32but mask because it callis dma_get_required_mask() _before_ setting the mask so dma_get_required_mask() does not go the dma_alloc_direct() path and calls the powerpc's dma_iommu_get_required_mask() which:
1. does the math like this (spot 2 bugs):
mask = 1ULL < (fls_long(tbl->it_offset + tbl->it_size) - 1)
2. but even after fixing that, the driver crashes as f1565c24b596 removed the call to dma_iommu_bypass_supported() so it enforces IOMMU.
The patch below (the first hunk to be precise) brings the things back to where they were (64bit mask). The double unmap bug in the driver is still to be investigated.
arch/powerpc/kernel/dma-iommu.c +9 -1
@@ -117,10 +117,18 @@ u64 dma_iommu_get_required_mask(struct device *dev)struct iommu_table *tbl =get_iommu_table_base (dev);u64 mask; +if (dev_is_pci (dev)) { +u64 bypass_mask =dma_direct_get_required_mask (dev); + +if (dma_iommu_bypass_supported (dev, bypass_mask)) +return bypass_mask; + } +if (!tbl)return 0 ; - mask =1ULL < (fls_long (tbl->it_offset + tbl->it_size) -1 ); + mask =1ULL << (fls_long (tbl->it_offset + tbl->it_size) + + tbl->it_page_shift -1 ); mask += mask -1 ;return mask;
Signature · 1 line
Alexey
Quoted 8 lines · On Wed, 8 Jul 2020 17:24:44 +0200 Christoph Hellwig <[email protected]> wrote:
Note that as-is this breaks the XSK buffer pool, which unfortunately poked directly into DMA internals. A fix for that is already queued up in the netdev tree.
Jesper and XDP gang: this should not regress any performance as the dma-direct calls are now inlined into the out of line DMA mapping calls. But if you can verify the performance numbers that would be greatly appreciated.
From a superficial review of the patches, they look okay to me. I don't have time to run a performance benchmark (before I go on vacation).
I hoped Björn could test/benchmark this(?), given (as mentioned) this also affect XSK / AF_XDP performance.
Signature · 4 lines
Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer