Skip to content

Commit

Permalink
hw/nvram: Avoid unnecessary Xilinx eFuse backstore write
Browse files Browse the repository at this point in the history
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: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
Tong Ho authored and pm215 committed Jul 17, 2023
1 parent e60a7d0 commit c2c1c4a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions hw/nvram/xlnx-efuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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;
}

Expand Down

0 comments on commit c2c1c4a

Please sign in to comment.