hw/nvram/eeprom_at24c: Make reset behavior more like hardware
commit4f2c6448c3b074ca45c0743b1e98df3a2c6e0fe2
authorPeter Delevoryas <peter@pjd.dev>
Tue, 7 Feb 2023 08:02:05 +0000 (7 09:02 +0100)
committerCédric Le Goater <clg@kaod.org>
Tue, 7 Feb 2023 08:02:05 +0000 (7 09:02 +0100)
tree50c944e68e832ab238641d57c730c682f6e792cf
parentc0216b94ed9467c307f5c0cedfc87e5de666b08e
hw/nvram/eeprom_at24c: Make reset behavior more like hardware

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.

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>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Corey Minyard <cminyard@mvista.com>
Link: https://lore.kernel.org/r/20230128060543.95582-6-peter@pjd.dev
Signed-off-by: Cédric Le Goater <clg@kaod.org>
hw/nvram/eeprom_at24c.c