Merge tag 'renesas-boards-cleanups2-for-v3.19' of git://git.kernel.org/pub/scm/linux...
[firefly-linux-kernel-4.4.55.git] / arch / x86 / platform / efi / efi.c
index a1f745b0bf1df0b9a5f227caa8dc993d9f4dab08..dbc8627a5cdf6d569a5f69cbea05ebac924d2279 100644 (file)
@@ -70,17 +70,7 @@ static efi_config_table_type_t arch_tables[] __initdata = {
 
 u64 efi_setup;         /* efi setup_data physical address */
 
-static bool disable_runtime __initdata = false;
-static int __init setup_noefi(char *arg)
-{
-       disable_runtime = true;
-       return 0;
-}
-early_param("noefi", setup_noefi);
-
-int add_efi_memmap;
-EXPORT_SYMBOL(add_efi_memmap);
-
+static int add_efi_memmap __initdata;
 static int __init setup_add_efi_memmap(char *arg)
 {
        add_efi_memmap = 1;
@@ -96,7 +86,7 @@ static efi_status_t __init phys_efi_set_virtual_address_map(
 {
        efi_status_t status;
 
-       efi_call_phys_prelog();
+       efi_call_phys_prolog();
        status = efi_call_phys(efi_phys.set_virtual_address_map,
                               memory_map_size, descriptor_size,
                               descriptor_version, virtual_map);
@@ -210,9 +200,12 @@ static void __init print_efi_memmap(void)
        for (p = memmap.map, i = 0;
             p < memmap.map_end;
             p += memmap.desc_size, i++) {
+               char buf[64];
+
                md = p;
-               pr_info("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluMB)\n",
-                       i, md->type, md->attribute, md->phys_addr,
+               pr_info("mem%02u: %s range=[0x%016llx-0x%016llx) (%lluMB)\n",
+                       i, efi_md_typeattr_format(buf, sizeof(buf), md),
+                       md->phys_addr,
                        md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT),
                        (md->num_pages >> (20 - EFI_PAGE_SHIFT)));
        }
@@ -344,9 +337,9 @@ static int __init efi_runtime_init32(void)
        }
 
        /*
-        * We will only need *early* access to the following two
-        * EFI runtime services before set_virtual_address_map
-        * is invoked.
+        * We will only need *early* access to the SetVirtualAddressMap
+        * EFI runtime service. All other runtime services will be called
+        * via the virtual mapping.
         */
        efi_phys.set_virtual_address_map =
                        (efi_set_virtual_address_map_t *)
@@ -368,9 +361,9 @@ static int __init efi_runtime_init64(void)
        }
 
        /*
-        * We will only need *early* access to the following two
-        * EFI runtime services before set_virtual_address_map
-        * is invoked.
+        * We will only need *early* access to the SetVirtualAddressMap
+        * EFI runtime service. All other runtime services will be called
+        * via the virtual mapping.
         */
        efi_phys.set_virtual_address_map =
                        (efi_set_virtual_address_map_t *)
@@ -492,7 +485,7 @@ void __init efi_init(void)
        if (!efi_runtime_supported())
                pr_info("No EFI runtime due to 32/64-bit mismatch with kernel\n");
        else {
-               if (disable_runtime || efi_runtime_init())
+               if (efi_runtime_disabled() || efi_runtime_init())
                        return;
        }
        if (efi_memmap_init())
@@ -537,7 +530,7 @@ void __init runtime_code_page_mkexec(void)
        }
 }
 
-void efi_memory_uc(u64 addr, unsigned long size)
+void __init efi_memory_uc(u64 addr, unsigned long size)
 {
        unsigned long page_shift = 1UL << EFI_PAGE_SHIFT;
        u64 npages;
@@ -732,6 +725,7 @@ static void __init kexec_enter_virtual_mode(void)
         */
        if (!efi_is_native()) {
                efi_unmap_memmap();
+               clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
                return;
        }
 
@@ -805,6 +799,7 @@ static void __init __efi_enter_virtual_mode(void)
        new_memmap = efi_map_regions(&count, &pg_shift);
        if (!new_memmap) {
                pr_err("Error reallocating memory, EFI runtime non-functional!\n");
+               clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
                return;
        }
 
@@ -812,8 +807,10 @@ static void __init __efi_enter_virtual_mode(void)
 
        BUG_ON(!efi.systab);
 
-       if (efi_setup_page_tables(__pa(new_memmap), 1 << pg_shift))
+       if (efi_setup_page_tables(__pa(new_memmap), 1 << pg_shift)) {
+               clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
                return;
+       }
 
        efi_sync_low_kernel_mappings();
        efi_dump_pagetable();
@@ -938,29 +935,11 @@ u64 efi_mem_attributes(unsigned long phys_addr)
        return 0;
 }
 
-static int __init parse_efi_cmdline(char *str)
+static int __init arch_parse_efi_cmdline(char *str)
 {
-       if (*str == '=')
-               str++;
-
-       while (*str) {
-               if (!strncmp(str, "old_map", 7)) {
-                       set_bit(EFI_OLD_MEMMAP, &efi.flags);
-                       str += strlen("old_map");
-               }
-
-               /*
-                * Skip any options we don't understand. Presumably
-                * they apply to the EFI boot stub.
-                */
-               while (*str && *str != ',')
-                       str++;
-
-               /* If we hit a delimiter, skip it */
-               if (*str == ',')
-                       str++;
-       }
+       if (parse_option_str(str, "old_map"))
+               set_bit(EFI_OLD_MEMMAP, &efi.flags);
 
        return 0;
 }
-early_param("efi", parse_efi_cmdline);
+early_param("efi", arch_parse_efi_cmdline);