cpu/x86/smm: Use common APMC logging

Unify the debug messages on raised SMIs.

Change-Id: I34eeb41d929bfb18730ac821a63bde95ef9a0b3e
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/49248
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Kyösti Mälkki
2021-01-08 13:27:33 +02:00
parent 5e6e5c11c7
commit 9a1620f4ed
15 changed files with 35 additions and 77 deletions

View File

@@ -33,6 +33,7 @@ ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual
endif endif
smm-y += save_state.c smm-y += save_state.c
smm-y += smi_trigger.c
ifeq ($(CONFIG_SMM_TSEG),y) ifeq ($(CONFIG_SMM_TSEG),y)

View File

@@ -4,24 +4,23 @@
#include <console/console.h> #include <console/console.h>
#include <cpu/x86/smm.h> #include <cpu/x86/smm.h>
int apm_control(u8 cmd) static void apmc_log(const char *fn, u8 cmd)
{ {
if (!CONFIG(HAVE_SMI_HANDLER))
return -1;
switch (cmd) { switch (cmd) {
case APM_CNT_CST_CONTROL: case APM_CNT_CST_CONTROL:
printk(BIOS_DEBUG, "%s: C-state control.\n", fn);
break; break;
case APM_CNT_PST_CONTROL: case APM_CNT_PST_CONTROL:
printk(BIOS_DEBUG, "%s: P-state control.\n", fn);
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
printk(BIOS_DEBUG, "Disabling ACPI via APMC.\n"); printk(BIOS_DEBUG, "%s: Disabling ACPI.\n", fn);
break; break;
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
printk(BIOS_DEBUG, "Enabling ACPI via APMC.\n"); printk(BIOS_DEBUG, "%s: Enabling ACPI.\n", fn);
break; break;
case APM_CNT_FINALIZE: case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "Finalizing SMM.\n"); printk(BIOS_DEBUG, "%s: Finalizing SMM.\n", fn);
break; break;
case APM_CNT_ELOG_GSMI: case APM_CNT_ELOG_GSMI:
break; break;
@@ -30,8 +29,18 @@ int apm_control(u8 cmd)
case APM_CNT_SMMINFO: case APM_CNT_SMMINFO:
break; break;
default: default:
printk(BIOS_DEBUG, "%s: Unknown APMC 0x%02x.\n", fn, cmd);
break; break;
} }
}
int apm_control(u8 cmd)
{
/* Never proceed inside SMI handler or without one. */
if (ENV_SMM || !CONFIG(HAVE_SMI_HANDLER))
return -1;
apmc_log(__func__, cmd);
/* Now raise the SMI. */ /* Now raise the SMI. */
outb(cmd, APM_CNT); outb(cmd, APM_CNT);
@@ -39,3 +48,12 @@ int apm_control(u8 cmd)
printk(BIOS_DEBUG, "APMC done.\n"); printk(BIOS_DEBUG, "APMC done.\n");
return 0; return 0;
} }
u8 apm_get_apmc(void)
{
/* Emulate B2 register as the FADT / Linux expects it */
u8 cmd = inb(APM_CNT);
apmc_log("SMI#", cmd);
return cmd;
}

View File

@@ -33,6 +33,7 @@
/* Send cmd to APM_CNT with HAVE_SMI_HANDLER checking. */ /* Send cmd to APM_CNT with HAVE_SMI_HANDLER checking. */
int apm_control(u8 cmd); int apm_control(u8 cmd);
u8 apm_get_apmc(void);
void io_trap_handler(int smif); void io_trap_handler(int smif);
int southbridge_io_trap_handler(int smif); int southbridge_io_trap_handler(int smif);

View File

