From: Orgad Shaneh <orgads@gmail.com>
To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com,
tsbogend@alpha.franken.de
Cc: linux-mtd@lists.infradead.org, linux-mips@vger.kernel.org,
linux-kernel@vger.kernel.org, linusw@kernel.org,
kaloz@openwrt.org, ulli.kroll@googlemail.com, john@phrozen.org,
nico@fluxnic.net, dwmw2@infradead.org, corbet@lwn.net,
linux-doc@vger.kernel.org
Subject: [PATCH v3 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC
Date: Sun, 11 Oct 2026 06:29:08 +0000 [thread overview]
Message-ID: <20261011062908.2365879-4-orgads@gmail.com> (raw)
In-Reply-To: <20261011062908.2365879-1-orgads@gmail.com>
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: LLM
Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
v3: Assisted-by in the documented form.
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
next prev parent reply other threads:[~2026-10-11 6:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 17:21 [PATCH 0/3] mtd: point() for cfi_cmdset_0002, on simple maps only Orgad Shaneh
2026-10-10 17:21 ` [PATCH 1/3] mtd: maps: only point() maps read through the simple accessors Orgad Shaneh
2026-10-10 17:21 ` [PATCH 2/3] mtd: cfi_cmdset_0002: implement point() for simple linear maps Orgad Shaneh
2026-10-10 17:31 ` sashiko-bot
2026-10-10 17:21 ` [PATCH 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC Orgad Shaneh
2026-10-10 17:32 ` sashiko-bot
2026-10-10 18:08 ` [PATCH v2 0/3] mtd: point() for cfi_cmdset_0002, on simple maps only Orgad Shaneh
2026-10-10 18:08 ` [PATCH v2 1/3] mtd: maps: only point() maps read through the simple accessors Orgad Shaneh
2026-10-10 18:08 ` [PATCH v2 2/3] mtd: cfi_cmdset_0002: implement point() for simple linear maps Orgad Shaneh
2026-10-10 18:18 ` sashiko-bot
2026-10-10 18:08 ` [PATCH v2 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC Orgad Shaneh
2026-10-10 18:18 ` sashiko-bot
2026-10-11 6:29 ` [PATCH v3 0/3] mtd: point() for cfi_cmdset_0002, on simple maps only Orgad Shaneh
2026-10-11 6:29 ` [PATCH v3 1/3] mtd: maps: only point() maps read through the simple accessors Orgad Shaneh
2026-10-11 6:29 ` [PATCH v3 2/3] mtd: cfi_cmdset_0002: implement point() for simple linear maps Orgad Shaneh
2026-10-11 6:29 ` Orgad Shaneh [this message]
2026-10-11 6:39 ` [PATCH v3 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC sashiko-bot
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=20261011062908.2365879-4-orgads@gmail.com \
--to=orgads@gmail.com \
--cc=corbet@lwn.net \
--cc=dwmw2@infradead.org \
--cc=john@phrozen.org \
--cc=kaloz@openwrt.org \
--cc=linusw@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=nico@fluxnic.net \
--cc=richard@nod.at \
--cc=tsbogend@alpha.franken.de \
--cc=ulli.kroll@googlemail.com \
--cc=vigneshr@ti.com \
/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
all inboxes | Powered by JetHome®