From d9bc5c93de1412ee13acc61e3aa0a52327b44e5e Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Thu, 4 Jan 2024 02:02:53 +0800 Subject: [PATCH] generic: 6.6: manually refresh hack patches Refresh hack patches for kernel 6.6. Signed-off-by: Weijie Gao --- .../generic/hack-6.6/204-module_strip.patch | 24 ++-- .../211-darwin-uuid-typedef-clash.patch | 6 +- .../hack-6.6/212-tools_portability.patch | 34 +++--- .../hack-6.6/220-arm-gc_sections.patch | 2 +- .../generic/hack-6.6/221-module_exports.patch | 58 +++------ .../linux/generic/hack-6.6/251-kconfig.patch | 6 +- .../generic/hack-6.6/259-regmap_dynamic.patch | 44 ++++--- .../260-crypto_test_dependencies.patch | 36 +++--- .../hack-6.6/261-lib-arc4-unhide.patch | 6 +- ...upport-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch | 4 +- .../721-net-add-packet-mangeling.patch | 6 +- ...hy-aquantia-enable-AQR112-and-AQR412.patch | 71 ++++------- ...ntia-add-PHY_IDs-for-AQR112-variants.patch | 14 +-- ...mtk-lynxi-workaround-2500BaseX-no-an.patch | 33 ++++-- ...-r8152-add-LED-configuration-from-OF.patch | 2 +- .../765-mxl-gpy-control-LED-reg-from-DT.patch | 10 +- .../790-SFP-GE-T-ignore-TX_FAULT.patch | 4 +- .../800-GPIO-add-named-gpio-exports.patch | 112 ++++++++---------- .../hack-6.6/901-debloat_sock_diag.patch | 53 +++++---- 19 files changed, 243 insertions(+), 282 deletions(-) diff --git a/target/linux/generic/hack-6.6/204-module_strip.patch b/target/linux/generic/hack-6.6/204-module_strip.patch index 9fefd0bd6e..6ff9d6a13b 100644 --- a/target/linux/generic/hack-6.6/204-module_strip.patch +++ b/target/linux/generic/hack-6.6/204-module_strip.patch @@ -102,7 +102,7 @@ Signed-off-by: Felix Fietkau endif # MODULES --- a/kernel/module/main.c +++ b/kernel/module/main.c -@@ -988,6 +988,7 @@ size_t modinfo_attrs_count = ARRAY_SIZE( +@@ -997,6 +997,7 @@ size_t modinfo_attrs_count = ARRAY_SIZE( static const char vermagic[] = VERMAGIC_STRING; @@ -110,15 +110,15 @@ Signed-off-by: Felix Fietkau int try_to_force_load(struct module *mod, const char *reason) { #ifdef CONFIG_MODULE_FORCE_LOAD -@@ -999,6 +1000,7 @@ int try_to_force_load(struct module *mod +@@ -1008,6 +1009,7 @@ int try_to_force_load(struct module *mod return -ENOEXEC; #endif } +#endif - static char *get_modinfo(const struct load_info *info, const char *tag); - static char *get_next_modinfo(const struct load_info *info, const char *tag, -@@ -1958,9 +1960,11 @@ static int setup_load_info(struct load_i + /* Parse tag=value strings from .modinfo section */ + char *module_next_tag_pair(char *string, unsigned long *secsize) +@@ -2075,9 +2077,11 @@ static void module_augment_kernel_taints static int check_modinfo(struct module *mod, struct load_info *info, int flags) { @@ -131,14 +131,14 @@ Signed-off-by: Felix Fietkau if (flags & MODULE_INIT_IGNORE_VERMAGIC) modmagic = NULL; -@@ -1981,6 +1985,7 @@ static int check_modinfo(struct module * - mod->name); - add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK); +@@ -2091,6 +2095,7 @@ static int check_modinfo(struct module * + info->name, modmagic, vermagic); + return -ENOEXEC; } +#endif - check_modinfo_retpoline(mod, info); - + err = check_modinfo_livepatch(mod, info); + if (err) --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1785,7 +1785,9 @@ static void read_symbols(const char *mod @@ -150,8 +150,8 @@ Signed-off-by: Felix Fietkau +#endif } - for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { -@@ -1948,8 +1950,10 @@ static void add_header(struct buffer *b, + check_sec_ref(mod, &info); +@@ -1944,8 +1946,10 @@ static void add_header(struct buffer *b, buf_printf(b, "BUILD_SALT;\n"); buf_printf(b, "BUILD_LTO_INFO;\n"); buf_printf(b, "\n"); diff --git a/target/linux/generic/hack-6.6/211-darwin-uuid-typedef-clash.patch b/target/linux/generic/hack-6.6/211-darwin-uuid-typedef-clash.patch index 50a6227148..9a1905a138 100644 --- a/target/linux/generic/hack-6.6/211-darwin-uuid-typedef-clash.patch +++ b/target/linux/generic/hack-6.6/211-darwin-uuid-typedef-clash.patch @@ -11,12 +11,12 @@ Signed-off-by: Kevin Darbyshire-Bryant --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -38,6 +38,9 @@ typedef struct { - __u8 b[16]; - } guid_t; + typedef uint16_t __u16; + typedef unsigned char __u8; +#ifdef __APPLE__ +#define uuid_t compat_uuid_t +#endif - /* backwards compatibility, don't use in new code */ + /* UUID types for backward compatibility, don't use in new code */ typedef struct { __u8 b[16]; diff --git a/target/linux/generic/hack-6.6/212-tools_portability.patch b/target/linux/generic/hack-6.6/212-tools_portability.patch index add281991e..4671e75128 100644 --- a/target/linux/generic/hack-6.6/212-tools_portability.patch +++ b/target/linux/generic/hack-6.6/212-tools_portability.patch @@ -74,8 +74,8 @@ Signed-off-by: Felix Fietkau struct page; struct kmem_cache; @@ -51,7 +55,9 @@ typedef __s8 s8; - #define __force #define __user + #endif #define __must_check +#ifndef __cold #define __cold @@ -108,7 +108,7 @@ Signed-off-by: Felix Fietkau --- a/tools/arch/x86/include/asm/orc_types.h +++ b/tools/arch/x86/include/asm/orc_types.h @@ -40,7 +40,6 @@ - #define ORC_REG_MAX 15 + #define ORC_TYPE_REGS_PARTIAL 4 #ifndef __ASSEMBLY__ -#include @@ -123,13 +123,13 @@ Signed-off-by: Felix Fietkau +#if __BYTE_ORDER == __LITTLE_ENDIAN unsigned sp_reg:4; unsigned bp_reg:4; - unsigned type:2; - unsigned end:1; + unsigned type:3; + unsigned signal:1; -#elif defined(__BIG_ENDIAN_BITFIELD) +#elif __BYTE_ORDER == __BIG_ENDIAN unsigned bp_reg:4; unsigned sp_reg:4; - unsigned unused:5; + unsigned unused:4; --- a/tools/arch/x86/lib/insn.c +++ b/tools/arch/x86/lib/insn.c @@ -15,7 +15,11 @@ @@ -199,15 +199,15 @@ Signed-off-by: Felix Fietkau unsigned long __rb_parent_color; --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile -@@ -4,7 +4,7 @@ include ../scripts/Makefile.arch +@@ -40,7 +40,7 @@ include ../scripts/Makefile.arch + OBJTOOL_CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) - # always use the host compiler - AR = $(HOSTAR) --CC = $(HOSTCC) -+CC = $(HOSTCC) $(HOST_EXTRACFLAGS) - LD = $(HOSTLD) + # Always want host compilation. +-HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" ++HOST_OVERRIDES := CC="$(HOSTCC) $(HOST_EXTRACFLAGS)" LD="$(HOSTLD)" AR="$(HOSTAR)" - ifeq ($(srctree),) + AWK = awk + MKDIR = mkdir @@ -43,6 +43,7 @@ BUILD_ORC := n ifeq ($(SRCARCH),x86) @@ -252,8 +252,8 @@ Signed-off-by: Felix Fietkau } +#endif - #define NEGATIVE_RELOC ((void *)-1L) - + static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *insn) + { --- a/tools/objtool/include/objtool/objtool.h +++ b/tools/objtool/include/objtool/objtool.h @@ -12,7 +12,9 @@ @@ -268,10 +268,10 @@ Signed-off-by: Felix Fietkau bool clean; --- a/tools/objtool/orc_dump.c +++ b/tools/objtool/orc_dump.c -@@ -5,10 +5,10 @@ +@@ -4,10 +4,10 @@ + */ #include - #include -#include #include #include @@ -285,7 +285,7 @@ Signed-off-by: Felix Fietkau @@ -7,11 +7,11 @@ #include - #include + #include -#include #include diff --git a/target/linux/generic/hack-6.6/220-arm-gc_sections.patch b/target/linux/generic/hack-6.6/220-arm-gc_sections.patch index a6a6c7cf2c..257796aee9 100644 --- a/target/linux/generic/hack-6.6/220-arm-gc_sections.patch +++ b/target/linux/generic/hack-6.6/220-arm-gc_sections.patch @@ -13,7 +13,7 @@ Signed-off-by: Gabor Juhos --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -124,6 +124,7 @@ config ARM - select HAVE_VIRT_CPU_ACCOUNTING_GEN + select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU select IRQ_FORCED_THREADING select LOCK_MM_AND_FIND_VMA + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION diff --git a/target/linux/generic/hack-6.6/221-module_exports.patch b/target/linux/generic/hack-6.6/221-module_exports.patch index 967510bcb6..5af4eba372 100644 --- a/target/linux/generic/hack-6.6/221-module_exports.patch +++ b/target/linux/generic/hack-6.6/221-module_exports.patch @@ -27,8 +27,8 @@ Signed-off-by: Felix Fietkau +#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) @@ -511,14 +521,14 @@ /* Kernel symbol table: Normal symbols */ \ @@ -64,12 +64,12 @@ Signed-off-by: Felix Fietkau + SYMTAB_DISCARD_GPL \ *(.discard) \ *(.discard.*) \ - *(.modinfo) \ ---- a/include/linux/export.h -+++ b/include/linux/export.h -@@ -72,6 +72,12 @@ struct kernel_symbol { - - #else + *(.export_symbol) \ +--- a/include/linux/export-internal.h ++++ b/include/linux/export-internal.h +@@ -23,6 +23,12 @@ + #define __KSYM_REF(sym) ".long " #sym + #endif +#ifdef MODULE +#define __EXPORT_SUFFIX(sym) @@ -80,39 +80,15 @@ Signed-off-by: Felix Fietkau /* * For every exported symbol, do the following: * -@@ -87,7 +93,7 @@ struct kernel_symbol { - extern typeof(sym) sym; \ - extern const char __kstrtab_##sym[]; \ - extern const char __kstrtabns_##sym[]; \ -- asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1 \n" \ -+ asm(" .section \"__ksymtab_strings" __EXPORT_SUFFIX(sym) "\",\"aMS\",%progbits,1 \n" \ - "__kstrtab_" #sym ": \n" \ - " .asciz \"" #sym "\" \n" \ - "__kstrtabns_" #sym ": \n" \ ---- a/include/asm-generic/export.h -+++ b/include/asm-generic/export.h -@@ -31,6 +31,12 @@ - #endif - .endm - -+#ifdef MODULE -+#define __EXPORT_SUFFIX(name) -+#else -+#define __EXPORT_SUFFIX(name) + #name -+#endif -+ - /* - * note on .section use: we specify progbits since usage of the "M" (SHF_MERGE) - * section flag requires it. Use '%progbits' instead of '@progbits' since the -@@ -44,7 +50,7 @@ - __ksymtab_\name: - __put \val, __kstrtab_\name - .previous -- .section __ksymtab_strings,"aMS",%progbits,1 -+ .section __ksymtab_strings __EXPORT_SUFFIX(name),"aMS",%progbits,1 - __kstrtab_\name: - .asciz "\name" - .previous +@@ -35,7 +41,7 @@ + * former apparently works on all arches according to the binutils source. + */ + #define __KSYMTAB(name, sym, sec, ns) \ +- asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1" "\n" \ ++ asm(" .section \"__ksymtab_strings" __EXPORT_SUFFIX(sym) "\",\"aMS\",%progbits,1" "\n" \ + "__kstrtab_" #name ":" "\n" \ + " .asciz \"" #name "\"" "\n" \ + "__kstrtabns_" #name ":" "\n" \ --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -388,7 +388,7 @@ targets += $(real-dtb-y) $(lib-y) $(alwa diff --git a/target/linux/generic/hack-6.6/251-kconfig.patch b/target/linux/generic/hack-6.6/251-kconfig.patch index fcf4eaf6e8..0cdbe948a1 100644 --- a/target/linux/generic/hack-6.6/251-kconfig.patch +++ b/target/linux/generic/hack-6.6/251-kconfig.patch @@ -35,7 +35,7 @@ Signed-off-by: John Crispin select CRYPTO_ALGAPI @@ -75,7 +75,7 @@ config CRYPTO_AEAD2 - select CRYPTO_RNG2 + select CRYPTO_ALGAPI2 config CRYPTO_SKCIPHER - tristate @@ -44,7 +44,7 @@ Signed-off-by: John Crispin select CRYPTO_ALGAPI @@ -85,7 +85,7 @@ config CRYPTO_SKCIPHER2 - select CRYPTO_RNG2 + select CRYPTO_ALGAPI2 config CRYPTO_HASH - tristate @@ -136,7 +136,7 @@ Signed-off-by: John Crispin config SND_SEQ_DEVICE tristate @@ -27,7 +27,7 @@ config SND_RAWMIDI - select SND_SEQ_DEVICE if SND_SEQUENCER != n + The device contains 16 substreams corresponding to UMP groups. config SND_COMPRESS_OFFLOAD - tristate diff --git a/target/linux/generic/hack-6.6/259-regmap_dynamic.patch b/target/linux/generic/hack-6.6/259-regmap_dynamic.patch index 8d25f59ce2..c62e0a6242 100644 --- a/target/linux/generic/hack-6.6/259-regmap_dynamic.patch +++ b/target/linux/generic/hack-6.6/259-regmap_dynamic.patch @@ -14,20 +14,27 @@ Signed-off-by: Felix Fietkau --- a/drivers/base/regmap/Kconfig +++ b/drivers/base/regmap/Kconfig -@@ -4,10 +4,9 @@ +@@ -4,8 +4,7 @@ # subsystems should select the appropriate symbols. config REGMAP -- default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_SOUNDWIRE || REGMAP_SOUNDWIRE_MBQ || REGMAP_SCCB || REGMAP_I3C || REGMAP_SPI_AVMM || REGMAP_MDIO) - select IRQ_DOMAIN if REGMAP_IRQ - select MDIO_BUS if REGMAP_MDIO - bool +- default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_SOUNDWIRE || REGMAP_SOUNDWIRE_MBQ || REGMAP_SCCB || REGMAP_I3C || REGMAP_SPI_AVMM || REGMAP_MDIO || REGMAP_FSI) + tristate + select IRQ_DOMAIN if REGMAP_IRQ + select MDIO_BUS if REGMAP_MDIO + help +@@ -19,7 +18,7 @@ config REGMAP - config REGCACHE_COMPRESSED - select LZO_COMPRESS -@@ -15,53 +14,67 @@ config REGCACHE_COMPRESSED - bool + config REGMAP_KUNIT + tristate "KUnit tests for regmap" +- depends on KUNIT && REGMAP ++ depends on KUNIT + default KUNIT_ALL_TESTS + select REGMAP_RAM + +@@ -34,60 +33,76 @@ config REGMAP_BUILD + normally enabled. config REGMAP_AC97 + select REGMAP @@ -70,6 +77,10 @@ Signed-off-by: Felix Fietkau + select REGMAP bool + config REGMAP_RAM ++ select REGMAP + tristate + config REGMAP_SOUNDWIRE + select REGMAP tristate @@ -94,27 +105,28 @@ Signed-off-by: Felix Fietkau + select REGMAP tristate depends on SPI + + config REGMAP_FSI ++ select REGMAP + tristate + depends on FSI --- a/drivers/base/regmap/Makefile +++ b/drivers/base/regmap/Makefile -@@ -2,10 +2,14 @@ +@@ -2,9 +2,11 @@ # For include/trace/define_trace.h to include trace.h CFLAGS_regmap.o := -I$(src) -obj-$(CONFIG_REGMAP) += regmap.o regcache.o --obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-flat.o --obj-$(CONFIG_REGCACHE_COMPRESSED) += regcache-lzo.o +-obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-flat.o regcache-maple.o -obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o -+regmap-core-objs = regmap.o regcache.o regcache-rbtree.o regcache-flat.o ++regmap-core-objs = regmap.o regcache.o regcache-rbtree.o regcache-flat.o regcache-maple.o +ifdef CONFIG_DEBUG_FS +regmap-core-objs += regmap-debugfs.o +endif -+ifdef CONFIG_REGCACHE_COMPRESSED -+regmap-core-objs += regcache-lzo.o -+endif +obj-$(CONFIG_REGMAP) += regmap-core.o + obj-$(CONFIG_REGMAP_KUNIT) += regmap-kunit.o obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o - obj-$(CONFIG_REGMAP_SLIMBUS) += regmap-slimbus.o --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -9,6 +9,7 @@ diff --git a/target/linux/generic/hack-6.6/260-crypto_test_dependencies.patch b/target/linux/generic/hack-6.6/260-crypto_test_dependencies.patch index 7ea517496e..6221d0f868 100644 --- a/target/linux/generic/hack-6.6/260-crypto_test_dependencies.patch +++ b/target/linux/generic/hack-6.6/260-crypto_test_dependencies.patch @@ -14,39 +14,41 @@ Signed-off-by: Felix Fietkau --- a/crypto/Kconfig +++ b/crypto/Kconfig -@@ -142,13 +142,13 @@ config CRYPTO_MANAGER +@@ -148,15 +148,15 @@ config CRYPTO_MANAGER cbc(aes). config CRYPTO_MANAGER2 - def_tristate CRYPTO_MANAGER || (CRYPTO_MANAGER!=n && CRYPTO_ALGAPI=y) +- select CRYPTO_ACOMP2 - select CRYPTO_AEAD2 -- select CRYPTO_HASH2 -- select CRYPTO_SKCIPHER2 - select CRYPTO_AKCIPHER2 +- select CRYPTO_SIG2 +- select CRYPTO_HASH2 - select CRYPTO_KPP2 -- select CRYPTO_ACOMP2 +- select CRYPTO_RNG2 +- select CRYPTO_SKCIPHER2 + def_tristate CRYPTO_MANAGER || (CRYPTO_MANAGER!=n && CRYPTO_ALGAPI=y && !CRYPTO_MANAGER_DISABLE_TESTS) ++ select CRYPTO_ACOMP2 if !CRYPTO_MANAGER_DISABLE_TESTS + select CRYPTO_AEAD2 if !CRYPTO_MANAGER_DISABLE_TESTS -+ select CRYPTO_HASH2 if !CRYPTO_MANAGER_DISABLE_TESTS -+ select CRYPTO_SKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS + select CRYPTO_AKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_SIG2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_HASH2 if !CRYPTO_MANAGER_DISABLE_TESTS + select CRYPTO_KPP2 if !CRYPTO_MANAGER_DISABLE_TESTS -+ select CRYPTO_ACOMP2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_RNG2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_SKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS config CRYPTO_USER tristate "Userspace cryptographic algorithm configuration" --- a/crypto/algboss.c +++ b/crypto/algboss.c -@@ -211,8 +211,12 @@ static int cryptomgr_schedule_test(struc - type = alg->cra_flags; +@@ -204,6 +204,10 @@ static int cryptomgr_schedule_test(struc + memcpy(param->alg, alg->cra_name, sizeof(param->alg)); + param->type = alg->cra_flags; - /* Do not test internal algorithms. */ +#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS -+ type |= CRYPTO_ALG_TESTED; -+#else - if (type & CRYPTO_ALG_INTERNAL) - type |= CRYPTO_ALG_TESTED; ++ param->type |= CRYPTO_ALG_TESTED; +#endif - - param->type = type; - ++ + thread = kthread_run(cryptomgr_test, param, "cryptomgr_test"); + if (IS_ERR(thread)) + goto err_free_param; diff --git a/target/linux/generic/hack-6.6/261-lib-arc4-unhide.patch b/target/linux/generic/hack-6.6/261-lib-arc4-unhide.patch index 01829b2d51..64b4ca4521 100644 --- a/target/linux/generic/hack-6.6/261-lib-arc4-unhide.patch +++ b/target/linux/generic/hack-6.6/261-lib-arc4-unhide.patch @@ -14,11 +14,11 @@ from backports. --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -9,7 +9,7 @@ config CRYPTO_LIB_AES - tristate + select CRYPTO_LIB_UTILS config CRYPTO_LIB_ARC4 - tristate + tristate "ARC4 cipher library" - config CRYPTO_ARCH_HAVE_LIB_BLAKE2S - bool + config CRYPTO_LIB_GF128MUL + tristate diff --git a/target/linux/generic/hack-6.6/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch b/target/linux/generic/hack-6.6/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch index 7c7e4c814e..726a2a0f18 100644 --- a/target/linux/generic/hack-6.6/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch +++ b/target/linux/generic/hack-6.6/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch @@ -16,8 +16,8 @@ Signed-off-by: Rafał Miłecki mutex_unlock(&mtd_table_mutex); -- if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL)) { -+ if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL) || +- if (of_property_read_bool(mtd_get_of_node(mtd), "linux,rootfs")) { ++ if (of_property_read_bool(mtd_get_of_node(mtd), "linux,rootfs") || + (IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) && !strcmp(mtd->name, "rootfs") && ROOT_DEV == 0)) { if (IS_BUILTIN(CONFIG_MTD)) { pr_info("mtd: setting mtd%d (%s) as root device\n", mtd->index, mtd->name); diff --git a/target/linux/generic/hack-6.6/721-net-add-packet-mangeling.patch b/target/linux/generic/hack-6.6/721-net-add-packet-mangeling.patch index b0be9dfdcb..64465fae2a 100644 --- a/target/linux/generic/hack-6.6/721-net-add-packet-mangeling.patch +++ b/target/linux/generic/hack-6.6/721-net-add-packet-mangeling.patch @@ -19,11 +19,11 @@ Signed-off-by: Felix Fietkau --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -1730,6 +1730,7 @@ enum netdev_priv_flags { - /* was IFF_LIVE_RENAME_OK */ +@@ -1707,6 +1707,7 @@ enum netdev_priv_flags { IFF_TX_SKB_NO_LINEAR = BIT_ULL(31), IFF_CHANGE_PROTO_DOWN = BIT_ULL(32), -+ IFF_NO_IP_ALIGN = BIT_ULL(33), + IFF_SEE_ALL_HWTSTAMP_REQUESTS = BIT_ULL(33), ++ IFF_NO_IP_ALIGN = BIT_ULL(34), }; #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN diff --git a/target/linux/generic/hack-6.6/722-net-phy-aquantia-enable-AQR112-and-AQR412.patch b/target/linux/generic/hack-6.6/722-net-phy-aquantia-enable-AQR112-and-AQR412.patch index faaa40f9bd..1232c664ed 100644 --- a/target/linux/generic/hack-6.6/722-net-phy-aquantia-enable-AQR112-and-AQR412.patch +++ b/target/linux/generic/hack-6.6/722-net-phy-aquantia-enable-AQR112-and-AQR412.patch @@ -15,16 +15,7 @@ Signed-off-by: Alex Marginean --- a/drivers/net/phy/aquantia/aquantia_main.c +++ b/drivers/net/phy/aquantia/aquantia_main.c -@@ -27,6 +27,8 @@ - #define PHY_ID_AQR113 0x31c31c40 - #define PHY_ID_AQR113C 0x31c31c12 - #define PHY_ID_AQR813 0x31c31cb2 -+#define PHY_ID_AQR112 0x03a1b662 -+#define PHY_ID_AQR412 0x03a1b712 - - #define MDIO_PHYXS_VEND_IF_STATUS 0xe812 - #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK GENMASK(7, 3) -@@ -99,6 +101,29 @@ +@@ -101,6 +101,29 @@ #define AQR107_OP_IN_PROG_SLEEP 1000 #define AQR107_OP_IN_PROG_TIMEOUT 100000 @@ -54,7 +45,7 @@ Signed-off-by: Alex Marginean struct aqr107_hw_stat { const char *name; int reg; -@@ -230,6 +255,51 @@ static int aqr_config_aneg(struct phy_de +@@ -232,6 +255,51 @@ static int aqr_config_aneg(struct phy_de return genphy_c45_check_and_restart_aneg(phydev, changed); } @@ -106,43 +97,21 @@ Signed-off-by: Alex Marginean static int aqr_config_intr(struct phy_device *phydev) { bool en = phydev->interrupts == PHY_INTERRUPT_ENABLED; -@@ -860,6 +930,30 @@ static struct phy_driver aqr_driver[] = - .get_stats = aqr107_get_stats, - .link_change_notify = aqr107_link_change_notify, - }, -+{ -+ PHY_ID_MATCH_MODEL(PHY_ID_AQR112), -+ .name = "Aquantia AQR112", -+ .probe = aqr107_probe, -+ .config_aneg = aqr_config_aneg_set_prot, -+ .config_intr = aqr_config_intr, -+ .handle_interrupt = aqr_handle_interrupt, -+ .read_status = aqr107_read_status, -+ .get_sset_count = aqr107_get_sset_count, -+ .get_strings = aqr107_get_strings, -+ .get_stats = aqr107_get_stats, -+}, -+{ -+ PHY_ID_MATCH_MODEL(PHY_ID_AQR412), -+ .name = "Aquantia AQR412", -+ .probe = aqr107_probe, -+ .config_aneg = aqr_config_aneg_set_prot, -+ .config_intr = aqr_config_intr, -+ .handle_interrupt = aqr_handle_interrupt, -+ .read_status = aqr107_read_status, -+ .get_sset_count = aqr107_get_sset_count, -+ .get_strings = aqr107_get_strings, -+ .get_stats = aqr107_get_stats, -+}, - }; - - module_phy_driver(aqr_driver); -@@ -877,6 +971,8 @@ static struct mdio_device_id __maybe_unu - { PHY_ID_MATCH_MODEL(PHY_ID_AQR113) }, - { PHY_ID_MATCH_MODEL(PHY_ID_AQR113C) }, - { PHY_ID_MATCH_MODEL(PHY_ID_AQR813) }, -+ { PHY_ID_MATCH_MODEL(PHY_ID_AQR112) }, -+ { PHY_ID_MATCH_MODEL(PHY_ID_AQR412) }, - { } - }; - +@@ -809,7 +877,7 @@ static struct phy_driver aqr_driver[] = + PHY_ID_MATCH_MODEL(PHY_ID_AQR112), + .name = "Aquantia AQR112", + .probe = aqr107_probe, +- .config_aneg = aqr_config_aneg, ++ .config_aneg = aqr_config_aneg_set_prot, + .config_intr = aqr_config_intr, + .handle_interrupt = aqr_handle_interrupt, + .get_tunable = aqr107_get_tunable, +@@ -827,7 +895,7 @@ static struct phy_driver aqr_driver[] = + PHY_ID_MATCH_MODEL(PHY_ID_AQR412), + .name = "Aquantia AQR412", + .probe = aqr107_probe, +- .config_aneg = aqr_config_aneg, ++ .config_aneg = aqr_config_aneg_set_prot, + .config_intr = aqr_config_intr, + .handle_interrupt = aqr_handle_interrupt, + .get_tunable = aqr107_get_tunable, diff --git a/target/linux/generic/hack-6.6/725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch b/target/linux/generic/hack-6.6/725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch index d83cc48a33..bee48be007 100644 --- a/target/linux/generic/hack-6.6/725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch +++ b/target/linux/generic/hack-6.6/725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch @@ -13,17 +13,17 @@ Signed-off-by: Daniel Golle --- a/drivers/net/phy/aquantia/aquantia_main.c +++ b/drivers/net/phy/aquantia/aquantia_main.c @@ -29,6 +29,8 @@ + #define PHY_ID_AQR113 0x31c31c40 + #define PHY_ID_AQR113C 0x31c31c12 #define PHY_ID_AQR813 0x31c31cb2 - #define PHY_ID_AQR112 0x03a1b662 - #define PHY_ID_AQR412 0x03a1b712 +#define PHY_ID_AQR112C 0x03a1b790 +#define PHY_ID_AQR112R 0x31c31d12 #define MDIO_PHYXS_VEND_IF_STATUS 0xe812 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK GENMASK(7, 3) -@@ -960,6 +962,30 @@ static struct phy_driver aqr_driver[] = - .get_strings = aqr107_get_strings, +@@ -898,6 +900,30 @@ static struct phy_driver aqr_driver[] = .get_stats = aqr107_get_stats, + .link_change_notify = aqr107_link_change_notify, }, +{ + PHY_ID_MATCH_MODEL(PHY_ID_AQR112C), @@ -52,10 +52,10 @@ Signed-off-by: Daniel Golle }; module_phy_driver(aqr_driver); -@@ -979,6 +1005,8 @@ static struct mdio_device_id __maybe_unu +@@ -917,6 +943,8 @@ static struct mdio_device_id __maybe_unu + { PHY_ID_MATCH_MODEL(PHY_ID_AQR113) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR113C) }, { PHY_ID_MATCH_MODEL(PHY_ID_AQR813) }, - { PHY_ID_MATCH_MODEL(PHY_ID_AQR112) }, - { PHY_ID_MATCH_MODEL(PHY_ID_AQR412) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR112C) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR112R) }, { } diff --git a/target/linux/generic/hack-6.6/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch b/target/linux/generic/hack-6.6/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch index a2bd3a3dbb..b50973f20b 100644 --- a/target/linux/generic/hack-6.6/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch +++ b/target/linux/generic/hack-6.6/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch @@ -13,7 +13,7 @@ Signed-off-by: Daniel Golle --- a/drivers/net/pcs/pcs-mtk-lynxi.c +++ b/drivers/net/pcs/pcs-mtk-lynxi.c -@@ -114,14 +114,23 @@ static void mtk_pcs_lynxi_get_state(stru +@@ -92,14 +92,23 @@ static void mtk_pcs_lynxi_get_state(struct struct phylink_link_state *state) { struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs); @@ -30,24 +30,35 @@ Signed-off-by: Daniel Golle + state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE); + state->speed = SPEED_2500; + state->duplex = DUPLEX_FULL; ++ ++ return; ++ } - phylink_mii_c22_pcs_decode_state(state, FIELD_GET(SGMII_BMSR, bm), - FIELD_GET(SGMII_LPA, adv)); -+ return; -+ } -+ + regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv); + phylink_mii_c22_pcs_decode_state(state, bmsr, FIELD_GET(SGMII_LPA, adv)); } static void mtk_sgmii_reset(struct mtk_pcs_lynxi *mpcs) -@@ -163,7 +172,8 @@ static int mtk_pcs_lynxi_config(struct p - if (neg_mode & PHYLINK_PCS_NEG_INBAND) - sgm_mode |= SGMII_REMOTE_FAULT_DIS; +@@ -109,7 +118,7 @@ static int mtk_pcs_lynxi_config(struct p + { + struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs); + bool mode_changed = false, changed; +- unsigned int rgc3, sgm_mode, bmcr; ++ unsigned int rgc3, sgm_mode, bmcr = 0; + int advertise, link_timer; -- if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) { -+ if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED && -+ interface != PHY_INTERFACE_MODE_2500BASEX) { + advertise = phylink_mii_c22_pcs_encode_advertisement(interface, +@@ -132,9 +141,8 @@ static int mtk_pcs_lynxi_config(struct p + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) { if (interface == PHY_INTERFACE_MODE_SGMII) sgm_mode |= SGMII_SPEED_DUPLEX_AN; - bmcr = BMCR_ANENABLE; +- bmcr = BMCR_ANENABLE; +- } else { +- bmcr = 0; ++ if (interface != PHY_INTERFACE_MODE_2500BASEX) ++ bmcr = BMCR_ANENABLE; + } + + if (mpcs->interface != interface) { diff --git a/target/linux/generic/hack-6.6/760-net-usb-r8152-add-LED-configuration-from-OF.patch b/target/linux/generic/hack-6.6/760-net-usb-r8152-add-LED-configuration-from-OF.patch index 48d4626ed6..9ef11623fc 100644 --- a/target/linux/generic/hack-6.6/760-net-usb-r8152-add-LED-configuration-from-OF.patch +++ b/target/linux/generic/hack-6.6/760-net-usb-r8152-add-LED-configuration-from-OF.patch @@ -36,7 +36,7 @@ Signed-off-by: David Bauer + + if (ret) + return ret; -+ ++ + ocp_write_word(tp, MCU_TYPE_PLA, PLA_LEDSEL, led_data); + + return 0; diff --git a/target/linux/generic/hack-6.6/765-mxl-gpy-control-LED-reg-from-DT.patch b/target/linux/generic/hack-6.6/765-mxl-gpy-control-LED-reg-from-DT.patch index 2724efa15e..dc582bba28 100644 --- a/target/linux/generic/hack-6.6/765-mxl-gpy-control-LED-reg-from-DT.patch +++ b/target/linux/generic/hack-6.6/765-mxl-gpy-control-LED-reg-from-DT.patch @@ -30,7 +30,7 @@ Signed-off-by: David Bauer +#include #include #include - #include + #include @@ -33,6 +34,7 @@ #define PHY_MIISTAT 0x18 /* MII state */ #define PHY_IMASK 0x19 /* interrupt mask */ @@ -52,9 +52,9 @@ Signed-off-by: David Bauer +/* LED */ +#define VSPEC1_LED(x) (0x1 + x) + - /* SGMII */ - #define VSPEC1_SGMII_CTRL 0x08 - #define VSPEC1_SGMII_CTRL_ANEN BIT(12) /* Aneg enable */ + #define PHY_PMA_MGBT_POLARITY 0x82 + #define PHY_MDI_MDI_X_MASK GENMASK(1, 0) + #define PHY_MDI_MDI_X_NORMAL 0x3 @@ -241,6 +248,35 @@ out: return ret; } @@ -102,4 +102,4 @@ Signed-off-by: David Bauer + return gpy_led_write(phydev); } - static bool gpy_has_broken_mdint(struct phy_device *phydev) + static int gpy_probe(struct phy_device *phydev) diff --git a/target/linux/generic/hack-6.6/790-SFP-GE-T-ignore-TX_FAULT.patch b/target/linux/generic/hack-6.6/790-SFP-GE-T-ignore-TX_FAULT.patch index bb21bb39d3..8fb8aa84d5 100644 --- a/target/linux/generic/hack-6.6/790-SFP-GE-T-ignore-TX_FAULT.patch +++ b/target/linux/generic/hack-6.6/790-SFP-GE-T-ignore-TX_FAULT.patch @@ -27,8 +27,8 @@ Signed-off-by: Daniel Golle --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -409,6 +409,9 @@ static const struct sfp_quirk sfp_quirks - SFP_QUIRK("HUAWEI", "MA5671A", sfp_quirk_2500basex, - sfp_fixup_ignore_tx_fault), + // FS 2.5G Base-T + SFP_QUIRK_M("FS", "SFP-2.5G-T", sfp_quirk_oem_2_5g), + // OEM SFP-GE-T is 1000Base-T module + SFP_QUIRK_F("OEM", "SFP-GE-T", sfp_fixup_ignore_tx_fault), diff --git a/target/linux/generic/hack-6.6/800-GPIO-add-named-gpio-exports.patch b/target/linux/generic/hack-6.6/800-GPIO-add-named-gpio-exports.patch index b60b428dc8..59acb9e57b 100644 --- a/target/linux/generic/hack-6.6/800-GPIO-add-named-gpio-exports.patch +++ b/target/linux/generic/hack-6.6/800-GPIO-add-named-gpio-exports.patch @@ -6,18 +6,18 @@ Subject: [PATCH 30/36] GPIO: add named gpio exports Signed-off-by: John Crispin --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c -@@ -19,6 +19,8 @@ - #include - #include +@@ -21,6 +21,8 @@ + + #include #include +#include +#include #include "gpiolib.h" #include "gpiolib-of.h" -@@ -1030,3 +1032,100 @@ void of_gpio_dev_init(struct gpio_chip * - else - gc->of_node = gdev->dev.of_node; +@@ -1111,3 +1113,74 @@ void of_gpiochip_remove(struct gpio_chip + { + of_node_put(dev_of_node(&chip->gpiodev->dev)); } + +#ifdef CONFIG_GPIO_SYSFS @@ -44,57 +44,31 @@ Signed-off-by: John Crispin + of_property_read_string(cnp, "gpio-export,name", &name); + + if (!name) -+ max_gpio = of_gpio_count(cnp); ++ max_gpio = of_gpio_named_count(cnp, "gpios"); + + for (i = 0; i < max_gpio; i++) { + struct gpio_desc *desc; + unsigned flags = 0; + enum of_gpio_flags of_flags; + -+ gpio = of_get_gpio_flags(cnp, i, &of_flags); -+ if (!gpio_is_valid(gpio)) -+ return gpio; ++ desc = of_get_named_gpiod_flags(cnp, "gpios", i, &of_flags); ++ if (IS_ERR(desc)) ++ return PTR_ERR(desc); ++ gpio = desc_to_gpio(desc); + + if (of_flags & OF_GPIO_ACTIVE_LOW) + flags |= GPIOF_ACTIVE_LOW; + -+ if (!of_property_read_u32(cnp, "gpio-export,output", &val)) { -+ if (of_flags & OF_GPIO_SINGLE_ENDED) { -+ /* -+ * As gpiod_direction_output_raw() is used, we -+ * need to emulate open drain or open source here. -+ */ -+ if (of_flags & OF_GPIO_OPEN_DRAIN) { -+ flags |= GPIOF_OPEN_DRAIN; -+ flags |= val ? GPIOF_IN : GPIOF_OUT_INIT_LOW; -+ } else { -+ flags |= GPIOF_OPEN_SOURCE; -+ flags |= val ? GPIOF_OUT_INIT_HIGH : GPIOF_IN; -+ } -+ } else { -+ flags |= val ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; -+ } -+ } else { ++ if (!of_property_read_u32(cnp, "gpio-export,output", &val)) ++ flags |= val ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; ++ else + flags |= GPIOF_IN; -+ } + + if (devm_gpio_request_one(&pdev->dev, gpio, flags, name ? name : of_node_full_name(np))) + continue; + -+ /* -+ * When emulating open-source or open-drain functionalities by not -+ * actively driving the line (setting mode to input) we still need to -+ * set the IS_OUT flag or otherwise we won't be able to set the line -+ * value anymore. -+ */ -+ if ((flags & GPIOF_IN) && -+ ((flags & GPIOF_OPEN_DRAIN) || (flags & GPIOF_OPEN_SOURCE))) { -+ desc = gpio_to_desc(gpio); -+ set_bit(FLAG_IS_OUT, &desc->flags); -+ } -+ + dmc = of_property_read_bool(cnp, "gpio-export,direction_may_change"); -+ gpio_export_with_name(gpio, dmc, name); ++ gpio_export_with_name(gpio_to_desc(gpio), dmc, name); + nb++; + } + } @@ -116,36 +90,24 @@ Signed-off-by: John Crispin +module_platform_driver(gpio_export_driver); + +#endif ---- a/include/asm-generic/gpio.h -+++ b/include/asm-generic/gpio.h -@@ -125,6 +125,12 @@ static inline int gpio_export(unsigned g - return gpiod_export(gpio_to_desc(gpio), direction_may_change); - } - -+int __gpiod_export(struct gpio_desc *desc, bool direction_may_change, const char *name); -+static inline int gpio_export_with_name(unsigned gpio, bool direction_may_change, const char *name) -+{ -+ return __gpiod_export(gpio_to_desc(gpio), direction_may_change, name); -+} -+ - static inline int gpio_export_link(struct device *dev, const char *name, - unsigned gpio) - { --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h -@@ -715,6 +715,7 @@ static inline struct gpio_desc *acpi_get +@@ -644,7 +644,10 @@ static inline struct gpio_desc *acpi_get #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS) -+int _gpiod_export(struct gpio_desc *desc, bool direction_may_change, const char *name); ++int __gpiod_export(struct gpio_desc *desc, bool direction_may_change, const char *name); int gpiod_export(struct gpio_desc *desc, bool direction_may_change); ++int gpio_export_with_name(struct gpio_desc *desc, bool direction_may_change, ++ const char *name); int gpiod_export_link(struct device *dev, const char *name, struct gpio_desc *desc); -@@ -722,6 +723,13 @@ void gpiod_unexport(struct gpio_desc *de + void gpiod_unexport(struct gpio_desc *desc); +@@ -653,12 +656,26 @@ void gpiod_unexport(struct gpio_desc *de - #else /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */ + #include -+static inline int _gpiod_export(struct gpio_desc *desc, ++static inline int __gpiod_export(struct gpio_desc *desc, + bool direction_may_change, + const char *name) +{ @@ -154,10 +116,23 @@ Signed-off-by: John Crispin + static inline int gpiod_export(struct gpio_desc *desc, bool direction_may_change) + { + return -ENOSYS; + } + ++static inline int gpio_export_with_name(struct gpio_desc *desc, ++ bool direction_may_change, ++ const char *name) ++{ ++ return -ENOSYS; ++} ++ + static inline int gpiod_export_link(struct device *dev, const char *name, + struct gpio_desc *desc) { --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c -@@ -547,7 +547,7 @@ static struct class gpio_class = { +@@ -557,7 +557,7 @@ static struct class gpio_class = { * * Returns zero on success, else an error. */ @@ -166,7 +141,7 @@ Signed-off-by: John Crispin { struct gpio_chip *chip; struct gpio_device *gdev; -@@ -609,6 +609,8 @@ int gpiod_export(struct gpio_desc *desc, +@@ -619,6 +619,8 @@ int gpiod_export(struct gpio_desc *desc, offset = gpio_chip_hwgpio(desc); if (chip->names && chip->names[offset]) ioname = chip->names[offset]; @@ -175,7 +150,7 @@ Signed-off-by: John Crispin dev = device_create_with_groups(&gpio_class, &gdev->dev, MKDEV(0, 0), data, gpio_groups, -@@ -630,6 +632,12 @@ err_unlock: +@@ -640,8 +642,21 @@ int gpiod_export(struct gpio_desc *desc, gpiod_dbg(desc, "%s: status %d\n", __func__, status); return status; } @@ -187,4 +162,13 @@ Signed-off-by: John Crispin +} EXPORT_SYMBOL_GPL(gpiod_export); ++int gpio_export_with_name(struct gpio_desc *desc, bool direction_may_change, ++ const char *name) ++{ ++ return __gpiod_export(desc, direction_may_change, name); ++} ++EXPORT_SYMBOL_GPL(gpio_export_with_name); ++ static int match_export(struct device *dev, const void *desc) + { + struct gpiod_data *data = dev_get_drvdata(dev); diff --git a/target/linux/generic/hack-6.6/901-debloat_sock_diag.patch b/target/linux/generic/hack-6.6/901-debloat_sock_diag.patch index ec71f9af4b..92b35efa55 100644 --- a/target/linux/generic/hack-6.6/901-debloat_sock_diag.patch +++ b/target/linux/generic/hack-6.6/901-debloat_sock_diag.patch @@ -28,13 +28,14 @@ Signed-off-by: Felix Fietkau help --- a/net/core/Makefile +++ b/net/core/Makefile -@@ -11,11 +11,12 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core. +@@ -11,12 +11,13 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core. obj-y += dev.o dev_addr_lists.o dst.o netevent.o \ neighbour.o rtnetlink.o utils.o link_watch.o filter.o \ - sock_diag.o dev_ioctl.o tso.o sock_reuseport.o \ -+ dev_ioctl.o tso.o sock_reuseport.o \ - fib_notifier.o xdp.o flow_offload.o gro.o ++ dev_ioctl.o tso.o sock_reuseport.o \ + fib_notifier.o xdp.o flow_offload.o gro.o \ + netdev-genl.o netdev-genl-gen.o gso.o obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o @@ -44,15 +45,15 @@ Signed-off-by: Felix Fietkau obj-$(CONFIG_PROC_FS) += net-procfs.o --- a/net/core/sock.c +++ b/net/core/sock.c -@@ -115,6 +115,7 @@ - #include - #include - #include +@@ -117,6 +117,7 @@ + #include + #include + #include +#include #include -@@ -146,6 +147,7 @@ +@@ -149,6 +150,7 @@ static DEFINE_MUTEX(proto_list_mutex); static LIST_HEAD(proto_list); @@ -60,26 +61,29 @@ Signed-off-by: Felix Fietkau static void sock_def_write_space_wfree(struct sock *sk); static void sock_def_write_space(struct sock *sk); -@@ -585,6 +587,18 @@ discard_and_relse: +@@ -588,6 +590,21 @@ int __sk_receive_skb(struct sock *sk, str } EXPORT_SYMBOL(__sk_receive_skb); +u64 __sock_gen_cookie(struct sock *sk) +{ -+ while (1) { -+ u64 res = atomic64_read(&sk->sk_cookie); ++ u64 res = atomic64_read(&sk->sk_cookie); + -+ if (res) -+ return res; -+ res = gen_cookie_next(&sock_cookie); -+ atomic64_cmpxchg(&sk->sk_cookie, 0, res); ++ if (!res) { ++ u64 new = gen_cookie_next(&sock_cookie); ++ ++ atomic64_cmpxchg(&sk->sk_cookie, res, new); ++ ++ /* Another thread might have changed sk_cookie before us. */ ++ res = atomic64_read(&sk->sk_cookie); + } ++ return res; +} + INDIRECT_CALLABLE_DECLARE(struct dst_entry *ip6_dst_check(struct dst_entry *, u32)); INDIRECT_CALLABLE_DECLARE(struct dst_entry *ipv4_dst_check(struct dst_entry *, -@@ -2188,9 +2202,11 @@ static void __sk_free(struct sock *sk) +@@ -2238,9 +2255,11 @@ static void __sk_free(struct sock *sk) if (likely(sk->sk_net_refcnt)) sock_inuse_add(sock_net(sk), -1); @@ -101,7 +105,7 @@ Signed-off-by: Felix Fietkau #include #include -@@ -21,20 +20,6 @@ static int (*inet_rcv_compat)(struct sk_ +@@ -21,23 +20,6 @@ static int (*inet_rcv_compat)(struct sk_ static DEFINE_MUTEX(sock_diag_table_mutex); static struct workqueue_struct *broadcast_wq; @@ -109,14 +113,17 @@ Signed-off-by: Felix Fietkau - -u64 __sock_gen_cookie(struct sock *sk) -{ -- while (1) { -- u64 res = atomic64_read(&sk->sk_cookie); +- u64 res = atomic64_read(&sk->sk_cookie); +- +- if (!res) { +- u64 new = gen_cookie_next(&sock_cookie); +- +- atomic64_cmpxchg(&sk->sk_cookie, res, new); - -- if (res) -- return res; -- res = gen_cookie_next(&sock_cookie); -- atomic64_cmpxchg(&sk->sk_cookie, 0, res); +- /* Another thread might have changed sk_cookie before us. */ +- res = atomic64_read(&sk->sk_cookie); - } +- return res; -} - int sock_diag_check_cookie(struct sock *sk, const __u32 *cookie) -- 2.30.2