From 84c09433b574b40a7d673fb47a1600c64b1d57c8 Mon Sep 17 00:00:00 2001 From: Marcin Szkudlinski Date: Tue, 25 Oct 2022 10:02:12 +0200 Subject: [PATCH] mtl: soc: TLB driver provides required size of L3 storage buffer TLB driver knows the required number of bytes for HPSRAM storage during power off state. Signed-off-by: Marcin Szkudlinski --- drivers/mm/mm_drv_intel_adsp_mtl_tlb.c | 14 +++++++++++++- include/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/mm/mm_drv_intel_adsp_mtl_tlb.c b/drivers/mm/mm_drv_intel_adsp_mtl_tlb.c index af13ee5ab81..4eb16f4e4a6 100644 --- a/drivers/mm/mm_drv_intel_adsp_mtl_tlb.c +++ b/drivers/mm/mm_drv_intel_adsp_mtl_tlb.c @@ -817,8 +817,20 @@ __imr void adsp_mm_restore_context(void *storage_buffer) /* HPSRAM memory is restored */ } +static uint32_t adsp_mm_get_storage_size(void) +{ + /* + * FIXME - currently the function returns a maximum possible size of the buffer + * as L3 memory is generally a huge area its OK (and fast) + * in future the function may go through the mapping and calculate a required size + */ + return L2_SRAM_SIZE + TLB_SIZE + (L2_SRAM_PAGES_NUM * sizeof(void *)) + + sizeof(void *); +} + static const struct intel_adsp_tlb_api adsp_tlb_api_func = { - .save_context = adsp_mm_save_context + .save_context = adsp_mm_save_context, + .get_storage_size = adsp_mm_get_storage_size }; DEVICE_DT_DEFINE(DT_INST(0, intel_adsp_mtl_tlb), diff --git a/include/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h b/include/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h index b6ec89fe647..22f81098fbc 100644 --- a/include/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h +++ b/include/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h @@ -26,6 +26,12 @@ */ typedef void (*mm_save_context)(void *storage_buffer); +/* + * This function will return a required size of storage buffer needed to perform context save + * + */ +typedef uint32_t (*mm_get_storage_size)(void); + /* * This function will restore the contents and power state of the physical memory banks * and recreate physical to virtual mappings @@ -40,6 +46,7 @@ void adsp_mm_restore_context(void *storage_buffer); struct intel_adsp_tlb_api { mm_save_context save_context; + mm_get_storage_size get_storage_size; }; #endif /* ZEPHYR_INCLUDE_DRIVERS_INTEL_ADSP_MTL_TLB */