From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH v3 13/23] elf: use iomem regions as fallback when loading to non-sdram memory
Date: Mon, 13 Jan 2025 12:27:00 +0100 [thread overview]
Message-ID: <20250113-k3-r5-v3-13-065fcdcc28d3@pengutronix.de> (raw)
In-Reply-To: <20250113-k3-r5-v3-0-065fcdcc28d3@pengutronix.de>
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@pengutronix.de>
---
common/elf.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/common/elf.c b/common/elf.c
index ec78e45bf1..3cbe63f6b2 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
next prev parent reply other threads:[~2025-01-13 11:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 11:26 [PATCH v3 00/23] ARM: K3: Add R5 boot support Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 01/23] ARM: add ARMv7R MPU support Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 02/23] lib/rationale: compile for pbl Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 04/23] ARM: move ARM_CPU_PART_* defines to header Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 05/23] nommu_v7_vectors_init: disable for r5 Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 06/23] clocksource: timer-ti-dm: add support for K3 SoCs Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 07/23] ARM: K3: mount /boot even with env handling disabled Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 08/23] clk: add K3 clk driver Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 09/23] pmdomain: add K3 driver Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 10/23] rproc: add K3 arm64 rproc driver Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 11/23] ARM: k3: add k3_debug_ll_init() Sascha Hauer
2025-01-13 11:26 ` [PATCH v3 12/23] ARM: K3: use debug_ll code for regular PBL console Sascha Hauer
2025-01-13 11:27 ` Sascha Hauer [this message]
2025-01-13 11:27 ` [PATCH v3 14/23] rproc: add K3 system_controller Sascha Hauer
2025-01-13 11:27 ` [PATCH v3 15/23] firmware: ti_sci: add function to get global handle Sascha Hauer
2025-01-13 11:27 ` [PATCH v3 16/23] ARM: k3: Add initial r5 support Sascha Hauer
2025-01-13 11:27 ` [PATCH v3 17/23] scripts: k3: add script to generate cfg files from yaml Sascha Hauer
2025-01-14 9:29 ` Ahmad Fatoum
2025-01-14 9:38 ` Sascha Hauer
2025-01-13 11:27 ` [PATCH v3 18/23] ARM: k3: Add k3img tool Sascha Hauer
2025-01-13 11:27 ` [PATCH v3 19/23] ARM: beagleplay: add Cortex-R5 boot support Sascha Hauer
2025-01-13 11:27 ` [PATCH v3 20/23] Documentation: add build documentation for TI K3 SoCs Sascha Hauer
2025-01-13 11:27 ` [PATCH v3 21/23] ARM: am625: disable secondary watchdogs Sascha Hauer
2025-01-13 11:27 ` [PATCH v3 22/23] ARM: k3: Add DRAM size detection Sascha Hauer
2025-01-13 11:27 ` [PATCH v3 23/23] ARM: k3: am625-sk board support Sascha Hauer
2025-01-14 8:32 ` [PATCH v3 00/23] ARM: K3: Add R5 boot support Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250113-k3-r5-v3-13-065fcdcc28d3@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox