Skip to contentSkip to conversation

scatterlist arch cleanups

PATCH In review Christoph Hellwig 3 participants 10 messages Nov 9, 2018 – Dec 6, 2018

Subsystems (15)
lore
Share & tools
lore
#1 lore raw

PATCH 1/2 csky, h8300, riscv: remove <asm/scatterlist.h> leftovers

There has been no <asm/scatterlist.h> for a long time, which also means there is no point in using it from asm-generic.

---
 arch/csky/include/asm/Kbuild  | 1 -
 arch/h8300/include/asm/Kbuild | 1 -
 arch/riscv/include/asm/Kbuild | 1 -
 3 files changed, 3 deletions(-)
arch/csky/include/asm/Kbuild +0 -1
index 2a0abe8f2a35..7c48a123300d 100644
@@ -34,7 +34,6 @@ generic-y += pci.h
 generic-y += percpu.h
 generic-y += preempt.h
 generic-y += qrwlock.h
-generic-y += scatterlist.h
 generic-y += sections.h
 generic-y += serial.h
 generic-y += shm.h
arch/h8300/include/asm/Kbuild +0 -1
index a5d0b2991f47..32f0c8952147 100644
@@ -36,7 +36,6 @@ generic-y += parport.h
 generic-y += percpu.h
 generic-y += pgalloc.h
 generic-y += preempt.h
-generic-y += scatterlist.h
 generic-y += sections.h
 generic-y += serial.h
 generic-y += sizes.h
arch/riscv/include/asm/Kbuild +0 -1
index 6a646d9ea780..011cc7c7b3ad 100644
@@ -37,7 +37,6 @@ generic-y += poll.h
 generic-y += posix_types.h
 generic-y += preempt.h
 generic-y += resource.h
-generic-y += scatterlist.h
 generic-y += sections.h
 generic-y += sembuf.h
 generic-y += serial.h
Signature · 1 line
2.19.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] csky, h8300, riscv: remove <asm/scatterlist.h> leftovers

Quoted 39 lines · Christoph Hellwig

There has been no <asm/scatterlist.h> for a long time, which also means there is no point in using it from asm-generic.

---
 arch/csky/include/asm/Kbuild  | 1 -
 arch/h8300/include/asm/Kbuild | 1 -
 arch/riscv/include/asm/Kbuild | 1 -
 3 files changed, 3 deletions(-)
arch/csky/include/asm/Kbuild +0 -1
index 2a0abe8f2a35..7c48a123300d 100644
@@ -34,7 +34,6 @@ generic-y += pci.h
 generic-y += percpu.h
 generic-y += preempt.h
 generic-y += qrwlock.h
-generic-y += scatterlist.h
 generic-y += sections.h
 generic-y += serial.h
 generic-y += shm.h
arch/h8300/include/asm/Kbuild +0 -1
index a5d0b2991f47..32f0c8952147 100644
@@ -36,7 +36,6 @@ generic-y += parport.h
 generic-y += percpu.h
 generic-y += pgalloc.h
 generic-y += preempt.h
-generic-y += scatterlist.h
 generic-y += sections.h
 generic-y += serial.h
 generic-y += sizes.h
arch/riscv/include/asm/Kbuild +0 -0
index 6a646d9ea780..011cc7c7b3ad 100644

arch/riscv/include/asm/Kbuild generic-y += poll.h · line 42

Quoted 7 lines
arch/riscv/include/asm/Kbuild +0 -1
@@ -37,7 +37,6 @@ generic-y += poll.h
 generic-y += posix_types.h
 generic-y += preempt.h
 generic-y += resource.h
-generic-y += scatterlist.h
 generic-y += sections.h
 generic-y += sembuf.h
 generic-y += serial.h
#3 lore raw

Re: [PATCH 1/2] csky, h8300, riscv: remove <asm/scatterlist.h> leftovers

In reply to Christoph Hellwig

Looks like generic-y is mostly going away anyway, so I'm going to skip this to avoid conflicts with the kbuild tree.

#4 lore raw

PATCH 2/2 arch: switch the default on ARCH_HAS_SG_CHAIN

In reply to Christoph Hellwig

These days architectures are mostly out of the business of dealing with struct scatterlist at all, unless they have architecture specific iommu drivers. Replace the ARCH_HAS_SG_CHAIN symbol with a ARCH_NO_SG_CHAIN one only enabled for architectures with horrible legacy iommu drivers like alpha and parisc, and conditionally for arm which wants to keep it disable for legacy platforms.

---
 .../features/io/sg-chain/arch-support.txt     | 33 -------------------
 arch/alpha/Kconfig                            |  1 +
 arch/arc/Kconfig                              |  1 -
 arch/arm/Kconfig                              |  2 +-
 arch/arm64/Kconfig                            |  1 -
 arch/ia64/Kconfig                             |  1 -
 arch/parisc/Kconfig                           |  1 +
 arch/powerpc/Kconfig                          |  1 -
 arch/s390/Kconfig                             |  1 -
 arch/sparc/Kconfig                            |  1 -
 arch/x86/Kconfig                              |  1 -
 arch/xtensa/Kconfig                           |  1 -
 include/linux/scatterlist.h                   |  6 ++--
 lib/Kconfig                                   |  2 +-
 lib/scatterlist.c                             |  2 +-
 15 files changed, 8 insertions(+), 47 deletions(-)
 delete mode 100644 Documentation/features/io/sg-chain/arch-support.txt
Documentation/features/io/sg-chain/arch-support.txt deleted +0 -33
deleted file mode 100644
index 6554f0372c3f..000000000000
@@ -1,33 +0,0 @@
-#
-# Feature name:          sg-chain
-#         Kconfig:       ARCH_HAS_SG_CHAIN
-#         description:   arch supports chained scatter-gather lists
-#
-    -----------------------
-    |         arch |status|
-    -----------------------
-    |       alpha: | TODO |
-    |         arc: |  ok  |
-    |         arm: |  ok  |
-    |       arm64: |  ok  |
-    |         c6x: | TODO |
-    |       h8300: | TODO |
-    |     hexagon: | TODO |
-    |        ia64: |  ok  |
-    |        m68k: | TODO |
-    |  microblaze: | TODO |
-    |        mips: | TODO |
-    |       nds32: | TODO |
-    |       nios2: | TODO |
-    |    openrisc: | TODO |
-    |      parisc: | TODO |
-    |     powerpc: |  ok  |
-    |       riscv: | TODO |
-    |        s390: |  ok  |
-    |          sh: | TODO |
-    |       sparc: |  ok  |
-    |          um: | TODO |
-    |   unicore32: | TODO |
-    |         x86: |  ok  |
-    |      xtensa: | TODO |
-    -----------------------
arch/alpha/Kconfig +1 -0
index 5b4f88363453..a7e748a46c18 100644
@@ -5,6 +5,7 @@ config ALPHA
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select ARCH_NO_PREEMPT
+	select ARCH_NO_SG_CHAIN
 	select ARCH_USE_CMPXCHG_LOCKREF
 	select HAVE_AOUT
 	select HAVE_IDE
arch/arc/Kconfig +0 -1
index c9e2a1323536..fd48d698da29 100644
@@ -13,7 +13,6 @@ config ARC
 	select ARCH_HAS_PTE_SPECIAL
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
 	select BUILDTIME_EXTABLE_SORT
 	select CLONE_BACKWARDS
arch/arm/Kconfig +1 -1
index 91be74d8df65..199eb62230b0 100644
@@ -19,6 +19,7 @@ config ARM
 	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_HAS_GCOV_PROFILE_ALL
 	select ARCH_MIGHT_HAVE_PC_PARPORT
+	select ARCH_NO_SG_CHAIN if !ARM_HAS_SG_CHAIN
 	select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7
 	select ARCH_SUPPORTS_ATOMIC_RMW
@@ -118,7 +119,6 @@ config ARM
 	  <http://www.arm.linux.org.uk/>.
 
 config ARM_HAS_SG_CHAIN
-	select ARCH_HAS_SG_CHAIN
 	bool
 
 config ARM_DMA_USE_IOMMU
arch/arm64/Kconfig +0 -1
index 787d7850e064..4c851b3a7b7c 100644
@@ -23,7 +23,6 @@ config ARM64
 	select ARCH_HAS_MEMBARRIER_SYNC_CORE
 	select ARCH_HAS_PTE_SPECIAL
 	select ARCH_HAS_SET_MEMORY
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
arch/ia64/Kconfig +0 -1
index 36773def6920..d6f203658994 100644
@@ -29,7 +29,6 @@ config IA64
 	select HAVE_MEMBLOCK_NODE_MAP
 	select HAVE_VIRT_CPU_ACCOUNTING
 	select ARCH_HAS_DMA_MARK_CLEAN
