<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<br>
<br>
<div class="moz-cite-prefix">Le 26/04/2023 à 17:26, Frederic Barrat
a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:9d4caa49-bb2f-2c7a-b76c-672f3c6f00cb@linux.ibm.com">
<br>
<br>
On 29/04/2022 11:47, Christophe Lombard wrote:
<br>
<blockquote type="cite">Last BMC firmware is available with a
complete PLDM support on Rainier
<br>
system.
<br>
This patch allows initially to:
<br>
- Initialize the MCTP core.
<br>
- Enable the mctp binding over LPC bus interface and new
wrappers to send
<br>
and receive PLDM messages over the mctp library.
<br>
- Retrieve all needed PLDM data.
<br>
- "Virtualize" the content of a BMC flash based on lid files.
<br>
<br>
Then, others mandatory support (watchdog, opal rtc, opal ipmi)
are enabled.
<br>
<br>
Signed-off-by: Christophe Lombard
<a class="moz-txt-link-rfc2396E" href="mailto:clombard@linux.vnet.ibm.com"><clombard@linux.vnet.ibm.com></a>
<br>
---
<br>
core/init.c | 22 +++++++++++++++++++++-
<br>
core/pldm/pldm-common.c | 11 +++++++++++
<br>
include/pldm.h | 2 ++
<br>
platforms/astbmc/astbmc.h | 4 ++++
<br>
platforms/astbmc/common.c | 37
+++++++++++++++++++++++++++++++++++++
<br>
platforms/astbmc/pnor.c | 25 +++++++++++++++++++++++++
<br>
platforms/astbmc/rainier.c | 33
+++++++++++++++++++++++++++++----
<br>
7 files changed, 129 insertions(+), 5 deletions(-)
<br>
<br>
diff --git a/core/init.c b/core/init.c
<br>
index a1fd5f2b..f8492e2d 100644
<br>
--- a/core/init.c
<br>
+++ b/core/init.c
<br>
@@ -34,6 +34,7 @@
<br>
#include <libfdt/libfdt.h>
<br>
#include <timer.h>
<br>
#include <ipmi.h>
<br>
+#include <pldm.h>
<br>
#include <sensor.h>
<br>
#include <xive.h>
<br>
#include <nvram.h>
<br>
@@ -561,8 +562,15 @@ void __noreturn load_and_boot_kernel(bool
is_reboot)
<br>
trustedboot_exit_boot_services();
<br>
+#ifdef CONFIG_PLDM
<br>
+ if (pldm_present())
<br>
+ pldm_platform_send_progress_state_change(
<br>
+ PLDM_STATE_SET_BOOT_PROG_STATE_STARTING_OP_SYS);
<br>
+ else
<br>
+ ipmi_set_fw_progress_sensor(IPMI_FW_OS_BOOT);
<br>
</blockquote>
<br>
<br>
Not specific to this patch, but for all the cases where we try
PLDM first and fall back in IPMI: I'm wondering how this is going
to age and whether we should go full PLDM or nothing. Are we sure
we're not going to end up in some weird state where some of the
config is PLDM and some is IPMI?
<br>
<br>
Fred
<br>
<br>
</blockquote>
<br>
<span class="HwtZe" lang="en"><span class="jCAhz ChMk0b"><span
class="ryNqvb">Normally we shouldn't have a hybrid state where
one part of skiboot uses pdlm and the other ipmi.</span></span>
<span class="jCAhz ChMk0b"><span class="ryNqvb"><br>
The idea is only in case of pldm issue, we switch completely
to IPMI<br>
<br>
</span></span></span>
<blockquote type="cite"
cite="mid:9d4caa49-bb2f-2c7a-b76c-672f3c6f00cb@linux.ibm.com">
<blockquote type="cite">+#else
<br>
ipmi_set_fw_progress_sensor(IPMI_FW_OS_BOOT);
<br>
-
<br>
+#endif
<br>
if (!is_reboot) {
<br>
/* We wait for the nvram read to complete here so we
can
<br>
@@ -1372,10 +1380,22 @@ void __noreturn __nomcount
main_cpu_entry(const void *fdt)
<br>
/* Setup ibm,firmware-versions if able */
<br>
if (platform.bmc) {
<br>
flash_dt_add_fw_version();
<br>
+#ifdef CONFIG_PLDM
<br>
+ pldm_fru_dt_add_bmc_version();
<br>
+#else
<br>
ipmi_dt_add_bmc_info();
<br>
+#endif
<br>
}
<br>
+#ifdef CONFIG_PLDM
<br>
+ if (pldm_present())
<br>
+ pldm_platform_send_progress_state_change(
<br>
+
PLDM_STATE_SET_BOOT_PROG_STATE_PCI_RESORUCE_CONFIG);
<br>
+ else
<br>
+ ipmi_set_fw_progress_sensor(IPMI_FW_PCI_INIT);
<br>
+#else
<br>
ipmi_set_fw_progress_sensor(IPMI_FW_PCI_INIT);
<br>
+#endif
<br>
/*
<br>
* These last few things must be done as late as possible
<br>
diff --git a/core/pldm/pldm-common.c b/core/pldm/pldm-common.c
<br>
index 50f86948..42bce415 100644
<br>
--- a/core/pldm/pldm-common.c
<br>
+++ b/core/pldm/pldm-common.c
<br>
@@ -10,6 +10,13 @@
<br>
#include <ast.h>
<br>
#include "pldm.h"
<br>
+bool pldm_enabled;
<br>
+
<br>
+bool pldm_present(void)
<br>
+{
<br>
+ return pldm_enabled;
<br>
+}
<br>
+
<br>
/*
<br>
* Print content of PLDM message in hex mode.
<br>
* 15 bytes per line.
<br>
@@ -136,6 +143,8 @@ int pldm_mctp_init(void)
<br>
goto out;
<br>
}
<br>
+ pldm_enabled = true;
<br>
+
<br>
/* Get PDRs data */
<br>
rc = pldm_platform_init();
<br>
if (rc) {
<br>
@@ -162,6 +171,8 @@ out:
<br>
void pldm_mctp_exit(void)
<br>
{
<br>
+ pldm_enabled = false;
<br>
+
<br>
pldm_platform_exit();
<br>
ast_mctp_exit();
<br>
diff --git a/include/pldm.h b/include/pldm.h
<br>
index 8a91ee99..7e7e3b93 100644
<br>
--- a/include/pldm.h
<br>
+++ b/include/pldm.h
<br>
@@ -8,6 +8,8 @@
<br>
#include <skiboot.h>
<br>
#include <pldm/libpldm/state_set.h>
<br>
+bool pldm_present(void);
<br>
+
<br>
/**
<br>
* PLDM over MCTP initialization
<br>
*/
<br>
diff --git a/platforms/astbmc/astbmc.h
b/platforms/astbmc/astbmc.h
<br>
index 00f22123..7783fe20 100644
<br>
--- a/platforms/astbmc/astbmc.h
<br>
+++ b/platforms/astbmc/astbmc.h
<br>
@@ -96,6 +96,10 @@ extern const struct bmc_platform
bmc_plat_ast2600_openbmc;
<br>
extern void astbmc_early_init(void);
<br>
extern int64_t astbmc_ipmi_reboot(void);
<br>
extern int64_t astbmc_ipmi_power_down(uint64_t request);
<br>
+#ifdef CONFIG_PLDM
<br>
+extern int astbmc_pldm_init(void);
<br>
+extern int pnor_pldm_init(void);
<br>
+#endif
<br>
extern void astbmc_init(void);
<br>
extern void astbmc_ext_irq_serirq_cpld(unsigned int chip_id);
<br>
extern int pnor_init(void);
<br>
diff --git a/platforms/astbmc/common.c
b/platforms/astbmc/common.c
<br>
index 83ef70ad..a6f52a38 100644
<br>
--- a/platforms/astbmc/common.c
<br>
+++ b/platforms/astbmc/common.c
<br>
@@ -9,6 +9,7 @@
<br>
#include <xscom.h>
<br>
#include <ast.h>
<br>
#include <ipmi.h>
<br>
+#include <pldm.h>
<br>
#include <bt.h>
<br>
#include <errorlog.h>
<br>
#include <lpc.h>
<br>
@@ -104,6 +105,38 @@ static int astbmc_fru_init(void)
<br>
return 0;
<br>
}
<br>
+#ifdef CONFIG_PLDM
<br>
+int astbmc_pldm_init(void)
<br>
+{
<br>
+ int rc;
<br>
+
<br>
+ /* PLDM over MCTP */
<br>
+ rc = pldm_mctp_init();
<br>
+ if (rc)
<br>
+ goto err;
<br>
+
<br>
+ /* Initialize PNOR/NVRAM */
<br>
+ rc = pnor_pldm_init();
<br>
+ if (rc)
<br>
+ goto err;
<br>
+
<br>
+ /* Initialize elog */
<br>
+ elog_init();
<br>
+
<br>
+ pldm_watchdog_init();
<br>
+ pldm_rtc_init();
<br>
+ /*pldm_opal_init(); FIXME */
<br>
+
<br>
+ /* Setup UART console for use by Linux via OPAL API */
<br>
+ set_opal_console(&uart_opal_con);
<br>
+
<br>
+ return OPAL_SUCCESS;
<br>
+
<br>
+err:
<br>
+ prlog(PR_WARNING, "Failed to configure PLDM\n");
<br>
+ return rc;
<br>
+}
<br>
+#endif
<br>
void astbmc_init(void)
<br>
{
<br>
@@ -501,6 +534,10 @@ void astbmc_early_init(void)
<br>
void astbmc_exit(void)
<br>
{
<br>
+#ifdef CONFIG_PLDM
<br>
+ if (pldm_present())
<br>
+ return;
<br>
+#endif
<br>
ipmi_wdt_final_reset();
<br>
}
<br>
diff --git a/platforms/astbmc/pnor.c b/platforms/astbmc/pnor.c
<br>
index 64f2249d..853da467 100644
<br>
--- a/platforms/astbmc/pnor.c
<br>
+++ b/platforms/astbmc/pnor.c
<br>
@@ -5,6 +5,7 @@
<br>
#include <device.h>
<br>
#include <console.h>
<br>
#include <opal.h>
<br>
+#include <pldm.h>
<br>
#include <libflash/ipmi-hiomap.h>
<br>
#include <libflash/mbox-flash.h>
<br>
#include <libflash/libflash.h>
<br>
@@ -32,6 +33,30 @@ static enum ast_flash_style
ast_flash_get_fallback_style(void)
<br>
return raw_mem;
<br>
}
<br>
+#ifdef CONFIG_PLDM
<br>
+int pnor_pldm_init(void)
<br>
+{
<br>
+ struct blocklevel_device *bl = NULL;
<br>
+ int rc = 0;
<br>
+
<br>
+ rc = pldm_lid_files_init(&bl);
<br>
+ if (rc) {
<br>
+ prerror("PLAT: Failed to init PNOR driver\n");
<br>
+ goto fail;
<br>
+ }
<br>
+
<br>
+ rc = flash_register(bl);
<br>
+ if (!rc)
<br>
+ return 0;
<br>
+
<br>
+fail:
<br>
+ if (bl)
<br>
+ pldm_lid_files_exit(bl);
<br>
+
<br>
+ return rc;
<br>
+}
<br>
+#endif
<br>
+
<br>
int pnor_init(void)
<br>
{
<br>
struct spi_flash_ctrl *pnor_ctrl = NULL;
<br>
diff --git a/platforms/astbmc/rainier.c
b/platforms/astbmc/rainier.c
<br>
index 3e21e1b9..26ce6acf 100644
<br>
--- a/platforms/astbmc/rainier.c
<br>
+++ b/platforms/astbmc/rainier.c
<br>
@@ -6,6 +6,7 @@
<br>
#include <skiboot.h>
<br>
#include <device.h>
<br>
#include <ipmi.h>
<br>
+#include <pldm.h>
<br>
#include <pau.h>
<br>
#include <chip.h>
<br>
#include <i2c.h>
<br>
@@ -321,9 +322,33 @@ static void
rainier_pau_create_i2c_bus(void)
<br>
}
<br>
}
<br>
+static int64_t rainier_power_down(uint64_t request)
<br>
+{
<br>
+#ifdef CONFIG_PLDM
<br>
+ /* Issue a PLDM request for a Off-Soft Graceful */
<br>
+ if (pldm_present())
<br>
+ return pldm_platform_power_off();
<br>
+#endif
<br>
+ return astbmc_ipmi_power_down(request);
<br>
+}
<br>
+
<br>
+static int64_t rainier_reboot(void)
<br>
+{
<br>
+#ifdef CONFIG_PLDM
<br>
+ /* Issue a PLDM request for a graceful restart */
<br>
+ if (pldm_present())
<br>
+ return pldm_platform_restart();
<br>
+#endif
<br>
+ return astbmc_ipmi_reboot();
<br>
+}
<br>
+
<br>
static void rainier_init(void)
<br>
{
<br>
- astbmc_init();
<br>
+#ifdef CONFIG_PLDM
<br>
+ if (astbmc_pldm_init())
<br>
+#endif
<br>
+ astbmc_init();
<br>
+
<br>
rainier_init_slot_power();
<br>
}
<br>
@@ -365,9 +390,9 @@ DECLARE_PLATFORM(rainier) = {
<br>
.start_preload_resource = flash_start_preload_resource,
<br>
.resource_loaded = flash_resource_loaded,
<br>
.bmc = &bmc_plat_ast2600_openbmc,
<br>
- .cec_power_down = astbmc_ipmi_power_down,
<br>
- .cec_reboot = astbmc_ipmi_reboot,
<br>
- .elog_commit = ipmi_elog_commit,
<br>
+ .cec_power_down = rainier_power_down,
<br>
+ .cec_reboot = rainier_reboot,
<br>
+ .elog_commit = ipmi_elog_commit, /* FIXME */
<br>
.pau_device_detect = rainier_pau_device_detect,
<br>
.ocapi = &rainier_ocapi,
<br>
.exit = astbmc_exit,
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>