mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
Make kmalloc'ed memory really DMA-safe
In Linux, the memory returned by kmalloc() is DMA-capable. However, it is not true in U-Boot. At a glance, kmalloc() in U-Boot returns address aligned with ARCH_DMA_MINALIGN. However, it never pads the allocated memory. This half-way house is completely useless because calling kmalloc() and malloc() in this order causes a cache sharing problem. Change the implementation to call malloc_cache_aligned(), which allocates really DMA-capable memory. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
4b0a2d3aab
commit
e3332e1a1a
1 changed files with 3 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <memalign.h>
|
||||
#include <linux/compat.h>
|
||||
|
||||
struct p_current cur = {
|
||||
|
@ -18,7 +19,7 @@ void *kmalloc(size_t size, int flags)
|
|||
{
|
||||
void *p;
|
||||
|
||||
p = memalign(ARCH_DMA_MINALIGN, size);
|
||||
p = malloc_cache_aligned(size);
|
||||
if (flags & __GFP_ZERO)
|
||||
memset(p, 0, size);
|
||||
|
||||
|
@ -37,5 +38,5 @@ struct kmem_cache *get_mem(int element_sz)
|
|||
|
||||
void *kmem_cache_alloc(struct kmem_cache *obj, int flag)
|
||||
{
|
||||
return memalign(ARCH_DMA_MINALIGN, obj->sz);
|
||||
return malloc_cache_aligned(obj->sz);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue