From 26a1eb514ccefc61b110068cf0eea73c397ba045 Mon Sep 17 00:00:00 2001 From: persmule Date: Mon, 9 Sep 2024 02:50:06 +0800 Subject: [PATCH] ichspi: Probe opcode in POSSIBLE_OPCODES[] as well ich_spi_send_command() and ich_spi_send_multicommand() will overwrite the "Sector erase" opcode with the opcode for command via reprogram_opcode_on_the_fly(), but not restore it, causing the "Sector erase" opcode may get lost after sending commands, leaving only "Bulk erase" opcode which erase the whole chip available. In the mean time, ich_spi_probe_opcode() used not to report opcodes in POSSIBLE_OPCODES[] but not in curopcodes->opcode[] as supported. Now, if the opcode being probed is not in curopcodes->opcode[] but in POSSIBLE_OPCODES[], it will be reported as supported, and programmed later by ich_spi_send_(multi)command(). Fix:https://ticket.coreboot.org/issues/556 Change-Id: I3fc831fc072e2af9265835cb2f71bf8c222c6a64 Signed-off-by: persmule Reviewed-on: https://review.coreboot.org/c/flashrom/+/84253 Tested-by: build bot (Jenkins) Reviewed-by: Anastasia Klimchuk Reviewed-by: Nikolai Artemiev --- ichspi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ichspi.c b/ichspi.c index 338865718..fc994db04 100644 --- a/ichspi.c +++ b/ichspi.c @@ -1822,7 +1822,11 @@ static int ich_spi_send_multicommand(const struct flashctx *flash, static bool ich_spi_probe_opcode(const struct flashctx *flash, uint8_t opcode) { - return find_opcode(curopcodes, opcode) >= 0; + int ret = find_opcode(curopcodes, opcode); + if ((ret == -1) && (lookup_spi_type(opcode) <= 3)) + /* opcode is in POSSIBLE_OPCODES, report supported. */ + return true; + return ret >= 0; } #define ICH_BMWAG(x) ((x >> 24) & 0xff)