aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2023-10-31 17:09:45 +0100
committerRafał Miłecki <rafal@milecki.pl>2023-11-02 09:45:08 +0100
commit0dec0e0f1931bb6089daef6cfb5a3670bcaa64b7 (patch)
tree126b768dd939ecc30749d4f42d23b47b0fd398c2
parent20736013e91030005353b401bc4b757ba5e5fa98 (diff)
downloadupstream-0dec0e0f1931bb6089daef6cfb5a3670bcaa64b7.tar.gz
upstream-0dec0e0f1931bb6089daef6cfb5a3670bcaa64b7.tar.bz2
upstream-0dec0e0f1931bb6089daef6cfb5a3670bcaa64b7.zip
kernel: fix mtd/NVMEM regression affecting U-Boot env NVMEM driver
Fixes: 20736013e910 ("kernel: backport nvmem v6.6 fixes and v6.7 changes") Fixes: https://github.com/openwrt/openwrt/issues/13831 Signed-off-by: Rafał Miłecki <rafal@milecki.pl> (cherry picked from commit c997634c017294cb38cf6f9a0112860c7e736a53)
-rw-r--r--target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch2
-rw-r--r--target/linux/generic/hack-5.15/402-mtd-blktrans-call-add-disks-after-mtd-device.patch2
-rw-r--r--target/linux/generic/hack-5.15/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch2
-rw-r--r--target/linux/generic/pending-5.15/401-mtd-don-t-register-NVMEM-devices-for-partitions-with.patch48
-rw-r--r--target/linux/pistachio/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch2
5 files changed, 52 insertions, 4 deletions
diff --git a/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch b/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
index 7db6346c37..36f5331bd0 100644
--- a/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
+++ b/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
@@ -34,7 +34,7 @@ Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
mtd->type = MTD_NORFLASH;
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
-@@ -847,6 +847,17 @@ out_error:
+@@ -870,6 +870,17 @@ out_error:
*/
static void mtd_set_dev_defaults(struct mtd_info *mtd)
{
diff --git a/target/linux/generic/hack-5.15/402-mtd-blktrans-call-add-disks-after-mtd-device.patch b/target/linux/generic/hack-5.15/402-mtd-blktrans-call-add-disks-after-mtd-device.patch
index 62737aa779..1df6f2f18b 100644
--- a/target/linux/generic/hack-5.15/402-mtd-blktrans-call-add-disks-after-mtd-device.patch
+++ b/target/linux/generic/hack-5.15/402-mtd-blktrans-call-add-disks-after-mtd-device.patch
@@ -77,7 +77,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
#include "mtdcore.h"
-@@ -1083,6 +1084,8 @@ int mtd_device_parse_register(struct mtd
+@@ -1106,6 +1107,8 @@ int mtd_device_parse_register(struct mtd
register_reboot_notifier(&mtd->reboot_notifier);
}
diff --git a/target/linux/generic/hack-5.15/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch b/target/linux/generic/hack-5.15/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch
index 947b2c262f..ed46301b0e 100644
--- a/target/linux/generic/hack-5.15/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch
+++ b/target/linux/generic/hack-5.15/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch
@@ -12,7 +12,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
-@@ -761,7 +761,8 @@ int add_mtd_device(struct mtd_info *mtd)
+@@ -784,7 +784,8 @@ int add_mtd_device(struct mtd_info *mtd)
mutex_unlock(&mtd_table_mutex);
diff --git a/target/linux/generic/pending-5.15/401-mtd-don-t-register-NVMEM-devices-for-partitions-with.patch b/target/linux/generic/pending-5.15/401-mtd-don-t-register-NVMEM-devices-for-partitions-with.patch
new file mode 100644
index 0000000000..650e10a3a5
--- /dev/null
+++ b/target/linux/generic/pending-5.15/401-mtd-don-t-register-NVMEM-devices-for-partitions-with.patch
@@ -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
+@@ -537,6 +537,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);
diff --git a/target/linux/pistachio/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch b/target/linux/pistachio/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
index 7db6346c37..36f5331bd0 100644
--- a/target/linux/pistachio/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
+++ b/target/linux/pistachio/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
@@ -34,7 +34,7 @@ Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
mtd->type = MTD_NORFLASH;
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
-@@ -847,6 +847,17 @@ out_error:
+@@ -870,6 +870,17 @@ out_error:
*/
static void mtd_set_dev_defaults(struct mtd_info *mtd)
{