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@kernel.org, ulli.kroll@googlemail.com, john@phrozen.org,
nico@fluxnic.net, dwmw2@infradead.org, corbet@lwn.net,
linux-doc@vger.kernel.org, Orgad Shaneh <orgads@gmail.com>
Subject: [PATCH v5 4/4] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC
Date: Thu, 26 Nov 2026 08:59:06 +0000 [thread overview]
Message-ID: <20261126085906.814373-5-orgads@gmail.com> (raw)
In-Reply-To: <20261126085906.814373-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; that commit gives no reason beyond "Without this,
we get bus errors." The semaphore's 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.
A little-endian kernel keeps the semaphore accessors: the boot bus
there needs the address swizzle of the I/O accessors, and a pointed
address would be read with plain loads.
Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
v5: keep the old accessors on little-endian kernels (sashiko);
quote the reason 8c1e6b14e27d gives, and drop a duplicated
bank width comment.
v4: rebased onto v7.4-rc1; the Assisted-by tag is dropped (an LLM
helped write this series).
On top of the new 3/4: simple_map_init() gets the per-device
map, and the bank width check runs before the allocation.
v3: Assisted-by in the documented form.
v2: check the bank width before ioremap() and drop the added
iounmap() calls: flash_map was one static instance, so they could
unmap a mapping that an earlier probe registered (sashiko).
arch/mips/cavium-octeon/flash_setup.c | 39 +++++++++++++++++++++++----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/arch/mips/cavium-octeon/flash_setup.c b/arch/mips/cavium-octeon/flash_setup.c
index d69249acf..896baf52d 100644
--- a/arch/mips/cavium-octeon/flash_setup.c
+++ b/arch/mips/cavium-octeon/flash_setup.c
@@ -61,6 +61,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,11 @@ 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) {
+ if (!map_bankwidth_supported(region_cfg.s.width + 1)) {
+ pr_err("Unsupported flash bank width %d\n",
+ region_cfg.s.width + 1);
+ return -EINVAL;
+ }
map = devm_kzalloc(&pdev->dev, sizeof(*map), GFP_KERNEL);
if (!map)
return -ENOMEM;
@@ -107,11 +123,24 @@ static int octeon_flash_probe(struct platform_device *pdev)
return -ENOMEM;
pr_notice("Bootbus flash: Setting flash for %luMB flash at 0x%08llx\n",
map->size >> 20, map->phys);
- WARN_ON(!map_bankwidth_supported(map->bankwidth));
- map->read = octeon_flash_map_read;
- map->write = octeon_flash_map_write;
- map->copy_from = octeon_flash_map_copy_from;
- 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.
+ * Not on little-endian: the boot bus needs the address
+ * swizzle of the I/O accessors, which a plain load through
+ * a pointed address does not get.
+ */
+ if (octeon_flash_bus_shared() ||
+ IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN)) {
+ map->read = octeon_flash_map_read;
+ map->write = octeon_flash_map_write;
+ map->copy_from = octeon_flash_map_copy_from;
+ map->copy_to = octeon_flash_map_copy_to;
+ } else {
+ simple_map_init(map);
+ }
mtd = do_map_probe("cfi_probe", map);
if (!mtd) {
pr_err("Failed to register MTD device for flash\n");
--
2.53.0
next prev parent reply other threads:[~2026-11-26 8:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 8:59 [PATCH v5 0/4] mtd: point() for cfi_cmdset_0002, on simple maps only Orgad Shaneh
2026-11-26 8:59 ` [PATCH v5 1/4] mtd: maps: only point() maps read through the simple accessors Orgad Shaneh
2026-11-26 8:59 ` [PATCH v5 2/4] mtd: cfi_cmdset_0002: implement point() for simple linear maps Orgad Shaneh
2026-11-26 8:59 ` [PATCH v5 3/4] MIPS: Octeon: flash: allocate the map per device Orgad Shaneh
2026-11-26 8:59 ` Orgad Shaneh [this message]
2026-11-26 11:01 ` [PATCH v5 0/4] mtd: point() for cfi_cmdset_0002, on simple maps only Miquel Raynal
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=20261126085906.814373-5-orgads@gmail.com \
--to=orgads@gmail.com \
--cc=corbet@lwn.net \
--cc=dwmw2@infradead.org \
--cc=john@phrozen.org \
--cc=kaloz@kernel.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