yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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