From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Alistair Francis" <Alistair.Francis@wdc.com>,
"Bin Meng" <bin.meng@windriver.com>,
qemu-riscv@nongnu.org, "Palmer Dabbelt" <palmer@dabbelt.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [RFC PATCH-for-6.2?] hw/misc/sifive_u_otp: Do not reset OTP content on hardware reset
Date: Fri, 19 Nov 2021 11:47:57 +0100 [thread overview]
Message-ID: <20211119104757.331579-1-f4bug@amsat.org> (raw)
Once a "One Time Programmable" is programmed, it shouldn't be reset.
Do not re-initialize the OTP content in the DeviceReset handler,
initialize it once in the DeviceRealize one.
Fixes: 9fb45c62ae8 ("riscv: sifive: Implement a model for SiFive FU540 OTP")
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/misc/sifive_u_otp.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c
index 18aa0bd55d8..b5adcfa7cb4 100644
--- a/hw/misc/sifive_u_otp.c
+++ b/hw/misc/sifive_u_otp.c
@@ -235,14 +235,10 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
if (blk_pread(s->blk, 0, s->fuse, filesize) != filesize) {
error_setg(errp, "failed to read the initial flash content");
+ return;
}
}
}
-}
-
-static void sifive_u_otp_reset(DeviceState *dev)
-{
- SiFiveUOTPState *s = SIFIVE_U_OTP(dev);
/* Initialize all fuses' initial value to 0xFFs */
memset(s->fuse, 0xff, sizeof(s->fuse));
@@ -259,13 +255,15 @@ static void sifive_u_otp_reset(DeviceState *dev)
serial_data = s->serial;
if (blk_pwrite(s->blk, index * SIFIVE_U_OTP_FUSE_WORD,
&serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) {
- error_report("write error index<%d>", index);
+ error_setg(errp, "failed to write index<%d>", index);
+ return;
}
serial_data = ~(s->serial);
if (blk_pwrite(s->blk, (index + 1) * SIFIVE_U_OTP_FUSE_WORD,
&serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) {
- error_report("write error index<%d>", index + 1);
+ error_setg(errp, "failed to write index<%d>", index + 1);
+ return;
}
}
@@ -279,7 +277,6 @@ static void sifive_u_otp_class_init(ObjectClass *klass, void *data)
device_class_set_props(dc, sifive_u_otp_properties);
dc->realize = sifive_u_otp_realize;
- dc->reset = sifive_u_otp_reset;
}
static const TypeInfo sifive_u_otp_info = {
--
2.31.1
next reply other threads:[~2021-11-19 10:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 10:47 Philippe Mathieu-Daudé [this message]
2021-11-19 13:07 ` [RFC PATCH-for-6.2?] hw/misc/sifive_u_otp: Do not reset OTP content on hardware reset Alistair Francis
2021-11-22 0:45 ` Alistair Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211119104757.331579-1-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=Alistair.Francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).