From 1cb13106c972666a88dfe95620d55c856ce14db4 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Thu, 7 Sep 2023 14:10:14 -0600 Subject: [PATCH] drivers/smmstore: Retry APM SCI if it fails For some reason, the APM SCI to install the SMMSTORE comm buffer regularly, but not always, fails with 0x4ed on ADL. In this case, a second attempt seems to always complete successfully. Tested on system76/darp8 and system76/galp6. Change-Id: I843116113b8c24f1aee42f9d9042cdc0471a1b43 Signed-off-by: Tim Crawford --- src/drivers/smmstore/ramstage.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/drivers/smmstore/ramstage.c b/src/drivers/smmstore/ramstage.c index ef80e221bc..4d86506e2c 100644 --- a/src/drivers/smmstore/ramstage.c +++ b/src/drivers/smmstore/ramstage.c @@ -57,18 +57,22 @@ static void init_store(void *unused) printk(BIOS_INFO, "SMMSTORE: Setting up SMI handler\n"); - /* Issue SMI using APM to update the com buffer and to lock the SMMSTORE */ - __asm__ __volatile__ ( - "outb %%al, %%dx" - : "=a" (eax) - : "a" ((SMMSTORE_CMD_INIT << 8) | APM_CNT_SMMSTORE), - "b" (ebx), - "d" (APM_CNT) - : "memory"); + for (int retries = 0; retries < 3; retries++) { + /* Issue SMI using APM to update the com buffer and to lock the SMMSTORE */ + __asm__ __volatile__ ( + "outb %%al, %%dx" + : "=a" (eax) + : "a" ((SMMSTORE_CMD_INIT << 8) | APM_CNT_SMMSTORE), + "b" (ebx), + "d" (APM_CNT) + : "memory"); - if (eax != SMMSTORE_RET_SUCCESS) { - printk(BIOS_ERR, "SMMSTORE: Failed to install com buffer\n"); - return; + if (eax == SMMSTORE_RET_SUCCESS) { + printk(BIOS_INFO, "SMMSTORE: Installed com buffer\n"); + break; + } + + printk(BIOS_ERR, "SMMSTORE: Failed to install com buffer: 0x%x\n", eax); } }