From nobody Tue Dec 16 11:48:11 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1674886067356232.07174723227854; Fri, 27 Jan 2023 22:07:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLeLf-0002MK-Nm; Sat, 28 Jan 2023 01:05:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLeLe-0002LP-Ab; Sat, 28 Jan 2023 01:05:58 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLeLc-0007WH-MH; Sat, 28 Jan 2023 01:05:58 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 83FCF5C0113; Sat, 28 Jan 2023 01:05:55 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sat, 28 Jan 2023 01:05:55 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 28 Jan 2023 01:05:54 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pjd.dev; h=cc:cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1674885955; x= 1674972355; bh=NP/ZhOqWE80vJNTYapWYBX2e580uJYMFdH8GQpi9ub4=; b=y 2cH+sHRQY8mlQWI9uO5qu+yzgIaApjc1UPH8EtoQDmgfOL5enE2SEx8e0UpuU4B7 0HUPpReHScgerZOqbtrFVL8ej8VWC4Abau+9QYr/139Ef5ARBOmeHdt/AFfOX1DA BImjt421yeHH3ahvqaidqsAVVWl6HaMxHRXF/nLbJCuvGtbMgiVFmr5tmEkFXEOQ bncZW/6B8csqFIKTcZacOpV8Zv9CFwJNzogYYiLialhv3P4usagM6454iufUuwGs 0oZIXeROabiD9BoZfuUBmz9+yz7W9cLdc74M37bVWRl+tKZ8Ta0GU/IXUbxvOdUg fj7epv8w++/gZ3T2jDslQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1674885955; x= 1674972355; bh=NP/ZhOqWE80vJNTYapWYBX2e580uJYMFdH8GQpi9ub4=; b=Y 6g8+i+wsp3nTmsVFefT6g8NdcZuJKtGSI9UaouOv+wc+IsnRFUiye+UIZ62n/RTp hEmDfF3it6Efda6dDMXmd6XGW6oDzDBu4AqBWamSq1oogQKDE0imeDpiZ+gTn2Dn oU9rHUVnWnKRSBs/njz07MZB0MTiaUUxQvEW3oMS8ooOhzwyxGMEz+eyE8NDRnmH d2nbz7MkdqVniUz6xStS9wh6jShqTHSjz84DgzZ4UuFv+jjzpIDvHMfjXhYqUEsm 6F3J5Bp+8NsQeNa2RHC+m3RAwpsonsLPME9oYdR6pBKZCTzaOOr1RH2NEqxtZ8sb bqN0+6eKejuSNAizPV6+Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddvjedgledvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenuchmihhsshhinhhgucfvqfcufhhivghlugculdeftd dmnegoteeftdduqddtudculdduhedmnecujfgurhephffvvefufffkofgjfhggtgfgseht keertdertdejnecuhfhrohhmpefrvghtvghrucffvghlvghvohhrhigrshcuoehpvghtvg hrsehpjhgurdguvghvqeenucggtffrrghtthgvrhhnpedvhfevvefhtddvueevudelvedt ieehvdejjeeuvedtudegjeeileetheekgfeggeenucevlhhushhtvghrufhiiigvpedune curfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrsehpjhgurdguvghv X-ME-Proxy: Feedback-ID: i9e814621:Fastmail From: Peter Delevoryas To: Cc: peter@pjd.dev, clg@kaod.org, peter.maydell@linaro.org, andrew@aj.id.au, joel@jms.id.au, hskinnemoen@google.com, kfting@nuvoton.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org, philmd@linaro.org, cminyard@mvista.com Subject: [PATCH v5 5/5] hw/nvram/eeprom_at24c: Make reset behavior more like hardware Date: Fri, 27 Jan 2023 22:05:43 -0800 Message-Id: <20230128060543.95582-6-peter@pjd.dev> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230128060543.95582-1-peter@pjd.dev> References: <20230128060543.95582-1-peter@pjd.dev> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.25; envelope-from=peter@pjd.dev; helo=out1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674886068401100001 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 (li= ke warm or bus resets) which may keep certain parts untouched. But differs from my intuition. For example, if someone writes some informat= ion to an EEPROM, then AC power cycles their board, they would expect the EEPRO= M to retain that information. It's very useful to be able to test things like th= is in QEMU as well, to verify software instrumentation like determining the ca= use of a reboot. Fixes: 5d8424dbd3e8 ("nvram: add AT24Cx i2c eeprom") Signed-off-by: Peter Delevoryas Reviewed-by: Joel Stanley Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Corey Minyard --- hw/nvram/eeprom_at24c.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c index 05598699dc2b..3328c3281435 100644 --- a/hw/nvram/eeprom_at24c.c +++ b/hw/nvram/eeprom_at24c.c @@ -184,18 +184,6 @@ static void at24c_eeprom_realize(DeviceState *dev, Err= or **errp) } =20 ee->mem =3D g_malloc0(ee->rsize); - -} - -static -void at24c_eeprom_reset(DeviceState *state) -{ - EEPROMState *ee =3D AT24C_EE(state); - - ee->changed =3D false; - ee->cur =3D 0; - ee->haveaddr =3D 0; - memset(ee->mem, 0, ee->rsize); =20 if (ee->init_rom) { @@ -213,6 +201,16 @@ void at24c_eeprom_reset(DeviceState *state) } } =20 +static +void at24c_eeprom_reset(DeviceState *state) +{ + EEPROMState *ee =3D AT24C_EE(state); + + ee->changed =3D false; + ee->cur =3D 0; + ee->haveaddr =3D 0; +} + static Property at24c_eeprom_props[] =3D { DEFINE_PROP_UINT32("rom-size", EEPROMState, rsize, 0), DEFINE_PROP_BOOL("writable", EEPROMState, writable, true), --=20 2.39.0