From ccd73f9c7279e717cc4dcb4f938a31f1b63338e4 Mon Sep 17 00:00:00 2001
From: Michal Hrusecky <michal.hrusecky@turris.com>
Date: Fri, 26 Apr 2024 13:37:55 +0200
Subject: [PATCH] openwrt: Update kernel to 5.15.156

---
 NEWS                                          |   2 +-
 ...7-kernel-Fix-compilation-of-5.15.156.patch | 190 ++++++++++++++++++
 ...add-dedicated-files-for-versions-5.1.patch |   4 +-
 3 files changed, 193 insertions(+), 3 deletions(-)
 create mode 100644 patches/openwrt/a-new-kernel-5.15/0037-kernel-Fix-compilation-of-5.15.156.patch

diff --git a/NEWS b/NEWS
index 215aee406..6ecb82c0e 100644
--- a/NEWS
+++ b/NEWS
@@ -7,7 +7,7 @@
 đź“Ś Updates
   • ethtool: Update to 6.6
   • iproute2: Update to 6.7.0
-  • kernel: Update to 5.15.152
+  • kernel: Update to 5.15.156
 
 7.0.0
 -----
diff --git a/patches/openwrt/a-new-kernel-5.15/0037-kernel-Fix-compilation-of-5.15.156.patch b/patches/openwrt/a-new-kernel-5.15/0037-kernel-Fix-compilation-of-5.15.156.patch
new file mode 100644
index 000000000..5b916cddf
--- /dev/null
+++ b/patches/openwrt/a-new-kernel-5.15/0037-kernel-Fix-compilation-of-5.15.156.patch
@@ -0,0 +1,190 @@
+From 1e6d3caff7e5335a2aa2f3bcf0e836ff8157a593 Mon Sep 17 00:00:00 2001
+From: Michal Hrusecky <michal.hrusecky@turris.com>
+Date: Fri, 26 Apr 2024 13:18:08 +0200
+Subject: [PATCH] kernel: Fix compilation of 5.15.156
+
+Drop one patch already included in upstream kernel, disable NFSv2 and
+rebase another patch.
+---
+ package/kernel/linux/modules/fs.mk            |  1 +
+ ...c-move-MAC_MCR-setting-to-mac_finish.patch | 79 -------------------
+ .../hack-5.15/221-module_exports.patch        | 30 ++++---
+ 3 files changed, 20 insertions(+), 90 deletions(-)
+ delete mode 100644 target/linux/generic/backport-5.15/704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch
+
+diff --git a/package/kernel/linux/modules/fs.mk b/package/kernel/linux/modules/fs.mk
+index 649588543b..64bc443fb8 100644
+--- a/package/kernel/linux/modules/fs.mk
++++ b/package/kernel/linux/modules/fs.mk
+@@ -481,6 +481,7 @@ define KernelPackage/fs-nfsd
+   DEPENDS:=+kmod-fs-nfs-common +kmod-fs-exportfs +kmod-fs-nfs-common-rpcsec
+   KCONFIG:= \
+ 	CONFIG_NFSD \
++	CONFIG_NFSD_V2=n \
+ 	CONFIG_NFSD_V4=y \
+ 	CONFIG_NFSD_V4_SECURITY_LABEL=n \
+ 	CONFIG_NFSD_BLOCKLAYOUT=n \
+diff --git a/target/linux/generic/backport-5.15/704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch b/target/linux/generic/backport-5.15/704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch
+deleted file mode 100644
+index 337c6112d6..0000000000
+--- a/target/linux/generic/backport-5.15/704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch
++++ /dev/null
+@@ -1,79 +0,0 @@
+-From 0e37ad71b2ff772009595002da2860999e98e14e Mon Sep 17 00:00:00 2001
+-From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
+-Date: Wed, 18 May 2022 15:55:12 +0100
+-Subject: [PATCH 09/12] net: mtk_eth_soc: move MAC_MCR setting to mac_finish()
+-
+-Move the setting of the MTK_MAC_MCR register from the end of mac_config
+-into the phylink mac_finish() method, to keep it as the very last write
+-that is done during configuration.
+-
+-Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
+-Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+----
+- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 33 ++++++++++++++-------
+- 1 file changed, 22 insertions(+), 11 deletions(-)
+-
+---- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+-+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+-@@ -316,8 +316,8 @@ static void mtk_mac_config(struct phylin
+- 	struct mtk_mac *mac = container_of(config, struct mtk_mac,
+- 					   phylink_config);
+- 	struct mtk_eth *eth = mac->hw;
+--	u32 mcr_cur, mcr_new, sid, i;
+- 	int val, ge_mode, err = 0;
+-+	u32 sid, i;
+- 
+- 	/* MT76x8 has no hardware settings between for the MAC */
+- 	if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) &&
+-@@ -455,6 +455,25 @@ static void mtk_mac_config(struct phylin
+- 		return;
+- 	}
+- 
+-+	return;
+-+
+-+err_phy:
+-+	dev_err(eth->dev, "%s: GMAC%d mode %s not supported!\n", __func__,
+-+		mac->id, phy_modes(state->interface));
+-+	return;
+-+
+-+init_err:
+-+	dev_err(eth->dev, "%s: GMAC%d mode %s err: %d!\n", __func__,
+-+		mac->id, phy_modes(state->interface), err);
+-+}
+-+
+-+static int mtk_mac_finish(struct phylink_config *config, unsigned int mode,
+-+			  phy_interface_t interface)
+-+{
+-+	struct mtk_mac *mac = container_of(config, struct mtk_mac,
+-+					   phylink_config);
+-+	u32 mcr_cur, mcr_new;
+-+
+- 	/* Setup gmac */
+- 	mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
+- 	mcr_new = mcr_cur;
+-@@ -466,16 +485,7 @@ static void mtk_mac_config(struct phylin
+- 	if (mcr_new != mcr_cur)
+- 		mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id));
+- 
+--	return;
+--
+--err_phy:
+--	dev_err(eth->dev, "%s: GMAC%d mode %s not supported!\n", __func__,
+--		mac->id, phy_modes(state->interface));
+--	return;
+--
+--init_err:
+--	dev_err(eth->dev, "%s: GMAC%d mode %s err: %d!\n", __func__,
+--		mac->id, phy_modes(state->interface), err);
+-+	return 0;
+- }
+- 
+- static void mtk_mac_pcs_get_state(struct phylink_config *config,
+-@@ -582,6 +592,7 @@ static const struct phylink_mac_ops mtk_
+- 	.mac_pcs_get_state = mtk_mac_pcs_get_state,
+- 	.mac_an_restart = mtk_mac_an_restart,
+- 	.mac_config = mtk_mac_config,
+-+	.mac_finish = mtk_mac_finish,
+- 	.mac_link_down = mtk_mac_link_down,
+- 	.mac_link_up = mtk_mac_link_up,
+- };
+diff --git a/target/linux/generic/hack-5.15/221-module_exports.patch b/target/linux/generic/hack-5.15/221-module_exports.patch
+index 405dc5f78c..1b0eaba75a 100644
+--- a/target/linux/generic/hack-5.15/221-module_exports.patch
++++ b/target/linux/generic/hack-5.15/221-module_exports.patch
+@@ -11,8 +11,10 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+  scripts/Makefile.build            |  2 +-
+  3 files changed, 24 insertions(+), 5 deletions(-)
+ 
+---- a/include/asm-generic/vmlinux.lds.h
+-+++ b/include/asm-generic/vmlinux.lds.h
++Index: linux-5.15.156/include/asm-generic/vmlinux.lds.h
++===================================================================
++--- linux-5.15.156.orig/include/asm-generic/vmlinux.lds.h
+++++ linux-5.15.156/include/asm-generic/vmlinux.lds.h
+ @@ -81,6 +81,16 @@
+  #define RO_EXCEPTION_TABLE
+  #endif
+@@ -27,8 +29,8 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+ +#define SYMTAB_DISCARD_GPL
+ +#endif
+ +
+- /* Align . to a 8 byte boundary equals to maximum function alignment. */
+- #define ALIGN_FUNCTION()  . = ALIGN(8)
++ /* Align . function alignment. */
++ #define ALIGN_FUNCTION()  . = ALIGN(CONFIG_FUNCTION_ALIGNMENT)
+  
+ @@ -485,14 +495,14 @@
+  	/* Kernel symbol table: Normal symbols */			\
+@@ -56,7 +58,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+  	}								\
+  									\
+  	/* __*init sections */						\
+-@@ -1017,6 +1027,8 @@
++@@ -1022,6 +1032,8 @@
+  
+  #define COMMON_DISCARDS							\
+  	SANITIZER_DISCARDS						\
+@@ -65,8 +67,10 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+  	*(.discard)							\
+  	*(.discard.*)							\
+  	*(.modinfo)							\
+---- a/include/linux/export.h
+-+++ b/include/linux/export.h
++Index: linux-5.15.156/include/linux/export.h
++===================================================================
++--- linux-5.15.156.orig/include/linux/export.h
+++++ linux-5.15.156/include/linux/export.h
+ @@ -84,6 +84,12 @@ struct kernel_symbol {
+  
+  #else
+@@ -89,8 +93,10 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+  	    "__kstrtab_" #sym ":					\n"	\
+  	    "	.asciz 	\"" #sym "\"					\n"	\
+  	    "__kstrtabns_" #sym ":					\n"	\
+---- a/include/asm-generic/export.h
+-+++ b/include/asm-generic/export.h
++Index: linux-5.15.156/include/asm-generic/export.h
++===================================================================
++--- linux-5.15.156.orig/include/asm-generic/export.h
+++++ linux-5.15.156/include/asm-generic/export.h
+ @@ -26,6 +26,12 @@
+  #endif
+  .endm
+@@ -113,8 +119,10 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+  __kstrtab_\name:
+  	.asciz "\name"
+  	.previous
+---- a/scripts/Makefile.build
+-+++ b/scripts/Makefile.build
++Index: linux-5.15.156/scripts/Makefile.build
++===================================================================
++--- linux-5.15.156.orig/scripts/Makefile.build
+++++ linux-5.15.156/scripts/Makefile.build
+ @@ -397,7 +397,7 @@ targets += $(real-dtb-y) $(lib-y) $(alwa
+  # Linker scripts preprocessor (.lds.S -> .lds)
+  # ---------------------------------------------------------------------------
+-- 
+2.44.0
+
diff --git a/patches/openwrt/wip/0003-include-kernels-add-dedicated-files-for-versions-5.1.patch b/patches/openwrt/wip/0003-include-kernels-add-dedicated-files-for-versions-5.1.patch
index 660c523ce..27ce39015 100644
--- a/patches/openwrt/wip/0003-include-kernels-add-dedicated-files-for-versions-5.1.patch
+++ b/patches/openwrt/wip/0003-include-kernels-add-dedicated-files-for-versions-5.1.patch
@@ -16,8 +16,8 @@ index 0000000000..4c18bc35c2
 --- /dev/null
 +++ b/include/kernel-5.15
 @@ -0,0 +1,2 @@
-+LINUX_VERSION-5.15 = .152
-+LINUX_KERNEL_HASH-5.15.152 = f0805225f4a5b24d0bba9302c2c2f261c04f737ac5dd931da9b112e9f3e4a47e
++LINUX_VERSION-5.15 = .156
++LINUX_KERNEL_HASH-5.15.156 = 9f0465d14c93691056f5f94de647601f94f083ad8ce2e5d306564394b13e7778
 -- 
 2.40.1
 
-- 
GitLab