From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Laszlo Ersek" <lersek@redhat.com>,
qemu-block@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Max Reitz" <mreitz@redhat.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"John Snow" <jsnow@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: [Qemu-devel] [PATCH-for-4.1 v6 5/5] hw/block/pflash_cfi01: Add the DeviceReset() handler
Date: Wed, 17 Jul 2019 00:15:55 +0200 [thread overview]
Message-ID: <20190716221555.11145-6-philmd@redhat.com> (raw)
In-Reply-To: <20190716221555.11145-1-philmd@redhat.com>
A "system reset" sets the device state machine in READ_ARRAY mode
and, after some delay, set the SR.7 READY bit.
We do not model timings, so we set the SR.7 bit directly.
The TYPE_DEVICE interface provides a DeviceReset handler.
This pflash device is a subclass of TYPE_SYS_BUS_DEVICE (which
is a subclass of TYPE_DEVICE).
SYS_BUS devices are automatically plugged into the 'main system
bus', which is the root of the qbus tree.
Devices in the qbus tree are guaranteed to have their reset()
handler called after realize() and before we try to run the guest.
To avoid incoherent states when the machine resets (see but report
below), factor out the reset code into pflash_cfi01_system_reset,
and register the method as a device reset callback.
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1678713
Reported-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v6: dropped Laszlo's Regression-tested-by tag
---
hw/block/pflash_cfi01.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 65afdbf3a7..ee0ed70242 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -768,8 +768,6 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
pfl->max_device_width = pfl->device_width;
}
- pflash_mode_read_array(pfl);
- pfl->status = 0x80; /* WSM ready */
/* Hardcoded CFI table */
/* Standard "QRY" string */
pfl->cfi_table[0x10] = 'Q';
@@ -857,6 +855,18 @@ 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);
+
+ pflash_mode_read_array(pfl);
+ /*
+ * 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,
@@ -901,6 +911,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;
--
2.20.1
next prev parent reply other threads:[~2019-07-16 22:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-16 22:15 [Qemu-devel] [PATCH-for-4.1 v6 0/5] hw/block/pflash_cfi01: Add DeviceReset() handler Philippe Mathieu-Daudé
2019-07-16 22:15 ` [Qemu-devel] [PATCH-for-4.1 v6 1/5] hw/block/pflash_cfi01: Removed an unused timer Philippe Mathieu-Daudé
2019-07-16 22:15 ` [Qemu-devel] [PATCH-for-4.1 v6 2/5] hw/block/pflash_cfi01: Document use of non-CFI compliant command '0x00' Philippe Mathieu-Daudé
2019-07-16 22:24 ` Alistair Francis
2019-07-16 22:15 ` [Qemu-devel] [PATCH-for-4.1 v6 3/5] hw/block/pflash_cfi01: Extract pflash_mode_read_array() Philippe Mathieu-Daudé
2019-07-16 22:53 ` Alistair Francis
2019-07-16 22:15 ` [Qemu-devel] [PATCH-for-4.1 v6 4/5] hw/block/pflash_cfi01: Rename 'reset_flash' label as 'mode_read_array' Philippe Mathieu-Daudé
2019-07-16 22:15 ` Philippe Mathieu-Daudé [this message]
2019-07-17 6:43 ` [Qemu-devel] [PATCH-for-4.1 v6 5/5] hw/block/pflash_cfi01: Add the DeviceReset() handler Philippe Mathieu-Daudé
2019-07-17 12:24 ` [Qemu-devel] [PATCH-for-4.1 v6 0/5] hw/block/pflash_cfi01: Add " Laszlo Ersek
2019-07-17 14:00 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190716221555.11145-6-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=alistair.francis@wdc.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=lersek@redhat.com \
--cc=mreitz@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).