From 9a4c6710abd7f66bcd8efc3dbc85dae8483c85a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kope=C4=87?= Date: Sun, 20 Oct 2024 19:22:54 +0200 Subject: [PATCH] soc/intel/cmn/blk: cse_enable_ptt: Wait up to 5 s for FW Init Complete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FW Init Complete is a prerequisite for sending the FW FEATURE SHIPMENT TIME STATE OVERRIDE message. Unfortunately, on some platforms such as Lenovo ThinkCentre M700 Tiny, it takes too long for the flag to be set, so enabling PTT fails. Wait up to 5 seconds for the FW Init Complete to be set instead of failing immediately. On M700 Tiny with debug level set to ERROR, we have to wait nearly 2 seconds: [EMERG] HECI: CSE took 1900 ms to complete FW init Because FW Init Complete is not required for getting the current feature enablement state, only for setting, move the FW Init Complete check to after we've determined if we actually need to change the state. This avoids needlessly increasing boot time. Reference: Intel ME 11.x BIOS Specification, #549522, section 6.3.15 Change-Id: Ib6de170f3f998273bec437848faa49652f013f45 Signed-off-by: Michał Kopeć Reviewed-on: https://review.coreboot.org/c/coreboot/+/84862 Reviewed-by: Martin L Roth Tested-by: build bot (Jenkins) --- src/soc/intel/common/block/cse/cse.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/soc/intel/common/block/cse/cse.c b/src/soc/intel/common/block/cse/cse.c index 53c5fe1471..2e0f2dbbbd 100644 --- a/src/soc/intel/common/block/cse/cse.c +++ b/src/soc/intel/common/block/cse/cse.c @@ -40,6 +40,8 @@ #define HECI_CIP_TIMEOUT_US 1000 /* Wait up to 5 seconds for CSE to boot from RO(BP1) */ #define CSE_DELAY_BOOT_TO_RO_MS (5 * 1000) +/* Wait up to 5 sec for CSE FW init to complete */ +#define CSE_FW_INIT_TIMEOUT_MS (5 * 1000) #define SLOT_SIZE sizeof(uint32_t) @@ -1193,10 +1195,8 @@ void cse_enable_ptt(bool state) * 4) HFSTS1 FW Init Complete is set * 5) Before EOP issued to CSE */ - if (!cse_is_hfs1_cws_normal() || !cse_is_hfs1_com_normal() || - !cse_is_hfs1_fw_init_complete() || !ENV_RAMSTAGE) { - printk(BIOS_ERR, "HECI: Unmet prerequisites for" - "FW FEATURE SHIPMENT TIME STATE OVERRIDE\n"); + if (!cse_is_hfs1_cws_normal() || !cse_is_hfs1_com_normal() || !ENV_RAMSTAGE) { + printk(BIOS_ERR, "HECI: Could not set PTT state because ME is not ready\n"); return; } @@ -1210,6 +1210,14 @@ void cse_enable_ptt(bool state) return; } + int elapsed = wait_ms(CSE_FW_INIT_TIMEOUT_MS, cse_is_hfs1_fw_init_complete()); + if (!elapsed) { + printk(BIOS_ERR, "HECI: Could not set PTT state because ME is not ready\n"); + return; + } + + printk(BIOS_DEBUG, "HECI: CSE took %d ms to become ready\n", elapsed); + printk(BIOS_DEBUG, "HECI: Send FW FEATURE SHIPMENT TIME STATE OVERRIDE Command\n"); if (state)