Skip to contentSkip to conversation

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

PATCH In review Vasant Hegde 3 participants 7 messages Feb 12, 2015 – Feb 13, 2015 PowerPC

lore
Share & tools
lore
#0 lore raw

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

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.

---
 arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/opal-flash.c +2 -1
index 5c21d9c..5455cd4 100644
@@ -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");
#1 lore raw
Quoted 4 lines · Vasant Hegde

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.

Quoted 26 lines

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.

---
 arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/opal-flash.c +2 -1
index 5c21d9c..5455cd4 100644
@@ -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");
#2 lore raw
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 4 lines · Vasant Hegde

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.

Quoted 33 lines
Quoted 17 lines

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.

---
 arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/opal-flash.c +0 -0
index 5c21d9c..5455cd4 100644

arch/powerpc/platforms/powernv/opal-flash.c void opal_flash_term_callback(void) · line 326

Quoted 9 lines
arch/powerpc/platforms/powernv/opal-flash.c +2 -1
@@ -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
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#3 lore raw
Quoted 10 lines · Sam Bobroff
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 4 lines · Vasant Hegde

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

Quoted 41 lines

but I agree with Ben that it seems cleaner to use a static initializer.

Quoted 25 lines
Quoted 25 lines

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.

---
 arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/opal-flash.c +2 -1
index 5c21d9c..5455cd4 100644
@@ -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;
 
Quoted 8 lines

arch/powerpc/platforms/powernv/opal-flash.c void opal_flash_term_callback(void) · line 326

Quoted 1 line
arch/powerpc/platforms/powernv/opal-flash.c +0 -0
 	pr_alert("FLASH: Flashing new firmware\n");

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#4 lore raw
In reply to Benjamin Herrenschmidt
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 4 lines · Vasant Hegde

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

Quoted 29 lines
Quoted 27 lines

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.

---
 arch/powerpc/platforms/powernv/opal-flash.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/opal-flash.c +2 -1
index 5c21d9c..5455cd4 100644
@@ -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");
#5 lore raw

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

In reply to Vasant Hegde

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 fixes above described issue by initializes update_flash status to invalid state.

---
Ben, Sam,
How about this patch?

Initially I though of changing FLASH_IMG_READY value. But it has a impact on user space tool. (update_flash checks this value before calling reboot. See update_show function. Of course we can work around that .. But I thought this one is simpler approach.

-Vasant

 arch/powerpc/platforms/powernv/opal-flash.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/opal-flash.c +5 -1
index 5c21d9c..0ff07ff 100644
@@ -120,7 +120,11 @@ static struct image_header_t	image_header;
 static struct image_data_t	image_data;
 static struct validate_flash_t	validate_flash_data;
 static struct manage_flash_t	manage_flash_data;
-static struct update_flash_t	update_flash_data;
+
+/* Initialize update_flash_data status to No Operation */
+static struct update_flash_t	update_flash_data = {
+	.status = FLASH_NO_OP,
+};
 
 static DEFINE_MUTEX(image_data_mutex);
 
#6 lore raw

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

In reply to Vasant Hegde

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 fixes above described issue by initializes update_flash status to invalid state.

---
 arch/powerpc/platforms/powernv/opal-flash.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/opal-flash.c +5 -1
index 5c21d9c..0ff07ff 100644
@@ -120,7 +120,11 @@ static struct image_header_t	image_header;
 static struct image_data_t	image_data;
 static struct validate_flash_t	validate_flash_data;
 static struct manage_flash_t	manage_flash_data;
-static struct update_flash_t	update_flash_data;
+
+/* Initialize update_flash_data status to No Operation */
+static struct update_flash_t	update_flash_data = {
+	.status = FLASH_NO_OP,
+};
 
 static DEFINE_MUTEX(image_data_mutex);