thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-hw-block-pflash_cfi01-Add-missing-DeviceReset-handle.patch

Pablo Greco e6a3ae
From 707a777c2992e840d2c3dd4e1fbed5b0d6c682ec Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
Pablo Greco e6a3ae
Date: Tue, 23 Jul 2019 11:51:05 +0100
Pablo Greco e6a3ae
Subject: [PATCH 01/14] hw/block/pflash_cfi01: Add missing DeviceReset()
Pablo Greco e6a3ae
 handler
Pablo Greco e6a3ae
MIME-Version: 1.0
Pablo Greco e6a3ae
Content-Type: text/plain; charset=UTF-8
Pablo Greco e6a3ae
Content-Transfer-Encoding: 8bit
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Philippe Mathieu-Daudé <philmd@redhat.com>
Pablo Greco e6a3ae
Message-id: <20190723115105.31305-2-philmd@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 89645
Pablo Greco e6a3ae
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 1/1] hw/block/pflash_cfi01: Add missing DeviceReset() handler
Pablo Greco e6a3ae
Bugzilla: 1707192
Pablo Greco e6a3ae
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: John Snow <jsnow@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
To avoid incoherent states when the machine resets (see bug report
Pablo Greco e6a3ae
below), add the device reset callback.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
A "system reset" sets the device state machine in READ_ARRAY mode
Pablo Greco e6a3ae
and, after some delay, set the SR.7 READY bit.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Since we do not model timings, we set the SR.7 bit directly.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1678713
Pablo Greco e6a3ae
Reported-by: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: John Snow <jsnow@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Pablo Greco e6a3ae
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
Tested-by: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
[Laszlo Ersek: Regression tested EDK2 OVMF IA32X64, ArmVirtQemu Aarch64
Pablo Greco e6a3ae
 https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04373.html]
Pablo Greco e6a3ae
Message-Id: <20190718104837.13905-2-philmd@redhat.com>
Pablo Greco e6a3ae
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 3a283507c03474d285196620fca506bd1a89b198)
Pablo Greco e6a3ae
[PMD: upstream commit e7b6274197c changed PFLASH_CFI01 <- CFI_PFLASH01,
Pablo Greco e6a3ae
  and upstream commit 1643406520f changed PFlashCFI01 <- pflash_t]
Pablo Greco e6a3ae
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 hw/block/pflash_cfi01.c | 19 +++++++++++++++++++
Pablo Greco e6a3ae
 1 file changed, 19 insertions(+)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
Pablo Greco e6a3ae
index 2e82840..1be351e 100644
Pablo Greco e6a3ae
--- a/hw/block/pflash_cfi01.c
Pablo Greco e6a3ae
+++ b/hw/block/pflash_cfi01.c
Pablo Greco e6a3ae
@@ -876,6 +876,24 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
Pablo Greco e6a3ae
     pfl->cfi_table[0x3f] = 0x01; /* Number of protection fields */
Pablo Greco e6a3ae
 }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
+static void pflash_cfi01_system_reset(DeviceState *dev)
Pablo Greco e6a3ae
+{
Pablo Greco e6a3ae
+    pflash_t *pfl = CFI_PFLASH01(dev);
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+    /*
Pablo Greco e6a3ae
+     * The command 0x00 is not assigned by the CFI open standard,
Pablo Greco e6a3ae
+     * but QEMU historically uses it for the READ_ARRAY command (0xff).
Pablo Greco e6a3ae
+     */
Pablo Greco e6a3ae
+    pfl->cmd = 0x00;
Pablo Greco e6a3ae
+    pfl->wcycle = 0;
Pablo Greco e6a3ae
+    memory_region_rom_device_set_romd(&pfl->mem, true);
Pablo Greco e6a3ae
+    /*
Pablo Greco e6a3ae
+     * The WSM ready timer occurs at most 150ns after system reset.
Pablo Greco e6a3ae
+     * This model deliberately ignores this delay.
Pablo Greco e6a3ae
+     */
Pablo Greco e6a3ae
+    pfl->status = 0x80;
Pablo Greco e6a3ae
+}
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
 static Property pflash_cfi01_properties[] = {
Pablo Greco e6a3ae
     DEFINE_PROP_DRIVE("drive", struct pflash_t, blk),
Pablo Greco e6a3ae
     /* num-blocks is the number of blocks actually visible to the guest,
Pablo Greco e6a3ae
@@ -920,6 +938,7 @@ static void pflash_cfi01_class_init(ObjectClass *klass, void *data)
Pablo Greco e6a3ae
 {
Pablo Greco e6a3ae
     DeviceClass *dc = DEVICE_CLASS(klass);
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
+    dc->reset = pflash_cfi01_system_reset;
Pablo Greco e6a3ae
     dc->realize = pflash_cfi01_realize;
Pablo Greco e6a3ae
     dc->props = pflash_cfi01_properties;
Pablo Greco e6a3ae
     dc->vmsd = &vmstate_pflash;
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae