astbmc: Only mbox_init() if we mbox_flash_init()

Message ID 20181005131254.24662-1-andrew@aj.id.au
State New
Headers show
Series
  • astbmc: Only mbox_init() if we mbox_flash_init()
Related show

Checks

Context Check Description
snowpatch_ozlabs/make_check success Test make_check on branch master
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied

Commit Message

Andrew Jeffery Oct. 5, 2018, 1:12 p.m.
Avoid setting up the hardware if we're not going to use it. Setting it
up without using it is actively harmful as it prevents us succesfully
entering Petitboot (we exit skiboot with locks held and checkstop the
machine).

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 libflash/mbox-flash.c     | 6 ++++++
 platforms/astbmc/common.c | 2 --
 2 files changed, 6 insertions(+), 2 deletions(-)

Patch

diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c
index 3239be964b57..11ec90523d58 100644
--- a/libflash/mbox-flash.c
+++ b/libflash/mbox-flash.c
@@ -1134,6 +1134,12 @@  int mbox_flash_init(struct blocklevel_device **bl)
 	if (!bl)
 		return FLASH_ERR_PARM_ERROR;
 
+	/* XXX: We only support one blocklevel flash device over mbox. If we
+	 * ever support more than one, move this out. The chances of that are
+	 * slim though due to circumstances.
+	 */
+	mbox_init();
+
 	*bl = NULL;
 
 	mbox_flash = zalloc(sizeof(struct mbox_flash_data));
diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c
index a616f24fd863..10aed3f72901 100644
--- a/platforms/astbmc/common.c
+++ b/platforms/astbmc/common.c
@@ -419,8 +419,6 @@  void astbmc_early_init(void)
 	/* Setup UART and use it as console */
 	uart_init();
 
-	mbox_init();
-
 	prd_init();
 }