From 79e072715ac88d716cf2a0ce7254ad5d06158d92 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 11 Oct 2021 13:51:18 +0800 Subject: [PATCH 01/14] testbench: alloc: update rballoc_align with buffer initialized Update to initiaze the new allocated buffers to all 0s by rballoc_align() helper. Signed-off-by: Keyon Jie --- src/platform/library/lib/alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/library/lib/alloc.c b/src/platform/library/lib/alloc.c index d33d82f49e52..ee847a41717f 100644 --- a/src/platform/library/lib/alloc.c +++ b/src/platform/library/lib/alloc.c @@ -34,7 +34,7 @@ void rfree(void *ptr) void *rballoc_align(uint32_t flags, uint32_t caps, size_t bytes, uint32_t alignment) { - return malloc(bytes); + return calloc(bytes, 1); } void *rbrealloc_align(void *ptr, uint32_t flags, uint32_t caps, size_t bytes, From 59afda05c2b1309e6746af0ac1c079522117ca32 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 11 Oct 2021 13:53:33 +0800 Subject: [PATCH 02/14] alloc: update comments with 0s initialized for rballoc_align() The rballoc_align() helper will initialize new allocated buffers with 0s, update comments to document this. Signed-off-by: Keyon Jie --- src/include/sof/lib/alloc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/include/sof/lib/alloc.h b/src/include/sof/lib/alloc.h index 8f84ab9beefd..5a3cf116b5a2 100644 --- a/src/include/sof/lib/alloc.h +++ b/src/include/sof/lib/alloc.h @@ -94,7 +94,8 @@ void *rmalloc(enum mem_zone zone, uint32_t flags, uint32_t caps, size_t bytes); void *rzalloc(enum mem_zone zone, uint32_t flags, uint32_t caps, size_t bytes); /** - * Allocates memory block from SOF_MEM_ZONE_BUFFER. + * Allocates memory block from SOF_MEM_ZONE_BUFFER, + * the allocated buffer will be initialized to 0s. * @param flags Flags, see SOF_MEM_FLAG_... * @param caps Capabilities, see SOF_MEM_CAPS_... * @param bytes Size in bytes. From 5e86bced48a81b624c3b3eef421c5a50d1deaabf Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Sun, 10 Oct 2021 08:31:38 +0800 Subject: [PATCH 03/14] dma-trace: avoid multiple allocations to fix fuzzy IPC The fuzzy IPC testing reports there is memory leak if dma_trace_config IPC is sent multiple times, we should just return if the DMA trace buffer is already allocated, to avoid allocating new buffers and the leakage of the old buffers. Signed-off-by: Keyon Jie --- src/trace/dma-trace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/trace/dma-trace.c b/src/trace/dma-trace.c index e757c1a94fae..8ee10f444c2d 100644 --- a/src/trace/dma-trace.c +++ b/src/trace/dma-trace.c @@ -224,6 +224,10 @@ static int dma_trace_buffer_init(struct dma_trace_data *d) void *buf; unsigned int flags; + /* return if already initialized */ + if (buffer->addr) + return 0; + /* allocate new buffer */ buf = rballoc(0, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA, DMA_TRACE_LOCAL_SIZE); From 3a8fdca150cfaa3e08784810923257a69f5827f1 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Sat, 9 Oct 2021 10:35:16 +0800 Subject: [PATCH 04/14] alloc: free_block: perform wb/inv for the blocks When freeing blocks, we need to perform writeback and invalidate to the dirty cache lines, otherwise, they will be evicted from the cache at some point in the future, which will break the usage of the same memory region from another DSP core. Introduce a free_ptr to make sure the original 'ptr' is not changed, so we can use it for this wb/inv operation. Signed-off-by: Keyon Jie --- src/lib/alloc.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/lib/alloc.c b/src/lib/alloc.c index 15ed8dc352c6..782e2e170ad6 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -453,6 +453,7 @@ static void free_block(void *ptr) struct block_hdr *hdr; void *cached_ptr = uncache_to_cache(ptr); void *uncached_ptr = cache_to_uncache(ptr); + void *free_ptr; int i; int block; int used_blocks; @@ -465,13 +466,13 @@ static void free_block(void *ptr) if (!heap) { heap = get_heap_from_ptr(uncached_ptr); if (!heap) { - tr_err(&mem_tr, "free_block(): invalid heap = %p, cpu = %d", + tr_err(&mem_tr, "free_block(): invalid heap, ptr = %p, cpu = %d", ptr, cpu_get_id()); return; } - ptr = uncached_ptr; + free_ptr = uncached_ptr; } else { - ptr = cached_ptr; + free_ptr = cached_ptr; } /* find block that ptr belongs to */ @@ -479,7 +480,7 @@ static void free_block(void *ptr) block_map = &heap->map[i]; /* is ptr in this block */ - if ((uint32_t)ptr < (block_map->base + + if ((uint32_t)free_ptr < (block_map->base + (block_map->block_size * block_map->count))) break; @@ -488,13 +489,13 @@ static void free_block(void *ptr) if (i == heap->blocks) { /* not found */ - tr_err(&mem_tr, "free_block(): invalid ptr = %p cpu = %d", - ptr, cpu_get_id()); + tr_err(&mem_tr, "free_block(): invalid free_ptr = %p cpu = %d", + free_ptr, cpu_get_id()); return; } /* calculate block header */ - block = ((uint32_t)ptr - block_map->base) / block_map->block_size; + block = ((uint32_t)free_ptr - block_map->base) / block_map->block_size; hdr = &block_map->block[block]; @@ -503,17 +504,25 @@ static void free_block(void *ptr) * be from different block since we got user pointer here * or null if header was not set) */ - if (hdr->unaligned_ptr != ptr && hdr->unaligned_ptr) { - ptr = hdr->unaligned_ptr; - block = ((uint32_t)ptr - block_map->base) + if (hdr->unaligned_ptr != free_ptr && hdr->unaligned_ptr) { + free_ptr = hdr->unaligned_ptr; + block = ((uint32_t)free_ptr - block_map->base) / block_map->block_size; hdr = &block_map->block[block]; } /* report an error if ptr is not aligned to block */ - if (block_map->base + block_map->block_size * block != (uint32_t)ptr) + if (block_map->base + block_map->block_size * block != (uint32_t)free_ptr) panic(SOF_IPC_PANIC_MEM); + /* There may still be live dirty cache lines in the region + * on the current core. Those must be invalidated, otherwise + * they will be evicted from the cache at some point in the + * future, on top of the memory region now being used for + * different purposes on another core. + */ + dcache_writeback_invalidate_region(ptr, block_map->block_size * hdr->size); + heap_is_full = !block_map->free_count; /* free block header and continuous blocks */ From 86fb3b738d8cf989b02b18df02f333a3c90f04e6 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 15 Sep 2021 14:56:02 +0800 Subject: [PATCH 05/14] alloc: remove the usage of runtime_shared zone Change the usage of the runtime_shared zone to the buffer zone, and the calling of rmalloc/rzalloc() from runtime_shared zone to rballoc() with SOF_MEM_ZONE_RUNTIME_SHARED flag. Change the rballoc to zeroing allocated buffers to meet the rzalloc() usage also. Signed-off-by: Keyon Jie --- src/arch/xtensa/lib/cpu.c | 2 +- src/audio/buffer.c | 4 ++-- src/audio/dai.c | 2 +- src/drivers/dw/dma.c | 4 ++-- src/drivers/generic/dummy-dma.c | 2 +- src/drivers/imx/esai.c | 2 +- src/drivers/imx/sai.c | 2 +- src/drivers/intel/alh.c | 2 +- src/drivers/intel/dmic/dmic.c | 2 +- src/drivers/intel/hda/hda-dma.c | 4 ++-- src/drivers/intel/hda/hda.c | 2 +- src/drivers/intel/ssp/ssp.c | 2 +- src/drivers/interrupt.c | 2 +- src/drivers/mediatek/mt8195/afe-drv.c | 6 +++--- src/include/sof/ipc/msg.h | 4 ++-- src/ipc/ipc3/dai.c | 2 +- src/ipc/ipc3/helper.c | 6 +++--- src/ipc/ipc4/helper.c | 4 ++-- 18 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/arch/xtensa/lib/cpu.c b/src/arch/xtensa/lib/cpu.c index dcbe811f2476..fd74064c4052 100644 --- a/src/arch/xtensa/lib/cpu.c +++ b/src/arch/xtensa/lib/cpu.c @@ -46,7 +46,7 @@ static void alloc_shared_secondary_cores_objects(void) { uint8_t *dynamic_vectors; - dynamic_vectors = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, 0, SOF_DYNAMIC_VECTORS_SIZE); + dynamic_vectors = rballoc(SOF_MEM_FLAG_COHERENT, 0, SOF_DYNAMIC_VECTORS_SIZE); if (dynamic_vectors == NULL) panic(SOF_IPC_PANIC_MEM); diff --git a/src/audio/buffer.c b/src/audio/buffer.c index fb90ddf3326a..b682eb148e2f 100644 --- a/src/audio/buffer.c +++ b/src/audio/buffer.c @@ -38,14 +38,14 @@ struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t align) } /* allocate new buffer */ - buffer = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + buffer = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*buffer)); if (!buffer) { tr_err(&buffer_tr, "buffer_alloc(): could not alloc structure"); return NULL; } - buffer->lock = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + buffer->lock = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*buffer->lock)); if (!buffer->lock) { rfree(buffer); diff --git a/src/audio/dai.c b/src/audio/dai.c index bc437939b36e..08f05bd3d225 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -164,7 +164,7 @@ static struct comp_dev *dai_new(const struct comp_driver *drv, return NULL; dev->ipc_config = *config; - dd = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*dd)); + dd = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*dd)); if (!dd) { rfree(dev); return NULL; diff --git a/src/drivers/dw/dma.c b/src/drivers/dw/dma.c index 70d640581718..bf4664f9c470 100644 --- a/src/drivers/dw/dma.c +++ b/src/drivers/dw/dma.c @@ -966,7 +966,7 @@ static int dw_dma_probe(struct dma *dma) pm_runtime_get_sync(DW_DMAC_CLK, dma->plat_data.id); /* allocate dma channels */ - dma->chan = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + dma->chan = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct dma_chan_data) * dma->plat_data.channels); if (!dma->chan) { @@ -987,7 +987,7 @@ static int dw_dma_probe(struct dma *dma) chan->index = i; chan->core = DMA_CORE_INVALID; - dw_chan = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + dw_chan = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*dw_chan)); if (!dw_chan) { diff --git a/src/drivers/generic/dummy-dma.c b/src/drivers/generic/dummy-dma.c index 7e3165120ad4..1c8245981e72 100644 --- a/src/drivers/generic/dummy-dma.c +++ b/src/drivers/generic/dummy-dma.c @@ -435,7 +435,7 @@ static int dummy_dma_probe(struct dma *dma) return -EEXIST; /* already created */ } - dma->chan = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + dma->chan = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, dma->plat_data.channels * sizeof(dma->chan[0])); if (!dma->chan) { tr_err(&ddma_tr, "dummy-dmac %d: Out of memory!", diff --git a/src/drivers/imx/esai.c b/src/drivers/imx/esai.c index 26e7bfd3f944..4479a03a3163 100644 --- a/src/drivers/imx/esai.c +++ b/src/drivers/imx/esai.c @@ -394,7 +394,7 @@ static int esai_probe(struct dai *dai) dai_err(dai, "ESAI: Repeated probe, skipping"); return -EEXIST; } - pdata = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*pdata)); + pdata = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*pdata)); if (!pdata) { dai_err(dai, "ESAI probe failure, out of memory"); return -ENOMEM; diff --git a/src/drivers/imx/sai.c b/src/drivers/imx/sai.c index 2c013b5b5d3d..13c9ed0a2c58 100644 --- a/src/drivers/imx/sai.c +++ b/src/drivers/imx/sai.c @@ -367,7 +367,7 @@ static int sai_probe(struct dai *dai) dai_info(dai, "SAI: sai_probe"); /* allocate private data */ - sai = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*sai)); + sai = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*sai)); if (!sai) { dai_err(dai, "sai_probe(): alloc failed"); return -ENOMEM; diff --git a/src/drivers/intel/alh.c b/src/drivers/intel/alh.c index 2e241eed8b4f..c6704f7b0295 100644 --- a/src/drivers/intel/alh.c +++ b/src/drivers/intel/alh.c @@ -117,7 +117,7 @@ static int alh_probe(struct dai *dai) if (dai_get_drvdata(dai)) return -EEXIST; - alh = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*alh)); + alh = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*alh)); if (!alh) { dai_err(dai, "alh_probe() error: alloc failed"); return -ENOMEM; diff --git a/src/drivers/intel/dmic/dmic.c b/src/drivers/intel/dmic/dmic.c index 139e7fa0b0b0..2a5c0f79a7da 100644 --- a/src/drivers/intel/dmic/dmic.c +++ b/src/drivers/intel/dmic/dmic.c @@ -554,7 +554,7 @@ static int dmic_probe(struct dai *dai) if (dai_get_drvdata(dai)) return -EEXIST; /* already created */ - dmic = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*dmic)); + dmic = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*dmic)); if (!dmic) { dai_err(dai, "dmic_probe(): alloc failed"); return -ENOMEM; diff --git a/src/drivers/intel/hda/hda-dma.c b/src/drivers/intel/hda/hda-dma.c index 0e911afd2181..3311d1cf48c0 100644 --- a/src/drivers/intel/hda/hda-dma.c +++ b/src/drivers/intel/hda/hda-dma.c @@ -786,7 +786,7 @@ static int hda_dma_probe(struct dma *dma) if (dma->chan) return -EEXIST; /* already created */ - dma->chan = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + dma->chan = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct dma_chan_data) * dma->plat_data.channels); if (!dma->chan) { @@ -804,7 +804,7 @@ static int hda_dma_probe(struct dma *dma) chan->status = COMP_STATE_INIT; chan->core = DMA_CORE_INVALID; - hda_chan = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, + hda_chan = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct hda_chan_data)); if (!hda_chan) { diff --git a/src/drivers/intel/hda/hda.c b/src/drivers/intel/hda/hda.c index da4be0a696c4..6040b9eea271 100644 --- a/src/drivers/intel/hda/hda.c +++ b/src/drivers/intel/hda/hda.c @@ -71,7 +71,7 @@ static int hda_probe(struct dai *dai) if (dai_get_drvdata(dai)) return -EEXIST; - hda = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*hda)); + hda = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*hda)); if (!hda) { dai_err(dai, "hda_probe() error: alloc failed"); return -ENOMEM; diff --git a/src/drivers/intel/ssp/ssp.c b/src/drivers/intel/ssp/ssp.c index 70b7f2e3ef7c..861c8e116c43 100644 --- a/src/drivers/intel/ssp/ssp.c +++ b/src/drivers/intel/ssp/ssp.c @@ -1132,7 +1132,7 @@ static int ssp_probe(struct dai *dai) return -EEXIST; /* already created */ /* allocate private data */ - ssp = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*ssp)); + ssp = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*ssp)); if (!ssp) { dai_err(dai, "ssp_probe(): alloc failed"); return -ENOMEM; diff --git a/src/drivers/interrupt.c b/src/drivers/interrupt.c index 60c7d7b103df..c77fedc52f1a 100644 --- a/src/drivers/interrupt.c +++ b/src/drivers/interrupt.c @@ -204,7 +204,7 @@ static int irq_register_child(struct irq_cascade_desc *cascade, int irq, /* init child from run-time, may be registered and unregistered * many times at run-time */ - child = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + child = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct irq_desc)); if (!child) { ret = -ENOMEM; diff --git a/src/drivers/mediatek/mt8195/afe-drv.c b/src/drivers/mediatek/mt8195/afe-drv.c index f9461f55a449..f8b61f0803d7 100644 --- a/src/drivers/mediatek/mt8195/afe-drv.c +++ b/src/drivers/mediatek/mt8195/afe-drv.c @@ -352,7 +352,7 @@ int afe_probe(struct mtk_base_afe *afe) tr_dbg(&afedrv_tr, "afe_base:0x%x\n", afe->base); /* TODO how to get the memif number, how to sync with dmac lib */ afe->memifs_size = platform->memif_size; - afe->memif = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + afe->memif = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct mtk_base_afe_memif) * afe->memifs_size); if (!afe->memif) return -ENOMEM; @@ -362,14 +362,14 @@ int afe_probe(struct mtk_base_afe *afe) /* TODO how to get the dai number, how to sync with dai lib*/ afe->dais_size = platform->dais_size; - afe->dais = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + afe->dais = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct mtk_base_afe_dai) * afe->dais_size); if (!afe->dais) goto err_alloc_memif; /* TODO how to get the irq number */ afe->irqs_size = platform->irqs_size; - afe->irqs = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + afe->irqs = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct mtk_base_afe_irq) * afe->irqs_size); if (!afe->irqs) goto err_alloc_dais; diff --git a/src/include/sof/ipc/msg.h b/src/include/sof/ipc/msg.h index 4c5cea20e586..f34d3edfa4ec 100644 --- a/src/include/sof/ipc/msg.h +++ b/src/include/sof/ipc/msg.h @@ -45,11 +45,11 @@ static inline struct ipc_msg *ipc_msg_init(uint32_t header, uint32_t size) { struct ipc_msg *msg; - msg = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*msg)); + msg = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*msg)); if (!msg) return NULL; - msg->tx_data = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, size); + msg->tx_data = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, size); if (!msg->tx_data) { rfree(msg); return NULL; diff --git a/src/ipc/ipc3/dai.c b/src/ipc/ipc3/dai.c index 3f920e924e00..7701bc31631a 100644 --- a/src/ipc/ipc3/dai.c +++ b/src/ipc/ipc3/dai.c @@ -287,7 +287,7 @@ int dai_config(struct comp_dev *dev, struct ipc_config_dai *common_config, /* allocated dai_config if not yet */ if (!dd->dai_spec_config) { - dd->dai_spec_config = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + dd->dai_spec_config = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct sof_ipc_dai_config)); if (!dd->dai_spec_config) { comp_err(dev, "dai_config(): No memory for dai_config."); diff --git a/src/ipc/ipc3/helper.c b/src/ipc/ipc3/helper.c index 2cd566c745bf..a16b7815aec7 100644 --- a/src/ipc/ipc3/helper.c +++ b/src/ipc/ipc3/helper.c @@ -358,7 +358,7 @@ int ipc_pipeline_new(struct ipc *ipc, ipc_pipe_new *_pipe_desc) } /* allocate the IPC pipeline container */ - ipc_pipe = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + ipc_pipe = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct ipc_comp_dev)); if (!ipc_pipe) { pipeline_free(pipe); @@ -431,7 +431,7 @@ int ipc_buffer_new(struct ipc *ipc, const struct sof_ipc_buffer *desc) return -ENOMEM; } - ibd = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + ibd = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct ipc_comp_dev)); if (!ibd) { buffer_free(buffer); @@ -639,7 +639,7 @@ int ipc_comp_new(struct ipc *ipc, ipc_comp *_comp) } /* allocate the IPC component container */ - icd = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + icd = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct ipc_comp_dev)); if (!icd) { tr_err(&ipc_tr, "ipc_comp_new(): alloc failed"); diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index a3cffd31e5b6..c4720760dc53 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -118,7 +118,7 @@ int ipc_pipeline_new(struct ipc *ipc, ipc_pipe_new *_pipe_desc) pipe->period = 1000; /* allocate the IPC pipeline container */ - ipc_pipe = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + ipc_pipe = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct ipc_comp_dev)); if (!ipc_pipe) { pipeline_free(pipe); @@ -393,7 +393,7 @@ int ipc4_add_comp_dev(struct comp_dev *dev) struct ipc_comp_dev *icd; /* allocate the IPC component container */ - icd = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, + icd = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(struct ipc_comp_dev)); if (!icd) { tr_err(&ipc_tr, "ipc_comp_new(): alloc failed"); From de206ad0269b06178e54edadffc1f064a42beca7 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 22 Sep 2021 19:06:28 +0800 Subject: [PATCH 06/14] tools: testbench: remove the usage of RUNTIME_SHARED zone Change to use rballoc(SOF_MEM_FLAG_COHERENT,) one now. Signed-off-by: Keyon Jie --- tools/testbench/file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testbench/file.c b/tools/testbench/file.c index c6d1ddcf6dba..856d3a29c708 100644 --- a/tools/testbench/file.c +++ b/tools/testbench/file.c @@ -434,19 +434,19 @@ static struct comp_dev *file_new(const struct comp_driver *drv, dev->ipc_config = *config; /* allocate memory for file comp data */ - dd = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*dd)); + dd = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*dd)); if (!dd) goto error_skip_dd; - fdai = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*fdai)); + fdai = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*fdai)); if (!fdai) goto error_skip_dai; - fdrv = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*fdrv)); + fdrv = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*fdrv)); if (!fdrv) goto error_skip_drv; - cd = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*cd)); + cd = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*cd)); if (!cd) goto error_skip_cd; From 39bb7691b7546d1f459ea248045c21f7833fd7e8 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 27 Aug 2021 17:59:31 +0800 Subject: [PATCH 07/14] mux: use rballoc() for allocating big buffer The mux cd could be bigger than 1KB, change to use rballoc() for allocating the buffer, to try to ensure the allocation is success. Signed-off-by: Keyon Jie --- src/audio/mux/mux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/audio/mux/mux.c b/src/audio/mux/mux.c index ba830ddf2461..710c25ad1386 100644 --- a/src/audio/mux/mux.c +++ b/src/audio/mux/mux.c @@ -173,7 +173,8 @@ static struct comp_dev *mux_new(const struct comp_driver *drv, return NULL; dev->ipc_config = *config; - cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, + /* allocate quite a big buffer, use rballoc to make sure it will succeed */ + cd = rballoc(0, SOF_MEM_CAPS_RAM, sizeof(*cd) + MUX_MAX_STREAMS * sizeof(struct mux_stream_data)); if (!cd) { rfree(dev); From 079ffe58fcbfd3a0b69d61c38291d08c15144eb2 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 22 Sep 2021 16:49:07 +0800 Subject: [PATCH 08/14] memory: move buffers from runtime_shared ZONE to buffer ZONE We are allocating more buffers from BUFFER zone now, change size of ZONEs to reflect that. Signed-off-by: Keyon Jie --- .../apollolake/include/platform/lib/memory.h | 14 +++++++------- .../baytrail/include/platform/lib/memory.h | 8 ++++---- src/platform/haswell/include/platform/lib/memory.h | 14 +++++++------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/platform/apollolake/include/platform/lib/memory.h b/src/platform/apollolake/include/platform/lib/memory.h index 396905f3a95a..52b80a8b6db2 100644 --- a/src/platform/apollolake/include/platform/lib/memory.h +++ b/src/platform/apollolake/include/platform/lib/memory.h @@ -266,16 +266,16 @@ #define HEAP_SYS_RT_X_COUNT1024 2 /* Heap section counts base */ -#define HEAP_COUNT64 128 -#define HEAP_COUNT128 128 -#define HEAP_COUNT256 96 -#define HEAP_COUNT512 12 -#define HEAP_COUNT1024 3 -#define HEAP_COUNT2048 1 +#define HEAP_COUNT64 48 +#define HEAP_COUNT128 64 +#define HEAP_COUNT256 64 +#define HEAP_COUNT512 6 +#define HEAP_COUNT1024 0 +#define HEAP_COUNT2048 0 #define HEAP_COUNT4096 0 #define RT_TIMES 1 -#define RT_SHARED_TIMES 1 +#define RT_SHARED_TIMES 0 /* Heap section sizes for module pool */ #define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES) diff --git a/src/platform/baytrail/include/platform/lib/memory.h b/src/platform/baytrail/include/platform/lib/memory.h index 6b0e942ef49b..8d8ce0b36eeb 100644 --- a/src/platform/baytrail/include/platform/lib/memory.h +++ b/src/platform/baytrail/include/platform/lib/memory.h @@ -126,11 +126,11 @@ static inline void *platform_rfree_prepare(void *ptr) /* Heap section sizes for module pool */ #define HEAP_RT_COUNT8 0 -#define HEAP_RT_COUNT16 32 -#define HEAP_RT_COUNT32 32 -#define HEAP_RT_COUNT64 32 +#define HEAP_RT_COUNT16 0 +#define HEAP_RT_COUNT32 8 +#define HEAP_RT_COUNT64 4 #define HEAP_RT_COUNT128 32 -#define HEAP_RT_COUNT256 32 +#define HEAP_RT_COUNT256 18 #define HEAP_RT_COUNT512 2 #define HEAP_RT_COUNT1024 1 diff --git a/src/platform/haswell/include/platform/lib/memory.h b/src/platform/haswell/include/platform/lib/memory.h index 920130587f06..5a2e24aa8b5b 100644 --- a/src/platform/haswell/include/platform/lib/memory.h +++ b/src/platform/haswell/include/platform/lib/memory.h @@ -123,13 +123,13 @@ static inline void *platform_rfree_prepare(void *ptr) /* Heap section sizes for module pool */ #define HEAP_RT_COUNT8 0 -#define HEAP_RT_COUNT16 192 -#define HEAP_RT_COUNT32 128 -#define HEAP_RT_COUNT64 64 -#define HEAP_RT_COUNT128 64 -#define HEAP_RT_COUNT256 64 -#define HEAP_RT_COUNT512 8 -#define HEAP_RT_COUNT1024 4 +#define HEAP_RT_COUNT16 64 +#define HEAP_RT_COUNT32 48 +#define HEAP_RT_COUNT64 24 +#define HEAP_RT_COUNT128 24 +#define HEAP_RT_COUNT256 24 +#define HEAP_RT_COUNT512 2 +#define HEAP_RT_COUNT1024 1 /* Heap section sizes for system runtime heap */ #define HEAP_SYS_RT_COUNT64 64 From 00992ee99199df7f8b06ab40a51c05dac8ba2f31 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 15 Sep 2021 15:12:58 +0800 Subject: [PATCH 09/14] alloc: remove the usage of system_shared zone Change the usage of the system_shared zone to the buffer zone, and the calling of rmalloc/rzalloc() from system_shared zone to rballoc() with SOF_MEM_ZONE_RUNTIME_SHARED flag. Signed-off-by: Keyon Jie --- src/drivers/intel/baytrail/ssp.c | 2 +- src/drivers/intel/haswell/ssp.c | 2 +- src/drivers/interrupt.c | 2 +- src/include/sof/schedule/ll_schedule_domain.h | 2 +- src/ipc/ipc-common.c | 4 ++-- src/lib/agent.c | 2 +- src/lib/pm_runtime.c | 4 ++-- src/platform/intel/cavs/lib/pm_runtime.c | 2 +- src/schedule/dma_multi_chan_domain.c | 2 +- src/schedule/dma_single_chan_domain.c | 2 +- src/schedule/timer_domain.c | 2 +- src/schedule/zephyr_domain.c | 2 +- src/trace/dma-trace.c | 2 +- src/trace/trace.c | 2 +- 14 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/drivers/intel/baytrail/ssp.c b/src/drivers/intel/baytrail/ssp.c index c4c0ba0ce972..0e44de88e431 100644 --- a/src/drivers/intel/baytrail/ssp.c +++ b/src/drivers/intel/baytrail/ssp.c @@ -617,7 +617,7 @@ static int ssp_probe(struct dai *dai) struct ssp_pdata *ssp; /* allocate private data */ - ssp = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*ssp)); + ssp = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*ssp)); dai_set_drvdata(dai, ssp); ssp->state[DAI_DIR_PLAYBACK] = COMP_STATE_READY; diff --git a/src/drivers/intel/haswell/ssp.c b/src/drivers/intel/haswell/ssp.c index dae4104eb532..b47e25abf448 100644 --- a/src/drivers/intel/haswell/ssp.c +++ b/src/drivers/intel/haswell/ssp.c @@ -540,7 +540,7 @@ static int ssp_probe(struct dai *dai) struct ssp_pdata *ssp; /* allocate private data */ - ssp = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*ssp)); + ssp = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*ssp)); dai_set_drvdata(dai, ssp); ssp->state[DAI_DIR_PLAYBACK] = COMP_STATE_READY; diff --git a/src/drivers/interrupt.c b/src/drivers/interrupt.c index c77fedc52f1a..1928b065df5f 100644 --- a/src/drivers/interrupt.c +++ b/src/drivers/interrupt.c @@ -72,7 +72,7 @@ int interrupt_cascade_register(const struct irq_cascade_tmpl *tmpl) } - *cascade = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(**cascade)); + *cascade = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(**cascade)); spinlock_init(&(*cascade)->lock); diff --git a/src/include/sof/schedule/ll_schedule_domain.h b/src/include/sof/schedule/ll_schedule_domain.h index 4dd9ecfac041..dd20c5dda2e1 100644 --- a/src/include/sof/schedule/ll_schedule_domain.h +++ b/src/include/sof/schedule/ll_schedule_domain.h @@ -80,7 +80,7 @@ static inline struct ll_schedule_domain *domain_init { struct ll_schedule_domain *domain; - domain = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*domain)); + domain = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*domain)); domain->type = type; domain->clk = clk; domain->synchronous = synchronous; diff --git a/src/ipc/ipc-common.c b/src/ipc/ipc-common.c index dd29110e18c3..9d7ec1cf77a2 100644 --- a/src/ipc/ipc-common.c +++ b/src/ipc/ipc-common.c @@ -230,8 +230,8 @@ int ipc_init(struct sof *sof) tr_info(&ipc_tr, "ipc_init()"); /* init ipc data */ - sof->ipc = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*sof->ipc)); - sof->ipc->comp_data = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, + sof->ipc = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*sof->ipc)); + sof->ipc->comp_data = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, SOF_IPC_MSG_MAX_SIZE); spinlock_init(&sof->ipc->lock); diff --git a/src/lib/agent.c b/src/lib/agent.c index ce9c0f75b007..6e4b98c7b0b4 100644 --- a/src/lib/agent.c +++ b/src/lib/agent.c @@ -94,7 +94,7 @@ void sa_init(struct sof *sof, uint64_t timeout) else tr_info(&sa_tr, "sa_init(), timeout = %u", (unsigned int)timeout); - sof->sa = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*sof->sa)); + sof->sa = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*sof->sa)); /* set default timeouts */ #ifdef __ZEPHYR__ diff --git a/src/lib/pm_runtime.c b/src/lib/pm_runtime.c index d5111b80c88d..a4cbdd479dad 100644 --- a/src/lib/pm_runtime.c +++ b/src/lib/pm_runtime.c @@ -28,7 +28,7 @@ DECLARE_TR_CTX(pm_tr, SOF_UUID(pm_runtime_uuid), LOG_LEVEL_INFO); void pm_runtime_init(struct sof *sof) { - sof->prd = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*sof->prd)); + sof->prd = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*sof->prd)); spinlock_init(&sof->prd->lock); platform_pm_runtime_init(sof->prd); @@ -142,7 +142,7 @@ void init_dsp_r_state(enum dsp_r_state r_state) struct pm_runtime_data *prd = pm_runtime_data_get(); struct r_counters_data *r_counters; - r_counters = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*r_counters)); + r_counters = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*r_counters)); prd->r_counters = r_counters; r_counters->ts = platform_timer_get(timer_get()); diff --git a/src/platform/intel/cavs/lib/pm_runtime.c b/src/platform/intel/cavs/lib/pm_runtime.c index 957e484ec2f9..419ece3993dd 100644 --- a/src/platform/intel/cavs/lib/pm_runtime.c +++ b/src/platform/intel/cavs/lib/pm_runtime.c @@ -471,7 +471,7 @@ void platform_pm_runtime_init(struct pm_runtime_data *prd) { struct cavs_pm_runtime_data *pprd; - pprd = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*pprd)); + pprd = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*pprd)); prd->platform_data = pprd; } diff --git a/src/schedule/dma_multi_chan_domain.c b/src/schedule/dma_multi_chan_domain.c index 33f9cb463e2d..8fd48e669e23 100644 --- a/src/schedule/dma_multi_chan_domain.c +++ b/src/schedule/dma_multi_chan_domain.c @@ -363,7 +363,7 @@ struct ll_schedule_domain *dma_multi_chan_domain_init(struct dma *dma_array, domain = domain_init(SOF_SCHEDULE_LL_DMA, clk, true, &dma_multi_chan_domain_ops); - dma_domain = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*dma_domain)); + dma_domain = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*dma_domain)); dma_domain->dma_array = dma_array; dma_domain->num_dma = num_dma; dma_domain->aggregated_irq = aggregated_irq; diff --git a/src/schedule/dma_single_chan_domain.c b/src/schedule/dma_single_chan_domain.c index 1d07867ce676..425ac6a31c55 100644 --- a/src/schedule/dma_single_chan_domain.c +++ b/src/schedule/dma_single_chan_domain.c @@ -542,7 +542,7 @@ struct ll_schedule_domain *dma_single_chan_domain_init(struct dma *dma_array, domain = domain_init(SOF_SCHEDULE_LL_DMA, clk, false, &dma_single_chan_domain_ops); - dma_domain = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*dma_domain)); + dma_domain = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*dma_domain)); dma_domain->dma_array = dma_array; dma_domain->num_dma = num_dma; dma_domain->owner = DMA_DOMAIN_OWNER_INVALID; diff --git a/src/schedule/timer_domain.c b/src/schedule/timer_domain.c index 48c7862033b4..b6798d075269 100644 --- a/src/schedule/timer_domain.c +++ b/src/schedule/timer_domain.c @@ -159,7 +159,7 @@ struct ll_schedule_domain *timer_domain_init(struct timer *timer, int clk) domain = domain_init(SOF_SCHEDULE_LL_TIMER, clk, false, &timer_domain_ops); - timer_domain = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*timer_domain)); + timer_domain = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*timer_domain)); timer_domain->timer = timer; ll_sch_domain_set_pdata(domain, timer_domain); diff --git a/src/schedule/zephyr_domain.c b/src/schedule/zephyr_domain.c index 8381ca15b359..e6f3ccede976 100644 --- a/src/schedule/zephyr_domain.c +++ b/src/schedule/zephyr_domain.c @@ -227,7 +227,7 @@ struct ll_schedule_domain *zephyr_domain_init(struct timer *timer, int clk) domain = domain_init(SOF_SCHEDULE_LL_TIMER, clk, false, &zephyr_domain_ops); - zephyr_domain = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, + zephyr_domain = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*zephyr_domain)); zephyr_domain->ll_timer = timer; diff --git a/src/trace/dma-trace.c b/src/trace/dma-trace.c index 8ee10f444c2d..bba266669b38 100644 --- a/src/trace/dma-trace.c +++ b/src/trace/dma-trace.c @@ -139,7 +139,7 @@ int dma_trace_init_early(struct sof *sof) */ assert(!dma_trace_initialized(sof->dmat)); - sof->dmat = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*sof->dmat)); + sof->dmat = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*sof->dmat)); dma_sg_init(&sof->dmat->config.elem_array); spinlock_init(&sof->dmat->lock); diff --git a/src/trace/trace.c b/src/trace/trace.c index f31fb3a1c3e8..3f94d4ec35e1 100644 --- a/src/trace/trace.c +++ b/src/trace/trace.c @@ -511,7 +511,7 @@ void trace_off(void) void trace_init(struct sof *sof) { - sof->trace = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*sof->trace)); + sof->trace = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM, sizeof(*sof->trace)); sof->trace->enable = 1; sof->trace->pos = 0; #if CONFIG_TRACE_FILTERING_ADAPTIVE From bf6289ca0ec0c3ce388d83b84b9cdd7a34d645cf Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 22 Sep 2021 17:26:24 +0800 Subject: [PATCH 10/14] memory: move buffers from system ZONE to buffer ZONE We are allocating more buffers from BUFFER zone now, change size of ZONEs to reflect that. Signed-off-by: Keyon Jie --- src/platform/apollolake/include/platform/lib/memory.h | 4 ++-- src/platform/baytrail/include/platform/lib/memory.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platform/apollolake/include/platform/lib/memory.h b/src/platform/apollolake/include/platform/lib/memory.h index 52b80a8b6db2..14afb5e02ebf 100644 --- a/src/platform/apollolake/include/platform/lib/memory.h +++ b/src/platform/apollolake/include/platform/lib/memory.h @@ -315,8 +315,8 @@ */ #define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / (HEAP_BUFFER_BLOCK_SIZE * 2)) -#define HEAP_SYSTEM_M_SIZE 0x4000 /* heap primary core size */ -#define HEAP_SYSTEM_S_SIZE 0x3000 /* heap secondary core size */ +#define HEAP_SYSTEM_M_SIZE 0x3000 /* heap primary core size */ +#define HEAP_SYSTEM_S_SIZE 0x2000 /* heap secondary core size */ #define HEAP_SYSTEM_T_SIZE \ (HEAP_SYSTEM_M_SIZE + ((CONFIG_CORE_COUNT - 1) * HEAP_SYSTEM_S_SIZE)) diff --git a/src/platform/baytrail/include/platform/lib/memory.h b/src/platform/baytrail/include/platform/lib/memory.h index 8d8ce0b36eeb..e52c61968b1f 100644 --- a/src/platform/baytrail/include/platform/lib/memory.h +++ b/src/platform/baytrail/include/platform/lib/memory.h @@ -143,7 +143,7 @@ static inline void *platform_rfree_prepare(void *ptr) #define SOF_DATA_SIZE 0x9800 #define HEAP_SYSTEM_BASE (DRAM0_BASE + SOF_DATA_SIZE) -#define HEAP_SYSTEM_SIZE 0xA800 +#define HEAP_SYSTEM_SIZE 0x1000 #define HEAP_SYSTEM_0_BASE HEAP_SYSTEM_BASE From 96487ce363c2b975af99c39acb01ddf6848cd04d Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 22 Sep 2021 18:19:57 +0800 Subject: [PATCH 11/14] alloc: remove the runtime_shared zone Since there is no any usage of the runtime_shared zone now, we can remove it thoroughly now. Signed-off-by: Keyon Jie --- src/include/sof/lib/alloc.h | 1 - src/include/sof/lib/mm_heap.h | 2 - src/ipc/ipc3/handler.c | 4 +- src/lib/alloc.c | 41 ------------------- src/platform/apollolake/apollolake.x.in | 7 ---- .../apollolake/include/platform/lib/memory.h | 13 ------ src/platform/cannonlake/cannonlake.x.in | 7 ---- .../cannonlake/include/platform/lib/memory.h | 15 ------- src/platform/icelake/icelake.x.in | 7 ---- .../icelake/include/platform/lib/memory.h | 15 ------- src/platform/intel/cavs/lib/memory.c | 30 +------------- .../library/include/platform/lib/memory.h | 13 ------ src/platform/library/lib/memory.c | 28 ------------- .../suecreek/include/platform/lib/memory.h | 13 ------ src/platform/suecreek/suecreek.x.in | 7 ---- .../tigerlake/include/platform/lib/memory.h | 16 -------- src/platform/tigerlake/tigerlake.x.in | 7 ---- 17 files changed, 2 insertions(+), 224 deletions(-) diff --git a/src/include/sof/lib/alloc.h b/src/include/sof/lib/alloc.h index 5a3cf116b5a2..7272312686d6 100644 --- a/src/include/sof/lib/alloc.h +++ b/src/include/sof/lib/alloc.h @@ -57,7 +57,6 @@ enum mem_zone { SOF_MEM_ZONE_SYS_RUNTIME, /**< System-runtime zone */ SOF_MEM_ZONE_RUNTIME, /**< Runtime zone */ SOF_MEM_ZONE_BUFFER, /**< Buffer zone */ - SOF_MEM_ZONE_RUNTIME_SHARED, /**< Runtime shared zone */ SOF_MEM_ZONE_SYS_SHARED, /**< System shared zone */ }; diff --git a/src/include/sof/lib/mm_heap.h b/src/include/sof/lib/mm_heap.h index 1d570863bd75..b9bd06cf0f84 100644 --- a/src/include/sof/lib/mm_heap.h +++ b/src/include/sof/lib/mm_heap.h @@ -68,8 +68,6 @@ struct mm { #if CONFIG_CORE_COUNT > 1 /* object shared between different cores - used during init cannot be freed */ struct mm_heap system_shared[PLATFORM_HEAP_SYSTEM_SHARED]; - /* object shared between different cores */ - struct mm_heap runtime_shared[PLATFORM_HEAP_RUNTIME_SHARED]; #endif /* general heap for components */ struct mm_heap runtime[PLATFORM_HEAP_RUNTIME]; diff --git a/src/ipc/ipc3/handler.c b/src/ipc/ipc3/handler.c index a87dd30ef9d7..6a1e9e88dcfb 100644 --- a/src/ipc/ipc3/handler.c +++ b/src/ipc/ipc3/handler.c @@ -1369,7 +1369,7 @@ static int fill_mem_usage_elems(enum mem_zone zone, enum sof_ipc_dbg_mem_zone ip } #if CONFIG_CORE_COUNT > 1 -#define PLATFORM_HEAP_SYSTEM_SHARED_CNT (PLATFORM_HEAP_SYSTEM_SHARED + PLATFORM_HEAP_RUNTIME_SHARED) +#define PLATFORM_HEAP_SYSTEM_SHARED_CNT PLATFORM_HEAP_SYSTEM_SHARED #else #define PLATFORM_HEAP_SYSTEM_SHARED_CNT 0 #endif @@ -1407,8 +1407,6 @@ static int ipc_glb_test_mem_usage(uint32_t header) #if CONFIG_CORE_COUNT > 1 elems += fill_mem_usage_elems(SOF_MEM_ZONE_SYS_SHARED, SOF_IPC_MEM_ZONE_SYS_SHARED, PLATFORM_HEAP_SYSTEM_SHARED, elems); - elems += fill_mem_usage_elems(SOF_MEM_ZONE_RUNTIME_SHARED, SOF_IPC_MEM_ZONE_RUNTIME_SHARED, - PLATFORM_HEAP_RUNTIME_SHARED, elems); #endif /* write component values to the outbox */ diff --git a/src/lib/alloc.c b/src/lib/alloc.c index 782e2e170ad6..eb3054b8231c 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -368,12 +368,6 @@ static struct mm_heap *get_heap_from_ptr(void *ptr) if (heap) goto out; -#if CONFIG_CORE_COUNT > 1 - heap = find_in_heap_arr(memmap->runtime_shared, PLATFORM_HEAP_RUNTIME_SHARED, ptr); - if (heap) - goto out; -#endif - heap = find_in_heap_arr(memmap->buffer, PLATFORM_HEAP_BUFFER, ptr); if (heap) goto out; @@ -599,8 +593,6 @@ void heap_trace_all(int force) tr_info(&mem_tr, "heap: runtime status"); heap_trace(memmap->runtime, PLATFORM_HEAP_RUNTIME); #if CONFIG_CORE_COUNT > 1 - tr_info(&mem_tr, "heap: runtime shared status"); - heap_trace(memmap->runtime_shared, PLATFORM_HEAP_RUNTIME_SHARED); tr_info(&mem_tr, "heap: system shared status"); heap_trace(memmap->system_shared, PLATFORM_HEAP_SYSTEM_SHARED); #endif @@ -682,24 +674,6 @@ static void *rmalloc_runtime(uint32_t flags, uint32_t caps, size_t bytes) PLATFORM_DCACHE_ALIGN); } -#if CONFIG_CORE_COUNT > 1 -/* allocate single block for shared */ -static void *rmalloc_runtime_shared(uint32_t flags, uint32_t caps, size_t bytes) -{ - struct mm *memmap = memmap_get(); - struct mm_heap *heap; - - /* check shared heap for capabilities */ - heap = get_heap_from_caps(memmap->runtime_shared, PLATFORM_HEAP_RUNTIME_SHARED, caps); - if (!heap) { - tr_err(&mem_tr, "rmalloc_runtime_shared(): caps = %x, bytes = %d", caps, bytes); - return NULL; - } - - return get_ptr_from_heap(heap, flags, caps, bytes, PLATFORM_DCACHE_ALIGN); -} -#endif - static void *_malloc_unlocked(enum mem_zone zone, uint32_t flags, uint32_t caps, size_t bytes) { @@ -717,16 +691,10 @@ static void *_malloc_unlocked(enum mem_zone zone, uint32_t flags, uint32_t caps, ptr = rmalloc_runtime(flags, caps, bytes); break; #if CONFIG_CORE_COUNT > 1 - case SOF_MEM_ZONE_RUNTIME_SHARED: - ptr = rmalloc_runtime_shared(flags, caps, bytes); - break; case SOF_MEM_ZONE_SYS_SHARED: ptr = rmalloc_sys(memmap->system_shared, flags, caps, bytes); break; #else - case SOF_MEM_ZONE_RUNTIME_SHARED: - ptr = rmalloc_runtime(flags, caps, bytes); - break; case SOF_MEM_ZONE_SYS_SHARED: ptr = rmalloc_sys(memmap->system, flags, caps, bytes); break; @@ -1094,10 +1062,6 @@ void init_heap(struct sof *sof) init_heap_map(memmap->runtime, PLATFORM_HEAP_RUNTIME); -#if CONFIG_CORE_COUNT > 1 - init_heap_map(memmap->runtime_shared, PLATFORM_HEAP_RUNTIME_SHARED); -#endif - init_heap_map(memmap->buffer, PLATFORM_HEAP_BUFFER); #if CONFIG_DEBUG_BLOCK_FREE @@ -1147,11 +1111,6 @@ int heap_info(enum mem_zone zone, int index, struct mm_info *out) goto error; heap = memmap->system_shared + index; break; - case SOF_MEM_ZONE_RUNTIME_SHARED: - if (index >= PLATFORM_HEAP_RUNTIME_SHARED) - goto error; - heap = memmap->runtime_shared + index; - break; #endif default: goto error; diff --git a/src/platform/apollolake/apollolake.x.in b/src/platform/apollolake/apollolake.x.in index 31b09a70392f..b8dd719fb3aa 100644 --- a/src/platform/apollolake/apollolake.x.in +++ b/src/platform/apollolake/apollolake.x.in @@ -502,12 +502,6 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); #if CONFIG_CORE_COUNT > 1 - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _runtime_shared_heap_start = ABSOLUTE(.); - . = . + HEAP_RUNTIME_SHARED_SIZE; - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _runtime_shared_heap_end = ABSOLUTE(.); - . = ALIGN (PLATFORM_DCACHE_ALIGN); _system_shared_heap_start = ABSOLUTE(.); . = . + HEAP_SYSTEM_SHARED_SIZE; @@ -549,7 +543,6 @@ SECTIONS #if CONFIG_CORE_COUNT > 1 /* Shared Heap */ - _runtime_shared_heap = _runtime_shared_heap_start; _system_shared_heap = _system_shared_heap_start; #endif diff --git a/src/platform/apollolake/include/platform/lib/memory.h b/src/platform/apollolake/include/platform/lib/memory.h index 14afb5e02ebf..94d9d35bbde4 100644 --- a/src/platform/apollolake/include/platform/lib/memory.h +++ b/src/platform/apollolake/include/platform/lib/memory.h @@ -293,18 +293,6 @@ HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ HEAP_RT_COUNT4096 * 4096) -/* Heap section sizes for runtime shared heap */ -#define HEAP_RUNTIME_SHARED_COUNT64 (HEAP_COUNT64 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT128 (HEAP_COUNT128 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT256 (HEAP_COUNT256 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT512 (HEAP_COUNT512 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT1024 (HEAP_COUNT1024 * RT_SHARED_TIMES) - -#define HEAP_RUNTIME_SHARED_SIZE \ - (HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \ - HEAP_RUNTIME_SHARED_COUNT256 * 256 + HEAP_RUNTIME_SHARED_COUNT512 * 512 + \ - HEAP_RUNTIME_SHARED_COUNT1024 * 1024) - /* Heap section sizes for system shared heap */ #define HEAP_SYSTEM_SHARED_SIZE 0x1500 @@ -406,7 +394,6 @@ #define PLATFORM_HEAP_SYSTEM CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 -#define PLATFORM_HEAP_RUNTIME_SHARED 1 #define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_BUFFER 2 diff --git a/src/platform/cannonlake/cannonlake.x.in b/src/platform/cannonlake/cannonlake.x.in index 176c03f3cb11..1941a60e79cc 100644 --- a/src/platform/cannonlake/cannonlake.x.in +++ b/src/platform/cannonlake/cannonlake.x.in @@ -467,12 +467,6 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); #if CONFIG_CORE_COUNT > 1 - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _runtime_shared_heap_start = ABSOLUTE(.); - . = . + HEAP_RUNTIME_SHARED_SIZE; - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _runtime_shared_heap_end = ABSOLUTE(.); - . = ALIGN (PLATFORM_DCACHE_ALIGN); _system_shared_heap_start = ABSOLUTE(.); . = . + HEAP_SYSTEM_SHARED_SIZE; @@ -515,7 +509,6 @@ SECTIONS #if CONFIG_CORE_COUNT > 1 /* Shared Heap */ - _runtime_shared_heap = _runtime_shared_heap_start; _system_shared_heap = _system_shared_heap_start; #endif diff --git a/src/platform/cannonlake/include/platform/lib/memory.h b/src/platform/cannonlake/include/platform/lib/memory.h index a20e1e3dd9e0..416f7b2eacb1 100644 --- a/src/platform/cannonlake/include/platform/lib/memory.h +++ b/src/platform/cannonlake/include/platform/lib/memory.h @@ -256,10 +256,8 @@ #if HP_SRAM_SIZE < 0x200000 #define RT_TIMES 3 -#define RT_SHARED_TIMES 6 #else #define RT_TIMES 8 -#define RT_SHARED_TIMES 16 #endif /* Heap section sizes for module pool */ @@ -278,18 +276,6 @@ HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ HEAP_RT_COUNT4096 * 4096) -/* Heap section sizes for runtime shared heap */ -#define HEAP_RUNTIME_SHARED_COUNT64 (HEAP_COUNT64 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT128 (HEAP_COUNT128 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT256 (HEAP_COUNT256 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT512 (HEAP_COUNT512 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT1024 (HEAP_COUNT1024 * RT_SHARED_TIMES) - -#define HEAP_RUNTIME_SHARED_SIZE \ - (HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \ - HEAP_RUNTIME_SHARED_COUNT256 * 256 + HEAP_RUNTIME_SHARED_COUNT512 * 512 + \ - HEAP_RUNTIME_SHARED_COUNT1024 * 1024) - /* Heap section sizes for system shared heap */ #define HEAP_SYSTEM_SHARED_SIZE 0x1500 @@ -397,7 +383,6 @@ #define PLATFORM_HEAP_SYSTEM CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 -#define PLATFORM_HEAP_RUNTIME_SHARED 1 #define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_BUFFER 2 diff --git a/src/platform/icelake/icelake.x.in b/src/platform/icelake/icelake.x.in index d1711941a2d6..3bd5ce2f8603 100644 --- a/src/platform/icelake/icelake.x.in +++ b/src/platform/icelake/icelake.x.in @@ -471,12 +471,6 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); #if CONFIG_CORE_COUNT > 1 - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _runtime_shared_heap_start = ABSOLUTE(.); - . = . + HEAP_RUNTIME_SHARED_SIZE; - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _runtime_shared_heap_end = ABSOLUTE(.); - . = ALIGN (PLATFORM_DCACHE_ALIGN); _system_shared_heap_start = ABSOLUTE(.); . = . + HEAP_SYSTEM_SHARED_SIZE; @@ -519,7 +513,6 @@ SECTIONS #if CONFIG_CORE_COUNT > 1 /* Shared Heap */ - _runtime_shared_heap = _runtime_shared_heap_start; _system_shared_heap = _system_shared_heap_start; #endif diff --git a/src/platform/icelake/include/platform/lib/memory.h b/src/platform/icelake/include/platform/lib/memory.h index bbcb49643a7b..06f5ab49aa56 100644 --- a/src/platform/icelake/include/platform/lib/memory.h +++ b/src/platform/icelake/include/platform/lib/memory.h @@ -253,10 +253,8 @@ #if HP_SRAM_SIZE < 0x200000 #define RT_TIMES 1 -#define RT_SHARED_TIMES 1 #else #define RT_TIMES 8 -#define RT_SHARED_TIMES 16 #endif /* Heap section sizes for module pool */ @@ -275,18 +273,6 @@ HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ HEAP_RT_COUNT4096 * 4096) -/* Heap section sizes for runtime shared heap */ -#define HEAP_RUNTIME_SHARED_COUNT64 (HEAP_COUNT64 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT128 (HEAP_COUNT128 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT256 (HEAP_COUNT256 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT512 (HEAP_COUNT512 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT1024 (HEAP_COUNT1024 * RT_SHARED_TIMES) - -#define HEAP_RUNTIME_SHARED_SIZE \ - (HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \ - HEAP_RUNTIME_SHARED_COUNT256 * 256 + HEAP_RUNTIME_SHARED_COUNT512 * 512 + \ - HEAP_RUNTIME_SHARED_COUNT1024 * 1024) - /* Heap section sizes for system shared heap */ #define HEAP_SYSTEM_SHARED_SIZE 0x1500 @@ -369,7 +355,6 @@ #define PLATFORM_HEAP_SYSTEM CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 -#define PLATFORM_HEAP_RUNTIME_SHARED 1 #define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_BUFFER 2 diff --git a/src/platform/intel/cavs/lib/memory.c b/src/platform/intel/cavs/lib/memory.c index a2030ae66fb0..5343933b77a9 100644 --- a/src/platform/intel/cavs/lib/memory.c +++ b/src/platform/intel/cavs/lib/memory.c @@ -21,7 +21,7 @@ extern uintptr_t _system_heap, _system_runtime_heap, _module_heap; extern uintptr_t _buffer_heap, _sof_core_s_start; #if CONFIG_CORE_COUNT > 1 -extern uintptr_t _runtime_shared_heap, _system_shared_heap; +extern uintptr_t _system_shared_heap; #endif /* Heap blocks for system runtime for primary core */ @@ -93,24 +93,6 @@ static SHARED_DATA struct block_map rt_heap_map[] = { BLOCK_DEF(4096, HEAP_RT_COUNT4096, uncached_block_hdr(mod_block4096)), }; -#if CONFIG_CORE_COUNT > 1 -/* Heap blocks for runtime shared */ -static SHARED_DATA struct block_hdr rt_shared_block64[HEAP_RUNTIME_SHARED_COUNT64]; -static SHARED_DATA struct block_hdr rt_shared_block128[HEAP_RUNTIME_SHARED_COUNT128]; -static SHARED_DATA struct block_hdr rt_shared_block256[HEAP_RUNTIME_SHARED_COUNT256]; -static SHARED_DATA struct block_hdr rt_shared_block512[HEAP_RUNTIME_SHARED_COUNT512]; -static SHARED_DATA struct block_hdr rt_shared_block1024[HEAP_RUNTIME_SHARED_COUNT1024]; - -/* Heap memory map for runtime shared */ -static SHARED_DATA struct block_map rt_shared_heap_map[] = { - BLOCK_DEF(64, HEAP_RUNTIME_SHARED_COUNT64, uncached_block_hdr(rt_shared_block64)), - BLOCK_DEF(128, HEAP_RUNTIME_SHARED_COUNT128, uncached_block_hdr(rt_shared_block128)), - BLOCK_DEF(256, HEAP_RUNTIME_SHARED_COUNT256, uncached_block_hdr(rt_shared_block256)), - BLOCK_DEF(512, HEAP_RUNTIME_SHARED_COUNT512, uncached_block_hdr(rt_shared_block512)), - BLOCK_DEF(1024, HEAP_RUNTIME_SHARED_COUNT1024, uncached_block_hdr(rt_shared_block1024)), -}; -#endif - /* Heap blocks for buffers */ static SHARED_DATA struct block_hdr buf_block[HEAP_BUFFER_COUNT_MAX]; static SHARED_DATA struct block_hdr lp_buf_block[HEAP_LP_BUFFER_COUNT]; @@ -197,16 +179,6 @@ void platform_init_memmap(struct sof *sof) } #if CONFIG_CORE_COUNT > 1 - /* .runtime_shared init */ - sof->memory_map->runtime_shared[0].blocks = ARRAY_SIZE(rt_shared_heap_map); - sof->memory_map->runtime_shared[0].map = uncached_block_map(rt_shared_heap_map); - sof->memory_map->runtime_shared[0].heap = - cache_to_uncache((uintptr_t)&_runtime_shared_heap); - sof->memory_map->runtime_shared[0].size = HEAP_RUNTIME_SHARED_SIZE; - sof->memory_map->runtime_shared[0].info.free = HEAP_RUNTIME_SHARED_SIZE; - sof->memory_map->runtime_shared[0].caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_EXT | - SOF_MEM_CAPS_CACHE; - /* .system_shared init */ sof->memory_map->system_shared[0].heap = cache_to_uncache((uintptr_t)&_system_shared_heap); sof->memory_map->system_shared[0].size = HEAP_SYSTEM_SHARED_SIZE; diff --git a/src/platform/library/include/platform/lib/memory.h b/src/platform/library/include/platform/lib/memory.h index f64118c03257..d4bb1dc5a58c 100644 --- a/src/platform/library/include/platform/lib/memory.h +++ b/src/platform/library/include/platform/lib/memory.h @@ -27,7 +27,6 @@ uint8_t *get_library_mailbox(void); #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT #define PLATFORM_HEAP_RUNTIME 1 #define PLATFORM_HEAP_BUFFER 2 -#define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_RUNTIME_SHARED 1 #define SHARED_DATA @@ -99,18 +98,6 @@ static inline uint32_t arch_get_stack_size(void) HEAP_COUNT1024 * 1024 + HEAP_COUNT2048 * 2048 + \ HEAP_COUNT4096 * 4096) -/* Heap section sizes for runtime shared heap */ -#define HEAP_RUNTIME_SHARED_COUNT64 (64 + 32 * CONFIG_CORE_COUNT) -#define HEAP_RUNTIME_SHARED_COUNT128 64 -#define HEAP_RUNTIME_SHARED_COUNT256 4 -#define HEAP_RUNTIME_SHARED_COUNT512 16 -#define HEAP_RUNTIME_SHARED_COUNT1024 4 - -#define HEAP_RUNTIME_SHARED_SIZE \ - (HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \ - HEAP_RUNTIME_SHARED_COUNT256 * 256 + HEAP_RUNTIME_SHARED_COUNT512 * 512 + \ - HEAP_RUNTIME_SHARED_COUNT1024 * 1024) - /* Heap section sizes for system shared heap */ #define HEAP_SYSTEM_SHARED_SIZE 0x1500 diff --git a/src/platform/library/lib/memory.c b/src/platform/library/lib/memory.c index 6efaea1f4be6..947cb271b3a7 100644 --- a/src/platform/library/lib/memory.c +++ b/src/platform/library/lib/memory.c @@ -95,24 +95,6 @@ static SHARED_DATA struct block_map rt_heap_map[] = { BLOCK_DEF(4096, HEAP_COUNT4096, uncached_block_hdr(mod_block4096)), }; -#if CONFIG_CORE_COUNT > 1 -/* Heap blocks for runtime shared */ -static SHARED_DATA struct block_hdr rt_shared_block64[HEAP_RUNTIME_SHARED_COUNT64]; -static SHARED_DATA struct block_hdr rt_shared_block128[HEAP_RUNTIME_SHARED_COUNT128]; -static SHARED_DATA struct block_hdr rt_shared_block256[HEAP_RUNTIME_SHARED_COUNT256]; -static SHARED_DATA struct block_hdr rt_shared_block512[HEAP_RUNTIME_SHARED_COUNT512]; -static SHARED_DATA struct block_hdr rt_shared_block1024[HEAP_RUNTIME_SHARED_COUNT1024]; - -/* Heap memory map for runtime shared */ -static SHARED_DATA struct block_map rt_shared_heap_map[] = { - BLOCK_DEF(64, HEAP_RUNTIME_SHARED_COUNT64, uncached_block_hdr(rt_shared_block64)), - BLOCK_DEF(128, HEAP_RUNTIME_SHARED_COUNT128, uncached_block_hdr(rt_shared_block128)), - BLOCK_DEF(256, HEAP_RUNTIME_SHARED_COUNT256, uncached_block_hdr(rt_shared_block256)), - BLOCK_DEF(512, HEAP_RUNTIME_SHARED_COUNT512, uncached_block_hdr(rt_shared_block512)), - BLOCK_DEF(1024, HEAP_RUNTIME_SHARED_COUNT1024, uncached_block_hdr(rt_shared_block1024)), -}; -#endif - /* Heap blocks for buffers */ static SHARED_DATA struct block_hdr buf_block[HEAP_BUFFER_COUNT_MAX]; static SHARED_DATA struct block_hdr lp_buf_block[HEAP_LP_BUFFER_COUNT]; @@ -199,16 +181,6 @@ void platform_init_memmap(struct sof *sof) } #if CONFIG_CORE_COUNT > 1 - /* .runtime_shared init */ - sof->memory_map->runtime_shared[0].blocks = ARRAY_SIZE(rt_shared_heap_map); - sof->memory_map->runtime_shared[0].map = uncached_block_map(rt_shared_heap_map); - sof->memory_map->runtime_shared[0].heap = - (unsigned long)cache_to_uncache(malloc(HEAP_RUNTIME_SHARED_SIZE)); - sof->memory_map->runtime_shared[0].size = HEAP_RUNTIME_SHARED_SIZE; - sof->memory_map->runtime_shared[0].info.free = HEAP_RUNTIME_SHARED_SIZE; - sof->memory_map->runtime_shared[0].caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_EXT | - SOF_MEM_CAPS_CACHE; - /* .system_shared init */ sof->memory_map->system_shared[0].heap = (unsigned long)cache_to_uncache(malloc(HEAP_SYSTEM_SHARED_SIZE)); diff --git a/src/platform/suecreek/include/platform/lib/memory.h b/src/platform/suecreek/include/platform/lib/memory.h index 8999057b587b..e45b06c74d3f 100644 --- a/src/platform/suecreek/include/platform/lib/memory.h +++ b/src/platform/suecreek/include/platform/lib/memory.h @@ -264,18 +264,6 @@ HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ HEAP_RT_COUNT4096 * 4096) -/* Heap section sizes for runtime shared heap */ -#define HEAP_RUNTIME_SHARED_COUNT64 (64 + 32 * CONFIG_CORE_COUNT) -#define HEAP_RUNTIME_SHARED_COUNT128 64 -#define HEAP_RUNTIME_SHARED_COUNT256 4 -#define HEAP_RUNTIME_SHARED_COUNT512 16 -#define HEAP_RUNTIME_SHARED_COUNT1024 4 - -#define HEAP_RUNTIME_SHARED_SIZE \ - (HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \ - HEAP_RUNTIME_SHARED_COUNT256 * 256 + HEAP_RUNTIME_SHARED_COUNT512 * 512 + \ - HEAP_RUNTIME_SHARED_COUNT1024 * 1024) - /* Heap section sizes for system shared heap */ #define HEAP_SYSTEM_SHARED_SIZE 0x1500 @@ -375,7 +363,6 @@ #define PLATFORM_HEAP_SYSTEM CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 -#define PLATFORM_HEAP_RUNTIME_SHARED 1 #define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_BUFFER 2 diff --git a/src/platform/suecreek/suecreek.x.in b/src/platform/suecreek/suecreek.x.in index 858fab86f79e..dd21920ad7e2 100644 --- a/src/platform/suecreek/suecreek.x.in +++ b/src/platform/suecreek/suecreek.x.in @@ -469,12 +469,6 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); #if CONFIG_CORE_COUNT > 1 - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _runtime_shared_heap_start = ABSOLUTE(.); - . = . + HEAP_RUNTIME_SHARED_SIZE; - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _runtime_shared_heap_end = ABSOLUTE(.); - . = ALIGN (PLATFORM_DCACHE_ALIGN); _system_shared_heap_start = ABSOLUTE(.); . = . + HEAP_SYSTEM_SHARED_SIZE; @@ -517,7 +511,6 @@ SECTIONS #if CONFIG_CORE_COUNT > 1 /* Shared Heap */ - _runtime_shared_heap = _runtime_shared_heap_start; _system_shared_heap = _system_shared_heap_start; #endif diff --git a/src/platform/tigerlake/include/platform/lib/memory.h b/src/platform/tigerlake/include/platform/lib/memory.h index 80206d2d2264..302e1ab0297f 100644 --- a/src/platform/tigerlake/include/platform/lib/memory.h +++ b/src/platform/tigerlake/include/platform/lib/memory.h @@ -262,14 +262,11 @@ #if HP_SRAM_SIZE < 0x200000 #define RT_TIMES 3 -#define RT_SHARED_TIMES 6 #else #ifdef CONFIG_COMP_RTNR #define RT_TIMES 6 -#define RT_SHARED_TIMES 11 #else #define RT_TIMES 8 -#define RT_SHARED_TIMES 16 #endif /* CONFIG_COMP_RTNR */ #endif @@ -289,18 +286,6 @@ HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ HEAP_RT_COUNT4096 * 4096) -/* Heap section sizes for runtime shared heap */ -#define HEAP_RUNTIME_SHARED_COUNT64 (HEAP_COUNT64 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT128 (HEAP_COUNT128 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT256 (HEAP_COUNT256 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT512 (HEAP_COUNT512 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT1024 (HEAP_COUNT1024 * RT_SHARED_TIMES) - -#define HEAP_RUNTIME_SHARED_SIZE \ - (HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \ - HEAP_RUNTIME_SHARED_COUNT256 * 256 + HEAP_RUNTIME_SHARED_COUNT512 * 512 + \ - HEAP_RUNTIME_SHARED_COUNT1024 * 1024) - /* Heap section sizes for system shared heap */ #define HEAP_SYSTEM_SHARED_SIZE 0x1500 @@ -401,7 +386,6 @@ #define PLATFORM_HEAP_SYSTEM CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 -#define PLATFORM_HEAP_RUNTIME_SHARED 1 #define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_BUFFER 2 diff --git a/src/platform/tigerlake/tigerlake.x.in b/src/platform/tigerlake/tigerlake.x.in index 1df42426d40f..a872b2ab53f5 100644 --- a/src/platform/tigerlake/tigerlake.x.in +++ b/src/platform/tigerlake/tigerlake.x.in @@ -545,12 +545,6 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); #if CONFIG_CORE_COUNT > 1 - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _runtime_shared_heap_start = ABSOLUTE(.); - . = . + HEAP_RUNTIME_SHARED_SIZE; - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _runtime_shared_heap_end = ABSOLUTE(.); - . = ALIGN (PLATFORM_DCACHE_ALIGN); _system_shared_heap_start = ABSOLUTE(.); . = . + HEAP_SYSTEM_SHARED_SIZE; @@ -593,7 +587,6 @@ SECTIONS #if CONFIG_CORE_COUNT > 1 /* Shared Heap */ - _runtime_shared_heap = _runtime_shared_heap_start; _system_shared_heap = _system_shared_heap_start; #endif From 8ec50db9a67d9076d451e303fdd3371eae71c5b5 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 22 Sep 2021 18:27:28 +0800 Subject: [PATCH 12/14] alloc: remove the system_shared zone Since there is no any usage of the system_shared zone now, we can remove it thoroughly now. Signed-off-by: Keyon Jie --- src/include/sof/lib/mm_heap.h | 4 -- src/ipc/ipc3/handler.c | 13 +----- src/lib/alloc.c | 40 ------------------- src/platform/apollolake/apollolake.x.in | 11 ----- .../apollolake/include/platform/lib/memory.h | 4 -- src/platform/cannonlake/cannonlake.x.in | 11 ----- .../cannonlake/include/platform/lib/memory.h | 4 -- src/platform/icelake/icelake.x.in | 11 ----- .../icelake/include/platform/lib/memory.h | 4 -- src/platform/intel/cavs/lib/memory.c | 13 ------ src/platform/library/lib/memory.c | 18 ++++----- .../suecreek/include/platform/lib/memory.h | 4 -- src/platform/suecreek/suecreek.x.in | 11 ----- .../tigerlake/include/platform/lib/memory.h | 4 -- src/platform/tigerlake/tigerlake.x.in | 11 ----- 15 files changed, 8 insertions(+), 155 deletions(-) diff --git a/src/include/sof/lib/mm_heap.h b/src/include/sof/lib/mm_heap.h index b9bd06cf0f84..8f1b2270b52b 100644 --- a/src/include/sof/lib/mm_heap.h +++ b/src/include/sof/lib/mm_heap.h @@ -65,10 +65,6 @@ struct mm { struct mm_heap system[PLATFORM_HEAP_SYSTEM]; /* system runtime heap - used for runtime system components */ struct mm_heap system_runtime[PLATFORM_HEAP_SYSTEM_RUNTIME]; -#if CONFIG_CORE_COUNT > 1 - /* object shared between different cores - used during init cannot be freed */ - struct mm_heap system_shared[PLATFORM_HEAP_SYSTEM_SHARED]; -#endif /* general heap for components */ struct mm_heap runtime[PLATFORM_HEAP_RUNTIME]; /* general component buffer heap */ diff --git a/src/ipc/ipc3/handler.c b/src/ipc/ipc3/handler.c index 6a1e9e88dcfb..558b9abfac79 100644 --- a/src/ipc/ipc3/handler.c +++ b/src/ipc/ipc3/handler.c @@ -1368,18 +1368,11 @@ static int fill_mem_usage_elems(enum mem_zone zone, enum sof_ipc_dbg_mem_zone ip return elem_number; } -#if CONFIG_CORE_COUNT > 1 -#define PLATFORM_HEAP_SYSTEM_SHARED_CNT PLATFORM_HEAP_SYSTEM_SHARED -#else -#define PLATFORM_HEAP_SYSTEM_SHARED_CNT 0 -#endif - static int ipc_glb_test_mem_usage(uint32_t header) { /* count number heaps */ int elem_cnt = PLATFORM_HEAP_SYSTEM + PLATFORM_HEAP_SYSTEM_RUNTIME + - PLATFORM_HEAP_RUNTIME + PLATFORM_HEAP_BUFFER + - PLATFORM_HEAP_SYSTEM_SHARED_CNT; + PLATFORM_HEAP_RUNTIME + PLATFORM_HEAP_BUFFER; size_t size = sizeof(struct sof_ipc_dbg_mem_usage) + elem_cnt * sizeof(struct sof_ipc_dbg_mem_usage_elem); struct sof_ipc_dbg_mem_usage_elem *elems; @@ -1404,10 +1397,6 @@ static int ipc_glb_test_mem_usage(uint32_t header) /* cppcheck-suppress unreadVariable */ elems += fill_mem_usage_elems(SOF_MEM_ZONE_BUFFER, SOF_IPC_MEM_ZONE_BUFFER, PLATFORM_HEAP_BUFFER, elems); -#if CONFIG_CORE_COUNT > 1 - elems += fill_mem_usage_elems(SOF_MEM_ZONE_SYS_SHARED, SOF_IPC_MEM_ZONE_SYS_SHARED, - PLATFORM_HEAP_SYSTEM_SHARED, elems); -#endif /* write component values to the outbox */ mailbox_hostbox_write(0, mem_usage, mem_usage->rhdr.hdr.size); diff --git a/src/lib/alloc.c b/src/lib/alloc.c index eb3054b8231c..15f7d11f3400 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -592,14 +592,9 @@ void heap_trace_all(int force) heap_trace(memmap->buffer, PLATFORM_HEAP_BUFFER); tr_info(&mem_tr, "heap: runtime status"); heap_trace(memmap->runtime, PLATFORM_HEAP_RUNTIME); -#if CONFIG_CORE_COUNT > 1 - tr_info(&mem_tr, "heap: system shared status"); - heap_trace(memmap->system_shared, PLATFORM_HEAP_SYSTEM_SHARED); -#endif } memmap->heap_trace_updated = 0; - } #else void heap_trace_all(int force) { } @@ -690,15 +685,6 @@ static void *_malloc_unlocked(enum mem_zone zone, uint32_t flags, uint32_t caps, case SOF_MEM_ZONE_RUNTIME: ptr = rmalloc_runtime(flags, caps, bytes); break; -#if CONFIG_CORE_COUNT > 1 - case SOF_MEM_ZONE_SYS_SHARED: - ptr = rmalloc_sys(memmap->system_shared, flags, caps, bytes); - break; -#else - case SOF_MEM_ZONE_SYS_SHARED: - ptr = rmalloc_sys(memmap->system, flags, caps, bytes); - break; -#endif default: tr_err(&mem_tr, "rmalloc(): invalid zone"); @@ -930,7 +916,6 @@ void *rballoc_align(uint32_t flags, uint32_t caps, size_t bytes, static void _rfree_unlocked(void *ptr) { struct mm *memmap = memmap_get(); - struct mm_heap *heap; /* sanity check - NULL ptrs are fine */ if (!ptr) @@ -939,24 +924,6 @@ static void _rfree_unlocked(void *ptr) /* prepare pointer if it's platform requirement */ ptr = platform_rfree_prepare(ptr); - /* use the heap dedicated for the core or shared memory */ -#if CONFIG_CORE_COUNT > 1 - if (is_uncached(ptr)) - heap = memmap->system_shared; - else - heap = memmap->system + cpu_get_id(); -#else - heap = memmap->system; -#endif - - /* panic if pointer is from system heap */ - if (ptr >= (void *)heap->heap && - (char *)ptr < (char *)heap->heap + heap->size) { - tr_err(&mem_tr, "rfree(): attempt to free system heap = %p, cpu = %d", - ptr, cpu_get_id()); - panic(SOF_IPC_PANIC_MEM); - } - /* free the block */ free_block(ptr); memmap->heap_trace_updated = 1; @@ -1105,13 +1072,6 @@ int heap_info(enum mem_zone zone, int index, struct mm_info *out) goto error; heap = memmap->buffer + index; break; -#if CONFIG_CORE_COUNT > 1 - case SOF_MEM_ZONE_SYS_SHARED: - if (index >= PLATFORM_HEAP_SYSTEM_SHARED) - goto error; - heap = memmap->system_shared + index; - break; -#endif default: goto error; } diff --git a/src/platform/apollolake/apollolake.x.in b/src/platform/apollolake/apollolake.x.in index b8dd719fb3aa..e24c59692755 100644 --- a/src/platform/apollolake/apollolake.x.in +++ b/src/platform/apollolake/apollolake.x.in @@ -502,12 +502,6 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); #if CONFIG_CORE_COUNT > 1 - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _system_shared_heap_start = ABSOLUTE(.); - . = . + HEAP_SYSTEM_SHARED_SIZE; - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _system_shared_heap_end = ABSOLUTE(.); - . = ALIGN (HEAP_BUF_ALIGNMENT); _sof_core_s_start = ABSOLUTE(.); . = . + SOF_CORE_S_T_SIZE; @@ -541,11 +535,6 @@ SECTIONS /* system runtime heap */ _system_runtime_heap = _system_runtime_heap_start; -#if CONFIG_CORE_COUNT > 1 - /* Shared Heap */ - _system_shared_heap = _system_shared_heap_start; -#endif - /* module heap */ _module_heap = _runtime_heap_start; diff --git a/src/platform/apollolake/include/platform/lib/memory.h b/src/platform/apollolake/include/platform/lib/memory.h index 94d9d35bbde4..b44606cf251f 100644 --- a/src/platform/apollolake/include/platform/lib/memory.h +++ b/src/platform/apollolake/include/platform/lib/memory.h @@ -293,9 +293,6 @@ HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ HEAP_RT_COUNT4096 * 4096) -/* Heap section sizes for system shared heap */ -#define HEAP_SYSTEM_SHARED_SIZE 0x1500 - #define HEAP_BUFFER_BLOCK_SIZE 0x100 /* * The buffer zone will not occupy more than half of the HP SRAM on APL, @@ -394,7 +391,6 @@ #define PLATFORM_HEAP_SYSTEM CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 -#define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_BUFFER 2 /* Stack configuration */ diff --git a/src/platform/cannonlake/cannonlake.x.in b/src/platform/cannonlake/cannonlake.x.in index 1941a60e79cc..e047d36e02be 100644 --- a/src/platform/cannonlake/cannonlake.x.in +++ b/src/platform/cannonlake/cannonlake.x.in @@ -467,12 +467,6 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); #if CONFIG_CORE_COUNT > 1 - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _system_shared_heap_start = ABSOLUTE(.); - . = . + HEAP_SYSTEM_SHARED_SIZE; - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _system_shared_heap_end = ABSOLUTE(.); - . = ALIGN (SRAM_BANK_SIZE); _sof_core_s_start = ABSOLUTE(.); . = . + SOF_CORE_S_T_SIZE; @@ -507,11 +501,6 @@ SECTIONS /* system runtime heap */ _system_runtime_heap = _system_runtime_heap_start; -#if CONFIG_CORE_COUNT > 1 - /* Shared Heap */ - _system_shared_heap = _system_shared_heap_start; -#endif - /* module heap */ _module_heap = _runtime_heap_start; diff --git a/src/platform/cannonlake/include/platform/lib/memory.h b/src/platform/cannonlake/include/platform/lib/memory.h index 416f7b2eacb1..8c0d282c9dbd 100644 --- a/src/platform/cannonlake/include/platform/lib/memory.h +++ b/src/platform/cannonlake/include/platform/lib/memory.h @@ -276,9 +276,6 @@ HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ HEAP_RT_COUNT4096 * 4096) -/* Heap section sizes for system shared heap */ -#define HEAP_SYSTEM_SHARED_SIZE 0x1500 - #define HEAP_BUFFER_BLOCK_SIZE 0x100 #define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / HEAP_BUFFER_BLOCK_SIZE) @@ -383,7 +380,6 @@ #define PLATFORM_HEAP_SYSTEM CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 -#define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_BUFFER 2 /* Stack configuration */ diff --git a/src/platform/icelake/icelake.x.in b/src/platform/icelake/icelake.x.in index 3bd5ce2f8603..8feca537bed9 100644 --- a/src/platform/icelake/icelake.x.in +++ b/src/platform/icelake/icelake.x.in @@ -471,12 +471,6 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); #if CONFIG_CORE_COUNT > 1 - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _system_shared_heap_start = ABSOLUTE(.); - . = . + HEAP_SYSTEM_SHARED_SIZE; - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _system_shared_heap_end = ABSOLUTE(.); - . = ALIGN (SRAM_BANK_SIZE); _sof_core_s_start = ABSOLUTE(.); . = . + SOF_CORE_S_T_SIZE; @@ -511,11 +505,6 @@ SECTIONS /* system runtime heap */ _system_runtime_heap = _system_runtime_heap_start; -#if CONFIG_CORE_COUNT > 1 - /* Shared Heap */ - _system_shared_heap = _system_shared_heap_start; -#endif - /* module heap */ _module_heap = _runtime_heap_start; diff --git a/src/platform/icelake/include/platform/lib/memory.h b/src/platform/icelake/include/platform/lib/memory.h index 06f5ab49aa56..884b4de8cccc 100644 --- a/src/platform/icelake/include/platform/lib/memory.h +++ b/src/platform/icelake/include/platform/lib/memory.h @@ -273,9 +273,6 @@ HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ HEAP_RT_COUNT4096 * 4096) -/* Heap section sizes for system shared heap */ -#define HEAP_SYSTEM_SHARED_SIZE 0x1500 - #define HEAP_BUFFER_BLOCK_SIZE 0x100 #define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / HEAP_BUFFER_BLOCK_SIZE) @@ -355,7 +352,6 @@ #define PLATFORM_HEAP_SYSTEM CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 -#define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_BUFFER 2 /* Stack configuration */ diff --git a/src/platform/intel/cavs/lib/memory.c b/src/platform/intel/cavs/lib/memory.c index 5343933b77a9..c3fbd9bdb82f 100644 --- a/src/platform/intel/cavs/lib/memory.c +++ b/src/platform/intel/cavs/lib/memory.c @@ -20,9 +20,6 @@ extern uintptr_t _system_heap, _system_runtime_heap, _module_heap; extern uintptr_t _buffer_heap, _sof_core_s_start; -#if CONFIG_CORE_COUNT > 1 -extern uintptr_t _system_shared_heap; -#endif /* Heap blocks for system runtime for primary core */ static SHARED_DATA struct block_hdr sys_rt_0_block64[HEAP_SYS_RT_0_COUNT64]; @@ -178,16 +175,6 @@ void platform_init_memmap(struct sof *sof) SOF_MEM_CAPS_DMA; } -#if CONFIG_CORE_COUNT > 1 - /* .system_shared init */ - sof->memory_map->system_shared[0].heap = cache_to_uncache((uintptr_t)&_system_shared_heap); - sof->memory_map->system_shared[0].size = HEAP_SYSTEM_SHARED_SIZE; - sof->memory_map->system_shared[0].info.free = HEAP_SYSTEM_SHARED_SIZE; - sof->memory_map->system_shared[0].caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_EXT | - SOF_MEM_CAPS_CACHE; - -#endif - /* .runtime init*/ sof->memory_map->runtime[0].blocks = ARRAY_SIZE(rt_heap_map); sof->memory_map->runtime[0].map = uncached_block_map(rt_heap_map); diff --git a/src/platform/library/lib/memory.c b/src/platform/library/lib/memory.c index 947cb271b3a7..6dc1aa77f607 100644 --- a/src/platform/library/lib/memory.c +++ b/src/platform/library/lib/memory.c @@ -26,6 +26,13 @@ #define HEAP_RUNTIME_BASE 0xBE180000 #define HEAP_BUFFER_BASE 0xBE1C0000 +/* Memory mock for memmap */ +#define HEAP_SYSTEM_0_BASE 0xBE100000 +#define HEAP_SYS_RUNTIME_0_BASE 0xBE120000 +#define SOF_CORE_S_START 0xBE140000 +#define HEAP_RUNTIME_BASE 0xBE180000 +#define HEAP_BUFFER_BASE 0xBE1C0000 + /* Heap blocks for system runtime for primary core */ static SHARED_DATA struct block_hdr sys_rt_0_block64[HEAP_SYS_RT_0_COUNT64]; static SHARED_DATA struct block_hdr sys_rt_0_block512[HEAP_SYS_RT_0_COUNT512]; @@ -180,17 +187,6 @@ void platform_init_memmap(struct sof *sof) SOF_MEM_CAPS_DMA; } -#if CONFIG_CORE_COUNT > 1 - /* .system_shared init */ - sof->memory_map->system_shared[0].heap = - (unsigned long)cache_to_uncache(malloc(HEAP_SYSTEM_SHARED_SIZE)); - sof->memory_map->system_shared[0].size = HEAP_SYSTEM_SHARED_SIZE; - sof->memory_map->system_shared[0].info.free = HEAP_SYSTEM_SHARED_SIZE; - sof->memory_map->system_shared[0].caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_EXT | - SOF_MEM_CAPS_CACHE; - -#endif - /* .runtime init*/ sof->memory_map->runtime[0].blocks = ARRAY_SIZE(rt_heap_map); sof->memory_map->runtime[0].map = uncached_block_map(rt_heap_map); diff --git a/src/platform/suecreek/include/platform/lib/memory.h b/src/platform/suecreek/include/platform/lib/memory.h index e45b06c74d3f..c99c8c6a567b 100644 --- a/src/platform/suecreek/include/platform/lib/memory.h +++ b/src/platform/suecreek/include/platform/lib/memory.h @@ -264,9 +264,6 @@ HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ HEAP_RT_COUNT4096 * 4096) -/* Heap section sizes for system shared heap */ -#define HEAP_SYSTEM_SHARED_SIZE 0x1500 - #define HEAP_BUFFER_BLOCK_SIZE 0x100 #define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / HEAP_BUFFER_BLOCK_SIZE) @@ -363,7 +360,6 @@ #define PLATFORM_HEAP_SYSTEM CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 -#define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_BUFFER 2 /* Stack configuration */ diff --git a/src/platform/suecreek/suecreek.x.in b/src/platform/suecreek/suecreek.x.in index dd21920ad7e2..fbe8318d4bed 100644 --- a/src/platform/suecreek/suecreek.x.in +++ b/src/platform/suecreek/suecreek.x.in @@ -469,12 +469,6 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); #if CONFIG_CORE_COUNT > 1 - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _system_shared_heap_start = ABSOLUTE(.); - . = . + HEAP_SYSTEM_SHARED_SIZE; - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _system_shared_heap_end = ABSOLUTE(.); - . = ALIGN (SRAM_BANK_SIZE); _sof_core_s_start = ABSOLUTE(.); . = . + SOF_CORE_S_T_SIZE; @@ -509,11 +503,6 @@ SECTIONS /* system runtime heap */ _system_runtime_heap = _system_runtime_heap_start; -#if CONFIG_CORE_COUNT > 1 - /* Shared Heap */ - _system_shared_heap = _system_shared_heap_start; -#endif - /* module heap */ _module_heap = _runtime_heap_start; diff --git a/src/platform/tigerlake/include/platform/lib/memory.h b/src/platform/tigerlake/include/platform/lib/memory.h index 302e1ab0297f..53d5b3f3e2c6 100644 --- a/src/platform/tigerlake/include/platform/lib/memory.h +++ b/src/platform/tigerlake/include/platform/lib/memory.h @@ -286,9 +286,6 @@ HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ HEAP_RT_COUNT4096 * 4096) -/* Heap section sizes for system shared heap */ -#define HEAP_SYSTEM_SHARED_SIZE 0x1500 - #define HEAP_BUFFER_BLOCK_SIZE 0x100 #define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / HEAP_BUFFER_BLOCK_SIZE) @@ -386,7 +383,6 @@ #define PLATFORM_HEAP_SYSTEM CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 -#define PLATFORM_HEAP_SYSTEM_SHARED 1 #define PLATFORM_HEAP_BUFFER 2 /* Stack configuration */ diff --git a/src/platform/tigerlake/tigerlake.x.in b/src/platform/tigerlake/tigerlake.x.in index a872b2ab53f5..a02b8c0f44aa 100644 --- a/src/platform/tigerlake/tigerlake.x.in +++ b/src/platform/tigerlake/tigerlake.x.in @@ -545,12 +545,6 @@ SECTIONS _sof_stack_end = ABSOLUTE(.); #if CONFIG_CORE_COUNT > 1 - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _system_shared_heap_start = ABSOLUTE(.); - . = . + HEAP_SYSTEM_SHARED_SIZE; - . = ALIGN (PLATFORM_DCACHE_ALIGN); - _system_shared_heap_end = ABSOLUTE(.); - . = ALIGN (SRAM_BANK_SIZE); _sof_core_s_start = ABSOLUTE(.); . = . + SOF_CORE_S_T_SIZE; @@ -585,11 +579,6 @@ SECTIONS /* system runtime heap */ _system_runtime_heap = _system_runtime_heap_start; -#if CONFIG_CORE_COUNT > 1 - /* Shared Heap */ - _system_shared_heap = _system_shared_heap_start; -#endif - /* module heap */ _module_heap = _runtime_heap_start; From 1a1526aa2766908fb733e46f6f1231ae69e47c88 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 10 Sep 2021 12:43:43 +0800 Subject: [PATCH 13/14] cmocka: align to the remove the shared zones Align to the new heap memory map and allocator, SYSTEM_SHARED and RUNTIME_SHARED zones are removed. Signed-off-by: Keyon Jie --- src/platform/library/include/platform/lib/memory.h | 4 ---- test/cmocka/include/mock_memory.h | 6 ++---- test/cmocka/memory_mock.x.in | 2 -- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/platform/library/include/platform/lib/memory.h b/src/platform/library/include/platform/lib/memory.h index d4bb1dc5a58c..9030cd2fe8d9 100644 --- a/src/platform/library/include/platform/lib/memory.h +++ b/src/platform/library/include/platform/lib/memory.h @@ -27,7 +27,6 @@ uint8_t *get_library_mailbox(void); #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT #define PLATFORM_HEAP_RUNTIME 1 #define PLATFORM_HEAP_BUFFER 2 -#define PLATFORM_HEAP_RUNTIME_SHARED 1 #define SHARED_DATA @@ -98,9 +97,6 @@ static inline uint32_t arch_get_stack_size(void) HEAP_COUNT1024 * 1024 + HEAP_COUNT2048 * 2048 + \ HEAP_COUNT4096 * 4096) -/* Heap section sizes for system shared heap */ -#define HEAP_SYSTEM_SHARED_SIZE 0x1500 - #define HEAP_BUFFER_BLOCK_SIZE 0x100 #define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / HEAP_BUFFER_BLOCK_SIZE) diff --git a/test/cmocka/include/mock_memory.h b/test/cmocka/include/mock_memory.h index f06e4a71d4bf..6e2a8b20a855 100644 --- a/test/cmocka/include/mock_memory.h +++ b/test/cmocka/include/mock_memory.h @@ -9,7 +9,5 @@ #define HEAP_SYSTEM_0_BASE 0xBE200000 #define HEAP_SYS_RUNTIME_0_BASE 0xBE220000 #define SOF_CORE_S_START 0xBE280000 -#define HEAP_RUNTIME_SHARED_BASE 0xBE290000 -#define HEAP_SYSTEM_SHARED_BASE 0xBE2B0000 -#define HEAP_RUNTIME_BASE 0xBE2C0000 -#define HEAP_BUFFER_BASE 0xBE3B0000 +#define HEAP_RUNTIME_BASE 0xBE290000 +#define HEAP_BUFFER_BASE 0xBE380000 diff --git a/test/cmocka/memory_mock.x.in b/test/cmocka/memory_mock.x.in index add0b217b077..60d217f3c56f 100644 --- a/test/cmocka/memory_mock.x.in +++ b/test/cmocka/memory_mock.x.in @@ -18,8 +18,6 @@ SECTIONS _system_heap_start = HEAP_SYSTEM_0_BASE; _system_runtime_heap = HEAP_SYS_RUNTIME_0_BASE; _sof_core_s_start = SOF_CORE_S_START; - _runtime_shared_heap = HEAP_RUNTIME_SHARED_BASE; - _system_shared_heap = HEAP_SYSTEM_SHARED_BASE; _module_heap = HEAP_RUNTIME_BASE; _buffer_heap = HEAP_BUFFER_BASE; } From acbbfa508ba18be0896fd3e3ae43038010cca147 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 22 Sep 2021 18:30:31 +0800 Subject: [PATCH 14/14] memory: update configurations to adapt to the new allocator Now buffer zone should have bigger size, and runtime zone is smaller. Signed-off-by: Keyon Jie --- .../apollolake/include/platform/lib/memory.h | 52 ++++++------------- .../cannonlake/include/platform/lib/memory.h | 37 ++++--------- .../haswell/include/platform/lib/memory.h | 14 ++--- .../icelake/include/platform/lib/memory.h | 37 ++++--------- src/platform/intel/cavs/lib/memory.c | 28 +++++----- .../suecreek/include/platform/lib/memory.h | 36 ++++++------- .../tigerlake/include/platform/lib/memory.h | 39 +++----------- 7 files changed, 79 insertions(+), 164 deletions(-) diff --git a/src/platform/apollolake/include/platform/lib/memory.h b/src/platform/apollolake/include/platform/lib/memory.h index b44606cf251f..c7e91dbc1c0e 100644 --- a/src/platform/apollolake/include/platform/lib/memory.h +++ b/src/platform/apollolake/include/platform/lib/memory.h @@ -152,14 +152,6 @@ * | | ----------------------- | | * | ||BSS: || | * | ||-----------------------++-----------------------------+ - * | ||Runtime Heap || HEAP_RUNTIME_SIZE | - * | ||-----------------------++-----------------------------+ - * | ||Runtime shared Heap || HEAP_RUNTIME_SHARED_SIZE | - * | ||-----------------------++-----------------------------+ - * | ||System shared Heap || HEAP_SYSTEM_SHARED_SIZE | - * | ||-----------------------++-----------------------------+ - * | ||Module Buffers || HEAP_BUFFER_SIZE | - * | ||-----------------------++-----------------------------+ * | ||Primary core Sys Heap || HEAP_SYSTEM_M_SIZE | * | ||-----------------------++-----------------------------+ * | ||Pri. Sys Runtime Heap || HEAP_SYS_RUNTIME_M_SIZE | @@ -169,6 +161,10 @@ * | ||Sec. core Sys Heap || SOF_CORE_S_T_SIZE | * | ||Sec. Sys Runtime Heap || | * | ||Secondary core Stack || | + * | ||-----------------------++-----------------------------+ + * | ||Runtime Heap || HEAP_RUNTIME_SIZE | + * | ||-----------------------++-----------------------------+ + * | ||Module Buffers || HEAP_BUFFER_SIZE | * | | ----------------------- | | * +------------------+-------------------------+-----------------------------+ */ @@ -265,40 +261,24 @@ #define HEAP_SYS_RT_X_COUNT512 4 #define HEAP_SYS_RT_X_COUNT1024 2 -/* Heap section counts base */ -#define HEAP_COUNT64 48 -#define HEAP_COUNT128 64 -#define HEAP_COUNT256 64 -#define HEAP_COUNT512 6 -#define HEAP_COUNT1024 0 -#define HEAP_COUNT2048 0 +/* Heap runtime block counts */ +#define HEAP_COUNT64 48 +#define HEAP_COUNT128 64 +#define HEAP_COUNT256 64 +#define HEAP_COUNT512 6 +#define HEAP_COUNT1024 0 +#define HEAP_COUNT2048 0 #define HEAP_COUNT4096 0 -#define RT_TIMES 1 -#define RT_SHARED_TIMES 0 - -/* Heap section sizes for module pool */ -#define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES) -#define HEAP_RT_COUNT128 (HEAP_COUNT128 * RT_TIMES) -#define HEAP_RT_COUNT256 (HEAP_COUNT256 * RT_TIMES) -#define HEAP_RT_COUNT512 (HEAP_COUNT512 * RT_TIMES) -#define HEAP_RT_COUNT1024 (HEAP_COUNT1024 * RT_TIMES) -#define HEAP_RT_COUNT2048 (HEAP_COUNT2048 * RT_TIMES) -#define HEAP_RT_COUNT4096 (HEAP_COUNT4096 * RT_TIMES) - /* Heap configuration */ #define HEAP_RUNTIME_SIZE \ - (HEAP_RT_COUNT64 * 64 + HEAP_RT_COUNT128 * 128 + \ - HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT512 * 512 + \ - HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ - HEAP_RT_COUNT4096 * 4096) + (HEAP_COUNT64 * 64 + HEAP_COUNT128 * 128 + \ + HEAP_COUNT256 * 256 + HEAP_COUNT512 * 512 + \ + HEAP_COUNT1024 * 1024 + HEAP_COUNT2048 * 2048 + \ + HEAP_COUNT4096 * 4096) #define HEAP_BUFFER_BLOCK_SIZE 0x100 -/* - * The buffer zone will not occupy more than half of the HP SRAM on APL, - * enforcing this limit due to the the SRAM size limitations on APL. - */ -#define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / (HEAP_BUFFER_BLOCK_SIZE * 2)) +#define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / HEAP_BUFFER_BLOCK_SIZE) #define HEAP_SYSTEM_M_SIZE 0x3000 /* heap primary core size */ #define HEAP_SYSTEM_S_SIZE 0x2000 /* heap secondary core size */ diff --git a/src/platform/cannonlake/include/platform/lib/memory.h b/src/platform/cannonlake/include/platform/lib/memory.h index 8c0d282c9dbd..ac7418e21844 100644 --- a/src/platform/cannonlake/include/platform/lib/memory.h +++ b/src/platform/cannonlake/include/platform/lib/memory.h @@ -156,14 +156,6 @@ * | | ----------------------- | | * | ||BSS: || | * | ||-----------------------++-----------------------------+ - * | ||Runtime Heap || HEAP_RUNTIME_SIZE | - * | ||-----------------------++-----------------------------+ - * | ||Runtime shared Heap || HEAP_RUNTIME_SHARED_SIZE | - * | ||-----------------------++-----------------------------+ - * | ||System shared Heap || HEAP_SYSTEM_SHARED_SIZE | - * | ||-----------------------++-----------------------------+ - * | ||Module Buffers || HEAP_BUFFER_SIZE | - * | ||-----------------------++-----------------------------+ * | ||Primary core Sys Heap || HEAP_SYSTEM_M_SIZE | * | ||-----------------------++-----------------------------+ * | ||Pri. Sys Runtime Heap || HEAP_SYS_RUNTIME_M_SIZE | @@ -173,6 +165,10 @@ * | ||Sec. core Sys Heap || SOF_CORE_S_T_SIZE | * | ||Sec. Sys Runtime Heap || | * | ||Secondary core Stack || | + * | ||-----------------------++-----------------------------+ + * | ||Runtime Heap || HEAP_RUNTIME_SIZE | + * | ||-----------------------++-----------------------------+ + * | ||Module Buffers || HEAP_BUFFER_SIZE | * | | ----------------------- | | * +------------------+-------------------------+-----------------------------+ */ @@ -245,7 +241,7 @@ #define HEAP_SYS_RT_X_COUNT512 8 #define HEAP_SYS_RT_X_COUNT1024 4 -/* Heap section counts base */ +/* Heap runtime block counts */ #define HEAP_COUNT64 128 #define HEAP_COUNT128 128 #define HEAP_COUNT256 96 @@ -254,27 +250,12 @@ #define HEAP_COUNT2048 2 #define HEAP_COUNT4096 1 -#if HP_SRAM_SIZE < 0x200000 -#define RT_TIMES 3 -#else -#define RT_TIMES 8 -#endif - -/* Heap section sizes for module pool */ -#define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES) -#define HEAP_RT_COUNT128 (HEAP_COUNT128 * RT_TIMES) -#define HEAP_RT_COUNT256 (HEAP_COUNT256 * RT_TIMES) -#define HEAP_RT_COUNT512 (HEAP_COUNT512 * RT_TIMES) -#define HEAP_RT_COUNT1024 (HEAP_COUNT1024 * RT_TIMES) -#define HEAP_RT_COUNT2048 (HEAP_COUNT2048 * RT_TIMES) -#define HEAP_RT_COUNT4096 (HEAP_COUNT4096 * RT_TIMES) - /* Heap configuration */ #define HEAP_RUNTIME_SIZE \ - (HEAP_RT_COUNT64 * 64 + HEAP_RT_COUNT128 * 128 + \ - HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT512 * 512 + \ - HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ - HEAP_RT_COUNT4096 * 4096) + (HEAP_COUNT64 * 64 + HEAP_COUNT128 * 128 + \ + HEAP_COUNT256 * 256 + HEAP_COUNT512 * 512 + \ + HEAP_COUNT1024 * 1024 + HEAP_COUNT2048 * 2048 + \ + HEAP_COUNT4096 * 4096) #define HEAP_BUFFER_BLOCK_SIZE 0x100 #define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / HEAP_BUFFER_BLOCK_SIZE) diff --git a/src/platform/haswell/include/platform/lib/memory.h b/src/platform/haswell/include/platform/lib/memory.h index 5a2e24aa8b5b..920130587f06 100644 --- a/src/platform/haswell/include/platform/lib/memory.h +++ b/src/platform/haswell/include/platform/lib/memory.h @@ -123,13 +123,13 @@ static inline void *platform_rfree_prepare(void *ptr) /* Heap section sizes for module pool */ #define HEAP_RT_COUNT8 0 -#define HEAP_RT_COUNT16 64 -#define HEAP_RT_COUNT32 48 -#define HEAP_RT_COUNT64 24 -#define HEAP_RT_COUNT128 24 -#define HEAP_RT_COUNT256 24 -#define HEAP_RT_COUNT512 2 -#define HEAP_RT_COUNT1024 1 +#define HEAP_RT_COUNT16 192 +#define HEAP_RT_COUNT32 128 +#define HEAP_RT_COUNT64 64 +#define HEAP_RT_COUNT128 64 +#define HEAP_RT_COUNT256 64 +#define HEAP_RT_COUNT512 8 +#define HEAP_RT_COUNT1024 4 /* Heap section sizes for system runtime heap */ #define HEAP_SYS_RT_COUNT64 64 diff --git a/src/platform/icelake/include/platform/lib/memory.h b/src/platform/icelake/include/platform/lib/memory.h index 884b4de8cccc..7bb3157c17ef 100644 --- a/src/platform/icelake/include/platform/lib/memory.h +++ b/src/platform/icelake/include/platform/lib/memory.h @@ -155,14 +155,6 @@ * | | data | | * | | BSS | | * +------------------+-------------------------+-----------------------------+ - * | | Runtime Heap | HEAP_RUNTIME_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | | Runtime shared Heap | HEAP_RUNTIME_SHARED_SIZE | - * | |-------------------------+-----------------------------+ - * | | System shared Heap | HEAP_SYSTEM_SHARED_SIZE | - * | |-------------------------+-----------------------------+ - * | | Module Buffers | HEAP_BUFFER_SIZE | - * +------------------+-------------------------+-----------------------------+ * | | Primary core Sys Heap | HEAP_SYSTEM_M_SIZE | * +------------------+-------------------------+-----------------------------+ * | | Pri. Sys Runtime Heap | HEAP_SYS_RUNTIME_M_SIZE | @@ -173,6 +165,10 @@ * | | Sec. Sys Runtime Heap | | * | | Secondary core Stack | | * +------------------+-------------------------+-----------------------------+ + * | | Runtime Heap | HEAP_RUNTIME_SIZE | + * +------------------+-------------------------+-----------------------------+ + * | | Module Buffers | HEAP_BUFFER_SIZE | + * +------------------+-------------------------+-----------------------------+ */ /* HP SRAM */ @@ -242,7 +238,7 @@ #define HEAP_SYS_RT_X_COUNT512 8 #define HEAP_SYS_RT_X_COUNT1024 4 -/* Heap section counts base */ +/* Heap runtime block counts */ #define HEAP_COUNT64 128 #define HEAP_COUNT128 128 #define HEAP_COUNT256 96 @@ -251,27 +247,12 @@ #define HEAP_COUNT2048 2 #define HEAP_COUNT4096 1 -#if HP_SRAM_SIZE < 0x200000 -#define RT_TIMES 1 -#else -#define RT_TIMES 8 -#endif - -/* Heap section sizes for module pool */ -#define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES) -#define HEAP_RT_COUNT128 (HEAP_COUNT128 * RT_TIMES) -#define HEAP_RT_COUNT256 (HEAP_COUNT256 * RT_TIMES) -#define HEAP_RT_COUNT512 (HEAP_COUNT512 * RT_TIMES) -#define HEAP_RT_COUNT1024 (HEAP_COUNT1024 * RT_TIMES) -#define HEAP_RT_COUNT2048 (HEAP_COUNT2048 * RT_TIMES) -#define HEAP_RT_COUNT4096 (HEAP_COUNT4096 * RT_TIMES) - /* Heap configuration */ #define HEAP_RUNTIME_SIZE \ - (HEAP_RT_COUNT64 * 64 + HEAP_RT_COUNT128 * 128 + \ - HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT512 * 512 + \ - HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ - HEAP_RT_COUNT4096 * 4096) + (HEAP_COUNT64 * 64 + HEAP_COUNT128 * 128 + \ + HEAP_COUNT256 * 256 + HEAP_COUNT512 * 512 + \ + HEAP_COUNT1024 * 1024 + HEAP_COUNT2048 * 2048 + \ + HEAP_COUNT4096 * 4096) #define HEAP_BUFFER_BLOCK_SIZE 0x100 #define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / HEAP_BUFFER_BLOCK_SIZE) diff --git a/src/platform/intel/cavs/lib/memory.c b/src/platform/intel/cavs/lib/memory.c index c3fbd9bdb82f..c12d7b0d27e0 100644 --- a/src/platform/intel/cavs/lib/memory.c +++ b/src/platform/intel/cavs/lib/memory.c @@ -71,23 +71,23 @@ static SHARED_DATA struct block_map sys_rt_heap_map[CONFIG_CORE_COUNT][3] = { }; /* Heap blocks for modules */ -static SHARED_DATA struct block_hdr mod_block64[HEAP_RT_COUNT64]; -static SHARED_DATA struct block_hdr mod_block128[HEAP_RT_COUNT128]; -static SHARED_DATA struct block_hdr mod_block256[HEAP_RT_COUNT256]; -static SHARED_DATA struct block_hdr mod_block512[HEAP_RT_COUNT512]; -static SHARED_DATA struct block_hdr mod_block1024[HEAP_RT_COUNT1024]; -static SHARED_DATA struct block_hdr mod_block2048[HEAP_RT_COUNT2048]; -static SHARED_DATA struct block_hdr mod_block4096[HEAP_RT_COUNT4096]; +static SHARED_DATA struct block_hdr mod_block64[HEAP_COUNT64]; +static SHARED_DATA struct block_hdr mod_block128[HEAP_COUNT128]; +static SHARED_DATA struct block_hdr mod_block256[HEAP_COUNT256]; +static SHARED_DATA struct block_hdr mod_block512[HEAP_COUNT512]; +static SHARED_DATA struct block_hdr mod_block1024[HEAP_COUNT1024]; +static SHARED_DATA struct block_hdr mod_block2048[HEAP_COUNT2048]; +static SHARED_DATA struct block_hdr mod_block4096[HEAP_COUNT4096]; /* Heap memory map for modules */ static SHARED_DATA struct block_map rt_heap_map[] = { - BLOCK_DEF(64, HEAP_RT_COUNT64, uncached_block_hdr(mod_block64)), - BLOCK_DEF(128, HEAP_RT_COUNT128, uncached_block_hdr(mod_block128)), - BLOCK_DEF(256, HEAP_RT_COUNT256, uncached_block_hdr(mod_block256)), - BLOCK_DEF(512, HEAP_RT_COUNT512, uncached_block_hdr(mod_block512)), - BLOCK_DEF(1024, HEAP_RT_COUNT1024, uncached_block_hdr(mod_block1024)), - BLOCK_DEF(2048, HEAP_RT_COUNT2048, uncached_block_hdr(mod_block2048)), - BLOCK_DEF(4096, HEAP_RT_COUNT4096, uncached_block_hdr(mod_block4096)), + BLOCK_DEF(64, HEAP_COUNT64, uncached_block_hdr(mod_block64)), + BLOCK_DEF(128, HEAP_COUNT128, uncached_block_hdr(mod_block128)), + BLOCK_DEF(256, HEAP_COUNT256, uncached_block_hdr(mod_block256)), + BLOCK_DEF(512, HEAP_COUNT512, uncached_block_hdr(mod_block512)), + BLOCK_DEF(1024, HEAP_COUNT1024, uncached_block_hdr(mod_block1024)), + BLOCK_DEF(2048, HEAP_COUNT2048, uncached_block_hdr(mod_block2048)), + BLOCK_DEF(4096, HEAP_COUNT4096, uncached_block_hdr(mod_block4096)), }; /* Heap blocks for buffers */ diff --git a/src/platform/suecreek/include/platform/lib/memory.h b/src/platform/suecreek/include/platform/lib/memory.h index c99c8c6a567b..7f4480ce3195 100644 --- a/src/platform/suecreek/include/platform/lib/memory.h +++ b/src/platform/suecreek/include/platform/lib/memory.h @@ -166,14 +166,6 @@ * | | ----------------------- | | * | ||BSS: || | * | ||-----------------------++-----------------------------+ - * | ||Runtime Heap || HEAP_RUNTIME_SIZE | - * | ||-----------------------++-----------------------------+ - * | ||Runtime shared Heap || HEAP_RUNTIME_SHARED_SIZE | - * | ||-----------------------++-----------------------------+ - * | ||System shared Heap || HEAP_SYSTEM_SHARED_SIZE | - * | ||-----------------------++-----------------------------+ - * | ||Module Buffers || HEAP_BUFFER_SIZE | - * | ||-----------------------++-----------------------------+ * | ||Primary core Sys Heap || HEAP_SYSTEM_M_SIZE | * | ||-----------------------++-----------------------------+ * | ||Pri. Sys Runtime Heap || HEAP_SYS_RUNTIME_M_SIZE | @@ -183,6 +175,10 @@ * | ||Sec. core Sys Heap || SOF_CORE_S_T_SIZE | * | ||Sec. Sys Runtime Heap || | * | ||Secondary core Stack || | + * | ||-----------------------++-----------------------------+ + * | ||Runtime Heap || HEAP_RUNTIME_SIZE | + * | ||-----------------------++-----------------------------+ + * | ||Module Buffers || HEAP_BUFFER_SIZE | * | | ----------------------- | | * +------------------+-------------------------+-----------------------------+ */ @@ -248,21 +244,21 @@ #define HEAP_SYS_RT_X_COUNT512 8 #define HEAP_SYS_RT_X_COUNT1024 4 -/* Heap section sizes for module pool */ -#define HEAP_RT_COUNT64 192 -#define HEAP_RT_COUNT128 32 -#define HEAP_RT_COUNT256 80 -#define HEAP_RT_COUNT512 8 -#define HEAP_RT_COUNT1024 4 -#define HEAP_RT_COUNT2048 1 -#define HEAP_RT_COUNT4096 1 +/* Heap runtime block counts */ +#define HEAP_COUNT64 128 +#define HEAP_COUNT128 128 +#define HEAP_COUNT256 96 +#define HEAP_COUNT512 8 +#define HEAP_COUNT1024 4 +#define HEAP_COUNT2048 2 +#define HEAP_COUNT4096 1 /* Heap configuration */ #define HEAP_RUNTIME_SIZE \ - (HEAP_RT_COUNT64 * 64 + HEAP_RT_COUNT128 * 128 + \ - HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT512 * 512 + \ - HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ - HEAP_RT_COUNT4096 * 4096) + (HEAP_COUNT64 * 64 + HEAP_COUNT128 * 128 + \ + HEAP_COUNT256 * 256 + HEAP_COUNT512 * 512 + \ + HEAP_COUNT1024 * 1024 + HEAP_COUNT2048 * 2048 + \ + HEAP_COUNT4096 * 4096) #define HEAP_BUFFER_BLOCK_SIZE 0x100 #define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / HEAP_BUFFER_BLOCK_SIZE) diff --git a/src/platform/tigerlake/include/platform/lib/memory.h b/src/platform/tigerlake/include/platform/lib/memory.h index 53d5b3f3e2c6..d5fefba5cf9a 100644 --- a/src/platform/tigerlake/include/platform/lib/memory.h +++ b/src/platform/tigerlake/include/platform/lib/memory.h @@ -158,14 +158,6 @@ * | | data | | * | | BSS | | * +--------------------+-------------------------+-----------------------------+ - * | | Runtime Heap | HEAP_RUNTIME_SIZE | - * +--------------------+-------------------------+-----------------------------+ - * | | Runtime shared Heap | HEAP_RUNTIME_SHARED_SIZE | - * | |-------------------------+-----------------------------+ - * | | System shared Heap | HEAP_SYSTEM_SHARED_SIZE | - * | |-------------------------+-----------------------------+ - * | | Module Buffers | HEAP_BUFFER_SIZE | - * +--------------------+-------------------------+-----------------------------+ * | | Primary core Sys Heap | HEAP_SYSTEM_M_SIZE | * +--------------------+-------------------------+-----------------------------+ * | | Pri. Sys Runtime Heap | HEAP_SYS_RUNTIME_M_SIZE | @@ -176,6 +168,10 @@ * | | Sec. Sys Runtime Heap | | * | | Secondary core Stack | | * +--------------------+-------------------------+-----------------------------+ + * | | Runtime Heap | HEAP_RUNTIME_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | | Module Buffers | HEAP_BUFFER_SIZE | + * +--------------------+-------------------------+-----------------------------+ */ /* HP SRAM */ @@ -260,31 +256,12 @@ #define HEAP_COUNT2048 2 #define HEAP_COUNT4096 1 -#if HP_SRAM_SIZE < 0x200000 -#define RT_TIMES 3 -#else -#ifdef CONFIG_COMP_RTNR -#define RT_TIMES 6 -#else -#define RT_TIMES 8 -#endif /* CONFIG_COMP_RTNR */ -#endif - -/* Heap section sizes for module pool */ -#define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES) -#define HEAP_RT_COUNT128 (HEAP_COUNT128 * RT_TIMES) -#define HEAP_RT_COUNT256 (HEAP_COUNT256 * RT_TIMES) -#define HEAP_RT_COUNT512 (HEAP_COUNT512 * RT_TIMES) -#define HEAP_RT_COUNT1024 (HEAP_COUNT1024 * RT_TIMES) -#define HEAP_RT_COUNT2048 (HEAP_COUNT2048 * RT_TIMES) -#define HEAP_RT_COUNT4096 (HEAP_COUNT4096 * RT_TIMES) - /* Heap configuration */ #define HEAP_RUNTIME_SIZE \ - (HEAP_RT_COUNT64 * 64 + HEAP_RT_COUNT128 * 128 + \ - HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT512 * 512 + \ - HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + \ - HEAP_RT_COUNT4096 * 4096) + (HEAP_COUNT64 * 64 + HEAP_COUNT128 * 128 + \ + HEAP_COUNT256 * 256 + HEAP_COUNT512 * 512 + \ + HEAP_COUNT1024 * 1024 + HEAP_COUNT2048 * 2048 + \ + HEAP_COUNT4096 * 4096) #define HEAP_BUFFER_BLOCK_SIZE 0x100 #define HEAP_BUFFER_COUNT_MAX (HP_SRAM_SIZE / HEAP_BUFFER_BLOCK_SIZE)