Received: from eggs.gnu.org ([209.51.188.92]:39375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNNPx-0002sy-Mc for qemu-devel@nongnu.org; Sun, 05 May 2019 16:07:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNNPu-0006Pa-L0 for qemu-devel@nongnu.org; Sun, 05 May 2019 16:07:24 -0400 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sun, 5 May 2019 22:06:02 +0200 Message-Id: <20190505200602.12412-6-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 5/5] hw/block/pflash_cfi02: 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_cfi02.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index f321b74433c..5af367d1563 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -674,6 +674,11 @@ static void pflash_cfi02_realize(DeviceState *dev, E= rror **errp) pfl->cfi_table[0x3c] =3D 0x00; } =20 +static void pflash_cfi02_reset(DeviceState *dev) +{ + pflash_reset(PFLASH_CFI02(dev)); +} + static Property pflash_cfi02_properties[] =3D { DEFINE_PROP_DRIVE("drive", PFlashCFI02, blk), DEFINE_PROP_UINT32("num-blocks", PFlashCFI02, nb_blocs, 0), @@ -701,6 +706,7 @@ static void pflash_cfi02_class_init(ObjectClass *klas= s, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 + dc->reset =3D pflash_cfi02_reset; dc->realize =3D pflash_cfi02_realize; dc->unrealize =3D pflash_cfi02_unrealize; dc->props =3D pflash_cfi02_properties; --=20 2.20.1