Skip to contentSkip to conversation

pflash-next patches for v4.1.0-rc2

GIT PULL Philippe Mathieu-Daudé 1 participant 3 messages Jul 22, 2019

lore
Share & tools
lore
#0 lore raw

The following changes since commit 9d2e1fcd14c2bae5be1992214a03c0ddff714c80:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2019-07-22 13:20:49 +0100)

are available in the Git repository at:

https://gitlab.com/philmd/qemu.git tags/pflash-next-20190722

for you to fetch changes up to 5ef209c777a1a1eacea30e267640b029b6bd0bc0:

hw/block/pflash_cfi02: Rewrite a fall through comment (2019-07-22 19:02:09 +0200)

----------------------------------------------------------------
This pull request contains a bugfix and silent a fallthru warning.

----------------------------------------------------------------

Philippe Mathieu-Daudé (2):
hw/block/pflash_cfi01: Add missing DeviceReset() handler hw/block/pflash_cfi02: Rewrite a fall through comment

 hw/block/pflash_cfi01.c | 19 +++++++++++++++++++
 hw/block/pflash_cfi02.c |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)
Signature · 1 line
2.20.1
#1 lore raw

[Qemu-devel] [PULL 1/2] hw/block/pflash_cfi01: Add missing DeviceReset() handler

To avoid incoherent states when the machine resets (see bug report below), add the device reset callback.

A "system reset" sets the device state machine in READ_ARRAY mode and, after some delay, set the SR.7 READY bit.

Since we do not model timings, we set the SR.7 bit directly.

Message-Id: <[email protected]>

---
 hw/block/pflash_cfi01.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
hw/block/pflash_cfi01.c +19 -0
index 435be1e35c..a1ec1faae5 100644
@@ -865,6 +865,24 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
     pfl->cfi_table[0x3f] = 0x01; /* Number of protection fields */
 }
 
+static void pflash_cfi01_system_reset(DeviceState *dev)
+{
+    PFlashCFI01 *pfl = PFLASH_CFI01(dev);
+
+    /*
+     * The command 0x00 is not assigned by the CFI open standard,
+     * but QEMU historically uses it for the READ_ARRAY command (0xff).
+     */
+    pfl->cmd = 0x00;
+    pfl->wcycle = 0;
+    memory_region_rom_device_set_romd(&pfl->mem, true);
+    /*
+     * The WSM ready timer occurs at most 150ns after system reset.
+     * This model deliberately ignores this delay.
+     */
+    pfl->status = 0x80;
+}
+
 static Property pflash_cfi01_properties[] = {
     DEFINE_PROP_DRIVE("drive", PFlashCFI01, blk),
     /* num-blocks is the number of blocks actually visible to the guest,
@@ -909,6 +927,7 @@ static void pflash_cfi01_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
+    dc->reset = pflash_cfi01_system_reset;
     dc->realize = pflash_cfi01_realize;
     dc->props = pflash_cfi01_properties;
     dc->vmsd = &vmstate_pflash;
Signature · 1 line
2.20.1
#2 lore raw

[Qemu-devel] [PULL 2/2] hw/block/pflash_cfi02: Rewrite a fall through comment

In reply to Philippe Mathieu-Daudé

GCC9 is confused by this comment when building with CFLAG -Wimplicit-fallthrough=2:

hw/block/pflash_cfi02.c: In function ‘pflash_write’:
hw/block/pflash_cfi02.c:574:16: error: this statement may fall through [-Werror=implicit-fallthrough=]

    574 |             if (boff == 0x55 && cmd == 0x98) {
        |                ^
  hw/block/pflash_cfi02.c:581:9: note: here
    581 |         default:
        |         ^~~~~~~

cc1: all warnings being treated as errors

Rewrite the comment using 'fall through' which is recognized by GCC and static analyzers.

Message-Id: <[email protected]>

---
 hw/block/pflash_cfi02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/pflash_cfi02.c +1 -1
index f68837a449..42886f6af5 100644
@@ -577,7 +577,7 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value,
                 pfl->cmd = 0x98;
                 return;
             }
-            /* No break here */
+            /* fall through */
         default:
             DPRINTF("%s: invalid write for command %02x\n",
                     __func__, pfl->cmd);
Signature · 1 line
2.20.1