Re: [PATCH] dma-debug: Check scatterlist segments
This looks interesting. I suspect it is going to blow up in quite a few places, so maybe at least for now it might make sense to have a separate config option? On Tue, Apr 24, 2018 at 05:12:19PM +0100, Robin Murphy wrote: > Drivers/subsystems creating scatterlists for DMA should be taking care > to respect the scatter-gather limitations of the appropriate device, as > described by dma_parms. A DMA API implementation cannot feasibly split > a scatterlist into *more* entries than originally passed, so it is not > well defined what they should do when given a segment larger than the > limit they are also required to respect. > > Conversely, devices which are less limited than the rather conservative > defaults, or indeed have no limitations at all (e.g. GPUs with their own > internal MMU), should be encouraged to set appropriate dma_parms, as > they may get more efficient DMA mapping performance out of it. > > Signed-off-by: Robin Murphy> --- > lib/dma-debug.c | 26 ++ > 1 file changed, 26 insertions(+) > > diff --git a/lib/dma-debug.c b/lib/dma-debug.c > index 7f5cdc1e6b29..9f158941004d 100644 > --- a/lib/dma-debug.c > +++ b/lib/dma-debug.c > @@ -1293,6 +1293,30 @@ static void check_sync(struct device *dev, > put_hash_bucket(bucket, ); > } > > +static void check_sg_segment(struct device *dev, struct scatterlist *sg) > +{ > + unsigned int max_seg = dma_get_max_seg_size(dev); > + dma_addr_t start, end, boundary = dma_get_seg_boundary(dev); > + > + /* > + * Either the driver forgot to set dma_parms appropriately, or > + * whoever generated the list forgot to check them. > + */ > + if (sg->length > max_seg) > + err_printk(dev, NULL, "DMA-API: mapping sg segment longer than > device claims to support [len=%u] [max=%u]\n", > +sg->length, max_seg); > + /* > + * In some cases this could potentially be the DMA API > + * implementation's fault, but it would usually imply that > + * the scatterlist was built inappropriately to begin with. > + */ > + start = sg_dma_address(sg); > + end = start + sg_dma_len(sg) - 1; > + if ((start ^ end) & ~boundary) > + err_printk(dev, NULL, "DMA-API: mapping sg segment across > boundary [start=0x%016llx] [end=0x%016llx] [boundary=0x%016llx]\n", > +start, end, boundary); > +} > + > void debug_dma_map_page(struct device *dev, struct page *page, size_t offset, > size_t size, int direction, dma_addr_t dma_addr, > bool map_single) > @@ -1423,6 +1447,8 @@ void debug_dma_map_sg(struct device *dev, struct > scatterlist *sg, > check_for_illegal_area(dev, sg_virt(s), sg_dma_len(s)); > } > > + check_sg_segment(dev, s); > + > add_dma_entry(entry); > } > } > -- > 2.17.0.dirty ---end quoted text--- ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[GIT PULL] dma mapping fixes for 4.17-rc3
The following changes since commit 6d08b06e67cd117f6992c46611dfb4ce267cd71e: Linux 4.17-rc2 (2018-04-22 19:20:09 -0700) are available in the Git repository at: git://git.infradead.org/users/hch/dma-mapping.git tags/dma-mapping-4.17-3 for you to fetch changes up to 60695be2bb6b0623f8e53bd9949d582a83c6d44a: dma-mapping: postpone cpu addr translation on mmap (2018-04-23 14:44:24 +0200) A few small dma-mapping fixes for Linux 4.17-rc3: - don't loop to try GFP_DMA allocations if ZONE_DMA is not actually enabled (regression in 4.16) - don't try to do virt_to_page before we know we actuall have a valid page in dma_common_mmap - a comment fixup related to the above fix Jacopo Mondi (1): dma-mapping: postpone cpu addr translation on mmap Robin Murphy (1): dma-coherent: clarify dma_mmap_from_dev_coherent documentation Takashi Iwai (1): dma-direct: don't retry allocation for no-op GFP_DMA drivers/base/dma-coherent.c | 5 +++-- drivers/base/dma-mapping.c | 6 ++ lib/dma-direct.c| 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 11/13] mips,unicore32: swiotlb doesn't need sg->dma_length
Only mips and unicore32 select CONFIG_NEED_SG_DMA_LENGTH when building swiotlb. swiotlb itself never merges segements and doesn't accesses the dma_length field directly, so drop the dependency. Signed-off-by: Christoph Hellwig--- arch/mips/cavium-octeon/Kconfig | 1 - arch/mips/loongson64/Kconfig| 1 - arch/unicore32/mm/Kconfig | 1 - 3 files changed, 3 deletions(-) diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig index 5d73041547a7..eb5faeed4f66 100644 --- a/arch/mips/cavium-octeon/Kconfig +++ b/arch/mips/cavium-octeon/Kconfig @@ -70,7 +70,6 @@ config CAVIUM_OCTEON_LOCK_L2_MEMCPY config SWIOTLB def_bool y select DMA_DIRECT_OPS - select NEED_SG_DMA_LENGTH config OCTEON_ILM tristate "Module to measure interrupt latency using Octeon CIU Timer" diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig index 641a1477031e..2a4fb91adbb6 100644 --- a/arch/mips/loongson64/Kconfig +++ b/arch/mips/loongson64/Kconfig @@ -135,7 +135,6 @@ config SWIOTLB default y depends on CPU_LOONGSON3 select DMA_DIRECT_OPS - select NEED_SG_DMA_LENGTH select NEED_DMA_MAP_STATE config PHYS48_TO_HT40 diff --git a/arch/unicore32/mm/Kconfig b/arch/unicore32/mm/Kconfig index 1d9fed0ada71..45b7f769375e 100644 --- a/arch/unicore32/mm/Kconfig +++ b/arch/unicore32/mm/Kconfig @@ -43,4 +43,3 @@ config CPU_TLB_SINGLE_ENTRY_DISABLE config SWIOTLB def_bool y select DMA_DIRECT_OPS - select NEED_SG_DMA_LENGTH -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 12/13] swiotlb: move the SWIOTLB config symbol to lib/Kconfig
This way we have one central definition of it, and user can select it as needed. The new option is not user visible, which is the behavior it had in most architectures, with a few notable exceptions: - On x86_64 and mips/loongson3 it used to be user selectable, but defaulted to y. It now is unconditional, which seems like the right thing for 64-bit architectures without guaranteed availablity of IOMMUs. - on powerpc the symbol is user selectable and defaults to n, but many boards select it. This change assumes no working setup required a manual selection, but if that turned out to be wrong we'll have to add another select statement or two for the respective boards. Signed-off-by: Christoph Hellwig--- arch/arm/Kconfig| 3 --- arch/arm64/Kconfig | 4 +--- arch/ia64/Kconfig | 8 arch/mips/Kconfig | 2 ++ arch/mips/cavium-octeon/Kconfig | 4 arch/mips/loongson64/Kconfig| 7 --- arch/powerpc/Kconfig| 9 - arch/unicore32/Kconfig | 1 + arch/unicore32/mm/Kconfig | 4 arch/x86/Kconfig| 12 +--- lib/Kconfig | 5 + 11 files changed, 10 insertions(+), 49 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 90b81a3a28a7..676977bdfe33 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1773,9 +1773,6 @@ config SECCOMP and the task is only allowed to execute a few safe syscalls defined by each seccomp mode. -config SWIOTLB - bool - config PARAVIRT bool "Enable paravirtualization code" help diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 4d924eb32e7f..db51b6445744 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -144,6 +144,7 @@ config ARM64 select POWER_SUPPLY select REFCOUNT_FULL select SPARSE_IRQ + select SWIOTLB select SYSCTL_EXCEPTION_TRACE select THREAD_INFO_IN_TASK help @@ -239,9 +240,6 @@ config HAVE_GENERIC_GUP config SMP def_bool y -config SWIOTLB - def_bool y - config KERNEL_MODE_NEON def_bool y diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 685d557eea48..9485b5490eca 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -80,9 +80,6 @@ config MMU bool default y -config SWIOTLB - bool - config STACKTRACE_SUPPORT def_bool y @@ -139,7 +136,6 @@ config IA64_GENERIC bool "generic" select NUMA select ACPI_NUMA - select DMA_DIRECT_OPS select SWIOTLB select PCI_MSI help @@ -160,7 +156,6 @@ config IA64_GENERIC config IA64_DIG bool "DIG-compliant" - select DMA_DIRECT_OPS select SWIOTLB config IA64_DIG_VTD @@ -176,7 +171,6 @@ config IA64_HP_ZX1 config IA64_HP_ZX1_SWIOTLB bool "HP-zx1/sx1000 with software I/O TLB" - select DMA_DIRECT_OPS select SWIOTLB help Build a kernel that runs on HP zx1 and sx1000 systems even when they @@ -200,7 +194,6 @@ config IA64_SGI_UV bool "SGI-UV" select NUMA select ACPI_NUMA - select DMA_DIRECT_OPS select SWIOTLB help Selecting this option will optimize the kernel for use on UV based @@ -211,7 +204,6 @@ config IA64_SGI_UV config IA64_HP_SIM bool "Ski-simulator" - select DMA_DIRECT_OPS select SWIOTLB depends on !PM diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index e10cc5c7be69..0f619b8c0e9e 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -912,6 +912,7 @@ config CAVIUM_OCTEON_SOC select MIPS_NR_CPU_NR_MAP_1024 select BUILTIN_DTB select MTD_COMPLEX_MAPPINGS + select SWIOTLB select SYS_SUPPORTS_RELOCATABLE help This option supports all of the Octeon reference boards from Cavium @@ -1367,6 +1368,7 @@ config CPU_LOONGSON3 select MIPS_PGD_C0_CONTEXT select MIPS_L1_CACHE_SHIFT_6 select GPIOLIB + select SWIOTLB help The Loongson 3 processor implements the MIPS64R2 instruction set with many extensions. diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig index eb5faeed4f66..4984e462be30 100644 --- a/arch/mips/cavium-octeon/Kconfig +++ b/arch/mips/cavium-octeon/Kconfig @@ -67,10 +67,6 @@ config CAVIUM_OCTEON_LOCK_L2_MEMCPY help Lock the kernel's implementation of memcpy() into L2. -config SWIOTLB - def_bool y - select DMA_DIRECT_OPS - config OCTEON_ILM tristate "Module to measure interrupt latency using Octeon CIU Timer" help diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig index 2a4fb91adbb6..c79e6a565572 100644 --- a/arch/mips/loongson64/Kconfig +++ b/arch/mips/loongson64/Kconfig @@ -130,13 +130,6 @@ config
[PATCH 05/13] scatterlist: move the NEED_SG_DMA_LENGTH config symbol to lib/Kconfig
This way we have one central definition of it, and user can select it as needed. Signed-off-by: Christoph HellwigReviewed-by: Anshuman Khandual --- arch/alpha/Kconfig | 4 +--- arch/arm/Kconfig| 3 --- arch/arm64/Kconfig | 4 +--- arch/hexagon/Kconfig| 4 +--- arch/ia64/Kconfig | 4 +--- arch/mips/cavium-octeon/Kconfig | 3 --- arch/mips/loongson64/Kconfig| 3 --- arch/mips/netlogic/Kconfig | 3 --- arch/parisc/Kconfig | 4 +--- arch/powerpc/Kconfig| 4 +--- arch/s390/Kconfig | 4 +--- arch/sh/Kconfig | 5 ++--- arch/sparc/Kconfig | 4 +--- arch/unicore32/mm/Kconfig | 5 + arch/x86/Kconfig| 4 +--- lib/Kconfig | 3 +++ 16 files changed, 15 insertions(+), 46 deletions(-) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 3ff735a722af..8e6a67ecf069 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -10,6 +10,7 @@ config ALPHA select HAVE_OPROFILE select HAVE_PCSPKR_PLATFORM select HAVE_PERF_EVENTS + select NEED_SG_DMA_LENGTH select VIRT_TO_BUS select GENERIC_IRQ_PROBE select AUTO_IRQ_AFFINITY if SMP @@ -70,9 +71,6 @@ config ARCH_DMA_ADDR_T_64BIT config NEED_DMA_MAP_STATE def_bool y -config NEED_SG_DMA_LENGTH - def_bool y - config GENERIC_ISA_DMA bool default y diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2f79222c5c02..602c8320282f 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -119,9 +119,6 @@ config ARM_HAS_SG_CHAIN select ARCH_HAS_SG_CHAIN bool -config NEED_SG_DMA_LENGTH - bool - config ARM_DMA_USE_IOMMU bool select ARM_HAS_SG_CHAIN diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index fbef5d3de83f..3b441c5587f1 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -133,6 +133,7 @@ config ARM64 select IRQ_FORCED_THREADING select MODULES_USE_ELF_RELA select MULTI_IRQ_HANDLER + select NEED_SG_DMA_LENGTH select NO_BOOTMEM select OF select OF_EARLY_FLATTREE @@ -243,9 +244,6 @@ config ARCH_DMA_ADDR_T_64BIT config NEED_DMA_MAP_STATE def_bool y -config NEED_SG_DMA_LENGTH - def_bool y - config SMP def_bool y diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 76d2f20d525e..37adb2003033 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -19,6 +19,7 @@ config HEXAGON select GENERIC_IRQ_SHOW select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK + select NEED_SG_DMA_LENGTH select NO_IOPORT_MAP select GENERIC_IOMAP select GENERIC_SMP_IDLE_THREAD @@ -63,9 +64,6 @@ config GENERIC_CSUM config GENERIC_IRQ_PROBE def_bool y -config NEED_SG_DMA_LENGTH - def_bool y - config RWSEM_GENERIC_SPINLOCK def_bool n diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 862c5160c09d..333917676f7f 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -54,6 +54,7 @@ config IA64 select MODULES_USE_ELF_RELA select ARCH_USE_CMPXCHG_LOCKREF select HAVE_ARCH_AUDITSYSCALL + select NEED_SG_DMA_LENGTH default y help The Itanium Processor Family is Intel's 64-bit successor to @@ -84,9 +85,6 @@ config ARCH_DMA_ADDR_T_64BIT config NEED_DMA_MAP_STATE def_bool y -config NEED_SG_DMA_LENGTH - def_bool y - config SWIOTLB bool diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig index 647ed158ac98..5d73041547a7 100644 --- a/arch/mips/cavium-octeon/Kconfig +++ b/arch/mips/cavium-octeon/Kconfig @@ -67,9 +67,6 @@ config CAVIUM_OCTEON_LOCK_L2_MEMCPY help Lock the kernel's implementation of memcpy() into L2. -config NEED_SG_DMA_LENGTH - bool - config SWIOTLB def_bool y select DMA_DIRECT_OPS diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig index 5efb2e63878e..641a1477031e 100644 --- a/arch/mips/loongson64/Kconfig +++ b/arch/mips/loongson64/Kconfig @@ -130,9 +130,6 @@ config LOONGSON_UART_BASE default y depends on EARLY_PRINTK || SERIAL_8250 -config NEED_SG_DMA_LENGTH - bool - config SWIOTLB bool "Soft IOMMU Support for All-Memory DMA" default y diff --git a/arch/mips/netlogic/Kconfig b/arch/mips/netlogic/Kconfig index 5c5ee0e05a17..412351c5acc6 100644 --- a/arch/mips/netlogic/Kconfig +++ b/arch/mips/netlogic/Kconfig @@ -83,7 +83,4 @@ endif config NLM_COMMON bool -config NEED_SG_DMA_LENGTH - bool - endif diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index fc5a574c3482..89caea87556e 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -51,6 +51,7 @@ config PARISC select GENERIC_CLOCKEVENTS select
[PATCH 07/13] arch: remove the ARCH_PHYS_ADDR_T_64BIT config symbol
Instead select the PHYS_ADDR_T_64BIT for 32-bit architectures that need a 64-bit phys_addr_t type directly. Signed-off-by: Christoph Hellwig--- arch/arc/Kconfig | 4 +--- arch/arm/kernel/setup.c| 2 +- arch/arm/mm/Kconfig| 4 +--- arch/arm64/Kconfig | 3 --- arch/mips/Kconfig | 15 ++- arch/powerpc/Kconfig | 5 + arch/powerpc/platforms/Kconfig.cputype | 1 + arch/riscv/Kconfig | 6 ++ arch/x86/Kconfig | 5 + mm/Kconfig | 2 +- 10 files changed, 15 insertions(+), 32 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index d76bf4a83740..f94c61da682a 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -453,13 +453,11 @@ config ARC_HAS_PAE40 default n depends on ISA_ARCV2 select HIGHMEM + select PHYS_ADDR_T_64BIT help Enable access to physical memory beyond 4G, only supported on ARC cores with 40 bit Physical Addressing support -config ARCH_PHYS_ADDR_T_64BIT - def_bool ARC_HAS_PAE40 - config ARCH_DMA_ADDR_T_64BIT bool diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index fc40a2b40595..35ca494c028c 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -754,7 +754,7 @@ int __init arm_add_memory(u64 start, u64 size) else size -= aligned_start - start; -#ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT +#ifndef CONFIG_PHYS_ADDR_T_64BIT if (aligned_start > ULONG_MAX) { pr_crit("Ignoring memory at 0x%08llx outside 32-bit physical address space\n", (long long)start); diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig index 7f14acf67caf..2f77c6344ef1 100644 --- a/arch/arm/mm/Kconfig +++ b/arch/arm/mm/Kconfig @@ -661,6 +661,7 @@ config ARM_LPAE bool "Support for the Large Physical Address Extension" depends on MMU && CPU_32v7 && !CPU_32v6 && !CPU_32v5 && \ !CPU_32v4 && !CPU_32v3 + select PHYS_ADDR_T_64BIT help Say Y if you have an ARMv7 processor supporting the LPAE page table format and you would like to access memory beyond the @@ -673,9 +674,6 @@ config ARM_PV_FIXUP def_bool y depends on ARM_LPAE && ARM_PATCH_PHYS_VIRT && ARCH_KEYSTONE -config ARCH_PHYS_ADDR_T_64BIT - def_bool ARM_LPAE - config ARCH_DMA_ADDR_T_64BIT bool diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 940adfb9a2bc..b6aa33e642cc 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -152,9 +152,6 @@ config ARM64 config 64BIT def_bool y -config ARCH_PHYS_ADDR_T_64BIT - def_bool y - config MMU def_bool y diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 47d72c64d687..985388078872 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -132,7 +132,7 @@ config MIPS_GENERIC config MIPS_ALCHEMY bool "Alchemy processor based machines" - select ARCH_PHYS_ADDR_T_64BIT + select PHYS_ADDR_T_64BIT select CEVT_R4K select CSRC_R4K select IRQ_MIPS_CPU @@ -890,7 +890,7 @@ config CAVIUM_OCTEON_SOC bool "Cavium Networks Octeon SoC based boards" select CEVT_R4K select ARCH_HAS_PHYS_TO_DMA - select ARCH_PHYS_ADDR_T_64BIT + select PHYS_ADDR_T_64BIT select DMA_COHERENT select SYS_SUPPORTS_64BIT_KERNEL select SYS_SUPPORTS_BIG_ENDIAN @@ -936,7 +936,7 @@ config NLM_XLR_BOARD select SWAP_IO_SPACE select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_64BIT_KERNEL - select ARCH_PHYS_ADDR_T_64BIT + select PHYS_ADDR_T_64BIT select SYS_SUPPORTS_BIG_ENDIAN select SYS_SUPPORTS_HIGHMEM select DMA_COHERENT @@ -962,7 +962,7 @@ config NLM_XLP_BOARD select HW_HAS_PCI select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_64BIT_KERNEL - select ARCH_PHYS_ADDR_T_64BIT + select PHYS_ADDR_T_64BIT select GPIOLIB select SYS_SUPPORTS_BIG_ENDIAN select SYS_SUPPORTS_LITTLE_ENDIAN @@ -1102,7 +1102,7 @@ config FW_CFE bool config ARCH_DMA_ADDR_T_64BIT - def_bool (HIGHMEM && ARCH_PHYS_ADDR_T_64BIT) || 64BIT + def_bool (HIGHMEM && PHYS_ADDR_T_64BIT) || 64BIT config ARCH_SUPPORTS_UPROBES bool @@ -1767,7 +1767,7 @@ config CPU_MIPS32_R5_XPA depends on SYS_SUPPORTS_HIGHMEM select XPA select HIGHMEM - select ARCH_PHYS_ADDR_T_64BIT + select PHYS_ADDR_T_64BIT default n help Choose this option if you want to enable the Extended Physical @@ -2399,9 +2399,6 @@ config SB1_PASS_2_1_WORKAROUNDS default y -config ARCH_PHYS_ADDR_T_64BIT - bool - choice prompt "SmartMIPS or microMIPS ASE support" diff
[PATCH 08/13] arch: define the ARCH_DMA_ADDR_T_64BIT config symbol in lib/Kconfig
Define this symbol if the architecture either uses 64-bit pointers or the PHYS_ADDR_T_64BIT is set. This covers 95% of the old arch magic. We only need an additional select for Xen on ARM (why anyway?), and we now always set ARCH_DMA_ADDR_T_64BIT on mips boards with 64-bit physical addressing instead of only doing it when highmem is set. Signed-off-by: Christoph Hellwig--- arch/alpha/Kconfig | 3 --- arch/arc/Kconfig | 3 --- arch/arm/mach-axxia/Kconfig| 1 - arch/arm/mach-bcm/Kconfig | 1 - arch/arm/mach-exynos/Kconfig | 1 - arch/arm/mach-highbank/Kconfig | 1 - arch/arm/mach-rockchip/Kconfig | 1 - arch/arm/mach-shmobile/Kconfig | 1 - arch/arm/mach-tegra/Kconfig| 1 - arch/arm/mm/Kconfig| 3 --- arch/arm64/Kconfig | 3 --- arch/ia64/Kconfig | 3 --- arch/mips/Kconfig | 3 --- arch/powerpc/Kconfig | 3 --- arch/riscv/Kconfig | 3 --- arch/s390/Kconfig | 3 --- arch/sparc/Kconfig | 4 arch/x86/Kconfig | 4 lib/Kconfig| 3 +++ 19 files changed, 3 insertions(+), 42 deletions(-) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 1fd9645b0c67..aa7df1a36fd0 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -66,9 +66,6 @@ config ZONE_DMA bool default y -config ARCH_DMA_ADDR_T_64BIT - def_bool y - config GENERIC_ISA_DMA bool default y diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index f94c61da682a..7498aca4b887 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -458,9 +458,6 @@ config ARC_HAS_PAE40 Enable access to physical memory beyond 4G, only supported on ARC cores with 40 bit Physical Addressing support -config ARCH_DMA_ADDR_T_64BIT - bool - config ARC_KVADDR_SIZE int "Kernel Virtual Address Space size (MB)" range 0 512 diff --git a/arch/arm/mach-axxia/Kconfig b/arch/arm/mach-axxia/Kconfig index bb2ce1c63fd9..d3eae6037913 100644 --- a/arch/arm/mach-axxia/Kconfig +++ b/arch/arm/mach-axxia/Kconfig @@ -2,7 +2,6 @@ config ARCH_AXXIA bool "LSI Axxia platforms" depends on ARCH_MULTI_V7 && ARM_LPAE - select ARCH_DMA_ADDR_T_64BIT select ARM_AMBA select ARM_GIC select ARM_TIMER_SP804 diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig index c2f3b0d216a4..c46a728df44e 100644 --- a/arch/arm/mach-bcm/Kconfig +++ b/arch/arm/mach-bcm/Kconfig @@ -211,7 +211,6 @@ config ARCH_BRCMSTB select BRCMSTB_L2_IRQ select BCM7120_L2_IRQ select ARCH_HAS_HOLES_MEMORYMODEL - select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE select ZONE_DMA if ARM_LPAE select SOC_BRCMSTB select SOC_BUS diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig index 647c319f9f5f..2ca405816846 100644 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig @@ -112,7 +112,6 @@ config SOC_EXYNOS5440 bool "SAMSUNG EXYNOS5440" default y depends on ARCH_EXYNOS5 - select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE select HAVE_ARM_ARCH_TIMER select AUTO_ZRELADDR select PINCTRL_EXYNOS5440 diff --git a/arch/arm/mach-highbank/Kconfig b/arch/arm/mach-highbank/Kconfig index 81110ec34226..5552968f07f8 100644 --- a/arch/arm/mach-highbank/Kconfig +++ b/arch/arm/mach-highbank/Kconfig @@ -1,7 +1,6 @@ config ARCH_HIGHBANK bool "Calxeda ECX-1000/2000 (Highbank/Midway)" depends on ARCH_MULTI_V7 - select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE select ARCH_HAS_HOLES_MEMORYMODEL select ARCH_SUPPORTS_BIG_ENDIAN select ARM_AMBA diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index a4065966881a..fafd3d7f9f8c 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -3,7 +3,6 @@ config ARCH_ROCKCHIP depends on ARCH_MULTI_V7 select PINCTRL select PINCTRL_ROCKCHIP - select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE select ARCH_HAS_RESET_CONTROLLER select ARM_AMBA select ARM_GIC diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig index 280e7312a9e1..fe60cd09a5ca 100644 --- a/arch/arm/mach-shmobile/Kconfig +++ b/arch/arm/mach-shmobile/Kconfig @@ -29,7 +29,6 @@ config ARCH_RMOBILE menuconfig ARCH_RENESAS bool "Renesas ARM SoCs" depends on ARCH_MULTI_V7 && MMU - select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE select ARCH_SHMOBILE select ARM_GIC select GPIOLIB diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig index 1e0aeb47bac6..7f3b83e0d324 100644 --- a/arch/arm/mach-tegra/Kconfig +++ b/arch/arm/mach-tegra/Kconfig @@ -15,6 +15,5 @@ menuconfig ARCH_TEGRA select RESET_CONTROLLER select SOC_BUS select ZONE_DMA if ARM_LPAE - select ARCH_DMA_ADDR_T_64BIT
[PATCH 13/13] swiotlb: remove the CONFIG_DMA_DIRECT_OPS ifdefs
swiotlb now selects the DMA_DIRECT_OPS config symbol, so this will always be true. Signed-off-by: Christoph Hellwig--- lib/swiotlb.c | 4 1 file changed, 4 deletions(-) diff --git a/lib/swiotlb.c b/lib/swiotlb.c index fece57566d45..6954f7ad200a 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -692,7 +692,6 @@ void swiotlb_tbl_sync_single(struct device *hwdev, phys_addr_t tlb_addr, } } -#ifdef CONFIG_DMA_DIRECT_OPS static inline bool dma_coherent_ok(struct device *dev, dma_addr_t addr, size_t size) { @@ -764,7 +763,6 @@ static bool swiotlb_free_buffer(struct device *dev, size_t size, DMA_ATTR_SKIP_CPU_SYNC); return true; } -#endif static void swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir, @@ -1045,7 +1043,6 @@ swiotlb_dma_supported(struct device *hwdev, u64 mask) return __phys_to_dma(hwdev, io_tlb_end - 1) <= mask; } -#ifdef CONFIG_DMA_DIRECT_OPS void *swiotlb_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) { @@ -1089,4 +1086,3 @@ const struct dma_map_ops swiotlb_dma_ops = { .unmap_page = swiotlb_unmap_page, .dma_supported = dma_direct_supported, }; -#endif /* CONFIG_DMA_DIRECT_OPS */ -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 09/13] PCI: remove CONFIG_PCI_BUS_ADDR_T_64BIT
This symbol is now always identical to CONFIG_ARCH_DMA_ADDR_T_64BIT, so remove it. Signed-off-by: Christoph HellwigAcked-by: Bjorn Helgaas --- drivers/pci/Kconfig | 4 drivers/pci/bus.c | 4 ++-- include/linux/pci.h | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 34b56a8f8480..29a487f31dae 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -5,10 +5,6 @@ source "drivers/pci/pcie/Kconfig" -config PCI_BUS_ADDR_T_64BIT - def_bool y if (ARCH_DMA_ADDR_T_64BIT || 64BIT) - depends on PCI - config PCI_MSI bool "Message Signaled Interrupts (MSI and MSI-X)" depends on PCI diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index bc2ded4c451f..35b7fc87eac5 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -120,7 +120,7 @@ int devm_request_pci_bus_resources(struct device *dev, EXPORT_SYMBOL_GPL(devm_request_pci_bus_resources); static struct pci_bus_region pci_32_bit = {0, 0xULL}; -#ifdef CONFIG_PCI_BUS_ADDR_T_64BIT +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT static struct pci_bus_region pci_64_bit = {0, (pci_bus_addr_t) 0xULL}; static struct pci_bus_region pci_high = {(pci_bus_addr_t) 0x1ULL, @@ -230,7 +230,7 @@ int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, resource_size_t), void *alignf_data) { -#ifdef CONFIG_PCI_BUS_ADDR_T_64BIT +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT int rc; if (res->flags & IORESOURCE_MEM_64) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 73178a2fcee0..55371cb827ad 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -670,7 +670,7 @@ int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 val); -#ifdef CONFIG_PCI_BUS_ADDR_T_64BIT +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT typedef u64 pci_bus_addr_t; #else typedef u32 pci_bus_addr_t; -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 10/13] arm: don't build swiotlb by default
swiotlb is only used as a library of helper for xen-swiotlb if Xen support is enabled on arm, so don't build it by default. Signed-off-by: Christoph Hellwig--- arch/arm/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index aa1c187d756d..90b81a3a28a7 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1774,7 +1774,7 @@ config SECCOMP defined by each seccomp mode. config SWIOTLB - def_bool y + bool config PARAVIRT bool "Enable paravirtualization code" @@ -1807,6 +1807,7 @@ config XEN depends on MMU select ARCH_DMA_ADDR_T_64BIT select ARM_PSCI + select SWIOTLB select SWIOTLB_XEN select PARAVIRT help -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 06/13] dma-mapping: move the NEED_DMA_MAP_STATE config symbol to lib/Kconfig
This way we have one central definition of it, and user can select it as needed. Note that we now also always select it when CONFIG_DMA_API_DEBUG is select, which fixes some incorrect checks in a few network drivers. Signed-off-by: Christoph HellwigReviewed-by: Anshuman Khandual --- arch/alpha/Kconfig | 4 +--- arch/arm/Kconfig| 4 +--- arch/arm64/Kconfig | 4 +--- arch/ia64/Kconfig | 4 +--- arch/mips/Kconfig | 3 --- arch/parisc/Kconfig | 4 +--- arch/s390/Kconfig | 4 +--- arch/sh/Kconfig | 4 +--- arch/sparc/Kconfig | 4 +--- arch/unicore32/Kconfig | 4 +--- arch/x86/Kconfig| 6 ++ drivers/iommu/Kconfig | 1 + include/linux/dma-mapping.h | 2 +- lib/Kconfig | 3 +++ lib/Kconfig.debug | 1 + 15 files changed, 17 insertions(+), 35 deletions(-) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 8e6a67ecf069..1fd9645b0c67 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -10,6 +10,7 @@ config ALPHA select HAVE_OPROFILE select HAVE_PCSPKR_PLATFORM select HAVE_PERF_EVENTS + select NEED_DMA_MAP_STATE select NEED_SG_DMA_LENGTH select VIRT_TO_BUS select GENERIC_IRQ_PROBE @@ -68,9 +69,6 @@ config ZONE_DMA config ARCH_DMA_ADDR_T_64BIT def_bool y -config NEED_DMA_MAP_STATE - def_bool y - config GENERIC_ISA_DMA bool default y diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 602c8320282f..aa1c187d756d 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -96,6 +96,7 @@ config ARM select HAVE_VIRT_CPU_ACCOUNTING_GEN select IRQ_FORCED_THREADING select MODULES_USE_ELF_REL + select NEED_DMA_MAP_STATE select NO_BOOTMEM select OF_EARLY_FLATTREE if OF select OF_RESERVED_MEM if OF @@ -221,9 +222,6 @@ config ARCH_MAY_HAVE_PC_FDC config ZONE_DMA bool -config NEED_DMA_MAP_STATE - def_bool y - config ARCH_SUPPORTS_UPROBES def_bool y diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 3b441c5587f1..940adfb9a2bc 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -133,6 +133,7 @@ config ARM64 select IRQ_FORCED_THREADING select MODULES_USE_ELF_RELA select MULTI_IRQ_HANDLER + select NEED_DMA_MAP_STATE select NEED_SG_DMA_LENGTH select NO_BOOTMEM select OF @@ -241,9 +242,6 @@ config HAVE_GENERIC_GUP config ARCH_DMA_ADDR_T_64BIT def_bool y -config NEED_DMA_MAP_STATE - def_bool y - config SMP def_bool y diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 333917676f7f..0e42731adaf1 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -54,6 +54,7 @@ config IA64 select MODULES_USE_ELF_RELA select ARCH_USE_CMPXCHG_LOCKREF select HAVE_ARCH_AUDITSYSCALL + select NEED_DMA_MAP_STATE select NEED_SG_DMA_LENGTH default y help @@ -82,9 +83,6 @@ config MMU config ARCH_DMA_ADDR_T_64BIT def_bool y -config NEED_DMA_MAP_STATE - def_bool y - config SWIOTLB bool diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 225c95da23ce..47d72c64d687 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1122,9 +1122,6 @@ config DMA_NONCOHERENT bool select NEED_DMA_MAP_STATE -config NEED_DMA_MAP_STATE - bool - config SYS_HAS_EARLY_PRINTK bool diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 89caea87556e..4d8f64d48597 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -51,6 +51,7 @@ config PARISC select GENERIC_CLOCKEVENTS select ARCH_NO_COHERENT_DMA_MMAP select CPU_NO_EFFICIENT_FFS + select NEED_DMA_MAP_STATE select NEED_SG_DMA_LENGTH help @@ -112,9 +113,6 @@ config PM config STACKTRACE_SUPPORT def_bool y -config NEED_DMA_MAP_STATE - def_bool y - config ISA_DMA_API bool diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index f80c6b983159..89a007672f70 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -711,6 +711,7 @@ menuconfig PCI select PCI_MSI select IOMMU_HELPER select IOMMU_SUPPORT + select NEED_DMA_MAP_STATE select NEED_SG_DMA_LENGTH help @@ -736,9 +737,6 @@ config PCI_DOMAINS config HAS_IOMEM def_bool PCI -config NEED_DMA_MAP_STATE - def_bool PCI - config CHSC_SCH def_tristate m prompt "Support for CHSC subchannels" diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index e127e0cbe30f..9417f70e008e 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -50,6 +50,7 @@ config SUPERH select HAVE_ARCH_AUDITSYSCALL select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI + select NEED_DMA_MAP_STATE select NEED_SG_DMA_LENGTH help @@
[PATCH 01/13] iommu-common: move to arch/sparc
This code is only used by sparc, and all new iommu drivers should use the drivers/iommu/ framework. Also remove the unused exports. Signed-off-by: Christoph HellwigReviewed-by: Anshuman Khandual --- {include/linux => arch/sparc/include/asm}/iommu-common.h | 0 arch/sparc/include/asm/iommu_64.h| 2 +- arch/sparc/kernel/Makefile | 2 +- {lib => arch/sparc/kernel}/iommu-common.c| 5 + arch/sparc/kernel/iommu.c| 2 +- arch/sparc/kernel/ldc.c | 2 +- arch/sparc/kernel/pci_sun4v.c| 2 +- lib/Makefile | 2 +- 8 files changed, 7 insertions(+), 10 deletions(-) rename {include/linux => arch/sparc/include/asm}/iommu-common.h (100%) rename {lib => arch/sparc/kernel}/iommu-common.c (98%) diff --git a/include/linux/iommu-common.h b/arch/sparc/include/asm/iommu-common.h similarity index 100% rename from include/linux/iommu-common.h rename to arch/sparc/include/asm/iommu-common.h diff --git a/arch/sparc/include/asm/iommu_64.h b/arch/sparc/include/asm/iommu_64.h index 9ed6b54caa4b..0ef6dedf747e 100644 --- a/arch/sparc/include/asm/iommu_64.h +++ b/arch/sparc/include/asm/iommu_64.h @@ -17,7 +17,7 @@ #define IOPTE_WRITE 0x0002UL #define IOMMU_NUM_CTXS 4096 -#include +#include struct iommu_arena { unsigned long *map; diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile index 76cb57750dda..a284662b0e4c 100644 --- a/arch/sparc/kernel/Makefile +++ b/arch/sparc/kernel/Makefile @@ -59,7 +59,7 @@ obj-$(CONFIG_SPARC32) += leon_pmc.o obj-$(CONFIG_SPARC64) += reboot.o obj-$(CONFIG_SPARC64) += sysfs.o -obj-$(CONFIG_SPARC64) += iommu.o +obj-$(CONFIG_SPARC64) += iommu.o iommu-common.o obj-$(CONFIG_SPARC64) += central.o obj-$(CONFIG_SPARC64) += starfire.o obj-$(CONFIG_SPARC64) += power.o diff --git a/lib/iommu-common.c b/arch/sparc/kernel/iommu-common.c similarity index 98% rename from lib/iommu-common.c rename to arch/sparc/kernel/iommu-common.c index 55b00de106b5..59cb16691322 100644 --- a/lib/iommu-common.c +++ b/arch/sparc/kernel/iommu-common.c @@ -8,9 +8,9 @@ #include #include #include -#include #include #include +#include static unsigned long iommu_large_alloc = 15; @@ -93,7 +93,6 @@ void iommu_tbl_pool_init(struct iommu_map_table *iommu, p->hint = p->start; p->end = num_entries; } -EXPORT_SYMBOL(iommu_tbl_pool_init); unsigned long iommu_tbl_range_alloc(struct device *dev, struct iommu_map_table *iommu, @@ -224,7 +223,6 @@ unsigned long iommu_tbl_range_alloc(struct device *dev, return n; } -EXPORT_SYMBOL(iommu_tbl_range_alloc); static struct iommu_pool *get_pool(struct iommu_map_table *tbl, unsigned long entry) @@ -264,4 +262,3 @@ void iommu_tbl_range_free(struct iommu_map_table *iommu, u64 dma_addr, bitmap_clear(iommu->map, entry, npages); spin_unlock_irqrestore(&(pool->lock), flags); } -EXPORT_SYMBOL(iommu_tbl_range_free); diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c index b08dc3416f06..40d008b0bd3e 100644 --- a/arch/sparc/kernel/iommu.c +++ b/arch/sparc/kernel/iommu.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #ifdef CONFIG_PCI #include diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c index 86b625f9d8dc..c0fa3ef6cf01 100644 --- a/arch/sparc/kernel/ldc.c +++ b/arch/sparc/kernel/ldc.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index 249367228c33..565d9ac883d0 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include diff --git a/lib/Makefile b/lib/Makefile index ce20696d5a92..94203b5eecd4 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -147,7 +147,7 @@ obj-$(CONFIG_AUDIT_GENERIC) += audit.o obj-$(CONFIG_AUDIT_COMPAT_GENERIC) += compat_audit.o obj-$(CONFIG_SWIOTLB) += swiotlb.o -obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o iommu-common.o +obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
centralize SWIOTLB config symbol and misc other cleanups V3
Hi all, this seris aims for a single defintion of the Kconfig symbol. To get there various cleanups, mostly about config symbols are included as well. Changes since V2: - swiotlb doesn't need the dma_length field by itself, so don't select it - don't offer a user visible SWIOTLB choice Chages since V1: - fixed a incorrect Reviewed-by that should be a Signed-off-by. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 04/13] iommu-helper: move the IOMMU_HELPER config symbol to lib/
This way we have one central definition of it, and user can select it as needed. Signed-off-by: Christoph HellwigReviewed-by: Anshuman Khandual --- arch/powerpc/Kconfig | 4 +--- arch/s390/Kconfig| 5 ++--- arch/sparc/Kconfig | 5 + arch/x86/Kconfig | 6 ++ lib/Kconfig | 3 +++ 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 43e3c8e4e7f4..7698cf89af9c 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -223,6 +223,7 @@ config PPC select HAVE_SYSCALL_TRACEPOINTS select HAVE_VIRT_CPU_ACCOUNTING select HAVE_IRQ_TIME_ACCOUNTING + select IOMMU_HELPER if PPC64 select IRQ_DOMAIN select IRQ_FORCED_THREADING select MODULES_USE_ELF_RELA @@ -478,9 +479,6 @@ config MPROFILE_KERNEL depends on PPC64 && CPU_LITTLE_ENDIAN def_bool !DISABLE_MPROFILE_KERNEL -config IOMMU_HELPER - def_bool PPC64 - config SWIOTLB bool "SWIOTLB support" default n diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 199ac3e4da1d..60c4ab854182 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -709,7 +709,9 @@ config QDIO menuconfig PCI bool "PCI support" select PCI_MSI + select IOMMU_HELPER select IOMMU_SUPPORT + help Enable PCI support. @@ -733,9 +735,6 @@ config PCI_DOMAINS config HAS_IOMEM def_bool PCI -config IOMMU_HELPER - def_bool PCI - config NEED_SG_DMA_LENGTH def_bool PCI diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 8767e45f1b2b..44e0f3cd7988 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -67,6 +67,7 @@ config SPARC64 select HAVE_SYSCALL_TRACEPOINTS select HAVE_CONTEXT_TRACKING select HAVE_DEBUG_KMEMLEAK + select IOMMU_HELPER select SPARSE_IRQ select RTC_DRV_CMOS select RTC_DRV_BQ4802 @@ -106,10 +107,6 @@ config ARCH_DMA_ADDR_T_64BIT bool default y if ARCH_ATU -config IOMMU_HELPER - bool - default y if SPARC64 - config STACKTRACE_SUPPORT bool default y if SPARC64 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index cb2c7ecc1fea..fe9713539166 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -871,6 +871,7 @@ config DMI config GART_IOMMU bool "Old AMD GART IOMMU support" + select IOMMU_HELPER select SWIOTLB depends on X86_64 && PCI && AMD_NB ---help--- @@ -892,6 +893,7 @@ config GART_IOMMU config CALGARY_IOMMU bool "IBM Calgary IOMMU support" + select IOMMU_HELPER select SWIOTLB depends on X86_64 && PCI ---help--- @@ -929,10 +931,6 @@ config SWIOTLB with more than 3 GB of memory. If unsure, say Y. -config IOMMU_HELPER - def_bool y - depends on CALGARY_IOMMU || GART_IOMMU - config MAXSMP bool "Enable Maximum number of SMP Processors and NUMA Nodes" depends on X86_64 && SMP && DEBUG_KERNEL diff --git a/lib/Kconfig b/lib/Kconfig index 5fe577673b98..2f6908577534 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -429,6 +429,9 @@ config SGL_ALLOC bool default n +config IOMMU_HELPER + bool + config DMA_DIRECT_OPS bool depends on HAS_DMA && (!64BIT || ARCH_DMA_ADDR_T_64BIT) -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 02/13] iommu-helper: unexport iommu_area_alloc
This function is only used by built-in code. Signed-off-by: Christoph HellwigReviewed-by: Anshuman Khandual --- lib/iommu-helper.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/iommu-helper.c b/lib/iommu-helper.c index 23633c0fda4a..ded1703e7e64 100644 --- a/lib/iommu-helper.c +++ b/lib/iommu-helper.c @@ -3,7 +3,6 @@ * IOMMU helper functions for the free area management */ -#include #include #include @@ -38,4 +37,3 @@ unsigned long iommu_area_alloc(unsigned long *map, unsigned long size, } return -1; } -EXPORT_SYMBOL(iommu_area_alloc); -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH] dma-debug: Check scatterlist segments
Hi Robin, I love your patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v4.17-rc2 next-20180424] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Robin-Murphy/dma-debug-Check-scatterlist-segments/20180425-070135 config: sh-allmodconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All warnings (new ones prefixed by >>): In file included from arch/sh/include/asm/bug.h:112:0, from include/linux/bug.h:5, from include/linux/thread_info.h:12, from include/asm-generic/current.h:5, from ./arch/sh/include/generated/asm/current.h:1, from include/linux/sched.h:12, from include/linux/sched/task_stack.h:9, from lib/dma-debug.c:20: lib/dma-debug.c: In function 'check_sg_segment': >> lib/dma-debug.c:232:12: warning: format '%llx' expects argument of type >> 'long long unsigned int', but argument 4 has type 'dma_addr_t {aka unsigned >> int}' [-Wformat=] WARN(1, "%s %s: " format, \ ^ include/asm-generic/bug.h:98:50: note: in definition of macro '__WARN_printf' #define __WARN_printf(arg...) do { __warn_printk(arg); __WARN(); } while (0) ^~~ >> lib/dma-debug.c:232:4: note: in expansion of macro 'WARN' WARN(1, "%s %s: " format, \ ^~~~ >> lib/dma-debug.c:1316:3: note: in expansion of macro 'err_printk' err_printk(dev, NULL, "DMA-API: mapping sg segment across boundary [start=0x%016llx] [end=0x%016llx] [boundary=0x%016llx]\n", ^~ lib/dma-debug.c:1316:85: note: format string is defined here err_printk(dev, NULL, "DMA-API: mapping sg segment across boundary [start=0x%016llx] [end=0x%016llx] [boundary=0x%016llx]\n", ~~^ %016x In file included from arch/sh/include/asm/bug.h:112:0, from include/linux/bug.h:5, from include/linux/thread_info.h:12, from include/asm-generic/current.h:5, from ./arch/sh/include/generated/asm/current.h:1, from include/linux/sched.h:12, from include/linux/sched/task_stack.h:9, from lib/dma-debug.c:20: lib/dma-debug.c:232:12: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 5 has type 'dma_addr_t {aka unsigned int}' [-Wformat=] WARN(1, "%s %s: " format, \ ^ include/asm-generic/bug.h:98:50: note: in definition of macro '__WARN_printf' #define __WARN_printf(arg...) do { __warn_printk(arg); __WARN(); } while (0) ^~~ >> lib/dma-debug.c:232:4: note: in expansion of macro 'WARN' WARN(1, "%s %s: " format, \ ^~~~ >> lib/dma-debug.c:1316:3: note: in expansion of macro 'err_printk' err_printk(dev, NULL, "DMA-API: mapping sg segment across boundary [start=0x%016llx] [end=0x%016llx] [boundary=0x%016llx]\n", ^~ lib/dma-debug.c:1316:101: note: format string is defined here err_printk(dev, NULL, "DMA-API: mapping sg segment across boundary [start=0x%016llx] [end=0x%016llx] [boundary=0x%016llx]\n", ~~^ %016x In file included from arch/sh/include/asm/bug.h:112:0, from include/linux/bug.h:5, from include/linux/thread_info.h:12, from include/asm-generic/current.h:5, from ./arch/sh/include/generated/asm/current.h:1, from include/linux/sched.h:12, from include/linux/sched/task_stack.h:9, from lib/dma-debug.c:20: lib/dma-debug.c:232:12: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 6 has type 'dma_addr_t {aka unsigned int}' [-Wformat=] WARN(1, "%s %s: " format, \ ^ include/asm-generic/bug.h:98:50: note: in definition of macro '__WARN_printf' #define __WARN_printf(arg...) do { __warn_printk(arg);
Re: [PATCH 5/5] PCI: remove PCI_DMA_BUS_IS_PHYS
On Tue, 24 Apr 2018 11:16:25 PDT (-0700), Christoph Hellwig wrote: This was used by the ide, scsi and networking code in the past to determine if they should bounce payloads. Now that the dma mapping always have to support dma to all physical memory (thanks to swiotlb for non-iommu systems) there is no need to this crude hack any more. Signed-off-by: Christoph Hellwig--- [...] diff --git a/arch/riscv/include/asm/pci.h b/arch/riscv/include/asm/pci.h index 0f2fc9ef20fc..b3638c505728 100644 --- a/arch/riscv/include/asm/pci.h +++ b/arch/riscv/include/asm/pci.h @@ -26,9 +26,6 @@ /* RISC-V shim does not initialize PCI bus */ #define pcibios_assign_all_busses() 1 -/* We do not have an IOMMU */ -#define PCI_DMA_BUS_IS_PHYS 1 - extern int isa_dma_bridge_buggy; #ifdef CONFIG_PCI Thanks! Acked-by: Palmer Dabbelt (For the RISC-V change) ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 03/37] iommu/sva: Manage process address spaces
On 24/04/18 18:17, Sinan Kaya wrote: > On 4/24/2018 5:33 AM, Jean-Philippe Brucker wrote: >>> Please return pasid when you find an io_mm that is already bound. Something >>> like >>> *pasid = io_mm->pasid should do the work here when bond is true. >> Right. I think we should also keep returning 0, not switch to -EEXIST or >> similar. So in next version a driver can call bind(devX, mmY) multiple >> times, but the first unbind() removes the bond. > > If we are going to allow multiple binds, then the last unbind should > remove the bond rather than the first one via reference counting. Yeah that's probably better. Since a bond belongs to a device driver it doesn't need multiple bind/unbind, so earlier in this thread (1/37) I talked about removing the bond->refs. But thinking about it, there still is a need for it. When mm exits, we now need to call the device driver's mm_exit handler outside of the spinlock, so we have to take a ref in order to prevent a concurrent unbind() from freeing the bond. Thanks, Jean ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v4 12/22] iommu: introduce device fault report API
On Mon, 23 Apr 2018 12:30:13 +0100 Jean-Philippe Bruckerwrote: > On Mon, Apr 16, 2018 at 10:49:01PM +0100, Jacob Pan wrote: > [...] > > +int iommu_register_device_fault_handler(struct device *dev, > > + iommu_dev_fault_handler_t > > handler, > > + void *data) > > +{ > > + struct iommu_param *param = dev->iommu_param; > > + > > + /* > > +* Device iommu_param should have been allocated when > > device is > > +* added to its iommu_group. > > +*/ > > + if (!param) > > + return -EINVAL; > > + > > + /* Only allow one fault handler registered for each device > > */ > > + if (param->fault_param) > > + return -EBUSY; > > + > > + mutex_lock(>lock); > > + get_device(dev); > > + param->fault_param = > > + kzalloc(sizeof(struct iommu_fault_param), > > GFP_ATOMIC); > > This can be GFP_KERNEL > yes, will change. > [...] > > +int iommu_report_device_fault(struct device *dev, struct > > iommu_fault_event *evt) +{ > > + int ret = 0; > > + struct iommu_fault_event *evt_pending; > > + struct iommu_fault_param *fparam; > > + > > + /* iommu_param is allocated when device is added to group > > */ > > + if (!dev->iommu_param | !evt) > > + return -EINVAL; > > + /* we only report device fault if there is a handler > > registered */ > > + mutex_lock(>iommu_param->lock); > > + if (!dev->iommu_param->fault_param || > > + !dev->iommu_param->fault_param->handler) { > > + ret = -EINVAL; > > + goto done_unlock; > > + } > > + fparam = dev->iommu_param->fault_param; > > + if (evt->type == IOMMU_FAULT_PAGE_REQ && evt->last_req) { > > + evt_pending = kzalloc(sizeof(*evt_pending), > > GFP_ATOMIC); > > We're expecting caller to be a thread at the moment, so this could be > GFP_KERNEL too. You could also use kmemdup to remove the memcpy below > good idea. will do. > [...] > > +static inline int iommu_register_device_fault_handler(struct > > device *dev, > > + > > iommu_dev_fault_handler_t handler, > > + void *data) > > +{ > > + return 0; > > Should return -ENODEV > right. thanks. > Thanks, > Jean [Jacob Pan] ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 4/5] net: remove the PCI_DMA_BUS_IS_PHYS check in illegal_highdma
These days the dma mapping routines must be able to handle any address supported by the device, be that using an iommu, or swiotlb if none is supported. With that the PCI_DMA_BUS_IS_PHYS check in illegal_highdma is not needed and can be removed. Signed-off-by: Christoph Hellwig--- net/core/dev.c | 20 +--- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index af0558b00c6c..060256cbf4f3 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2884,11 +2884,7 @@ void netdev_rx_csum_fault(struct net_device *dev) EXPORT_SYMBOL(netdev_rx_csum_fault); #endif -/* Actually, we should eliminate this check as soon as we know, that: - * 1. IOMMU is present and allows to map all the memory. - * 2. No high memory really exists on this machine. - */ - +/* XXX: check that highmem exists at all on the given machine. */ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb) { #ifdef CONFIG_HIGHMEM @@ -2902,20 +2898,6 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb) return 1; } } - - if (PCI_DMA_BUS_IS_PHYS) { - struct device *pdev = dev->dev.parent; - - if (!pdev) - return 0; - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { - skb_frag_t *frag = _shinfo(skb)->frags[i]; - dma_addr_t addr = page_to_phys(skb_frag_page(frag)); - - if (!pdev->dma_mask || addr + PAGE_SIZE - 1 > *pdev->dma_mask) - return 1; - } - } #endif return 0; } -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 3/5] ide: remove the PCI_DMA_BUS_IS_PHYS check
We now have ways to deal with drainage in the block layer, and libata has been using it for ages. We also want to get rid of PCI_DMA_BUS_IS_PHYS now, so just reduce the PCI transfer size for ide - anyone who cares for performance on PCI controllers should have switched to libata long ago. Signed-off-by: Christoph Hellwig--- drivers/ide/ide-probe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 8d8ed036ca0a..56d7bc228cb3 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -796,8 +796,7 @@ static int ide_init_queue(ide_drive_t *drive) * This will be fixed once we teach pci_map_sg() about our boundary * requirements, hopefully soon. *FIXME* */ - if (!PCI_DMA_BUS_IS_PHYS) - max_sg_entries >>= 1; + max_sg_entries >>= 1; #endif /* CONFIG_PCI */ blk_queue_max_segments(q, max_sg_entries); -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 2/5] ide: kill ide_toggle_bounce
ide_toggle_bounce did select various strange block bounce limits, including not bouncing at all as soon as an iommu is present in the system. Given that the dma_map routines now handle any required bounce buffering except for ISA DMA, and the ide code already must handle either ISA DMA or highmem at least for iommu equipped systems we can get rid of the block layer bounce limit setting entirely. Signed-off-by: Christoph Hellwig--- drivers/ide/ide-dma.c | 2 -- drivers/ide/ide-lib.c | 26 -- drivers/ide/ide-probe.c | 3 --- include/linux/ide.h | 2 -- 4 files changed, 33 deletions(-) diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 54d4d78ca46a..6f344654ef22 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -180,7 +180,6 @@ EXPORT_SYMBOL_GPL(ide_dma_unmap_sg); void ide_dma_off_quietly(ide_drive_t *drive) { drive->dev_flags &= ~IDE_DFLAG_USING_DMA; - ide_toggle_bounce(drive, 0); drive->hwif->dma_ops->dma_host_set(drive, 0); } @@ -211,7 +210,6 @@ EXPORT_SYMBOL(ide_dma_off); void ide_dma_on(ide_drive_t *drive) { drive->dev_flags |= IDE_DFLAG_USING_DMA; - ide_toggle_bounce(drive, 1); drive->hwif->dma_ops->dma_host_set(drive, 1); } diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index e1180fa46196..78cb79eddc8b 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -6,32 +6,6 @@ #include #include -/** - * ide_toggle_bounce - handle bounce buffering - * @drive: drive to update - * @on: on/off boolean - * - * Enable or disable bounce buffering for the device. Drives move - * between PIO and DMA and that changes the rules we need. - */ - -void ide_toggle_bounce(ide_drive_t *drive, int on) -{ - u64 addr = BLK_BOUNCE_HIGH; /* dma64_addr_t */ - - if (!PCI_DMA_BUS_IS_PHYS) { - addr = BLK_BOUNCE_ANY; - } else if (on && drive->media == ide_disk) { - struct device *dev = drive->hwif->dev; - - if (dev && dev->dma_mask) - addr = *dev->dma_mask; - } - - if (drive->queue) - blk_queue_bounce_limit(drive->queue, addr); -} - u64 ide_get_lba_addr(struct ide_cmd *cmd, int lba48) { struct ide_taskfile *tf = >tf; diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 2019e66eada7..8d8ed036ca0a 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -805,9 +805,6 @@ static int ide_init_queue(ide_drive_t *drive) /* assign drive queue */ drive->queue = q; - /* needs drive->queue to be set */ - ide_toggle_bounce(drive, 1); - return 0; } diff --git a/include/linux/ide.h b/include/linux/ide.h index ca9d34feb572..11f0dd03a4b4 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1508,8 +1508,6 @@ static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data) hwif->hwif_data = data; } -extern void ide_toggle_bounce(ide_drive_t *drive, int on); - u64 ide_get_lba_addr(struct ide_cmd *, int); u8 ide_dump_status(ide_drive_t *, const char *, u8); -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 5/5] PCI: remove PCI_DMA_BUS_IS_PHYS
This was used by the ide, scsi and networking code in the past to determine if they should bounce payloads. Now that the dma mapping always have to support dma to all physical memory (thanks to swiotlb for non-iommu systems) there is no need to this crude hack any more. Signed-off-by: Christoph Hellwig--- arch/alpha/include/asm/pci.h | 5 - arch/arc/include/asm/pci.h| 6 -- arch/arm/include/asm/pci.h| 7 --- arch/arm64/include/asm/pci.h | 5 - arch/h8300/include/asm/pci.h | 2 -- arch/hexagon/kernel/dma.c | 1 - arch/ia64/hp/common/sba_iommu.c | 3 --- arch/ia64/include/asm/pci.h | 17 - arch/ia64/kernel/setup.c | 12 arch/ia64/sn/kernel/io_common.c | 5 - arch/m68k/include/asm/pci.h | 6 -- arch/microblaze/include/asm/pci.h | 6 -- arch/mips/include/asm/pci.h | 7 --- arch/parisc/include/asm/pci.h | 23 --- arch/parisc/kernel/setup.c| 5 - arch/powerpc/include/asm/pci.h| 18 -- arch/riscv/include/asm/pci.h | 3 --- arch/s390/include/asm/pci.h | 2 -- arch/s390/pci/pci_dma.c | 2 -- arch/sh/include/asm/pci.h | 6 -- arch/sh/kernel/dma-nommu.c| 1 - arch/sparc/include/asm/pci_32.h | 4 arch/sparc/include/asm/pci_64.h | 6 -- arch/x86/include/asm/pci.h| 3 --- arch/xtensa/include/asm/pci.h | 2 -- drivers/parisc/ccio-dma.c | 2 -- drivers/parisc/sba_iommu.c| 2 -- include/asm-generic/pci.h | 8 include/linux/dma-mapping.h | 1 - lib/dma-direct.c | 1 - tools/virtio/linux/dma-mapping.h | 2 -- 31 files changed, 173 deletions(-) diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h index b9ec55351924..cf6bc1e64d66 100644 --- a/arch/alpha/include/asm/pci.h +++ b/arch/alpha/include/asm/pci.h @@ -56,11 +56,6 @@ struct pci_controller { /* IOMMU controls. */ -/* The PCI address space does not equal the physical memory address space. - The networking and block device layers use this boolean for bounce buffer - decisions. */ -#define PCI_DMA_BUS_IS_PHYS 0 - /* TODO: integrate with include/asm-generic/pci.h ? */ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) { diff --git a/arch/arc/include/asm/pci.h b/arch/arc/include/asm/pci.h index ba56c23c1b20..4ff53c041c64 100644 --- a/arch/arc/include/asm/pci.h +++ b/arch/arc/include/asm/pci.h @@ -16,12 +16,6 @@ #define PCIBIOS_MIN_MEM 0x10 #define pcibios_assign_all_busses()1 -/* - * The PCI address space does equal the physical memory address space. - * The networking and block device layers use this boolean for bounce - * buffer decisions. - */ -#define PCI_DMA_BUS_IS_PHYS1 #endif /* __KERNEL__ */ diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h index 1f0de808d111..0abd389cf0ec 100644 --- a/arch/arm/include/asm/pci.h +++ b/arch/arm/include/asm/pci.h @@ -19,13 +19,6 @@ static inline int pci_proc_domain(struct pci_bus *bus) } #endif /* CONFIG_PCI_DOMAINS */ -/* - * The PCI address space does equal the physical memory address space. - * The networking and block device layers use this boolean for bounce - * buffer decisions. - */ -#define PCI_DMA_BUS_IS_PHYS (1) - #define HAVE_PCI_MMAP #define ARCH_GENERIC_PCI_MMAP_RESOURCE diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h index 8747f7c5e0e7..9e690686e8aa 100644 --- a/arch/arm64/include/asm/pci.h +++ b/arch/arm64/include/asm/pci.h @@ -18,11 +18,6 @@ #define pcibios_assign_all_busses() \ (pci_has_flag(PCI_REASSIGN_ALL_BUS)) -/* - * PCI address space differs from physical memory address space - */ -#define PCI_DMA_BUS_IS_PHYS(0) - #define ARCH_GENERIC_PCI_MMAP_RESOURCE 1 extern int isa_dma_bridge_buggy; diff --git a/arch/h8300/include/asm/pci.h b/arch/h8300/include/asm/pci.h index 7c9e55d62215..d4d345a52092 100644 --- a/arch/h8300/include/asm/pci.h +++ b/arch/h8300/include/asm/pci.h @@ -15,6 +15,4 @@ static inline void pcibios_penalize_isa_irq(int irq, int active) /* We don't do dynamic PCI IRQ allocation */ } -#define PCI_DMA_BUS_IS_PHYS(1) - #endif /* _ASM_H8300_PCI_H */ diff --git a/arch/hexagon/kernel/dma.c b/arch/hexagon/kernel/dma.c index ad8347c29dcf..77459df34e2e 100644 --- a/arch/hexagon/kernel/dma.c +++ b/arch/hexagon/kernel/dma.c @@ -208,7 +208,6 @@ const struct dma_map_ops hexagon_dma_ops = { .sync_single_for_cpu = hexagon_sync_single_for_cpu, .sync_single_for_device = hexagon_sync_single_for_device, .mapping_error = hexagon_mapping_error, - .is_phys= 1, }; void __init hexagon_dma_init(void) diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c index aec4a3354abe..6f05aba9012f 100644 --- a/arch/ia64/hp/common/sba_iommu.c +++
remove PCI_DMA_BUS_IS_PHYS V2
Hi all, this series tries to get rid of the global and PCI_DMA_BUS_IS_PHYS flag, which causes the block layer and networking code to bounce buffer memory above the dma mask in some cases. It is a leftover from i386 + highmem days and is obsolete now that we have swiotlb or iommus so that the dma ops implementations can always (minus the ISA DMA case which will require further attention) handle memory passed to them. Changes since V1: - dropped all patches not strictly required to remove PCI_DMA_BUS_IS_PHYS, those will be resent separately ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 03/37] iommu/sva: Manage process address spaces
On 4/24/2018 5:33 AM, Jean-Philippe Brucker wrote: >> Please return pasid when you find an io_mm that is already bound. Something >> like >> *pasid = io_mm->pasid should do the work here when bond is true. > Right. I think we should also keep returning 0, not switch to -EEXIST or > similar. So in next version a driver can call bind(devX, mmY) multiple > times, but the first unbind() removes the bond. If we are going to allow multiple binds, then the last unbind should remove the bond rather than the first one via reference counting. -- Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH] dma-debug: Check scatterlist segments
Drivers/subsystems creating scatterlists for DMA should be taking care to respect the scatter-gather limitations of the appropriate device, as described by dma_parms. A DMA API implementation cannot feasibly split a scatterlist into *more* entries than originally passed, so it is not well defined what they should do when given a segment larger than the limit they are also required to respect. Conversely, devices which are less limited than the rather conservative defaults, or indeed have no limitations at all (e.g. GPUs with their own internal MMU), should be encouraged to set appropriate dma_parms, as they may get more efficient DMA mapping performance out of it. Signed-off-by: Robin Murphy--- lib/dma-debug.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 7f5cdc1e6b29..9f158941004d 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c @@ -1293,6 +1293,30 @@ static void check_sync(struct device *dev, put_hash_bucket(bucket, ); } +static void check_sg_segment(struct device *dev, struct scatterlist *sg) +{ + unsigned int max_seg = dma_get_max_seg_size(dev); + dma_addr_t start, end, boundary = dma_get_seg_boundary(dev); + + /* +* Either the driver forgot to set dma_parms appropriately, or +* whoever generated the list forgot to check them. +*/ + if (sg->length > max_seg) + err_printk(dev, NULL, "DMA-API: mapping sg segment longer than device claims to support [len=%u] [max=%u]\n", + sg->length, max_seg); + /* +* In some cases this could potentially be the DMA API +* implementation's fault, but it would usually imply that +* the scatterlist was built inappropriately to begin with. +*/ + start = sg_dma_address(sg); + end = start + sg_dma_len(sg) - 1; + if ((start ^ end) & ~boundary) + err_printk(dev, NULL, "DMA-API: mapping sg segment across boundary [start=0x%016llx] [end=0x%016llx] [boundary=0x%016llx]\n", + start, end, boundary); +} + void debug_dma_map_page(struct device *dev, struct page *page, size_t offset, size_t size, int direction, dma_addr_t dma_addr, bool map_single) @@ -1423,6 +1447,8 @@ void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, check_for_illegal_area(dev, sg_virt(s), sg_dma_len(s)); } + check_sg_segment(dev, s); + add_dma_entry(entry); } } -- 2.17.0.dirty ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 3/3] dma-debug: unexport dma_debug_resize_entries and debug_dma_dump_mappings
Only used by the AMD GART driver, which must be built in. Signed-off-by: Christoph Hellwig--- lib/dma-debug.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 075253cb613b..6a1ebaa83623 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c @@ -444,7 +444,6 @@ void debug_dma_dump_mappings(struct device *dev) spin_unlock_irqrestore(>lock, flags); } } -EXPORT_SYMBOL(debug_dma_dump_mappings); /* * For each mapping (initial cacheline in the case of @@ -753,7 +752,6 @@ int dma_debug_resize_entries(u32 num_entries) return ret; } -EXPORT_SYMBOL(dma_debug_resize_entries); /* * DMA-API debugging init code -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 1/3] dma-debug: move initialization to common code
Most mainstream architectures are using 65536 entries, so lets stick to that. If someone is really desperate to override it that can still be done through , but I'd rather see a really good rationale for that. dma_debug_init is now called as a core_initcall, which for many architectures means much earlier, and provides dma-debug functionality earlier in the boot process. This should be safe as it only relies on the memory allocator already being available. Signed-off-by: Christoph Hellwig--- arch/arm/mm/dma-mapping-nommu.c | 9 - arch/arm/mm/dma-mapping.c | 9 - arch/arm64/mm/dma-mapping.c | 10 -- arch/c6x/kernel/dma.c | 11 --- arch/ia64/kernel/dma-mapping.c | 10 -- arch/microblaze/kernel/dma.c| 11 --- arch/mips/mm/dma-default.c | 10 -- arch/openrisc/kernel/dma.c | 11 --- arch/powerpc/kernel/dma.c | 3 --- arch/s390/pci/pci_dma.c | 9 - arch/sh/mm/consistent.c | 9 - arch/sparc/kernel/Makefile | 2 -- arch/sparc/kernel/dma.c | 13 - arch/x86/kernel/pci-dma.c | 4 arch/xtensa/kernel/pci-dma.c| 9 - include/linux/dma-debug.h | 6 -- lib/dma-debug.c | 21 ++--- 17 files changed, 14 insertions(+), 143 deletions(-) delete mode 100644 arch/sparc/kernel/dma.c diff --git a/arch/arm/mm/dma-mapping-nommu.c b/arch/arm/mm/dma-mapping-nommu.c index 619f24a42d09..f448a0663b10 100644 --- a/arch/arm/mm/dma-mapping-nommu.c +++ b/arch/arm/mm/dma-mapping-nommu.c @@ -241,12 +241,3 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, void arch_teardown_dma_ops(struct device *dev) { } - -#define PREALLOC_DMA_DEBUG_ENTRIES 4096 - -static int __init dma_debug_do_init(void) -{ - dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); - return 0; -} -core_initcall(dma_debug_do_init); diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 8c398fedbbb6..c26bf83f44ca 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1165,15 +1165,6 @@ int arm_dma_supported(struct device *dev, u64 mask) return __dma_supported(dev, mask, false); } -#define PREALLOC_DMA_DEBUG_ENTRIES 4096 - -static int __init dma_debug_do_init(void) -{ - dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); - return 0; -} -core_initcall(dma_debug_do_init); - #ifdef CONFIG_ARM_DMA_USE_IOMMU static int __dma_info_to_prot(enum dma_data_direction dir, unsigned long attrs) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index a96ec0181818..db01f2709842 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -508,16 +508,6 @@ static int __init arm64_dma_init(void) } arch_initcall(arm64_dma_init); -#define PREALLOC_DMA_DEBUG_ENTRIES 4096 - -static int __init dma_debug_do_init(void) -{ - dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); - return 0; -} -fs_initcall(dma_debug_do_init); - - #ifdef CONFIG_IOMMU_DMA #include #include diff --git a/arch/c6x/kernel/dma.c b/arch/c6x/kernel/dma.c index 9fff8be75f58..31e1a9ec3a9c 100644 --- a/arch/c6x/kernel/dma.c +++ b/arch/c6x/kernel/dma.c @@ -136,14 +136,3 @@ const struct dma_map_ops c6x_dma_ops = { .sync_sg_for_cpu= c6x_dma_sync_sg_for_cpu, }; EXPORT_SYMBOL(c6x_dma_ops); - -/* Number of entries preallocated for DMA-API debugging */ -#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16) - -static int __init dma_init(void) -{ - dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); - - return 0; -} -fs_initcall(dma_init); diff --git a/arch/ia64/kernel/dma-mapping.c b/arch/ia64/kernel/dma-mapping.c index f2d57e66fd86..7a471d8d67d4 100644 --- a/arch/ia64/kernel/dma-mapping.c +++ b/arch/ia64/kernel/dma-mapping.c @@ -9,16 +9,6 @@ int iommu_detected __read_mostly; const struct dma_map_ops *dma_ops; EXPORT_SYMBOL(dma_ops); -#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16) - -static int __init dma_init(void) -{ - dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); - - return 0; -} -fs_initcall(dma_init); - const struct dma_map_ops *dma_get_ops(struct device *dev) { return dma_ops; diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c index c91e8cef98dd..3145e7dc8ab1 100644 --- a/arch/microblaze/kernel/dma.c +++ b/arch/microblaze/kernel/dma.c @@ -184,14 +184,3 @@ const struct dma_map_ops dma_nommu_ops = { .sync_sg_for_device = dma_nommu_sync_sg_for_device, }; EXPORT_SYMBOL(dma_nommu_ops); - -/* Number of entries preallocated for DMA-API debugging */ -#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16) - -static int __init dma_init(void) -{ - dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); - - return 0; -} -fs_initcall(dma_init); diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c index dcafa43613b6..f9fef0028ca2 100644 --- a/arch/mips/mm/dma-default.c +++
[PATCH 2/3] dma-debug: simplify counting of preallocated requests
Just keep a single variable with a descriptive name instead of two with confusing names. Signed-off-by: Christoph Hellwig--- lib/dma-debug.c | 20 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 712a897174e4..075253cb613b 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c @@ -132,7 +132,7 @@ static u32 min_free_entries; static u32 nr_total_entries; /* number of preallocated entries requested by kernel cmdline */ -static u32 req_entries; +static u32 nr_prealloc_entries = PREALLOC_DMA_DEBUG_ENTRIES; /* debugfs dentry's for the stuff above */ static struct dentry *dma_debug_dent__read_mostly; @@ -1011,7 +1011,6 @@ void dma_debug_add_bus(struct bus_type *bus) static int dma_debug_init(void) { - u32 num_entries; int i; /* Do not use dma_debug_initialized here, since we really want to be @@ -1032,12 +1031,7 @@ static int dma_debug_init(void) return 0; } - if (req_entries) - num_entries = req_entries; - else - num_entries = PREALLOC_DMA_DEBUG_ENTRIES; - - if (prealloc_memory(num_entries) != 0) { + if (prealloc_memory(nr_prealloc_entries) != 0) { pr_err("DMA-API: debugging out of memory error - disabled\n"); global_disable = true; @@ -1068,16 +1062,10 @@ static __init int dma_debug_cmdline(char *str) static __init int dma_debug_entries_cmdline(char *str) { - int res; - if (!str) return -EINVAL; - - res = get_option(, _entries); - - if (!res) - req_entries = 0; - + if (!get_option(, _prealloc_entries)) + nr_prealloc_entries = PREALLOC_DMA_DEBUG_ENTRIES; return 0; } -- 2.17.0 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
dma-debug cleanups, including removing the arch hook
Hi all, this series has a few dma-debug cleanups, most notably removing the need for architectures to explicitly initialize dma-debug. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
RE: [PATCH v6 4/7] iommu/dma: Move PCI window region reservation back into dma specific path.
Hi Joerg, Could you please take a look at this patch and let me know. I have rebased this to 4.17-rc1 and added Robin's R-by. This series[1] is now pending on this patch as without this it will break few ARM platforms[2]. Please take a look and let me know. Thanks, Shameer [1] https://lkml.org/lkml/2018/4/18/293 [2] https://lkml.org/lkml/2018/3/14/881 > -Original Message- > From: Shameerali Kolothum Thodi > Sent: Wednesday, April 18, 2018 12:41 PM > To: alex.william...@redhat.com; eric.au...@redhat.com; > pmo...@linux.vnet.ibm.com > Cc: k...@vger.kernel.org; linux-ker...@vger.kernel.org; iommu@lists.linux- > foundation.org; Linuxarm; John Garry > ; xuwei (O) ; Shameerali > Kolothum Thodi ; Joerg Roedel > > Subject: [PATCH v6 4/7] iommu/dma: Move PCI window region reservation > back into dma specific path. > > This pretty much reverts commit 273df9635385 ("iommu/dma: Make PCI > window reservation generic") by moving the PCI window region > reservation back into the dma specific path so that these regions > doesn't get exposed via the IOMMU API interface. With this change, > the vfio interface will report only iommu specific reserved regions > to the user space. > > Cc: Joerg Roedel > Signed-off-by: Shameer Kolothum > Reviewed-by: Robin Murphy > --- > drivers/iommu/dma-iommu.c | 54 ++-- > --- > 1 file changed, 25 insertions(+), 29 deletions(-) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index f05f3cf..ddcbbdb 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -167,40 +167,16 @@ EXPORT_SYMBOL(iommu_put_dma_cookie); > * @list: Reserved region list from iommu_get_resv_regions() > * > * IOMMU drivers can use this to implement their .get_resv_regions callback > - * for general non-IOMMU-specific reservations. Currently, this covers host > - * bridge windows for PCI devices and GICv3 ITS region reservation on ACPI > - * based ARM platforms that may require HW MSI reservation. > + * for general non-IOMMU-specific reservations. Currently, this covers GICv3 > + * ITS region reservation on ACPI based ARM platforms that may require HW > MSI > + * reservation. > */ > void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list) > { > - struct pci_host_bridge *bridge; > - struct resource_entry *window; > - > - if (!is_of_node(dev->iommu_fwspec->iommu_fwnode) && > - iort_iommu_msi_get_resv_regions(dev, list) < 0) > - return; > - > - if (!dev_is_pci(dev)) > - return; > - > - bridge = pci_find_host_bridge(to_pci_dev(dev)->bus); > - resource_list_for_each_entry(window, >windows) { > - struct iommu_resv_region *region; > - phys_addr_t start; > - size_t length; > - > - if (resource_type(window->res) != IORESOURCE_MEM) > - continue; > > - start = window->res->start - window->offset; > - length = window->res->end - window->res->start + 1; > - region = iommu_alloc_resv_region(start, length, 0, > - IOMMU_RESV_RESERVED); > - if (!region) > - return; > + if (!is_of_node(dev->iommu_fwspec->iommu_fwnode)) > + iort_iommu_msi_get_resv_regions(dev, list); > > - list_add_tail(>list, list); > - } > } > EXPORT_SYMBOL(iommu_dma_get_resv_regions); > > @@ -229,6 +205,23 @@ static int cookie_init_hw_msi_region(struct > iommu_dma_cookie *cookie, > return 0; > } > > +static void iova_reserve_pci_windows(struct pci_dev *dev, > + struct iova_domain *iovad) > +{ > + struct pci_host_bridge *bridge = pci_find_host_bridge(dev->bus); > + struct resource_entry *window; > + unsigned long lo, hi; > + > + resource_list_for_each_entry(window, >windows) { > + if (resource_type(window->res) != IORESOURCE_MEM) > + continue; > + > + lo = iova_pfn(iovad, window->res->start - window->offset); > + hi = iova_pfn(iovad, window->res->end - window->offset); > + reserve_iova(iovad, lo, hi); > + } > +} > + > static int iova_reserve_iommu_regions(struct device *dev, > struct iommu_domain *domain) > { > @@ -238,6 +231,9 @@ static int iova_reserve_iommu_regions(struct device > *dev, > LIST_HEAD(resv_regions); > int ret = 0; > > + if (dev_is_pci(dev)) > + iova_reserve_pci_windows(to_pci_dev(dev), iovad); > + > iommu_get_resv_regions(dev, _regions); > list_for_each_entry(region, _regions, list) { > unsigned long lo, hi; > -- > 2.7.4 > ___ iommu mailing list
Re: [RFC 1/2] iommu/arm-smmu-v3: Remove bypass in arm_smmu_reset_device
Hi Robin, Thanks for your comment! On 2018/4/24 0:07, Robin Murphy wrote: > On 23/04/18 12:45, Yisheng Xie wrote: >> Add a bypass parameter in arm_smmu_device to keep whether smmu device >> should pypass or not, so parameter bypass in arm_smmu_reset_device can >> be removed. > > Given that the GBPA configuration implied by the bypass argument here > is only there to avoid initialising a full stream table when the firmware > is terminally broken, I wonder if it would make sense to simply skip > allocating a stream table at all in that case. Then we could just base > the subsequent SMMUEN/GPBA decision on whether strtab_cfg.strtab is valid or > not. > Yes, it may save many memory, and should be care about not access strtab when attach device or other similar scenario, anyway software can achieve this after move bypass to struct arm_smmu_device. Thanks Yisheng > Robin. > ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [RFC 2/2] iommu/arm-smmu-v3: Support software retention for pm_resume
Hi Robin, Thanks for your comment. On 2018/4/24 0:14, Robin Murphy wrote: > On 23/04/18 12:45, Yisheng Xie wrote: >> When system suspend, hisilicon's smmu will do power gating for smmu, >> this time smmu's reg will be set to default value for not having >> hardware retention, which means need software do the retention instead. >> >> The patch is to use arm_smmu_device_reset() to restore the register of >> smmu. However, it need to save the msis setting at probe if smmu do not >> support hardware retention. >> >> Signed-off-by: Yisheng Xie>> --- >> drivers/iommu/arm-smmu-v3.c | 69 >> +++-- >> 1 file changed, 66 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c >> index 044df6e..6cb56d8 100644 >> --- a/drivers/iommu/arm-smmu-v3.c >> +++ b/drivers/iommu/arm-smmu-v3.c >> @@ -534,6 +534,11 @@ struct arm_smmu_strtab_cfg { >> u32strtab_base_cfg; >> }; >> +struct arm_smmu_msi_val { >> +u64doorbell; >> +u32data; >> +}; > > What does this do that struct msi_msg doesn't already (apart from take up > more space in an array)? Right, struct msi_msg can be used instead, and memcpy can be used when save the msi_msg. > >> + >> /* An SMMUv3 instance */ >> struct arm_smmu_device { >> struct device*dev; >> @@ -558,6 +563,7 @@ struct arm_smmu_device { >> #define ARM_SMMU_OPT_SKIP_PREFETCH(1 << 0) >> #define ARM_SMMU_OPT_PAGE0_REGS_ONLY(1 << 1) >> +#define ARM_SMMU_OPT_SW_RETENTION(1 << 2) >> u32options; >> struct arm_smmu_cmdqcmdq; >> @@ -587,6 +593,8 @@ struct arm_smmu_device { >> u32sync_count; >> +struct arm_smmu_msi_val*msi; >> +boolprobed; > > This looks really hacky. I'm sure there's probably enough driver model > information > to be able to identify the probe state from just the struct device, but > that's still > not the right way to go. If you need to know this, then it can only mean > we've got > one-time software state initialisation mixed in with the actual hardware > reset which > programs the software state into the device. Thus there should be some > refactoring to > properly separate those concerns. So you mean status enum should use instead? Maybe something like: enum arm_smmu_status { ARM_SMMU_INACTIVE; ARM_SMMU_ACTIVE; ARM_SMMU_SUSPEND; }; to indicate the status of device ? > >> boolbypass; >> /* IOMMU core code handle */ >> @@ -630,6 +638,7 @@ struct arm_smmu_option_prop { >> static struct arm_smmu_option_prop arm_smmu_options[] = { >> { ARM_SMMU_OPT_SKIP_PREFETCH, "hisilicon,broken-prefetch-cmd" }, >> { ARM_SMMU_OPT_PAGE0_REGS_ONLY, "cavium,cn9900-broken-page1-regspace"}, >> +{ ARM_SMMU_OPT_SW_RETENTION, "hisilicon,broken-hardware-retention" }, > > That seems a bit over-specific - there are going to be any number of SMMU > implementations/integrations > which may or may not implement hardware retention states. More crucially, > it's also backwards. Making > the driver assume that *every* SMMU implements hardware retention unless this > new DT property is present > is quite obviously completely wrong, especially for ACPI... > I was thought about remove the word *hisilicon* for other implement may also not have hardware retention. Anyway, this a wrong for ACPI cannot works without hardware retention. > The sensible thing to do is to implement suspend/resume support which works > in general, *then* consider > optimising it for cases where explicitly restoring the hardware state may be > skipped (if indeed it makes > a significant difference). Yes, we should make it common, what I was doubt is that whether should enable it by default or not, for someone who do not want do power gating at all when suspend, it may suffer from device reset when resume ? > Are there not already generic DT/ACPI properties for describing the retention > levels of different power states, which could be made use of here? AFAIK no, and I have just tried to find some clue from the document of DT/ACPI but do not find any usefull information. Do you have any idea or clue about it? >> { 0, NULL}, >> }; >> @@ -2228,7 +2237,8 @@ static void arm_smmu_write_msi_msg(struct msi_desc >> *desc, struct msi_msg *msg) >> phys_addr_t doorbell; >> struct device *dev = msi_desc_to_dev(desc); >> struct arm_smmu_device *smmu = dev_get_drvdata(dev); >> -phys_addr_t *cfg = arm_smmu_msi_cfg[desc->platform.msi_index]; >> +int msi_index = desc->platform.msi_index; >> +phys_addr_t *cfg = arm_smmu_msi_cfg[msi_index]; >> doorbell = (((u64)msg->address_hi) << 32) | msg->address_lo; >> doorbell &= MSI_CFG0_ADDR_MASK; >> @@ -2236,6 +2246,28 @@ static void arm_smmu_write_msi_msg(struct
Re: [PATCH 03/37] iommu/sva: Manage process address spaces
On 24/04/18 02:32, Sinan Kaya wrote: > On 2/12/2018 1:33 PM, Jean-Philippe Brucker wrote: >> /** >> * iommu_sva_device_init() - Initialize Shared Virtual Addressing for a >> device >> * @dev: the device >> @@ -129,7 +439,10 @@ EXPORT_SYMBOL_GPL(iommu_sva_device_shutdown); >> int iommu_sva_bind_device(struct device *dev, struct mm_struct *mm, int >> *pasid, >>unsigned long flags, void *drvdata) >> { >> +int i, ret; >> +struct io_mm *io_mm = NULL; >> struct iommu_domain *domain; >> +struct iommu_bond *bond = NULL, *tmp; >> struct iommu_param *dev_param = dev->iommu_param; >> >> domain = iommu_get_domain_for_dev(dev); >> @@ -145,7 +458,42 @@ int iommu_sva_bind_device(struct device *dev, struct >> mm_struct *mm, int *pasid, >> if (flags != (IOMMU_SVA_FEAT_PASID | IOMMU_SVA_FEAT_IOPF)) >> return -EINVAL; >> >> -return -ENOSYS; /* TODO */ >> +/* If an io_mm already exists, use it */ >> +spin_lock(_sva_lock); >> +idr_for_each_entry(_pasid_idr, io_mm, i) { >> +if (io_mm->mm != mm || !io_mm_get_locked(io_mm)) >> +continue; >> + >> +/* Is it already bound to this device? */ >> +list_for_each_entry(tmp, _mm->devices, mm_head) { >> +if (tmp->dev != dev) >> +continue; >> + >> +bond = tmp; >> +refcount_inc(>refs); >> +io_mm_put_locked(io_mm); >> +break; >> +} >> +break; >> +} >> +spin_unlock(_sva_lock); >> + >> +if (bond) > > Please return pasid when you find an io_mm that is already bound. Something > like > *pasid = io_mm->pasid should do the work here when bond is true. Right. I think we should also keep returning 0, not switch to -EEXIST or similar. So in next version a driver can call bind(devX, mmY) multiple times, but the first unbind() removes the bond. Thanks, Jean ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 11/12] swiotlb: move the SWIOTLB config symbol to lib/Kconfig
On Tue, Apr 24, 2018 at 08:47:27AM +0100, Russell King - ARM Linux wrote: > Therefore, the default state for SWIOTLB and hence NEED_SG_DMA_LENGTH > becomes 'y' on ARM, and any defconfig file that does not mention SWIOTLB > explicitly ends up with both these enabled. Indeed, sorry. > It does look a bit weird though - patch 10 arranged stuff so that we > didn't end up with SWIOTLB always enabled, but this patch reintroduces > that with the allowance that the user can disable if so desired. I am not very happy with that patch, but I have a hard time coming up with something saner. Bascially x86_64 and mips/loongson default to SWIOTLB=y but allow to deselect it, powerpc has it optional without any real dependency and defaults to n and everyone just selects it otherwise. I suspect the right thing is to just have it always one for x86_64 and loongson and have a ppc-specific option to enable it on powerpc so that we can always use select statements. I'll do that for the next round. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 11/12] swiotlb: move the SWIOTLB config symbol to lib/Kconfig
On Tue, Apr 24, 2018 at 08:55:49AM +0200, Christoph Hellwig wrote: > On Tue, Apr 24, 2018 at 12:52:05AM +0100, Russell King - ARM Linux wrote: > > On Mon, Apr 23, 2018 at 07:04:18PM +0200, Christoph Hellwig wrote: > > > This way we have one central definition of it, and user can select it as > > > needed. Note that we also add a second ARCH_HAS_SWIOTLB symbol to > > > indicate the architecture supports swiotlb at all, so that we can still > > > make the usage optional for a few architectures that want this feature > > > to be user selectable. > > > > > > Signed-off-by: Christoph Hellwig> > > > Hmm, this looks like we end up with NEED_SG_DMA_LENGTH=y on ARM by > > default, which probably isn't a good idea - ARM pre-dates the dma_length > > parameter in scatterlists, and I don't think all code is guaranteed to > > do the right thing if this is enabled. > > We shouldn't end up with NEED_SG_DMA_LENGTH=y on ARM by default. Your patch as sent would end up with: ARM selects ARCH_HAS_SWIOTLB SWIOTLB is defaulted to ARCH_HAS_SWIOTLB SWIOTLB selects NEED_SG_DMA_LENGTH due to: @@ -106,6 +106,7 @@ config ARM select REFCOUNT_FULL select RTC_LIB select SYS_SUPPORTS_APM_EMULATION + select ARCH_HAS_SWIOTLB and: +config SWIOTLB + bool "SWIOTLB support" + default ARCH_HAS_SWIOTLB + select NEED_SG_DMA_LENGTH Therefore, the default state for SWIOTLB and hence NEED_SG_DMA_LENGTH becomes 'y' on ARM, and any defconfig file that does not mention SWIOTLB explicitly ends up with both these enabled. > It is only select by ARM_DMA_USE_IOMMU before the patch, and it will > now also be selected by SWIOTLB, which for arm is never used or seleted > directly by anything but xen-swiotlb. See above. > Then again looking at the series there shouldn't be any need to > even select NEED_SG_DMA_LENGTH for swiotlb, as we'll never merge segments, > so I'll fix that up. That would help to avoid any regressions along the lines I've spotted by review. It does look a bit weird though - patch 10 arranged stuff so that we didn't end up with SWIOTLB always enabled, but this patch reintroduces that with the allowance that the user can disable if so desired. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 11/12] swiotlb: move the SWIOTLB config symbol to lib/Kconfig
On Tue, Apr 24, 2018 at 12:52:05AM +0100, Russell King - ARM Linux wrote: > On Mon, Apr 23, 2018 at 07:04:18PM +0200, Christoph Hellwig wrote: > > This way we have one central definition of it, and user can select it as > > needed. Note that we also add a second ARCH_HAS_SWIOTLB symbol to > > indicate the architecture supports swiotlb at all, so that we can still > > make the usage optional for a few architectures that want this feature > > to be user selectable. > > > > Signed-off-by: Christoph Hellwig> > Hmm, this looks like we end up with NEED_SG_DMA_LENGTH=y on ARM by > default, which probably isn't a good idea - ARM pre-dates the dma_length > parameter in scatterlists, and I don't think all code is guaranteed to > do the right thing if this is enabled. We shouldn't end up with NEED_SG_DMA_LENGTH=y on ARM by default. It is only select by ARM_DMA_USE_IOMMU before the patch, and it will now also be selected by SWIOTLB, which for arm is never used or seleted directly by anything but xen-swiotlb. Then again looking at the series there shouldn't be any need to even select NEED_SG_DMA_LENGTH for swiotlb, as we'll never merge segments, so I'll fix that up. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu