Merge tag 'defconfig-5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / drivers / firmware / iscsi_ibft_find.c
index 85c656d..94b49cc 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  *  Copyright 2007-2010 Red Hat, Inc.
  *  by Peter Jones <pjones@redhat.com>
@@ -7,15 +8,6 @@
  *  by Konrad Rzeszutek <ketuzsezr@darnok.org>
  *
  * This code finds the iSCSI Boot Format Table.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License v2.0 as published by
- * the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #include <linux/memblock.h>
@@ -39,8 +31,8 @@
 /*
  * Physical location of iSCSI Boot Format Table.
  */
-struct acpi_table_ibft *ibft_addr;
-EXPORT_SYMBOL_GPL(ibft_addr);
+phys_addr_t ibft_phys_addr;
+EXPORT_SYMBOL_GPL(ibft_phys_addr);
 
 static const struct {
        char *sign;
@@ -55,13 +47,24 @@ static const struct {
 #define VGA_MEM 0xA0000 /* VGA buffer */
 #define VGA_SIZE 0x20000 /* 128kB */
 
-static int __init find_ibft_in_mem(void)
+/*
+ * Routine used to find and reserve the iSCSI Boot Format Table
+ */
+void __init reserve_ibft_region(void)
 {
        unsigned long pos;
        unsigned int len = 0;
        void *virt;
        int i;
 
+       ibft_phys_addr = 0;
+
+       /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
+        * only use ACPI for this
+        */
+       if (efi_enabled(EFI_BOOT))
+               return;
+
        for (pos = IBFT_START; pos < IBFT_END; pos += 16) {
                /* The table can't be inside the VGA BIOS reserved space,
                 * so skip that area */
@@ -78,35 +81,12 @@ static int __init find_ibft_in_mem(void)
                                /* if the length of the table extends past 1M,
                                 * the table cannot be valid. */
                                if (pos + len <= (IBFT_END-1)) {
-                                       ibft_addr = (struct acpi_table_ibft *)virt;
-                                       pr_info("iBFT found at 0x%lx.\n", pos);
-                                       goto done;
+                                       ibft_phys_addr = pos;
+                                       memblock_reserve(ibft_phys_addr, PAGE_ALIGN(len));
+                                       pr_info("iBFT found at %pa.\n", &ibft_phys_addr);
+                                       return;
                                }
                        }
                }
        }
-done:
-       return len;
-}
-/*
- * Routine used to find the iSCSI Boot Format Table. The logical
- * kernel address is set in the ibft_addr global variable.
- */
-unsigned long __init find_ibft_region(unsigned long *sizep)
-{
-       ibft_addr = NULL;
-
-       /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
-        * only use ACPI for this */
-
-       if (!efi_enabled(EFI_BOOT))
-               find_ibft_in_mem();
-
-       if (ibft_addr) {
-               *sizep = PAGE_ALIGN(ibft_addr->header.length);
-               return (u64)virt_to_phys(ibft_addr);
-       }
-
-       *sizep = 0;
-       return 0;
 }