<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On Monday 09 April 2018 10:30 AM,
      Madhavan Srinivasan wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:1523250044-29538-1-git-send-email-maddy@linux.vnet.ibm.com">
      <pre wrap="">pause_microcode_at_boot() loops through all the chip's ucode
control block and pause the ucode if it is in the running state.
But it does not fail if any of the chip's ucode is not initialised.

Add code to return a failure if ucode is not initialized in any
of the chip. Since pause_microcode_at_boot() is called just before
attaching the IMC device nodes in imc_init(), add code to check for
the function return.

Fixes: 9750eee802f8d ('hw/imc: pause microcode at boot')
Signed-off-by: Madhavan Srinivasan <a class="moz-txt-link-rfc2396E" href="mailto:maddy@linux.vnet.ibm.com"><maddy@linux.vnet.ibm.com></a>
---
 hw/imc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/imc.c b/hw/imc.c
index a56f33677096..c567429ec5f4 100644
--- a/hw/imc.c
+++ b/hw/imc.c
@@ -164,7 +164,7 @@ static struct imc_chip_cb *get_imc_cb(uint32_t chip_id)
        return cb;
 }
 
-static void pause_microcode_at_boot(void)
+static int pause_microcode_at_boot(void)
 {
        struct proc_chip *chip;
        struct imc_chip_cb *cb;
@@ -173,7 +173,11 @@ static void pause_microcode_at_boot(void)
                cb = get_imc_cb(chip->id);
                if (cb)
                        cb->imc_chip_command =  cpu_to_be64(NEST_IMC_DISABLE);
+               else
+                       return -1; /* ucode is not init-ed */
        }
+
+       return 0;
 }
 
 /*
@@ -606,7 +610,8 @@ imc_mambo:
         * then out to band tools will race with ucode and end up getting
         * undesirable values. Hence pause the ucode if it is already running.
         */
-       pause_microcode_at_boot();
+       if (pause_microcode_at_boot())
+               goto err;
 
        /*
         * If the dt_attach_root() fails, "imc-counters" node will not be
</pre>
    </blockquote>
    Tested-by : Anju T Sudhakar <a class="moz-txt-link-rfc2396E"
      href="mailto:anju@linux.vnet.ibm.com"><anju@linux.vnet.ibm.com></a><br>
    <br>
    <br>
    <br>
    Regards,<br>
    Anju<br>
  </body>
</html>