From: Francisco Iglesias <frasse.iglesias@gmail.com>
To: Tong Ho <tong.ho@amd.com>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
alistair@alistair23.me, edgar.iglesias@gmail.comi,
peter.maydell@linaro.org
Subject: Re: [PATCH] hw/nvram: Avoid unnecessary Xilinx eFuse backstore write
Date: Thu, 27 Apr 2023 08:38:55 +0200 [thread overview]
Message-ID: <20230427063854.GA6030@fralle-msi> (raw)
In-Reply-To: <20230426211607.2054776-1-tong.ho@amd.com>
On [2023 Apr 26] Wed 14:16:07, Tong Ho wrote:
> Add a check in the bit-set operation to write the backstore
> only if the affected bit is 0 before.
>
> With this in place, there will be no need for callers to
> do the checking in order to avoid unnecessary writes.
>
> Signed-off-by: Tong Ho <tong.ho@amd.com>
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
> ---
> hw/nvram/xlnx-efuse.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c
> index fdfffaab99..655c40b8d1 100644
> --- a/hw/nvram/xlnx-efuse.c
> +++ b/hw/nvram/xlnx-efuse.c
> @@ -143,6 +143,8 @@ static bool efuse_ro_bits_find(XlnxEFuse *s, uint32_t k)
>
> bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit)
> {
> + uint32_t set, *row;
> +
> if (efuse_ro_bits_find(s, bit)) {
> g_autofree char *path = object_get_canonical_path(OBJECT(s));
>
> @@ -152,8 +154,13 @@ bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit)
> return false;
> }
>
> - s->fuse32[bit / 32] |= 1 << (bit % 32);
> - efuse_bdrv_sync(s, bit);
> + /* Avoid back-end write unless there is a real update */
> + row = &s->fuse32[bit / 32];
> + set = 1 << (bit % 32);
> + if (!(set & *row)) {
> + *row |= set;
> + efuse_bdrv_sync(s, bit);
> + }
> return true;
> }
>
> --
> 2.25.1
>
next prev parent reply other threads:[~2023-04-27 6:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 21:16 [PATCH] hw/nvram: Avoid unnecessary Xilinx eFuse backstore write Tong Ho
2023-04-27 5:14 ` Alistair Francis
2023-04-27 6:38 ` Francisco Iglesias [this message]
2023-04-28 23:08 ` Philippe Mathieu-Daudé
2023-07-17 10:06 ` Peter Maydell
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=20230427063854.GA6030@fralle-msi \
--to=frasse.iglesias@gmail.com \
--cc=alistair@alistair23.me \
--cc=edgar.iglesias@gmail.comi \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=tong.ho@amd.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.