-	select ARCH_HAS_SG_CHAIN
 	select VIRT_TO_BUS
 	select ARCH_DISCARD_MEMBLOCK
 	select GENERIC_IRQ_PROBE
arch/parisc/Kconfig +1 -0
index 92a339ee28b3..428ee50fc3db 100644
@@ -11,6 +11,7 @@ config PARISC
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
+	select ARCH_NO_SG_CHAIN
 	select ARCH_SUPPORTS_MEMORY_FAILURE
 	select RTC_CLASS
 	select RTC_DRV_GENERIC
arch/powerpc/Kconfig +0 -1
index 8be31261aec8..4bc8edd83cee 100644
@@ -138,7 +138,6 @@ config PPC
 	select ARCH_HAS_PTE_SPECIAL
 	select ARCH_HAS_MEMBARRIER_CALLBACKS
 	select ARCH_HAS_SCALED_CPUTIME		if VIRT_CPU_ACCOUNTING_NATIVE && PPC64
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_HAS_STRICT_KERNEL_RWX	if ((PPC_BOOK3S_64 || PPC32) && !RELOCATABLE && !HIBERNATION)
 	select ARCH_HAS_TICK_BROADCAST		if GENERIC_CLOCKEVENTS_BROADCAST
 	select ARCH_HAS_UACCESS_FLUSHCACHE	if PPC64
arch/s390/Kconfig +0 -1
index 5173366af8f3..5624e8607054 100644
@@ -73,7 +73,6 @@ config S390
 	select ARCH_HAS_KCOV
 	select ARCH_HAS_PTE_SPECIAL
 	select ARCH_HAS_SET_MEMORY
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
arch/sparc/Kconfig +0 -1
index 490b2c95c212..8853b6ceae17 100644
@@ -40,7 +40,6 @@ config SPARC
 	select MODULES_USE_ELF_RELA
 	select ODD_RT_SIGACTION
 	select OLD_SIGSUSPEND
-	select ARCH_HAS_SG_CHAIN
 	select CPU_NO_EFFICIENT_FFS
 	select LOCKDEP_SMALL if LOCKDEP
 	select NEED_DMA_MAP_STATE
arch/x86/Kconfig +0 -1
index ba7e3464ee92..6faab6f9b57e 100644
@@ -66,7 +66,6 @@ config X86
 	select ARCH_HAS_UACCESS_FLUSHCACHE	if X86_64
 	select ARCH_HAS_UACCESS_MCSAFE		if X86_64 && X86_MCE
 	select ARCH_HAS_SET_MEMORY
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
 	select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
arch/xtensa/Kconfig +0 -1
index d29b7365da8d..e3387919eb22 100644
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 config XTENSA
 	def_bool y
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
 	select ARCH_NO_COHERENT_DMA_MMAP if !MMU
include/linux/scatterlist.h +3 -3
index 093aa57120b0..b96f0d0b5b8f 100644
@@ -324,10 +324,10 @@ size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents,
  * Like SG_CHUNK_SIZE, but for archs that have sg chaining. This limit
  * is totally arbitrary, a setting of 2048 will get you at least 8mb ios.
  */
-#ifdef CONFIG_ARCH_HAS_SG_CHAIN
-#define SG_MAX_SEGMENTS	2048
-#else
+#ifdef CONFIG_ARCH_NO_SG_CHAIN
 #define SG_MAX_SEGMENTS	SG_CHUNK_SIZE
+#else
+#define SG_MAX_SEGMENTS	2048
 #endif
 
 #ifdef CONFIG_SG_POOL
lib/Kconfig +1 -1
index a9965f4af4dd..d5a5e2ebf286 100644
@@ -577,7 +577,7 @@ config SG_POOL
 # sg chaining option
 #
 
-config ARCH_HAS_SG_CHAIN
+config ARCH_NO_SG_CHAIN
 	def_bool n
 
 config ARCH_HAS_PMEM_API
lib/scatterlist.c +1 -1
index 7c6096a71704..9ba349e775ef 100644
@@ -271,7 +271,7 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents,
 
 	if (nents == 0)
 		return -EINVAL;
