]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
fix(allwinner): improve DTB patching error handling
authorSamuel Holland <samuel@sholland.org>
Sun, 23 Jan 2022 22:30:08 +0000 (16:30 -0600)
committerJoanna Farley <joanna.farley@arm.com>
Tue, 26 Apr 2022 15:52:20 +0000 (17:52 +0200)
Currently, if any step of the DTB patching process fails, the whole
process is aborted. However, this causes some problems:
 - If any step modifies the DTB (including fdt_open_into), the dcache
   must still be cleaned, even if some later step fails.
 - The DTB may need changes in multiple places; if one patch fails (for
   example due to missing nodes), we should still apply other patches.
 - Similarly, if some patch fails, we should still run fdt_pack to
   clean up after ourselves.

Change-Id: If1af2e58e5a7edaf542354bb8a261dd1c3da1ad0
Signed-off-by: Samuel Holland <samuel@sholland.org>
plat/allwinner/common/sunxi_prepare_dtb.c

index 93428ac2cbdaf4696356c55b28d5a2c98527d014..fc2e561fbbe880835966edf59799c654b8006ab4 100644 (file)
@@ -31,7 +31,6 @@ void sunxi_prepare_dtb(void *fdt)
        if (fdt_add_reserved_memory(fdt, "tf-a@40000000", BL31_BASE,
                                    BL31_LIMIT - BL31_BASE)) {
                WARN("Failed to add reserved memory nodes to DT.\n");
-               return;
        }
 #endif
 
@@ -39,8 +38,8 @@ void sunxi_prepare_dtb(void *fdt)
        if (ret < 0) {
                ERROR("Failed to pack devicetree at %p: error %d\n",
                      fdt, ret);
-       } else {
-               clean_dcache_range((uintptr_t)fdt, fdt_blob_size(fdt));
-               INFO("Changed devicetree.\n");
        }
+
+       clean_dcache_range((uintptr_t)fdt, fdt_blob_size(fdt));
+       INFO("Changed devicetree.\n");
 }