dma-mapping:remove CONFIG_HAVE_DMA_ATTRS
Subsystems (3)
cover dma-mapping:remove CONFIG_HAVE_DMA_ATTRS
This patch sets enable CONFIG_HAVE_DMA_ATTRS always, so remove it in dma-mapping and Kconfig of X86 and IA64 arch, based on the following ideas:
1,Currently asm-generic/dma-mapping-common.h has provided dma_map_*_attrs() and dma_unmap_*_attrs(), and more ARCHs will move to asm-generic/dma-mapping-common.h;
2,Disabling CONFIG_HAVE_DMA_ATTRS may lead to a compile failure;
3,X86 and IA64 has taken asm-generic/dma-mapping-common.h and always enabled the option now;
4,If CONFIG_HAVE_DMA_ATTRS is enabled, dma_set/get_attr support the passed attrs is NULL.
PATCH 1/3 dma-mapping:remove CONFIG_HAVE_DMA_ATTRS
From: Ming Lei <[email protected]>
--- include/linux/dma-attrs.h | 10 ---------- include/linux/dma-mapping.h | 17 ----------------- 2 files changed, 0 insertions(+), 27 deletions(-)
include/linux/dma-attrs.h +0 -10
@@ -36,7 +36,6 @@ static inline void init_dma_attrs(struct dma_attrs *attrs)bitmap_zero (attrs->flags, __DMA_ATTRS_LONGS); } -#ifdef CONFIG_HAVE_DMA_ATTRS /** * dma_set_attr - set a specific attribute * @attr: attribute to set
@@ -62,14 +61,5 @@ static inline int dma_get_attr(enum dma_attr attr, struct dma_attrs *attrs)BUG_ON (attr >=DMA_ATTR_MAX ); return test_bit(attr, attrs->flags); } -#else /* !CONFIG_HAVE_DMA_ATTRS */ -static inline void dma_set_attr (enum dma_attr attr,struct dma_attrs *attrs) -{ -} -static inline int dma_get_attr (enum dma_attr attr,struct dma_attrs *attrs) -{ -return 0 ; -} -#endif /* CONFIG_HAVE_DMA_ATTRS */ #endif /* _DMA_ATTR_H */
include/linux/dma-mapping.h +0 -17
@@ -219,21 +219,4 @@ static inline void dmam_release_declared_memory(struct device *dev) }#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */ -#ifndef CONFIG_HAVE_DMA_ATTRS -struct dma_attrs ; - -#define dma_map_single_attrs (dev, cpu_addr, size, dir, attrs) \ - dma_map_single(dev, cpu_addr, size, dir) - -#define dma_unmap_single_attrs (dev, dma_addr, size, dir, attrs) \ - dma_unmap_single(dev, dma_addr, size, dir) - -#define dma_map_sg_attrs (dev, sgl, nents, dir, attrs) \ - dma_map_sg(dev, sgl, nents, dir) - -#define dma_unmap_sg_attrs (dev, sgl, nents, dir, attrs) \ - dma_unmap_sg(dev, sgl, nents, dir) - -#endif /* CONFIG_HAVE_DMA_ATTRS */ -#endif
Signature · 1 line
1.6.0.GIT
PATCH 2/3 dma-mapping:X86:remove CONFIG_HAVE_DMA_ATTRS
From: Ming Lei <[email protected]>
--- arch/x86/Kconfig | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
arch/x86/Kconfig +0 -1
@@ -28,7 +28,6 @@ config X86 select HAVE_KPROBES select ARCH_WANT_OPTIONAL_GPIOLIB select ARCH_WANT_FRAME_POINTERS - select HAVE_DMA_ATTRS select HAVE_KRETPROBES select HAVE_FTRACE_MCOUNT_RECORD select HAVE_DYNAMIC_FTRACE
Signature · 1 line
1.6.0.GIT
PATCH 3/3 dma-mapping:IA64:remove CONFIG_HAVE_DMA_ATTRS
From: Ming Lei <[email protected]>
--- arch/ia64/Kconfig | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
arch/ia64/Kconfig +0 -1
@@ -25,7 +25,6 @@ config IA64 select HAVE_FTRACE_MCOUNT_RECORD select HAVE_DYNAMIC_FTRACE if (!ITANIUM) select HAVE_FUNCTION_TRACER - select HAVE_DMA_ATTRS select HAVE_KVM select HAVE_ARCH_TRACEHOOK select HAVE_DMA_API_DEBUG
Signature · 1 line
1.6.0.GIT
Arnd Bergmann
maintainerQuoted 1 line · On Saturday 04 July 2009, [email protected] wrote:
2,Disabling
CONFIG_HAVE_DMA_ATTRSmay lead to a compile failure;
I'm not sure I understand this point. CONFIG_HAVE_DMA_ATTRS tells the common code whether the architecture understands dma attributes. If you enable it on all architectures, you will get new compile failures on all those that don't understand them, while the current code correctly falls back on the standard functions.
I think it makes sense to combine CONFIG_HAVE_DMA_ATTRS with the use of dma-mapping-common.h, but the majority of the architectures just uses a static mapping, where attributes make no sense.
You also missed powerpc64, which selects CONFIG_HAVE_DMA_ATTRS but does not (yet) use dma-mapping-common.h.
Arnd <><
Quoted 5 lines · On Sun, 5 Jul 2009 13:19:36 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 1 line · On Saturday 04 July 2009, [email protected] wrote:
2,Disabling
CONFIG_HAVE_DMA_ATTRSmay lead to a compile failure;I'm not sure I understand this point.
CONFIG_HAVE_DMA_ATTRStells the common code whether the architecture understands dma attributes.
If a new arch does not define CONFIG_HAVE_DMA_ATTRS but uses dma-mapping-common.h, it will lead to a compile failure.
include/asm-generic/dma-mapping-common.h
#define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL) ...
include/linux/dma-mapping.h
#ifndef CONFIG_HAVE_DMA_ATTRS
struct dma_attrs;
#define dma_map_single_attrs(dev, cpu_addr, size, dir, attrs) \
dma_map_single(dev, cpu_addr, size, dir)
...
#endifQuoted 3 lines
If you enable it on all architectures, you will get new compile failures on all those that don't understand them, while the current code correctly falls back on the standard functions.
You are right, the patch will lead to new compile failure for the ARCHs, on which disables CONFIG_HAVE_DMA_ATTRS and doesn't use dma-mapping-common.h. So the patch is not mature.
Quoted 7 lines
I think it makes sense to combine
CONFIG_HAVE_DMA_ATTRSwith the use ofdma-mapping-common.h, but the majority of the architectures just uses a static mapping, where attributes make no sense.You also missed powerpc64, which selects
CONFIG_HAVE_DMA_ATTRSbut does not (yet) usedma-mapping-common.h.
ppc64 doesn't use dma-mapping-common.h, so the patch doesn't consider it.
Signature · 1 line
Lei Ming
2009/7/5 Ming Lei <[email protected]>:
Quoted 20 lines
Quoted 5 lines · On Sun, 5 Jul 2009 13:19:36 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 1 line · On Saturday 04 July 2009, [email protected] wrote:
2,Disabling
CONFIG_HAVE_DMA_ATTRSmay lead to a compile failure;I'm not sure I understand this point.
CONFIG_HAVE_DMA_ATTRStells the common code whether the architecture understands dma attributes.If a new arch does not define
CONFIG_HAVE_DMA_ATTRSbut usesdma-mapping-common.h, it will lead to a compile failure.
include/asm-generic/dma-mapping-common.h#define
dma_map_single(d, a, s, r)dma_map_single_attrs(d, a, s, r, NULL)
...
include/linux/dma-mapping.h
Quoted 9 lines
#ifndef
CONFIG_HAVE_DMA_ATTRS
structdma_attrs;#define
dma_map_single_attrs(dev, cpu_addr, size, dir, attrs)\
dma_map_single(dev,cpu_addr, size, dir)
...
#endif
I have another idea to fix the possible compile failure. Does the following patch
work?
(quoted diff) +0 -0
b/include/asm-generic/dma-mapping-common.h
index 5406a60..39e2ec5 100644
include/asm-generic/dma-mapping-common.h +2 -0
@@ -6,6 +6,8 @@#include <linux/dma-debug.h> #include <linux/dma-attrs.h> +#define ARCH_USE_DMA_MAPPING_COMMON + static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr, size_t size, enum dma_data_direction dir,
include/linux/dma-mapping.h +0 -0
@@ -219,6 +219,7 @@ static inline void
dmam_release_declared_memory(struct device *dev)
}
#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */
+#ifndef ARCH_USE_DMA_MAPPING_COMMON
#ifndef CONFIG_HAVE_DMA_ATTRS
struct dma_attrs;
@@ -235,5 +236,7 @@ struct dma_attrs;
dma_unmap_sg(dev, sgl, nents, dir)
#endif /* CONFIG_HAVE_DMA_ATTRS */
+#endif /* ARCH_USE_DMA_MAPPING_COMMON */
+
#endif
Signature · 1 line
Lei Ming
Arnd Bergmann
maintainerQuoted 2 lines · Ming Lei
If a new arch does not define
CONFIG_HAVE_DMA_ATTRSbut usesdma-mapping-common.h, it will lead to a compile failure.
Right, but I think we should just mandate that every arch that wants to use dma-mapping-common.h should define CONFIG_HAVE_DMA_ATTRS, which is sort of implied by the definition of dma_map_ops anyway.
Arnd <><
Quoted 11 lines · On Sun, 5 Jul 2009 20:44:18 +0800 Ming Lei <[email protected]> wrote:
Quoted 5 lines · On Sun, 5 Jul 2009 13:19:36 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 1 line · On Saturday 04 July 2009, [email protected] wrote:
2,Disabling
CONFIG_HAVE_DMA_ATTRSmay lead to a compile failure;I'm not sure I understand this point.
CONFIG_HAVE_DMA_ATTRStells the common code whether the architecture understands dma attributes.If a new arch does not define
CONFIG_HAVE_DMA_ATTRSbut usesdma-mapping-common.h, it will lead to a compile failure.
Yeah, architectures that use dma-mapping-common.h need to define CONFIG_HAVE_DMA_ATTRS because dma-mapping-common.h needs to handle architectures that need CONFIG_HAVE_DMA_ATTRS.
Your idea doesn't sound good to me.
I think that it's better to define CONFIG_HAVE_DMA_ATTRS in the consistent way; defining arch's Kconfig. Defining CONFIG_HAVE_DMA_ATTRS in two different ways and inventing another define such as ARCH_USE_DMA_MAPPING_COMMON is just confusing.