Skip to content

Commit 59ec929

Browse files
marcinszkudlinskikv2019i
authored andcommitted
mem: remove virtual memory regions workarounds
remove all workarounds for virtual memory region creation: - stubs for zephyr functions - using first memory region without checking attributes Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent 87359c1 commit 59ec929

2 files changed

Lines changed: 10 additions & 25 deletions

File tree

zephyr/lib/alloc.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -289,25 +289,6 @@ static const struct vmh_heap_config static_hp_buffers = {
289289
},
290290
};
291291

292-
/* WA Stubs begin
293-
*
294-
* in order to merge a PR that moves initialization of virtual regions from Zephyr to SOF,
295-
* we need to create weak stubs for 2 functions that will need to be called once the PR is merged
296-
*/
297-
298-
__weak
299-
uintptr_t adsp_mm_get_unused_l2_start_aligned(void)
300-
{
301-
return 0;
302-
}
303-
304-
__weak
305-
int adsp_add_virtual_memory_region(uintptr_t region_address, uint32_t region_size, uint32_t attr)
306-
{
307-
return 0;
308-
}
309-
/* WA Stubs end */
310-
311292
static int virtual_heap_init(void)
312293
{
313294
int ret;

zephyr/lib/regions_mm.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ struct vmh_heap {
4949
*/
5050
struct vmh_heap *vmh_init_heap(const struct vmh_heap_config *cfg, bool allocating_continuously)
5151
{
52+
const struct sys_mm_drv_region *virtual_memory_regions =
53+
sys_mm_drv_query_memory_regions();
5254
int i;
55+
5356
struct vmh_heap *new_heap =
5457
rzalloc(SOF_MEM_FLAG_KERNEL | SOF_MEM_FLAG_COHERENT, sizeof(*new_heap));
5558

@@ -58,13 +61,14 @@ struct vmh_heap *vmh_init_heap(const struct vmh_heap_config *cfg, bool allocatin
5861

5962
k_mutex_init(&new_heap->lock);
6063
struct vmh_heap_config new_config = {0};
64+
const struct sys_mm_drv_region *region;
6165

62-
/* Workaround - use the very first virtual memory region because of virt addresses
63-
* collision.
64-
* Fix will be provided ASAP, but removing MEM_REG_ATTR_SHARED_HEAP from SOF is required
65-
* to merge Zephyr changes
66-
*/
67-
new_heap->virtual_region = sys_mm_drv_query_memory_regions();
66+
SYS_MM_DRV_MEMORY_REGION_FOREACH(virtual_memory_regions, region) {
67+
if (region->attr == VIRTUAL_REGION_SHARED_HEAP_ATTR) {
68+
new_heap->virtual_region = region;
69+
break;
70+
}
71+
}
6872
if (!new_heap->virtual_region || !new_heap->virtual_region->size)
6973
goto fail;
7074

0 commit comments

Comments
 (0)