Skip to contentSkip to conversation

move dma mapping code to kernel/dma

RFC In review Christoph Hellwig 2 participants 5 messages Jun 14, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hi all,

I'm tempted to send this little file move series to Linus around -rc1 where it would cause the least harm.

Opinions?

#1 lore raw

PATCH 1/2 dma-mapping: use obj-y instead of lib-y for generic dma ops

We already have exact config symbols to select the direct, non-coherent, or virt dma ops. So use the normal obj- scheme to select them.

---
 lib/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/Makefile +3 -3
index 956b320292fe..5e0e160c9242 100644
@@ -29,9 +29,9 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
 lib-$(CONFIG_PRINTK) += dump_stack.o
 lib-$(CONFIG_MMU) += ioremap.o
 lib-$(CONFIG_SMP) += cpumask.o
-lib-$(CONFIG_DMA_DIRECT_OPS) += dma-direct.o
-lib-$(CONFIG_DMA_NONCOHERENT_OPS) += dma-noncoherent.o
-lib-$(CONFIG_DMA_VIRT_OPS) += dma-virt.o
+obj-$(CONFIG_DMA_DIRECT_OPS) += dma-direct.o
+obj-$(CONFIG_DMA_NONCOHERENT_OPS) += dma-noncoherent.o
+obj-$(CONFIG_DMA_VIRT_OPS) += dma-virt.o
 
 lib-y	+= kobject.o klist.o
 obj-y	+= lockref.o
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 dma-mapping: move all DMA mapping code to kernel/dma

In reply to Christoph Hellwig

Currently the code is split over various files with dma- prefixes in the lib/ and drives/base directories, and the number of files keeps growing. Move them into a single directory to keep the code together and remove the file name prefixes. To match the irq infrastructure this directory is placed under the kernel/ directory.

---
 Documentation/driver-api/infrastructure.rst   |  4 +-
 MAINTAINERS                                   |  9 +---
 drivers/base/Makefile                         |  3 --
 include/linux/dma-contiguous.h                |  2 +-
 init/Kconfig                                  |  4 --
 kernel/Makefile                               |  1 +
 kernel/dma/Kconfig                            | 50 +++++++++++++++++++
 kernel/dma/Makefile                           | 11 ++++
 .../dma-coherent.c => kernel/dma/coherent.c   |  0
 .../dma/contiguous.c                          |  0
 lib/dma-debug.c => kernel/dma/debug.c         |  0
 lib/dma-direct.c => kernel/dma/direct.c       |  0
 .../dma-mapping.c => kernel/dma/mapping.c     |  2 +-
 .../dma/noncoherent.c                         |  0
 {lib => kernel/dma}/swiotlb.c                 |  0
 lib/dma-virt.c => kernel/dma/virt.c           |  2 -
 lib/Kconfig                                   | 47 +----------------
 lib/Makefile                                  |  6 ---
 18 files changed, 69 insertions(+), 72 deletions(-)
 create mode 100644 kernel/dma/Kconfig
 create mode 100644 kernel/dma/Makefile
 rename drivers/base/dma-coherent.c => kernel/dma/coherent.c (100%)
 rename drivers/base/dma-contiguous.c => kernel/dma/contiguous.c (100%)
 rename lib/dma-debug.c => kernel/dma/debug.c (100%)
 rename lib/dma-direct.c => kernel/dma/direct.c (100%)
 rename drivers/base/dma-mapping.c => kernel/dma/mapping.c (99%)
 rename lib/dma-noncoherent.c => kernel/dma/noncoherent.c (100%)
 rename {lib => kernel/dma}/swiotlb.c (100%)
 rename lib/dma-virt.c => kernel/dma/virt.c (98%)
Documentation/driver-api/infrastructure.rst +2 -2
index bee1b9a1702f..6172f3cc3d0b 100644
@@ -49,10 +49,10 @@ Device Drivers Base
 Device Drivers DMA Management
 -----------------------------
 
-.. kernel-doc:: drivers/base/dma-coherent.c
+.. kernel-doc:: kernel/dma/coherent.c
    :export:
 
-.. kernel-doc:: drivers/base/dma-mapping.c
+.. kernel-doc:: kernel/dma/mapping.c
    :export:
 
 Device drivers PnP support