@@ -16,7 +16,6 @@ int mainboard_smi_apmc(u8 data)
u8 val; u8 val;
switch (data) { switch (data) {
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
printk(BIOS_SPEW, "%s: APM CNT EN: %02x\n", __func__, data);
/* Enable wake on PS2 */ /* Enable wake on PS2 */
val = inb(SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN1); val = inb(SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN1);
val |= (SCH5545_KBD_PME_EN | SCH5545_MOUSE_PME_EN); val |= (SCH5545_KBD_PME_EN | SCH5545_MOUSE_PME_EN);
@@ -26,7 +25,6 @@ int mainboard_smi_apmc(u8 data)
outb(SCH5545_GLOBAL_PME_EN, SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN); outb(SCH5545_GLOBAL_PME_EN, SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN);
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
printk(BIOS_SPEW, "%s: APM CNT DIS: %02x\n", __func__, data);
/* Disable wake on PS2 */ /* Disable wake on PS2 */
val = inb(SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN1); val = inb(SCH5545_RUNTIME_REG_BASE + SCH5545_RR_PME_EN1);
val &= ~(SCH5545_KBD_PME_EN | SCH5545_MOUSE_PME_EN); val &= ~(SCH5545_KBD_PME_EN | SCH5545_MOUSE_PME_EN);

View File

@@ -36,16 +36,13 @@ void mainboard_smi_sleep(u8 slp_typ)
int mainboard_smi_apmc(u8 apmc) int mainboard_smi_apmc(u8 apmc)
{ {
printk(BIOS_DEBUG, "mainboard_smi_apmc: %x\n", apmc);
switch (apmc) { switch (apmc) {
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
printk(BIOS_DEBUG, "APMC: ACPI_EN\n");
/* Clear all pending events and enable SCI */ /* Clear all pending events and enable SCI */
ec_write_cmd(EC_CMD_ENABLE_ACPI_MODE); ec_write_cmd(EC_CMD_ENABLE_ACPI_MODE);
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
printk(BIOS_DEBUG, "APMC: ACPI_DIS\n");
/* Clear all pending events and tell the EC that ACPI is disabled */ /* Clear all pending events and tell the EC that ACPI is disabled */
ec_write_cmd(EC_CMD_DISABLE_ACPI_MODE); ec_write_cmd(EC_CMD_DISABLE_ACPI_MODE);
break; break;

View File

@@ -66,10 +66,8 @@ void mainboard_smi_sleep(u8 slp_typ)
int mainboard_smi_apmc(u8 apmc) int mainboard_smi_apmc(u8 apmc)
{ {
printk(BIOS_DEBUG, "%s: %x\n", __func__, apmc);
switch (apmc) { switch (apmc) {
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
printk(BIOS_DEBUG, "APMC: ACPI_EN\n");
/* Clear all pending events */ /* Clear all pending events */
/* EC cmd:59 data:E8 */ /* EC cmd:59 data:E8 */
ec_kbc_write_cmd(0x59); ec_kbc_write_cmd(0x59);
@@ -79,7 +77,6 @@ int mainboard_smi_apmc(u8 apmc)
gpi_route_interrupt(EC_LID_GPI, GPI_IS_SCI); gpi_route_interrupt(EC_LID_GPI, GPI_IS_SCI);
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
printk(BIOS_DEBUG, "APMC: ACPI_DIS\n");
/* Clear all pending events */ /* Clear all pending events */
/* EC cmd:59 data:e9 */ /* EC cmd:59 data:e9 */
ec_kbc_write_cmd(0x59); ec_kbc_write_cmd(0x59);

View File

@@ -74,18 +74,14 @@ void mainboard_smi_gpi(u32 gpi_sts)
int mainboard_smi_apmc(u8 data) int mainboard_smi_apmc(u8 data)
{ {
printk(BIOS_INFO, "%s(%02x)\n", __func__, data);
switch (data) { switch (data) {
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
printk(BIOS_DEBUG, "Enable ACPI mode\n");
ec_enter_acpi_mode(); ec_enter_acpi_mode();
gpi_route_interrupt(GPE_EC_SCI, GPI_IS_SCI); gpi_route_interrupt(GPE_EC_SCI, GPI_IS_SCI);
gpi_route_interrupt(GPE_PALMDET1, GPI_IS_SCI); gpi_route_interrupt(GPE_PALMDET1, GPI_IS_SCI);
gpi_route_interrupt(GPE_PALMDET2, GPI_IS_SCI); gpi_route_interrupt(GPE_PALMDET2, GPI_IS_SCI);
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
printk(BIOS_DEBUG, "Disable ACPI mode\n");
ec_enter_apm_mode(); ec_enter_apm_mode();
gpi_route_interrupt(GPE_EC_SCI, GPI_IS_SMI); gpi_route_interrupt(GPE_EC_SCI, GPI_IS_SMI);
break; break;

View File

@@ -281,9 +281,7 @@ static void southbridge_smi_apmc(void)
{ {
uint8_t reg8; uint8_t reg8;
/* Emulate B2 register as the FADT / Linux expects it */ reg8 = apm_get_apmc();
reg8 = inb(APM_CNT);
switch (reg8) { switch (reg8) {
case APM_CNT_CST_CONTROL: case APM_CNT_CST_CONTROL:
/* /*
@@ -291,7 +289,6 @@ static void southbridge_smi_apmc(void)
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "C-state control\n");
break; break;
case APM_CNT_PST_CONTROL: case APM_CNT_PST_CONTROL:
/* /*
@@ -299,15 +296,12 @@ static void southbridge_smi_apmc(void)
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "P-state control\n");
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
disable_pm1_control(SCI_EN); disable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
break; break;
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
enable_pm1_control(SCI_EN); enable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
break; break;
case APM_CNT_ELOG_GSMI: case APM_CNT_ELOG_GSMI:
if (CONFIG(ELOG_GSMI)) if (CONFIG(ELOG_GSMI))

View File

@@ -260,9 +260,7 @@ static void southbridge_smi_apmc(void)
{ {
uint8_t reg8; uint8_t reg8;
/* Emulate B2 register as the FADT / Linux expects it */ reg8 = apm_get_apmc();
reg8 = inb(APM_CNT);
switch (reg8) { switch (reg8) {
case APM_CNT_CST_CONTROL: case APM_CNT_CST_CONTROL:
/* /*
@@ -270,7 +268,6 @@ static void southbridge_smi_apmc(void)
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "C-state control\n");
break; break;
case APM_CNT_PST_CONTROL: case APM_CNT_PST_CONTROL:
/* /*
@@ -278,15 +275,12 @@ static void southbridge_smi_apmc(void)
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "P-state control\n");
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
disable_pm1_control(SCI_EN); disable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
break; break;
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
enable_pm1_control(SCI_EN); enable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
break; break;
case APM_CNT_ELOG_GSMI: case APM_CNT_ELOG_GSMI:
if (CONFIG(ELOG_GSMI)) if (CONFIG(ELOG_GSMI))

View File

@@ -312,23 +312,17 @@ static void southbridge_smi_apmc(void)
{ {
u8 reg8; u8 reg8;
/* Emulate B2 register as the FADT / Linux expects it */ reg8 = apm_get_apmc();
reg8 = inb(APM_CNT);
switch (reg8) { switch (reg8) {
case APM_CNT_CST_CONTROL: case APM_CNT_CST_CONTROL:
printk(BIOS_DEBUG, "C-state control\n");
break; break;
case APM_CNT_PST_CONTROL: case APM_CNT_PST_CONTROL:
printk(BIOS_DEBUG, "P-state control\n");
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
disable_pm1_control(SCI_EN); disable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
break; break;
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
enable_pm1_control(SCI_EN); enable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
break; break;
case APM_CNT_ELOG_GSMI: case APM_CNT_ELOG_GSMI:
if (CONFIG(ELOG_GSMI)) if (CONFIG(ELOG_GSMI))

View File

@@ -331,9 +331,7 @@ void smihandler_southbridge_apmc(
{ {
uint8_t reg8; uint8_t reg8;
/* Emulate B2 register as the FADT / Linux expects it */ reg8 = apm_get_apmc();
reg8 = inb(APM_CNT);
switch (reg8) { switch (reg8) {
case APM_CNT_CST_CONTROL: case APM_CNT_CST_CONTROL:
/* /*
@@ -341,7 +339,6 @@ void smihandler_southbridge_apmc(
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "C-state control\n");
break; break;
case APM_CNT_PST_CONTROL: case APM_CNT_PST_CONTROL:
/* /*
@@ -349,15 +346,12 @@ void smihandler_southbridge_apmc(
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "P-state control\n");
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
pmc_disable_pm1_control(SCI_EN); pmc_disable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
break; break;
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
pmc_enable_pm1_control(SCI_EN); pmc_enable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
break; break;
case APM_CNT_ELOG_GSMI: case APM_CNT_ELOG_GSMI:
if (CONFIG(ELOG_GSMI)) if (CONFIG(ELOG_GSMI))

View File

@@ -220,31 +220,25 @@ static void southbridge_smi_apmc(void)
{ {
uint8_t reg8; uint8_t reg8;
/* Emulate B2 register as the FADT / Linux expects it */ reg8 = apm_get_apmc();
reg8 = inb(APM_CNT);
switch (reg8) { switch (reg8) {
case APM_CNT_CST_CONTROL: case APM_CNT_CST_CONTROL:
/* Calling this function seems to cause /* Calling this function seems to cause
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "C-state control\n");
break; break;
case APM_CNT_PST_CONTROL: case APM_CNT_PST_CONTROL:
/* Calling this function seems to cause /* Calling this function seems to cause
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "P-state control\n");
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
disable_pm1_control(SCI_EN); disable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
break; break;
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
enable_pm1_control(SCI_EN); enable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
break; break;
case APM_CNT_FINALIZE: case APM_CNT_FINALIZE:
finalize(); finalize();

View File

@@ -274,31 +274,25 @@ static void southbridge_smi_apmc(void)
{ {
u8 reg8; u8 reg8;
/* Emulate B2 register as the FADT / Linux expects it */ reg8 = apm_get_apmc();
reg8 = inb(APM_CNT);
switch (reg8) { switch (reg8) {
case APM_CNT_CST_CONTROL: case APM_CNT_CST_CONTROL:
/* Calling this function seems to cause /* Calling this function seems to cause
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "C-state control\n");
break; break;
case APM_CNT_PST_CONTROL: case APM_CNT_PST_CONTROL:
/* Calling this function seems to cause /* Calling this function seems to cause
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "P-state control\n");
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) & ~SCI_EN); write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) & ~SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
break; break;
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | SCI_EN); write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
break; break;
case APM_CNT_FINALIZE: case APM_CNT_FINALIZE:
if (mainboard_finalized) { if (mainboard_finalized) {

View File

@@ -297,38 +297,30 @@ static void southbridge_smi_apmc(void)
u32 pmctrl; u32 pmctrl;
u8 reg8; u8 reg8;
/* Emulate B2 register as the FADT / Linux expects it */ reg8 = apm_get_apmc();
reg8 = inb(APM_CNT);
switch (reg8) { switch (reg8) {
case APM_CNT_CST_CONTROL: case APM_CNT_CST_CONTROL:
/* Calling this function seems to cause /* Calling this function seems to cause
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "C-state control\n");
break; break;
case APM_CNT_PST_CONTROL: case APM_CNT_PST_CONTROL:
/* Calling this function seems to cause /* Calling this function seems to cause
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "P-state control\n");
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
pmctrl = inl(pmbase + PM1_CNT); pmctrl = inl(pmbase + PM1_CNT);
pmctrl &= ~SCI_EN; pmctrl &= ~SCI_EN;
outl(pmctrl, pmbase + PM1_CNT); outl(pmctrl, pmbase + PM1_CNT);
printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
break; break;
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
pmctrl = inl(pmbase + PM1_CNT); pmctrl = inl(pmbase + PM1_CNT);
pmctrl |= SCI_EN; pmctrl |= SCI_EN;
outl(pmctrl, pmbase + PM1_CNT); outl(pmctrl, pmbase + PM1_CNT);
printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
break; break;
default:
printk(BIOS_DEBUG, "SMI#: Unknown function APM_CNT=%02x\n", reg8);
} }
} }

View File

@@ -262,9 +262,7 @@ static void southbridge_smi_apmc(void)
u8 reg8; u8 reg8;
static int chipset_finalized = 0; static int chipset_finalized = 0;
/* Emulate B2 register as the FADT / Linux expects it */ reg8 = apm_get_apmc();
reg8 = inb(APM_CNT);
switch (reg8) { switch (reg8) {
case APM_CNT_FINALIZE: case APM_CNT_FINALIZE:
if (chipset_finalized) { if (chipset_finalized) {
@@ -284,22 +282,18 @@ static void southbridge_smi_apmc(void)
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "C-state control\n");
break; break;
case APM_CNT_PST_CONTROL: case APM_CNT_PST_CONTROL:
/* Calling this function seems to cause /* Calling this function seems to cause
* some kind of race condition in Linux * some kind of race condition in Linux
* and causes a kernel oops * and causes a kernel oops
*/ */
printk(BIOS_DEBUG, "P-state control\n");
break; break;
case APM_CNT_ACPI_DISABLE: case APM_CNT_ACPI_DISABLE:
disable_pm1_control(SCI_EN); disable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
break; break;
case APM_CNT_ACPI_ENABLE: case APM_CNT_ACPI_ENABLE:
enable_pm1_control(SCI_EN); enable_pm1_control(SCI_EN);
printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
break; break;
case APM_CNT_ROUTE_ALL_XHCI: case APM_CNT_ROUTE_ALL_XHCI:
usb_xhci_route_all(); usb_xhci_route_all();