From: Markus Armbruster <armbru@redhat.com>
To: Johny Mattsson <jmattsson@dius.com.au>
Cc: qemu-trivial@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] Fix pflash_cfi01 to restore flash command/array state after migration
Date: Thu, 21 Aug 2014 11:48:08 +0200 [thread overview]
Message-ID: <87egwab2cn.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <CACTyEaOFhLnoA5TDHGkDpxpP+TxVKyuTT9AL+q8Y1kaa+wxE5A@mail.gmail.com> (Johny Mattsson's message of "Thu, 21 Aug 2014 17:35:25 +1000")
I'm afraid this is *not* trivial. Migration stuff rarely is :)
Johny Mattsson <jmattsson@dius.com.au> writes:
> When using snapshots on e.g. the VersatilePB board, the pflash driver
> would report an error and get reset at times after resuming the snapshot.
> This was traced down to the 'romd' flag in the pflash emulation which was
> not being persisted in the snapshot.
>
> Author: Bernd Meyer <bmeyer@dius.com.au>
> Signed-off-by: Johny Mattsson <jmattsson@dius.com.au>
>
> ---
> hw/block/pflash_cfi01.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
> index f9507b4..83cb1d3 100644
> --- a/hw/block/pflash_cfi01.c
> +++ b/hw/block/pflash_cfi01.c
> @@ -80,6 +80,7 @@ struct pflash_t {
> int ro;
> uint8_t cmd;
> uint8_t status;
> + uint8_t romd;
> uint16_t ident0;
> uint16_t ident1;
> uint16_t ident2;
> @@ -94,14 +95,25 @@ struct pflash_t {
> void *storage;
> };
>
> +static int sync_romd(void* opaque, int version_id)
> +{
> + (void)version_id;
> + pflash_t *pfl = opaque;
> +
> + memory_region_rom_device_set_romd(&pfl->mem,!!pfl->romd);
> + return 0;
> +}
> +
> static const VMStateDescription vmstate_pflash = {
> .name = "pflash_cfi01",
> .version_id = 1,
> .minimum_version_id = 1,
> + .post_load = sync_romd,
> .fields = (VMStateField[]) {
> VMSTATE_UINT8(wcycle, pflash_t),
> VMSTATE_UINT8(cmd, pflash_t),
> VMSTATE_UINT8(status, pflash_t),
> + VMSTATE_UINT8(romd, pflash_t),
> VMSTATE_UINT64(counter, pflash_t),
> VMSTATE_END_OF_LIST()
> }
Doesn't this break migration to/from unfixed versions?
> @@ -114,6 +126,7 @@ static void pflash_timer (void *opaque)
> DPRINTF("%s: command %02x done\n", __func__, pfl->cmd);
> /* Reset flash */
> pfl->status ^= 0x80;
> + pfl->romd=1;
> memory_region_rom_device_set_romd(&pfl->mem, true);
> pfl->wcycle = 0;
> pfl->cmd = 0;
> @@ -453,6 +466,7 @@ static void pflash_write(pflash_t *pfl, hwaddr offset,
>
> if (!pfl->wcycle) {
> /* Set the device in I/O access mode */
> + pfl->romd=0;
> memory_region_rom_device_set_romd(&pfl->mem, false);
> }
>
> @@ -638,6 +652,7 @@ static void pflash_write(pflash_t *pfl, hwaddr offset,
> "\n", __func__, offset, pfl->wcycle, pfl->cmd, value);
>
> reset_flash:
> + pfl->romd=1;
> memory_region_rom_device_set_romd(&pfl->mem, true);
>
> pfl->wcycle = 0;
> @@ -804,6 +819,7 @@ static void pflash_cfi01_realize(DeviceState *dev,
> Error **errp)
> pfl->wcycle = 0;
> pfl->cmd = 0;
> pfl->status = 0;
> + pfl->romd = 1;
> /* Hardcoded CFI table */
> pfl->cfi_len = 0x52;
> /* Standard "QRY" string */
> --
> 2.0.0
I suspect you need a subsection. Initialize ->romd = 1, then let the
subsection override it.
WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: Johny Mattsson <jmattsson@dius.com.au>
Cc: qemu-trivial@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] Fix pflash_cfi01 to restore flash command/array state after migration
Date: Thu, 21 Aug 2014 11:48:08 +0200 [thread overview]
Message-ID: <87egwab2cn.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <CACTyEaOFhLnoA5TDHGkDpxpP+TxVKyuTT9AL+q8Y1kaa+wxE5A@mail.gmail.com> (Johny Mattsson's message of "Thu, 21 Aug 2014 17:35:25 +1000")
I'm afraid this is *not* trivial. Migration stuff rarely is :)
Johny Mattsson <jmattsson@dius.com.au> writes:
> When using snapshots on e.g. the VersatilePB board, the pflash driver
> would report an error and get reset at times after resuming the snapshot.
> This was traced down to the 'romd' flag in the pflash emulation which was
> not being persisted in the snapshot.
>
> Author: Bernd Meyer <bmeyer@dius.com.au>
> Signed-off-by: Johny Mattsson <jmattsson@dius.com.au>
>
> ---
> hw/block/pflash_cfi01.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
> index f9507b4..83cb1d3 100644
> --- a/hw/block/pflash_cfi01.c
> +++ b/hw/block/pflash_cfi01.c
> @@ -80,6 +80,7 @@ struct pflash_t {
> int ro;
> uint8_t cmd;
> uint8_t status;
> + uint8_t romd;
> uint16_t ident0;
> uint16_t ident1;
> uint16_t ident2;
> @@ -94,14 +95,25 @@ struct pflash_t {
> void *storage;
> };
>
> +static int sync_romd(void* opaque, int version_id)
> +{
> + (void)version_id;
> + pflash_t *pfl = opaque;
> +
> + memory_region_rom_device_set_romd(&pfl->mem,!!pfl->romd);
> + return 0;
> +}
> +
> static const VMStateDescription vmstate_pflash = {
> .name = "pflash_cfi01",
> .version_id = 1,
> .minimum_version_id = 1,
> + .post_load = sync_romd,
> .fields = (VMStateField[]) {
> VMSTATE_UINT8(wcycle, pflash_t),
> VMSTATE_UINT8(cmd, pflash_t),
> VMSTATE_UINT8(status, pflash_t),
> + VMSTATE_UINT8(romd, pflash_t),
> VMSTATE_UINT64(counter, pflash_t),
> VMSTATE_END_OF_LIST()
> }
Doesn't this break migration to/from unfixed versions?
> @@ -114,6 +126,7 @@ static void pflash_timer (void *opaque)
> DPRINTF("%s: command %02x done\n", __func__, pfl->cmd);
> /* Reset flash */
> pfl->status ^= 0x80;
> + pfl->romd=1;
> memory_region_rom_device_set_romd(&pfl->mem, true);
> pfl->wcycle = 0;
> pfl->cmd = 0;
> @@ -453,6 +466,7 @@ static void pflash_write(pflash_t *pfl, hwaddr offset,
>
> if (!pfl->wcycle) {
> /* Set the device in I/O access mode */
> + pfl->romd=0;
> memory_region_rom_device_set_romd(&pfl->mem, false);
> }
>
> @@ -638,6 +652,7 @@ static void pflash_write(pflash_t *pfl, hwaddr offset,
> "\n", __func__, offset, pfl->wcycle, pfl->cmd, value);
>
> reset_flash:
> + pfl->romd=1;
> memory_region_rom_device_set_romd(&pfl->mem, true);
>
> pfl->wcycle = 0;
> @@ -804,6 +819,7 @@ static void pflash_cfi01_realize(DeviceState *dev,
> Error **errp)
> pfl->wcycle = 0;
> pfl->cmd = 0;
> pfl->status = 0;
> + pfl->romd = 1;
> /* Hardcoded CFI table */
> pfl->cfi_len = 0x52;
> /* Standard "QRY" string */
> --
> 2.0.0
I suspect you need a subsection. Initialize ->romd = 1, then let the
subsection override it.
next prev parent reply other threads:[~2014-08-21 9:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-21 7:35 [Qemu-trivial] [PATCH] Fix pflash_cfi01 to restore flash command/array state after migration Johny Mattsson
2014-08-21 7:35 ` [Qemu-devel] " Johny Mattsson
2014-08-21 9:22 ` [Qemu-trivial] " Peter Maydell
2014-08-21 9:22 ` Peter Maydell
2014-08-21 9:58 ` [Qemu-trivial] " Paolo Bonzini
2014-08-21 9:58 ` [Qemu-devel] " Paolo Bonzini
2014-08-21 9:48 ` Markus Armbruster [this message]
2014-08-21 9:48 ` Markus Armbruster
2014-08-22 7:53 ` [Qemu-trivial] " Johny Mattsson
2014-08-22 7:53 ` Johny Mattsson
2014-08-22 9:12 ` [Qemu-trivial] " Markus Armbruster
2014-08-22 9:12 ` Markus Armbruster
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=87egwab2cn.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=jmattsson@dius.com.au \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=stefanha@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.