diff --git a/drivers/amlogic/secmon/secmon.c b/drivers/amlogic/secmon/secmon.c index c24a866d38c9..1eb31cb3da19 100644 --- a/drivers/amlogic/secmon/secmon.c +++ b/drivers/amlogic/secmon/secmon.c @@ -37,7 +37,7 @@ static long phy_out_base; #ifdef CONFIG_ARM64 #define IN_SIZE 0x1000 #else - #define IN_SIZE 0x8000 + #define IN_SIZE 0x1000 #endif #define OUT_SIZE 0x1000 static DEFINE_MUTEX(sharemem_mutex); @@ -87,12 +87,22 @@ static int secmon_probe(struct platform_device *pdev) } pr_info("get page:%p, %lx\n", page, page_to_pfn(page)); - sharemem_in_base = ioremap_cache(phy_in_base, IN_SIZE); + if (pfn_valid(__phys_to_pfn(phy_in_base))) + sharemem_in_base = (void __iomem *)__phys_to_virt(phy_in_base); + else + sharemem_in_base = ioremap_cache(phy_in_base, IN_SIZE); + if (!sharemem_in_base) { pr_info("secmon share mem in buffer remap fail!\n"); return -ENOMEM; } - sharemem_out_base = ioremap_cache(phy_out_base, OUT_SIZE); + + if (pfn_valid(__phys_to_pfn(phy_out_base))) + sharemem_out_base = (void __iomem *) + __phys_to_virt(phy_out_base); + else + sharemem_out_base = ioremap_cache(phy_out_base, OUT_SIZE); + if (!sharemem_out_base) { pr_info("secmon share mem out buffer remap fail!\n"); return -ENOMEM; diff --git a/drivers/amlogic/unifykey/v8/securitykey.c b/drivers/amlogic/unifykey/v8/securitykey.c index d120b41ed987..5c1cb24d8767 100644 --- a/drivers/amlogic/unifykey/v8/securitykey.c +++ b/drivers/amlogic/unifykey/v8/securitykey.c @@ -370,12 +370,26 @@ static int storage_probe(struct platform_device *pdev) storage_out_base = NULL; storage_block_base = NULL; } else { - storage_in_base = ioremap_cache(phy_storage_in_base, - storage_block_size); - storage_out_base = ioremap_cache(phy_storage_out_base, - storage_block_size); - storage_block_base = ioremap_cache(phy_storage_block_base, - storage_block_size); + if (pfn_valid(__phys_to_pfn(phy_storage_in_base))) + storage_in_base = (void __iomem *) + __phys_to_virt(phy_storage_in_base); + else + storage_in_base = ioremap_cache( + phy_storage_in_base, storage_block_size); + + if (pfn_valid(__phys_to_pfn(phy_storage_out_base))) + storage_out_base = (void __iomem *) + __phys_to_virt(phy_storage_out_base); + else + storage_out_base = ioremap_cache( + phy_storage_out_base, storage_block_size); + + if (pfn_valid(__phys_to_pfn(phy_storage_block_base))) + storage_block_base = (void __iomem *) + __phys_to_virt(phy_storage_block_base); + else + storage_block_base = ioremap_cache( + phy_storage_block_base, storage_block_size); } pr_info("storage in base: 0x%lx\n", (long)storage_in_base);