* [PATCH 1/4] sandbox: set DMA_ALIGNMENT instead of defining dma_alloc
@ 2024-01-08 10:24 Ahmad Fatoum
2024-01-08 10:24 ` [PATCH 2/4] kvx: " Ahmad Fatoum
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2024-01-08 10:24 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov, Yann Sionneau, Ahmad Fatoum
<dma.h> will take care to define dma_alloc with DMA_ALIGNMENT as
alignment. As 32 is the default and we for some reason, use 64 for
sandbox, define DMA_ALIGNMENT and drop the now duplicate code.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/include/asm/dma.h | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h
index ac8b408aae0b..cafbb7fe6a4c 100644
--- a/arch/sandbox/include/asm/dma.h
+++ b/arch/sandbox/include/asm/dma.h
@@ -12,11 +12,7 @@
#include <linux/string.h>
#include <driver.h>
-#define dma_alloc dma_alloc
-static inline void *dma_alloc(size_t size)
-{
- return xmemalign(64, ALIGN(size, 64));
-}
+#define DMA_ALIGNMENT 64
#define dma_alloc_coherent dma_alloc_coherent
static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] kvx: set DMA_ALIGNMENT instead of defining dma_alloc
2024-01-08 10:24 [PATCH 1/4] sandbox: set DMA_ALIGNMENT instead of defining dma_alloc Ahmad Fatoum
@ 2024-01-08 10:24 ` Ahmad Fatoum
2024-01-08 12:07 ` Yann Sionneau
2024-01-08 10:24 ` [PATCH 3/4] mips: " Ahmad Fatoum
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Ahmad Fatoum @ 2024-01-08 10:24 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov, Yann Sionneau, Ahmad Fatoum
<dma.h> will take care to define dma_alloc with DMA_ALIGNMENT as
alignment. As 32 is the default and we for need 64 for kvx,
define DMA_ALIGNMENT and drop the now duplicate code.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/kvx/include/asm/dma.h | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/arch/kvx/include/asm/dma.h b/arch/kvx/include/asm/dma.h
index f35eafba8fae..c6f67e76d024 100644
--- a/arch/kvx/include/asm/dma.h
+++ b/arch/kvx/include/asm/dma.h
@@ -6,11 +6,7 @@
#include <common.h>
-#define dma_alloc dma_alloc
-static inline void *dma_alloc(size_t size)
-{
- return xmemalign(64, ALIGN(size, 64));
-}
+#define DMA_ALIGNMENT 64
#define dma_alloc_coherent dma_alloc_coherent
static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] mips: set DMA_ALIGNMENT instead of defining dma_alloc
2024-01-08 10:24 [PATCH 1/4] sandbox: set DMA_ALIGNMENT instead of defining dma_alloc Ahmad Fatoum
2024-01-08 10:24 ` [PATCH 2/4] kvx: " Ahmad Fatoum
@ 2024-01-08 10:24 ` Ahmad Fatoum
2024-01-08 10:24 ` [PATCH 4/4] dma: don't allow override of dma_alloc/dma_free Ahmad Fatoum
2024-01-10 6:45 ` [PATCH 1/4] sandbox: set DMA_ALIGNMENT instead of defining dma_alloc Sascha Hauer
3 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2024-01-08 10:24 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov, Yann Sionneau, Ahmad Fatoum
<dma.h> will take care to define dma_alloc with DMA_ALIGNMENT as
alignment. As 32 is the default and may not be applicable to the used
processor, we define DMA_ALIGNMENT and drop the now duplicate code.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/mips/include/asm/dma.h | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/arch/mips/include/asm/dma.h b/arch/mips/include/asm/dma.h
index d7570cce7109..5c5b6d5b3a58 100644
--- a/arch/mips/include/asm/dma.h
+++ b/arch/mips/include/asm/dma.h
@@ -14,13 +14,8 @@
#include <asm/io.h>
#include <asm/types.h>
-#define dma_alloc dma_alloc
-static inline void *dma_alloc(size_t size)
-{
- unsigned long max_linesz = max(current_cpu_data.dcache.linesz,
- current_cpu_data.scache.linesz);
- return xmemalign(max_linesz, ALIGN(size, max_linesz));
-}
+#define DMA_ALIGNMENT \
+ max(current_cpu_data.dcache.linesz, current_cpu_data.scache.linesz)
#define dma_alloc_coherent dma_alloc_coherent
static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/4] dma: don't allow override of dma_alloc/dma_free
2024-01-08 10:24 [PATCH 1/4] sandbox: set DMA_ALIGNMENT instead of defining dma_alloc Ahmad Fatoum
2024-01-08 10:24 ` [PATCH 2/4] kvx: " Ahmad Fatoum
2024-01-08 10:24 ` [PATCH 3/4] mips: " Ahmad Fatoum
@ 2024-01-08 10:24 ` Ahmad Fatoum
2024-01-10 6:45 ` [PATCH 1/4] sandbox: set DMA_ALIGNMENT instead of defining dma_alloc Sascha Hauer
3 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2024-01-08 10:24 UTC (permalink / raw)
To: barebox; +Cc: Peter Mamonov, Yann Sionneau, Ahmad Fatoum
There are no architectures left defining their own dma_alloc/dma_free.
Instead, they define DMA_ALIGNMENT and use <dma.h>'s common
implementation.
This will be useful later on, as we can use DMA_ALIGNMENT for sanity
checking with CONFIG_DMA_DEBUG_API. Till then, ensure we get no new
architecture-specific definitions of dma_alloc/dma_free, by preventing
override of the <dma.h> implementation.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/dma.h | 4 ----
1 file changed, 4 deletions(-)
diff --git a/include/dma.h b/include/dma.h
index 266a7f323fa5..df9807b4f2e4 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -21,19 +21,15 @@
#define DMA_ALIGNMENT 32
#endif
-#ifndef dma_alloc
static inline void *dma_alloc(size_t size)
{
return xmemalign(DMA_ALIGNMENT, ALIGN(size, DMA_ALIGNMENT));
}
-#endif
-#ifndef dma_free
static inline void dma_free(void *mem)
{
free(mem);
}
-#endif
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/4] kvx: set DMA_ALIGNMENT instead of defining dma_alloc
2024-01-08 10:24 ` [PATCH 2/4] kvx: " Ahmad Fatoum
@ 2024-01-08 12:07 ` Yann Sionneau
0 siblings, 0 replies; 6+ messages in thread
From: Yann Sionneau @ 2024-01-08 12:07 UTC (permalink / raw)
To: Ahmad Fatoum, barebox; +Cc: Peter Mamonov
Hello Ahmad,
On 1/8/24 11:24, Ahmad Fatoum wrote:
> <dma.h> will take care to define dma_alloc with DMA_ALIGNMENT as
> alignment. As 32 is the default and we for need 64 for kvx,
> define DMA_ALIGNMENT and drop the now duplicate code.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> arch/kvx/include/asm/dma.h | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/arch/kvx/include/asm/dma.h b/arch/kvx/include/asm/dma.h
> index f35eafba8fae..c6f67e76d024 100644
> --- a/arch/kvx/include/asm/dma.h
> +++ b/arch/kvx/include/asm/dma.h
> @@ -6,11 +6,7 @@
>
> #include <common.h>
>
> -#define dma_alloc dma_alloc
> -static inline void *dma_alloc(size_t size)
> -{
> - return xmemalign(64, ALIGN(size, 64));
> -}
> +#define DMA_ALIGNMENT 64
>
> #define dma_alloc_coherent dma_alloc_coherent
> static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
Small typo in the commit msg (`we for`) but otherwise Ack!
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
--
Yann
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/4] sandbox: set DMA_ALIGNMENT instead of defining dma_alloc
2024-01-08 10:24 [PATCH 1/4] sandbox: set DMA_ALIGNMENT instead of defining dma_alloc Ahmad Fatoum
` (2 preceding siblings ...)
2024-01-08 10:24 ` [PATCH 4/4] dma: don't allow override of dma_alloc/dma_free Ahmad Fatoum
@ 2024-01-10 6:45 ` Sascha Hauer
3 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2024-01-10 6:45 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, Peter Mamonov, Yann Sionneau
On Mon, Jan 08, 2024 at 11:24:35AM +0100, Ahmad Fatoum wrote:
> <dma.h> will take care to define dma_alloc with DMA_ALIGNMENT as
> alignment. As 32 is the default and we for some reason, use 64 for
> sandbox, define DMA_ALIGNMENT and drop the now duplicate code.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> arch/sandbox/include/asm/dma.h | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h
> index ac8b408aae0b..cafbb7fe6a4c 100644
> --- a/arch/sandbox/include/asm/dma.h
> +++ b/arch/sandbox/include/asm/dma.h
> @@ -12,11 +12,7 @@
> #include <linux/string.h>
> #include <driver.h>
>
> -#define dma_alloc dma_alloc
> -static inline void *dma_alloc(size_t size)
> -{
> - return xmemalign(64, ALIGN(size, 64));
> -}
> +#define DMA_ALIGNMENT 64
>
> #define dma_alloc_coherent dma_alloc_coherent
> static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-01-10 6:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-08 10:24 [PATCH 1/4] sandbox: set DMA_ALIGNMENT instead of defining dma_alloc Ahmad Fatoum
2024-01-08 10:24 ` [PATCH 2/4] kvx: " Ahmad Fatoum
2024-01-08 12:07 ` Yann Sionneau
2024-01-08 10:24 ` [PATCH 3/4] mips: " Ahmad Fatoum
2024-01-08 10:24 ` [PATCH 4/4] dma: don't allow override of dma_alloc/dma_free Ahmad Fatoum
2024-01-10 6:45 ` [PATCH 1/4] sandbox: set DMA_ALIGNMENT instead of defining dma_alloc Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox