From 981e61bde9afa3bfe3779828380c356384096068 Mon Sep 17 00:00:00 2001 From: Sean Rhodes Date: Tue, 18 Jul 2023 12:07:29 +0100 Subject: [PATCH] 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 Change-Id: Ia39b2ce4ffcb8db3a335449c8bdb0d5c8a28a52c Reviewed-on: https://review.coreboot.org/c/coreboot/+/76581 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier --- src/ec/starlabs/merlin/ite.c | 39 +++++++++++++++--------------------- 1 file changed, 16 insertions(+), 23 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); + if (cmos_mirror_flag_counter == UINT_MAX) + return; - /* 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); + printk(BIOS_DEBUG, "ITE: mirror_flag_counter = %u\n", cmos_mirror_flag_counter); - /* Write the EC mirror flag */ - ec_write(ECRAM_MIRROR_FLAG, MIRROR_ENABLED); + /* 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); - /* 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"); /* 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); } }