projects/linux·commit af7ddd8a

Merge tag 'dma-mapping-4.21' of git://git.infradead.org/users/hch/dma-mapping

af7ddd8a · Linus Torvalds <[email protected]> · 2018-12-28 14:12:21 -08:00

Pull DMA mapping updates from Christoph Hellwig:
 "A huge update this time, but a lot of that is just consolidating or
  removing code:

   - provide a common DMA_MAPPING_ERROR definition and avoid indirect
     calls for dma_map_* error checking

   - use direct calls for the DMA direct mapping case, avoiding huge
     retpoline overhead for high performance workloads

   - merge the swiotlb dma_map_ops into dma-direct

   - provide a generic remapping DMA consistent allocator for
     architectures that have devices that perform DMA that is not cache
     coherent. Based on the existing arm64 implementation and also used
     for csky now.

   - improve the dma-debug infrastructure, including dynamic allocation
     of entries (Robin Murphy)

   - default to providing chaining scatterlist everywhere, with opt-outs
     for the few architectures (alpha, parisc, most arm32 variants) that
     can't cope with it

   - misc sparc32 dma-related cleanups

   - remove the dma_mark_clean arch hook used by swiotlb on ia64 and
     replace it with the generic noncoherent infrastructure

   - fix the return type of dma_set_max_seg_size (Niklas Söderlund)

   - move the dummy dma ops for not DMA capable devices from arm64 to
     common code (Robin Murphy)

   - ensure dma_alloc_coherent returns zeroed memory to avoid kernel
     data leaks through userspace. We already did this for most common
     architectures, but this ensures we do it everywhere.
     dma_zalloc_coherent has been deprecated and can hopefully be
     removed after -rc1 with a coccinelle script"

* tag 'dma-mapping-4.21' of git://git.infradead.org/users/hch/dma-mapping: (73 commits)
  dma-mapping: fix inverted logic in dma_supported
  dma-mapping: deprecate dma_zalloc_coherent
  dma-mapping: zero memory returned from dma_alloc_*
  sparc/iommu: fix ->map_sg return value
  sparc/io-unit: fix ->map_sg return value
  arm64: default to the direct mapping in get_arch_dma_ops
  PCI: Remove unused attr variable in pci_dma_configure
  ia64: only select ARCH_HAS_DMA_COHERENT_TO_PFN if swiotlb is enabled
  dma-mapping: bypass indirect calls for dma-direct
  vmd: use the proper dma_* APIs instead of direct methods calls
  dma-direct: merge swiotlb_dma_ops into the dma_direct code
  dma-direct: use dma_direct_map_page to implement dma_direct_map_sg
  dma-direct: improve addressability error reporting
  swiotlb: remove dma_mark_clean
  swiotlb: remove SWIOTLB_MAP_ERROR
  ACPI / scan: Refactor _CCA enforcement
  dma-mapping: factor out dummy DMA ops
  dma-mapping: always build the direct mapping code
  dma-mapping: move dma_cache_sync out of line
  dma-mapping: move various slow path functions out of line
  ...
Commit
af7ddd8a627c62a835524b3f5b471edbbbcce025
Parents
fe2b0cda · 8b1cce9f

Merge commit. Changes below are compared with the first parent: fe2b0cda.

Changes

112 files changed · +1408 −2340

