Skip to content

Commit

Permalink
drivers/smmstore/ramstage.c: retry smmstore init up 5 times
Browse files Browse the repository at this point in the history
Retry calling the SMI 5 times in case the initial write to APM did not
cause SMM entry immediately.

Fixes occasional SMMSTORE initialization failure on Clevo NV4xPZ with
Intel i5-1240P processor. The issue was especially evident when all
logging in coreboot was disabled.

Based on SMMSTORE implementation in MrChromebox's fork of EDK2:
MrChromebox/edk2@27854bc

Change-Id: I8929af25c4f69873bbdd835fde5cb60fc324b6ab
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
  • Loading branch information
mkopec authored and crawfxrd committed Feb 20, 2024
1 parent f941def commit 5b13dc0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/drivers/smmstore/ramstage.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <smmstore.h>
#include <types.h>
#include <cbmem.h>
#include <delay.h>

static struct smmstore_params_info info;

Expand Down Expand Up @@ -39,6 +40,7 @@ static void init_store(void *unused)
{
struct smmstore_params_init args;
uint32_t ret = ~0;
uint8_t retry = 5;

if (smmstore_get_info(&info) < 0) {
printk(BIOS_INFO, "SMMSTORE: Failed to get meta data\n");
Expand All @@ -56,8 +58,17 @@ 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 */
ret = call_smm(APM_CNT_SMMSTORE, SMMSTORE_CMD_INIT, &args);
/*
* Issue SMI using APM to update the com buffer and to lock the SMMSTORE.
* Retry 5 times in case the SMI isn't triggered immediately.
*/
do {
ret = call_smm(APM_CNT_SMMSTORE, SMMSTORE_CMD_INIT, &args);
if (ret == SMMSTORE_RET_SUCCESS)
break;

mdelay(1);
} while (retry--);

if (ret != SMMSTORE_RET_SUCCESS) {
printk(BIOS_ERR, "SMMSTORE: Failed to install com buffer\n");
Expand Down

0 comments on commit 5b13dc0

Please sign in to comment.