Hi Christoph,
On Fri, Dec 29, 2017 at 9:18 AM, Christoph Hellwig wrote:
> Roughly based on the x86 pci-nommu implementation.
>
> Signed-off-by: Christoph Hellwig
Thanks for your patch!
> --- a/lib/dma-direct.c
> +++ b/lib/dma-direct.c
> @@ -9,6 +9,24 @@
> #include
> #include
>
> +#define D
On 29/12/17 08:18, Christoph Hellwig wrote:
> Almost every architecture supports a direct dma mapping implementation,
> where no iommu is used and the device dma address is a 1:1 mapping to
> the physical address or has a simple linear offset. Currently the
> code for this implementation is most d
Hi Christoph,
On Fri, Dec 29, 2017 at 7:18 PM, Christoph Hellwig wrote:
> This frees the dma_direct_* namespace for a generic implementation.
Don't you mean "dma_nommu" not "dma_microblaze" in the subject line?
Thanks,
--
Julian Calaby
Email: julian.cal...@gmail.com
Profile: http://www.googl
The generic swiotlb_alloc and swiotlb_free routines already take care
of CMA allocations and adding GFP_DMA32 where needed, so use them
instead of the arm specific helpers.
Signed-off-by: Christoph Hellwig
---
arch/arm64/Kconfig | 1 +
arch/arm64/mm/dma-mapping.c | 46 +++--
These days the coherent DMA mask is always set, so don't work around the
lack of it.
Signed-off-by: Christoph Hellwig
---
lib/swiotlb.c | 10 +++---
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index e0b8980334c3..a14fff30ee9d 100644
--- a/lib/s
All these symbols are only used by arch dma_ops implementations or
xen-swiotlb. None of which can be modular.
Signed-off-by: Christoph Hellwig
---
lib/swiotlb.c | 13 -
1 file changed, 13 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 77a40b508db8..823e1055a394 10064
Signed-off-by: Christoph Hellwig
---
lib/dma-direct.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index d0266b39788b..ab81de3ac1d3 100644
--- a/lib/dma-direct.c
+++ b/lib/dma-direct.c
@@ -39,7 +39,7 @@ static void *dma_direct_alloc(struc
All dma_ops implementations used on x86 now take care of setting their own
required GFP_ masks for the allocation. And given that the common code
now clears harmful flags itself that means we can stop the flags in all
the iommu implementations as well.
Signed-off-by: Christoph Hellwig
---
arch/
We want to use the dma_direct_ namespace for a generic implementation,
so rename powerpc to the second best choice: dma_nommu_.
Signed-off-by: Christoph Hellwig
---
arch/powerpc/include/asm/dma-mapping.h| 8 ++--
arch/powerpc/kernel/dma-iommu.c | 2 +-
arch/powerpc/kernel/dma-swi
If we got back an allocation that wasn't inside the support coherent mask,
retry the allocation using GFP_DMA.
Based on the x86 code.
Signed-off-by: Christoph Hellwig
---
lib/dma-direct.c | 25 -
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/lib/dma-direc
tile uses ZONE_DMA for allocations below 32-bits. These days we
name the zone for that ZONE_DMA32, which will allow to use the
dma-direct and generic swiotlb code as-is, so rename it.
Signed-off-by: Christoph Hellwig
---
arch/tile/Kconfig | 2 +-
arch/tile/kernel/pci-dma.c | 4 ++--
ar
Try the CMA allocator for coherent allocations if supported.
Roughly modelled after the x86 code.
Signed-off-by: Christoph Hellwig
---
lib/dma-direct.c | 24 ++--
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index ddd9dcf
Unused now that everyone uses swiotlb_{alloc,free}.
Signed-off-by: Christoph Hellwig
---
include/linux/swiotlb.h | 8
lib/swiotlb.c | 41 -
2 files changed, 49 deletions(-)
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
nlm_swiotlb_dma_ops is unused code, so the whole swiotlb support is dead.
If it gets resurrected at some point it should use the generic
swiotlb_dma_ops instead.
Signed-off-by: Christoph Hellwig
---
arch/mips/include/asm/netlogic/common.h | 3 --
arch/mips/netlogic/Kconfig | 5 --
arm64 uses ZONE_DMA for allocations below 32-bits. These days we
name the zone for that ZONE_DMA32, which will allow to use the
dma-direct and generic swiotlb code as-is, so rename it.
Signed-off-by: Christoph Hellwig
---
arch/arm64/Kconfig | 2 +-
arch/arm64/mm/dma-mapping.c | 6 +++
Replace the bare-bones h8300 direct dma mapping implementation with
the fully featured generic dma-direct one.
Signed-off-by: Christoph Hellwig
---
arch/h8300/Kconfig | 1 +
arch/h8300/include/asm/Kbuild| 1 +
arch/h8300/include/asm/dma-mapping.h | 12 ---
arch/h8
These days all devices should have a DMA coherent mask, and most dma_ops
implementations rely on that fact. But just to be sure add an assert to
ring the warning bell if that is not the case.
Signed-off-by: Christoph Hellwig
---
include/linux/dma-mapping.h | 1 +
1 file changed, 1 insertion(+)
These are identical to the tile ops, and would also support CMA
if enabled on tile.
Signed-off-by: Christoph Hellwig
---
arch/tile/Kconfig | 1 +
arch/tile/kernel/pci-dma.c | 36 +++-
2 files changed, 4 insertions(+), 33 deletions(-)
diff --git a/arch/t
These already include the GFP_DMA/GFP_DMA32 usage, and will use CMA
memory if enabled, thus avoiding the GFP_NORETRY hack.
Signed-off-by: Christoph Hellwig
---
arch/mips/cavium-octeon/Kconfig | 1 +
arch/mips/cavium-octeon/dma-octeon.c | 26 +++---
arch/mips/l
Signed-off-by: Christoph Hellwig
---
arch/hexagon/include/asm/dma-mapping.h | 7 ---
arch/hexagon/kernel/dma.c | 1 +
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/arch/hexagon/include/asm/dma-mapping.h
b/arch/hexagon/include/asm/dma-mapping.h
index 5208de242e79.
Always returning 1 is the same behavior as not supplying a method at all.
Signed-off-by: Christoph Hellwig
---
arch/microblaze/kernel/dma.c | 6 --
arch/parisc/kernel/pci-dma.c | 7 ---
2 files changed, 13 deletions(-)
diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/d
The generic version now takes dma_pfn_offset into account, so there is no
more need for an architecture override.
Signed-off-by: Christoph Hellwig
---
arch/arm64/include/asm/dma-mapping.h | 9 -
1 file changed, 9 deletions(-)
diff --git a/arch/arm64/include/asm/dma-mapping.h
b/arch/arm
To implement the x86 forbid_dac and iommu_sac_force we want an arch hook
so that it can apply the global options across all dma_map_ops
implementations.
Signed-off-by: Christoph Hellwig
---
arch/x86/include/asm/dma-mapping.h | 3 +++
arch/x86/kernel/pci-dma.c | 19 ---
Move the few remaining bits of swiotlb glue towards their callers,
and remove the pointless on ia64 swiotlb variable.
Signed-off-by: Christoph Hellwig
---
arch/ia64/include/asm/dma-mapping.h | 1 -
arch/ia64/include/asm/swiotlb.h | 18 --
arch/ia64/kernel/dma-mapping.c
These are identical to the ia64 ops, and would also support CMA
if enabled on ia64.
Signed-off-by: Christoph Hellwig
---
arch/ia64/Kconfig| 5 +
arch/ia64/hp/common/hwsw_iommu.c | 4 ++--
arch/ia64/hp/common/sba_iommu.c | 6 +++---
arch/ia64/kernel/pci-swiotlb.c | 38 ++
ia64 uses ZONE_DMA for allocations below 32-bits. These days we
name the zone for that ZONE_DMA32, which will allow to use the
dma-direct and generic swiotlb code as-is, so rename it.
Signed-off-by: Christoph Hellwig
---
arch/ia64/Kconfig | 2 +-
arch/ia64/kernel/pci-swiotlb.c | 2
Both the swiotlb and the dma-direct code already call into phys_to_dma
to translate the DMA address. So the sta2x11 into phys_to_dma and
dma_to_phys are enough to handle this "special" device, and we can use
the plain old swiotlb ops.
Signed-off-by: Christoph Hellwig
---
arch/x86/include/asm/de
The file is only compiled if CONFIG_INTEL_IOMMU is set to start with.
Signed-off-by: Christoph Hellwig
---
arch/ia64/kernel/pci-dma.c | 7 ---
1 file changed, 7 deletions(-)
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index 35e0cad33b7d..b5df084c0af4 100644
--- a/ar
These are identical to the unicore32 ops, and would also support CMA
if enabled on unicore32.
Signed-off-by: Christoph Hellwig
---
arch/unicore32/include/asm/dma-mapping.h | 9 +-
arch/unicore32/mm/Kconfig| 1 +
arch/unicore32/mm/Makefile | 2 --
arch/unicore
Gіve the basic phys_to_dma and dma_to_phys helpers a __-prefix and add
the memory encryption mask to the non-prefixed versions. Use the
__-prefixed versions directly instead of clearing the mask again in
various places.
With that in place the generic dma-direct routines can be used to
allocate no
Now that set_memory_decrypted is always available we can just call
it directly.
Signed-off-by: Christoph Hellwig
---
arch/x86/include/asm/mem_encrypt.h | 2 --
arch/x86/mm/mem_encrypt.c | 9 -
lib/swiotlb.c | 12 ++--
3 files changed, 6 insertions(
Signed-off-by: Christoph Hellwig
---
include/linux/set_memory.h | 12
1 file changed, 12 insertions(+)
diff --git a/include/linux/set_memory.h b/include/linux/set_memory.h
index e5140648f638..da5178216da5 100644
--- a/include/linux/set_memory.h
+++ b/include/linux/set_memory.h
@@ -1
Factor out a new swiotlb_alloc_buffer helper that allocates DMA coherent
memory from the swiotlb bounce buffer.
This allows to simplify the swiotlb_alloc implemenation that uses
dma_direct_alloc to try to allocate a reachable buffer first.
Signed-off-by: Christoph Hellwig
---
lib/swiotlb.c | 10
We'll need that name for a generic implementation soon.
Signed-off-by: Christoph Hellwig
---
arch/powerpc/include/asm/swiotlb.h | 2 +-
arch/powerpc/kernel/dma-swiotlb.c | 4 ++--
arch/powerpc/kernel/dma.c | 2 +-
arch/powerpc/sysdev/fsl_pci.c | 2 +-
4 files changed, 5 insertions
We'll need that name for a generic implementation soon.
Signed-off-by: Christoph Hellwig
---
arch/ia64/hp/common/hwsw_iommu.c | 4 ++--
arch/ia64/hp/common/sba_iommu.c | 6 +++---
arch/ia64/kernel/pci-swiotlb.c | 6 +++---
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/ia
Factor out a new swiotlb_free_buffer helper that checks if an address
is allocated from the swiotlb bounce buffer, and if yes frees it.
This allows to simplify the swiotlb_free implemenation that uses
dma_direct_free to free the non-bounce buffer allocations.
Signed-off-by: Christoph Hellwig
---
Signed-off-by: Christoph Hellwig
---
arch/powerpc/kernel/dma-swiotlb.c | 2 +-
arch/x86/kernel/pci-swiotlb.c | 2 +-
include/linux/swiotlb.h | 4 ++--
lib/swiotlb.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kernel/dma-swi
To properly reject too small DMA masks based on the addressability of the
bounce buffer.
Signed-off-by: Christoph Hellwig
---
lib/swiotlb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 9c100f0173bf..e0b8980334c3 100644
--- a/lib/swiotlb.c
+++ b/lib/swio
Including the useful helpers for coherent allocations that first try the
full blown direct mapping.
Signed-off-by: Christoph Hellwig
---
arch/x86/include/asm/swiotlb.h | 8
arch/x86/kernel/pci-swiotlb.c | 45 --
arch/x86/pci/sta2x11-fixup.c |
We'll need that name for a generic implementation soon.
Signed-off-by: Christoph Hellwig
---
arch/arm64/mm/dma-mapping.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index f3a637b98487..6840426bbe77 100644
--- a
This adds support for CMA allocations, but is otherwise identical.
Signed-off-by: Christoph Hellwig
---
drivers/iommu/Kconfig | 1 +
drivers/iommu/amd_iommu.c | 27 +--
2 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/drivers/iommu/Kconfig b/drivers/i
cris currently has an incomplete direct mapping dma_map_ops implementation
is PCI support is enabled. Replace it with the fully feature generic
dma-direct implementation.
Signed-off-by: Christoph Hellwig
---
arch/cris/Kconfig | 4 ++
arch/cris/arch-v32/drivers/pci/Makefil
The generic dma-direct implementation is now functionally equivalent to
the x86 nommu dma_map implementation, so switch over to using it.
Note that the various iommu drivers are switched from x86_dma_supported
to dma_direct_supported to provide identical functionality, although the
checks looks fa
This simplifies the code a bit, and prepares for future cleanups.
Signed-off-by: Christoph Hellwig
---
drivers/iommu/Kconfig | 1 +
drivers/iommu/intel-iommu.c | 17 -
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kcon
These days all devices (including the ISA fallback device) have a coherent
DMA mask set, so remove the workaround.
Signed-off-by: Christoph Hellwig
---
arch/x86/include/asm/dma-mapping.h | 18 ++
arch/x86/kernel/pci-dma.c | 10 --
arch/x86/mm/mem_encrypt.c
Don't rely on the gfp mask from dma_alloc_coherent_gfp_flags to make the
fallback decision, and streamline the code flow a bit.
Signed-off-by: Christoph Hellwig
---
arch/x86/kernel/amd_gart_64.c | 36 ++--
1 file changed, 18 insertions(+), 18 deletions(-)
diff --
Signed-off-by: Christoph Hellwig
---
include/linux/dma-direct.h | 1 +
lib/dma-direct.c | 19 +++
2 files changed, 20 insertions(+)
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index 4788bf0bf683..bcdb1a3e4b1f 100644
--- a/include/linux/dma-dire
So that they don't need to indirect through the operation vector.
Signed-off-by: Christoph Hellwig
---
arch/arm/mm/dma-mapping-nommu.c | 9 +++--
include/linux/dma-direct.h | 5 +
lib/dma-direct.c| 6 +++---
3 files changed, 11 insertions(+), 9 deletions(-)
diff --g
Signed-off-by: Christoph Hellwig
---
lib/dma-direct.c | 14 ++
1 file changed, 14 insertions(+)
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index 7e913728e099..2e9b9494610c 100644
--- a/lib/dma-direct.c
+++ b/lib/dma-direct.c
@@ -12,6 +12,14 @@
#define DIRECT_MAPPING_ERROR
This means it uses whatever linear remapping scheme that the architecture
provides is used in the generic dma_direct ops.
Signed-off-by: Christoph Hellwig
---
lib/dma-direct.c | 18 +++---
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/lib/dma-direct.c b/lib/dma-direc
Roughly based on the x86 pci-nommu implementation.
Signed-off-by: Christoph Hellwig
---
lib/dma-direct.c | 32 +++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index 0e087650e86b..ddd9dcf4e663 100644
--- a/lib/dma-
The trivial direct mapping implementation already does a virtual to
physical translation which isn't strictly a noop, and will soon learn
to do non-direct but linear physical to dma translations through the
device offset and a few small tricks. Rename it to a better fitting
name.
Signed-off-by: C
This is not needed in drivers, so move it to a private header.
Signed-off-by: Christoph Hellwig
---
arch/s390/include/asm/dma-mapping.h | 2 --
arch/s390/include/asm/pci_dma.h | 3 +++
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/s390/include/asm/dma-mapping.h
b/arch/
And unlike the other helpers we don't require a as
this helper is a special case for ia64 only, and this keeps it as
simple as possible.
Signed-off-by: Christoph Hellwig
---
arch/arm/include/asm/dma-mapping.h | 2 --
arch/arm64/include/asm/dma-mapping.h | 4
arch/ia64/Kconfig
Signed-off-by: Christoph Hellwig
---
arch/microblaze/kernel/dma.c | 28
1 file changed, 28 deletions(-)
diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c
index 49b09648679b..031d889670f5 100644
--- a/arch/microblaze/kernel/dma.c
+++ b/arch/micr
Life the code from x86 so that we behave consistently. In the future we
should probably warn if any of these is set.
Signed-off-by: Christoph Hellwig
---
arch/cris/arch-v32/drivers/pci/dma.c | 3 ---
arch/h8300/kernel/dma.c | 3 ---
arch/m68k/kernel/dma.c
This frees the dma_direct_* namespace for a generic implementation.
Signed-off-by: Christoph Hellwig
---
arch/microblaze/include/asm/dma-mapping.h | 4 +--
arch/microblaze/kernel/dma.c | 50 +++
2 files changed, 27 insertions(+), 27 deletions(-)
diff --
For architectures that just use the generic dma_noop_ops we can provide
a generic version of dma-mapping.h.
Signed-off-by: Christoph Hellwig
---
MAINTAINERS | 1 +
arch/m32r/include/asm/Kbuild | 1 +
arch/m32r/include/asm/dma-mapping.h | 17 -
phys_to_dma, dma_to_phys and dma_capable are helpers published by
architecture code for use of swiotlb and xen-swiotlb only. Drivers are
not supposed to use these directly, but use the DMA API instead.
Move these to a new asm/dma-direct.h helper, included by a
linux/dma-direct.h wrapper that prov
We always use the stub definitions, so remove the unused other code.
Signed-off-by: Christoph Hellwig
---
arch/arc/Kconfig | 3 ---
arch/arc/include/asm/dma-mapping.h | 7 ---
arch/arc/mm/dma.c | 14 +++---
3 files changed, 7 insertions(+), 17 del
Signed-off-by: Christoph Hellwig
---
arch/s390/include/asm/dma-mapping.h | 7 ---
1 file changed, 7 deletions(-)
diff --git a/arch/s390/include/asm/dma-mapping.h
b/arch/s390/include/asm/dma-mapping.h
index eaf490f9c5bc..2ec7240c1ada 100644
--- a/arch/s390/include/asm/dma-mapping.h
+++ b/arc
Signed-off-by: Christoph Hellwig
---
arch/riscv/include/asm/dma-mapping.h | 8
1 file changed, 8 deletions(-)
diff --git a/arch/riscv/include/asm/dma-mapping.h
b/arch/riscv/include/asm/dma-mapping.h
index 3eec1000196d..73849e2cc761 100644
--- a/arch/riscv/include/asm/dma-mapping.h
+++
Signed-off-by: Christoph Hellwig
---
arch/m32r/include/asm/dma-mapping.h | 7 ---
1 file changed, 7 deletions(-)
diff --git a/arch/m32r/include/asm/dma-mapping.h
b/arch/m32r/include/asm/dma-mapping.h
index 336ffe60814b..8967fb659691 100644
--- a/arch/m32r/include/asm/dma-mapping.h
+++ b/arc
Signed-off-by: Christoph Hellwig
---
arch/powerpc/include/asm/dma-mapping.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/powerpc/include/asm/dma-mapping.h
b/arch/powerpc/include/asm/dma-mapping.h
index 5a6cbe11db6f..592c7f418aa0 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+
Signed-off-by: Christoph Hellwig
---
arch/m32r/include/asm/io.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/m32r/include/asm/io.h b/arch/m32r/include/asm/io.h
index 1b653bb16f9a..a4272d8f0d9c 100644
--- a/arch/m32r/include/asm/io.h
+++ b/arch/m32r/include/asm/io.h
@@ -191,8 +191,6 @
Signed-off-by: Christoph Hellwig
---
arch/hexagon/include/asm/io.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h
index 66f5e9a61efc..9e8621d94ee9 100644
--- a/arch/hexagon/include/asm/io.h
+++ b/arch/hexagon/include/asm/io.h
@@
The current PCI_DMA_BUS_IS_PHYS decided if a dma implementation is bound
by the dma mask in the device because it directly maps to a physical
address range (modulo an offset in the device), or if it is virtualized
by an iommu and can map any address (that includes virtual iommus like
swiotlb). The
This makes sure the generic version can be used with architectures /
devices that have a DMA offset in the direct mapping.
Signed-off-by: Christoph Hellwig
---
include/linux/dma-mapping.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/dma-mapping.h b/include/li
There were only a few Pentium Pro multiprocessors systems where this
errata applied. They are more than 20 years old now, and we've slowly
dropped places where put the workarounds in and discuraged anyone
from enabling the workaround.
Get rid of it for good.
Signed-off-by: Christoph Hellwig
---
CONFIG_ALPHA_JENSEN has failed to compile since commit aca05038
("alpha/dma: use common noop dma ops"), so mark it as broken.
Signed-off-by: Christoph Hellwig
---
arch/alpha/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index b31b974a03cb..e9
Almost every architecture supports a direct dma mapping implementation,
where no iommu is used and the device dma address is a 1:1 mapping to
the physical address or has a simple linear offset. Currently the
code for this implementation is most duplicated over the architectures,
and the duplicated
71 matches
Mail list logo