FileStatusAddDelContent
Documentation/DMA-API.txtmodified+14−15View file
Documentation/features/io/sg-chain/arch-support.txtdeleted+0−33View before deletion
Documentation/x86/x86_64/boot-options.txtmodified+1−4View file
arch/alpha/Kconfigmodified+1−1View file
arch/alpha/include/asm/dma-mapping.hmodified+1−1View file
arch/alpha/kernel/pci_iommu.cmodified+5−11View file
arch/arc/Kconfigmodified+0−2View file
arch/arc/mm/cache.cmodified+1−1View file
arch/arc/mm/dma.cmodified+1−1View file
arch/arm/Kconfigmodified+2−2View file
arch/arm/common/dmabounce.cmodified+3−9View file
arch/arm/include/asm/dma-iommu.hmodified+0−2View file
arch/arm/include/asm/dma-mapping.hmodified+1−1View file
arch/arm/mm/dma-mapping-nommu.cmodified+3−11View file
arch/arm/mm/dma-mapping.cmodified+15−24View file
arch/arm64/Kconfigmodified+1−2View file
arch/arm64/include/asm/dma-mapping.hmodified+1−7View file
arch/arm64/mm/dma-mapping.cmodified+13−273View file
arch/c6x/Kconfigmodified+0−1View file
arch/c6x/mm/dma-coherent.cmodified+4−1View file
arch/csky/Kconfigmodified+1−2View file
arch/csky/mm/dma-mapping.cmodified+2−140View file
arch/h8300/Kconfigmodified+0−1View file
arch/hexagon/Kconfigmodified+0−1View file
arch/ia64/Kconfigmodified+2−2View file
arch/ia64/hp/common/hwsw_iommu.cmodified+1−1View file
arch/ia64/hp/common/sba_iommu.cmodified+32−55View file
arch/ia64/kernel/dma-mapping.cmodified+19−2View file
arch/ia64/mm/init.cmodified+8−11View file
arch/ia64/sn/pci/pci_dma.cmodified+1−7View file
arch/m68k/Kconfigmodified+0−1View file
arch/m68k/kernel/dma.cmodified+1−1View file
arch/microblaze/Kconfigmodified+0−1View file
arch/microblaze/mm/consistent.cmodified+1−1View file
arch/mips/Kconfigmodified+0−1View file
arch/mips/include/asm/dma-mapping.hmodified+1−3View file
arch/mips/include/asm/jazzdma.hmodified+0−6View file
arch/mips/jazz/jazzdma.cmodified+5−11View file
arch/nds32/Kconfigmodified+0−1View file
arch/nios2/Kconfigmodified+0−1View file
arch/openrisc/Kconfigmodified+0−1View file
arch/openrisc/kernel/dma.cmodified+1−1View file
arch/parisc/Kconfigmodified+1−1View file
arch/parisc/kernel/pci-dma.cmodified+2−2View file
arch/parisc/kernel/setup.cmodified+0−4View file
arch/powerpc/Kconfigmodified+0−1View file
arch/powerpc/include/asm/dma-mapping.hmodified+0−1View file
arch/powerpc/include/asm/iommu.hmodified+0−4View file
arch/powerpc/kernel/dma-iommu.cmodified+0−6View file
arch/powerpc/kernel/dma-swiotlb.cmodified+8−9View file
arch/powerpc/kernel/iommu.cmodified+14−14View file
arch/powerpc/platforms/cell/iommu.cmodified+0−1View file
arch/powerpc/platforms/pseries/vio.cmodified+1−2View file
arch/riscv/Kconfigmodified+0−1View file
arch/riscv/include/asm/dma-mapping.hdeleted+0−15View before deletion
arch/s390/Kconfigmodified+0−2View file
arch/s390/pci/pci_dma.cmodified+6−14View file
arch/sh/Kconfigmodified+0−1View file
arch/sparc/Kconfigmodified+0−2View file
arch/sparc/include/asm/dma-mapping.hmodified+3−5View file
arch/sparc/include/asm/dma.hmodified+2−46View file
arch/sparc/include/asm/leon.hmodified+9−0View file
arch/sparc/include/asm/pci.hmodified+49−4View file
arch/sparc/include/asm/pci_32.hdeleted+0−41View before deletion
arch/sparc/include/asm/pci_64.hdeleted+0−52View before deletion
arch/sparc/kernel/iommu.cmodified+3−9View file
arch/sparc/kernel/iommu_common.hmodified+0−2View file
arch/sparc/kernel/ioport.cmodified+44−199View file
arch/sparc/kernel/pci_sun4v.cmodified+4−10View file
arch/sparc/mm/io-unit.cmodified+54−26View file
arch/sparc/mm/iommu.cmodified+96−64View file
arch/unicore32/Kconfigmodified+0−1View file
arch/x86/Kconfigmodified+0−2View file
arch/x86/kernel/amd_gart_64.cmodified+6−57View file
arch/x86/kernel/pci-calgary_64.cmodified+7−23View file
arch/x86/kernel/pci-dma.cmodified+1−1View file
arch/x86/kernel/pci-swiotlb.cmodified+1−3View file
arch/x86/mm/mem_encrypt.cmodified+0−7View file
arch/x86/pci/sta2x11-fixup.cmodified+0−1View file
arch/xtensa/Kconfigmodified+1−2View file
arch/xtensa/kernel/pci-dma.cmodified+1−1View file
drivers/acpi/scan.cmodified+5−0View file
drivers/base/platform.cmodified+1−33View file
drivers/gpu/drm/vmwgfx/vmwgfx_drv.cmodified+1−1View file
drivers/iommu/amd_iommu.cmodified+6−25View file
drivers/iommu/dma-iommu.cmodified+8−15View file
drivers/iommu/intel-iommu.cmodified+10−16View file
drivers/misc/mic/host/mic_boot.cmodified+1−1View file
drivers/parisc/ccio-dma.cmodified+1−9View file
drivers/parisc/sba_iommu.cmodified+1−9View file
drivers/pci/controller/vmd.cmodified+17−31View file
drivers/pci/pci-driver.cmodified+1−3View file
drivers/xen/swiotlb-xen.cmodified+5−31View file
include/asm-generic/dma-mapping.hmodified+1−1View file
include/linux/dma-debug.hmodified+0−34View file
include/linux/dma-direct.hmodified+3−16View file
include/linux/dma-iommu.hmodified+0−1View file
include/linux/dma-mapping.hmodified+143−207View file
include/linux/dma-noncoherent.hmodified+6−1View file
include/linux/scatterlist.hmodified+3−3View file
include/linux/swiotlb.hmodified+30−47View file
kernel/dma/Kconfigmodified+8−6View file
kernel/dma/Makefilemodified+2−3View file
kernel/dma/debug.cmodified+94−165View file
kernel/dma/direct.cmodified+129−93View file
kernel/dma/dummy.cadded+39−0View file
kernel/dma/mapping.cmodified+164−59View file
kernel/dma/remap.cadded+256−0View file
kernel/dma/swiotlb.cmodified+15−238View file
kernel/dma/virt.cmodified+1−1View file
lib/Kconfigmodified+1−1View file
lib/scatterlist.cmodified+1−1View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/DMA-API.txt

