Received: from eggs.gnu.org ([209.51.188.92]:39259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNNPi-0002ff-Ao for qemu-devel@nongnu.org; Sun, 05 May 2019 16:07:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNNPW-0004t8-L5 for qemu-devel@nongnu.org; Sun, 05 May 2019 16:07:04 -0400 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sun, 5 May 2019 22:06:00 +0200 Message-Id: <20190505200602.12412-4-philmd@redhat.com> In-Reply-To: <20190505200602.12412-1-philmd@redhat.com> References: <20190505200602.12412-1-philmd@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 3/5] hw/block/pflash_cfi01: Add the DeviceReset() handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Stephen Checkoway , Kevin Wolf , Paolo Bonzini , Laszlo Ersek , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Max Reitz , "Michael S . Tsirkin" , qemu-block@nongnu.org, Wei Yang , Gerd Hoffmann , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= The pflash device is a child of TYPE_DEVICE, so it can implement the DeviceReset handler. Actually it has to implement it, else on machine reset it might stay in an incoherent state, as it has been reported in the buglink listed below. Add the DeviceReset handler and remove its call from the realize() function. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1678713 Reported-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/block/pflash_cfi01.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 073cd14978f..639b05bc4d5 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -762,7 +762,6 @@ static void pflash_cfi01_realize(DeviceState *dev, Er= ror **errp) pfl->max_device_width =3D pfl->device_width; } =20 - pflash_reset(pfl); /* Hardcoded CFI table */ /* Standard "QRY" string */ pfl->cfi_table[0x10] =3D 'Q'; @@ -850,6 +849,11 @@ static void pflash_cfi01_realize(DeviceState *dev, E= rror **errp) pfl->cfi_table[0x3f] =3D 0x01; /* Number of protection fields */ } =20 +static void pflash_cfi01_reset(DeviceState *dev) +{ + pflash_reset(PFLASH_CFI01(dev)); +} + static Property pflash_cfi01_properties[] =3D { DEFINE_PROP_DRIVE("drive", PFlashCFI01, blk), /* num-blocks is the number of blocks actually visible to the guest, @@ -894,6 +898,7 @@ static void pflash_cfi01_class_init(ObjectClass *klas= s, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 + dc->reset =3D pflash_cfi01_reset; dc->realize =3D pflash_cfi01_realize; dc->props =3D pflash_cfi01_properties; dc->vmsd =3D &vmstate_pflash; --=20 2.20.1