MAINTAINERS +2 -7
index c13b9fb3be0b..a6844a9e2f64 100644
@@ -4359,12 +4359,7 @@ L:	[email protected]
 T:	git git://git.infradead.org/users/hch/dma-mapping.git
 W:	http://git.infradead.org/users/hch/dma-mapping.git
 S:	Supported
-F:	lib/dma-debug.c
-F:	lib/dma-direct.c
-F:	lib/dma-noncoherent.c
-F:	lib/dma-virt.c
-F:	drivers/base/dma-mapping.c
-F:	drivers/base/dma-coherent.c
+F:	kernel/dma/
 F:	include/asm-generic/dma-mapping.h
 F:	include/linux/dma-direct.h
 F:	include/linux/dma-mapping.h
@@ -13642,7 +13637,7 @@ M:	Konrad Rzeszutek Wilk <[email protected]>
 L:	[email protected]
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git
 S:	Supported
-F:	lib/swiotlb.c
+F:	kernel/dma/swiotlb.c
 F:	arch/*/kernel/pci-swiotlb.c
 F:	include/linux/swiotlb.h
 
drivers/base/Makefile +0 -3
index b074f242a435..704f44295810 100644
@@ -8,10 +8,7 @@ obj-y			:= component.o core.o bus.o dd.o syscore.o \
 			   topology.o container.o property.o cacheinfo.o \
 			   devcon.o
 obj-$(CONFIG_DEVTMPFS)	+= devtmpfs.o
-obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
 obj-y			+= power/
-obj-$(CONFIG_HAS_DMA)	+= dma-mapping.o
-obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
 obj-$(CONFIG_ISA_BUS_API)	+= isa.o
 obj-y				+= firmware_loader/
 obj-$(CONFIG_NUMA)	+= node.o
include/linux/dma-contiguous.h +1 -1
index b67bf6ac907d..3c5a4cb3eb95 100644
@@ -48,7 +48,7 @@
  *   CMA should not be used by the device drivers directly. It is
  *   only a helper framework for dma-mapping subsystem.
  *
- *   For more information, see kernel-docs in drivers/base/dma-contiguous.c
+ *   For more information, see kernel-docs in kernel/dma/contiguous.c
  */
 
 #ifdef __KERNEL__
init/Kconfig +0 -4
index 5a52f07259a2..fde3d09e8b27 100644
@@ -1719,10 +1719,6 @@ source "arch/Kconfig"
 
 endmenu		# General setup
 
-config HAVE_GENERIC_DMA_COHERENT
-	bool
-	default n
-
 config RT_MUTEXES
 	bool
 
kernel/Makefile +1 -0
index d2001624fe7a..04bc07c2b42a 100644
@@ -41,6 +41,7 @@ obj-y += printk/
 obj-y += irq/
 obj-y += rcu/
 obj-y += livepatch/
+obj-y += dma/
 
 obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
 obj-$(CONFIG_FREEZER) += freezer.o
kernel/dma/Kconfig new file +50 -0

50 lines not on this page · raw message

kernel/dma/Makefile new file +11 -0
new file mode 100644
index 000000000000..6de44e4eb454
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_HAS_DMA)			+= mapping.o
+obj-$(CONFIG_DMA_CMA)			+= contiguous.o
+obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += coherent.o
+obj-$(CONFIG_DMA_DIRECT_OPS)		+= direct.o
+obj-$(CONFIG_DMA_NONCOHERENT_OPS)	+= noncoherent.o
+obj-$(CONFIG_DMA_VIRT_OPS)		+= virt.o
+obj-$(CONFIG_DMA_API_DEBUG)		+= debug.o
+obj-$(CONFIG_SWIOTLB)			+= swiotlb.o
+
kernel/dma/coherent.c renamed from drivers/base/dma-coherent.c +0 -0
similarity index 100%
rename from drivers/base/dma-coherent.c
rename to kernel/dma/coherent.c
kernel/dma/contiguous.c renamed from drivers/base/dma-contiguous.c +0 -0
similarity index 100%
rename from drivers/base/dma-contiguous.c
rename to kernel/dma/contiguous.c
kernel/dma/debug.c renamed from lib/dma-debug.c +0 -0
similarity index 100%
rename from lib/dma-debug.c
rename to kernel/dma/debug.c
kernel/dma/direct.c renamed from lib/dma-direct.c +0 -0
similarity index 100%
rename from lib/dma-direct.c
rename to kernel/dma/direct.c
kernel/dma/mapping.c renamed from drivers/base/dma-mapping.c +1 -1
similarity index 99%
rename from drivers/base/dma-mapping.c
rename to kernel/dma/mapping.c
index f831a582209c..d2a92ddaac4d 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * drivers/base/dma-mapping.c - arch-independent dma-mapping routines
+ * arch-independent dma-mapping routines
  *
  * Copyright (c) 2006  SUSE Linux Products GmbH
  * Copyright (c) 2006  Tejun Heo <[email protected]>
