Edward O'Callaghan has uploaded this change for review.
internal.c: Fix map_flash() failures with linux_mtd via internal
prepare_flash_access() calls into map_flash() however this can
fail on some DUT's. The issue is that map_flash() can fail on
opaque spi masters such as linux_mtd and even ichspi when they
are dispatched into via 'internal'.
The issue with 'internal' is that the hook 'map_flash_region = physmap'
is used from the internal struct entry-point instance and not the native
one for the underlying master. This fails on some board topologies such
Volteer.
Structually this is not easy to solve with how internal is currently
implemented where it partially replaces itself with the underlying
master and so this fix only addresses the case of linux_mtd.
BUG=b:171093672
TEST=builds
Change-Id: Ia32ff1357b73166cdcec8a62ab5c516d1d1527f5
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M internal.c
1 file changed, 19 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/43/63543/1
diff --git a/internal.c b/internal.c
index 4049ef1..57b6ed6 100644
--- a/internal.c
+++ b/internal.c
@@ -188,6 +188,8 @@
return 0;
}
+static bool is_phys_master = true;
+
static int internal_init(void)
{
int ret = 0;
@@ -213,6 +215,7 @@
internal_buses_supported = BUS_NONSPI;
if (try_mtd() == 0) {
+ is_phys_master = false;
ret = 0;
goto internal_init_exit;
}
@@ -339,12 +342,26 @@
return ret;
}
+static void *internal_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len)
+{
+ if (is_phys_master)
+ return physmap(descr, phys_addr, len);
+ return fallback_map(descr, phys_addr, len);
+}
+
+static void internal_unmap_flash_region(void *virt_addr, size_t len)
+{
+ if (is_phys_master)
+ return physunmap(virt_addr, len);
+ return fallback_unmap(virt_addr, len);
+}
+
const struct programmer_entry programmer_internal = {
.name = "internal",
.type = OTHER,
.devs.note = NULL,
.init = internal_init,
- .map_flash_region = physmap,
- .unmap_flash_region = physunmap,
+ .map_flash_region = internal_map_flash_region,
+ .unmap_flash_region = internal_unmap_flash_region,
.delay = internal_delay,
};
To view, visit change 63543. To unsubscribe, or for help writing mail filters, visit settings.