Skip to content

Commit 15f900e

Browse files
mem: move creation of virtual region to sof
creation of virtual region should be done in SOF, not in Zephyr. Virtual regions are simply a dynamic memory map, zephyr's role is to provide the map and ensure no overlapping. Creation of regions is up to SOF as needed Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent be35b0d commit 15f900e

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

zephyr/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ config SOF_ZEPHYR_VIRTUAL_HEAP_SIZE
5050
NOTE: Keep in mind that the heap size should not be greater than the physical
5151
memory size of the system defined in DT (and this includes baseFW text/data).
5252

53+
config SOF_ZEPHYR_VIRTUAL_HEAP_REGION_SIZE
54+
hex "Size in bytes of virtual memory region for virtual heap shared for all cores"
55+
depends on MM_DRV_INTEL_ADSP_MTL_TLB
56+
default 0x100000
57+
help
58+
This config defines size of virtual heap region shared between all cores
59+
5360
config ZEPHYR_NATIVE_DRIVERS
5461
bool "Use Zephyr native drivers"
5562
default n

zephyr/include/sof/lib/regions_mm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include <zephyr/init.h>
1818
#include <zephyr/sys/mem_blocks.h>
1919

20+
/* Attributes for memory regions */
21+
#define VIRTUAL_REGION_SHARED_HEAP_ATTR 1U /*< region dedicated for shared virtual heap */
22+
2023
/* Dependency on ipc/topology.h created due to memory capability definitions
2124
* that are defined there
2225
*/

zephyr/lib/alloc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <sof/schedule/schedule.h>
1414
#include <sof/lib/notifier.h>
1515
#include <sof/lib/pm_runtime.h>
16+
#include <sof/lib/regions_mm.h>
1617
#include <sof/audio/pipeline.h>
1718
#include <sof/audio/component_ext.h>
1819
#include <sof/trace/trace.h>
@@ -290,6 +291,18 @@ static const struct vmh_heap_config static_hp_buffers = {
290291

291292
static int virtual_heap_init(void)
292293
{
294+
int ret;
295+
296+
if (virtual_buffers_heap)
297+
return -EEXIST;
298+
299+
/* add a virtual memory region */
300+
ret = adsp_add_virtual_memory_region(adsp_mm_get_unused_l2_start_aligned(),
301+
CONFIG_SOF_ZEPHYR_VIRTUAL_HEAP_REGION_SIZE,
302+
VIRTUAL_REGION_SHARED_HEAP_ATTR);
303+
if (ret)
304+
return ret;
305+
293306
virtual_buffers_heap = vmh_init_heap(&static_hp_buffers, false);
294307
if (!virtual_buffers_heap) {
295308
tr_err(&zephyr_tr, "Unable to init virtual heap");

zephyr/lib/regions_mm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct vmh_heap *vmh_init_heap(const struct vmh_heap_config *cfg, bool allocatin
6464
const struct sys_mm_drv_region *region;
6565

6666
SYS_MM_DRV_MEMORY_REGION_FOREACH(virtual_memory_regions, region) {
67-
if (region->attr == MEM_REG_ATTR_SHARED_HEAP) {
67+
if (region->attr == VIRTUAL_REGION_SHARED_HEAP_ATTR) {
6868
new_heap->virtual_region = region;
6969
break;
7070
}

0 commit comments

Comments
 (0)