kernel/dma/noncoherent.c renamed from lib/dma-noncoherent.c +0 -0
similarity index 100%
rename from lib/dma-noncoherent.c
rename to kernel/dma/noncoherent.c
kernel/dma/swiotlb.c renamed from lib/swiotlb.c +0 -0
similarity index 100%
rename from lib/swiotlb.c
rename to kernel/dma/swiotlb.c
kernel/dma/virt.c renamed from lib/dma-virt.c +0 -2
similarity index 98%
rename from lib/dma-virt.c
rename to kernel/dma/virt.c
index 8e61a02ef9ca..631ddec4b60a 100644
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- *	lib/dma-virt.c
- *
  * DMA operations that map to virtual addresses without flushing memory.
  */
 #include <linux/export.h>
lib/Kconfig +1 -46

61 lines not on this page · raw message

lib/Makefile +0 -6
index 5e0e160c9242..8153fdab287f 100644
@@ -29,9 +29,6 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
 lib-$(CONFIG_PRINTK) += dump_stack.o
 lib-$(CONFIG_MMU) += ioremap.o
 lib-$(CONFIG_SMP) += cpumask.o
-obj-$(CONFIG_DMA_DIRECT_OPS) += dma-direct.o
-obj-$(CONFIG_DMA_NONCOHERENT_OPS) += dma-noncoherent.o
-obj-$(CONFIG_DMA_VIRT_OPS) += dma-virt.o
 
 lib-y	+= kobject.o klist.o
 obj-y	+= lockref.o
@@ -148,7 +145,6 @@ obj-$(CONFIG_SMP) += percpu_counter.o
 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
 obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o
 obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o
@@ -169,8 +165,6 @@ obj-$(CONFIG_NLATTR) += nlattr.o
 
 obj-$(CONFIG_LRU_CACHE) += lru_cache.o
 
-obj-$(CONFIG_DMA_API_DEBUG) += dma-debug.o
-
 obj-$(CONFIG_GENERIC_CSUM) += checksum.o
 
 obj-$(CONFIG_GENERIC_ATOMIC64) += atomic64.o
Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH 2/2] dma-mapping: move all DMA mapping code to kernel/dma

Quoted 5 lines · Christoph Hellwig

Currently the code is split over various files with dma- prefixes in the lib/ and drives/base directories, and the number of files keeps growing. Move them into a single directory to keep the code together and remove the file name prefixes. To match the irq infrastructure this directory is placed under the kernel/ directory.

For my point of view, makes sense!

kernel/dma/Kconfig line 5

Quoted 4 lines
kernel/dma/Kconfig new file +4 -0
+config HAS_DMA
+       bool
+       depends on !NO_DMA
+       default y

I see it's just move from other file, though we might switch to
def_bool y
instead of two lines.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

Re: [PATCH 2/2] dma-mapping: move all DMA mapping code to kernel/dma

Quoted 10 lines · Andy Shevchenko

For my point of view, makes sense!

kernel/dma/Kconfig line 5

Quoted 4 lines
kernel/dma/Kconfig new file +4 -0
+config HAS_DMA
+       bool
+       depends on !NO_DMA
+       default y

I see it's just move from other file, though we might switch to
def_bool y
instead of two lines.

Makes sense, but I'd rather send it together with a bunch of other cleanups in that area for the 4.19 merge window.