From: Rafał Miłecki Date: Tue, 12 Dec 2023 11:02:31 +0000 (+0100) Subject: kernel: backport upstream nvmem fix for "fixed-layout" X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1d364cc9ffb6840dfa869f31e8961bec7b97d76e;p=openwrt%2Fstaging%2Fstintel.git kernel: backport upstream nvmem fix for "fixed-layout" It replaces a pretty much identical downstream patch. Signed-off-by: Rafał Miłecki --- diff --git a/target/linux/generic/backport-5.15/820-v6.7-0005-nvmem-Do-not-expect-fixed-layouts-to-grab-a-layout-d.patch b/target/linux/generic/backport-5.15/820-v6.7-0005-nvmem-Do-not-expect-fixed-layouts-to-grab-a-layout-d.patch new file mode 100644 index 0000000000..bd5ceaabf7 --- /dev/null +++ b/target/linux/generic/backport-5.15/820-v6.7-0005-nvmem-Do-not-expect-fixed-layouts-to-grab-a-layout-d.patch @@ -0,0 +1,45 @@ +From b7c1e53751cb3990153084f31c41f25fde3b629c Mon Sep 17 00:00:00 2001 +From: Miquel Raynal +Date: Fri, 24 Nov 2023 20:38:14 +0100 +Subject: [PATCH] nvmem: Do not expect fixed layouts to grab a layout driver +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Two series lived in parallel for some time, which led to this situation: +- The nvmem-layout container is used for dynamic layouts +- We now expect fixed layouts to also use the nvmem-layout container but +this does not require any additional driver, the support is built-in the +nvmem core. + +Ensure we don't refuse to probe for wrong reasons. + +Fixes: 27f699e578b1 ("nvmem: core: add support for fixed cells *layout*") +Cc: stable@vger.kernel.org +Reported-by: Luca Ceresoli +Signed-off-by: Miquel Raynal +Tested-by: Rafał Miłecki +Tested-by: Luca Ceresoli +Reviewed-by: Luca Ceresoli + +Link: https://lore.kernel.org/r/20231124193814.360552-1-miquel.raynal@bootlin.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/core.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -797,6 +797,12 @@ static struct nvmem_layout *nvmem_layout + if (!layout_np) + return NULL; + ++ /* Fixed layouts don't have a matching driver */ ++ if (of_device_is_compatible(layout_np, "fixed-layout")) { ++ of_node_put(layout_np); ++ return NULL; ++ } ++ + /* + * In case the nvmem device was built-in while the layout was built as a + * module, we shall manually request the layout driver loading otherwise diff --git a/target/linux/generic/backport-6.1/816-v6.7-0005-nvmem-Do-not-expect-fixed-layouts-to-grab-a-layout-d.patch b/target/linux/generic/backport-6.1/816-v6.7-0005-nvmem-Do-not-expect-fixed-layouts-to-grab-a-layout-d.patch new file mode 100644 index 0000000000..bd5ceaabf7 --- /dev/null +++ b/target/linux/generic/backport-6.1/816-v6.7-0005-nvmem-Do-not-expect-fixed-layouts-to-grab-a-layout-d.patch @@ -0,0 +1,45 @@ +From b7c1e53751cb3990153084f31c41f25fde3b629c Mon Sep 17 00:00:00 2001 +From: Miquel Raynal +Date: Fri, 24 Nov 2023 20:38:14 +0100 +Subject: [PATCH] nvmem: Do not expect fixed layouts to grab a layout driver +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Two series lived in parallel for some time, which led to this situation: +- The nvmem-layout container is used for dynamic layouts +- We now expect fixed layouts to also use the nvmem-layout container but +this does not require any additional driver, the support is built-in the +nvmem core. + +Ensure we don't refuse to probe for wrong reasons. + +Fixes: 27f699e578b1 ("nvmem: core: add support for fixed cells *layout*") +Cc: stable@vger.kernel.org +Reported-by: Luca Ceresoli +Signed-off-by: Miquel Raynal +Tested-by: Rafał Miłecki +Tested-by: Luca Ceresoli +Reviewed-by: Luca Ceresoli + +Link: https://lore.kernel.org/r/20231124193814.360552-1-miquel.raynal@bootlin.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/core.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -797,6 +797,12 @@ static struct nvmem_layout *nvmem_layout + if (!layout_np) + return NULL; + ++ /* Fixed layouts don't have a matching driver */ ++ if (of_device_is_compatible(layout_np, "fixed-layout")) { ++ of_node_put(layout_np); ++ return NULL; ++ } ++ + /* + * In case the nvmem device was built-in while the layout was built as a + * module, we shall manually request the layout driver loading otherwise diff --git a/target/linux/generic/pending-5.15/803-nvmem-core-fix-support-for-fixed-cells-NVMEM-layout.patch b/target/linux/generic/pending-5.15/803-nvmem-core-fix-support-for-fixed-cells-NVMEM-layout.patch deleted file mode 100644 index f403bbec9b..0000000000 --- a/target/linux/generic/pending-5.15/803-nvmem-core-fix-support-for-fixed-cells-NVMEM-layout.patch +++ /dev/null @@ -1,40 +0,0 @@ -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Date: Thu, 13 Jul 2023 17:30:59 +0200 -Subject: [PATCH] nvmem: core: fix support for fixed cells NVMEM layout -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Returning -EPROBE_DEFER for "fixed-layout" makes nvmem_register() always -fail (that layout is supported internally with no external module). That -makes callers (e.g. mtd_nvmem_add()) fail as well and prevents booting -on devices with "fixed-layout" in DT. - -Add a quick workaround for it. - -Fixes: 6468a6f45148 ("nvmem: core: handle the absence of expected layouts") -Signed-off-by: Rafał Miłecki ---- - ---- a/drivers/nvmem/core.c -+++ b/drivers/nvmem/core.c -@@ -798,6 +798,19 @@ static struct nvmem_layout *nvmem_layout - return NULL; - - /* -+ * We should return -EPROBE_DEFER only when layout driver is expected to -+ * become available later. Otherwise NVMEM will never probe successfully -+ * for unsupported layouts. There is no known solution for that right -+ * now. -+ * -+ * This problem also affects "fixed-layout". It's supported in NVMEM -+ * core code so there never will be layout for it. We shouldn't return -+ * -EPROBE_DEFER in such case. Add a quick workaround for that. -+ */ -+ if (of_device_is_compatible(layout_np, "fixed-layout")) -+ return NULL; -+ -+ /* - * In case the nvmem device was built-in while the layout was built as a - * module, we shall manually request the layout driver loading otherwise - * we'll never have any match. diff --git a/target/linux/generic/pending-6.1/803-nvmem-core-fix-support-for-fixed-cells-NVMEM-layout.patch b/target/linux/generic/pending-6.1/803-nvmem-core-fix-support-for-fixed-cells-NVMEM-layout.patch deleted file mode 100644 index f403bbec9b..0000000000 --- a/target/linux/generic/pending-6.1/803-nvmem-core-fix-support-for-fixed-cells-NVMEM-layout.patch +++ /dev/null @@ -1,40 +0,0 @@ -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Date: Thu, 13 Jul 2023 17:30:59 +0200 -Subject: [PATCH] nvmem: core: fix support for fixed cells NVMEM layout -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Returning -EPROBE_DEFER for "fixed-layout" makes nvmem_register() always -fail (that layout is supported internally with no external module). That -makes callers (e.g. mtd_nvmem_add()) fail as well and prevents booting -on devices with "fixed-layout" in DT. - -Add a quick workaround for it. - -Fixes: 6468a6f45148 ("nvmem: core: handle the absence of expected layouts") -Signed-off-by: Rafał Miłecki ---- - ---- a/drivers/nvmem/core.c -+++ b/drivers/nvmem/core.c -@@ -798,6 +798,19 @@ static struct nvmem_layout *nvmem_layout - return NULL; - - /* -+ * We should return -EPROBE_DEFER only when layout driver is expected to -+ * become available later. Otherwise NVMEM will never probe successfully -+ * for unsupported layouts. There is no known solution for that right -+ * now. -+ * -+ * This problem also affects "fixed-layout". It's supported in NVMEM -+ * core code so there never will be layout for it. We shouldn't return -+ * -EPROBE_DEFER in such case. Add a quick workaround for that. -+ */ -+ if (of_device_is_compatible(layout_np, "fixed-layout")) -+ return NULL; -+ -+ /* - * In case the nvmem device was built-in while the layout was built as a - * module, we shall manually request the layout driver loading otherwise - * we'll never have any match.