Attention is currently required from: Fred Reitberger, Jason Glenesk, Matt DeVillier.

Felix Held has uploaded this change for review.

View Change

soc/amd/common/psp_smm: introduce and use send_psp_command_smm

When sending mailbox commands to the PSP from SMM, the SMM flag needs to
be set right before sending the mailbox command and cleared right after
the command is sent. In order to not have this code duplicated, factor
it out into a function.

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: I3628463dece9d11703d5a068fe7c604108b69c1f
---
M src/soc/amd/common/block/psp/psp_smm.c
1 file changed, 13 insertions(+), 6 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/00/83700/1
diff --git a/src/soc/amd/common/block/psp/psp_smm.c b/src/soc/amd/common/block/psp/psp_smm.c
index 9b130b6..bcb1c90 100644
--- a/src/soc/amd/common/block/psp/psp_smm.c
+++ b/src/soc/amd/common/block/psp/psp_smm.c
@@ -47,6 +47,17 @@
smm_flag = 0;
}

+static int send_psp_command_smm(u32 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
@@ -83,9 +94,7 @@

printk(BIOS_DEBUG, "PSP: Notify SMM info... ");

- set_smm_flag();
- cmd_status = send_psp_command(MBOX_BIOS_CMD_SMM_INFO, &buffer);
- clear_smm_flag();
+ cmd_status = send_psp_command_smm(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);
@@ -113,9 +122,7 @@

buffer->sleep_type = sleep_type;

- set_smm_flag();
- cmd_status = send_psp_command(MBOX_BIOS_CMD_SX_INFO, buffer);
- clear_smm_flag();
+ cmd_status = send_psp_command_smm(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);

To view, visit change 83700. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I3628463dece9d11703d5a068fe7c604108b69c1f
Gerrit-Change-Number: 83700
Gerrit-PatchSet: 1
Gerrit-Owner: Felix Held <felix-coreboot@felixheld.de>
Gerrit-Reviewer: Fred Reitberger <reitbergerfred@gmail.com>
Gerrit-Reviewer: Jason Glenesk <jason.glenesk@gmail.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Gerrit-Attention: Jason Glenesk <jason.glenesk@gmail.com>
Gerrit-Attention: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Gerrit-Attention: Fred Reitberger <reitbergerfred@gmail.com>