diff mbox series

hw/imc: Check for pause_microcode_at_boot() return status

Message ID 1523250044-29538-1-git-send-email-maddy@linux.vnet.ibm.com
State Accepted
Headers show
Series hw/imc: Check for pause_microcode_at_boot() return status | expand

Commit Message

maddy April 9, 2018, 5 a.m. UTC
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 <maddy@linux.vnet.ibm.com>
---
 hw/imc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Anju T Sudhakar April 9, 2018, 10:33 a.m. UTC | #1
On Monday 09 April 2018 10:30 AM, Madhavan Srinivasan wrote:
> 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 <maddy@linux.vnet.ibm.com>
> ---
>   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
Tested-by : Anju T Sudhakar <anju@linux.vnet.ibm.com>



Regards,
Anju
<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">&lt;maddy@linux.vnet.ibm.com&gt;</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-&gt;id);
 		if (cb)
 			cb-&gt;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">&lt;anju@linux.vnet.ibm.com&gt;</a><br>
    <br>
    <br>
    <br>
    Regards,<br>
    Anju<br>
  </body>
</html>
Stewart Smith April 10, 2018, 6:36 a.m. UTC | #2
Madhavan Srinivasan <maddy@linux.vnet.ibm.com> writes:
> 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 <maddy@linux.vnet.ibm.com>
> ---
>  hw/imc.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Should this also go to stable ?

Merged to master as of afc89188010b4b33c78357eb9af1064690d324cb
maddy April 10, 2018, 8:03 a.m. UTC | #3
On Tuesday 10 April 2018 12:06 PM, Stewart Smith wrote:
> Madhavan Srinivasan <maddy@linux.vnet.ibm.com> writes:
>> 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 <maddy@linux.vnet.ibm.com>
>> ---
>>   hw/imc.c | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
> Should this also go to stable ?

Stewart, yes it should also goto stable.

Thanks
Maddy

> Merged to master as of afc89188010b4b33c78357eb9af1064690d324cb
>
Stewart Smith April 12, 2018, 5:55 a.m. UTC | #4
Madhavan Srinivasan <maddy@linux.vnet.ibm.com> writes:
> On Tuesday 10 April 2018 12:06 PM, Stewart Smith wrote:
>> Madhavan Srinivasan <maddy@linux.vnet.ibm.com> writes:
>>> 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 <maddy@linux.vnet.ibm.com>
>>> ---
>>>   hw/imc.c | 9 +++++++--
>>>   1 file changed, 7 insertions(+), 2 deletions(-)
>> Should this also go to stable ?
>
> Stewart, yes it should also goto stable.

Okay.

I have no plans for a 5.11.x, but merged to 5.10.x as of:

129e7bc35534  skiboot-5.10.x
diff mbox series

Patch

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