mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 1/2] dma: avoid clash between static inline and extern dma_alloc declarations
Date: Tue, 14 Jun 2022 11:15:55 +0200	[thread overview]
Message-ID: <20220614091556.1018102-1-a.fatoum@pengutronix.de> (raw)

dma_alloc/dma_sync/dma_free can be either either static inline definitions
usually supplied per arch or extern definitions that can be either
generic or supplied per arch.

To avoid clashes, expect static inline definitions to define a
preprocessor symbol for now. There is much duplication in the static
inline helpers, which we can remove in future.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
New patch, please apply to master.
---
 arch/arm/include/asm/dma.h          |  5 +++++
 arch/kvx/include/asm/dma.h          |  2 ++
 arch/mips/include/asm/dma-mapping.h |  2 ++
 arch/sandbox/include/asm/dma.h      |  5 +++++
 arch/x86/include/asm/dma.h          |  4 ++++
 include/dma.h                       | 12 ++++++++++++
 6 files changed, 30 insertions(+)

diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
index 226b1c146479..75a6c1ad86b2 100644
--- a/arch/arm/include/asm/dma.h
+++ b/arch/arm/include/asm/dma.h
@@ -10,6 +10,7 @@ static inline void *dma_alloc(size_t size)
 }
 
 #ifndef CONFIG_MMU
+#define dma_alloc_coherent dma_alloc_coherent
 static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 {
 	void *ret = xmemalign(4096, size);
@@ -21,22 +22,26 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 	return ret;
 }
 
+#define dma_alloc_writecombine dma_alloc_writecombine
 static inline void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
 {
 	return dma_alloc_coherent(size, dma_handle);
 }
 
+#define dma_free_coherent dma_free_coherent
 static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
 				     size_t size)
 {
 	free(mem);
 }
 
+#define dma_sync_single_for_cpu dma_sync_single_for_cpu
 static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
 					   enum dma_data_direction dir)
 {
 }
 
+#define dma_sync_single_for_device dma_sync_single_for_device
 static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
 					      enum dma_data_direction dir)
 {
diff --git a/arch/kvx/include/asm/dma.h b/arch/kvx/include/asm/dma.h
index a7ecf279a982..5bf601307e61 100644
--- a/arch/kvx/include/asm/dma.h
+++ b/arch/kvx/include/asm/dma.h
@@ -16,6 +16,7 @@ static inline void *dma_alloc(size_t size)
 	return xmemalign(64, ALIGN(size, 64));
 }
 
+#define dma_alloc_coherent dma_alloc_coherent
 static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 {
 	BUILD_BUG_ON_MSG(1, "dma_alloc_coherent not supported: "
@@ -23,6 +24,7 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 	return NULL;
 }
 
+#define dma_free_coherent dma_free_coherent
 static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
 				     size_t size)
 {
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index 19d5b3f7bc4d..8e6ea0816828 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -10,6 +10,7 @@
 #include <malloc.h>
 #include <asm/io.h>
 
+#define dma_alloc_coherent dma_alloc_coherent
 static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 {
 	void *ret;
@@ -26,6 +27,7 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 	return (void *)CKSEG1ADDR(ret);
 }
 
+#define dma_free_coherent dma_free_coherent
 static inline void dma_free_coherent(void *vaddr, dma_addr_t dma_handle,
 				     size_t size)
 {
diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h
index 34c0fc5190f8..958d10e2a199 100644
--- a/arch/sandbox/include/asm/dma.h
+++ b/arch/sandbox/include/asm/dma.h
@@ -18,6 +18,7 @@ static inline void *dma_alloc(size_t size)
 	return xmemalign(64, ALIGN(size, 64));
 }
 
+#define dma_alloc_coherent dma_alloc_coherent
 static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 {
 	void *ret = xmemalign(4096, size);
@@ -29,22 +30,26 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 	return ret;
 }
 
+#define dma_alloc_writecombine dma_alloc_writecombine
 static inline void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
 {
 	return dma_alloc_coherent(size, dma_handle);
 }
 
+#define dma_free_coherent dma_free_coherent
 static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
 				     size_t size)
 {
 	free(mem);
 }
 
+#define dma_sync_single_for_cpu dma_sync_single_for_cpu
 static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
 					   enum dma_data_direction dir)
 {
 }
 
+#define dma_sync_single_for_device dma_sync_single_for_device
 static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
 					      enum dma_data_direction dir)
 {
diff --git a/arch/x86/include/asm/dma.h b/arch/x86/include/asm/dma.h
index 8a3b044f3a9c..90791ecf3e07 100644
--- a/arch/x86/include/asm/dma.h
+++ b/arch/x86/include/asm/dma.h
@@ -13,6 +13,7 @@
  * x86 is cache coherent, so we need not do anything special here
  */
 
+#define dma_alloc_coherent dma_alloc_coherent
 static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 {
 	void *ret = xmemalign(4096, size);
@@ -24,17 +25,20 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 	return ret;
 }
 
+#define dma_free_coherent dma_free_coherent
 static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
 				     size_t size)
 {
 	free(mem);
 }
 
+#define dma_sync_single_for_cpu dma_sync_single_for_cpu
 static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
 					   enum dma_data_direction dir)
 {
 }
 
+#define dma_sync_single_for_device dma_sync_single_for_device
 static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
 					      enum dma_data_direction dir)
 {
diff --git a/include/dma.h b/include/dma.h
index 90f9254ea80f..2a271044f61c 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -57,14 +57,26 @@ static inline int dma_mapping_error(struct device_d *dev, dma_addr_t dma_addr)
 }
 
 /* streaming DMA - implement the below calls to support HAS_DMA */
+#ifndef dma_sync_single_for_cpu
 void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
 			     enum dma_data_direction dir);
+#endif
 
+#ifndef dma_sync_single_for_device
 void dma_sync_single_for_device(dma_addr_t address, size_t size,
 				enum dma_data_direction dir);
+#endif
 
+#ifndef dma_alloc_coherent
 void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle);
+#endif
+
+#ifndef dma_free_coherent
 void dma_free_coherent(void *mem, dma_addr_t dma_handle, size_t size);
+#endif
+
+#ifndef dma_alloc_writecombine
 void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle);
+#endif
 
 #endif /* __DMA_H */
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2022-06-14  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14  9:15 Ahmad Fatoum [this message]
2022-06-14  9:15 ` [PATCH 2/2] dma: add dma_sync nop stubs for PBL Ahmad Fatoum
2022-06-17  6:43 ` [PATCH master 1/2] dma: avoid clash between static inline and extern dma_alloc declarations Sascha Hauer
2022-06-17  6:48   ` Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220614091556.1018102-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --subject='Re: [PATCH master 1/2] dma: avoid clash between static inline and extern dma_alloc declarations' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox