diff options
author | Sean Rhodes <sean@starlabs.systems> | 2023-07-18 12:07:29 +0100 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2023-08-11 17:53:10 +0000 |
commit | 981e61bde9afa3bfe3779828380c356384096068 (patch) | |
tree | bf46f2adbbe976c2c1e7408cfabb4e9488db32d5 /src/ec/starlabs/merlin | |
parent | e4fd561ab77840717c2773122e24b86f069bae4e (diff) |
ec/starlabs/merlin/ite: Don't attempt EC mirror without a counter
If the variable `mirror_flag_attempts` isn't accessible, or doesn't
have a value, don't attempt to mirror the EC.
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Change-Id: Ia39b2ce4ffcb8db3a335449c8bdb0d5c8a28a52c
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76581
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Diffstat (limited to 'src/ec/starlabs/merlin')
-rw-r--r-- | src/ec/starlabs/merlin/ite.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/src/ec/starlabs/merlin/ite.c b/src/ec/starlabs/merlin/ite.c index c7a027974b..9916bf09ed 100644 --- a/src/ec/starlabs/merlin/ite.c +++ b/src/ec/starlabs/merlin/ite.c @@ -31,38 +31,31 @@ static void ec_mirror_with_count(void) { unsigned int cmos_mirror_flag_counter = get_uint_option("mirror_flag_counter", UINT_MAX); - if (cmos_mirror_flag_counter != UINT_MAX) { - printk(BIOS_DEBUG, "ITE: mirror_flag_counter = %u\n", cmos_mirror_flag_counter); - - /* Avoid boot loops by only trying a state change once */ - if (cmos_mirror_flag_counter < MIRROR_ATTEMPTS) { - cmos_mirror_flag_counter++; - set_uint_option("mirror_flag_counter", cmos_mirror_flag_counter); - printk(BIOS_DEBUG, "ITE: Mirror attempt %u/%u.\n", cmos_mirror_flag_counter, - MIRROR_ATTEMPTS); - - /* Write the EC mirror flag */ - ec_write(ECRAM_MIRROR_FLAG, MIRROR_ENABLED); - - /* Check what has been written */ - if (ec_read(ECRAM_MIRROR_FLAG) == MIRROR_ENABLED) - poweroff(); - } else { - /* - * If the mirror flags fails after 1 attempt, it will - * likely need a cold boot, or recovering. - */ - printk(BIOS_ERR, "ITE: Failed to mirror the EC in %u attempts!\n", - MIRROR_ATTEMPTS); - } - } else { - printk(BIOS_DEBUG, "ITE: Powering Off"); + if (cmos_mirror_flag_counter == UINT_MAX) + return; + + printk(BIOS_DEBUG, "ITE: mirror_flag_counter = %u\n", cmos_mirror_flag_counter); + + /* Avoid boot loops by only trying a state change once */ + if (cmos_mirror_flag_counter < MIRROR_ATTEMPTS) { + cmos_mirror_flag_counter++; + set_uint_option("mirror_flag_counter", cmos_mirror_flag_counter); + printk(BIOS_DEBUG, "ITE: Mirror attempt %u/%u.\n", cmos_mirror_flag_counter, + MIRROR_ATTEMPTS); + /* Write the EC mirror flag */ ec_write(ECRAM_MIRROR_FLAG, MIRROR_ENABLED); /* Check what has been written */ if (ec_read(ECRAM_MIRROR_FLAG) == MIRROR_ENABLED) poweroff(); + } else { + /* + * If the mirror flags fails after 1 attempt, it will + * likely need a cold boot, or recovering. + */ + printk(BIOS_ERR, "ITE: Failed to mirror the EC in %u attempts!\n", + MIRROR_ATTEMPTS); } } |