mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-28 23:43:42 +02:00
flashrom.c, flashcips.c: Test the order of erase functions
Add a check so that the erase functions for all flashchips are in increasing order of their respective eraseblock sizes. This is required for the implentation of the improved erasing algorithm. The patch uses the count of eraseblocks in each erase function to determine the order (More eraseblocks means that the function has smaller eraseblock size). Also fix the structs in flashchips.c which were found to be not conforming to this test. TEST = make && ./flashrom Change-Id: I137cb40483fa690ecc6c7eaece2d9d3f7a851bb4 Signed-off-by: Aarya Chaumal <aarya.chaumal@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/64961 Reviewed-by: Thomas Heijligen <src@posteo.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
aa64c054d0
commit
7db2baa77d
24
flashchips.c
24
flashchips.c
@ -5354,12 +5354,12 @@ const struct flashchip flashchips[] = {
|
||||
{
|
||||
.eraseblocks = { {4 * 1024, 512} },
|
||||
.block_erase = spi_block_erase_20,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 32} },
|
||||
.block_erase = spi_block_erase_52,
|
||||
}, {
|
||||
.eraseblocks = { {32 * 1024, 64} },
|
||||
.block_erase = spi_block_erase_d8,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 32} },
|
||||
.block_erase = spi_block_erase_52,
|
||||
}, {
|
||||
.eraseblocks = { {2048 * 1024, 1} },
|
||||
.block_erase = spi_block_erase_60,
|
||||
@ -9211,12 +9211,12 @@ const struct flashchip flashchips[] = {
|
||||
{
|
||||
.eraseblocks = { {4 * 1024, 2048} },
|
||||
.block_erase = spi_block_erase_20,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 128} },
|
||||
.block_erase = spi_block_erase_d8,
|
||||
}, {
|
||||
.eraseblocks = { {32 * 1024, 256} },
|
||||
.block_erase = spi_block_erase_52,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 128} },
|
||||
.block_erase = spi_block_erase_d8,
|
||||
}, {
|
||||
.eraseblocks = { {8 * 1024 * 1024, 1} },
|
||||
.block_erase = spi_block_erase_60,
|
||||
@ -9289,12 +9289,12 @@ const struct flashchip flashchips[] = {
|
||||
{
|
||||
.eraseblocks = { {4 * 1024, 1024} },
|
||||
.block_erase = spi_block_erase_20,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 64} },
|
||||
.block_erase = spi_block_erase_d8,
|
||||
}, {
|
||||
.eraseblocks = { {32 * 1024, 128} },
|
||||
.block_erase = spi_block_erase_52,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 64} },
|
||||
.block_erase = spi_block_erase_d8,
|
||||
}, {
|
||||
.eraseblocks = { {4 * 1024 * 1024, 1} },
|
||||
.block_erase = spi_block_erase_60,
|
||||
@ -9328,12 +9328,12 @@ const struct flashchip flashchips[] = {
|
||||
{
|
||||
.eraseblocks = { {4 * 1024, 2048} },
|
||||
.block_erase = spi_block_erase_20,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 128} },
|
||||
.block_erase = spi_block_erase_d8,
|
||||
}, {
|
||||
.eraseblocks = { {32 * 1024, 256} },
|
||||
.block_erase = spi_block_erase_52,
|
||||
}, {
|
||||
.eraseblocks = { {64 * 1024, 128} },
|
||||
.block_erase = spi_block_erase_d8,
|
||||
}, {
|
||||
.eraseblocks = { {8 * 1024 * 1024, 1} },
|
||||
.block_erase = spi_block_erase_60,
|
||||
|
11
flashrom.c
11
flashrom.c
@ -1075,10 +1075,12 @@ static int selfcheck_eraseblocks(const struct flashchip *chip)
|
||||
{
|
||||
int i, j, k;
|
||||
int ret = 0;
|
||||
unsigned int prev_eraseblock_count = chip->total_size * 1024;
|
||||
|
||||
for (k = 0; k < NUM_ERASEFUNCTIONS; k++) {
|
||||
unsigned int done = 0;
|
||||
struct block_eraser eraser = chip->block_erasers[k];
|
||||
unsigned int curr_eraseblock_count = 0;
|
||||
|
||||
for (i = 0; i < NUM_ERASEREGIONS; i++) {
|
||||
/* Blocks with zero size are bugs in flashchips.c. */
|
||||
@ -1101,6 +1103,7 @@ static int selfcheck_eraseblocks(const struct flashchip *chip)
|
||||
}
|
||||
done += eraser.eraseblocks[i].count *
|
||||
eraser.eraseblocks[i].size;
|
||||
curr_eraseblock_count += eraser.eraseblocks[i].count;
|
||||
}
|
||||
/* Empty eraseblock definition with erase function. */
|
||||
if (!done && eraser.block_erase)
|
||||
@ -1132,6 +1135,14 @@ static int selfcheck_eraseblocks(const struct flashchip *chip)
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
if(curr_eraseblock_count > prev_eraseblock_count)
|
||||
{
|
||||
msg_gerr("ERROR: Flash chip %s erase function %i is not "
|
||||
"in order. Please report a bug at flashrom@flashrom.org\n",
|
||||
chip->name, k);
|
||||
ret = 1;
|
||||
}
|
||||
prev_eraseblock_count = curr_eraseblock_count;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user