diff mbox

powerpc/powernv: Check image loaded or not before calling flash

Message ID 20150212095323.1829.45732.stgit@localhost.localdomain (mailing list archive)
State Superseded
Headers show

Commit Message

Vasant Hegde Feb. 12, 2015, 9:53 a.m. UTC
Present code checks for update_flash_data in opal_flash_term_callback().
update_flash_data has been statically initialized to zero, and that
is the value of FLASH_IMG_READY. Also code update initialization happens
during subsys init.

So if reboot is issued before the subsys init stage then we endup displaying
"Flashing new firmware" message.. which may confuse end user.

This patch adds additional validation to make sure image is actually loaded
or not.

Reported-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Benjamin Herrenschmidt Feb. 12, 2015, 9:27 p.m. UTC | #1
On Thu, 2015-02-12 at 15:23 +0530, Vasant Hegde wrote:
> Present code checks for update_flash_data in opal_flash_term_callback().
> update_flash_data has been statically initialized to zero, and that
> is the value of FLASH_IMG_READY. Also code update initialization happens
> during subsys init.

Please statically initialize it to a sane value instead.

> So if reboot is issued before the subsys init stage then we endup displaying
> "Flashing new firmware" message.. which may confuse end user.
> 
> This patch adds additional validation to make sure image is actually loaded
> or not.
> 
> Reported-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
> ---
>  arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c
> index 5c21d9c..5455cd4 100644
> --- a/arch/powerpc/platforms/powernv/opal-flash.c
> +++ b/arch/powerpc/platforms/powernv/opal-flash.c
> @@ -319,7 +319,8 @@ void opal_flash_term_callback(void)
>  {
>  	struct cpumask mask;
>  
> -	if (update_flash_data.status != FLASH_IMG_READY)
> +	if (update_flash_data.status != FLASH_IMG_READY ||
> +	    image_data.status != IMAGE_READY)
>  		return;
>  
>  	pr_alert("FLASH: Flashing new firmware\n");
Sam Bobroff Feb. 13, 2015, 2:46 a.m. UTC | #2
On 13/02/15 08:27, Benjamin Herrenschmidt wrote:
> On Thu, 2015-02-12 at 15:23 +0530, Vasant Hegde wrote:
>> Present code checks for update_flash_data in opal_flash_term_callback().
>> update_flash_data has been statically initialized to zero, and that
>> is the value of FLASH_IMG_READY. Also code update initialization happens
>> during subsys init.
> 
> Please statically initialize it to a sane value instead.

I've tested this patch and it works for me (the message is suppressed)
but I agree with Ben that it seems cleaner to use a static initializer.

>> So if reboot is issued before the subsys init stage then we endup displaying
>> "Flashing new firmware" message.. which may confuse end user.
>>
>> This patch adds additional validation to make sure image is actually loaded
>> or not.
>>
>> Reported-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
>> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
>> ---
>>  arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c
>> index 5c21d9c..5455cd4 100644
>> --- a/arch/powerpc/platforms/powernv/opal-flash.c
>> +++ b/arch/powerpc/platforms/powernv/opal-flash.c
>> @@ -319,7 +319,8 @@ void opal_flash_term_callback(void)
>>  {
>>  	struct cpumask mask;
>>  
>> -	if (update_flash_data.status != FLASH_IMG_READY)
>> +	if (update_flash_data.status != FLASH_IMG_READY ||
>> +	    image_data.status != IMAGE_READY)
>>  		return;
>>  
>>  	pr_alert("FLASH: Flashing new firmware\n");
> 
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
Vasant Hegde Feb. 13, 2015, 5:52 a.m. UTC | #3
On 02/13/2015 02:57 AM, Benjamin Herrenschmidt wrote:
> On Thu, 2015-02-12 at 15:23 +0530, Vasant Hegde wrote:
>> Present code checks for update_flash_data in opal_flash_term_callback().
>> update_flash_data has been statically initialized to zero, and that
>> is the value of FLASH_IMG_READY. Also code update initialization happens
>> during subsys init.
> 
> Please statically initialize it to a sane value instead.

Ok. Will fix and send v2 soon. Thanks!


-Vasant

> 
>> So if reboot is issued before the subsys init stage then we endup displaying
>> "Flashing new firmware" message.. which may confuse end user.
>>
>> This patch adds additional validation to make sure image is actually loaded
>> or not.
>>
>> Reported-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
>> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
>> ---
>>  arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c
>> index 5c21d9c..5455cd4 100644
>> --- a/arch/powerpc/platforms/powernv/opal-flash.c
>> +++ b/arch/powerpc/platforms/powernv/opal-flash.c
>> @@ -319,7 +319,8 @@ void opal_flash_term_callback(void)
>>  {
>>  	struct cpumask mask;
>>  
>> -	if (update_flash_data.status != FLASH_IMG_READY)
>> +	if (update_flash_data.status != FLASH_IMG_READY ||
>> +	    image_data.status != IMAGE_READY)
>>  		return;
>>  
>>  	pr_alert("FLASH: Flashing new firmware\n");
> 
>
Vasant Hegde Feb. 13, 2015, 5:53 a.m. UTC | #4
On 02/13/2015 08:16 AM, Sam Bobroff wrote:
> On 13/02/15 08:27, Benjamin Herrenschmidt wrote:
>> On Thu, 2015-02-12 at 15:23 +0530, Vasant Hegde wrote:
>>> Present code checks for update_flash_data in opal_flash_term_callback().
>>> update_flash_data has been statically initialized to zero, and that
>>> is the value of FLASH_IMG_READY. Also code update initialization happens
>>> during subsys init.
>>
>> Please statically initialize it to a sane value instead.
> 
> I've tested this patch and it works for me (the message is suppressed)

Sam,

Thanks for testing!

-Vasant

> but I agree with Ben that it seems cleaner to use a static initializer.
> 
>>> So if reboot is issued before the subsys init stage then we endup displaying
>>> "Flashing new firmware" message.. which may confuse end user.
>>>
>>> This patch adds additional validation to make sure image is actually loaded
>>> or not.
>>>
>>> Reported-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
>>> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
>>> ---
>>>  arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c
>>> index 5c21d9c..5455cd4 100644
>>> --- a/arch/powerpc/platforms/powernv/opal-flash.c
>>> +++ b/arch/powerpc/platforms/powernv/opal-flash.c
>>> @@ -319,7 +319,8 @@ void opal_flash_term_callback(void)
>>>  {
>>>  	struct cpumask mask;
>>>  
>>> -	if (update_flash_data.status != FLASH_IMG_READY)
>>> +	if (update_flash_data.status != FLASH_IMG_READY ||
>>> +	    image_data.status != IMAGE_READY)
>>>  		return;
>>>  
>>>  	pr_alert("FLASH: Flashing new firmware\n");
>>
>>
>> _______________________________________________
>> Linuxppc-dev mailing list
>> Linuxppc-dev@lists.ozlabs.org
>> https://lists.ozlabs.org/listinfo/linuxppc-dev
>>
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
diff mbox

Patch

diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c
index 5c21d9c..5455cd4 100644
--- a/arch/powerpc/platforms/powernv/opal-flash.c
+++ b/arch/powerpc/platforms/powernv/opal-flash.c
@@ -319,7 +319,8 @@  void opal_flash_term_callback(void)
 {
 	struct cpumask mask;
 
-	if (update_flash_data.status != FLASH_IMG_READY)
+	if (update_flash_data.status != FLASH_IMG_READY ||
+	    image_data.status != IMAGE_READY)
 		return;
 
 	pr_alert("FLASH: Flashing new firmware\n");