All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, amit.shah@redhat.com,
	fred.konrad@greensocs.com, alistair.francis@xilinx.com,
	crosthwaite.peter@gmail.com, hyun.kwon@xilinx.com,
	peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH v2] i2c: fix migration regression introduced by broadcast support
Date: Mon, 1 Aug 2016 10:20:39 +0100	[thread overview]
Message-ID: <20160801092038.GB2051@work-vm> (raw)
In-Reply-To: <1469623198-177227-1-git-send-email-imammedo@redhat.com>

* Igor Mammedov (imammedo@redhat.com) wrote:
> QEMU fails migration with following error:
> 
> qemu-system-x86_64: Missing section footer for i2c_bus
> qemu-system-x86_64: load of migration failed: Invalid argument
> 
> when migrating from:
>   qemu-system-x86_64-v2.6.0 -m 256M rhel72.img -M pc-i440fx-2.6
> to
>   qemu-system-x86_64-v2.7.0-rc0 -m 256M rhel72.img -M pc-i440fx-2.6
> 
> Regression is added by commit 2293c27f (i2c: implement broadcast write)
> 
> Fix it by dropping 'broadcast' VMState introduced by 2293c27f and
> reuse broadcast 0x00 address as broadcast flag in bus->saved_address.
> Then if there were ongoing broadcast at migration time, set
> bus->saved_address to it and at i2c_slave_post_load() time check
> for it instead of transfering and using 'broadcast' VMState.
> 
> As result of reusing existing saved_address VMState, no compat
> glue will be needed to keep forward/backward compatiblity. which
> makes fix much less intrusive.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
> CC: fred.konrad@greensocs.com
> CC: alistair.francis@xilinx.com
> CC: crosthwaite.peter@gmail.com
> CC: hyun.kwon@xilinx.com
> CC: peter.maydell@linaro.org
> 
> ---
>  hw/i2c/core.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/i2c/core.c b/hw/i2c/core.c
> index abb3efb..4afbe0b 100644
> --- a/hw/i2c/core.c
> +++ b/hw/i2c/core.c
> @@ -17,6 +17,8 @@ struct I2CNode {
>      QLIST_ENTRY(I2CNode) next;
>  };
>  
> +#define I2C_BROADCAST 0x00
> +
>  struct I2CBus
>  {
>      BusState qbus;
> @@ -47,6 +49,8 @@ static void i2c_bus_pre_save(void *opaque)
>      if (!QLIST_EMPTY(&bus->current_devs)) {
>          if (!bus->broadcast) {
>              bus->saved_address = QLIST_FIRST(&bus->current_devs)->elt->address;
> +        } else {
> +            bus->saved_address = I2C_BROADCAST;
>          }
>      }
>  }
> @@ -58,7 +62,6 @@ static const VMStateDescription vmstate_i2c_bus = {
>      .pre_save = i2c_bus_pre_save,
>      .fields = (VMStateField[]) {
>          VMSTATE_UINT8(saved_address, I2CBus),
> -        VMSTATE_BOOL(broadcast, I2CBus),
>          VMSTATE_END_OF_LIST()
>      }
>  };
> @@ -93,7 +96,7 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv)
>      I2CSlaveClass *sc;
>      I2CNode *node;
>  
> -    if (address == 0x00) {
> +    if (address == I2C_BROADCAST) {
>          /*
>           * This is a broadcast, the current_devs will be all the devices of the
>           * bus.
> @@ -221,7 +224,8 @@ static int i2c_slave_post_load(void *opaque, int version_id)
>      I2CNode *node;
>  
>      bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));
> -    if ((bus->saved_address == dev->address) || (bus->broadcast)) {
> +    if ((bus->saved_address == dev->address) ||
> +        (bus->saved_address == I2C_BROADCAST)) {
>          node = g_malloc(sizeof(struct I2CNode));
>          node->elt = dev;
>          QLIST_INSERT_HEAD(&bus->current_devs, node, next);
> -- 
> 2.7.4
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

      parent reply	other threads:[~2016-08-01  9:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26 13:55 [Qemu-arm] [PATCH] i2c: fix migration regression introduced by broadcast support Igor Mammedov
2016-07-26 13:55 ` [Qemu-devel] " Igor Mammedov
2016-07-26 14:01 ` [Qemu-arm] " Michael S. Tsirkin
2016-07-26 14:01   ` [Qemu-devel] " Michael S. Tsirkin
2016-07-26 15:31 ` [Qemu-arm] " Paolo Bonzini
2016-07-26 15:31   ` [Qemu-devel] " Paolo Bonzini
2016-07-27  7:34   ` Igor Mammedov
2016-07-27  7:34     ` Igor Mammedov
2016-07-27 12:39   ` [Qemu-devel] [PATCH v2] " Igor Mammedov
2016-08-01  8:46     ` Paolo Bonzini
2016-08-01  9:20     ` Dr. David Alan Gilbert [this message]

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=20160801092038.GB2051@work-vm \
    --to=dgilbert@redhat.com \
    --cc=alistair.francis@xilinx.com \
    --cc=amit.shah@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=fred.konrad@greensocs.com \
    --cc=hyun.kwon@xilinx.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.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 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.