board: fix ioremap call fail issue
authorAo Xu <ao.xu@amlogic.com>
Thu, 2 Aug 2018 07:42:02 +0000 (15:42 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Wed, 8 Aug 2018 10:36:28 +0000 (03:36 -0700)
PD#169652: board: fix ioremap call fail issue

for arm 32, ioremap will check if page is mapped

Change-Id: Icb5dda1b9de06d32e47c82a6bc45b62873332487
Signed-off-by: Ao Xu <ao.xu@amlogic.com>
drivers/amlogic/secmon/secmon.c
drivers/amlogic/unifykey/v8/securitykey.c

index c24a866d38c9d4d79b641d37e76826d97bceb40f..1eb31cb3da1962b168b140c2216e3b35082922e3 100644 (file)
@@ -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;
index d120b41ed987d45b0a49a9a4400de5033a2db83d..5c1cb24d876710e910fc5293f9d80fbf783ec854 100644 (file)
@@ -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);