[PATCH v2 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC
From: Orgad Shaneh
Date: Sat Oct 10 2026 - 14:09:46 EST
CAVIUM_OCTEON_SOC selects MTD_COMPLEX_MAPPINGS, and since
commit 8c1e6b14e27d ("MIPS: OCTEON: Protect accesses to bootbus flash
with octeon_bootbus_sem.") the flash map accessors take the semaphore
around every access. Its only other user is the eMMC host of the older
parts ("cavium,octeon-6130-mmc" in drivers/mmc/host/cavium-octeon.c),
which shares the boot bus; the CIU3 parts serialize their eMMC with a
lock of their own.
On boards without that host the semaphore guards nothing, but the
custom accessors make the map non-simple, so MTD will not let jffs2
point at it and its mount copies every used eraseblock. Use
simple_map_init() there. The test is for the node, not the driver, so
a disabled mmc node keeps the semaphore.
simple_map_init() BUG()s on an unsupported bank width; the old code
warned and then hit the BUG() in the inline map accessors on the first
probe command. Check the width before mapping anything and fail the
probe instead.
On an Octeon CN6635 board (no eMMC) with a 100 MB jffs2 partition on
an 8-bit NOR the mount drops from 15-30 s to under 1 s together with
point() support in cfi_cmdset_0002.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Orgad Shaneh <orgads@xxxxxxxxx>
---
v2: check the bank width before ioremap() and drop the added
iounmap() calls: flash_map is one static instance, so they could
unmap a mapping that an earlier probe registered (sashiko).
arch/mips/cavium-octeon/flash_setup.c | 36 +++++++++++++++++++++++----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/arch/mips/cavium-octeon/flash_setup.c b/arch/mips/cavium-octeon/flash_setup.c
index 9242521..1c0b7d7 100644
--- a/arch/mips/cavium-octeon/flash_setup.c
+++ b/arch/mips/cavium-octeon/flash_setup.c
@@ -63,6 +63,17 @@ static void octeon_flash_map_copy_to(struct map_info *map, unsigned long to,
up(&octeon_bootbus_sem);
}
+static bool octeon_flash_bus_shared(void)
+{
+ struct device_node *np;
+ bool shared;
+
+ np = of_find_compatible_node(NULL, NULL, "cavium,octeon-6130-mmc");
+ shared = !!np;
+ of_node_put(np);
+ return shared;
+}
+
/*
* Module/ driver initialization.
*
@@ -85,6 +96,12 @@ static int octeon_flash_probe(struct platform_device *pdev)
*/
region_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(cs));
if (region_cfg.s.en) {
+ /* 8-bit bus (0 + 1) or 16-bit bus (1 + 1) */
+ if (!map_bankwidth_supported(region_cfg.s.width + 1)) {
+ pr_err("Unsupported flash bank width %d\n",
+ region_cfg.s.width + 1);
+ return -EINVAL;
+ }
/*
* The bootloader always takes the flash and sets its
* address so the entire flash fits below
@@ -102,11 +119,20 @@ static int octeon_flash_probe(struct platform_device *pdev)
flash_map.virt = ioremap(flash_map.phys, flash_map.size);
pr_notice("Bootbus flash: Setting flash for %luMB flash at "
"0x%08llx\n", flash_map.size >> 20, flash_map.phys);
- WARN_ON(!map_bankwidth_supported(flash_map.bankwidth));
- flash_map.read = octeon_flash_map_read;
- flash_map.write = octeon_flash_map_write;
- flash_map.copy_from = octeon_flash_map_copy_from;
- flash_map.copy_to = octeon_flash_map_copy_to;
+ /*
+ * The boot bus semaphore only serializes the flash against
+ * an eMMC host that shares the bus (the CIU3 parts have
+ * their own). Without one, use the simple accessors: they
+ * let MTD point at the flash, so jffs2 scans it in place.
+ */
+ if (octeon_flash_bus_shared()) {
+ flash_map.read = octeon_flash_map_read;
+ flash_map.write = octeon_flash_map_write;
+ flash_map.copy_from = octeon_flash_map_copy_from;
+ flash_map.copy_to = octeon_flash_map_copy_to;
+ } else {
+ simple_map_init(&flash_map);
+ }
mymtd = do_map_probe("cfi_probe", &flash_map);
if (mymtd) {
mymtd->owner = THIS_MODULE;
--
2.53.0