Blame SOURCES/kvm-ppc405_boards-Don-t-size-flash-memory-to-match-backi.patch

383d26
From fc257e52fc251e4db6cd7ad604391941a2592556 Mon Sep 17 00:00:00 2001
383d26
From: Markus Armbruster <armbru@redhat.com>
383d26
Date: Fri, 17 May 2019 06:50:59 +0200
383d26
Subject: [PATCH 32/53] ppc405_boards: Don't size flash memory to match backing
383d26
 image
383d26
MIME-Version: 1.0
383d26
Content-Type: text/plain; charset=UTF-8
383d26
Content-Transfer-Encoding: 8bit
383d26
383d26
RH-Author: Markus Armbruster <armbru@redhat.com>
383d26
Message-id: <20190517065120.12028-11-armbru@redhat.com>
383d26
Patchwork-id: 88004
383d26
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v3 10/31] ppc405_boards: Don't size flash memory to match backing image
383d26
Bugzilla: 1624009
383d26
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
383d26
RH-Acked-by: Thomas Huth <thuth@redhat.com>
383d26
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
383d26
Machine "ref405ep" maps its flash memory at address 2^32 - image size.
383d26
Image size is rounded up to the next multiple of 64KiB.  Useless,
383d26
because pflash_cfi02_realize() fails with "failed to read the initial
383d26
flash content" unless the rounding is a no-op.
383d26
383d26
If the image size exceeds 0x80000 Bytes, we overlap first SRAM, then
383d26
other stuff.  No idea how that would play out, but useful outcomes
383d26
seem unlikely.
383d26
383d26
Map the flash memory at fixed address 0xFFF80000 with size 512KiB,
383d26
regardless of image size, to match the physical hardware.
383d26
383d26
Machine "taihu" maps its boot flash memory similarly.  The code even
383d26
has a comment /* XXX: should check that size is 2MB */, followed by
383d26
disabled code to adjust the size to 2MiB regardless of image size.
383d26
383d26
Its code to map its application flash memory looks the same, except
383d26
there the XXX comment asks for 32MiB, and the code to adjust the size
383d26
isn't disabled.  Note that pflash_cfi02_realize() fails with "failed
383d26
to read the initial flash content" for images smaller than 32MiB.
383d26
383d26
Map the boot flash memory at fixed address 0xFFE00000 with size 2MiB,
383d26
to match the physical hardware.  Delete dead code from application
383d26
flash mapping, and simplify some.
383d26
383d26
Cc: David Gibson <david@gibson.dropbear.id.au>
383d26
Signed-off-by: Markus Armbruster <armbru@redhat.com>
383d26
Acked-by: David Gibson <david@gibson.dropbear.id.au>
383d26
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
383d26
Message-Id: <20190308094610.21210-9-armbru@redhat.com>
383d26
(cherry picked from commit dd59bcae7687df4b2ba8e5292607724996e00892)
383d26
[Trivial conflict in hw/ppc/ppc405_boards.c due to lack of
383d26
commit ab3dd749241]
383d26
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 hw/ppc/ppc405_boards.c | 38 +++++++++++++-------------------------
383d26
 1 file changed, 13 insertions(+), 25 deletions(-)
383d26
383d26
diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
383d26
index 2c23e8b..bf32672 100644
383d26
--- a/hw/ppc/ppc405_boards.c
383d26
+++ b/hw/ppc/ppc405_boards.c
383d26
@@ -196,7 +196,7 @@ static void ref405ep_init(MachineState *machine)
383d26
     target_ulong kernel_base, initrd_base;
383d26
     long kernel_size, initrd_size;
383d26
     int linux_boot;
383d26
-    int fl_idx, fl_sectors, len;
383d26
+    int len;
383d26
     DriveInfo *dinfo;
383d26
     MemoryRegion *sysmem = get_system_memory();
383d26
 
383d26
@@ -224,20 +224,16 @@ static void ref405ep_init(MachineState *machine)
383d26
                            &error_fatal);
383d26
     memory_region_add_subregion(sysmem, 0xFFF00000, sram);
383d26
     /* allocate and load BIOS */
383d26
-    fl_idx = 0;
383d26
 #ifdef USE_FLASH_BIOS
383d26
-    dinfo = drive_get(IF_PFLASH, 0, fl_idx);
383d26
+    dinfo = drive_get(IF_PFLASH, 0, 0);
383d26
     if (dinfo) {
383d26
-        BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
383d26
-
383d26
-        bios_size = blk_getlength(blk);
383d26
-        fl_sectors = (bios_size + 65535) >> 16;
383d26
+        bios_size = 8 * MiB;
383d26
         pflash_cfi02_register((uint32_t)(-bios_size),
383d26
                               NULL, "ef405ep.bios", bios_size,
383d26
-                              blk, 65536, fl_sectors, 1,
383d26
+                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
383d26
+                              64 * KiB, bios_size / (64 * KiB), 1,
383d26
                               2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
383d26
                               1);
383d26
-        fl_idx++;
383d26
     } else
383d26
 #endif
383d26
     {
383d26
@@ -470,7 +466,7 @@ static void taihu_405ep_init(MachineState *machine)
383d26
     target_ulong kernel_base, initrd_base;
383d26
     long kernel_size, initrd_size;
383d26
     int linux_boot;
383d26
-    int fl_idx, fl_sectors;
383d26
+    int fl_idx;
383d26
     DriveInfo *dinfo;
383d26
 
383d26
 #ifdef TARGET_PPCEMB
383d26
@@ -502,15 +498,11 @@ static void taihu_405ep_init(MachineState *machine)
383d26
 #if defined(USE_FLASH_BIOS)
383d26
     dinfo = drive_get(IF_PFLASH, 0, fl_idx);
383d26
     if (dinfo) {
383d26
-        BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
383d26
-
383d26
-        bios_size = blk_getlength(blk);
383d26
-        /* XXX: should check that size is 2MB */
383d26
-        //        bios_size = 2 * 1024 * 1024;
383d26
-        fl_sectors = (bios_size + 65535) >> 16;
383d26
-        pflash_cfi02_register((uint32_t)(-bios_size),
383d26
+        bios_size = 2 * MiB;
383d26
+        pflash_cfi02_register(0xFFE00000,
383d26
                               NULL, "taihu_405ep.bios", bios_size,
383d26
-                              blk, 65536, fl_sectors, 1,
383d26
+                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
383d26
+                              64 * KiB, bios_size / (64 * KiB), 1,
383d26
                               4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
383d26
                               1);
383d26
         fl_idx++;
383d26
@@ -541,14 +533,10 @@ static void taihu_405ep_init(MachineState *machine)
383d26
     /* Register Linux flash */
383d26
     dinfo = drive_get(IF_PFLASH, 0, fl_idx);
383d26
     if (dinfo) {
383d26
-        BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
383d26
-
383d26
-        bios_size = blk_getlength(blk);
383d26
-        /* XXX: should check that size is 32MB */
383d26
-        bios_size = 32 * 1024 * 1024;
383d26
-        fl_sectors = (bios_size + 65535) >> 16;
383d26
+        bios_size = 32 * MiB;
383d26
         pflash_cfi02_register(0xfc000000, NULL, "taihu_405ep.flash", bios_size,
383d26
-                              blk, 65536, fl_sectors, 1,
383d26
+                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
383d26
+                              64 * KiB, bios_size / (64 * KiB), 1,
383d26
                               4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
383d26
                               1);
383d26
         fl_idx++;
383d26
-- 
383d26
1.8.3.1
383d26