-#ifndef CONFIG_ARCH_HAS_SG_CHAIN
+#ifdef CONFIG_ARCH_NO_SG_CHAIN
 	if (WARN_ON_ONCE(nents > max_ents))
 		return -EINVAL;
 #endif
Signature · 1 line
2.19.1
#5 lore raw

Re: [PATCH 2/2] arch: switch the default on ARCH_HAS_SG_CHAIN

Quoted 18 lines · Christoph Hellwig

These days architectures are mostly out of the business of dealing with struct scatterlist at all, unless they have architecture specific iommu drivers. Replace the ARCH_HAS_SG_CHAIN symbol with a ARCH_NO_SG_CHAIN one only enabled for architectures with horrible legacy iommu drivers like alpha and parisc, and conditionally for arm which wants to keep it disable for legacy platforms.

---
 .../features/io/sg-chain/arch-support.txt     | 33 -------------------
 arch/alpha/Kconfig                            |  1 +
 arch/arc/Kconfig                              |  1 -
 arch/arm/Kconfig                              |  2 +-
 arch/arm64/Kconfig                            |  1 -
 arch/ia64/Kconfig                             |  1 -
 arch/parisc/Kconfig                           |  1 +
 arch/powerpc/Kconfig                          |  1 -
 arch/s390/Kconfig                             |  1 -
Quoted 8 lines
 arch/sparc/Kconfig                            |  1 -
 arch/x86/Kconfig                              |  1 -
 arch/xtensa/Kconfig                           |  1 -
 include/linux/scatterlist.h                   |  6 ++--
 lib/Kconfig                                   |  2 +-
 lib/scatterlist.c                             |  2 +-
 15 files changed, 8 insertions(+), 47 deletions(-)
 delete mode 100644 Documentation/features/io/sg-chain/arch-support.txt

As far as I can tell, it looks like m68k, mips, and powerpc mention an IOMMU in their ports, don't set ARCH_HAS_SG_CHAIN, and with this patch set won't set ARCH_NO_SG_CHAIN. The issue is that I'm not sure how to determine what constitutes a horrible legacy IOMMU, at least with respect to not being able to use scatterlist chaining.

I poked through the 68k stuff (sun3 and sun3x) and the only thing I see that's odd is that DVMA_PAGE_SHIFT is 13. That matches PAGE_SHIFT for the subarch, though, so I don't think it's an issue. It looks like the mention in MIPS is trivial, so that should be fine. There's a lot in the PC port so I just glanced at it. I assume it's OK, but I did see an explicit mention of SG in their generic IOMMU. There's a lot of flavors here so I'm not sure how well they all work.

I don't really think that's enough for my reviewed-by tag, so feel free to give me some pointers if you're looking for one -- I'd be happy to lean about IOMMUs (particularly broken ones, as that might help prevent us from designing a broken one), I'm just not sure what I'm looking for.

I'm going to assume you're going to merge this and I'll drop the RISC-V patch that turns on ARCH_HAS_SG_CHAIN.

Thanks!

Quoted 223 lines
Documentation/features/io/sg-chain/arch-support.txt deleted +0 -33
deleted file mode 100644
index 6554f0372c3f..000000000000
@@ -1,33 +0,0 @@
-#
-# Feature name:          sg-chain
-#         Kconfig:       ARCH_HAS_SG_CHAIN
-#         description:   arch supports chained scatter-gather lists
-#
-    -----------------------
-    |         arch |status|
-    -----------------------
-    |       alpha: | TODO |
-    |         arc: |  ok  |
-    |         arm: |  ok  |
-    |       arm64: |  ok  |
-    |         c6x: | TODO |
-    |       h8300: | TODO |
-    |     hexagon: | TODO |
-    |        ia64: |  ok  |
-    |        m68k: | TODO |
-    |  microblaze: | TODO |
-    |        mips: | TODO |
-    |       nds32: | TODO |
-    |       nios2: | TODO |
-    |    openrisc: | TODO |
-    |      parisc: | TODO |
-    |     powerpc: |  ok  |
-    |       riscv: | TODO |
-    |        s390: |  ok  |
-    |          sh: | TODO |
-    |       sparc: |  ok  |
-    |          um: | TODO |
-    |   unicore32: | TODO |
-    |         x86: |  ok  |
-    |      xtensa: | TODO |
-    -----------------------
arch/alpha/Kconfig +1 -0
index 5b4f88363453..a7e748a46c18 100644
@@ -5,6 +5,7 @@ config ALPHA
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select ARCH_NO_PREEMPT
+	select ARCH_NO_SG_CHAIN
 	select ARCH_USE_CMPXCHG_LOCKREF
 	select HAVE_AOUT
 	select HAVE_IDE
