Blame SOURCES/kvm-sam460ex-Don-t-size-flash-memory-to-match-backing-im.patch

7711c0
From 862385809b305a6b02bc9cf39c8fb055bf764838 Mon Sep 17 00:00:00 2001
7711c0
From: Markus Armbruster <armbru@redhat.com>
7711c0
Date: Fri, 17 May 2019 06:50:57 +0200
7711c0
Subject: [PATCH 30/53] sam460ex: Don't size flash memory to match backing
7711c0
 image
7711c0
MIME-Version: 1.0
7711c0
Content-Type: text/plain; charset=UTF-8
7711c0
Content-Transfer-Encoding: 8bit
7711c0
7711c0
RH-Author: Markus Armbruster <armbru@redhat.com>
7711c0
Message-id: <20190517065120.12028-9-armbru@redhat.com>
7711c0
Patchwork-id: 87998
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v3 08/31] sam460ex: Don't size flash memory to match backing image
7711c0
Bugzilla: 1624009
7711c0
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7711c0
RH-Acked-by: Thomas Huth <thuth@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
Machine "sam460ex" maps its flash memory at address 0xFFF00000.  When
7711c0
no image is supplied, its size is 1MiB (0x100000), and 512KiB of ROM
7711c0
get mapped on top of its second half.  Else, it's the size of the
7711c0
image rounded up to the next multiple of 64KiB.
7711c0
7711c0
The rounding is actually useless: pflash_cfi01_realize() fails with
7711c0
"failed to read the initial flash content" unless it's a no-op.
7711c0
7711c0
I have no idea what happens when the pflash's size exceeds 1MiB.
7711c0
Useful outcomes seem unlikely.
7711c0
7711c0
I guess memory at the end of the address space remains unmapped when
7711c0
it's smaller than 1MiB.  Again, useful outcomes seem unlikely.
7711c0
7711c0
The physical hardware appears to have 512KiB of flash memory:
7711c0
https://eu.mouser.com/datasheet/2/268/atmel_AT49BV040B-1180330.pdf
7711c0
7711c0
For now, just set the flash memory size to 1MiB regardless of image
7711c0
size, and document the mess.
7711c0
7711c0
Cc: BALATON Zoltan <balaton@eik.bme.hu>
7711c0
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7711c0
Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
7711c0
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7711c0
Message-Id: <20190308094610.21210-7-armbru@redhat.com>
7711c0
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7711c0
(cherry picked from commit f30bc99559306eee9ef363bc11bf63a021aee707)
7711c0
[Trivial conflict in hw/ppc/sam460ex.c due to lack of commit ab3dd749241]
7711c0
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 hw/ppc/sam460ex.c | 41 ++++++++++++++++++++++++++---------------
7711c0
 1 file changed, 26 insertions(+), 15 deletions(-)
7711c0
7711c0
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
7711c0
index dfff262..83c6e90 100644
7711c0
--- a/hw/ppc/sam460ex.c
7711c0
+++ b/hw/ppc/sam460ex.c
7711c0
@@ -212,32 +212,43 @@ static void generate_eeprom_serial(uint8_t *eeprom)
7711c0
 
7711c0
 static int sam460ex_load_uboot(void)
7711c0
 {
7711c0
+    /*
7711c0
+     * This first creates 1MiB of flash memory mapped at the end of
7711c0
+     * the 32-bit address space (0xFFF00000..0xFFFFFFFF).
7711c0
+     *
7711c0
+     * If_PFLASH unit 0 is defined, the flash memory is initialized
7711c0
+     * from that block backend.
7711c0
+     *
7711c0
+     * Else, it's initialized to zero.  And then 512KiB of ROM get
7711c0
+     * mapped on top of its second half (0xFFF80000..0xFFFFFFFF),
7711c0
+     * initialized from u-boot-sam460-20100605.bin.
7711c0
+     *
7711c0
+     * This doesn't smell right.
7711c0
+     *
7711c0
+     * The physical hardware appears to have 512KiB flash memory.
7711c0
+     *
7711c0
+     * TODO Figure out what we really need here, and clean this up.
7711c0
+     */
7711c0
+
7711c0
     DriveInfo *dinfo;
7711c0
-    BlockBackend *blk = NULL;
7711c0
-    hwaddr base = FLASH_BASE | ((hwaddr)FLASH_BASE_H << 32);
7711c0
-    long bios_size = FLASH_SIZE;
7711c0
-    int fl_sectors;
7711c0
 
7711c0
     dinfo = drive_get(IF_PFLASH, 0, 0);
7711c0
-    if (dinfo) {
7711c0
-        blk = blk_by_legacy_dinfo(dinfo);
7711c0
-        bios_size = blk_getlength(blk);
7711c0
-    }
7711c0
-    fl_sectors = (bios_size + 65535) >> 16;
7711c0
-
7711c0
-    if (!pflash_cfi01_register(base, NULL, "sam460ex.flash", bios_size,
7711c0
-                               blk, (64 * 1024), fl_sectors,
7711c0
+    if (!pflash_cfi01_register(FLASH_BASE | ((hwaddr)FLASH_BASE_H << 32),
7711c0
+                               NULL, "sam460ex.flash", FLASH_SIZE,
7711c0
+                               dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
+                               64 * KiB, FLASH_SIZE / (64 * KiB),
7711c0
                                1, 0x89, 0x18, 0x0000, 0x0, 1)) {
7711c0
         error_report("qemu: Error registering flash memory.");
7711c0
         /* XXX: return an error instead? */
7711c0
         exit(1);
7711c0
     }
7711c0
 
7711c0
-    if (!blk) {
7711c0
+    if (!dinfo) {
7711c0
         /*error_report("No flash image given with the 'pflash' parameter,"
7711c0
                 " using default u-boot image");*/
7711c0
-        base = UBOOT_LOAD_BASE | ((hwaddr)FLASH_BASE_H << 32);
7711c0
-        rom_add_file_fixed(UBOOT_FILENAME, base, -1);
7711c0
+        rom_add_file_fixed(UBOOT_FILENAME,
7711c0
+                           UBOOT_LOAD_BASE | ((hwaddr)FLASH_BASE_H << 32),
7711c0
+                           -1);
7711c0
     }
7711c0
 
7711c0
     return 0;
7711c0
-- 
7711c0
1.8.3.1
7711c0