[PATCH 13/20] elf: use iomem regions as fallback when loading to non-sdram memory
Sascha Hauer
s.hauer at pengutronix.de
Fri Nov 29 03:44:28 PST 2024
The ELF code uses request_sdram_region() to request the regions the
binary shall be copied to. However, not all of these regions are
actually SDRAM. Some specialized ELF files might also use SoC SRAM
which is not registered as SDRAM, so use request_region as a fallback
in these cases.
This is needed on the TI K3 AM625 SoC to successfully load the ti-dm
firmware binary.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/elf.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/common/elf.c b/common/elf.c
index 62f793010f..cfe84939af 100644
--- a/common/elf.c
+++ b/common/elf.c
@@ -18,6 +18,7 @@ struct elf_section {
struct list_head list;
struct resource *r;
void *phdr;
+ bool is_iomem_region;
};
static int elf_request_region(struct elf_image *elf, resource_size_t start,
@@ -33,8 +34,12 @@ static int elf_request_region(struct elf_image *elf, resource_size_t start,
r_new = request_sdram_region("elf_section", start, size);
if (!r_new) {
- pr_err("Failed to request region: %pa %pa\n", &start, &size);
- return -EINVAL;
+ r_new = request_iomem_region("elf_section", start, size);
+ if (!r_new) {
+ pr_err("Failed to request region: %pa %pa\n", &start, &size);
+ return -EINVAL;
+ }
+ r->is_iomem_region = true;
}
r->r = r_new;
@@ -50,7 +55,10 @@ static void elf_release_regions(struct elf_image *elf)
struct elf_section *r, *r_tmp;
list_for_each_entry_safe(r, r_tmp, list, list) {
- release_sdram_region(r->r);
+ if (r->is_iomem_region)
+ release_region(r->r);
+ else
+ release_sdram_region(r->r);
list_del(&r->list);
free(r);
}
--
2.39.5
More information about the barebox
mailing list