From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45706C433DB for ; Wed, 10 Mar 2021 11:02:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8BA2664FCE for ; Wed, 10 Mar 2021 11:02:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8BA2664FCE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJwc5-0007sx-JT for qemu-devel@archiver.kernel.org; Wed, 10 Mar 2021 06:02:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJwan-0006xj-8M; Wed, 10 Mar 2021 06:01:29 -0500 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:52045) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJwah-0002Qj-Pj; Wed, 10 Mar 2021 06:01:28 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 13C6F5C4; Wed, 10 Mar 2021 06:01:21 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 10 Mar 2021 06:01:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=5gvmH0L9vL5I8RHByJZ8jZOIQ2LwPZFpULr0ZEME3 44=; b=ZRFpsv/k0tpsYhLoxaba2riNbr+lZZueqAB5/2EsET1JxBygDwwOwVmMs RaEDMSCDLEnrtlm/m5M/SjawLPZb7WypnibhM3N11wFbaj/txjggM99Rqe7hAhAI LZBrtpizsDaeSQ/HinX7LLEruW+zqLIycsxtpakCavbLUoo7D9hBxRWpDFmiZt0g nT9XCg4auoIvYXFywOtKi7IVDFAnbnEYyqNjZJDuDdsjsvL6rCYqtYz7oNty/VIl JiBX7E/RMcNLnk3Ig6QEwn5viagwUaf9YQccPQQyW8bUAPTtUBO5cMBFPldmWYop KCewukJcO2nLC+DgQm+k5FtZgg+xw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepvffujghfhfffkfggtgfgsehtqhertddttdejnecuhfhrohhmpeffrghvihgu ucfgughmohhnughsohhnuceouggrvhhiugdrvggumhhonhgushhonhesohhrrggtlhgvrd gtohhmqeenucggtffrrghtthgvrhhnpeekiedvtdfguedttdffhfeihfeffedttdekkedt leduheejgfeghfdujeelveduhfenucfkphepkedurddukeejrddviedrvdefkeenucevlh hushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpegurghvihgurdgv ughmohhnughsohhnsehorhgrtghlvgdrtghomh X-ME-Proxy: Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net [81.187.26.238]) by mail.messagingengine.com (Postfix) with ESMTPA id 1B023240057; Wed, 10 Mar 2021 06:01:19 -0500 (EST) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 5ca0da1a; Wed, 10 Mar 2021 11:01:18 +0000 (UTC) To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Subject: Re: [PATCH 7/9] hw/block/pflash_cfi02: Factor out DeviceReset method In-Reply-To: <20210309235028.912078-8-philmd@redhat.com> References: <20210309235028.912078-1-philmd@redhat.com> <20210309235028.912078-8-philmd@redhat.com> X-HGTTG: heart-of-gold From: David Edmondson Date: Wed, 10 Mar 2021 11:01:18 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: softfail client-ip=64.147.123.20; envelope-from=david.edmondson@oracle.com; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_SOFTFAIL=0.665, UNPARSEABLE_RELAY=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Stephen Checkoway , qemu-block@nongnu.org, Max Reitz , Alistair Francis , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Wednesday, 2021-03-10 at 00:50:26 +01, Philippe Mathieu-Daud=C3=A9 wrote: > There is multiple places doing a device reset. Factor that > out in a common method which matches the DeviceReset prototype, > so we can also remove the reset code from the DeviceRealize() > handler. Explicit the device is set in "read array" mode on > reset. > > Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: David Edmondson > --- > hw/block/pflash_cfi02.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c > index 2ba77a0171b..484b056b898 100644 > --- a/hw/block/pflash_cfi02.c > +++ b/hw/block/pflash_cfi02.c > @@ -193,6 +193,14 @@ static void pflash_mode_read_array(PFlashCFI02 *pfl) > memory_region_rom_device_set_romd(&pfl->orig_mem, true); > } >=20=20 > +static void pflash_cfi02_reset(DeviceState *dev) > +{ > + PFlashCFI02 *pfl =3D PFLASH_CFI02(dev); > + > + trace_pflash_reset(); > + pflash_mode_read_array(pfl); > +} > + > static size_t pflash_regions_count(PFlashCFI02 *pfl) > { > return pfl->cfi_table[0x2c]; > @@ -330,8 +338,7 @@ static uint64_t pflash_read(void *opaque, hwaddr offs= et, unsigned int width) > default: > /* This should never happen : reset state & treat it as a read*/ > DPRINTF("%s: unknown command state: %x\n", __func__, pfl->cmd); > - pfl->wcycle =3D 0; > - pfl->cmd =3D 0; > + pflash_cfi02_reset(DEVICE(pfl)); > /* fall through to the read code */ > case 0x80: /* Erase (unlock) */ > /* We accept reads during second unlock sequence... */ > @@ -710,10 +717,8 @@ static void pflash_write(void *opaque, hwaddr offset= , uint64_t value, >=20=20 > /* Reset flash */ > reset_flash: > - trace_pflash_reset(); > pfl->bypass =3D 0; > - pfl->wcycle =3D 0; > - pfl->cmd =3D 0; > + pflash_cfi02_reset(DEVICE(pfl)); > return; >=20=20 > do_bypass: > @@ -977,6 +982,7 @@ static void pflash_cfi02_class_init(ObjectClass *klas= s, void *data) > DeviceClass *dc =3D DEVICE_CLASS(klass); >=20=20 > dc->realize =3D pflash_cfi02_realize; > + dc->reset =3D pflash_cfi02_reset; > dc->unrealize =3D pflash_cfi02_unrealize; > device_class_set_props(dc, pflash_cfi02_properties); > set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); > --=20 > 2.26.2 dme. --=20 The band is just fantastic, that is really what I think.