arch/arc/Kconfig +0 -1
index c9e2a1323536..fd48d698da29 100644
@@ -13,7 +13,6 @@ config ARC
 	select ARCH_HAS_PTE_SPECIAL
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
 	select BUILDTIME_EXTABLE_SORT
 	select CLONE_BACKWARDS
arch/arm/Kconfig +1 -1
index 91be74d8df65..199eb62230b0 100644
@@ -19,6 +19,7 @@ config ARM
 	select ARCH_HAVE_CUSTOM_GPIO_H
 	select ARCH_HAS_GCOV_PROFILE_ALL
 	select ARCH_MIGHT_HAVE_PC_PARPORT
+	select ARCH_NO_SG_CHAIN if !ARM_HAS_SG_CHAIN
 	select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7
 	select ARCH_SUPPORTS_ATOMIC_RMW
@@ -118,7 +119,6 @@ config ARM
 	  <http://www.arm.linux.org.uk/>.
 
 config ARM_HAS_SG_CHAIN
-	select ARCH_HAS_SG_CHAIN
 	bool
 
 config ARM_DMA_USE_IOMMU
arch/arm64/Kconfig +0 -1
index 787d7850e064..4c851b3a7b7c 100644
@@ -23,7 +23,6 @@ config ARM64
 	select ARCH_HAS_MEMBARRIER_SYNC_CORE
 	select ARCH_HAS_PTE_SPECIAL
 	select ARCH_HAS_SET_MEMORY
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
arch/ia64/Kconfig +0 -1
index 36773def6920..d6f203658994 100644
@@ -29,7 +29,6 @@ config IA64
 	select HAVE_MEMBLOCK_NODE_MAP
 	select HAVE_VIRT_CPU_ACCOUNTING
 	select ARCH_HAS_DMA_MARK_CLEAN
-	select ARCH_HAS_SG_CHAIN
 	select VIRT_TO_BUS
 	select ARCH_DISCARD_MEMBLOCK
 	select GENERIC_IRQ_PROBE
arch/parisc/Kconfig +1 -0
index 92a339ee28b3..428ee50fc3db 100644
@@ -11,6 +11,7 @@ config PARISC
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
+	select ARCH_NO_SG_CHAIN
 	select ARCH_SUPPORTS_MEMORY_FAILURE
 	select RTC_CLASS
 	select RTC_DRV_GENERIC
arch/powerpc/Kconfig +0 -1
index 8be31261aec8..4bc8edd83cee 100644
@@ -138,7 +138,6 @@ config PPC
 	select ARCH_HAS_PTE_SPECIAL
 	select ARCH_HAS_MEMBARRIER_CALLBACKS
 	select ARCH_HAS_SCALED_CPUTIME		if VIRT_CPU_ACCOUNTING_NATIVE && PPC64
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_HAS_STRICT_KERNEL_RWX	if ((PPC_BOOK3S_64 || PPC32) && !RELOCATABLE && !HIBERNATION)
 	select ARCH_HAS_TICK_BROADCAST		if GENERIC_CLOCKEVENTS_BROADCAST
 	select ARCH_HAS_UACCESS_FLUSHCACHE	if PPC64
arch/s390/Kconfig +0 -1
index 5173366af8f3..5624e8607054 100644
@@ -73,7 +73,6 @@ config S390
 	select ARCH_HAS_KCOV
 	select ARCH_HAS_PTE_SPECIAL
 	select ARCH_HAS_SET_MEMORY
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
arch/sparc/Kconfig +0 -1
index 490b2c95c212..8853b6ceae17 100644
@@ -40,7 +40,6 @@ config SPARC
 	select MODULES_USE_ELF_RELA
 	select ODD_RT_SIGACTION
 	select OLD_SIGSUSPEND
-	select ARCH_HAS_SG_CHAIN
 	select CPU_NO_EFFICIENT_FFS
 	select LOCKDEP_SMALL if LOCKDEP
 	select NEED_DMA_MAP_STATE