View file
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index ac66ae2..e133ccd 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -60,15 +60,6 @@ the returned memory, like GFP_DMA).
::
- void *
- dma_zalloc_coherent(struct device *dev, size_t size,
- dma_addr_t *dma_handle, gfp_t flag)
-
-Wraps dma_alloc_coherent() and also zeroes the returned memory if the
-allocation attempt succeeded.
-
-::
-
void
dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
dma_addr_t dma_handle)
@@ -717,12 +708,15 @@ dma-api/num_errors The number in this file shows how many
dma-api/min_free_entries This read-only file can be read to get the
minimum number of free dma_debug_entries the
allocator has ever seen. If this value goes
- down to zero the code will disable itself
- because it is not longer reliable.
+ down to zero the code will attempt to increase
+ nr_total_entries to compensate.
dma-api/num_free_entries The current number of free dma_debug_entries
in the allocator.
+dma-api/nr_total_entries The total number of dma_debug_entries in the
+ allocator, both free and used.
+
dma-api/driver-filter You can write a name of a driver into this file
to limit the debug output to requests from that
particular driver. Write an empty string to
@@ -742,10 +736,15 @@ driver filter at boot time. The debug code will only print errors for that
driver afterwards. This filter can be disabled or changed later using debugfs.
When the code disables itself at runtime this is most likely because it ran
-out of dma_debug_entries. These entries are preallocated at boot. The number
-of preallocated entries is defined per architecture. If it is too low for you
-boot with 'dma_debug_entries=<your_desired_number>' to overwrite the
-architectural default.
+out of dma_debug_entries and was unable to allocate more on-demand. 65536
+entries are preallocated at boot - if this is too low for you boot with
+'dma_debug_entries=<your_desired_number>' to overwrite the default. Note
+that the code allocates entries in batches, so the exact number of
+preallocated entries may be greater than the actual number requested. The
+code will print to the kernel log each time it has dynamically allocated
+as many entries as were initially preallocated. This is to indicate that a
+larger preallocation size may be appropriate, or if it happens continually
+that a driver may be leaking mappings.
::

Documentation/features/io/sg-chain/arch-support.txt

View before deletion
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 6554f03..0000000
--- 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 |
- -----------------------

Documentation/x86/x86_64/boot-options.txt

