forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: fix mtd/NVMEM regression affecting U-Boot env NVMEM driver
Fixes: b595670 ("kernel: backport nvmem v6.6 fixes and v6.7 changes") Fixes: openwrt#13831 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
- Loading branch information
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.../linux/generic/pending-6.1/401-mtd-don-t-register-NVMEM-devices-for-partitions-with.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl> | ||
Date: Tue, 31 Oct 2023 15:51:01 +0100 | ||
Subject: [PATCH] mtd: don't register NVMEM devices for partitions with custom | ||
drivers | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
|
||
This fixes issue exposed by upstream commit f4cf4e5db331 ("Revert | ||
"nvmem: add new config option""). | ||
|
||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl> | ||
--- | ||
drivers/mtd/mtdcore.c | 23 +++++++++++++++++++++++ | ||
1 file changed, 23 insertions(+) | ||
|
||
--- a/drivers/mtd/mtdcore.c | ||
+++ b/drivers/mtd/mtdcore.c | ||
@@ -519,6 +519,29 @@ static int mtd_nvmem_add(struct mtd_info | ||
struct device_node *node = mtd_get_of_node(mtd); | ||
struct nvmem_config config = {}; | ||
|
||
+ /* | ||
+ * Do NOT register NVMEM device for any partition that is meant to be | ||
+ * handled by a U-Boot env driver. That would result in associating two | ||
+ * different NVMEM devices with the same OF node. | ||
+ * | ||
+ * An example of unwanted behaviour of above (forwardtrace): | ||
+ * of_get_mac_addr_nvmem() | ||
+ * of_nvmem_cell_get() | ||
+ * __nvmem_device_get() | ||
+ * | ||
+ * We can't have __nvmem_device_get() return "mtdX" NVMEM device instead | ||
+ * of U-Boot env NVMEM device. That would result in failing to find | ||
+ * NVMEM cell. | ||
+ * | ||
+ * This issue seems to affect U-Boot env case only and will go away with | ||
+ * switch to NVMEM layouts. | ||
+ */ | ||
+ if (of_device_is_compatible(node, "u-boot,env") || | ||
+ of_device_is_compatible(node, "u-boot,env-redundant-bool") || | ||
+ of_device_is_compatible(node, "u-boot,env-redundant-count") || | ||
+ of_device_is_compatible(node, "brcm,env")) | ||
+ return 0; | ||
+ | ||
config.id = -1; | ||
config.dev = &mtd->dev; | ||
config.name = dev_name(&mtd->dev); |