Skip to content

Commit 5b13dc0

Browse files
mkopeccrawfxrd
authored andcommitted
drivers/smmstore/ramstage.c: retry smmstore init up 5 times
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ć <[email protected]>
1 parent f941def commit 5b13dc0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/drivers/smmstore/ramstage.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <smmstore.h>
1010
#include <types.h>
1111
#include <cbmem.h>
12+
#include <delay.h>
1213

1314
static struct smmstore_params_info info;
1415

@@ -39,6 +40,7 @@ static void init_store(void *unused)
3940
{
4041
struct smmstore_params_init args;
4142
uint32_t ret = ~0;
43+
uint8_t retry = 5;
4244

4345
if (smmstore_get_info(&info) < 0) {
4446
printk(BIOS_INFO, "SMMSTORE: Failed to get meta data\n");
@@ -56,8 +58,17 @@ static void init_store(void *unused)
5658

5759
printk(BIOS_INFO, "SMMSTORE: Setting up SMI handler\n");
5860

59-
/* Issue SMI using APM to update the com buffer and to lock the SMMSTORE */
60-
ret = call_smm(APM_CNT_SMMSTORE, SMMSTORE_CMD_INIT, &args);
61+
/*
62+
* Issue SMI using APM to update the com buffer and to lock the SMMSTORE.
63+
* Retry 5 times in case the SMI isn't triggered immediately.
64+
*/
65+
do {
66+
ret = call_smm(APM_CNT_SMMSTORE, SMMSTORE_CMD_INIT, &args);
67+
if (ret == SMMSTORE_RET_SUCCESS)
68+
break;
69+
70+
mdelay(1);
71+
} while (retry--);
6172

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

0 commit comments

Comments
 (0)