Linux kmalloc() family of function is suitable for use with streaming DMA. barebox malloc() isn't though and changing that would increase the alignment of all allocations. Let's leave barebox malloc() as-is for now and have kmalloc/kcalloc and friends allocate memory suitable for DMA as in Linux. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- include/linux/slab.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 36b93bdd2f1b..47b0aec7e3b8 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -3,7 +3,7 @@ #ifndef _LINUX_SLAB_H #define _LINUX_SLAB_H -#include <malloc.h> +#include <dma.h> #include <linux/overflow.h> #include <linux/string.h> @@ -33,7 +33,7 @@ static inline void *kmalloc(size_t size, gfp_t flags) { - return malloc(size); + return dma_alloc(size); } struct kmem_cache { @@ -59,12 +59,12 @@ struct kmem_cache *kmem_cache_create(const char *name, unsigned int size, static inline void kmem_cache_destroy(struct kmem_cache *cache) { - free(cache); + dma_free(cache); } static inline void kfree(const void *mem) { - free((void *)mem); + dma_free((void *)mem); } static inline void *kmem_cache_alloc(struct kmem_cache *cache, gfp_t flags) @@ -88,7 +88,7 @@ static inline void kmem_cache_free(struct kmem_cache *cache, void *mem) static inline void *kzalloc(size_t size, gfp_t flags) { - return calloc(size, 1); + return dma_zalloc(size); } /** @@ -104,7 +104,7 @@ static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) static inline void *kcalloc(size_t n, size_t size, gfp_t flags) { - return calloc(n, size); + return dma_zalloc(size_mul(n, size)); } static inline void *krealloc(void *ptr, size_t size, gfp_t flags) -- 2.39.2