Skip to content

Commit e4a9503

Browse files
softwareckicarlescufi
authored andcommitted
mm: tlb: Improve the context saving function
Attempt to invalidate cache for an unmapped address results in cpu exception for the ptl platform. Perform cache invalidation after translation activation in tlb. Add address mapping in mmu for platforms that have it. Signed-off-by: Adrian Warecki <[email protected]>
1 parent 750212c commit e4a9503

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/mm/mm_drv_intel_adsp_mtl_tlb.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -836,18 +836,25 @@ static void adsp_mm_save_context(void *storage_buffer)
836836

837837
if (((tlb_entries[entry_idx] & TLB_PADDR_MASK) != entry) ||
838838
((tlb_entries[entry_idx] & TLB_ENABLE_BIT) != TLB_ENABLE_BIT)) {
839-
/* this page needs remapping, invalidate cache to avoid stalled data
840-
* all cache data has been flushed before
841-
* do this for pages to remap only
842-
*/
843-
sys_cache_data_invd_range(UINT_TO_POINTER(phys_addr),
844-
CONFIG_MM_DRV_PAGE_SIZE);
839+
/* This page needs remapping */
845840

846841
/* Enable the translation in the TLB entry */
847842
entry |= TLB_ENABLE_BIT;
848843

849844
/* map the page 1:1 virtual to physical */
850845
tlb_entries[entry_idx] = entry;
846+
847+
#ifdef CONFIG_MMU
848+
arch_mem_map(UINT_TO_POINTER(phys_addr), phys_addr, CONFIG_MM_DRV_PAGE_SIZE,
849+
K_MEM_CACHE_WB);
850+
#endif
851+
852+
/* Invalidate cache to avoid stalled data
853+
* all cache data has been flushed before
854+
* do this for pages to remap only
855+
*/
856+
sys_cache_data_invd_range(UINT_TO_POINTER(phys_addr),
857+
CONFIG_MM_DRV_PAGE_SIZE);
851858
}
852859

853860
/* save physical address */

0 commit comments

Comments
 (0)