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

2018-12-06 Thread Christoph Hellwig
I've picked this up for the dma-mapping for-next tree.
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


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

2018-11-19 Thread Palmer Dabbelt

On Mon, 19 Nov 2018 05:58:52 PST (-0800), Christoph Hellwig wrote:

On Fri, Nov 16, 2018 at 08:52:14AM -0800, Palmer Dabbelt wrote:

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.


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

Reviewed-by: Palmer Dabbelt 

in there, if you think it helps any.

Thanks for the help!
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


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

2018-11-19 Thread Christoph Hellwig
On Fri, Nov 16, 2018 at 08:52:14AM -0800, Palmer Dabbelt wrote:
> 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.

> 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.
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


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

2018-11-16 Thread Palmer Dabbelt

On Fri, 09 Nov 2018 01:00:08 PST (-0800), Christoph Hellwig wrote:

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.

Signed-off-by: Christoph Hellwig 
---
 .../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


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!


diff --git a/Documentation/features/io/sg-chain/arch-support.txt 
b/Documentation/features/io/sg-chain/arch-support.txt
deleted file mode 100644
index 6554f0372c3f..
--- a/Documentation/features/io/sg-chain/arch-support.txt
+++ /dev/null
@@ -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 |
----
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 5b4f88363453..a7e748a46c18 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -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
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index c9e2a1323536..fd48d698da29 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -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
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 91be74d8df65..199eb62230b0 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -19,6 +19,7 @@ config ARM
select ARCH_HAVE_CUSTOM_GPIO_H
select 

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

2018-11-09 Thread 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.

Signed-off-by: Christoph Hellwig 
---
 .../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

diff --git a/Documentation/features/io/sg-chain/arch-support.txt 
b/Documentation/features/io/sg-chain/arch-support.txt
deleted file mode 100644
index 6554f0372c3f..
--- a/Documentation/features/io/sg-chain/arch-support.txt
+++ /dev/null
@@ -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 |
----
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 5b4f88363453..a7e748a46c18 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -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
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index c9e2a1323536..fd48d698da29 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -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
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 91be74d8df65..199eb62230b0 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -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
  .
 
 config ARM_HAS_SG_CHAIN
-   select ARCH_HAS_SG_CHAIN
bool
 
 config ARM_DMA_USE_IOMMU
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 787d7850e064..4c851b3a7b7c 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -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
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 36773def6920..d6f203658994 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -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