1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 14:42:36 +02:00

erasure_layout: Erase larger block only when all sub-block need erase

A larger (not the smallest) erase block used to get erased when half
of sub-blocks it contains need erase, which has at least 2 issues:

1. The rest half of sub-blocks that do not need erase are also erased,
   introducing some erase overheads.

2. More severely, since this logic only selects a block and delects
   its sub-blocks when half of sub-blocks need erase, but this logic
   does not deselect "nested sub-blocks (sub-blocks of sub-block)" not
   reach the limit under this block, the logic may cause duplicated
   erase. For example, if a erase block (often the largest one
   corresponding to the whole chip) has half of its sub-blocks and
   some incontiguous nested sub-blocks needing erase, these double
   sub-blocks will end up being erased twice, introducing even more
   erase overheads than whole-chip erase.

The older behavior of flashrom before adding erasure_layout.c, when no
communicational error occurs, will neither erase blocks that do not
need erase, nor cause duplicated erase. Higher efficiency should be
achieved without introducing extra erase overheads, by allowing
combining contiguous small erase blocks only when they can
coincidently form a larger erase block.

Change-Id: I9e10749186e395da67ec80e296119f33c3f83122
Signed-off-by: persmule <persmule@hardenedlinux.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84614
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
persmule 2024-10-01 17:19:57 +08:00 committed by Anastasia Klimchuk
parent ad6d288b45
commit 348dbeb05f

View File

@ -228,7 +228,7 @@ static void select_erase_functions(struct flashctx *flashctx, const struct erase
}
const int total_blocks = sub_block_end - sub_block_start + 1;
if (count && count > total_blocks/2) {
if (count == total_blocks) {
if (ll->start_addr >= rstart && ll->end_addr <= rend) {
for (int j = sub_block_start; j <= sub_block_end; j++)
layout[findex - 1].layout_list[j].selected = false;