arch/x86/Kconfig +0 -1
index ba7e3464ee92..6faab6f9b57e 100644
@@ -66,7 +66,6 @@ config X86
 	select ARCH_HAS_UACCESS_FLUSHCACHE	if X86_64
 	select ARCH_HAS_UACCESS_MCSAFE		if X86_64 && X86_MCE
 	select ARCH_HAS_SET_MEMORY
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
 	select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
arch/xtensa/Kconfig +0 -1
index d29b7365da8d..e3387919eb22 100644
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 config XTENSA
 	def_bool y
-	select ARCH_HAS_SG_CHAIN
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
 	select ARCH_NO_COHERENT_DMA_MMAP if !MMU
include/linux/scatterlist.h +3 -3
index 093aa57120b0..b96f0d0b5b8f 100644
@@ -324,10 +324,10 @@ size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents,
  * Like SG_CHUNK_SIZE, but for archs that have sg chaining. This limit
  * is totally arbitrary, a setting of 2048 will get you at least 8mb ios.
  */
-#ifdef CONFIG_ARCH_HAS_SG_CHAIN
-#define SG_MAX_SEGMENTS	2048
-#else
+#ifdef CONFIG_ARCH_NO_SG_CHAIN
 #define SG_MAX_SEGMENTS	SG_CHUNK_SIZE
+#else
+#define SG_MAX_SEGMENTS	2048
 #endif
 
 #ifdef CONFIG_SG_POOL
lib/Kconfig +1 -1
index a9965f4af4dd..d5a5e2ebf286 100644
@@ -577,7 +577,7 @@ config SG_POOL
 # sg chaining option
 #
 
-config ARCH_HAS_SG_CHAIN
+config ARCH_NO_SG_CHAIN
 	def_bool n
 
 config ARCH_HAS_PMEM_API
lib/scatterlist.c +1 -1
index 7c6096a71704..9ba349e775ef 100644
@@ -271,7 +271,7 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents,
 
 	if (nents == 0)
 		return -EINVAL;
-#ifndef CONFIG_ARCH_HAS_SG_CHAIN
+#ifdef CONFIG_ARCH_NO_SG_CHAIN
 	if (WARN_ON_ONCE(nents > max_ents))
 		return -EINVAL;
 #endif
#6 lore raw

Re: [PATCH 2/2] arch: switch the default on ARCH_HAS_SG_CHAIN

Quoted 3 lines · Palmer Dabbelt

As far as I can tell, it looks like m68k, mips, and powerpc mention an IOMMU in their ports, don't set ARCH_HAS_SG_CHAIN, and with this patch set won't set ARCH_NO_SG_CHAIN.

m68k has no iommu, and not operations that operate on a scatterlist.

mips has a trivial iommu driver (jazzdma), but I wrote the current instance of it, nad it is fine.

powerpc has various iommu, but actually enables ARCH_HAS_SG_CHAIN unconditionally.

Quoted 3 lines

The issue is that I'm not sure how to
determine what constitutes a horrible legacy IOMMU, at least with respect to not being able to use scatterlist chaining.

It basically means someone is iterating using manual pointer arithmetics over a multi-element scatterlist instead of using the sg_next and for_each_sg helpers.

Reviewed-by
#7 lore raw

Re: [PATCH 2/2] arch: switch the default on ARCH_HAS_SG_CHAIN

Quoted 13 lines · Christoph Hellwig
Quoted 3 lines · Palmer Dabbelt

As far as I can tell, it looks like m68k, mips, and powerpc mention an IOMMU in their ports, don't set ARCH_HAS_SG_CHAIN, and with this patch set won't set ARCH_NO_SG_CHAIN.

m68k has no iommu, and not operations that operate on a scatterlist.

mips has a trivial iommu driver (jazzdma), but I wrote the current instance of it, nad it is fine.

powerpc has various iommu, but actually enables ARCH_HAS_SG_CHAIN unconditionally.

Quoted 7 lines
Quoted 3 lines

The issue is that I'm not sure how to
determine what constitutes a horrible legacy IOMMU, at least with respect to not being able to use scatterlist chaining.

It basically means someone is iterating using manual pointer arithmetics over a multi-element scatterlist instead of using the sg_next and for_each_sg helpers.

Ah, OK. In that case, feel free to drop a

in there, if you think it helps any.

Thanks for the help!