In preparation for adding another EFI_MEMMAP dependent call that needs to occur before e820__memblock_setup() fixup the existing efi calls to check for EFI_MEMMAP internally. This ends up being cleaner than the alternative of checking EFI_MEMMAP multiple times in setup_arch().
Unified · Split
| @@ -140,7 +140,6 @@ extern void efi_delete_dummy_variable(void); · 139 unmodified lines | |||
| 140 | extern void efi_switch_mm(struct mm_struct *mm); | 140 | extern void efi_switch_mm(struct mm_struct *mm); |
| 141 | extern void efi_recover_from_page_fault(unsigned long phys_addr); | 141 | extern void efi_recover_from_page_fault(unsigned long phys_addr); |
| 142 | extern void efi_free_boot_services(void); | 142 | extern void efi_free_boot_services(void); |
| 143 | extern void efi_reserve_boot_services(void); | ||
| 144 | 143 | ||
| 145 | struct efi_setup_data { | 144 | struct efi_setup_data { |
| 146 | u64 fw_vendor; | 145 | u64 fw_vendor; |
| @@ -244,6 +243,8 @@ static inline bool efi_is_64bit(void) · 97 unmodified lines | |||
| 244 | extern bool efi_reboot_required(void); | 243 | extern bool efi_reboot_required(void); |
| 245 | extern bool efi_is_table_address(unsigned long phys_addr); | 244 | extern bool efi_is_table_address(unsigned long phys_addr); |
| 246 | 245 | ||
| 246 | extern void efi_find_mirror(void); | ||
| 247 | extern void efi_reserve_boot_services(void); | ||
| 247 | #else | 248 | #else |
| 248 | static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {} | 249 | static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {} |
| 249 | static inline bool efi_reboot_required(void) | 250 | static inline bool efi_reboot_required(void) |
| @@ -254,6 +255,12 @@ static inline bool efi_is_table_address(unsigned long phys_addr) · 4 unmodified lines | |||
| 254 | { | 255 | { |
| 255 | return false; | 256 | return false; |
| 256 | } | 257 | } |
| 258 | static inline void efi_find_mirror(void) | ||
| 259 | { | ||
| 260 | } | ||
| 261 | static inline void efi_reserve_boot_services(void) | ||
| 262 | { | ||
| 263 | } | ||
| 257 | #endif /* CONFIG_EFI */ | 264 | #endif /* CONFIG_EFI */ |
| 258 | 265 | ||
| 259 | #endif /* _ASM_X86_EFI_H */ | 266 | #endif /* _ASM_X86_EFI_H */ |
| @@ -1122,17 +1122,15 @@ void __init setup_arch(char **cmdline_p) · 1121 unmodified lines | |||
| 1122 | 1122 | ||
| 1123 | reserve_bios_regions(); | 1123 | reserve_bios_regions(); |
| 1124 | 1124 | ||
| 1125 | if (efi_enabled(EFI_MEMMAP)) { | 1125 | efi_fake_memmap(); |
| 1126 | efi_fake_memmap(); | 1126 | efi_find_mirror(); |
| 1127 | efi_find_mirror(); | 1127 | efi_esrt_init(); |
| 1128 | efi_esrt_init(); | ||
| 1129 | 1128 | ||
| 1130 | /* | 1129 | /* |
| 1131 | * The EFI specification says that boot service code won't be | 1130 | * The EFI specification says that boot service code won't be |
| 1132 | * called after ExitBootServices(). This is, in fact, a lie. | 1131 | * called after ExitBootServices(). This is, in fact, a lie. |
| 1133 | */ | 1132 | */ |
| 1134 | efi_reserve_boot_services(); | 1133 | efi_reserve_boot_services(); |
| 1135 | } | ||
| 1136 | 1134 | ||
| 1137 | /* preallocate 4k for mptable mpc */ | 1135 | /* preallocate 4k for mptable mpc */ |
| 1138 | e820__memblock_alloc_reserved_mpc_new(); | 1136 | e820__memblock_alloc_reserved_mpc_new(); |
| @@ -128,6 +128,9 @@ void __init efi_find_mirror(void) · 127 unmodified lines | |||
| 128 | efi_memory_desc_t *md; | 128 | efi_memory_desc_t *md; |
| 129 | u64 mirror_size = 0, total_size = 0; | 129 | u64 mirror_size = 0, total_size = 0; |
| 130 | 130 | ||
| 131 | if (!efi_enabled(EFI_MEMMAP)) | ||
| 132 | return; | ||
| 133 | |||
| 131 | for_each_efi_memory_desc(md) { | 134 | for_each_efi_memory_desc(md) { |
| 132 | unsigned long long start = md->phys_addr; | 135 | unsigned long long start = md->phys_addr; |
| 133 | unsigned long long size = md->num_pages << EFI_PAGE_SHIFT; | 136 | unsigned long long size = md->num_pages << EFI_PAGE_SHIFT; |
| @@ -320,6 +320,9 @@ void __init efi_reserve_boot_services(void) · 319 unmodified lines | |||
| 320 | { | 320 | { |
| 321 | efi_memory_desc_t *md; | 321 | efi_memory_desc_t *md; |
| 322 | 322 | ||
| 323 | if (!efi_enabled(EFI_MEMMAP)) | ||
| 324 | return; | ||
| 325 | |||
| 323 | for_each_efi_memory_desc(md) { | 326 | for_each_efi_memory_desc(md) { |
| 324 | u64 start = md->phys_addr; | 327 | u64 start = md->phys_addr; |
| 325 | u64 size = md->num_pages << EFI_PAGE_SHIFT; | 328 | u64 size = md->num_pages << EFI_PAGE_SHIFT; |
| @@ -246,6 +246,9 @@ void __init efi_esrt_init(void) · 245 unmodified lines | |||
| 246 | int rc; | 246 | int rc; |
| 247 | phys_addr_t end; | 247 | phys_addr_t end; |
| 248 | 248 | ||
| 249 | if (!efi_enabled(EFI_MEMMAP)) | ||
| 250 | return; | ||
| 251 | |||
| 249 | pr_debug("esrt-init: loading.\n"); | 252 | pr_debug("esrt-init: loading.\n"); |
| 250 | if (!esrt_table_exists()) | 253 | if (!esrt_table_exists()) |
| 251 | return; | 254 | return; |
| @@ -44,7 +44,7 @@ void __init efi_fake_memmap(void) · 43 unmodified lines | |||
| 44 | void *new_memmap; | 44 | void *new_memmap; |
| 45 | int i; | 45 | int i; |
| 46 | 46 | ||
| 47 | if (!nr_fake_mem) | 47 | if (!efi_enabled(EFI_MEMMAP) || !nr_fake_mem) |
| 48 | return; | 48 | return; |
| 49 | 49 | ||
| 50 | /* count up the number of EFI memory descriptor */ | 50 | /* count up the number of EFI memory descriptor */ |
| @@ -1045,7 +1045,6 @@ extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if pos · 1044 unmodified lines | |||
| 1045 | extern efi_status_t efi_query_variable_store(u32 attributes, | 1045 | extern efi_status_t efi_query_variable_store(u32 attributes, |
| 1046 | unsigned long size, | 1046 | unsigned long size, |
| 1047 | bool nonblocking); | 1047 | bool nonblocking); |
| 1048 | extern void efi_find_mirror(void); | ||
| 1049 | #else | 1048 | #else |
| 1050 | 1049 | ||
| 1051 | static inline efi_status_t efi_query_variable_store(u32 attributes, | 1050 | static inline efi_status_t efi_query_variable_store(u32 attributes, |