qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Corey Minyard <minyard@acm.org>
To: Peter Delevoryas <peter@pjd.dev>
Cc: clg@kaod.org, peter.maydell@linaro.org, andrew@aj.id.au,
	joel@jms.id.au, hskinnemoen@google.com, kfting@nuvoton.com,
	qemu-arm@nongnu.org, qemu-devel@nongnu.org, philmd@linaro.org
Subject: Re: [PATCH v4 5/5] hw/nvram/eeprom_at24c: Make reset behavior more like hardware
Date: Wed, 25 Jan 2023 15:41:30 -0600	[thread overview]
Message-ID: <Y9GiCmi7GRW0e/dm@minyard.net> (raw)
In-Reply-To: <20230118024214.14413-6-peter@pjd.dev>

On Tue, Jan 17, 2023 at 06:42:14PM -0800, Peter Delevoryas wrote:
> EEPROM's are a form of non-volatile memory. After power-cycling an EEPROM,
> I would expect the I2C state machine to be reset to default values, but I
> wouldn't really expect the memory to change at all.

Yes, I agree, I was actually wondering about this reviewing earlier
changes.  Thanks for fixing this.

Reviewed-by: Corey Minyard <cminyard@mvista.com>

> 
> The current implementation of the at24c EEPROM resets its internal memory on
> reset. This matches the specification in docs/devel/reset.rst:
> 
>   Cold reset is supported by every resettable object. In QEMU, it means we reset
>   to the initial state corresponding to the start of QEMU; this might differ
>   from what is a real hardware cold reset. It differs from other resets (like
>   warm or bus resets) which may keep certain parts untouched.
> 
> But differs from my intuition. For example, if someone writes some information
> to an EEPROM, then AC power cycles their board, they would expect the EEPROM to
> retain that information. It's very useful to be able to test things like this
> in QEMU as well, to verify software instrumentation like determining the cause
> of a reboot.
> 
> Fixes: 5d8424dbd3e8 ("nvram: add AT24Cx i2c eeprom")
> Signed-off-by: Peter Delevoryas <peter@pjd.dev>
> Reviewed-by: Joel Stanley <joel@jms.id.au>
> ---
>  hw/nvram/eeprom_at24c.c | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
> index f8d751fa278d..5074776bff04 100644
> --- a/hw/nvram/eeprom_at24c.c
> +++ b/hw/nvram/eeprom_at24c.c
> @@ -185,18 +185,6 @@ static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
>      }
>  
>      ee->mem = g_malloc0(ee->rsize);
> -
> -}
> -
> -static
> -void at24c_eeprom_reset(DeviceState *state)
> -{
> -    EEPROMState *ee = AT24C_EE(state);
> -
> -    ee->changed = false;
> -    ee->cur = 0;
> -    ee->haveaddr = 0;
> -
>      memset(ee->mem, 0, ee->rsize);
>  
>      if (ee->init_rom) {
> @@ -214,6 +202,16 @@ void at24c_eeprom_reset(DeviceState *state)
>      }
>  }
>  
> +static
> +void at24c_eeprom_reset(DeviceState *state)
> +{
> +    EEPROMState *ee = AT24C_EE(state);
> +
> +    ee->changed = false;
> +    ee->cur = 0;
> +    ee->haveaddr = 0;
> +}
> +
>  static Property at24c_eeprom_props[] = {
>      DEFINE_PROP_UINT32("rom-size", EEPROMState, rsize, 0),
>      DEFINE_PROP_BOOL("writable", EEPROMState, writable, true),
> -- 
> 2.39.0
> 
> 


  parent reply	other threads:[~2023-01-25 21:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18  2:42 [PATCH v4 0/5] hw/nvram/eeprom_at24c: Cleanup + FRUID EEPROM init example Peter Delevoryas
2023-01-18  2:42 ` [PATCH v4 1/5] hw/arm: Extract at24c_eeprom_init helper from Aspeed and Nuvoton boards Peter Delevoryas
2023-01-25 21:37   ` Corey Minyard
2023-01-18  2:42 ` [PATCH v4 2/5] hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init Peter Delevoryas
2023-01-25 21:37   ` Corey Minyard
2023-01-18  2:42 ` [PATCH v4 3/5] hw/nvram/eeprom_at24c: Add init_rom field and at24c_eeprom_init_rom helper Peter Delevoryas
2023-01-18 12:32   ` Cédric Le Goater
2023-01-25 21:36   ` Corey Minyard
2023-01-25 22:06     ` Peter Delevoryas
2023-01-27  7:42       ` Cédric Le Goater
2023-01-28  5:03         ` Peter Delevoryas
2023-01-18  2:42 ` [PATCH v4 4/5] hw/arm/aspeed: Add aspeed_eeprom.c Peter Delevoryas
2023-01-18 10:31   ` Cédric Le Goater
2023-01-18 18:50     ` Peter Delevoryas
2023-01-25 21:39   ` Corey Minyard
2023-01-18  2:42 ` [PATCH v4 5/5] hw/nvram/eeprom_at24c: Make reset behavior more like hardware Peter Delevoryas
2023-01-18 10:29   ` Cédric Le Goater
2023-01-25 21:41   ` Corey Minyard [this message]
2023-01-25 22:07     ` Peter Delevoryas
     [not found] <<20230118024214.14413-4-peter@pjd.dev>
2023-01-25 16:53 ` [PATCH v4 3/5] hw/nvram/eeprom_at24c: Add init_rom field and at24c_eeprom_init_rom helper Ninad S Palsule
2023-01-25 19:12   ` Peter Delevoryas
2023-01-26  7:09   ` Cédric Le Goater
2023-01-26 16:23     ` Ninad S Palsule
2023-01-26 17:19       ` Cédric Le Goater
2023-01-26 19:48         ` Ninad S Palsule

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=Y9GiCmi7GRW0e/dm@minyard.net \
    --to=minyard@acm.org \
    --cc=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=hskinnemoen@google.com \
    --cc=joel@jms.id.au \
    --cc=kfting@nuvoton.com \
    --cc=peter.maydell@linaro.org \
    --cc=peter@pjd.dev \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@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).