Skip to contentSkip to conversation

powerpc/powernv/flash: Check OPAL flash calls exist before using

PATCH Applied Vasant Hegde 3 participants 5 messages Sep 14, 2021 – May 24, 2022 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/powernv/flash: Check OPAL flash calls exist before using

Currently only FSP based powernv systems supports firmware update interfaces. Hence check that the token OPAL_FLASH_VALIDATE exists before initalising the flash driver.

---
 arch/powerpc/platforms/powernv/opal-flash.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/platforms/powernv/opal-flash.c +4 -0
index 7e7d38b17420..05490fc22fae 100644
@@ -520,6 +520,10 @@ void __init opal_flash_update_init(void)
 {
 	int ret;
 
+	/* Firmware update is not supported by firmware */
+	if (!opal_check_token(OPAL_FLASH_VALIDATE))
+		return;
+
 	/* Allocate validate image buffer */
 	validate_flash_data.buf = kzalloc(VALIDATE_BUF_SIZE, GFP_KERNEL);
 	if (!validate_flash_data.buf) {
Signature · 1 line
2.31.1
#1 lore raw
Quoted 14 lines · Vasant Hegde

Currently only FSP based powernv systems supports firmware update interfaces. Hence check that the token OPAL_FLASH_VALIDATE exists before initalising the flash driver.

---
 arch/powerpc/platforms/powernv/opal-flash.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/platforms/powernv/opal-flash.c +0 -0
index 7e7d38b17420..05490fc22fae 100644

arch/powerpc/platforms/powernv/opal-flash.c void __init opal_flash_update_init(void) · line 526

Quoted 7 lines
arch/powerpc/platforms/powernv/opal-flash.c +4 -0
@@ -520,6 +520,10 @@ void __init opal_flash_update_init(void)
 {
 	int ret;
 
+	/* Firmware update is not supported by firmware */
+	if (!opal_check_token(OPAL_FLASH_VALIDATE))
+		return;
+

That will mean the following files no longer appear on BMC systems:

/sys/firmware/opal/image
/sys/firmware/opal/validate_flash
/sys/firmware/opal/manage_flash
/sys/firmware/opal/update_flash

Presumably those files don't actually work correctly, but are we sure their mere existence isn't used by anything at all?

We've had trouble in the past where removing sysfs files breaks tools unexpectedly, see smt_snooze_delay.

cheers

#2 lore raw
Quoted 18 lines · Michael Ellerman
Quoted 17 lines · Vasant Hegde

Currently only FSP based powernv systems supports firmware update interfaces. Hence check that the token OPAL_FLASH_VALIDATE exists before initalising the flash driver.

---
  arch/powerpc/platforms/powernv/opal-flash.c | 4 ++++
  1 file changed, 4 insertions(+)
arch/powerpc/platforms/powernv/opal-flash.c +0 -0
index 7e7d38b17420..05490fc22fae 100644
@@ -520,6 +520,10 @@ void __init opal_flash_update_init(void)
  {
  	int ret;
 
Quoted 5 lines

arch/powerpc/platforms/powernv/opal-flash.c void __init opal_flash_update_init(void) · line 526

Quoted 4 lines
arch/powerpc/platforms/powernv/opal-flash.c +4 -0
+	/* Firmware update is not supported by firmware */
+	if (!opal_check_token(OPAL_FLASH_VALIDATE))
+		return;
+

Michael,

Quoted 9 lines

That will mean the following files no longer appear on BMC systems:

/sys/firmware/opal/image
/sys/firmware/opal/validate_flash
/sys/firmware/opal/manage_flash
/sys/firmware/opal/update_flash

Presumably those files don't actually work correctly, but are we sure their mere existence isn't used by anything at all?

That's correct. We never used these files/interfaces on BMC based systems.

Quoted 3 lines

We've had trouble in the past where removing sysfs files breaks tools unexpectedly, see smt_snooze_delay.

AFAIK only update_flash uses these interfaces on baremetal systems. This change shouldn't break update_flash as these interfaces never used/worked on BMC based powernv systems.

-Vasant

#3 lore raw
In reply to Michael Ellerman
Quoted 18 lines · Michael Ellerman
Quoted 17 lines · Vasant Hegde

Currently only FSP based powernv systems supports firmware update interfaces. Hence check that the token OPAL_FLASH_VALIDATE exists before initalising the flash driver.

---
  arch/powerpc/platforms/powernv/opal-flash.c | 4 ++++
  1 file changed, 4 insertions(+)
arch/powerpc/platforms/powernv/opal-flash.c +0 -0
index 7e7d38b17420..05490fc22fae 100644
@@ -520,6 +520,10 @@ void __init opal_flash_update_init(void)
  {
  	int ret;
 
Quoted 5 lines

arch/powerpc/platforms/powernv/opal-flash.c void __init opal_flash_update_init(void) · line 526

Quoted 4 lines
arch/powerpc/platforms/powernv/opal-flash.c +4 -0
+	/* Firmware update is not supported by firmware */
+	if (!opal_check_token(OPAL_FLASH_VALIDATE))
+		return;
+

Michael,

Quoted 9 lines

That will mean the following files no longer appear on BMC systems:

/sys/firmware/opal/image
/sys/firmware/opal/validate_flash
/sys/firmware/opal/manage_flash
/sys/firmware/opal/update_flash

Presumably those files don't actually work correctly, but are we sure their mere existence isn't used by anything at all?

That's correct. We never used these files/interfaces on BMC based systems.

Quoted 3 lines

We've had trouble in the past where removing sysfs files breaks tools unexpectedly, see smt_snooze_delay.

AFAIK only update_flash uses these interfaces on baremetal systems. This change shouldn't break update_flash as these interfaces never used/worked on BMC based powernv systems.

-Vasant