View file
diff --git a/Documentation/x86/x86_64/boot-options.txt b/Documentation/x86/x86_64/boot-options.txt
index ad6d2a8..abc5388 100644
--- a/Documentation/x86/x86_64/boot-options.txt
+++ b/Documentation/x86/x86_64/boot-options.txt
@@ -209,7 +209,7 @@ IOMMU (input/output memory management unit)
mapping with memory protection, etc.
Kernel boot message: "PCI-DMA: Using Calgary IOMMU"
- iommu=[<size>][,noagp][,off][,force][,noforce][,leak[=<nr_of_leak_pages>]
+ iommu=[<size>][,noagp][,off][,force][,noforce]
[,memaper[=<order>]][,merge][,fullflush][,nomerge]
[,noaperture][,calgary]
@@ -228,9 +228,6 @@ IOMMU (input/output memory management unit)
allowed Overwrite iommu off workarounds for specific chipsets.
fullflush Flush IOMMU on each allocation (default).
nofullflush Don't use IOMMU fullflush.
- leak Turn on simple iommu leak tracing (only when
- CONFIG_IOMMU_LEAK is on). Default number of leak pages
- is 20.
memaper[=<order>] Allocate an own aperture over RAM with size 32MB<<order.
(default: order=1, i.e. 64MB)
merge Do scatter-gather (SG) merging. Implies "force"

arch/alpha/Kconfig

View file
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 5b4f883..5da6ff5 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
@@ -202,7 +203,6 @@ config ALPHA_EIGER
config ALPHA_JENSEN
bool "Jensen"
depends on BROKEN
- select DMA_DIRECT_OPS
help
DEC PC 150 AXP (aka Jensen): This is a very old Digital system - one
of the first-generation Alpha systems. A number of these systems

arch/alpha/include/asm/dma-mapping.h

View file
diff --git a/arch/alpha/include/asm/dma-mapping.h b/arch/alpha/include/asm/dma-mapping.h
index 8beeafd..0ee6a5c 100644
--- a/arch/alpha/include/asm/dma-mapping.h
+++ b/arch/alpha/include/asm/dma-mapping.h
@@ -7,7 +7,7 @@ extern const struct dma_map_ops alpha_pci_ops;
static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
{
#ifdef CONFIG_ALPHA_JENSEN
- return &dma_direct_ops;
+ return NULL;
#else
return &alpha_pci_ops;
#endif

arch/alpha/kernel/pci_iommu.c

View file
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 46e08e0..aa0f50d 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -291,7 +291,7 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size,
use direct_map above, it now must be considered an error. */
if (! alpha_mv.mv_pci_tbi) {
printk_once(KERN_WARNING "pci_map_single: no HW sg\n");
- return 0;
+ return DMA_MAPPING_ERROR;
}
arena = hose->sg_pci;
@@ -307,7 +307,7 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size,
if (dma_ofs < 0) {
printk(KERN_WARNING "pci_map_single failed: "
"could not allocate dma page tables\n");
- return 0;
+ return DMA_MAPPING_ERROR;
}
paddr &= PAGE_MASK;
@@ -443,7 +443,7 @@ static void *alpha_pci_alloc_coherent(struct device *dev, size_t size,
gfp &= ~GFP_DMA;
try_again:
- cpu_addr = (void *)__get_free_pages(gfp, order);
+ cpu_addr = (void *)__get_free_pages(gfp | __GFP_ZERO, order);
if (! cpu_addr) {
printk(KERN_INFO "pci_alloc_consistent: "
"get_free_pages failed from %pf\n",
@@ -455,7 +455,7 @@ try_again:
memset(cpu_addr, 0, size);
*dma_addrp = pci_map_single_1(pdev, cpu_addr, size, 0);
- if (*dma_addrp == 0) {
+ if (*dma_addrp == DMA_MAPPING_ERROR) {
free_pages((unsigned long)cpu_addr, order);
if (alpha_mv.mv_pci_tbi || (gfp & GFP_DMA))
return NULL;
@@ -671,7 +671,7 @@ static int alpha_pci_map_sg(struct device *dev, struct scatterlist *sg,
sg->dma_address
= pci_map_single_1(pdev, SG_ENT_VIRT_ADDRESS(sg),
sg->length, dac_allowed);
- return sg->dma_address != 0;
+ return sg->dma_address != DMA_MAPPING_ERROR;
}
start = sg;
@@ -935,11 +935,6 @@ iommu_unbind(struct pci_iommu_arena *arena, long pg_start, long pg_count)
return 0;
}
-static int alpha_pci_mapping_error(struct device *dev, dma_addr_t dma_addr)
-{
- return dma_addr == 0;
-}
-
const struct dma_map_ops alpha_pci_ops = {
.alloc = alpha_pci_alloc_coherent,
.free = alpha_pci_free_coherent,
@@ -947,7 +942,6 @@ const struct dma_map_ops alpha_pci_ops = {
.unmap_page = alpha_pci_unmap_page,
.map_sg = alpha_pci_map_sg,
.unmap_sg = alpha_pci_unmap_sg,
- .mapping_error = alpha_pci_mapping_error,
.dma_supported = alpha_pci_supported,
};
EXPORT_SYMBOL(alpha_pci_ops);

arch/arc/Kconfig

View file
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index dadb494..ca8e26d 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -13,12 +13,10 @@ 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
select COMMON_CLK
- select DMA_DIRECT_OPS
select GENERIC_ATOMIC64 if !ISA_ARCV2 || !(ARC_HAS_LL64 && ARC_HAS_LLSC)
select GENERIC_CLOCKEVENTS
select GENERIC_FIND_FIRST_BIT

arch/arc/mm/cache.c

View file
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
index cf9619d..4135abe 100644
--- a/arch/arc/mm/cache.c
+++ b/arch/arc/mm/cache.c
@@ -1294,7 +1294,7 @@ void __init arc_cache_init_master(void)
/*
* In case of IOC (say IOC+SLC case), pointers above could still be set
* but end up not being relevant as the first function in chain is not
- * called at all for @dma_direct_ops
+ * called at all for devices using coherent DMA.
* arch_sync_dma_for_cpu() -> dma_cache_*() -> __dma_cache_*()
*/
}

arch/arc/mm/dma.c

View file
diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
index db203ff..1525ac0 100644
--- a/arch/arc/mm/dma.c
+++ b/arch/arc/mm/dma.c
@@ -33,7 +33,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
*/
BUG_ON(gfp & __GFP_HIGHMEM);
- page = alloc_pages(gfp, order);
+ page = alloc_pages(gfp | __GFP_ZERO, order);
if (!page)
return NULL;

arch/arm/Kconfig

View file
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5c03055..2196aac 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
@@ -29,7 +30,7 @@ config ARM
select CLONE_BACKWARDS
select CPU_PM if (SUSPEND || CPU_IDLE)
select DCACHE_WORD_ACCESS if HAVE_EFFICIENT_UNALIGNED_ACCESS
- select DMA_DIRECT_OPS if !MMU
+ select DMA_REMAP if MMU
select EDAC_SUPPORT
select EDAC_ATOMIC_SCRUB
select GENERIC_ALLOCATOR
@@ -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/arm/common/dmabounce.c

View file
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 9a92de6..5ba4622 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -257,7 +257,7 @@ static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size,
if (buf == NULL) {
dev_err(dev, "%s: unable to map unsafe buffer %p!\n",
__func__, ptr);
- return ARM_MAPPING_ERROR;
+ return DMA_MAPPING_ERROR;
}
dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
@@ -327,7 +327,7 @@ static dma_addr_t dmabounce_map_page(struct device *dev, struct page *page,
ret = needs_bounce(dev, dma_addr, size);
if (ret < 0)
- return ARM_MAPPING_ERROR;
+ return DMA_MAPPING_ERROR;
if (ret == 0) {
arm_dma_ops.sync_single_for_device(dev, dma_addr, size, dir);
@@ -336,7 +336,7 @@ static dma_addr_t dmabounce_map_page(struct device *dev, struct page *page,
if (PageHighMem(page)) {
dev_err(dev, "DMA buffer bouncing of HIGHMEM pages is not supported\n");
- return ARM_MAPPING_ERROR;
+ return DMA_MAPPING_ERROR;
}
return map_single(dev, page_address(page) + offset, size, dir, attrs);
@@ -453,11 +453,6 @@ static int dmabounce_dma_supported(struct device *dev, u64 dma_mask)
return arm_dma_ops.dma_supported(dev, dma_mask);
}
-static int dmabounce_mapping_error(struct device *dev, dma_addr_t dma_addr)
-{
- return arm_dma_ops.mapping_error(dev, dma_addr);
-}
-
static const struct dma_map_ops dmabounce_ops = {
.alloc = arm_dma_alloc,
.free = arm_dma_free,
@@ -472,7 +467,6 @@ static const struct dma_map_ops dmabounce_ops = {
.sync_sg_for_cpu = arm_dma_sync_sg_for_cpu,
.sync_sg_for_device = arm_dma_sync_sg_for_device,
.dma_supported = dmabounce_dma_supported,
- .mapping_error = dmabounce_mapping_error,
};
static int dmabounce_init_pool(struct dmabounce_pool *pool, struct device *dev,

arch/arm/include/asm/dma-iommu.h

View file
diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h
index 6821f12..772f48e 100644
--- a/arch/arm/include/asm/dma-iommu.h
+++ b/arch/arm/include/asm/dma-iommu.h
@@ -9,8 +9,6 @@
#include <linux/dma-debug.h>
#include <linux/kref.h>
-#define ARM_MAPPING_ERROR (~(dma_addr_t)0x0)
-
struct dma_iommu_mapping {
/* iommu specific data */
struct iommu_domain *domain;

arch/arm/include/asm/dma-mapping.h

View file
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index 965b7c8..31d3b96 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -18,7 +18,7 @@ extern const struct dma_map_ops arm_coherent_dma_ops;
static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
{
- return IS_ENABLED(CONFIG_MMU) ? &arm_dma_ops : &dma_direct_ops;
+ return IS_ENABLED(CONFIG_MMU) ? &arm_dma_ops : NULL;
}
#ifdef __arch_page_to_dma

arch/arm/mm/dma-mapping-nommu.c

View file
diff --git a/arch/arm/mm/dma-mapping-nommu.c b/arch/arm/mm/dma-mapping-nommu.c
index 712416e..f304b10 100644
--- a/arch/arm/mm/dma-mapping-nommu.c
+++ b/arch/arm/mm/dma-mapping-nommu.c
@@ -22,7 +22,7 @@
#include "dma.h"
/*
- * dma_direct_ops is used if
+ * The generic direct mapping code is used if
* - MMU/MPU is off
* - cpu is v7m w/o cache support
* - device is coherent
@@ -209,16 +209,9 @@ const struct dma_map_ops arm_nommu_dma_ops = {
};
EXPORT_SYMBOL(arm_nommu_dma_ops);
-static const struct dma_map_ops *arm_nommu_get_dma_map_ops(bool coherent)
-{
- return coherent ? &dma_direct_ops : &arm_nommu_dma_ops;
-}
-
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
{
- const struct dma_map_ops *dma_ops;
-
if (IS_ENABLED(CONFIG_CPU_V7M)) {
/*
* Cache support for v7m is optional, so can be treated as
@@ -234,7 +227,6 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
dev->archdata.dma_coherent = (get_cr() & CR_M) ? coherent : true;
}
- dma_ops = arm_nommu_get_dma_map_ops(dev->archdata.dma_coherent);
-
- set_dma_ops(dev, dma_ops);
+ if (!dev->archdata.dma_coherent)
+ set_dma_ops(dev, &arm_nommu_dma_ops);
}

arch/arm/mm/dma-mapping.c

View file
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 78de138..f1e2922 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -179,11 +179,6 @@ static void arm_dma_sync_single_for_device(struct device *dev,
__dma_page_cpu_to_dev(page, offset, size, dir);
}
-static int arm_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
-{
- return dma_addr == ARM_MAPPING_ERROR;
-}
-
const struct dma_map_ops arm_dma_ops = {
.alloc = arm_dma_alloc,
.free = arm_dma_free,
@@ -197,7 +192,6 @@ const struct dma_map_ops arm_dma_ops = {
.sync_single_for_device = arm_dma_sync_single_for_device,
.sync_sg_for_cpu = arm_dma_sync_sg_for_cpu,
.sync_sg_for_device = arm_dma_sync_sg_for_device,
- .mapping_error = arm_dma_mapping_error,
.dma_supported = arm_dma_supported,
};
EXPORT_SYMBOL(arm_dma_ops);
@@ -217,7 +211,6 @@ const struct dma_map_ops arm_coherent_dma_ops = {
.get_sgtable = arm_dma_get_sgtable,
.map_page = arm_coherent_dma_map_page,
.map_sg = arm_dma_map_sg,
- .mapping_error = arm_dma_mapping_error,
.dma_supported = arm_dma_supported,
};
EXPORT_SYMBOL(arm_coherent_dma_ops);
@@ -774,7 +767,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
gfp &= ~(__GFP_COMP);
args.gfp = gfp;
- *handle = ARM_MAPPING_ERROR;
+ *handle = DMA_MAPPING_ERROR;
allowblock = gfpflags_allow_blocking(gfp);
cma = allowblock ? dev_get_cma_area(dev) : false;
@@ -1217,7 +1210,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping,
if (i == mapping->nr_bitmaps) {
if (extend_iommu_mapping(mapping)) {
spin_unlock_irqrestore(&mapping->lock, flags);
- return ARM_MAPPING_ERROR;
+ return DMA_MAPPING_ERROR;
}
start = bitmap_find_next_zero_area(mapping->bitmaps[i],
@@ -1225,7 +1218,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping,
if (start > mapping->bits) {
spin_unlock_irqrestore(&mapping->lock, flags);
- return ARM_MAPPING_ERROR;
+ return DMA_MAPPING_ERROR;
}
bitmap_set(mapping->bitmaps[i], start, count);
@@ -1409,7 +1402,7 @@ __iommu_create_mapping(struct device *dev, struct page **pages, size_t size,
int i;
dma_addr = __alloc_iova(mapping, size);
- if (dma_addr == ARM_MAPPING_ERROR)
+ if (dma_addr == DMA_MAPPING_ERROR)
return dma_addr;
iova = dma_addr;
@@ -1436,7 +1429,7 @@ __iommu_create_mapping(struct device *dev, struct page **pages, size_t size,
fail:
iommu_unmap(mapping->domain, dma_addr, iova-dma_addr);
__free_iova(mapping, dma_addr, size);
- return ARM_MAPPING_ERROR;
+ return DMA_MAPPING_ERROR;
}
static int __iommu_remove_mapping(struct device *dev, dma_addr_t iova, size_t size)
@@ -1497,7 +1490,7 @@ static void *__iommu_alloc_simple(struct device *dev, size_t size, gfp_t gfp,
return NULL;
*handle = __iommu_create_mapping(dev, &page, size, attrs);
- if (*handle == ARM_MAPPING_ERROR)
+ if (*handle == DMA_MAPPING_ERROR)
goto err_mapping;
return addr;
@@ -1525,7 +1518,7 @@ static void *__arm_iommu_alloc_attrs(struct device *dev, size_t size,
struct page **pages;
void *addr = NULL;
- *handle = ARM_MAPPING_ERROR;
+ *handle = DMA_MAPPING_ERROR;
size = PAGE_ALIGN(size);
if (coherent_flag == COHERENT || !gfpflags_allow_blocking(gfp))
@@ -1546,7 +1539,7 @@ static void *__arm_iommu_alloc_attrs(struct device *dev, size_t size,
return NULL;
*handle = __iommu_create_mapping(dev, pages, size, attrs);
- if (*handle == ARM_MAPPING_ERROR)
+ if (*handle == DMA_MAPPING_ERROR)
goto err_buffer;
if (attrs & DMA_ATTR_NO_KERNEL_MAPPING)
@@ -1696,10 +1689,10 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg,
int prot;
size = PAGE_ALIGN(size);
- *handle = ARM_MAPPING_ERROR;
+ *handle = DMA_MAPPING_ERROR;
iova_base = iova = __alloc_iova(mapping, size);
- if (iova == ARM_MAPPING_ERROR)
+ if (iova == DMA_MAPPING_ERROR)
return -ENOMEM;
for (count = 0, s = sg; count < (size >> PAGE_SHIFT); s = sg_next(s)) {
@@ -1739,7 +1732,7 @@ static int __iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents,
for (i = 1; i < nents; i++) {
s = sg_next(s);
- s->dma_address = ARM_MAPPING_ERROR;
+ s->dma_address = DMA_MAPPING_ERROR;
s->dma_length = 0;
if (s->offset || (size & ~PAGE_MASK) || size + s->length > max) {
@@ -1914,7 +1907,7 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p
int ret, prot, len = PAGE_ALIGN(size + offset);
dma_addr = __alloc_iova(mapping, len);
- if (dma_addr == ARM_MAPPING_ERROR)
+ if (dma_addr == DMA_MAPPING_ERROR)
return dma_addr;
prot = __dma_info_to_prot(dir, attrs);
@@ -1926,7 +1919,7 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p
return dma_addr + offset;
fail:
__free_iova(mapping, dma_addr, len);
- return ARM_MAPPING_ERROR;
+ return DMA_MAPPING_ERROR;
}
/**
@@ -2020,7 +2013,7 @@ static dma_addr_t arm_iommu_map_resource(struct device *dev,
size_t len = PAGE_ALIGN(size + offset);
dma_addr = __alloc_iova(mapping, len);
- if (dma_addr == ARM_MAPPING_ERROR)
+ if (dma_addr == DMA_MAPPING_ERROR)
return dma_addr;
prot = __dma_info_to_prot(dir, attrs) | IOMMU_MMIO;
@@ -2032,7 +2025,7 @@ static dma_addr_t arm_iommu_map_resource(struct device *dev,
return dma_addr + offset;
fail:
__free_iova(mapping, dma_addr, len);
- return ARM_MAPPING_ERROR;
+ return DMA_MAPPING_ERROR;
}
/**
@@ -2105,7 +2098,6 @@ const struct dma_map_ops iommu_ops = {
.map_resource = arm_iommu_map_resource,
.unmap_resource = arm_iommu_unmap_resource,
- .mapping_error = arm_dma_mapping_error,
.dma_supported = arm_dma_supported,
};
@@ -2124,7 +2116,6 @@ const struct dma_map_ops iommu_coherent_ops = {
.map_resource = arm_iommu_map_resource,
.unmap_resource = arm_iommu_unmap_resource,
- .mapping_error = arm_dma_mapping_error,
.dma_supported = arm_dma_supported,
};

arch/arm64/Kconfig

View file
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 6b7bf0f..ff92918 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

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/dma-mapping.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/mm/dma-mapping.c

View file

This diff is incomplete. Download the complete patch.

arch/c6x/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/c6x/mm/dma-coherent.c

View file

This diff is incomplete. Download the complete patch.

arch/csky/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/csky/mm/dma-mapping.c

View file

This diff is incomplete. Download the complete patch.

arch/h8300/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/hexagon/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/ia64/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/ia64/hp/common/hwsw_iommu.c

View file

This diff is incomplete. Download the complete patch.

arch/ia64/hp/common/sba_iommu.c

View file

This diff is incomplete. Download the complete patch.

arch/ia64/kernel/dma-mapping.c

View file

This diff is incomplete. Download the complete patch.

arch/ia64/mm/init.c

View file

This diff is incomplete. Download the complete patch.

arch/ia64/sn/pci/pci_dma.c

View file

This diff is incomplete. Download the complete patch.

arch/m68k/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/m68k/kernel/dma.c

View file

This diff is incomplete. Download the complete patch.

arch/microblaze/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/microblaze/mm/consistent.c

View file

This diff is incomplete. Download the complete patch.

arch/mips/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/mips/include/asm/dma-mapping.h

View file

This diff is incomplete. Download the complete patch.

arch/mips/include/asm/jazzdma.h

View file

This diff is incomplete. Download the complete patch.

arch/mips/jazz/jazzdma.c

View file

This diff is incomplete. Download the complete patch.

arch/nds32/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/nios2/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/openrisc/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/openrisc/kernel/dma.c

View file

This diff is incomplete. Download the complete patch.

arch/parisc/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/parisc/kernel/pci-dma.c

View file

This diff is incomplete. Download the complete patch.

arch/parisc/kernel/setup.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/dma-mapping.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/iommu.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kernel/dma-iommu.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kernel/dma-swiotlb.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kernel/iommu.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/platforms/cell/iommu.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/platforms/pseries/vio.c

View file

This diff is incomplete. Download the complete patch.

arch/riscv/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/riscv/include/asm/dma-mapping.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/s390/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/s390/pci/pci_dma.c

View file

This diff is incomplete. Download the complete patch.

arch/sh/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/sparc/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/sparc/include/asm/dma-mapping.h

View file

This diff is incomplete. Download the complete patch.

arch/sparc/include/asm/dma.h

View file

This diff is incomplete. Download the complete patch.

arch/sparc/include/asm/leon.h

View file

This diff is incomplete. Download the complete patch.

arch/sparc/include/asm/pci.h

View file

This diff is incomplete. Download the complete patch.

arch/sparc/include/asm/pci_32.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/sparc/include/asm/pci_64.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/sparc/kernel/iommu.c

View file

This diff is incomplete. Download the complete patch.

arch/sparc/kernel/iommu_common.h

View file

This diff is incomplete. Download the complete patch.

arch/sparc/kernel/ioport.c

View file

This diff is incomplete. Download the complete patch.

arch/sparc/kernel/pci_sun4v.c

View file

This diff is incomplete. Download the complete patch.

arch/sparc/mm/io-unit.c

View file

This diff is incomplete. Download the complete patch.

arch/sparc/mm/iommu.c

View file

This diff is incomplete. Download the complete patch.

arch/unicore32/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/x86/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/amd_gart_64.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/pci-calgary_64.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/pci-dma.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/pci-swiotlb.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/mm/mem_encrypt.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/pci/sta2x11-fixup.c

View file

This diff is incomplete. Download the complete patch.

arch/xtensa/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/xtensa/kernel/pci-dma.c

View file

This diff is incomplete. Download the complete patch.

drivers/acpi/scan.c

View file

This diff is incomplete. Download the complete patch.

drivers/base/platform.c

View file

This diff is incomplete. Download the complete patch.

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

View file

This diff is incomplete. Download the complete patch.

drivers/iommu/amd_iommu.c

View file

This diff is incomplete. Download the complete patch.

drivers/iommu/dma-iommu.c

View file

This diff is incomplete. Download the complete patch.

drivers/iommu/intel-iommu.c

View file

This diff is incomplete. Download the complete patch.

drivers/misc/mic/host/mic_boot.c

View file

This diff is incomplete. Download the complete patch.

drivers/parisc/ccio-dma.c

View file

This diff is incomplete. Download the complete patch.

drivers/parisc/sba_iommu.c

View file

This diff is incomplete. Download the complete patch.

drivers/pci/controller/vmd.c

View file

This diff is incomplete. Download the complete patch.

drivers/pci/pci-driver.c

View file

This diff is incomplete. Download the complete patch.

drivers/xen/swiotlb-xen.c

View file

This diff is incomplete. Download the complete patch.

include/asm-generic/dma-mapping.h

View file

This diff is incomplete. Download the complete patch.

include/linux/dma-debug.h

View file

This diff is incomplete. Download the complete patch.

include/linux/dma-direct.h

View file

This diff is incomplete. Download the complete patch.

include/linux/dma-iommu.h

View file

This diff is incomplete. Download the complete patch.

include/linux/dma-mapping.h

View file

This diff is incomplete. Download the complete patch.

include/linux/dma-noncoherent.h

View file

This diff is incomplete. Download the complete patch.

include/linux/scatterlist.h

View file

This diff is incomplete. Download the complete patch.

include/linux/swiotlb.h

View file

This diff is incomplete. Download the complete patch.

kernel/dma/Kconfig

View file

This diff is incomplete. Download the complete patch.

kernel/dma/Makefile

View file

This diff is incomplete. Download the complete patch.

kernel/dma/debug.c

View file

This diff is incomplete. Download the complete patch.

kernel/dma/direct.c

View file

This diff is incomplete. Download the complete patch.

kernel/dma/dummy.c

View file

This diff is incomplete. Download the complete patch.

kernel/dma/mapping.c

View file

This diff is incomplete. Download the complete patch.

kernel/dma/remap.c

View file

This diff is incomplete. Download the complete patch.

kernel/dma/swiotlb.c

View file

This diff is incomplete. Download the complete patch.

kernel/dma/virt.c

View file

This diff is incomplete. Download the complete patch.

lib/Kconfig

View file

This diff is incomplete. Download the complete patch.

lib/scatterlist.c

View file

This diff is incomplete. Download the complete patch.