The TYPE_NAND device is bus-less, thus isn't reset automatically.
Register a reset handler to get reset with the machine.
Fixed: 7426aa72c36 ("nand: Don't inherit from Sysbus")
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/block/nand.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/hw/block/nand.c b/hw/block/nand.c
index 8bc80e35144..8ec656659f5 100644
--- a/hw/block/nand.c
+++ b/hw/block/nand.c
@@ -24,6 +24,7 @@
#include "hw/qdev-properties-system.h"
#include "hw/block/flash.h"
#include "sysemu/block-backend.h"
+#include "sysemu/reset.h"
#include "migration/vmstate.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
@@ -364,6 +365,11 @@ static const VMStateDescription vmstate_nand = {
}
};
+static void nand_reset_handler(void *dev)
+{
+ device_cold_reset(DEVICE(dev));
+}
+
static void nand_realize(DeviceState *dev, Error **errp)
{
int pagesize;
@@ -423,6 +429,13 @@ static void nand_realize(DeviceState *dev, Error **errp)
}
/* Give s->ioaddr a sane value in case we save state before it is used. */
s->ioaddr = s->io;
+
+ qemu_register_reset(nand_reset_handler, dev);
+}
+
+static void nand_unrealize(DeviceState *dev)
+{
+ qemu_unregister_reset(nand_reset_handler, dev);
}
static Property nand_properties[] = {
@@ -437,6 +450,7 @@ static void nand_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = nand_realize;
+ dc->unrealize = nand_unrealize;
dc->reset = nand_reset;
dc->vmsd = &vmstate_nand;
device_class_set_props(dc, nand_properties);
--
2.26.3
On Sun, 2 May 2021 at 21:31, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> The TYPE_NAND device is bus-less, thus isn't reset automatically.
> Register a reset handler to get reset with the machine.
>
> Fixed: 7426aa72c36 ("nand: Don't inherit from Sysbus")
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
Personally I would just revert 7426aa72c36 rather than introduce
a new use of qemu_register_reset()...
thanks
-- PMM
Peter Maydell <peter.maydell@linaro.org> writes:
> On Sun, 2 May 2021 at 21:31, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>
>> The TYPE_NAND device is bus-less, thus isn't reset automatically.
>> Register a reset handler to get reset with the machine.
>>
>> Fixed: 7426aa72c36 ("nand: Don't inherit from Sysbus")
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>
> Personally I would just revert 7426aa72c36 rather than introduce
> a new use of qemu_register_reset()...
I think this depends on what you dislike more, qemu_register_reset() or
sysbus. Neither is deprecated, both have more than a hundred users.
One more user doesn't matter all that much for either.
I happen to dislike sysbus more, but my opinion on this is yet another
thin that doesn't matter all that much :)
© 2016 - 2026 Red Hat, Inc.