Re: [PATCH 2/3] ARM: layerscape: add helpful runtime warning when firmware is missing

2024-05-05 Thread Sascha Hauer
On Fri, May 03, 2024 at 12:32:29PM +0200, Ahmad Fatoum wrote:
> Firmware compiled into barebox PBL is rarely optional, so even if
> CONFIG_MISSING_FIRMWARE_ERROR is disabled, barebox will not generate
> images with missing PBL firmware.
> 
> We can relax this for firmware compiled into barebox proper though: If
> the user disables CONFIG_MISSING_FIRMWARE_ERROR, just have the driver
> fail at runtime as not to break other boards in the same build that
> don't require the firmware.
> 
> Missing barebox proper firmware will be detectable as a 0-byte firmware
> blob in the follow-up commit, so prepare for that by printing an
> informative error message.

I changed the order of the first two patches to what this sentence
suggests.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



[PATCH 2/3] ARM: layerscape: add helpful runtime warning when firmware is missing

2024-05-03 Thread Ahmad Fatoum
Firmware compiled into barebox PBL is rarely optional, so even if
CONFIG_MISSING_FIRMWARE_ERROR is disabled, barebox will not generate
images with missing PBL firmware.

We can relax this for firmware compiled into barebox proper though: If
the user disables CONFIG_MISSING_FIRMWARE_ERROR, just have the driver
fail at runtime as not to break other boards in the same build that
don't require the firmware.

Missing barebox proper firmware will be detectable as a 0-byte firmware
blob in the follow-up commit, so prepare for that by printing an
informative error message.

Signed-off-by: Ahmad Fatoum 
---
 arch/arm/mach-layerscape/ppa.c | 4 
 drivers/net/fsl-fman.c | 4 
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/mach-layerscape/ppa.c b/arch/arm/mach-layerscape/ppa.c
index 21efaae3ab32..99b76b4c30d7 100644
--- a/arch/arm/mach-layerscape/ppa.c
+++ b/arch/arm/mach-layerscape/ppa.c
@@ -121,6 +121,10 @@ int ls1046a_ppa_init(resource_size_t ppa_start, 
resource_size_t ppa_size)
}
 
get_builtin_firmware(ppa_ls1046a_bin, &ppa_fw, &ppa_fw_size);
+   if (!ppa_fw_size) {
+   pr_err("PPA Firmware was not included in build\n");
+   return -ENOSYS;
+   }
 
if (el == 3) {
unsigned long cr;
diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index 5528e950..98af3dafb44a 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -213,6 +213,10 @@ static int fman_upload_firmware(struct device *dev, struct 
fm_imem *fm_imem)
const struct qe_firmware *firmware;
 
get_builtin_firmware(fsl_fman_ucode_ls1046_r1_0_106_4_18_bin, 
&firmware, &size);
+   if (!size) {
+   dev_err(dev, "FMan Firmware was not included in build\n");
+   return -ENOSYS;
+   }
 
ret = qe_validate_firmware(firmware, size);
if (ret)
-- 
2.39.2