From bc6e2ce23d2bc398467e021a413c8dd624c64721 Mon Sep 17 00:00:00 2001 From: Liam Mark Date: Wed, 16 Nov 2022 11:27:04 -0800 Subject: [PATCH] ubwcp: Re-map as uncached and invalidate Re-map ULA PA as uncached and invalidate before power collapse. Change-Id: Ice676b98a472512c0be1ad83b5b592fec079e7ee Signed-off-by: Liam Mark --- ubwcp/ubwcp_main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ubwcp/ubwcp_main.c b/ubwcp/ubwcp_main.c index d0768b1b31..34e3ba207b 100644 --- a/ubwcp/ubwcp_main.c +++ b/ubwcp/ubwcp_main.c @@ -26,6 +26,7 @@ #include #include #include +#include MODULE_IMPORT_NS(DMA_BUF); @@ -2000,6 +2001,24 @@ static int ubwcp_free_buffer(struct dma_buf *dmabuf) * care of flush. Just a note for now. Might need to add the * flush here for debug purpose. */ + + DBG("set_direct_map_range_uncached() for ULA PA pool st:0x%lx num pages:%lu", + ubwcp->ula_pool_base, ubwcp->ula_pool_size >> PAGE_SHIFT); + ret = set_direct_map_range_uncached((unsigned long)phys_to_virt( + ubwcp->ula_pool_base), ubwcp->ula_pool_size >> PAGE_SHIFT); + if (ret) { + ERR("set_direct_map_range_uncached failed st:0x%lx num pages:%lu err: %d", + ubwcp->ula_pool_base, + ubwcp->ula_pool_size >> PAGE_SHIFT, ret); + goto err_remove_mem; + } else { + DBG("DONE: calling set_direct_map_range_uncached() for ULA PA pool"); + } + + DBG("Calling dma_sync_single_for_cpu() for ULA PA pool"); + dma_sync_single_for_cpu(ubwcp->dev, ubwcp->ula_pool_base, ubwcp->ula_pool_size, + DMA_BIDIRECTIONAL); + DBG("Calling offline_and_remove_memory() for ULA PA pool"); ret = offline_and_remove_memory(ubwcp->ula_pool_base, ubwcp->ula_pool_size);