soc/amd/common/block/psp: Drop send_psp_command_smm

Drop send_psp_command_smm() and let the generic send_psp_command()
method handle SMM as special case. This allows to use the same
method in regular code and SMM.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Change-Id: I5dad79e80b97e9d4dfbcd0d84d49eb23ea3f83cc
Reviewed-on: https://review.coreboot.org/c/coreboot/+/91702
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Patrick Rudolph 2026-02-26 10:04:44 +01:00 committed by Matt DeVillier
commit dc315c8f51
4 changed files with 41 additions and 25 deletions

View file

@ -175,4 +175,7 @@ enum cb_err soc_read_c2p38(uint32_t *msg_38_value);
void enable_psp_smi(void);
void psp_set_smm_flag(void);
void psp_clear_smm_flag(void);
#endif /* __AMD_PSP_DEF_H__ */

View file

@ -115,6 +115,7 @@ static int wait_command(struct pspv1_mbox *mbox)
int send_psp_command(uint32_t command, void *buffer)
{
struct pspv1_mbox *mbox = soc_get_mbox_address();
int ret = 0;
if (!mbox)
return -PSPSTS_NOBASE;
@ -132,19 +133,30 @@ int send_psp_command(uint32_t command, void *buffer)
if (wait_command(mbox))
return -PSPSTS_CMD_TIMEOUT;
if (ENV_SMM)
psp_set_smm_flag();
/* set address of command-response buffer and write command register */
wr_mbox_cmd_resp(mbox, buffer);
wr_mbox_cmd(mbox, command);
/* PSP clears command register when complete */
if (wait_command(mbox))
return -PSPSTS_CMD_TIMEOUT;
if (wait_command(mbox)) {
ret = -PSPSTS_CMD_TIMEOUT;
goto out;
}
/* check delivery status */
if (rd_mbox_sts(mbox) & (PSPV1_STATUS_ERROR | PSPV1_STATUS_TERMINATED))
return -PSPSTS_SEND_ERROR;
if (rd_mbox_sts(mbox) & (PSPV1_STATUS_ERROR | PSPV1_STATUS_TERMINATED)) {
ret = -PSPSTS_SEND_ERROR;
goto out;
}
return 0;
out:
if (ENV_SMM)
psp_clear_smm_flag();
return ret;
}
/*

View file

@ -152,6 +152,8 @@ static int wait_command(uintptr_t psp_mmio, bool wait_for_ready)
int send_psp_command(uint32_t command, void *buffer)
{
const uintptr_t psp_mmio = get_psp_mmio_base();
int ret = 0;
if (!psp_mmio)
return -PSPSTS_NOBASE;
@ -161,20 +163,30 @@ int send_psp_command(uint32_t command, void *buffer)
if (wait_command(psp_mmio, true))
return -PSPSTS_CMD_TIMEOUT;
if (ENV_SMM)
psp_set_smm_flag();
/* set address of command-response buffer and write command register */
wr_mbox_buffer_ptr(psp_mmio, buffer);
wr_mbox_cmd(psp_mmio, command);
/* PSP clears command register when complete. All commands except
* SxInfo set the Ready bit. */
if (wait_command(psp_mmio, command != MBOX_BIOS_CMD_SX_INFO))
return -PSPSTS_CMD_TIMEOUT;
if (wait_command(psp_mmio, command != MBOX_BIOS_CMD_SX_INFO)) {
ret = -PSPSTS_CMD_TIMEOUT;
goto out;
}
/* check delivery status */
if (rd_mbox_sts(psp_mmio))
return -PSPSTS_SEND_ERROR;
if (rd_mbox_sts(psp_mmio)) {
ret = -PSPSTS_SEND_ERROR;
goto out;
}
return 0;
out:
if (ENV_SMM)
psp_clear_smm_flag();
return ret;
}
enum cb_err psp_get_psp_capabilities(uint32_t *capabilities)

View file

@ -36,27 +36,16 @@ struct {
*/
static uint32_t smm_flag;
static void set_smm_flag(void)
void psp_set_smm_flag(void)
{
smm_flag = 1;
}
static void clear_smm_flag(void)
void psp_clear_smm_flag(void)
{
smm_flag = 0;
}
static int send_psp_command_smm(uint32_t command, void *buffer)
{
int cmd_status;
set_smm_flag();
cmd_status = send_psp_command(command, buffer);
clear_smm_flag();
return cmd_status;
}
/*
* The MBOX_BIOS_CMD_SMM_INFO PSP mailbox command doesn't necessarily need be sent from SMM,
* but doing so allows the linker to sort out the addresses of c2p_buffer, p2c_buffer and
@ -101,7 +90,7 @@ int psp_notify_smm(void)
printk(BIOS_DEBUG, "PSP: Notify SMM info... ");
cmd_status = send_psp_command_smm(MBOX_BIOS_CMD_SMM_INFO, &buffer);
cmd_status = send_psp_command(MBOX_BIOS_CMD_SMM_INFO, &buffer);
/* buffer's status shouldn't change but report it if it does */
psp_print_cmd_status(cmd_status, &buffer.header);
@ -129,7 +118,7 @@ void psp_notify_sx_info(uint8_t sleep_type)
buffer->sleep_type = sleep_type;
cmd_status = send_psp_command_smm(MBOX_BIOS_CMD_SX_INFO, buffer);
cmd_status = send_psp_command(MBOX_BIOS_CMD_SX_INFO, buffer);
/* buffer's status shouldn't change but report it if it does */
psp_print_cmd_status(cmd_status, &buffer->header);