mirror of https://github.com/thesofproject/sof.git
alloc: add method for getting shared memory
Adds platform implementations for getting shared memory. Uncached tranformations are not very generic, since not all platforms have such memory region. Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit is contained in:
parent
84bc15e3dd
commit
d2b0823daa
|
@ -187,10 +187,8 @@ static void *rmalloc_sys(uint32_t flags, int caps, int core, size_t bytes)
|
|||
dcache_writeback_invalidate_region(cpu_heap,
|
||||
sizeof(*cpu_heap));
|
||||
|
||||
if (flags & SOF_MEM_FLAG_SHARED) {
|
||||
dcache_invalidate_region(ptr, bytes);
|
||||
ptr = cache_to_uncache(ptr);
|
||||
}
|
||||
if (flags & SOF_MEM_FLAG_SHARED)
|
||||
ptr = platform_shared_get(ptr, bytes);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
@ -422,10 +420,8 @@ static void *get_ptr_from_heap(struct mm_heap *heap, uint32_t flags,
|
|||
break;
|
||||
}
|
||||
|
||||
if (ptr && (flags & SOF_MEM_FLAG_SHARED)) {
|
||||
dcache_invalidate_region(ptr, bytes);
|
||||
ptr = cache_to_uncache(ptr);
|
||||
}
|
||||
if (ptr && (flags & SOF_MEM_FLAG_SHARED))
|
||||
ptr = platform_shared_get(ptr, bytes);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
@ -775,10 +771,8 @@ static void *alloc_heap_buffer(struct mm_heap *heap, uint32_t flags,
|
|||
}
|
||||
}
|
||||
|
||||
if (ptr && (flags & SOF_MEM_FLAG_SHARED)) {
|
||||
dcache_invalidate_region(ptr, bytes);
|
||||
ptr = cache_to_uncache(ptr);
|
||||
}
|
||||
if (ptr && (flags & SOF_MEM_FLAG_SHARED))
|
||||
ptr = platform_shared_get(ptr, bytes);
|
||||
|
||||
#if CONFIG_DEBUG_BLOCK_FREE
|
||||
if (ptr)
|
||||
|
|
|
@ -13,7 +13,14 @@
|
|||
#include <config.h>
|
||||
|
||||
#if !defined(__ASSEMBLER__) && !defined(LINKER)
|
||||
|
||||
void platform_init_memmap(void);
|
||||
|
||||
static inline void *platform_shared_get(void *ptr, int bytes)
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define PLATFORM_DCACHE_ALIGN sizeof(void *)
|
||||
|
|
|
@ -13,7 +13,14 @@
|
|||
#include <config.h>
|
||||
|
||||
#if !defined(__ASSEMBLER__) && !defined(LINKER)
|
||||
|
||||
void platform_init_memmap(void);
|
||||
|
||||
static inline void *platform_shared_get(void *ptr, int bytes)
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* data cache line alignment */
|
||||
|
|
|
@ -172,7 +172,14 @@
|
|||
#define HEAP_BUF_ALIGNMENT PLATFORM_DCACHE_ALIGN
|
||||
|
||||
#if !defined(__ASSEMBLER__) && !defined(LINKER)
|
||||
|
||||
void platform_init_memmap(void);
|
||||
|
||||
static inline void *platform_shared_get(void *ptr, int bytes)
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __PLATFORM_LIB_MEMORY_H__ */
|
||||
|
|
|
@ -74,6 +74,22 @@
|
|||
#define is_uncached(address) \
|
||||
(((uint32_t)(address) & SRAM_ALIAS_MASK) == SRAM_ALIAS_BASE)
|
||||
|
||||
/**
|
||||
* \brief Returns pointer to the memory shared by multiple cores.
|
||||
* \param[in,out] ptr Initial pointer to the allocated memory.
|
||||
* \param[in] bytes Size of the allocated memory
|
||||
* \return Appropriate pointer to the shared memory.
|
||||
*
|
||||
* This function is called only once right after allocation of shared memory.
|
||||
* Platforms with uncached memory region should return aliased address.
|
||||
* On platforms without such region simple invalidate is enough.
|
||||
*/
|
||||
static inline void *platform_shared_get(void *ptr, int bytes)
|
||||
{
|
||||
dcache_invalidate_region(ptr, bytes);
|
||||
return cache_to_uncache(ptr);
|
||||
}
|
||||
|
||||
void platform_init_memmap(void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue