* [PATCH v2 0/2] mtd/nvmem: don't defer forever on absent NVMEM suppliers
@ 2026-11-30 7:45 Manikandan Muralidharan
2026-11-30 7:45 ` [PATCH v2 1/2] mtd: spi-nor: drop fw_devlink suppliers below a flash that failed to probe Manikandan Muralidharan
2026-11-30 7:45 ` [PATCH v2 2/2] nvmem: core: stop deferring for a cell after the deferred probe timeout Manikandan Muralidharan
0 siblings, 2 replies; 3+ messages in thread
From: Manikandan Muralidharan @ 2026-11-30 7:45 UTC (permalink / raw)
To: pratyush, mwalle, takahiro.kuwano, miquel.raynal, richard,
vigneshr, srini, linux-mtd, linux-kernel
Cc: manikandan.m
A consumer that gets its MAC address from an NVMEM cell can be deferred
forever when the cell will never appear, instead of falling back to
another address source. These came up while testing the SFDP EUI-48
series [1], where macb reads its MAC address from a cell exposed by the
QSPI flash, but both are generic:
- 1/2: when the SPI NOR flash is not populated or not reachable, nothing
below its node is ever registered, yet fw_devlink keeps the consumer
from probing. Drop the fw_devlink links below a flash that failed to
probe.
- 2/2: the NVMEM lookup keeps returning -EPROBE_DEFER for a provider
that never shows up, or for a cell that a bound layout did not add,
e.g. when the data it describes is not programmed on the device. Once
the deferred probe timeout has expired, return -ENOENT instead.
In both cases the consumer then falls back once the deferred probe
timeout has expired (10 seconds by default),
e.g. macb uses the address left by the bootloader or a random one.
This series depends on the SFDP EUI-48 series [1] and applies on top of it.
Changes in v2:
- 1/2 - Drop the FWNODE_FLAG_NOT_DEVICE check in of_nvmem_cell_get():
The patch now only touches the SPI NOR core.
- 2/2 - Replace the "layout is bound" check with a fallback once the
deferred probe timeout has expired. This covers both the absent
flash and the missing cell without touching the layout device,
so it no longer races with the layout probe or removal.
Renamed from "nvmem: core: don't defer for a missing cell once
the layout is bound".
v1: https://lore.kernel.org/all/cover.1794391847.git.manikandan.m@microchip.com/
[1] https://lore.kernel.org/all/cover.1796023049.git.manikandan.m@microchip.com/
Manikandan Muralidharan (2):
mtd: spi-nor: drop fw_devlink suppliers below a flash that failed to
probe
nvmem: core: stop deferring for a cell after the deferred probe
timeout
drivers/mtd/spi-nor/core.c | 26 +++++++++++++++++++++++++-
drivers/nvmem/core.c | 9 +++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
prerequisite-patch-id: 76d8b1168f88c3e7912ac2ce01a705f7e69d8a3b
prerequisite-patch-id: b360d0d00ac1a6feb76d4b3f9412b6f1741f6161
prerequisite-patch-id: 659801d6f415ba79ce51f21b3a4f5e132348c150
prerequisite-patch-id: 902c67d8bcfad07fc6424ee551557eeab87efaa4
prerequisite-patch-id: 94ede38b6c2480cb1e0e102e9bbeb6ffd5b276ef
prerequisite-patch-id: ae3977b6c56c5bd4f352d77bd8a7883a69d390af
prerequisite-patch-id: 58d0ad25e81f16f60864d624eed7ff481607e960
prerequisite-patch-id: ba140b71fdbfc992861ae4c34b6acc737d4e4528
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] mtd: spi-nor: drop fw_devlink suppliers below a flash that failed to probe
2026-11-30 7:45 [PATCH v2 0/2] mtd/nvmem: don't defer forever on absent NVMEM suppliers Manikandan Muralidharan
@ 2026-11-30 7:45 ` Manikandan Muralidharan
2026-11-30 7:45 ` [PATCH v2 2/2] nvmem: core: stop deferring for a cell after the deferred probe timeout Manikandan Muralidharan
1 sibling, 0 replies; 3+ messages in thread
From: Manikandan Muralidharan @ 2026-11-30 7:45 UTC (permalink / raw)
To: pratyush, mwalle, takahiro.kuwano, miquel.raynal, richard,
vigneshr, srini, linux-mtd, linux-kernel
Cc: manikandan.m
When a SPI NOR flash is not populated or not reachable, spi_nor_scan()
fails and nothing described below the flash node (the SFDP NVMEM device,
its nvmem-layout, partitions) is ever registered. fw_devlink still holds
links from consumers of those nodes, so a consumer such as an Ethernet
MAC whose "nvmem-cells" points at the SFDP EUI-48 cell waits for its
supplier forever and is never probed:
platform f8008000.ethernet: deferred probe pending: platform: wait for
supplier /ahb/apb/spi@f0024000/flash@0/sfdp/nvmem-layout/mac-address
On a permanent spi_nor_scan() failure, call
fw_devlink_purge_absent_suppliers() on each child of the flash node to
drop their consumer links, so the consumer is probed. Keep the links on
-EPROBE_DEFER, as the flash may still probe once the reset GPIO or
regulator is available.
Signed-off-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
drivers/mtd/spi-nor/core.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 99584ee0ecb3..c2661dc2395b 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -12,6 +12,7 @@
#include <linux/device.h>
#include <linux/err.h>
#include <linux/errno.h>
+#include <linux/fwnode.h>
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
@@ -3624,6 +3625,25 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor)
return PTR_ERR_OR_ZERO(nor->dirmap.wdesc);
}
+/**
+ * spi_nor_purge_absent_suppliers() - drop fw_devlink links below a missing
+ * flash
+ * @dev: pointer to the flash 'struct device'
+ *
+ * When the flash cannot be probed (e.g. it is not populated or not
+ * reachable), nothing described below its node, such as the SFDP NVMEM
+ * device or the partitions, is ever registered. Mark those nodes as never
+ * becoming devices and drop their consumer links, so that consumers such as
+ * an Ethernet MAC using an NVMEM cell are not deferred forever.
+ */
+static void spi_nor_purge_absent_suppliers(struct device *dev)
+{
+ struct fwnode_handle *child;
+
+ device_for_each_child_node(dev, child)
+ fw_devlink_purge_absent_suppliers(child);
+}
+
static int spi_nor_probe(struct spi_mem *spimem)
{
struct spi_device *spi = spimem->spi;
@@ -3672,8 +3692,12 @@ static int spi_nor_probe(struct spi_mem *spimem)
flash_name = spi->modalias;
ret = spi_nor_scan(nor, flash_name, &hwcaps);
- if (ret)
+ if (ret) {
+ /* A deferred probe (e.g. on the reset GPIO) may still succeed. */
+ if (ret != -EPROBE_DEFER)
+ spi_nor_purge_absent_suppliers(dev);
return ret;
+ }
spi_nor_debugfs_register(nor);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] nvmem: core: stop deferring for a cell after the deferred probe timeout
2026-11-30 7:45 [PATCH v2 0/2] mtd/nvmem: don't defer forever on absent NVMEM suppliers Manikandan Muralidharan
2026-11-30 7:45 ` [PATCH v2 1/2] mtd: spi-nor: drop fw_devlink suppliers below a flash that failed to probe Manikandan Muralidharan
@ 2026-11-30 7:45 ` Manikandan Muralidharan
1 sibling, 0 replies; 3+ messages in thread
From: Manikandan Muralidharan @ 2026-11-30 7:45 UTC (permalink / raw)
To: pratyush, mwalle, takahiro.kuwano, miquel.raynal, richard,
vigneshr, srini, linux-mtd, linux-kernel
Cc: manikandan.m
nvmem_cell_get() returns -EPROBE_DEFER for as long as the nvmem device
providing a DT cell is not registered. When that device never shows up,
for instance because the flash holding the cell is not populated on the
board, the consumer is deferred forever instead of falling back to
another source.
Once the deferred probe timeout has expired, as reported by
driver_deferred_probe_check_state(), return -ENOENT instead, so that the
consumer treats the cell as missing. A provider that is merely late is
still waited for until then.
Signed-off-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
drivers/nvmem/core.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index a755cc4318dc..a1208663b50e 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1508,6 +1508,15 @@ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *id)
if (dev->of_node) { /* try dt first */
cell = of_nvmem_cell_get(dev->of_node, id);
+ /*
+ * Don't wait forever for a provider that never shows up, e.g.
+ * when the device holding it is not populated. Once the
+ * deferred probe timeout has expired, report the cell as
+ * missing so that the consumer can fall back.
+ */
+ if (PTR_ERR(cell) == -EPROBE_DEFER &&
+ driver_deferred_probe_check_state(dev) != -EPROBE_DEFER)
+ return ERR_PTR(-ENOENT);
if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER)
return cell;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 7:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 7:45 [PATCH v2 0/2] mtd/nvmem: don't defer forever on absent NVMEM suppliers Manikandan Muralidharan
2026-11-30 7:45 ` [PATCH v2 1/2] mtd: spi-nor: drop fw_devlink suppliers below a flash that failed to probe Manikandan Muralidharan
2026-11-30 7:45 ` [PATCH v2 2/2] nvmem: core: stop deferring for a cell after the deferred probe timeout Manikandan Muralidharan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox