diff options
Diffstat (limited to 'target/linux/generic/backport-6.6')
64 files changed, 2878 insertions, 109 deletions
diff --git a/target/linux/generic/backport-6.6/0080-v6.9-smp-Avoid-setup_max_cpus_namespace_collision_shadowing.patch b/target/linux/generic/backport-6.6/0080-v6.9-smp-Avoid-setup_max_cpus_namespace_collision_shadowing.patch new file mode 100644 index 0000000000..54ebaa1a80 --- /dev/null +++ b/target/linux/generic/backport-6.6/0080-v6.9-smp-Avoid-setup_max_cpus_namespace_collision_shadowing.patch @@ -0,0 +1,56 @@ +From 4c8a49854130da0117a0fdb858551824919a2389 Mon Sep 17 00:00:00 2001 +From: Ingo Molnar <mingo@kernel.org> +Date: Tue, 27 Feb 2024 09:58:15 +0100 +Subject: [PATCH] smp: Avoid 'setup_max_cpus' namespace collision/shadowing + +bringup_nonboot_cpus() gets passed the 'setup_max_cpus' +variable in init/main.c - which is also the name of the parameter, +shadowing the name. + +To reduce confusion and to allow the 'setup_max_cpus' value +to be #defined in the <linux/smp.h> header, use the 'max_cpus' +name for the function parameter name. + +Signed-off-by: Ingo Molnar <mingo@kernel.org> +Cc: Thomas Gleixner <tglx@linutronix.de> +Cc: linux-kernel@vger.kernel.org +--- + include/linux/cpu.h | 2 +- + kernel/cpu.c | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +--- a/include/linux/cpu.h ++++ b/include/linux/cpu.h +@@ -109,7 +109,7 @@ void notify_cpu_starting(unsigned int cp + extern void cpu_maps_update_begin(void); + extern void cpu_maps_update_done(void); + int bringup_hibernate_cpu(unsigned int sleep_cpu); +-void bringup_nonboot_cpus(unsigned int setup_max_cpus); ++void bringup_nonboot_cpus(unsigned int max_cpus); + + #else /* CONFIG_SMP */ + #define cpuhp_tasks_frozen 0 +--- a/kernel/cpu.c ++++ b/kernel/cpu.c +@@ -1905,17 +1905,17 @@ static bool __init cpuhp_bringup_cpus_pa + static inline bool cpuhp_bringup_cpus_parallel(unsigned int ncpus) { return false; } + #endif /* CONFIG_HOTPLUG_PARALLEL */ + +-void __init bringup_nonboot_cpus(unsigned int setup_max_cpus) ++void __init bringup_nonboot_cpus(unsigned int max_cpus) + { +- if (!setup_max_cpus) ++ if (!max_cpus) + return; + + /* Try parallel bringup optimization if enabled */ +- if (cpuhp_bringup_cpus_parallel(setup_max_cpus)) ++ if (cpuhp_bringup_cpus_parallel(max_cpus)) + return; + + /* Full per CPU serialized bringup */ +- cpuhp_bringup_mask(cpu_present_mask, setup_max_cpus, CPUHP_ONLINE); ++ cpuhp_bringup_mask(cpu_present_mask, max_cpus, CPUHP_ONLINE); + } + + #ifdef CONFIG_PM_SLEEP_SMP diff --git a/target/linux/generic/backport-6.6/200-regmap-maple-work-around-false-positive-warning.patch b/target/linux/generic/backport-6.6/200-regmap-maple-work-around-false-positive-warning.patch new file mode 100644 index 0000000000..de5c813804 --- /dev/null +++ b/target/linux/generic/backport-6.6/200-regmap-maple-work-around-false-positive-warning.patch @@ -0,0 +1,47 @@ +From 542440fd7b30983cae23e32bd22f69a076ec7ef4 Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann <arnd@arndb.de> +Date: Fri, 19 Jul 2024 12:40:24 +0200 +Subject: regmap: maple: work around gcc-14.1 false-positive warning + +With gcc-14.1, there is a false-postive -Wuninitialized warning in +regcache_maple_drop: + +drivers/base/regmap/regcache-maple.c: In function 'regcache_maple_drop': +drivers/base/regmap/regcache-maple.c:113:23: error: 'lower_index' is used uninitialized [-Werror=uninitialized] + 113 | unsigned long lower_index, lower_last; + | ^~~~~~~~~~~ +drivers/base/regmap/regcache-maple.c:113:36: error: 'lower_last' is used uninitialized [-Werror=uninitialized] + 113 | unsigned long lower_index, lower_last; + | ^~~~~~~~~~ + +I've created a reduced test case to see if this needs to be reported +as a gcc, but it appears that the gcc-14.x branch already has a change +that turns this into a more sensible -Wmaybe-uninitialized warning, so +I ended up not reporting it so far. + +The reduced test case also produces a warning for gcc-13 and gcc-12 +but I don't see that with the version in the kernel. + +Link: https://godbolt.org/z/oKbohKqd3 +Link: https://lore.kernel.org/all/CAMuHMdWj=FLmkazPbYKPevDrcym2_HDb_U7Mb9YE9ovrP0jJfA@mail.gmail.com/ +Signed-off-by: Arnd Bergmann <arnd@arndb.de> +Link: https://patch.msgid.link/20240719104030.1382465-1-arnd@kernel.org +Signed-off-by: Mark Brown <broonie@kernel.org> +--- + drivers/base/regmap/regcache-maple.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +(limited to 'drivers/base/regmap/regcache-maple.c') + +--- a/drivers/base/regmap/regcache-maple.c ++++ b/drivers/base/regmap/regcache-maple.c +@@ -110,7 +110,8 @@ static int regcache_maple_drop(struct re + struct maple_tree *mt = map->cache; + MA_STATE(mas, mt, min, max); + unsigned long *entry, *lower, *upper; +- unsigned long lower_index, lower_last; ++ /* initialized to work around false-positive -Wuninitialized warning */ ++ unsigned long lower_index = 0, lower_last = 0; + unsigned long upper_index, upper_last; + int ret = 0; + diff --git a/target/linux/generic/backport-6.6/310-v6.7-mips-kexec-fix-the-incorrect-ifdeffery-and-dependenc.patch b/target/linux/generic/backport-6.6/310-v6.7-mips-kexec-fix-the-incorrect-ifdeffery-and-dependenc.patch index 99a6bfe638..6d3c7d04fe 100644 --- a/target/linux/generic/backport-6.6/310-v6.7-mips-kexec-fix-the-incorrect-ifdeffery-and-dependenc.patch +++ b/target/linux/generic/backport-6.6/310-v6.7-mips-kexec-fix-the-incorrect-ifdeffery-and-dependenc.patch @@ -134,7 +134,7 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org> }; --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c -@@ -392,7 +392,7 @@ static void cps_smp_finish(void) +@@ -395,7 +395,7 @@ static void cps_smp_finish(void) local_irq_enable(); } @@ -143,7 +143,7 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org> enum cpu_death { CPU_DEATH_HALT, -@@ -429,7 +429,7 @@ static void cps_shutdown_this_cpu(enum c +@@ -432,7 +432,7 @@ static void cps_shutdown_this_cpu(enum c } } @@ -152,7 +152,7 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org> static void cps_kexec_nonboot_cpu(void) { -@@ -439,9 +439,9 @@ static void cps_kexec_nonboot_cpu(void) +@@ -442,9 +442,9 @@ static void cps_kexec_nonboot_cpu(void) cps_shutdown_this_cpu(CPU_DEATH_POWER); } @@ -164,7 +164,7 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org> #ifdef CONFIG_HOTPLUG_CPU -@@ -610,7 +610,7 @@ static const struct plat_smp_ops cps_smp +@@ -613,7 +613,7 @@ static const struct plat_smp_ops cps_smp .cpu_die = cps_cpu_die, .cleanup_dead_cpu = cps_cleanup_dead_cpu, #endif @@ -175,8 +175,8 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org> }; --- a/arch/mips/loongson64/reset.c +++ b/arch/mips/loongson64/reset.c -@@ -53,7 +53,7 @@ static void loongson_halt(void) - } +@@ -39,7 +39,7 @@ static int firmware_poweroff(struct sys_ + return NOTIFY_DONE; } -#ifdef CONFIG_KEXEC @@ -184,9 +184,9 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org> /* 0X80000000~0X80200000 is safe */ #define MAX_ARGS 64 -@@ -158,7 +158,7 @@ static int __init mips_reboot_setup(void - _machine_halt = loongson_halt; - pm_power_off = loongson_poweroff; +@@ -152,7 +152,7 @@ static int __init mips_reboot_setup(void + firmware_poweroff, NULL); + } -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE @@ -195,7 +195,7 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org> return -ENOMEM; --- a/arch/mips/loongson64/smp.c +++ b/arch/mips/loongson64/smp.c -@@ -864,7 +864,7 @@ const struct plat_smp_ops loongson3_smp_ +@@ -883,7 +883,7 @@ const struct plat_smp_ops loongson3_smp_ .cpu_disable = loongson3_cpu_disable, .cpu_die = loongson3_cpu_die, #endif diff --git a/target/linux/generic/backport-6.6/320-v6.11-mips-bmips-rework-and-cache-CBR-addr-handling.patch b/target/linux/generic/backport-6.6/320-v6.11-mips-bmips-rework-and-cache-CBR-addr-handling.patch new file mode 100644 index 0000000000..21eaa3d6cb --- /dev/null +++ b/target/linux/generic/backport-6.6/320-v6.11-mips-bmips-rework-and-cache-CBR-addr-handling.patch @@ -0,0 +1,171 @@ +From a5c05453a13ab324ad8719e8a23dfb6af01f3652 Mon Sep 17 00:00:00 2001 +From: Christian Marangi <ansuelsmth@gmail.com> +Date: Thu, 20 Jun 2024 17:26:42 +0200 +Subject: [PATCH 1/4] mips: bmips: rework and cache CBR addr handling + +Rework the handling of the CBR address and cache it. This address +doesn't change and can be cached instead of reading the register every +time. + +This is in preparation of permitting to tweak the CBR address in DT with +broken SoC or bootloader. + +bmips_cbr_addr is defined in setup.c for each arch to keep compatibility +with legacy brcm47xx/brcm63xx and generic BMIPS target. + +Acked-by: Florian Fainelli <florian.fainelli@broadcom.com> +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> +--- + arch/mips/bcm47xx/prom.c | 3 +++ + arch/mips/bcm47xx/setup.c | 4 ++++ + arch/mips/bcm63xx/prom.c | 3 +++ + arch/mips/bcm63xx/setup.c | 4 ++++ + arch/mips/bmips/dma.c | 2 +- + arch/mips/bmips/setup.c | 7 ++++++- + arch/mips/include/asm/bmips.h | 1 + + arch/mips/kernel/smp-bmips.c | 4 ++-- + 8 files changed, 24 insertions(+), 4 deletions(-) + +--- a/arch/mips/bcm47xx/prom.c ++++ b/arch/mips/bcm47xx/prom.c +@@ -32,6 +32,7 @@ + #include <linux/ssb/ssb_driver_chipcommon.h> + #include <linux/ssb/ssb_regs.h> + #include <linux/smp.h> ++#include <asm/bmips.h> + #include <asm/bootinfo.h> + #include <bcm47xx.h> + #include <bcm47xx_board.h> +@@ -109,6 +110,8 @@ static __init void prom_init_mem(void) + + void __init prom_init(void) + { ++ /* Cache CBR addr before CPU/DMA setup */ ++ bmips_cbr_addr = BMIPS_GET_CBR(); + prom_init_mem(); + setup_8250_early_printk_port(CKSEG1ADDR(BCM47XX_SERIAL_ADDR), 0, 0); + } +--- a/arch/mips/bcm47xx/setup.c ++++ b/arch/mips/bcm47xx/setup.c +@@ -37,6 +37,7 @@ + #include <linux/ssb/ssb.h> + #include <linux/ssb/ssb_embedded.h> + #include <linux/bcma/bcma_soc.h> ++#include <asm/bmips.h> + #include <asm/bootinfo.h> + #include <asm/idle.h> + #include <asm/prom.h> +@@ -45,6 +46,9 @@ + #include <bcm47xx.h> + #include <bcm47xx_board.h> + ++/* CBR addr doesn't change and we can cache it */ ++void __iomem *bmips_cbr_addr __read_mostly; ++ + union bcm47xx_bus bcm47xx_bus; + EXPORT_SYMBOL(bcm47xx_bus); + +--- a/arch/mips/bcm63xx/prom.c ++++ b/arch/mips/bcm63xx/prom.c +@@ -22,6 +22,9 @@ void __init prom_init(void) + { + u32 reg, mask; + ++ /* Cache CBR addr before CPU/DMA setup */ ++ bmips_cbr_addr = BMIPS_GET_CBR(); ++ + bcm63xx_cpu_init(); + + /* stop any running watchdog */ +--- a/arch/mips/bcm63xx/setup.c ++++ b/arch/mips/bcm63xx/setup.c +@@ -12,6 +12,7 @@ + #include <linux/memblock.h> + #include <linux/ioport.h> + #include <linux/pm.h> ++#include <asm/bmips.h> + #include <asm/bootinfo.h> + #include <asm/time.h> + #include <asm/reboot.h> +@@ -22,6 +23,9 @@ + #include <bcm63xx_io.h> + #include <bcm63xx_gpio.h> + ++/* CBR addr doesn't change and we can cache it */ ++void __iomem *bmips_cbr_addr __read_mostly; ++ + void bcm63xx_machine_halt(void) + { + pr_info("System halted\n"); +--- a/arch/mips/bmips/dma.c ++++ b/arch/mips/bmips/dma.c +@@ -9,7 +9,7 @@ bool bmips_rac_flush_disable; + + void arch_sync_dma_for_cpu_all(void) + { +- void __iomem *cbr = BMIPS_GET_CBR(); ++ void __iomem *cbr = bmips_cbr_addr; + u32 cfg; + + if (boot_cpu_type() != CPU_BMIPS3300 && +--- a/arch/mips/bmips/setup.c ++++ b/arch/mips/bmips/setup.c +@@ -34,6 +34,9 @@ + #define REG_BCM6328_OTP ((void __iomem *)CKSEG1ADDR(0x1000062c)) + #define BCM6328_TP1_DISABLED BIT(9) + ++/* CBR addr doesn't change and we can cache it */ ++void __iomem *bmips_cbr_addr __read_mostly; ++ + extern bool bmips_rac_flush_disable; + + static const unsigned long kbase = VMLINUX_LOAD_ADDRESS & 0xfff00000; +@@ -111,7 +114,7 @@ static void bcm6358_quirks(void) + * because the bootloader is not initializing it properly. + */ + bmips_rac_flush_disable = !!(read_c0_brcm_cmt_local() & (1 << 31)) || +- !!BMIPS_GET_CBR(); ++ !!bmips_cbr_addr; + } + + static void bcm6368_quirks(void) +@@ -144,6 +147,8 @@ static void __init bmips_init_cfe(void) + + void __init prom_init(void) + { ++ /* Cache CBR addr before CPU/DMA setup */ ++ bmips_cbr_addr = BMIPS_GET_CBR(); + bmips_init_cfe(); + bmips_cpu_setup(); + register_bmips_smp_ops(); +--- a/arch/mips/include/asm/bmips.h ++++ b/arch/mips/include/asm/bmips.h +@@ -81,6 +81,7 @@ extern char bmips_smp_movevec[]; + extern char bmips_smp_int_vec[]; + extern char bmips_smp_int_vec_end[]; + ++extern void __iomem *bmips_cbr_addr; + extern int bmips_smp_enabled; + extern int bmips_cpu_offset; + extern cpumask_t bmips_booted_mask; +--- a/arch/mips/kernel/smp-bmips.c ++++ b/arch/mips/kernel/smp-bmips.c +@@ -518,7 +518,7 @@ static void bmips_set_reset_vec(int cpu, + info.val = val; + bmips_set_reset_vec_remote(&info); + } else { +- void __iomem *cbr = BMIPS_GET_CBR(); ++ void __iomem *cbr = bmips_cbr_addr; + + if (cpu == 0) + __raw_writel(val, cbr + BMIPS_RELO_VECTOR_CONTROL_0); +@@ -591,7 +591,7 @@ asmlinkage void __weak plat_wired_tlb_se + + void bmips_cpu_setup(void) + { +- void __iomem __maybe_unused *cbr = BMIPS_GET_CBR(); ++ void __iomem __maybe_unused *cbr = bmips_cbr_addr; + u32 __maybe_unused cfg; + + switch (current_cpu_type()) { diff --git a/target/linux/generic/backport-6.6/321-v6.11-mips-bmips-setup-make-CBR-address-configurable.patch b/target/linux/generic/backport-6.6/321-v6.11-mips-bmips-setup-make-CBR-address-configurable.patch new file mode 100644 index 0000000000..10a710a31d --- /dev/null +++ b/target/linux/generic/backport-6.6/321-v6.11-mips-bmips-setup-make-CBR-address-configurable.patch @@ -0,0 +1,111 @@ +From b95b30e50aed225d26e20737873ae2404941901c Mon Sep 17 00:00:00 2001 +From: Christian Marangi <ansuelsmth@gmail.com> +Date: Thu, 20 Jun 2024 17:26:44 +0200 +Subject: [PATCH 3/4] mips: bmips: setup: make CBR address configurable + +Add support to provide CBR address from DT to handle broken +SoC/Bootloader that doesn't correctly init it. This permits to use the +RAC flush even in these condition. + +To provide a CBR address from DT, the property "brcm,bmips-cbr-reg" +needs to be set in the "cpus" node. On DT init, this property presence +will be checked and will set the bmips_cbr_addr value accordingly. Also +bmips_rac_flush_disable will be set to false as RAC flush can be +correctly supported. + +The CBR address from DT will overwrite the cached one and the +one set in the CBR register will be ignored. + +Also the DT CBR address is validated on being outside DRAM window. + +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +Acked-by: Florian Fainelli <florian.fainelli@broadcom.com> +Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> +--- + arch/mips/bcm47xx/setup.c | 6 +++++- + arch/mips/bcm63xx/setup.c | 6 +++++- + arch/mips/bmips/setup.c | 30 ++++++++++++++++++++++++++++-- + 3 files changed, 38 insertions(+), 4 deletions(-) + +--- a/arch/mips/bcm47xx/setup.c ++++ b/arch/mips/bcm47xx/setup.c +@@ -46,7 +46,11 @@ + #include <bcm47xx.h> + #include <bcm47xx_board.h> + +-/* CBR addr doesn't change and we can cache it */ ++/* ++ * CBR addr doesn't change and we can cache it. ++ * For broken SoC/Bootloader CBR addr might also be provided via DT ++ * with "brcm,bmips-cbr-reg" in the "cpus" node. ++ */ + void __iomem *bmips_cbr_addr __read_mostly; + + union bcm47xx_bus bcm47xx_bus; +--- a/arch/mips/bcm63xx/setup.c ++++ b/arch/mips/bcm63xx/setup.c +@@ -23,7 +23,11 @@ + #include <bcm63xx_io.h> + #include <bcm63xx_gpio.h> + +-/* CBR addr doesn't change and we can cache it */ ++/* ++ * CBR addr doesn't change and we can cache it. ++ * For broken SoC/Bootloader CBR addr might also be provided via DT ++ * with "brcm,bmips-cbr-reg" in the "cpus" node. ++ */ + void __iomem *bmips_cbr_addr __read_mostly; + + void bcm63xx_machine_halt(void) +--- a/arch/mips/bmips/setup.c ++++ b/arch/mips/bmips/setup.c +@@ -34,7 +34,11 @@ + #define REG_BCM6328_OTP ((void __iomem *)CKSEG1ADDR(0x1000062c)) + #define BCM6328_TP1_DISABLED BIT(9) + +-/* CBR addr doesn't change and we can cache it */ ++/* ++ * CBR addr doesn't change and we can cache it. ++ * For broken SoC/Bootloader CBR addr might also be provided via DT ++ * with "brcm,bmips-cbr-reg" in the "cpus" node. ++ */ + void __iomem *bmips_cbr_addr __read_mostly; + + extern bool bmips_rac_flush_disable; +@@ -208,13 +212,35 @@ void __init plat_mem_setup(void) + void __init device_tree_init(void) + { + struct device_node *np; ++ u32 addr; + + unflatten_and_copy_device_tree(); + + /* Disable SMP boot unless both CPUs are listed in DT and !disabled */ + np = of_find_node_by_name(NULL, "cpus"); +- if (np && of_get_available_child_count(np) <= 1) ++ if (!np) ++ return; ++ ++ if (of_get_available_child_count(np) <= 1) + bmips_smp_enabled = 0; ++ ++ /* Check if DT provide a CBR address */ ++ if (of_property_read_u32(np, "brcm,bmips-cbr-reg", &addr)) ++ goto exit; ++ ++ /* Make sure CBR address is outside DRAM window */ ++ if (addr >= (u32)memblock_start_of_DRAM() && ++ addr < (u32)memblock_end_of_DRAM()) { ++ WARN(1, "DT CBR %x inside DRAM window. Ignoring DT CBR.\n", ++ addr); ++ goto exit; ++ } ++ ++ bmips_cbr_addr = (void __iomem *)addr; ++ /* Since CBR is provided by DT, enable RAC flush */ ++ bmips_rac_flush_disable = false; ++ ++exit: + of_node_put(np); + } + diff --git a/target/linux/generic/backport-6.6/322-v6.11-mips-bmips-enable-RAC-on-BMIPS4350.patch b/target/linux/generic/backport-6.6/322-v6.11-mips-bmips-enable-RAC-on-BMIPS4350.patch new file mode 100644 index 0000000000..2af45df259 --- /dev/null +++ b/target/linux/generic/backport-6.6/322-v6.11-mips-bmips-enable-RAC-on-BMIPS4350.patch @@ -0,0 +1,57 @@ +From 04f38d1a4db017f17e82442727b91ce03dd72759 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Daniel=20Gonz=C3=A1lez=20Cabanelas?= <dgcbueu@gmail.com> +Date: Thu, 20 Jun 2024 17:26:45 +0200 +Subject: [PATCH 4/4] mips: bmips: enable RAC on BMIPS4350 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The data RAC is left disabled by the bootloader in some SoCs, at least in +the core it boots from. +Enabling this feature increases the performance up to +30% depending on the +task. + +Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com> +Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> +[ rework code and reduce code duplication ] +Acked-by: Florian Fainelli <florian.fainelli@broadcom.com> +Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> +Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> +--- + arch/mips/kernel/smp-bmips.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +--- a/arch/mips/kernel/smp-bmips.c ++++ b/arch/mips/kernel/smp-bmips.c +@@ -592,6 +592,7 @@ asmlinkage void __weak plat_wired_tlb_se + void bmips_cpu_setup(void) + { + void __iomem __maybe_unused *cbr = bmips_cbr_addr; ++ u32 __maybe_unused rac_addr; + u32 __maybe_unused cfg; + + switch (current_cpu_type()) { +@@ -620,6 +621,23 @@ void bmips_cpu_setup(void) + __raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE); + break; + ++ case CPU_BMIPS4350: ++ rac_addr = BMIPS_RAC_CONFIG_1; ++ ++ if (!(read_c0_brcm_cmt_local() & (1 << 31))) ++ rac_addr = BMIPS_RAC_CONFIG; ++ ++ /* Enable data RAC */ ++ cfg = __raw_readl(cbr + rac_addr); ++ __raw_writel(cfg | 0xf, cbr + rac_addr); ++ __raw_readl(cbr + rac_addr); ++ ++ /* Flush stale data out of the readahead cache */ ++ cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG); ++ __raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG); ++ __raw_readl(cbr + BMIPS_RAC_CONFIG); ++ break; ++ + case CPU_BMIPS4380: + /* CBG workaround for early BMIPS4380 CPUs */ + switch (read_c0_prid()) { diff --git a/target/linux/generic/backport-6.6/610-v6.9-net-mdio-add-2.5g-and-5g-related-PMA-speed-constants.patch b/target/linux/generic/backport-6.6/610-v6.9-net-mdio-add-2.5g-and-5g-related-PMA-speed-constants.patch new file mode 100644 index 0000000000..9a40ea4b90 --- /dev/null +++ b/target/linux/generic/backport-6.6/610-v6.9-net-mdio-add-2.5g-and-5g-related-PMA-speed-constants.patch @@ -0,0 +1,30 @@ +From 6c06c88fa838fcc1b7e5380facd086f57fd9d1c4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org> +Date: Sun, 4 Feb 2024 15:16:46 +0100 +Subject: [PATCH] net: mdio: add 2.5g and 5g related PMA speed constants +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add constants indicating 2.5g and 5g ability in the MMD PMA speed +register. + +Signed-off-by: Marek Behún <kabel@kernel.org> +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Link: https://lore.kernel.org/r/98e15038-d96c-442f-93e4-410100d27866@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + include/uapi/linux/mdio.h | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/include/uapi/linux/mdio.h ++++ b/include/uapi/linux/mdio.h +@@ -138,6 +138,8 @@ + #define MDIO_PMA_SPEED_1000 0x0010 /* 1000M capable */ + #define MDIO_PMA_SPEED_100 0x0020 /* 100M capable */ + #define MDIO_PMA_SPEED_10 0x0040 /* 10M capable */ ++#define MDIO_PMA_SPEED_2_5G 0x2000 /* 2.5G capable */ ++#define MDIO_PMA_SPEED_5G 0x4000 /* 5G capable */ + #define MDIO_PCS_SPEED_10P2B 0x0002 /* 10PASS-TS/2BASE-TL capable */ + #define MDIO_PCS_SPEED_2_5G 0x0040 /* 2.5G capable */ + #define MDIO_PCS_SPEED_5G 0x0080 /* 5G capable */ diff --git a/target/linux/generic/backport-6.6/611-01-v6.11-udp-Allow-GSO-transmit-from-devices-with-no-checksum.patch b/target/linux/generic/backport-6.6/611-01-v6.11-udp-Allow-GSO-transmit-from-devices-with-no-checksum.patch new file mode 100644 index 0000000000..4a71d1203a --- /dev/null +++ b/target/linux/generic/backport-6.6/611-01-v6.11-udp-Allow-GSO-transmit-from-devices-with-no-checksum.patch @@ -0,0 +1,94 @@ +From: Jakub Sitnicki <jakub@cloudflare.com> +Date: Wed, 26 Jun 2024 19:51:26 +0200 +Subject: [PATCH] udp: Allow GSO transmit from devices with no checksum offload + +Today sending a UDP GSO packet from a TUN device results in an EIO error: + + import fcntl, os, struct + from socket import * + + TUNSETIFF = 0x400454CA + IFF_TUN = 0x0001 + IFF_NO_PI = 0x1000 + UDP_SEGMENT = 103 + + tun_fd = os.open("/dev/net/tun", os.O_RDWR) + ifr = struct.pack("16sH", b"tun0", IFF_TUN | IFF_NO_PI) + fcntl.ioctl(tun_fd, TUNSETIFF, ifr) + + os.system("ip addr add 192.0.2.1/24 dev tun0") + os.system("ip link set dev tun0 up") + + s = socket(AF_INET, SOCK_DGRAM) + s.setsockopt(SOL_UDP, UDP_SEGMENT, 1200) + s.sendto(b"x" * 3000, ("192.0.2.2", 9)) # EIO + +This is due to a check in the udp stack if the egress device offers +checksum offload. While TUN/TAP devices, by default, don't advertise this +capability because it requires support from the TUN/TAP reader. + +However, the GSO stack has a software fallback for checksum calculation, +which we can use. This way we don't force UDP_SEGMENT users to handle the +EIO error and implement a segmentation fallback. + +Lift the restriction so that UDP_SEGMENT can be used with any egress +device. We also need to adjust the UDP GSO code to match the GSO stack +expectation about ip_summed field, as set in commit 8d63bee643f1 ("net: +avoid skb_warn_bad_offload false positives on UFO"). Otherwise we will hit +the bad offload check. + +Users should, however, expect a potential performance impact when +batch-sending packets with UDP_SEGMENT without checksum offload on the +egress device. In such case the packet payload is read twice: first during +the sendmsg syscall when copying data from user memory, and then in the GSO +stack for checksum computation. This double memory read can be less +efficient than a regular sendmsg where the checksum is calculated during +the initial data copy from user memory. + +Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> +Reviewed-by: Willem de Bruijn <willemb@google.com> +Link: https://patch.msgid.link/20240626-linux-udpgso-v2-1-422dfcbd6b48@cloudflare.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + +--- a/net/ipv4/udp.c ++++ b/net/ipv4/udp.c +@@ -942,8 +942,7 @@ static int udp_send_skb(struct sk_buff * + kfree_skb(skb); + return -EINVAL; + } +- if (skb->ip_summed != CHECKSUM_PARTIAL || is_udplite || +- dst_xfrm(skb_dst(skb))) { ++ if (is_udplite || dst_xfrm(skb_dst(skb))) { + kfree_skb(skb); + return -EIO; + } +--- a/net/ipv4/udp_offload.c ++++ b/net/ipv4/udp_offload.c +@@ -362,6 +362,14 @@ struct sk_buff *__udp_gso_segment(struct + else + uh->check = gso_make_checksum(seg, ~check) ? : CSUM_MANGLED_0; + ++ /* On the TX path, CHECKSUM_NONE and CHECKSUM_UNNECESSARY have the same ++ * meaning. However, check for bad offloads in the GSO stack expects the ++ * latter, if the checksum was calculated in software. To vouch for the ++ * segment skbs we actually need to set it on the gso_skb. ++ */ ++ if (gso_skb->ip_summed == CHECKSUM_NONE) ++ gso_skb->ip_summed = CHECKSUM_UNNECESSARY; ++ + /* update refcount for the packet */ + if (copy_dtor) { + int delta = sum_truesize - gso_skb->truesize; +--- a/net/ipv6/udp.c ++++ b/net/ipv6/udp.c +@@ -1261,8 +1261,7 @@ static int udp_v6_send_skb(struct sk_buf + kfree_skb(skb); + return -EINVAL; + } +- if (skb->ip_summed != CHECKSUM_PARTIAL || is_udplite || +- dst_xfrm(skb_dst(skb))) { ++ if (is_udplite || dst_xfrm(skb_dst(skb))) { + kfree_skb(skb); + return -EIO; + } diff --git a/target/linux/generic/backport-6.6/611-02-v6.11-net-Make-USO-depend-on-CSUM-offload.patch b/target/linux/generic/backport-6.6/611-02-v6.11-net-Make-USO-depend-on-CSUM-offload.patch new file mode 100644 index 0000000000..8eecb06304 --- /dev/null +++ b/target/linux/generic/backport-6.6/611-02-v6.11-net-Make-USO-depend-on-CSUM-offload.patch @@ -0,0 +1,69 @@ +From: Jakub Sitnicki <jakub@cloudflare.com> +Date: Thu, 8 Aug 2024 11:56:21 +0200 +Subject: [PATCH] net: Make USO depend on CSUM offload + +UDP segmentation offload inherently depends on checksum offload. It should +not be possible to disable checksum offload while leaving USO enabled. +Enforce this dependency in code. + +There is a single tx-udp-segmentation feature flag to indicate support for +both IPv4/6, hence the devices wishing to support USO must offer checksum +offload for both IP versions. + +Fixes: 10154dbded6d ("udp: Allow GSO transmit from devices with no checksum offload") +Suggested-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com> +Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> +Reviewed-by: Willem de Bruijn <willemb@google.com> +Link: https://patch.msgid.link/20240808-udp-gso-egress-from-tunnel-v4-1-f5c5b4149ab9@cloudflare.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -9751,6 +9751,15 @@ static void netdev_sync_lower_features(s + } + } + ++static bool netdev_has_ip_or_hw_csum(netdev_features_t features) ++{ ++ netdev_features_t ip_csum_mask = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; ++ bool ip_csum = (features & ip_csum_mask) == ip_csum_mask; ++ bool hw_csum = features & NETIF_F_HW_CSUM; ++ ++ return ip_csum || hw_csum; ++} ++ + static netdev_features_t netdev_fix_features(struct net_device *dev, + netdev_features_t features) + { +@@ -9832,15 +9841,9 @@ static netdev_features_t netdev_fix_feat + features &= ~NETIF_F_LRO; + } + +- if (features & NETIF_F_HW_TLS_TX) { +- bool ip_csum = (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) == +- (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); +- bool hw_csum = features & NETIF_F_HW_CSUM; +- +- if (!ip_csum && !hw_csum) { +- netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n"); +- features &= ~NETIF_F_HW_TLS_TX; +- } ++ if ((features & NETIF_F_HW_TLS_TX) && !netdev_has_ip_or_hw_csum(features)) { ++ netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n"); ++ features &= ~NETIF_F_HW_TLS_TX; + } + + if ((features & NETIF_F_HW_TLS_RX) && !(features & NETIF_F_RXCSUM)) { +@@ -9848,6 +9851,11 @@ static netdev_features_t netdev_fix_feat + features &= ~NETIF_F_HW_TLS_RX; + } + ++ if ((features & NETIF_F_GSO_UDP_L4) && !netdev_has_ip_or_hw_csum(features)) { ++ netdev_dbg(dev, "Dropping USO feature since no CSUM feature.\n"); ++ features &= ~NETIF_F_GSO_UDP_L4; ++ } ++ + return features; + } + diff --git a/target/linux/generic/backport-6.6/611-03-v6.11-udp-Fall-back-to-software-USO-if-IPv6-extension-head.patch b/target/linux/generic/backport-6.6/611-03-v6.11-udp-Fall-back-to-software-USO-if-IPv6-extension-head.patch new file mode 100644 index 0000000000..e8eceb880c --- /dev/null +++ b/target/linux/generic/backport-6.6/611-03-v6.11-udp-Fall-back-to-software-USO-if-IPv6-extension-head.patch @@ -0,0 +1,86 @@ +From: Jakub Sitnicki <jakub@cloudflare.com> +Date: Thu, 8 Aug 2024 11:56:22 +0200 +Subject: [PATCH] udp: Fall back to software USO if IPv6 extension headers are + present + +In commit 10154dbded6d ("udp: Allow GSO transmit from devices with no +checksum offload") we have intentionally allowed UDP GSO packets marked +CHECKSUM_NONE to pass to the GSO stack, so that they can be segmented and +checksummed by a software fallback when the egress device lacks these +features. + +What was not taken into consideration is that a CHECKSUM_NONE skb can be +handed over to the GSO stack also when the egress device advertises the +tx-udp-segmentation / NETIF_F_GSO_UDP_L4 feature. + +This will happen when there are IPv6 extension headers present, which we +check for in __ip6_append_data(). Syzbot has discovered this scenario, +producing a warning as below: + + ip6tnl0: caps=(0x00000006401d7869, 0x00000006401d7869) + WARNING: CPU: 0 PID: 5112 at net/core/dev.c:3293 skb_warn_bad_offload+0x166/0x1a0 net/core/dev.c:3291 + Modules linked in: + CPU: 0 PID: 5112 Comm: syz-executor391 Not tainted 6.10.0-rc7-syzkaller-01603-g80ab5445da62 #0 + Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 + RIP: 0010:skb_warn_bad_offload+0x166/0x1a0 net/core/dev.c:3291 + [...] + Call Trace: + <TASK> + __skb_gso_segment+0x3be/0x4c0 net/core/gso.c:127 + skb_gso_segment include/net/gso.h:83 [inline] + validate_xmit_skb+0x585/0x1120 net/core/dev.c:3661 + __dev_queue_xmit+0x17a4/0x3e90 net/core/dev.c:4415 + neigh_output include/net/neighbour.h:542 [inline] + ip6_finish_output2+0xffa/0x1680 net/ipv6/ip6_output.c:137 + ip6_finish_output+0x41e/0x810 net/ipv6/ip6_output.c:222 + ip6_send_skb+0x112/0x230 net/ipv6/ip6_output.c:1958 + udp_v6_send_skb+0xbf5/0x1870 net/ipv6/udp.c:1292 + udpv6_sendmsg+0x23b3/0x3270 net/ipv6/udp.c:1588 + sock_sendmsg_nosec net/socket.c:730 [inline] + __sock_sendmsg+0xef/0x270 net/socket.c:745 + ____sys_sendmsg+0x525/0x7d0 net/socket.c:2585 + ___sys_sendmsg net/socket.c:2639 [inline] + __sys_sendmmsg+0x3b2/0x740 net/socket.c:2725 + __do_sys_sendmmsg net/socket.c:2754 [inline] + __se_sys_sendmmsg net/socket.c:2751 [inline] + __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2751 + do_syscall_x64 arch/x86/entry/common.c:52 [inline] + do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 + entry_SYSCALL_64_after_hwframe+0x77/0x7f + [...] + </TASK> + +We are hitting the bad offload warning because when an egress device is +capable of handling segmentation offload requested by +skb_shinfo(skb)->gso_type, the chain of gso_segment callbacks won't produce +any segment skbs and return NULL. See the skb_gso_ok() branch in +{__udp,tcp,sctp}_gso_segment helpers. + +To fix it, force a fallback to software USO when processing a packet with +IPv6 extension headers, since we don't know if these can checksummed by +all devices which offer USO. + +Fixes: 10154dbded6d ("udp: Allow GSO transmit from devices with no checksum offload") +Reported-by: syzbot+e15b7e15b8a751a91d9a@syzkaller.appspotmail.com +Closes: https://lore.kernel.org/all/000000000000e1609a061d5330ce@google.com/ +Reviewed-by: Willem de Bruijn <willemb@google.com> +Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> +Link: https://patch.msgid.link/20240808-udp-gso-egress-from-tunnel-v4-2-f5c5b4149ab9@cloudflare.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + +--- a/net/ipv4/udp_offload.c ++++ b/net/ipv4/udp_offload.c +@@ -283,6 +283,12 @@ struct sk_buff *__udp_gso_segment(struct + !(skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST))) + return ERR_PTR(-EINVAL); + ++ /* We don't know if egress device can segment and checksum the packet ++ * when IPv6 extension headers are present. Fall back to software GSO. ++ */ ++ if (gso_skb->ip_summed != CHECKSUM_PARTIAL) ++ features &= ~(NETIF_F_GSO_UDP_L4 | NETIF_F_CSUM_MASK); ++ + if (skb_gso_ok(gso_skb, features | NETIF_F_GSO_ROBUST)) { + /* Packet is from an untrusted source, reset gso_segs. */ + skb_shinfo(gso_skb)->gso_segs = DIV_ROUND_UP(gso_skb->len - sizeof(*uh), diff --git a/target/linux/generic/backport-6.6/752-04-v6.6-net-ethernet-mtk_wed-check-update_wo_rx_stats-in-mtk.patch b/target/linux/generic/backport-6.6/752-04-v6.6-net-ethernet-mtk_wed-check-update_wo_rx_stats-in-mtk.patch deleted file mode 100644 index c99e1334d4..0000000000 --- a/target/linux/generic/backport-6.6/752-04-v6.6-net-ethernet-mtk_wed-check-update_wo_rx_stats-in-mtk.patch +++ /dev/null @@ -1,26 +0,0 @@ -From: Lorenzo Bianconi <lorenzo@kernel.org> -Date: Tue, 12 Sep 2023 10:28:00 +0200 -Subject: [PATCH] net: ethernet: mtk_wed: check update_wo_rx_stats in - mtk_wed_update_rx_stats() - -Check if update_wo_rx_stats function pointer is properly set in -mtk_wed_update_rx_stats routine before accessing it. - -Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> -Reviewed-by: Simon Horman <horms@kernel.org> -Link: https://lore.kernel.org/r/b0d233386e059bccb59f18f69afb79a7806e5ded.1694507226.git.lorenzo@kernel.org -Signed-off-by: Paolo Abeni <pabeni@redhat.com> ---- - ---- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c -+++ b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c -@@ -68,6 +68,9 @@ mtk_wed_update_rx_stats(struct mtk_wed_d - struct mtk_wed_wo_rx_stats *stats; - int i; - -+ if (!wed->wlan.update_wo_rx_stats) -+ return; -+ - if (count * sizeof(*stats) > skb->len - sizeof(u32)) - return; - diff --git a/target/linux/generic/backport-6.6/752-06-v6.7-net-ethernet-mtk_wed-introduce-versioning-utility-ro.patch b/target/linux/generic/backport-6.6/752-06-v6.7-net-ethernet-mtk_wed-introduce-versioning-utility-ro.patch index 6d1d9a4069..323bc14c3e 100644 --- a/target/linux/generic/backport-6.6/752-06-v6.7-net-ethernet-mtk_wed-introduce-versioning-utility-ro.patch +++ b/target/linux/generic/backport-6.6/752-06-v6.7-net-ethernet-mtk_wed-introduce-versioning-utility-ro.patch @@ -168,7 +168,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com> ext_mask |= MTK_WED_EXT_INT_STATUS_TX_DRV_R_RESP_ERR; else ext_mask |= MTK_WED_EXT_INT_STATUS_RX_FBUF_LO_TH | -@@ -1840,7 +1840,7 @@ mtk_wed_setup_tc(struct mtk_wed_device * +@@ -1842,7 +1842,7 @@ mtk_wed_setup_tc(struct mtk_wed_device * { struct mtk_wed_hw *hw = wed->hw; @@ -177,7 +177,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com> return -EOPNOTSUPP; switch (type) { -@@ -1914,9 +1914,9 @@ void mtk_wed_add_hw(struct device_node * +@@ -1916,9 +1916,9 @@ void mtk_wed_add_hw(struct device_node * hw->wdma = wdma; hw->index = index; hw->irq = irq; diff --git a/target/linux/generic/backport-6.6/752-13-v6.7-net-ethernet-mtk_wed-add-mtk_wed_soc_data-structure.patch b/target/linux/generic/backport-6.6/752-13-v6.7-net-ethernet-mtk_wed-add-mtk_wed_soc_data-structure.patch index 3e750ec1d4..6e2f8b1920 100644 --- a/target/linux/generic/backport-6.6/752-13-v6.7-net-ethernet-mtk_wed-add-mtk_wed_soc_data-structure.patch +++ b/target/linux/generic/backport-6.6/752-13-v6.7-net-ethernet-mtk_wed-add-mtk_wed_soc_data-structure.patch @@ -142,7 +142,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com> return -ENOMEM; wdma_w32(dev, MTK_WDMA_RING_TX(idx) + MTK_WED_RING_OFS_BASE, -@@ -1928,7 +1935,12 @@ void mtk_wed_add_hw(struct device_node * +@@ -1930,7 +1937,12 @@ void mtk_wed_add_hw(struct device_node * hw->irq = irq; hw->version = eth->soc->version; @@ -156,7 +156,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com> hw->mirror = syscon_regmap_lookup_by_phandle(eth_np, "mediatek,pcie-mirror"); hw->hifsys = syscon_regmap_lookup_by_phandle(eth_np, -@@ -1942,6 +1954,8 @@ void mtk_wed_add_hw(struct device_node * +@@ -1944,6 +1956,8 @@ void mtk_wed_add_hw(struct device_node * regmap_write(hw->mirror, 0, 0); regmap_write(hw->mirror, 4, 0); } diff --git a/target/linux/generic/backport-6.6/752-14-v6.7-net-ethernet-mtk_wed-introduce-WED-support-for-MT798.patch b/target/linux/generic/backport-6.6/752-14-v6.7-net-ethernet-mtk_wed-introduce-WED-support-for-MT798.patch index 5a271a5628..f565b7631f 100644 --- a/target/linux/generic/backport-6.6/752-14-v6.7-net-ethernet-mtk_wed-introduce-WED-support-for-MT798.patch +++ b/target/linux/generic/backport-6.6/752-14-v6.7-net-ethernet-mtk_wed-introduce-WED-support-for-MT798.patch @@ -759,7 +759,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com> val = wed_r32(dev, MTK_WED_EXT_INT_STATUS); wed_w32(dev, MTK_WED_EXT_INT_STATUS, val); -@@ -1939,6 +2130,9 @@ void mtk_wed_add_hw(struct device_node * +@@ -1941,6 +2132,9 @@ void mtk_wed_add_hw(struct device_node * case 2: hw->soc = &mt7986_data; break; diff --git a/target/linux/generic/backport-6.6/752-17-v6.7-net-ethernet-mtk_wed-introduce-hw_rro-support-for-MT.patch b/target/linux/generic/backport-6.6/752-17-v6.7-net-ethernet-mtk_wed-introduce-hw_rro-support-for-MT.patch index f035f8fc06..20befcc620 100644 --- a/target/linux/generic/backport-6.6/752-17-v6.7-net-ethernet-mtk_wed-introduce-hw_rro-support-for-MT.patch +++ b/target/linux/generic/backport-6.6/752-17-v6.7-net-ethernet-mtk_wed-introduce-hw_rro-support-for-MT.patch @@ -364,7 +364,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com> mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask) { int i; -@@ -2212,6 +2503,10 @@ void mtk_wed_add_hw(struct device_node * +@@ -2214,6 +2505,10 @@ void mtk_wed_add_hw(struct device_node * .detach = mtk_wed_detach, .ppe_check = mtk_wed_ppe_check, .setup_tc = mtk_wed_setup_tc, diff --git a/target/linux/generic/backport-6.6/752-28-v6.10-net-ethernet-mediatek-Allow-gaps-in-MAC-allocation.patch b/target/linux/generic/backport-6.6/752-28-v6.10-net-ethernet-mediatek-Allow-gaps-in-MAC-allocation.patch new file mode 100644 index 0000000000..b62586b992 --- /dev/null +++ b/target/linux/generic/backport-6.6/752-28-v6.10-net-ethernet-mediatek-Allow-gaps-in-MAC-allocation.patch @@ -0,0 +1,32 @@ +From 3b2aef99221d395ce37efa426d7b50e7dcd621d6 Mon Sep 17 00:00:00 2001 +From: Daniel Golle <daniel@makrotopia.org> +Date: Mon, 1 Jul 2024 20:28:14 +0100 +Subject: [PATCH] net: ethernet: mediatek: Allow gaps in MAC allocation + +Some devices with MediaTek SoCs don't use the first but only the second +MAC in the chip. Especially with MT7981 which got a built-in 1GE PHY +connected to the second MAC this is quite common. +Make sure to reset and enable PSE also in those cases by skipping gaps +using 'continue' instead of aborting the loop using 'break'. + +Fixes: dee4dd10c79a ("net: ethernet: mtk_eth_soc: ppe: add support for multiple PPEs") +Suggested-by: Elad Yifee <eladwf@gmail.com> +Signed-off-by: Daniel Golle <daniel@makrotopia.org> +Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> +Link: https://patch.msgid.link/379ae584cea112db60f4ada79c7e5ba4f3364a64.1719862038.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -3396,7 +3396,7 @@ static int mtk_open(struct net_device *d + + for (i = 0; i < MTK_MAX_DEVS; i++) { + if (!eth->netdev[i]) +- break; ++ continue; + + target_mac = netdev_priv(eth->netdev[i]); + if (!soc->offload_version) { diff --git a/target/linux/generic/backport-6.6/752-29-v6.10-net-ethernet-mtk_ppe-Change-PPE-entries-number-to-16.patch b/target/linux/generic/backport-6.6/752-29-v6.10-net-ethernet-mtk_ppe-Change-PPE-entries-number-to-16.patch new file mode 100644 index 0000000000..c6b332f370 --- /dev/null +++ b/target/linux/generic/backport-6.6/752-29-v6.10-net-ethernet-mtk_ppe-Change-PPE-entries-number-to-16.patch @@ -0,0 +1,29 @@ +From ca18300e00d584d5693127eb60c108b84883b8ac Mon Sep 17 00:00:00 2001 +From: Shengyu Qu <wiagn233@outlook.com> +Date: Fri, 5 Jul 2024 01:26:26 +0800 +Subject: [PATCH] net: ethernet: mtk_ppe: Change PPE entries number to 16K + +MT7981,7986 and 7988 all supports 32768 PPE entries, and MT7621/MT7620 +supports 16384 PPE entries, but only set to 8192 entries in driver. So +incrase max entries to 16384 instead. + +Signed-off-by: Elad Yifee <eladwf@gmail.com> +Signed-off-by: Shengyu Qu <wiagn233@outlook.com> +Reviewed-by: Simon Horman <horms@kernel.org> +Link: https://patch.msgid.link/TY3P286MB261103F937DE4EEB0F88437D98DE2@TY3P286MB2611.JPNP286.PROD.OUTLOOK.COM +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/mediatek/mtk_ppe.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/mediatek/mtk_ppe.h ++++ b/drivers/net/ethernet/mediatek/mtk_ppe.h +@@ -8,7 +8,7 @@ + #include <linux/bitfield.h> + #include <linux/rhashtable.h> + +-#define MTK_PPE_ENTRIES_SHIFT 3 ++#define MTK_PPE_ENTRIES_SHIFT 4 + #define MTK_PPE_ENTRIES (1024 << MTK_PPE_ENTRIES_SHIFT) + #define MTK_PPE_HASH_MASK (MTK_PPE_ENTRIES - 1) + #define MTK_PPE_WAIT_TIMEOUT_US 1000000 diff --git a/target/linux/generic/backport-6.6/752-30-v6.10-net-ethernet-mtk_eth_soc-implement-.-get-set-_pausep.patch b/target/linux/generic/backport-6.6/752-30-v6.10-net-ethernet-mtk_eth_soc-implement-.-get-set-_pausep.patch new file mode 100644 index 0000000000..09d7054965 --- /dev/null +++ b/target/linux/generic/backport-6.6/752-30-v6.10-net-ethernet-mtk_eth_soc-implement-.-get-set-_pausep.patch @@ -0,0 +1,55 @@ +From 064fbc4e9b5a6dbda7fe7b67dc7e9e95d31f8d75 Mon Sep 17 00:00:00 2001 +From: Daniel Golle <daniel@makrotopia.org> +Date: Thu, 4 Jul 2024 11:14:55 +0100 +Subject: [PATCH] net: ethernet: mtk_eth_soc: implement .{get,set}_pauseparam + ethtool ops + +Implement operations to get and set flow-control link parameters. +Both is done by simply calling phylink_ethtool_{get,set}_pauseparam(). +Fix whitespace in mtk_ethtool_ops while at it. + +Signed-off-by: Daniel Golle <daniel@makrotopia.org> +Reviewed-by: Michal Kubiak <michal.kubiak@intel.com> +Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> +Tested-by: Rui Salvaterra <rsalvaterra@gmail.com> +Link: https://patch.msgid.link/e3ece47323444631d6cb479f32af0dfd6d145be0.1720088047.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 18 +++++++++++++++++- + 1 file changed, 17 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -4462,6 +4462,20 @@ static int mtk_set_rxnfc(struct net_devi + return ret; + } + ++static void mtk_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause) ++{ ++ struct mtk_mac *mac = netdev_priv(dev); ++ ++ phylink_ethtool_get_pauseparam(mac->phylink, pause); ++} ++ ++static int mtk_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause) ++{ ++ struct mtk_mac *mac = netdev_priv(dev); ++ ++ return phylink_ethtool_set_pauseparam(mac->phylink, pause); ++} ++ + static u16 mtk_select_queue(struct net_device *dev, struct sk_buff *skb, + struct net_device *sb_dev) + { +@@ -4490,8 +4504,10 @@ static const struct ethtool_ops mtk_etht + .get_strings = mtk_get_strings, + .get_sset_count = mtk_get_sset_count, + .get_ethtool_stats = mtk_get_ethtool_stats, ++ .get_pauseparam = mtk_get_pauseparam, ++ .set_pauseparam = mtk_set_pauseparam, + .get_rxnfc = mtk_get_rxnfc, +- .set_rxnfc = mtk_set_rxnfc, ++ .set_rxnfc = mtk_set_rxnfc, + }; + + static const struct net_device_ops mtk_netdev_ops = { diff --git a/target/linux/generic/backport-6.6/780-01-v6.8-r8169-improve-RTL8411b-phy-down-fixup.patch b/target/linux/generic/backport-6.6/780-01-v6.8-r8169-improve-RTL8411b-phy-down-fixup.patch new file mode 100644 index 0000000000..9a17fe4f78 --- /dev/null +++ b/target/linux/generic/backport-6.6/780-01-v6.8-r8169-improve-RTL8411b-phy-down-fixup.patch @@ -0,0 +1,173 @@ +From 055dd7511f675d26fa283b35bb3dadfc7f77ed97 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Mon, 13 Nov 2023 20:13:26 +0100 +Subject: [PATCH] r8169: improve RTL8411b phy-down fixup + +Mirsad proposed a patch to reduce the number of spinlock lock/unlock +operations and the function code size. This can be further improved +because the function sets a consecutive register block. + +Suggested-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Reviewed-by: Simon Horman <horms@kernel.org> +Reviewed-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/ethernet/realtek/r8169_main.c | 139 +++++----------------- + 1 file changed, 28 insertions(+), 111 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -3129,6 +3129,33 @@ static void rtl_hw_start_8168g_2(struct + rtl_ephy_init(tp, e_info_8168g_2); + } + ++static void rtl8411b_fix_phy_down(struct rtl8169_private *tp) ++{ ++ static const u16 fix_data[] = { ++/* 0xf800 */ 0xe008, 0xe00a, 0xe00c, 0xe00e, 0xe027, 0xe04f, 0xe05e, 0xe065, ++/* 0xf810 */ 0xc602, 0xbe00, 0x0000, 0xc502, 0xbd00, 0x074c, 0xc302, 0xbb00, ++/* 0xf820 */ 0x080a, 0x6420, 0x48c2, 0x8c20, 0xc516, 0x64a4, 0x49c0, 0xf009, ++/* 0xf830 */ 0x74a2, 0x8ca5, 0x74a0, 0xc50e, 0x9ca2, 0x1c11, 0x9ca0, 0xe006, ++/* 0xf840 */ 0x74f8, 0x48c4, 0x8cf8, 0xc404, 0xbc00, 0xc403, 0xbc00, 0x0bf2, ++/* 0xf850 */ 0x0c0a, 0xe434, 0xd3c0, 0x49d9, 0xf01f, 0xc526, 0x64a5, 0x1400, ++/* 0xf860 */ 0xf007, 0x0c01, 0x8ca5, 0x1c15, 0xc51b, 0x9ca0, 0xe013, 0xc519, ++/* 0xf870 */ 0x74a0, 0x48c4, 0x8ca0, 0xc516, 0x74a4, 0x48c8, 0x48ca, 0x9ca4, ++/* 0xf880 */ 0xc512, 0x1b00, 0x9ba0, 0x1b1c, 0x483f, 0x9ba2, 0x1b04, 0xc508, ++/* 0xf890 */ 0x9ba0, 0xc505, 0xbd00, 0xc502, 0xbd00, 0x0300, 0x051e, 0xe434, ++/* 0xf8a0 */ 0xe018, 0xe092, 0xde20, 0xd3c0, 0xc50f, 0x76a4, 0x49e3, 0xf007, ++/* 0xf8b0 */ 0x49c0, 0xf103, 0xc607, 0xbe00, 0xc606, 0xbe00, 0xc602, 0xbe00, ++/* 0xf8c0 */ 0x0c4c, 0x0c28, 0x0c2c, 0xdc00, 0xc707, 0x1d00, 0x8de2, 0x48c1, ++/* 0xf8d0 */ 0xc502, 0xbd00, 0x00aa, 0xe0c0, 0xc502, 0xbd00, 0x0132 ++ }; ++ unsigned long flags; ++ int i; ++ ++ raw_spin_lock_irqsave(&tp->mac_ocp_lock, flags); ++ for (i = 0; i < ARRAY_SIZE(fix_data); i++) ++ __r8168_mac_ocp_write(tp, 0xf800 + 2 * i, fix_data[i]); ++ raw_spin_unlock_irqrestore(&tp->mac_ocp_lock, flags); ++} ++ + static void rtl_hw_start_8411_2(struct rtl8169_private *tp) + { + static const struct ephy_info e_info_8411_2[] = { +@@ -3162,117 +3189,7 @@ static void rtl_hw_start_8411_2(struct r + mdelay(3); + r8168_mac_ocp_write(tp, 0xFC26, 0x0000); + +- r8168_mac_ocp_write(tp, 0xF800, 0xE008); +- r8168_mac_ocp_write(tp, 0xF802, 0xE00A); +- r8168_mac_ocp_write(tp, 0xF804, 0xE00C); +- r8168_mac_ocp_write(tp, 0xF806, 0xE00E); +- r8168_mac_ocp_write(tp, 0xF808, 0xE027); +- r8168_mac_ocp_write(tp, 0xF80A, 0xE04F); +- r8168_mac_ocp_write(tp, 0xF80C, 0xE05E); +- r8168_mac_ocp_write(tp, 0xF80E, 0xE065); +- r8168_mac_ocp_write(tp, 0xF810, 0xC602); +- r8168_mac_ocp_write(tp, 0xF812, 0xBE00); +- r8168_mac_ocp_write(tp, 0xF814, 0x0000); +- r8168_mac_ocp_write(tp, 0xF816, 0xC502); +- r8168_mac_ocp_write(tp, 0xF818, 0xBD00); +- r8168_mac_ocp_write(tp, 0xF81A, 0x074C); +- r8168_mac_ocp_write(tp, 0xF81C, 0xC302); +- r8168_mac_ocp_write(tp, 0xF81E, 0xBB00); +- r8168_mac_ocp_write(tp, 0xF820, 0x080A); +- r8168_mac_ocp_write(tp, 0xF822, 0x6420); +- r8168_mac_ocp_write(tp, 0xF824, 0x48C2); +- r8168_mac_ocp_write(tp, 0xF826, 0x8C20); +- r8168_mac_ocp_write(tp, 0xF828, 0xC516); +- r8168_mac_ocp_write(tp, 0xF82A, 0x64A4); +- r8168_mac_ocp_write(tp, 0xF82C, 0x49C0); +- r8168_mac_ocp_write(tp, 0xF82E, 0xF009); +- r8168_mac_ocp_write(tp, 0xF830, 0x74A2); +- r8168_mac_ocp_write(tp, 0xF832, 0x8CA5); +- r8168_mac_ocp_write(tp, 0xF834, 0x74A0); +- r8168_mac_ocp_write(tp, 0xF836, 0xC50E); +- r8168_mac_ocp_write(tp, 0xF838, 0x9CA2); +- r8168_mac_ocp_write(tp, 0xF83A, 0x1C11); +- r8168_mac_ocp_write(tp, 0xF83C, 0x9CA0); +- r8168_mac_ocp_write(tp, 0xF83E, 0xE006); +- r8168_mac_ocp_write(tp, 0xF840, 0x74F8); +- r8168_mac_ocp_write(tp, 0xF842, 0x48C4); +- r8168_mac_ocp_write(tp, 0xF844, 0x8CF8); +- r8168_mac_ocp_write(tp, 0xF846, 0xC404); +- r8168_mac_ocp_write(tp, 0xF848, 0xBC00); +- r8168_mac_ocp_write(tp, 0xF84A, 0xC403); +- r8168_mac_ocp_write(tp, 0xF84C, 0xBC00); +- r8168_mac_ocp_write(tp, 0xF84E, 0x0BF2); +- r8168_mac_ocp_write(tp, 0xF850, 0x0C0A); +- r8168_mac_ocp_write(tp, 0xF852, 0xE434); +- r8168_mac_ocp_write(tp, 0xF854, 0xD3C0); +- r8168_mac_ocp_write(tp, 0xF856, 0x49D9); +- r8168_mac_ocp_write(tp, 0xF858, 0xF01F); +- r8168_mac_ocp_write(tp, 0xF85A, 0xC526); +- r8168_mac_ocp_write(tp, 0xF85C, 0x64A5); +- r8168_mac_ocp_write(tp, 0xF85E, 0x1400); +- r8168_mac_ocp_write(tp, 0xF860, 0xF007); +- r8168_mac_ocp_write(tp, 0xF862, 0x0C01); +- r8168_mac_ocp_write(tp, 0xF864, 0x8CA5); +- r8168_mac_ocp_write(tp, 0xF866, 0x1C15); +- r8168_mac_ocp_write(tp, 0xF868, 0xC51B); +- r8168_mac_ocp_write(tp, 0xF86A, 0x9CA0); +- r8168_mac_ocp_write(tp, 0xF86C, 0xE013); +- r8168_mac_ocp_write(tp, 0xF86E, 0xC519); +- r8168_mac_ocp_write(tp, 0xF870, 0x74A0); +- r8168_mac_ocp_write(tp, 0xF872, 0x48C4); +- r8168_mac_ocp_write(tp, 0xF874, 0x8CA0); +- r8168_mac_ocp_write(tp, 0xF876, 0xC516); +- r8168_mac_ocp_write(tp, 0xF878, 0x74A4); +- r8168_mac_ocp_write(tp, 0xF87A, 0x48C8); +- r8168_mac_ocp_write(tp, 0xF87C, 0x48CA); +- r8168_mac_ocp_write(tp, 0xF87E, 0x9CA4); +- r8168_mac_ocp_write(tp, 0xF880, 0xC512); +- r8168_mac_ocp_write(tp, 0xF882, 0x1B00); +- r8168_mac_ocp_write(tp, 0xF884, 0x9BA0); +- r8168_mac_ocp_write(tp, 0xF886, 0x1B1C); +- r8168_mac_ocp_write(tp, 0xF888, 0x483F); +- r8168_mac_ocp_write(tp, 0xF88A, 0x9BA2); +- r8168_mac_ocp_write(tp, 0xF88C, 0x1B04); +- r8168_mac_ocp_write(tp, 0xF88E, 0xC508); +- r8168_mac_ocp_write(tp, 0xF890, 0x9BA0); +- r8168_mac_ocp_write(tp, 0xF892, 0xC505); +- r8168_mac_ocp_write(tp, 0xF894, 0xBD00); +- r8168_mac_ocp_write(tp, 0xF896, 0xC502); +- r8168_mac_ocp_write(tp, 0xF898, 0xBD00); +- r8168_mac_ocp_write(tp, 0xF89A, 0x0300); +- r8168_mac_ocp_write(tp, 0xF89C, 0x051E); +- r8168_mac_ocp_write(tp, 0xF89E, 0xE434); +- r8168_mac_ocp_write(tp, 0xF8A0, 0xE018); +- r8168_mac_ocp_write(tp, 0xF8A2, 0xE092); +- r8168_mac_ocp_write(tp, 0xF8A4, 0xDE20); +- r8168_mac_ocp_write(tp, 0xF8A6, 0xD3C0); +- r8168_mac_ocp_write(tp, 0xF8A8, 0xC50F); +- r8168_mac_ocp_write(tp, 0xF8AA, 0x76A4); +- r8168_mac_ocp_write(tp, 0xF8AC, 0x49E3); +- r8168_mac_ocp_write(tp, 0xF8AE, 0xF007); +- r8168_mac_ocp_write(tp, 0xF8B0, 0x49C0); +- r8168_mac_ocp_write(tp, 0xF8B2, 0xF103); +- r8168_mac_ocp_write(tp, 0xF8B4, 0xC607); +- r8168_mac_ocp_write(tp, 0xF8B6, 0xBE00); +- r8168_mac_ocp_write(tp, 0xF8B8, 0xC606); +- r8168_mac_ocp_write(tp, 0xF8BA, 0xBE00); +- r8168_mac_ocp_write(tp, 0xF8BC, 0xC602); +- r8168_mac_ocp_write(tp, 0xF8BE, 0xBE00); +- r8168_mac_ocp_write(tp, 0xF8C0, 0x0C4C); +- r8168_mac_ocp_write(tp, 0xF8C2, 0x0C28); +- r8168_mac_ocp_write(tp, 0xF8C4, 0x0C2C); +- r8168_mac_ocp_write(tp, 0xF8C6, 0xDC00); +- r8168_mac_ocp_write(tp, 0xF8C8, 0xC707); +- r8168_mac_ocp_write(tp, 0xF8CA, 0x1D00); +- r8168_mac_ocp_write(tp, 0xF8CC, 0x8DE2); +- r8168_mac_ocp_write(tp, 0xF8CE, 0x48C1); +- r8168_mac_ocp_write(tp, 0xF8D0, 0xC502); +- r8168_mac_ocp_write(tp, 0xF8D2, 0xBD00); +- r8168_mac_ocp_write(tp, 0xF8D4, 0x00AA); +- r8168_mac_ocp_write(tp, 0xF8D6, 0xE0C0); +- r8168_mac_ocp_write(tp, 0xF8D8, 0xC502); +- r8168_mac_ocp_write(tp, 0xF8DA, 0xBD00); +- r8168_mac_ocp_write(tp, 0xF8DC, 0x0132); ++ rtl8411b_fix_phy_down(tp); + + r8168_mac_ocp_write(tp, 0xFC26, 0x8000); + diff --git a/target/linux/generic/backport-6.6/780-02-v6.8-r8169-remove-not-needed-check-in-rtl_fw_write_firmwa.patch b/target/linux/generic/backport-6.6/780-02-v6.8-r8169-remove-not-needed-check-in-rtl_fw_write_firmwa.patch new file mode 100644 index 0000000000..de10d30e83 --- /dev/null +++ b/target/linux/generic/backport-6.6/780-02-v6.8-r8169-remove-not-needed-check-in-rtl_fw_write_firmwa.patch @@ -0,0 +1,27 @@ +From 3a767b482cacd9bfeac786837fcac419af315995 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Thu, 23 Nov 2023 10:53:26 +0100 +Subject: [PATCH] r8169: remove not needed check in rtl_fw_write_firmware + +This check can never be true for a firmware file with a correct format. +Existing checks in rtl_fw_data_ok() are sufficient, no problems with +invalid firmware files are known. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/ethernet/realtek/r8169_firmware.c | 3 --- + 1 file changed, 3 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_firmware.c ++++ b/drivers/net/ethernet/realtek/r8169_firmware.c +@@ -151,9 +151,6 @@ void rtl_fw_write_firmware(struct rtl816 + u32 regno = (action & 0x0fff0000) >> 16; + enum rtl_fw_opcode opcode = action >> 28; + +- if (!action) +- break; +- + switch (opcode) { + case PHY_READ: + predata = fw_read(tp, regno); diff --git a/target/linux/generic/backport-6.6/780-03-v6.8-r8169-remove-multicast-filter-limit.patch b/target/linux/generic/backport-6.6/780-03-v6.8-r8169-remove-multicast-filter-limit.patch new file mode 100644 index 0000000000..4186e14e17 --- /dev/null +++ b/target/linux/generic/backport-6.6/780-03-v6.8-r8169-remove-multicast-filter-limit.patch @@ -0,0 +1,47 @@ +From cd04b44bf055c4cd6bcee2ebfa6932fb20ef369d Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Mon, 27 Nov 2023 21:16:10 +0100 +Subject: [PATCH] r8169: remove multicast filter limit + +Once upon a time, when r8169 was new, the multicast filter limit code +was copied from RTL8139 driver. There the filter limit is even +user-configurable. +The filtering is hash-based and we don't have perfect filtering. +Actually the mc filtering on RTL8125 still seems to be the same +as used on 8390/NE2000. So it's not clear to me which benefit it +should bring when switching to all-multi mode once a certain number +of filter bits is set. More the opposite: Filtering out at least +some unwanted mc traffic is better than no filtering. +Also the available chip documentation doesn't mention any restriction. +Therefore remove the filter limit. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Link: https://lore.kernel.org/r/57076c05-3730-40d1-ab9a-5334b263e41a@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/realtek/r8169_main.c | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -56,10 +56,6 @@ + #define FIRMWARE_8125A_3 "rtl_nic/rtl8125a-3.fw" + #define FIRMWARE_8125B_2 "rtl_nic/rtl8125b-2.fw" + +-/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). +- The RTL chips use a 64 element hash table based on the Ethernet CRC. */ +-#define MC_FILTER_LIMIT 32 +- + #define TX_DMA_BURST 7 /* Maximum PCI burst, '7' is unlimited */ + #define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */ + +@@ -2626,8 +2622,7 @@ static void rtl_set_rx_mode(struct net_d + rx_mode |= AcceptAllPhys; + } else if (!(dev->flags & IFF_MULTICAST)) { + rx_mode &= ~AcceptMulticast; +- } else if (netdev_mc_count(dev) > MC_FILTER_LIMIT || +- dev->flags & IFF_ALLMULTI || ++ } else if (dev->flags & IFF_ALLMULTI || + tp->mac_version == RTL_GIGA_MAC_VER_35) { + /* accept all multicasts */ + } else if (netdev_mc_empty(dev)) { diff --git a/target/linux/generic/backport-6.6/780-04-v6.8-r8169-improve-handling-task-scheduling.patch b/target/linux/generic/backport-6.6/780-04-v6.8-r8169-improve-handling-task-scheduling.patch new file mode 100644 index 0000000000..a809e8213a --- /dev/null +++ b/target/linux/generic/backport-6.6/780-04-v6.8-r8169-improve-handling-task-scheduling.patch @@ -0,0 +1,41 @@ +From 127532cd0f060ebc3c4cbca81b6438728ad5896e Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Mon, 27 Nov 2023 18:20:11 +0100 +Subject: [PATCH] r8169: improve handling task scheduling + +If we know that the task is going to be a no-op, don't even schedule it. +And remove the check for netif_running() in the worker function, the +check for flag RTL_FLAG_TASK_ENABLED is sufficient. Note that we can't +remove the check for flag RTL_FLAG_TASK_ENABLED in the worker function +because we have no guarantee when it will be executed. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> +Link: https://lore.kernel.org/r/c65873a3-7394-4107-99a7-83f20030779c@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/realtek/r8169_main.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -2252,6 +2252,9 @@ u16 rtl8168h_2_get_adc_bias_ioffset(stru + + static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag) + { ++ if (!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags)) ++ return; ++ + set_bit(flag, tp->wk.flags); + schedule_work(&tp->wk.work); + } +@@ -4491,8 +4494,7 @@ static void rtl_task(struct work_struct + + rtnl_lock(); + +- if (!netif_running(tp->dev) || +- !test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags)) ++ if (!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags)) + goto out_unlock; + + if (test_and_clear_bit(RTL_FLAG_TASK_TX_TIMEOUT, tp->wk.flags)) { diff --git a/target/linux/generic/backport-6.6/780-01-v6.8-r8169-add-support-for-LED-s-on-RTL8168-RTL8101.patch b/target/linux/generic/backport-6.6/780-05-v6.8-r8169-add-support-for-LED-s-on-RTL8168-RTL8101.patch index 3345ebf6c6..7a5d5a66a1 100644 --- a/target/linux/generic/backport-6.6/780-01-v6.8-r8169-add-support-for-LED-s-on-RTL8168-RTL8101.patch +++ b/target/linux/generic/backport-6.6/780-05-v6.8-r8169-add-support-for-LED-s-on-RTL8168-RTL8101.patch @@ -217,7 +217,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> +} --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c -@@ -289,6 +289,7 @@ enum rtl8168_8101_registers { +@@ -285,6 +285,7 @@ enum rtl8168_8101_registers { }; enum rtl8168_registers { @@ -225,7 +225,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> LED_FREQ = 0x1a, EEE_LED = 0x1b, ERIDR = 0x70, -@@ -620,6 +621,7 @@ struct rtl8169_private { +@@ -616,6 +617,7 @@ struct rtl8169_private { raw_spinlock_t config25_lock; raw_spinlock_t mac_ocp_lock; @@ -233,7 +233,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> raw_spinlock_t cfg9346_usage_lock; int cfg9346_usage_count; -@@ -792,6 +794,62 @@ static const struct rtl_cond name = { +@@ -788,6 +790,62 @@ static const struct rtl_cond name = { \ static bool name ## _check(struct rtl8169_private *tp) @@ -296,7 +296,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> static void r8168fp_adjust_ocp_cmd(struct rtl8169_private *tp, u32 *cmd, int type) { /* based on RTL8168FP_OOBMAC_BASE in vendor driver */ -@@ -5258,6 +5316,7 @@ static int rtl_init_one(struct pci_dev * +@@ -5168,6 +5226,7 @@ static int rtl_init_one(struct pci_dev * raw_spin_lock_init(&tp->cfg9346_usage_lock); raw_spin_lock_init(&tp->config25_lock); raw_spin_lock_init(&tp->mac_ocp_lock); @@ -304,7 +304,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> dev->tstats = devm_netdev_alloc_pcpu_stats(&pdev->dev, struct pcpu_sw_netstats); -@@ -5414,6 +5473,12 @@ static int rtl_init_one(struct pci_dev * +@@ -5324,6 +5383,12 @@ static int rtl_init_one(struct pci_dev * if (rc) return rc; diff --git a/target/linux/generic/backport-6.6/780-02-v6.8-r8169-fix-building-with-CONFIG_LEDS_CLASS-m.patch b/target/linux/generic/backport-6.6/780-06-v6.8-r8169-fix-building-with-CONFIG_LEDS_CLASS-m.patch index cea88c042a..67f215cadf 100644 --- a/target/linux/generic/backport-6.6/780-02-v6.8-r8169-fix-building-with-CONFIG_LEDS_CLASS-m.patch +++ b/target/linux/generic/backport-6.6/780-06-v6.8-r8169-fix-building-with-CONFIG_LEDS_CLASS-m.patch @@ -59,7 +59,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org> obj-$(CONFIG_R8169) += r8169.o --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c -@@ -5473,11 +5473,10 @@ static int rtl_init_one(struct pci_dev * +@@ -5383,11 +5383,10 @@ static int rtl_init_one(struct pci_dev * if (rc) return rc; diff --git a/target/linux/generic/backport-6.6/780-07-v6.9-r8169-simplify-EEE-handling.patch b/target/linux/generic/backport-6.6/780-07-v6.9-r8169-simplify-EEE-handling.patch new file mode 100644 index 0000000000..bdd3330580 --- /dev/null +++ b/target/linux/generic/backport-6.6/780-07-v6.9-r8169-simplify-EEE-handling.patch @@ -0,0 +1,96 @@ +From f5d59230ec26aa5e8b59e9f4a4d288703a737479 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Wed, 31 Jan 2024 21:31:01 +0100 +Subject: [PATCH] r8169: simplify EEE handling + +We don't have to store the EEE modes to be advertised in the driver, +phylib does this for us and stores it in phydev->advertising_eee. +phylib also takes care of properly handling the EEE advertisement. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Link: https://lore.kernel.org/r/27c336a8-ea47-483d-815b-02c45ae41da2@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/realtek/r8169_main.c | 32 +++-------------------- + 1 file changed, 4 insertions(+), 28 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -629,7 +629,6 @@ struct rtl8169_private { + struct rtl8169_counters *counters; + struct rtl8169_tc_offsets tc_offset; + u32 saved_wolopts; +- int eee_adv; + + const char *fw_name; + struct rtl_fw *rtl_fw; +@@ -2010,17 +2009,11 @@ static int rtl8169_get_eee(struct net_de + static int rtl8169_set_eee(struct net_device *dev, struct ethtool_eee *data) + { + struct rtl8169_private *tp = netdev_priv(dev); +- int ret; + + if (!rtl_supports_eee(tp)) + return -EOPNOTSUPP; + +- ret = phy_ethtool_set_eee(tp->phydev, data); +- +- if (!ret) +- tp->eee_adv = phy_read_mmd(dev->phydev, MDIO_MMD_AN, +- MDIO_AN_EEE_ADV); +- return ret; ++ return phy_ethtool_set_eee(tp->phydev, data); + } + + static void rtl8169_get_ringparam(struct net_device *dev, +@@ -2085,21 +2078,6 @@ static const struct ethtool_ops rtl8169_ + .set_pauseparam = rtl8169_set_pauseparam, + }; + +-static void rtl_enable_eee(struct rtl8169_private *tp) +-{ +- struct phy_device *phydev = tp->phydev; +- int adv; +- +- /* respect EEE advertisement the user may have set */ +- if (tp->eee_adv >= 0) +- adv = tp->eee_adv; +- else +- adv = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE); +- +- if (adv >= 0) +- phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv); +-} +- + static enum mac_version rtl8169_get_mac_version(u16 xid, bool gmii) + { + /* +@@ -2336,9 +2314,6 @@ static void rtl8169_init_phy(struct rtl8 + /* We may have called phy_speed_down before */ + phy_speed_up(tp->phydev); + +- if (rtl_supports_eee(tp)) +- rtl_enable_eee(tp); +- + genphy_soft_reset(tp->phydev); + } + +@@ -5085,7 +5060,9 @@ static int r8169_mdio_register(struct rt + } + + tp->phydev->mac_managed_pm = true; +- ++ if (rtl_supports_eee(tp)) ++ linkmode_copy(tp->phydev->advertising_eee, ++ tp->phydev->supported_eee); + phy_support_asym_pause(tp->phydev); + + /* PHY will be woken up in rtl_open() */ +@@ -5220,7 +5197,6 @@ static int rtl_init_one(struct pci_dev * + tp->dev = dev; + tp->pci_dev = pdev; + tp->supports_gmii = ent->driver_data == RTL_CFG_NO_GBIT ? 0 : 1; +- tp->eee_adv = -1; + tp->ocp_base = OCP_STD_PHY_BASE; + + raw_spin_lock_init(&tp->cfg9346_usage_lock); diff --git a/target/linux/generic/backport-6.6/780-03-v6.9-r8169-add-support-for-RTL8126A.patch b/target/linux/generic/backport-6.6/780-08-v6.9-r8169-add-support-for-RTL8126A.patch index 5ab160855a..65aa5449ec 100644 --- a/target/linux/generic/backport-6.6/780-03-v6.9-r8169-add-support-for-RTL8126A.patch +++ b/target/linux/generic/backport-6.6/780-08-v6.9-r8169-add-support-for-RTL8126A.patch @@ -34,9 +34,9 @@ Signed-off-by: David S. Miller <davem@davemloft.net> #define FIRMWARE_8125B_2 "rtl_nic/rtl8125b-2.fw" +#define FIRMWARE_8126A_2 "rtl_nic/rtl8126a-2.fw" - /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). - The RTL chips use a 64 element hash table based on the Ethernet CRC. */ -@@ -140,6 +141,7 @@ static const struct { + #define TX_DMA_BURST 7 /* Maximum PCI burst, '7' is unlimited */ + #define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */ +@@ -136,6 +137,7 @@ static const struct { [RTL_GIGA_MAC_VER_61] = {"RTL8125A", FIRMWARE_8125A_3}, /* reserve 62 for CFG_METHOD_4 in the vendor driver */ [RTL_GIGA_MAC_VER_63] = {"RTL8125B", FIRMWARE_8125B_2}, @@ -44,7 +44,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> }; static const struct pci_device_id rtl8169_pci_tbl[] = { -@@ -162,6 +164,7 @@ static const struct pci_device_id rtl816 +@@ -158,6 +160,7 @@ static const struct pci_device_id rtl816 { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0024 }, { 0x0001, 0x8168, PCI_ANY_ID, 0x2410 }, { PCI_VDEVICE(REALTEK, 0x8125) }, @@ -52,7 +52,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> { PCI_VDEVICE(REALTEK, 0x3000) }, {} }; -@@ -331,8 +334,12 @@ enum rtl8168_registers { +@@ -327,8 +330,12 @@ enum rtl8168_registers { }; enum rtl8125_registers { @@ -65,7 +65,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> TxPoll_8125 = 0x90, MAC0_BKP = 0x19e0, EEE_TXIDLE_TIMER_8125 = 0x6048, -@@ -1144,7 +1151,7 @@ static void rtl_writephy(struct rtl8169_ +@@ -1139,7 +1146,7 @@ static void rtl_writephy(struct rtl8169_ case RTL_GIGA_MAC_VER_31: r8168dp_2_mdio_write(tp, location, val); break; @@ -74,7 +74,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> r8168g_mdio_write(tp, location, val); break; default: -@@ -1159,7 +1166,7 @@ static int rtl_readphy(struct rtl8169_pr +@@ -1154,7 +1161,7 @@ static int rtl_readphy(struct rtl8169_pr case RTL_GIGA_MAC_VER_28: case RTL_GIGA_MAC_VER_31: return r8168dp_2_mdio_read(tp, location); @@ -83,7 +83,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> return r8168g_mdio_read(tp, location); default: return r8169_mdio_read(tp, location); -@@ -1368,7 +1375,7 @@ static void rtl_set_d3_pll_down(struct r +@@ -1363,7 +1370,7 @@ static void rtl_set_d3_pll_down(struct r case RTL_GIGA_MAC_VER_25 ... RTL_GIGA_MAC_VER_26: case RTL_GIGA_MAC_VER_29 ... RTL_GIGA_MAC_VER_30: case RTL_GIGA_MAC_VER_32 ... RTL_GIGA_MAC_VER_37: @@ -92,7 +92,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> if (enable) RTL_W8(tp, PMCH, RTL_R8(tp, PMCH) & ~D3_NO_PLL_DOWN); else -@@ -1535,7 +1542,7 @@ static void __rtl8169_set_wol(struct rtl +@@ -1530,7 +1537,7 @@ static void __rtl8169_set_wol(struct rtl break; case RTL_GIGA_MAC_VER_34: case RTL_GIGA_MAC_VER_37: @@ -101,7 +101,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> if (wolopts) rtl_mod_config2(tp, 0, PME_SIGNAL); else -@@ -2122,6 +2129,9 @@ static enum mac_version rtl8169_get_mac_ +@@ -2096,6 +2103,9 @@ static enum mac_version rtl8169_get_mac_ u16 val; enum mac_version ver; } mac_info[] = { @@ -111,7 +111,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> /* 8125B family. */ { 0x7cf, 0x641, RTL_GIGA_MAC_VER_63 }, -@@ -2392,6 +2402,7 @@ static void rtl_init_rxcfg(struct rtl816 +@@ -2366,6 +2376,7 @@ static void rtl_init_rxcfg(struct rtl816 RTL_W32(tp, RxConfig, RX_FETCH_DFLT_8125 | RX_DMA_BURST); break; case RTL_GIGA_MAC_VER_63: @@ -119,7 +119,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> RTL_W32(tp, RxConfig, RX_FETCH_DFLT_8125 | RX_DMA_BURST | RX_PAUSE_SLOT_ON); break; -@@ -2578,7 +2589,7 @@ static void rtl_wait_txrx_fifo_empty(str +@@ -2552,7 +2563,7 @@ static void rtl_wait_txrx_fifo_empty(str case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_61: rtl_loop_wait_high(tp, &rtl_rxtx_empty_cond, 100, 42); break; @@ -128,7 +128,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> RTL_W8(tp, ChipCmd, RTL_R8(tp, ChipCmd) | StopReq); rtl_loop_wait_high(tp, &rtl_rxtx_empty_cond, 100, 42); rtl_loop_wait_high(tp, &rtl_rxtx_empty_cond_2, 100, 42); -@@ -2822,7 +2833,7 @@ static void rtl_enable_exit_l1(struct rt +@@ -2795,7 +2806,7 @@ static void rtl_enable_exit_l1(struct rt case RTL_GIGA_MAC_VER_37 ... RTL_GIGA_MAC_VER_38: rtl_eri_set_bits(tp, 0xd4, 0x0c00); break; @@ -137,7 +137,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> r8168_mac_ocp_modify(tp, 0xc0ac, 0, 0x1f80); break; default: -@@ -2836,7 +2847,7 @@ static void rtl_disable_exit_l1(struct r +@@ -2809,7 +2820,7 @@ static void rtl_disable_exit_l1(struct r case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38: rtl_eri_clear_bits(tp, 0xd4, 0x1f00); break; @@ -146,7 +146,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> r8168_mac_ocp_modify(tp, 0xc0ac, 0x1f80, 0); break; default: -@@ -2846,6 +2857,8 @@ static void rtl_disable_exit_l1(struct r +@@ -2819,6 +2830,8 @@ static void rtl_disable_exit_l1(struct r static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable) { @@ -155,7 +155,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> if (tp->mac_version < RTL_GIGA_MAC_VER_32) return; -@@ -2859,11 +2872,19 @@ static void rtl_hw_aspm_clkreq_enable(st +@@ -2832,11 +2845,19 @@ static void rtl_hw_aspm_clkreq_enable(st return; rtl_mod_config5(tp, 0, ASPM_en); @@ -177,7 +177,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> /* reset ephy tx/rx disable timer */ r8168_mac_ocp_modify(tp, 0xe094, 0xff00, 0); /* chip can trigger L1.2 */ -@@ -2875,14 +2896,22 @@ static void rtl_hw_aspm_clkreq_enable(st +@@ -2848,14 +2869,22 @@ static void rtl_hw_aspm_clkreq_enable(st } else { switch (tp->mac_version) { case RTL_GIGA_MAC_VER_46 ... RTL_GIGA_MAC_VER_48: @@ -202,7 +202,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> rtl_mod_config5(tp, ASPM_en, 0); } } -@@ -3678,10 +3707,15 @@ static void rtl_hw_start_8125_common(str +@@ -3568,10 +3597,15 @@ static void rtl_hw_start_8125_common(str /* disable new tx descriptor format */ r8168_mac_ocp_modify(tp, 0xeb58, 0x0001, 0x0000); @@ -220,7 +220,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> if (tp->mac_version == RTL_GIGA_MAC_VER_63) r8168_mac_ocp_modify(tp, 0xe63e, 0x0c30, 0x0000); -@@ -3694,6 +3728,10 @@ static void rtl_hw_start_8125_common(str +@@ -3584,6 +3618,10 @@ static void rtl_hw_start_8125_common(str r8168_mac_ocp_modify(tp, 0xe056, 0x00f0, 0x0030); r8168_mac_ocp_modify(tp, 0xe040, 0x1000, 0x0000); r8168_mac_ocp_modify(tp, 0xea1c, 0x0003, 0x0001); @@ -231,7 +231,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> r8168_mac_ocp_modify(tp, 0xe0c0, 0x4f0f, 0x4403); r8168_mac_ocp_modify(tp, 0xe052, 0x0080, 0x0068); r8168_mac_ocp_modify(tp, 0xd430, 0x0fff, 0x047f); -@@ -3708,10 +3746,10 @@ static void rtl_hw_start_8125_common(str +@@ -3598,10 +3636,10 @@ static void rtl_hw_start_8125_common(str rtl_loop_wait_low(tp, &rtl_mac_ocp_e00e_cond, 1000, 10); @@ -245,7 +245,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> rtl_disable_rxdvgate(tp); } -@@ -3755,6 +3793,12 @@ static void rtl_hw_start_8125b(struct rt +@@ -3645,6 +3683,12 @@ static void rtl_hw_start_8125b(struct rt rtl_hw_start_8125_common(tp); } @@ -258,7 +258,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> static void rtl_hw_config(struct rtl8169_private *tp) { static const rtl_generic_fct hw_configs[] = { -@@ -3797,6 +3841,7 @@ static void rtl_hw_config(struct rtl8169 +@@ -3687,6 +3731,7 @@ static void rtl_hw_config(struct rtl8169 [RTL_GIGA_MAC_VER_53] = rtl_hw_start_8117, [RTL_GIGA_MAC_VER_61] = rtl_hw_start_8125a_2, [RTL_GIGA_MAC_VER_63] = rtl_hw_start_8125b, @@ -266,7 +266,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> }; if (hw_configs[tp->mac_version]) -@@ -3807,9 +3852,23 @@ static void rtl_hw_start_8125(struct rtl +@@ -3697,9 +3742,23 @@ static void rtl_hw_start_8125(struct rtl { int i; @@ -292,7 +292,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> rtl_hw_config(tp); } -@@ -3887,8 +3946,7 @@ static int rtl8169_change_mtu(struct net +@@ -3777,8 +3836,7 @@ static int rtl8169_change_mtu(struct net rtl_jumbo_config(tp); switch (tp->mac_version) { @@ -302,7 +302,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> rtl8125_set_eee_txidle_timer(tp); break; default: -@@ -4037,7 +4095,7 @@ static void rtl8169_cleanup(struct rtl81 +@@ -3927,7 +3985,7 @@ static void rtl8169_cleanup(struct rtl81 RTL_W8(tp, ChipCmd, RTL_R8(tp, ChipCmd) | StopReq); rtl_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 666); break; @@ -311,7 +311,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> rtl_enable_rxdvgate(tp); fsleep(2000); break; -@@ -4188,8 +4246,7 @@ static unsigned int rtl_quirk_packet_pad +@@ -4078,8 +4136,7 @@ static unsigned int rtl_quirk_packet_pad switch (tp->mac_version) { case RTL_GIGA_MAC_VER_34: @@ -321,7 +321,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> padto = max_t(unsigned int, padto, ETH_ZLEN); break; default: -@@ -5225,7 +5282,7 @@ static void rtl_hw_initialize(struct rtl +@@ -5112,7 +5169,7 @@ static void rtl_hw_initialize(struct rtl case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_48: rtl_hw_init_8168g(tp); break; diff --git a/target/linux/generic/backport-6.6/780-04-v6.9-r8169-improve-checking-for-valid-LED-modes.patch b/target/linux/generic/backport-6.6/780-09-v6.9-r8169-improve-checking-for-valid-LED-modes.patch index ae0c821267..ae0c821267 100644 --- a/target/linux/generic/backport-6.6/780-04-v6.9-r8169-improve-checking-for-valid-LED-modes.patch +++ b/target/linux/generic/backport-6.6/780-09-v6.9-r8169-improve-checking-for-valid-LED-modes.patch diff --git a/target/linux/generic/backport-6.6/780-10-v6.9-r8169-simplify-code-by-using-core-provided-pcpu-stat.patch b/target/linux/generic/backport-6.6/780-10-v6.9-r8169-simplify-code-by-using-core-provided-pcpu-stat.patch new file mode 100644 index 0000000000..510123767a --- /dev/null +++ b/target/linux/generic/backport-6.6/780-10-v6.9-r8169-simplify-code-by-using-core-provided-pcpu-stat.patch @@ -0,0 +1,39 @@ +From 400909df6e6543cb5cce3db9bbcd413d59125327 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Sat, 10 Feb 2024 17:58:29 +0100 +Subject: [PATCH] r8169: simplify code by using core-provided pcpu stats + allocation + +Use core-provided pcpu stats allocation instead of open-coding it in +the driver. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Link: https://lore.kernel.org/r/03f5bb3b-d7f4-48be-ae8a-54862ec4566c@gmail.com +Signed-off-by: Paolo Abeni <pabeni@redhat.com> +--- + drivers/net/ethernet/realtek/r8169_main.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -5261,11 +5261,6 @@ static int rtl_init_one(struct pci_dev * + raw_spin_lock_init(&tp->mac_ocp_lock); + mutex_init(&tp->led_lock); + +- dev->tstats = devm_netdev_alloc_pcpu_stats(&pdev->dev, +- struct pcpu_sw_netstats); +- if (!dev->tstats) +- return -ENOMEM; +- + /* Get the *optional* external "ether_clk" used on some boards */ + tp->clk = devm_clk_get_optional_enabled(&pdev->dev, "ether_clk"); + if (IS_ERR(tp->clk)) +@@ -5380,6 +5375,8 @@ static int rtl_init_one(struct pci_dev * + dev->hw_features |= NETIF_F_RXALL; + dev->hw_features |= NETIF_F_RXFCS; + ++ dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; ++ + netdev_sw_irq_coalesce_default_on(dev); + + /* configure chip for default features */ diff --git a/target/linux/generic/backport-6.6/780-05-v6.9-r8169-add-LED-support-for-RTL8125-RTL8126.patch b/target/linux/generic/backport-6.6/780-11-v6.9-r8169-add-LED-support-for-RTL8125-RTL8126.patch index 742ee578b2..2059551b50 100644 --- a/target/linux/generic/backport-6.6/780-05-v6.9-r8169-add-LED-support-for-RTL8125-RTL8126.patch +++ b/target/linux/generic/backport-6.6/780-11-v6.9-r8169-add-LED-support-for-RTL8125-RTL8126.patch @@ -149,7 +149,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org> +} --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c -@@ -334,17 +334,23 @@ enum rtl8168_registers { +@@ -330,17 +330,23 @@ enum rtl8168_registers { }; enum rtl8125_registers { @@ -173,7 +173,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org> #define RX_VLAN_INNER_8125 BIT(22) #define RX_VLAN_OUTER_8125 BIT(23) #define RX_VLAN_8125 (RX_VLAN_INNER_8125 | RX_VLAN_OUTER_8125) -@@ -835,6 +841,51 @@ int rtl8168_get_led_mode(struct rtl8169_ +@@ -830,6 +836,51 @@ int rtl8168_get_led_mode(struct rtl8169_ return ret; } @@ -225,7 +225,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org> void r8169_get_led_name(struct rtl8169_private *tp, int idx, char *buf, int buf_len) { -@@ -5530,10 +5581,12 @@ static int rtl_init_one(struct pci_dev * +@@ -5413,10 +5464,12 @@ static int rtl_init_one(struct pci_dev * if (rc) return rc; diff --git a/target/linux/generic/backport-6.6/780-12-v6.9-r8169-add-generic-rtl_set_eee_txidle_timer-function.patch b/target/linux/generic/backport-6.6/780-12-v6.9-r8169-add-generic-rtl_set_eee_txidle_timer-function.patch new file mode 100644 index 0000000000..1a7eed191f --- /dev/null +++ b/target/linux/generic/backport-6.6/780-12-v6.9-r8169-add-generic-rtl_set_eee_txidle_timer-function.patch @@ -0,0 +1,91 @@ +From 2ce30993831041b9dcd31eb12896be6611e8b7e2 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Mon, 12 Feb 2024 19:57:46 +0100 +Subject: [PATCH] r8169: add generic rtl_set_eee_txidle_timer function + +Add a generic setter for the EEE tx idle timer and use it with all +RTL8125/RTL8126 chip versions, in line with the vendor driver. +This prepares for adding EEE tx idle timer support for additional +chip versions. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Reviewed-by: Andrew Lunn <andrew@lunn.ch> +Link: https://lore.kernel.org/r/39beed72-0dc4-4c45-8899-b72c43ab62a7@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/realtek/r8169_main.c | 34 +++++++++++++---------- + 1 file changed, 20 insertions(+), 14 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -619,6 +619,7 @@ struct rtl8169_private { + struct page *Rx_databuff[NUM_RX_DESC]; /* Rx data buffers */ + struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */ + u16 cp_cmd; ++ u16 tx_lpi_timer; + u32 irq_mask; + int irq; + struct clk *clk; +@@ -2054,6 +2055,22 @@ static int rtl_set_coalesce(struct net_d + return 0; + } + ++static void rtl_set_eee_txidle_timer(struct rtl8169_private *tp) ++{ ++ unsigned int timer_val = READ_ONCE(tp->dev->mtu) + ETH_HLEN + 0x20; ++ ++ switch (tp->mac_version) { ++ case RTL_GIGA_MAC_VER_61: ++ case RTL_GIGA_MAC_VER_63: ++ case RTL_GIGA_MAC_VER_65: ++ tp->tx_lpi_timer = timer_val; ++ RTL_W16(tp, EEE_TXIDLE_TIMER_8125, timer_val); ++ break; ++ default: ++ break; ++ } ++} ++ + static int rtl8169_get_eee(struct net_device *dev, struct ethtool_eee *data) + { + struct rtl8169_private *tp = netdev_priv(dev); +@@ -2312,14 +2329,8 @@ static void rtl8125a_config_eee_mac(stru + r8168_mac_ocp_modify(tp, 0xeb62, 0, BIT(2) | BIT(1)); + } + +-static void rtl8125_set_eee_txidle_timer(struct rtl8169_private *tp) +-{ +- RTL_W16(tp, EEE_TXIDLE_TIMER_8125, tp->dev->mtu + ETH_HLEN + 0x20); +-} +- + static void rtl8125b_config_eee_mac(struct rtl8169_private *tp) + { +- rtl8125_set_eee_txidle_timer(tp); + r8168_mac_ocp_modify(tp, 0xe040, 0, BIT(1) | BIT(0)); + } + +@@ -3852,6 +3863,8 @@ static void rtl_hw_start(struct rtl8169 + rtl_hw_aspm_clkreq_enable(tp, false); + RTL_W16(tp, CPlusCmd, tp->cp_cmd); + ++ rtl_set_eee_txidle_timer(tp); ++ + if (tp->mac_version <= RTL_GIGA_MAC_VER_06) + rtl_hw_start_8169(tp); + else if (rtl_is_8125(tp)) +@@ -3885,14 +3898,7 @@ static int rtl8169_change_mtu(struct net + dev->mtu = new_mtu; + netdev_update_features(dev); + rtl_jumbo_config(tp); +- +- switch (tp->mac_version) { +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_65: +- rtl8125_set_eee_txidle_timer(tp); +- break; +- default: +- break; +- } ++ rtl_set_eee_txidle_timer(tp); + + return 0; + } diff --git a/target/linux/generic/backport-6.6/780-13-v6.9-r8169-support-setting-the-EEE-tx-idle-timer-on-RTL81.patch b/target/linux/generic/backport-6.6/780-13-v6.9-r8169-support-setting-the-EEE-tx-idle-timer-on-RTL81.patch new file mode 100644 index 0000000000..917c7c194f --- /dev/null +++ b/target/linux/generic/backport-6.6/780-13-v6.9-r8169-support-setting-the-EEE-tx-idle-timer-on-RTL81.patch @@ -0,0 +1,30 @@ +From 57d2d2c8f132c830565058a5cdd8138350e068ec Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Mon, 12 Feb 2024 19:58:47 +0100 +Subject: [PATCH] r8169: support setting the EEE tx idle timer on + RTL8168h + +Support setting the EEE tx idle timer also on RTL8168h. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Reviewed-by: Andrew Lunn <andrew@lunn.ch> +Link: https://lore.kernel.org/r/cfb69ec9-24c4-4aad-9909-fdae3088add4@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/realtek/r8169_main.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -2060,6 +2060,11 @@ static void rtl_set_eee_txidle_timer(str + unsigned int timer_val = READ_ONCE(tp->dev->mtu) + ETH_HLEN + 0x20; + + switch (tp->mac_version) { ++ case RTL_GIGA_MAC_VER_46: ++ case RTL_GIGA_MAC_VER_48: ++ tp->tx_lpi_timer = timer_val; ++ r8168_mac_ocp_write(tp, 0xe048, timer_val); ++ break; + case RTL_GIGA_MAC_VER_61: + case RTL_GIGA_MAC_VER_63: + case RTL_GIGA_MAC_VER_65: diff --git a/target/linux/generic/backport-6.6/780-14-v6.9-r8169-add-support-for-returning-tx_lpi_timer-in-etht.patch b/target/linux/generic/backport-6.6/780-14-v6.9-r8169-add-support-for-returning-tx_lpi_timer-in-etht.patch new file mode 100644 index 0000000000..51477d0142 --- /dev/null +++ b/target/linux/generic/backport-6.6/780-14-v6.9-r8169-add-support-for-returning-tx_lpi_timer-in-etht.patch @@ -0,0 +1,55 @@ +From 9c50139727265c088f936e496777bf588850e9f1 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Mon, 12 Feb 2024 19:59:26 +0100 +Subject: [PATCH] r8169: add support for returning tx_lpi_timer in + ethtool get_eee + +Add support for returning the tx_lpi_timer value to userspace. +This is supported by few chip versions only: RTL8168h/RTL8125/RTL8126 + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Reviewed-by: Andrew Lunn <andrew@lunn.ch> +Link: https://lore.kernel.org/r/4eee9c34-c5d6-4c96-9b05-455896dea59a@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/realtek/r8169_main.c | 22 +++++++++++++++++++++- + 1 file changed, 21 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -2076,14 +2076,34 @@ static void rtl_set_eee_txidle_timer(str + } + } + ++static unsigned int r8169_get_tx_lpi_timer_us(struct rtl8169_private *tp) ++{ ++ unsigned int speed = tp->phydev->speed; ++ unsigned int timer = tp->tx_lpi_timer; ++ ++ if (!timer || speed == SPEED_UNKNOWN) ++ return 0; ++ ++ /* tx_lpi_timer value is in bytes */ ++ return DIV_ROUND_CLOSEST(timer * BITS_PER_BYTE, speed); ++} ++ + static int rtl8169_get_eee(struct net_device *dev, struct ethtool_eee *data) + { + struct rtl8169_private *tp = netdev_priv(dev); ++ int ret; + + if (!rtl_supports_eee(tp)) + return -EOPNOTSUPP; + +- return phy_ethtool_get_eee(tp->phydev, data); ++ ret = phy_ethtool_get_eee(tp->phydev, data); ++ if (ret) ++ return ret; ++ ++ data->tx_lpi_timer = r8169_get_tx_lpi_timer_us(tp); ++ data->tx_lpi_enabled = data->tx_lpi_timer ? data->eee_enabled : false; ++ ++ return 0; + } + + static int rtl8169_set_eee(struct net_device *dev, struct ethtool_eee *data) diff --git a/target/linux/generic/backport-6.6/780-06-v6.9-r8169-add-MODULE_FIRMWARE-entry-for-RTL8126A.patch b/target/linux/generic/backport-6.6/780-15-v6.9-r8169-add-MODULE_FIRMWARE-entry-for-RTL8126A.patch index a6175c824e..6a7ebc885b 100644 --- a/target/linux/generic/backport-6.6/780-06-v6.9-r8169-add-MODULE_FIRMWARE-entry-for-RTL8126A.patch +++ b/target/linux/generic/backport-6.6/780-15-v6.9-r8169-add-MODULE_FIRMWARE-entry-for-RTL8126A.patch @@ -15,7 +15,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org> --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c -@@ -680,6 +680,7 @@ MODULE_FIRMWARE(FIRMWARE_8168FP_3); +@@ -676,6 +676,7 @@ MODULE_FIRMWARE(FIRMWARE_8168FP_3); MODULE_FIRMWARE(FIRMWARE_8107E_2); MODULE_FIRMWARE(FIRMWARE_8125A_3); MODULE_FIRMWARE(FIRMWARE_8125B_2); diff --git a/target/linux/generic/backport-6.6/780-08-v6.10-r8169-fix-LED-related-deadlock-on-module-removal.patch b/target/linux/generic/backport-6.6/780-16-v6.9-r8169-fix-LED-related-deadlock-on-module-removal.patch index 52019869a8..d8e4a4f6ff 100644 --- a/target/linux/generic/backport-6.6/780-08-v6.10-r8169-fix-LED-related-deadlock-on-module-removal.patch +++ b/target/linux/generic/backport-6.6/780-16-v6.9-r8169-fix-LED-related-deadlock-on-module-removal.patch @@ -115,7 +115,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> } --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c -@@ -651,6 +651,8 @@ struct rtl8169_private { +@@ -647,6 +647,8 @@ struct rtl8169_private { const char *fw_name; struct rtl_fw *rtl_fw; @@ -124,7 +124,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> u32 ocp_base; }; -@@ -5126,6 +5128,8 @@ static void rtl_remove_one(struct pci_de +@@ -5040,6 +5042,8 @@ static void rtl_remove_one(struct pci_de cancel_work_sync(&tp->wk.work); @@ -133,7 +133,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> unregister_netdev(tp->dev); if (tp->dash_type != RTL_DASH_NONE) -@@ -5586,9 +5590,9 @@ static int rtl_init_one(struct pci_dev * +@@ -5498,9 +5502,9 @@ static int rtl_init_one(struct pci_dev * if (IS_ENABLED(CONFIG_R8169_LEDS)) { if (rtl_is_8125(tp)) diff --git a/target/linux/generic/backport-6.6/780-09-v6.10-r8169-add-missing-conditional-compiling-for-call-to-.patch b/target/linux/generic/backport-6.6/780-17-v6.9-r8169-add-missing-conditional-compiling-for-call-to-.patch index cfe552046e..366ae803f9 100644 --- a/target/linux/generic/backport-6.6/780-09-v6.10-r8169-add-missing-conditional-compiling-for-call-to-.patch +++ b/target/linux/generic/backport-6.6/780-17-v6.9-r8169-add-missing-conditional-compiling-for-call-to-.patch @@ -19,7 +19,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org> --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c -@@ -5128,7 +5128,8 @@ static void rtl_remove_one(struct pci_de +@@ -5042,7 +5042,8 @@ static void rtl_remove_one(struct pci_de cancel_work_sync(&tp->wk.work); diff --git a/target/linux/generic/backport-6.6/780-07-v6.10-r8169-add-support-for-RTL8168M.patch b/target/linux/generic/backport-6.6/780-18-v6.10-r8169-add-support-for-RTL8168M.patch index 557b8b1491..2abbe2ccf1 100644 --- a/target/linux/generic/backport-6.6/780-07-v6.10-r8169-add-support-for-RTL8168M.patch +++ b/target/linux/generic/backport-6.6/780-18-v6.10-r8169-add-support-for-RTL8168M.patch @@ -19,7 +19,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c -@@ -2212,6 +2212,8 @@ static enum mac_version rtl8169_get_mac_ +@@ -2230,6 +2230,8 @@ static enum mac_version rtl8169_get_mac_ * the wild. Let's disable detection. * { 0x7cf, 0x540, RTL_GIGA_MAC_VER_45 }, */ diff --git a/target/linux/generic/backport-6.6/780-19-v6.10-net-annotate-writes-on-dev-mtu-from-ndo_change_mtu.patch b/target/linux/generic/backport-6.6/780-19-v6.10-net-annotate-writes-on-dev-mtu-from-ndo_change_mtu.patch new file mode 100644 index 0000000000..cad1210e4d --- /dev/null +++ b/target/linux/generic/backport-6.6/780-19-v6.10-net-annotate-writes-on-dev-mtu-from-ndo_change_mtu.patch @@ -0,0 +1,60 @@ +From 1eb2cded45b35816085c1f962933c187d970f9dc Mon Sep 17 00:00:00 2001 +From: Eric Dumazet <edumazet@google.com> +Date: Mon, 6 May 2024 10:28:12 +0000 +Subject: [PATCH] net: annotate writes on dev->mtu from ndo_change_mtu() + +Simon reported that ndo_change_mtu() methods were never +updated to use WRITE_ONCE(dev->mtu, new_mtu) as hinted +in commit 501a90c94510 ("inet: protect against too small +mtu values.") + +We read dev->mtu without holding RTNL in many places, +with READ_ONCE() annotations. + +It is time to take care of ndo_change_mtu() methods +to use corresponding WRITE_ONCE() + +Signed-off-by: Eric Dumazet <edumazet@google.com> +Reported-by: Simon Horman <horms@kernel.org> +Closes: https://lore.kernel.org/netdev/20240505144608.GB67882@kernel.org/ +Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> +Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> +Reviewed-by: Simon Horman <horms@kernel.org> +Acked-by: Shannon Nelson <shannon.nelson@amd.com> +Link: https://lore.kernel.org/r/20240506102812.3025432-1-edumazet@google.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/realtek/8139cp.c | 4 ++-- + drivers/net/ethernet/realtek/r8169_main.c | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/net/ethernet/realtek/8139cp.c ++++ b/drivers/net/ethernet/realtek/8139cp.c +@@ -1277,14 +1277,14 @@ static int cp_change_mtu(struct net_devi + + /* if network interface not up, no need for complexity */ + if (!netif_running(dev)) { +- dev->mtu = new_mtu; ++ WRITE_ONCE(dev->mtu, new_mtu); + cp_set_rxbufsize(cp); /* set new rx buf size */ + return 0; + } + + /* network IS up, close it, reset MTU, and come up again. */ + cp_close(dev); +- dev->mtu = new_mtu; ++ WRITE_ONCE(dev->mtu, new_mtu); + cp_set_rxbufsize(cp); + return cp_open(dev); + } +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -3925,7 +3925,7 @@ static int rtl8169_change_mtu(struct net + { + struct rtl8169_private *tp = netdev_priv(dev); + +- dev->mtu = new_mtu; ++ WRITE_ONCE(dev->mtu, new_mtu); + netdev_update_features(dev); + rtl_jumbo_config(tp); + rtl_set_eee_txidle_timer(tp); diff --git a/target/linux/generic/backport-6.6/780-20-v6.11-r8169-disable-interrupt-source-RxOverflow.patch b/target/linux/generic/backport-6.6/780-20-v6.11-r8169-disable-interrupt-source-RxOverflow.patch new file mode 100644 index 0000000000..cef5d95252 --- /dev/null +++ b/target/linux/generic/backport-6.6/780-20-v6.11-r8169-disable-interrupt-source-RxOverflow.patch @@ -0,0 +1,34 @@ +From 6994520a332887f1688464f250c9ec8002a89a8e Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Mon, 27 May 2024 21:16:56 +0200 +Subject: [PATCH] r8169: disable interrupt source RxOverflow + +Vendor driver calls this bit RxDescUnavail. All we do in the interrupt +handler in this case is scheduling NAPI. If we should be out of +RX descriptors, then NAPI is scheduled anyway. Therefore remove this +interrupt source. Tested on RTL8168h. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Reviewed-by: Sunil Goutham <sgoutham@marvell.com> +Link: https://lore.kernel.org/r/9b2054b2-0548-4f48-bf91-b646572093b4@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/realtek/r8169_main.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -5083,12 +5083,10 @@ static void rtl_set_irq_mask(struct rtl8 + tp->irq_mask = RxOK | RxErr | TxOK | TxErr | LinkChg; + + if (tp->mac_version <= RTL_GIGA_MAC_VER_06) +- tp->irq_mask |= SYSErr | RxOverflow | RxFIFOOver; ++ tp->irq_mask |= SYSErr | RxFIFOOver; + else if (tp->mac_version == RTL_GIGA_MAC_VER_11) + /* special workaround needed */ + tp->irq_mask |= RxFIFOOver; +- else +- tp->irq_mask |= RxOverflow; + } + + static int rtl_alloc_irq(struct rtl8169_private *tp) diff --git a/target/linux/generic/backport-6.6/780-21-v6.11-r8169-remove-detection-of-chip-version-11-early-RTL8.patch b/target/linux/generic/backport-6.6/780-21-v6.11-r8169-remove-detection-of-chip-version-11-early-RTL8.patch new file mode 100644 index 0000000000..7f0f23fccb --- /dev/null +++ b/target/linux/generic/backport-6.6/780-21-v6.11-r8169-remove-detection-of-chip-version-11-early-RTL8.patch @@ -0,0 +1,32 @@ +From 982300c115d229565d7af8e8b38aa1ee7bb1f5bd Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Mon, 27 May 2024 21:20:16 +0200 +Subject: [PATCH] r8169: remove detection of chip version 11 (early + RTL8168b) + +This early RTL8168b version was the first PCIe chip version, and it's +quite quirky. Last sign of life is from more than 15 yrs ago. +Let's remove detection of this chip version, we'll see whether anybody +complains. If not, support for this chip version can be removed a few +kernel versions later. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Link: https://lore.kernel.org/r/875cdcf4-843c-420a-ad5d-417447b68572@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/ethernet/realtek/r8169_main.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -2275,7 +2275,9 @@ static enum mac_version rtl8169_get_mac_ + + /* 8168B family. */ + { 0x7c8, 0x380, RTL_GIGA_MAC_VER_17 }, +- { 0x7c8, 0x300, RTL_GIGA_MAC_VER_11 }, ++ /* This one is very old and rare, let's see if anybody complains. ++ * { 0x7c8, 0x300, RTL_GIGA_MAC_VER_11 }, ++ */ + + /* 8101 family. */ + { 0x7c8, 0x448, RTL_GIGA_MAC_VER_39 }, diff --git a/target/linux/generic/backport-6.6/781-01-v6.9-net-phy-realtek-add-support-for-RTL8126A-integrated-.patch b/target/linux/generic/backport-6.6/781-01-v6.9-net-phy-realtek-add-support-for-RTL8126A-integrated-.patch new file mode 100644 index 0000000000..723742e7fa --- /dev/null +++ b/target/linux/generic/backport-6.6/781-01-v6.9-net-phy-realtek-add-support-for-RTL8126A-integrated-.patch @@ -0,0 +1,40 @@ +From 5befa3728b855e9f75b29bb0069a1ca7f5bab2f7 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Wed, 31 Jan 2024 21:24:29 +0100 +Subject: [PATCH] net: phy: realtek: add support for RTL8126A-integrated 5Gbps + PHY + +A user reported that first consumer mainboards show up with a RTL8126A +5Gbps MAC/PHY. This adds support for the integrated PHY, which is also +available stand-alone. From a PHY driver perspective it's treated the +same as the 2.5Gbps PHY's, we just have to support the new PHY ID. + +Reported-by: Joe Salmeri <jmscdba@gmail.com> +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Reviewed-by: Andrew Lunn <andrew@lunn.ch> +Tested-by: Joe Salmeri <jmscdba@gmail.com> +Link: https://lore.kernel.org/r/0c8e67ea-6505-43d1-bd51-94e7ecd6e222@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/phy/realtek.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -1050,6 +1050,16 @@ static struct phy_driver realtek_drvs[] + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + }, { ++ PHY_ID_MATCH_EXACT(0x001cc862), ++ .name = "RTL8251B 5Gbps PHY", ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .read_status = rtl822x_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { + PHY_ID_MATCH_EXACT(0x001cc961), + .name = "RTL8366RB Gigabit Ethernet", + .config_init = &rtl8366rb_config_init, diff --git a/target/linux/generic/backport-6.6/781-02-v6.9-net-phy-realtek-use-generic-MDIO-constants.patch b/target/linux/generic/backport-6.6/781-02-v6.9-net-phy-realtek-use-generic-MDIO-constants.patch new file mode 100644 index 0000000000..6672aca9b8 --- /dev/null +++ b/target/linux/generic/backport-6.6/781-02-v6.9-net-phy-realtek-use-generic-MDIO-constants.patch @@ -0,0 +1,93 @@ +From 2b9ec5dfb8255656ca731ab9d9bf59d94566d377 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org> +Date: Sun, 4 Feb 2024 15:17:53 +0100 +Subject: [PATCH] net: phy: realtek: use generic MDIO constants +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Drop the ad-hoc MDIO constants used in the driver and use generic +constants instead. + +Signed-off-by: Marek Behún <kabel@kernel.org> +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Reviewed-by: Andrew Lunn <andrew@lunn.ch> +Link: https://lore.kernel.org/r/732a70d6-4191-4aae-8862-3716b062aa9e@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/phy/realtek.c | 30 +++++++++++++----------------- + 1 file changed, 13 insertions(+), 17 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -57,14 +57,6 @@ + #define RTL8366RB_POWER_SAVE 0x15 + #define RTL8366RB_POWER_SAVE_ON BIT(12) + +-#define RTL_SUPPORTS_5000FULL BIT(14) +-#define RTL_SUPPORTS_2500FULL BIT(13) +-#define RTL_SUPPORTS_10000FULL BIT(0) +-#define RTL_ADV_2500FULL BIT(7) +-#define RTL_LPADV_10000FULL BIT(11) +-#define RTL_LPADV_5000FULL BIT(6) +-#define RTL_LPADV_2500FULL BIT(5) +- + #define RTL9000A_GINMR 0x14 + #define RTL9000A_GINMR_LINK_STATUS BIT(4) + +@@ -676,11 +668,11 @@ static int rtl822x_get_features(struct p + return val; + + linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, +- phydev->supported, val & RTL_SUPPORTS_2500FULL); ++ phydev->supported, val & MDIO_PMA_SPEED_2_5G); + linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, +- phydev->supported, val & RTL_SUPPORTS_5000FULL); ++ phydev->supported, val & MDIO_PMA_SPEED_5G); + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, +- phydev->supported, val & RTL_SUPPORTS_10000FULL); ++ phydev->supported, val & MDIO_SPEED_10G); + + return genphy_read_abilities(phydev); + } +@@ -694,10 +686,11 @@ static int rtl822x_config_aneg(struct ph + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, + phydev->advertising)) +- adv2500 = RTL_ADV_2500FULL; ++ adv2500 = MDIO_AN_10GBT_CTRL_ADV2_5G; + + ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12, +- RTL_ADV_2500FULL, adv2500); ++ MDIO_AN_10GBT_CTRL_ADV2_5G, ++ adv2500); + if (ret < 0) + return ret; + } +@@ -716,11 +709,14 @@ static int rtl822x_read_status(struct ph + return lpadv; + + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, +- phydev->lp_advertising, lpadv & RTL_LPADV_10000FULL); ++ phydev->lp_advertising, ++ lpadv & MDIO_AN_10GBT_STAT_LP10G); + linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, +- phydev->lp_advertising, lpadv & RTL_LPADV_5000FULL); ++ phydev->lp_advertising, ++ lpadv & MDIO_AN_10GBT_STAT_LP5G); + linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, +- phydev->lp_advertising, lpadv & RTL_LPADV_2500FULL); ++ phydev->lp_advertising, ++ lpadv & MDIO_AN_10GBT_STAT_LP2_5G); + } + + ret = genphy_read_status(phydev); +@@ -738,7 +734,7 @@ static bool rtlgen_supports_2_5gbps(stru + val = phy_read(phydev, 0x13); + phy_write(phydev, RTL821x_PAGE_SELECT, 0); + +- return val >= 0 && val & RTL_SUPPORTS_2500FULL; ++ return val >= 0 && val & MDIO_PMA_SPEED_2_5G; + } + + static int rtlgen_match_phy_device(struct phy_device *phydev) diff --git a/target/linux/generic/backport-6.6/781-03-v6.9-net-phy-realtek-add-5Gbps-support-to-rtl822x_config_.patch b/target/linux/generic/backport-6.6/781-03-v6.9-net-phy-realtek-add-5Gbps-support-to-rtl822x_config_.patch new file mode 100644 index 0000000000..4b99a0eae6 --- /dev/null +++ b/target/linux/generic/backport-6.6/781-03-v6.9-net-phy-realtek-add-5Gbps-support-to-rtl822x_config_.patch @@ -0,0 +1,42 @@ +From db1bb7741ff29bf2cefcbc0ca567644e9ed1caa9 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Sun, 4 Feb 2024 15:18:50 +0100 +Subject: [PATCH] net: phy: realtek: add 5Gbps support to rtl822x_config_aneg() + +RTL8126 as an evolution of RTL8125 supports 5Gbps. rtl822x_config_aneg() +is used by the PHY driver for the integrated PHY, therefore add 5Gbps +support to it. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Link: https://lore.kernel.org/r/5644ab50-e3e9-477c-96db-05cd5bdc2563@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/phy/realtek.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -682,15 +682,19 @@ static int rtl822x_config_aneg(struct ph + int ret = 0; + + if (phydev->autoneg == AUTONEG_ENABLE) { +- u16 adv2500 = 0; ++ u16 adv = 0; + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, + phydev->advertising)) +- adv2500 = MDIO_AN_10GBT_CTRL_ADV2_5G; ++ adv |= MDIO_AN_10GBT_CTRL_ADV2_5G; ++ if (linkmode_test_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, ++ phydev->advertising)) ++ adv |= MDIO_AN_10GBT_CTRL_ADV5G; + + ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12, +- MDIO_AN_10GBT_CTRL_ADV2_5G, +- adv2500); ++ MDIO_AN_10GBT_CTRL_ADV2_5G | ++ MDIO_AN_10GBT_CTRL_ADV5G, ++ adv); + if (ret < 0) + return ret; + } diff --git a/target/linux/generic/backport-6.6/781-04-v6.9-net-phy-realtek-use-generic-MDIO-helpers-to-simplify.patch b/target/linux/generic/backport-6.6/781-04-v6.9-net-phy-realtek-use-generic-MDIO-helpers-to-simplify.patch new file mode 100644 index 0000000000..86db2df76b --- /dev/null +++ b/target/linux/generic/backport-6.6/781-04-v6.9-net-phy-realtek-use-generic-MDIO-helpers-to-simplify.patch @@ -0,0 +1,52 @@ +From b63cc73341e076961d564a74cc3d29b2fd444079 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit <hkallweit1@gmail.com> +Date: Thu, 8 Feb 2024 07:59:18 +0100 +Subject: [PATCH] net: phy: realtek: use generic MDIO helpers to simplify the + code + +Use generic MDIO helpers to simplify the code. + +Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> +Reviewed-by: Andrew Lunn <andrew@lunn.ch> +Link: https://lore.kernel.org/r/422ae70f-7305-45fd-ab3e-0dd604b9fd6c@gmail.com +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/phy/realtek.c | 20 +++----------------- + 1 file changed, 3 insertions(+), 17 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -682,14 +682,7 @@ static int rtl822x_config_aneg(struct ph + int ret = 0; + + if (phydev->autoneg == AUTONEG_ENABLE) { +- u16 adv = 0; +- +- if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, +- phydev->advertising)) +- adv |= MDIO_AN_10GBT_CTRL_ADV2_5G; +- if (linkmode_test_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, +- phydev->advertising)) +- adv |= MDIO_AN_10GBT_CTRL_ADV5G; ++ u16 adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising); + + ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12, + MDIO_AN_10GBT_CTRL_ADV2_5G | +@@ -712,15 +705,8 @@ static int rtl822x_read_status(struct ph + if (lpadv < 0) + return lpadv; + +- linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, +- phydev->lp_advertising, +- lpadv & MDIO_AN_10GBT_STAT_LP10G); +- linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, +- phydev->lp_advertising, +- lpadv & MDIO_AN_10GBT_STAT_LP5G); +- linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, +- phydev->lp_advertising, +- lpadv & MDIO_AN_10GBT_STAT_LP2_5G); ++ mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, ++ lpadv); + } + + ret = genphy_read_status(phydev); diff --git a/target/linux/generic/backport-6.6/781-05-v6.10-net-phy-realtek-configure-SerDes-mode-for-rtl822xb-P.patch b/target/linux/generic/backport-6.6/781-05-v6.10-net-phy-realtek-configure-SerDes-mode-for-rtl822xb-P.patch new file mode 100644 index 0000000000..ba24ca3a16 --- /dev/null +++ b/target/linux/generic/backport-6.6/781-05-v6.10-net-phy-realtek-configure-SerDes-mode-for-rtl822xb-P.patch @@ -0,0 +1,209 @@ +From deb8af5243504e379878ae3f9a091b21422d65b2 Mon Sep 17 00:00:00 2001 +From: Alexander Couzens <lynxis@fe80.eu> +Date: Tue, 9 Apr 2024 09:30:11 +0200 +Subject: [PATCH] net: phy: realtek: configure SerDes mode for rtl822xb PHYs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The rtl8221b and rtl8226b series support switching SerDes mode between +2500base-x and sgmii based on the negotiated copper speed. + +Configure this switching mode according to SerDes modes supported by +host. + +There is an additional datasheet for RTL8226B/RTL8221B called +"SERDES MODE SETTING FLOW APPLICATION NOTE" where a sequence is +described to setup interface and rate adapter mode. + +However, there is no documentation about the meaning of registers +and bits, it's literally just magic numbers and pseudo-code. + +Signed-off-by: Alexander Couzens <lynxis@fe80.eu> +[ refactored, dropped HiSGMII mode and changed commit message ] +Signed-off-by: Marek Behún <kabel@kernel.org> +[ changed rtl822x_update_interface() to use vendor register ] +[ always fill in possible interfaces ] +[ only apply to rtl8221b and rtl8226b phy's ] +[ set phydev->rate_matching in .config_init() ] +Signed-off-by: Eric Woudstra <ericwouds@gmail.com> + +Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> +Reviewed-by: should come before them, without any blank lines. As the +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/phy/realtek.c | 114 ++++++++++++++++++++++++++++++++++++-- + 1 file changed, 110 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -54,6 +54,16 @@ + RTL8201F_ISR_LINK) + #define RTL8201F_IER 0x13 + ++#define RTL822X_VND1_SERDES_OPTION 0x697a ++#define RTL822X_VND1_SERDES_OPTION_MODE_MASK GENMASK(5, 0) ++#define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII 0 ++#define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX 2 ++ ++#define RTL822X_VND1_SERDES_CTRL3 0x7580 ++#define RTL822X_VND1_SERDES_CTRL3_MODE_MASK GENMASK(5, 0) ++#define RTL822X_VND1_SERDES_CTRL3_MODE_SGMII 0x02 ++#define RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX 0x16 ++ + #define RTL8366RB_POWER_SAVE 0x15 + #define RTL8366RB_POWER_SAVE_ON BIT(12) + +@@ -659,6 +669,63 @@ static int rtl822x_write_mmd(struct phy_ + return ret; + } + ++static int rtl822xb_config_init(struct phy_device *phydev) ++{ ++ bool has_2500, has_sgmii; ++ u16 mode; ++ int ret; ++ ++ has_2500 = test_bit(PHY_INTERFACE_MODE_2500BASEX, ++ phydev->host_interfaces) || ++ phydev->interface == PHY_INTERFACE_MODE_2500BASEX; ++ ++ has_sgmii = test_bit(PHY_INTERFACE_MODE_SGMII, ++ phydev->host_interfaces) || ++ phydev->interface == PHY_INTERFACE_MODE_SGMII; ++ ++ /* fill in possible interfaces */ ++ __assign_bit(PHY_INTERFACE_MODE_2500BASEX, phydev->possible_interfaces, ++ has_2500); ++ __assign_bit(PHY_INTERFACE_MODE_SGMII, phydev->possible_interfaces, ++ has_sgmii); ++ ++ if (!has_2500 && !has_sgmii) ++ return 0; ++ ++ /* determine SerDes option mode */ ++ if (has_2500 && !has_sgmii) { ++ mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX; ++ phydev->rate_matching = RATE_MATCH_PAUSE; ++ } else { ++ mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII; ++ phydev->rate_matching = RATE_MATCH_NONE; ++ } ++ ++ /* the following sequence with magic numbers sets up the SerDes ++ * option mode ++ */ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x75f3, 0); ++ if (ret < 0) ++ return ret; ++ ++ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND1, ++ RTL822X_VND1_SERDES_OPTION, ++ RTL822X_VND1_SERDES_OPTION_MODE_MASK, ++ mode); ++ if (ret < 0) ++ return ret; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6a04, 0x0503); ++ if (ret < 0) ++ return ret; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f10, 0xd455); ++ if (ret < 0) ++ return ret; ++ ++ return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020); ++} ++ + static int rtl822x_get_features(struct phy_device *phydev) + { + int val; +@@ -695,6 +762,28 @@ static int rtl822x_config_aneg(struct ph + return __genphy_config_aneg(phydev, ret); + } + ++static void rtl822xb_update_interface(struct phy_device *phydev) ++{ ++ int val; ++ ++ if (!phydev->link) ++ return; ++ ++ /* Change interface according to serdes mode */ ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_CTRL3); ++ if (val < 0) ++ return; ++ ++ switch (val & RTL822X_VND1_SERDES_CTRL3_MODE_MASK) { ++ case RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX: ++ phydev->interface = PHY_INTERFACE_MODE_2500BASEX; ++ break; ++ case RTL822X_VND1_SERDES_CTRL3_MODE_SGMII: ++ phydev->interface = PHY_INTERFACE_MODE_SGMII; ++ break; ++ } ++} ++ + static int rtl822x_read_status(struct phy_device *phydev) + { + int ret; +@@ -716,6 +805,19 @@ static int rtl822x_read_status(struct ph + return rtlgen_get_speed(phydev); + } + ++static int rtl822xb_read_status(struct phy_device *phydev) ++{ ++ int ret; ++ ++ ret = rtl822x_read_status(phydev); ++ if (ret < 0) ++ return ret; ++ ++ rtl822xb_update_interface(phydev); ++ ++ return 0; ++} ++ + static bool rtlgen_supports_2_5gbps(struct phy_device *phydev) + { + int val; +@@ -988,7 +1090,8 @@ static struct phy_driver realtek_drvs[] + .name = "RTL8226B_RTL8221B 2.5Gbps PHY", + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, ++ .config_init = rtl822xb_config_init, ++ .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, + .resume = rtlgen_resume, + .read_page = rtl821x_read_page, +@@ -1010,7 +1113,8 @@ static struct phy_driver realtek_drvs[] + .name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY", + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, ++ .config_init = rtl822xb_config_init, ++ .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, + .resume = rtlgen_resume, + .read_page = rtl821x_read_page, +@@ -1020,7 +1124,8 @@ static struct phy_driver realtek_drvs[] + .name = "RTL8221B-VB-CG 2.5Gbps PHY", + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, ++ .config_init = rtl822xb_config_init, ++ .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, + .resume = rtlgen_resume, + .read_page = rtl821x_read_page, +@@ -1030,7 +1135,8 @@ static struct phy_driver realtek_drvs[] + .name = "RTL8221B-VM-CG 2.5Gbps PHY", + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, ++ .config_init = rtl822xb_config_init, ++ .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, + .resume = rtlgen_resume, + .read_page = rtl821x_read_page, diff --git a/target/linux/generic/backport-6.6/781-06-v6.10-net-phy-realtek-add-get_rate_matching-for-rtl822xb-P.patch b/target/linux/generic/backport-6.6/781-06-v6.10-net-phy-realtek-add-get_rate_matching-for-rtl822xb-P.patch new file mode 100644 index 0000000000..609ae1a028 --- /dev/null +++ b/target/linux/generic/backport-6.6/781-06-v6.10-net-phy-realtek-add-get_rate_matching-for-rtl822xb-P.patch @@ -0,0 +1,77 @@ +From c189dbd738243be6775bb6878366bf63e27bfd05 Mon Sep 17 00:00:00 2001 +From: Eric Woudstra <ericwouds@gmail.com> +Date: Tue, 9 Apr 2024 09:30:12 +0200 +Subject: [PATCH] net: phy: realtek: add get_rate_matching() for rtl822xb PHYs + +Uses vendor register to determine if SerDes is setup in rate-matching mode. + +Rate-matching only supported when SerDes is set to 2500base-x. + +Signed-off-by: Eric Woudstra <ericwouds@gmail.com> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/phy/realtek.c | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -726,6 +726,27 @@ static int rtl822xb_config_init(struct p + return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020); + } + ++static int rtl822xb_get_rate_matching(struct phy_device *phydev, ++ phy_interface_t iface) ++{ ++ int val; ++ ++ /* Only rate matching at 2500base-x */ ++ if (iface != PHY_INTERFACE_MODE_2500BASEX) ++ return RATE_MATCH_NONE; ++ ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_OPTION); ++ if (val < 0) ++ return val; ++ ++ if ((val & RTL822X_VND1_SERDES_OPTION_MODE_MASK) == ++ RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX) ++ return RATE_MATCH_PAUSE; ++ ++ /* RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII */ ++ return RATE_MATCH_NONE; ++} ++ + static int rtl822x_get_features(struct phy_device *phydev) + { + int val; +@@ -1091,6 +1112,7 @@ static struct phy_driver realtek_drvs[] + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, + .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, + .resume = rtlgen_resume, +@@ -1114,6 +1136,7 @@ static struct phy_driver realtek_drvs[] + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, + .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, + .resume = rtlgen_resume, +@@ -1125,6 +1148,7 @@ static struct phy_driver realtek_drvs[] + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, + .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, + .resume = rtlgen_resume, +@@ -1136,6 +1160,7 @@ static struct phy_driver realtek_drvs[] + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, + .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, + .resume = rtlgen_resume, diff --git a/target/linux/generic/backport-6.6/781-07-v6.10-net-phy-realtek-Add-driver-instances-for-rtl8221b-vi.patch b/target/linux/generic/backport-6.6/781-07-v6.10-net-phy-realtek-Add-driver-instances-for-rtl8221b-vi.patch new file mode 100644 index 0000000000..5366c72f9c --- /dev/null +++ b/target/linux/generic/backport-6.6/781-07-v6.10-net-phy-realtek-Add-driver-instances-for-rtl8221b-vi.patch @@ -0,0 +1,218 @@ +From ad5ce743a6b0329f642d80be50ef7b534e908fba Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org> +Date: Tue, 9 Apr 2024 09:30:13 +0200 +Subject: [PATCH] net: phy: realtek: Add driver instances for rtl8221b via + Clause 45 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Collected from several commits in [PATCH net-next] +"Realtek RTL822x PHY rework to c45 and SerDes interface switching" + +The instances are used by Clause 45 only accessible PHY's on several sfp +modules, which are using RollBall protocol. + +Signed-off-by: Marek Behún <kabel@kernel.org> +[ Added matching functions to differentiate C45 instances ] +Signed-off-by: Eric Woudstra <ericwouds@gmail.com> + +Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/phy/realtek.c | 135 ++++++++++++++++++++++++++++++++++++-- + 1 file changed, 131 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -64,6 +64,13 @@ + #define RTL822X_VND1_SERDES_CTRL3_MODE_SGMII 0x02 + #define RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX 0x16 + ++/* RTL822X_VND2_XXXXX registers are only accessible when phydev->is_c45 ++ * is set, they cannot be accessed by C45-over-C22. ++ */ ++#define RTL822X_VND2_GBCR 0xa412 ++ ++#define RTL822X_VND2_GANLPAR 0xa414 ++ + #define RTL8366RB_POWER_SAVE 0x15 + #define RTL8366RB_POWER_SAVE_ON BIT(12) + +@@ -74,6 +81,9 @@ + + #define RTL_GENERIC_PHYID 0x001cc800 + #define RTL_8211FVD_PHYID 0x001cc878 ++#define RTL_8221B_VB_CG 0x001cc849 ++#define RTL_8221B_VN_CG 0x001cc84a ++#define RTL_8251B 0x001cc862 + + MODULE_DESCRIPTION("Realtek PHY driver"); + MODULE_AUTHOR("Johnson Leung"); +@@ -839,6 +849,67 @@ static int rtl822xb_read_status(struct p + return 0; + } + ++static int rtl822x_c45_config_aneg(struct phy_device *phydev) ++{ ++ bool changed = false; ++ int ret, val; ++ ++ if (phydev->autoneg == AUTONEG_DISABLE) ++ return genphy_c45_pma_setup_forced(phydev); ++ ++ ret = genphy_c45_an_config_aneg(phydev); ++ if (ret < 0) ++ return ret; ++ if (ret > 0) ++ changed = true; ++ ++ val = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); ++ ++ /* Vendor register as C45 has no standardized support for 1000BaseT */ ++ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, RTL822X_VND2_GBCR, ++ ADVERTISE_1000FULL, val); ++ if (ret < 0) ++ return ret; ++ if (ret > 0) ++ changed = true; ++ ++ return genphy_c45_check_and_restart_aneg(phydev, changed); ++} ++ ++static int rtl822x_c45_read_status(struct phy_device *phydev) ++{ ++ int ret, val; ++ ++ ret = genphy_c45_read_status(phydev); ++ if (ret < 0) ++ return ret; ++ ++ /* Vendor register as C45 has no standardized support for 1000BaseT */ ++ if (phydev->autoneg == AUTONEG_ENABLE) { ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND2, ++ RTL822X_VND2_GANLPAR); ++ if (val < 0) ++ return val; ++ ++ mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val); ++ } ++ ++ return 0; ++} ++ ++static int rtl822xb_c45_read_status(struct phy_device *phydev) ++{ ++ int ret; ++ ++ ret = rtl822x_c45_read_status(phydev); ++ if (ret < 0) ++ return ret; ++ ++ rtl822xb_update_interface(phydev); ++ ++ return 0; ++} ++ + static bool rtlgen_supports_2_5gbps(struct phy_device *phydev) + { + int val; +@@ -862,6 +933,35 @@ static int rtl8226_match_phy_device(stru + rtlgen_supports_2_5gbps(phydev); + } + ++static int rtlgen_is_c45_match(struct phy_device *phydev, unsigned int id, ++ bool is_c45) ++{ ++ if (phydev->is_c45) ++ return is_c45 && (id == phydev->c45_ids.device_ids[1]); ++ else ++ return !is_c45 && (id == phydev->phy_id); ++} ++ ++static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev) ++{ ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false); ++} ++ ++static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device *phydev) ++{ ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true); ++} ++ ++static int rtl8221b_vn_cg_c22_match_phy_device(struct phy_device *phydev) ++{ ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, false); ++} ++ ++static int rtl8221b_vn_cg_c45_match_phy_device(struct phy_device *phydev) ++{ ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, true); ++} ++ + static int rtlgen_resume(struct phy_device *phydev) + { + int ret = genphy_resume(phydev); +@@ -872,6 +972,15 @@ static int rtlgen_resume(struct phy_devi + return ret; + } + ++static int rtlgen_c45_resume(struct phy_device *phydev) ++{ ++ int ret = genphy_c45_pma_resume(phydev); ++ ++ msleep(20); ++ ++ return ret; ++} ++ + static int rtl9000a_config_init(struct phy_device *phydev) + { + phydev->autoneg = AUTONEG_DISABLE; +@@ -1143,8 +1252,8 @@ static struct phy_driver realtek_drvs[] + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + }, { +- PHY_ID_MATCH_EXACT(0x001cc849), +- .name = "RTL8221B-VB-CG 2.5Gbps PHY", ++ .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device, ++ .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)", + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, +@@ -1155,8 +1264,17 @@ static struct phy_driver realtek_drvs[] + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + }, { +- PHY_ID_MATCH_EXACT(0x001cc84a), +- .name = "RTL8221B-VM-CG 2.5Gbps PHY", ++ .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device, ++ .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", ++ .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .read_status = rtl822xb_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, ++ }, { ++ .match_phy_device = rtl8221b_vn_cg_c22_match_phy_device, ++ .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)", + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, +@@ -1167,6 +1285,15 @@ static struct phy_driver realtek_drvs[] + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + }, { ++ .match_phy_device = rtl8221b_vn_cg_c45_match_phy_device, ++ .name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)", ++ .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .read_status = rtl822xb_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, ++ }, { + PHY_ID_MATCH_EXACT(0x001cc862), + .name = "RTL8251B 5Gbps PHY", + .get_features = rtl822x_get_features, diff --git a/target/linux/generic/backport-6.6/781-08-v6.10-net-phy-realtek-Change-rtlgen_get_speed-to-rtlgen_de.patch b/target/linux/generic/backport-6.6/781-08-v6.10-net-phy-realtek-Change-rtlgen_get_speed-to-rtlgen_de.patch new file mode 100644 index 0000000000..5c7130d2e0 --- /dev/null +++ b/target/linux/generic/backport-6.6/781-08-v6.10-net-phy-realtek-Change-rtlgen_get_speed-to-rtlgen_de.patch @@ -0,0 +1,125 @@ +From 2e4ea707c7e04eb83e58c43e0e744bbdf6b23ff2 Mon Sep 17 00:00:00 2001 +From: Eric Woudstra <ericwouds@gmail.com> +Date: Tue, 9 Apr 2024 09:30:14 +0200 +Subject: [PATCH] net: phy: realtek: Change rtlgen_get_speed() to + rtlgen_decode_speed() + +The value of the register to determine the speed, is retrieved +differently when using Clause 45 only. To use the rtlgen_get_speed() +function in this case, pass the value of the register as argument to +rtlgen_get_speed(). The function would then always return 0, so change it +to void. A better name for this function now is rtlgen_decode_speed(). + +Replace a call to genphy_read_status() followed by rtlgen_get_speed() +with a call to rtlgen_read_status() in rtl822x_read_status(). + +Add reading speed to rtl822x_c45_read_status(). + +Signed-off-by: Eric Woudstra <ericwouds@gmail.com> + +Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/phy/realtek.c | 46 +++++++++++++++++++++------------------ + 1 file changed, 25 insertions(+), 21 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -71,6 +71,8 @@ + + #define RTL822X_VND2_GANLPAR 0xa414 + ++#define RTL822X_VND2_PHYSR 0xa434 ++ + #define RTL8366RB_POWER_SAVE 0x15 + #define RTL8366RB_POWER_SAVE_ON BIT(12) + +@@ -551,17 +553,8 @@ static int rtl8366rb_config_init(struct + } + + /* get actual speed to cover the downshift case */ +-static int rtlgen_get_speed(struct phy_device *phydev) ++static void rtlgen_decode_speed(struct phy_device *phydev, int val) + { +- int val; +- +- if (!phydev->link) +- return 0; +- +- val = phy_read_paged(phydev, 0xa43, 0x12); +- if (val < 0) +- return val; +- + switch (val & RTLGEN_SPEED_MASK) { + case 0x0000: + phydev->speed = SPEED_10; +@@ -584,19 +577,26 @@ static int rtlgen_get_speed(struct phy_d + default: + break; + } +- +- return 0; + } + + static int rtlgen_read_status(struct phy_device *phydev) + { +- int ret; ++ int ret, val; + + ret = genphy_read_status(phydev); + if (ret < 0) + return ret; + +- return rtlgen_get_speed(phydev); ++ if (!phydev->link) ++ return 0; ++ ++ val = phy_read_paged(phydev, 0xa43, 0x12); ++ if (val < 0) ++ return val; ++ ++ rtlgen_decode_speed(phydev, val); ++ ++ return 0; + } + + static int rtlgen_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) +@@ -817,8 +817,6 @@ static void rtl822xb_update_interface(st + + static int rtl822x_read_status(struct phy_device *phydev) + { +- int ret; +- + if (phydev->autoneg == AUTONEG_ENABLE) { + int lpadv = phy_read_paged(phydev, 0xa5d, 0x13); + +@@ -829,11 +827,7 @@ static int rtl822x_read_status(struct ph + lpadv); + } + +- ret = genphy_read_status(phydev); +- if (ret < 0) +- return ret; +- +- return rtlgen_get_speed(phydev); ++ return rtlgen_read_status(phydev); + } + + static int rtl822xb_read_status(struct phy_device *phydev) +@@ -894,6 +888,16 @@ static int rtl822x_c45_read_status(struc + mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val); + } + ++ if (!phydev->link) ++ return 0; ++ ++ /* Read actual speed from vendor register. */ ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_PHYSR); ++ if (val < 0) ++ return val; ++ ++ rtlgen_decode_speed(phydev, val); ++ + return 0; + } + diff --git a/target/linux/generic/backport-6.6/781-09-v6.10-net-phy-realtek-add-rtl822x_c45_get_features-to-set-.patch b/target/linux/generic/backport-6.6/781-09-v6.10-net-phy-realtek-add-rtl822x_c45_get_features-to-set-.patch new file mode 100644 index 0000000000..ed29dcd3e6 --- /dev/null +++ b/target/linux/generic/backport-6.6/781-09-v6.10-net-phy-realtek-add-rtl822x_c45_get_features-to-set-.patch @@ -0,0 +1,48 @@ +From 2d9ce64862705b33397d54dafecc5f51d8b1bb06 Mon Sep 17 00:00:00 2001 +From: Eric Woudstra <ericwouds@gmail.com> +Date: Tue, 9 Apr 2024 09:30:15 +0200 +Subject: [PATCH] net: phy: realtek: add rtl822x_c45_get_features() to set + supported port + +Sets ETHTOOL_LINK_MODE_TP_BIT in phydev->supported. + +Signed-off-by: Eric Woudstra <ericwouds@gmail.com> +Reviewed-by: Andrew Lunn <andrew@lunn.ch> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/phy/realtek.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -843,6 +843,14 @@ static int rtl822xb_read_status(struct p + return 0; + } + ++static int rtl822x_c45_get_features(struct phy_device *phydev) ++{ ++ linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, ++ phydev->supported); ++ ++ return genphy_c45_pma_read_abilities(phydev); ++} ++ + static int rtl822x_c45_config_aneg(struct phy_device *phydev) + { + bool changed = false; +@@ -1272,6 +1280,7 @@ static struct phy_driver realtek_drvs[] + .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", + .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, ++ .get_features = rtl822x_c45_get_features, + .config_aneg = rtl822x_c45_config_aneg, + .read_status = rtl822xb_c45_read_status, + .suspend = genphy_c45_pma_suspend, +@@ -1293,6 +1302,7 @@ static struct phy_driver realtek_drvs[] + .name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)", + .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, ++ .get_features = rtl822x_c45_get_features, + .config_aneg = rtl822x_c45_config_aneg, + .read_status = rtl822xb_c45_read_status, + .suspend = genphy_c45_pma_suspend, diff --git a/target/linux/generic/backport-6.6/781-10-v6.11-net-phy-realtek-add-support-for-rtl8224-2.5Gbps-PHY.patch b/target/linux/generic/backport-6.6/781-10-v6.11-net-phy-realtek-add-support-for-rtl8224-2.5Gbps-PHY.patch new file mode 100644 index 0000000000..13e1d883a3 --- /dev/null +++ b/target/linux/generic/backport-6.6/781-10-v6.11-net-phy-realtek-add-support-for-rtl8224-2.5Gbps-PHY.patch @@ -0,0 +1,33 @@ +From 9e42a2ea7f6703e2092c39171c2bf1fd7eec0bd3 Mon Sep 17 00:00:00 2001 +From: Chris Packham <chris.packham@alliedtelesis.co.nz> +Date: Tue, 11 Jun 2024 17:34:14 +1200 +Subject: [PATCH] net: phy: realtek: add support for rtl8224 2.5Gbps PHY + +The Realtek RTL8224 PHY is a 2.5Gbps capable PHY. It only uses the +clause 45 MDIO interface and can leverage the support that has already +been added for the other 822x PHYs. + +Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> +Link: https://lore.kernel.org/r/20240611053415.2111723-1-chris.packham@alliedtelesis.co.nz +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/phy/realtek.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -1318,6 +1318,14 @@ static struct phy_driver realtek_drvs[] + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + }, { ++ PHY_ID_MATCH_EXACT(0x001ccad0), ++ .name = "RTL8224 2.5Gbps PHY", ++ .get_features = rtl822x_c45_get_features, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .read_status = rtl822x_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, ++ }, { + PHY_ID_MATCH_EXACT(0x001cc961), + .name = "RTL8366RB Gigabit Ethernet", + .config_init = &rtl8366rb_config_init, diff --git a/target/linux/generic/backport-6.6/781-11-v6.11-net-phy-realtek-Add-support-for-PHY-LEDs-on-RTL8211F.patch b/target/linux/generic/backport-6.6/781-11-v6.11-net-phy-realtek-Add-support-for-PHY-LEDs-on-RTL8211F.patch new file mode 100644 index 0000000000..12c8ae66b5 --- /dev/null +++ b/target/linux/generic/backport-6.6/781-11-v6.11-net-phy-realtek-Add-support-for-PHY-LEDs-on-RTL8211F.patch @@ -0,0 +1,151 @@ +From 17784801d888238571a0c4101b9ac4401fffeaa0 Mon Sep 17 00:00:00 2001 +From: Marek Vasut <marex@denx.de> +Date: Tue, 25 Jun 2024 22:42:17 +0200 +Subject: [PATCH] net: phy: realtek: Add support for PHY LEDs on RTL8211F + +Realtek RTL8211F Ethernet PHY supports 3 LED pins which are used to +indicate link status and activity. Add minimal LED controller driver +supporting the most common uses with the 'netdev' trigger. + +Signed-off-by: Marek Vasut <marex@denx.de> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/phy/realtek.c | 106 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 106 insertions(+) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -32,6 +32,15 @@ + #define RTL8211F_PHYCR2 0x19 + #define RTL8211F_INSR 0x1d + ++#define RTL8211F_LEDCR 0x10 ++#define RTL8211F_LEDCR_MODE BIT(15) ++#define RTL8211F_LEDCR_ACT_TXRX BIT(4) ++#define RTL8211F_LEDCR_LINK_1000 BIT(3) ++#define RTL8211F_LEDCR_LINK_100 BIT(1) ++#define RTL8211F_LEDCR_LINK_10 BIT(0) ++#define RTL8211F_LEDCR_MASK GENMASK(4, 0) ++#define RTL8211F_LEDCR_SHIFT 5 ++ + #define RTL8211F_TX_DELAY BIT(8) + #define RTL8211F_RX_DELAY BIT(3) + +@@ -87,6 +96,8 @@ + #define RTL_8221B_VN_CG 0x001cc84a + #define RTL_8251B 0x001cc862 + ++#define RTL8211F_LED_COUNT 3 ++ + MODULE_DESCRIPTION("Realtek PHY driver"); + MODULE_AUTHOR("Johnson Leung"); + MODULE_LICENSE("GPL"); +@@ -476,6 +487,98 @@ static int rtl821x_resume(struct phy_dev + return 0; + } + ++static int rtl8211f_led_hw_is_supported(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ const unsigned long mask = BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000) | ++ BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX); ++ ++ /* The RTL8211F PHY supports these LED settings on up to three LEDs: ++ * - Link: Configurable subset of 10/100/1000 link rates ++ * - Active: Blink on activity, RX or TX is not differentiated ++ * The Active option has two modes, A and B: ++ * - A: Link and Active indication at configurable, but matching, ++ * subset of 10/100/1000 link rates ++ * - B: Link indication at configurable subset of 10/100/1000 link ++ * rates and Active indication always at all three 10+100+1000 ++ * link rates. ++ * This code currently uses mode B only. ++ */ ++ ++ if (index >= RTL8211F_LED_COUNT) ++ return -EINVAL; ++ ++ /* Filter out any other unsupported triggers. */ ++ if (rules & ~mask) ++ return -EOPNOTSUPP; ++ ++ /* RX and TX are not differentiated, either both are set or not set. */ ++ if (!(rules & BIT(TRIGGER_NETDEV_RX)) ^ !(rules & BIT(TRIGGER_NETDEV_TX))) ++ return -EOPNOTSUPP; ++ ++ return 0; ++} ++ ++static int rtl8211f_led_hw_control_get(struct phy_device *phydev, u8 index, ++ unsigned long *rules) ++{ ++ int val; ++ ++ val = phy_read_paged(phydev, 0xd04, RTL8211F_LEDCR); ++ if (val < 0) ++ return val; ++ ++ val >>= RTL8211F_LEDCR_SHIFT * index; ++ val &= RTL8211F_LEDCR_MASK; ++ ++ if (val & RTL8211F_LEDCR_LINK_10) ++ set_bit(TRIGGER_NETDEV_LINK_10, rules); ++ ++ if (val & RTL8211F_LEDCR_LINK_100) ++ set_bit(TRIGGER_NETDEV_LINK_100, rules); ++ ++ if (val & RTL8211F_LEDCR_LINK_1000) ++ set_bit(TRIGGER_NETDEV_LINK_1000, rules); ++ ++ if (val & RTL8211F_LEDCR_ACT_TXRX) { ++ set_bit(TRIGGER_NETDEV_RX, rules); ++ set_bit(TRIGGER_NETDEV_TX, rules); ++ } ++ ++ return 0; ++} ++ ++static int rtl8211f_led_hw_control_set(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ const u16 mask = RTL8211F_LEDCR_MASK << (RTL8211F_LEDCR_SHIFT * index); ++ u16 reg = RTL8211F_LEDCR_MODE; /* Mode B */ ++ ++ if (index >= RTL8211F_LED_COUNT) ++ return -EINVAL; ++ ++ if (test_bit(TRIGGER_NETDEV_LINK_10, &rules)) ++ reg |= RTL8211F_LEDCR_LINK_10; ++ ++ if (test_bit(TRIGGER_NETDEV_LINK_100, &rules)) ++ reg |= RTL8211F_LEDCR_LINK_100; ++ ++ if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) ++ reg |= RTL8211F_LEDCR_LINK_1000; ++ ++ if (test_bit(TRIGGER_NETDEV_RX, &rules) || ++ test_bit(TRIGGER_NETDEV_TX, &rules)) { ++ reg |= RTL8211F_LEDCR_ACT_TXRX; ++ } ++ ++ reg <<= RTL8211F_LEDCR_SHIFT * index; ++ ++ return phy_modify_paged(phydev, 0xd04, RTL8211F_LEDCR, mask, reg); ++} ++ + static int rtl8211e_config_init(struct phy_device *phydev) + { + int ret = 0, oldpage; +@@ -1192,6 +1295,9 @@ static struct phy_driver realtek_drvs[] + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + .flags = PHY_ALWAYS_CALL_SUSPEND, ++ .led_hw_is_supported = rtl8211f_led_hw_is_supported, ++ .led_hw_control_get = rtl8211f_led_hw_control_get, ++ .led_hw_control_set = rtl8211f_led_hw_control_set, + }, { + PHY_ID_MATCH_EXACT(RTL_8211FVD_PHYID), + .name = "RTL8211F-VD Gigabit Ethernet", diff --git a/target/linux/generic/backport-6.6/781-12-v6.11-net-phy-realtek-Fix-setting-of-PHY-LEDs-Mode-B-bit-o.patch b/target/linux/generic/backport-6.6/781-12-v6.11-net-phy-realtek-Fix-setting-of-PHY-LEDs-Mode-B-bit-o.patch new file mode 100644 index 0000000000..5958fc929c --- /dev/null +++ b/target/linux/generic/backport-6.6/781-12-v6.11-net-phy-realtek-Fix-setting-of-PHY-LEDs-Mode-B-bit-o.patch @@ -0,0 +1,42 @@ +From a2f5c505b4378cd6fc7c4a44ff3665ccef2037db Mon Sep 17 00:00:00 2001 +From: Sava Jakovljev <savaj@meyersound.com> +Date: Wed, 21 Aug 2024 04:16:57 +0200 +Subject: [PATCH] net: phy: realtek: Fix setting of PHY LEDs Mode B bit on + RTL8211F + +The current implementation incorrectly sets the mode bit of the PHY chip. +Bit 15 (RTL8211F_LEDCR_MODE) should not be shifted together with the +configuration nibble of a LED- it should be set independently of the +index of the LED being configured. +As a consequence, the RTL8211F LED control is actually operating in Mode A. +Fix the error by or-ing final register value to write with a const-value of +RTL8211F_LEDCR_MODE, thus setting Mode bit explicitly. + +Fixes: 17784801d888 ("net: phy: realtek: Add support for PHY LEDs on RTL8211F") +Signed-off-by: Sava Jakovljev <savaj@meyersound.com> +Reviewed-by: Marek Vasut <marex@denx.de> +Link: https://patch.msgid.link/PAWP192MB21287372F30C4E55B6DF6158C38E2@PAWP192MB2128.EURP192.PROD.OUTLOOK.COM +Signed-off-by: Paolo Abeni <pabeni@redhat.com> +--- + drivers/net/phy/realtek.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -555,7 +555,7 @@ static int rtl8211f_led_hw_control_set(s + unsigned long rules) + { + const u16 mask = RTL8211F_LEDCR_MASK << (RTL8211F_LEDCR_SHIFT * index); +- u16 reg = RTL8211F_LEDCR_MODE; /* Mode B */ ++ u16 reg = 0; + + if (index >= RTL8211F_LED_COUNT) + return -EINVAL; +@@ -575,6 +575,7 @@ static int rtl8211f_led_hw_control_set(s + } + + reg <<= RTL8211F_LEDCR_SHIFT * index; ++ reg |= RTL8211F_LEDCR_MODE; /* Mode B */ + + return phy_modify_paged(phydev, 0xd04, RTL8211F_LEDCR, mask, reg); + } diff --git a/target/linux/generic/backport-6.6/816-v6.7-0004-Revert-nvmem-add-new-config-option.patch b/target/linux/generic/backport-6.6/816-v6.7-0004-Revert-nvmem-add-new-config-option.patch index 39be82d4bf..36d15248b8 100644 --- a/target/linux/generic/backport-6.6/816-v6.7-0004-Revert-nvmem-add-new-config-option.patch +++ b/target/linux/generic/backport-6.6/816-v6.7-0004-Revert-nvmem-add-new-config-option.patch @@ -48,7 +48,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> mtd->nvmem = nvmem_register(&config); --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c -@@ -941,7 +941,7 @@ struct nvmem_device *nvmem_register(cons +@@ -940,7 +940,7 @@ struct nvmem_device *nvmem_register(cons nvmem->nkeepout = config->nkeepout; if (config->of_node) nvmem->dev.of_node = config->of_node; diff --git a/target/linux/generic/backport-6.6/819-v6.8-0001-nvmem-Move-of_nvmem_layout_get_container-in-another-.patch b/target/linux/generic/backport-6.6/819-v6.8-0001-nvmem-Move-of_nvmem_layout_get_container-in-another-.patch index 59175c8051..7ca426e87a 100644 --- a/target/linux/generic/backport-6.6/819-v6.8-0001-nvmem-Move-of_nvmem_layout_get_container-in-another-.patch +++ b/target/linux/generic/backport-6.6/819-v6.8-0001-nvmem-Move-of_nvmem_layout_get_container-in-another-.patch @@ -25,7 +25,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c -@@ -847,14 +847,6 @@ static int nvmem_add_cells_from_layout(s +@@ -846,14 +846,6 @@ static int nvmem_add_cells_from_layout(s } #if IS_ENABLED(CONFIG_OF) diff --git a/target/linux/generic/backport-6.6/819-v6.8-0003-nvmem-Simplify-the-add_cells-hook.patch b/target/linux/generic/backport-6.6/819-v6.8-0003-nvmem-Simplify-the-add_cells-hook.patch index 1f39dfea2f..dac691e117 100644 --- a/target/linux/generic/backport-6.6/819-v6.8-0003-nvmem-Simplify-the-add_cells-hook.patch +++ b/target/linux/generic/backport-6.6/819-v6.8-0003-nvmem-Simplify-the-add_cells-hook.patch @@ -20,7 +20,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c -@@ -816,7 +816,7 @@ static int nvmem_add_cells_from_layout(s +@@ -815,7 +815,7 @@ static int nvmem_add_cells_from_layout(s int ret; if (layout && layout->add_cells) { diff --git a/target/linux/generic/backport-6.6/819-v6.8-0004-nvmem-Move-and-rename-fixup_cell_info.patch b/target/linux/generic/backport-6.6/819-v6.8-0004-nvmem-Move-and-rename-fixup_cell_info.patch index d2c274033e..0a614fc13d 100644 --- a/target/linux/generic/backport-6.6/819-v6.8-0004-nvmem-Move-and-rename-fixup_cell_info.patch +++ b/target/linux/generic/backport-6.6/819-v6.8-0004-nvmem-Move-and-rename-fixup_cell_info.patch @@ -25,7 +25,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c -@@ -675,7 +675,6 @@ static int nvmem_validate_keepouts(struc +@@ -674,7 +674,6 @@ static int nvmem_validate_keepouts(struc static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np) { @@ -33,7 +33,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> struct device *dev = &nvmem->dev; struct device_node *child; const __be32 *addr; -@@ -705,8 +704,8 @@ static int nvmem_add_cells_from_dt(struc +@@ -704,8 +703,8 @@ static int nvmem_add_cells_from_dt(struc info.np = of_node_get(child); @@ -44,7 +44,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> ret = nvmem_add_one_cell(nvmem, &info); kfree(info.name); -@@ -895,6 +894,7 @@ struct nvmem_device *nvmem_register(cons +@@ -894,6 +893,7 @@ struct nvmem_device *nvmem_register(cons kref_init(&nvmem->refcnt); INIT_LIST_HEAD(&nvmem->cells); diff --git a/target/linux/generic/backport-6.6/819-v6.8-0005-nvmem-core-Rework-layouts-to-become-regular-devices.patch b/target/linux/generic/backport-6.6/819-v6.8-0005-nvmem-core-Rework-layouts-to-become-regular-devices.patch index ce33b52328..1a41050d08 100644 --- a/target/linux/generic/backport-6.6/819-v6.8-0005-nvmem-core-Rework-layouts-to-become-regular-devices.patch +++ b/target/linux/generic/backport-6.6/819-v6.8-0005-nvmem-core-Rework-layouts-to-become-regular-devices.patch @@ -84,7 +84,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> static int __nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offset, void *val, size_t bytes) { -@@ -740,97 +737,22 @@ static int nvmem_add_cells_from_fixed_la +@@ -739,97 +736,22 @@ static int nvmem_add_cells_from_fixed_la return err; } @@ -189,7 +189,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem, struct nvmem_layout *layout) { -@@ -838,7 +760,7 @@ const void *nvmem_layout_get_match_data( +@@ -837,7 +759,7 @@ const void *nvmem_layout_get_match_data( const struct of_device_id *match; layout_np = of_nvmem_layout_get_container(nvmem); @@ -198,7 +198,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> return match ? match->data : NULL; } -@@ -950,19 +872,6 @@ struct nvmem_device *nvmem_register(cons +@@ -949,19 +871,6 @@ struct nvmem_device *nvmem_register(cons goto err_put_device; } @@ -218,7 +218,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> if (config->cells) { rval = nvmem_add_cells(nvmem, config->cells, config->ncells); if (rval) -@@ -983,24 +892,24 @@ struct nvmem_device *nvmem_register(cons +@@ -982,24 +891,24 @@ struct nvmem_device *nvmem_register(cons if (rval) goto err_remove_cells; @@ -249,7 +249,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> if (config->compat) nvmem_sysfs_remove_compat(nvmem, config); err_put_device: -@@ -1022,7 +931,7 @@ static void nvmem_device_release(struct +@@ -1021,7 +930,7 @@ static void nvmem_device_release(struct device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); nvmem_device_remove_all_cells(nvmem); @@ -258,7 +258,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> device_unregister(&nvmem->dev); } -@@ -1324,6 +1233,12 @@ nvmem_cell_get_from_lookup(struct device +@@ -1323,6 +1232,12 @@ nvmem_cell_get_from_lookup(struct device return cell; } @@ -271,7 +271,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> #if IS_ENABLED(CONFIG_OF) static struct nvmem_cell_entry * nvmem_find_cell_entry_by_node(struct nvmem_device *nvmem, struct device_node *np) -@@ -1342,6 +1257,18 @@ nvmem_find_cell_entry_by_node(struct nvm +@@ -1341,6 +1256,18 @@ nvmem_find_cell_entry_by_node(struct nvm return cell; } @@ -290,7 +290,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> /** * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id * -@@ -1404,16 +1331,29 @@ struct nvmem_cell *of_nvmem_cell_get(str +@@ -1403,16 +1330,29 @@ struct nvmem_cell *of_nvmem_cell_get(str return ERR_CAST(nvmem); } @@ -322,7 +322,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> return cell; } -@@ -1527,6 +1467,7 @@ void nvmem_cell_put(struct nvmem_cell *c +@@ -1526,6 +1466,7 @@ void nvmem_cell_put(struct nvmem_cell *c kfree(cell); __nvmem_device_put(nvmem); @@ -330,7 +330,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> } EXPORT_SYMBOL_GPL(nvmem_cell_put); -@@ -2104,11 +2045,22 @@ EXPORT_SYMBOL_GPL(nvmem_dev_name); +@@ -2103,11 +2044,22 @@ EXPORT_SYMBOL_GPL(nvmem_dev_name); static int __init nvmem_init(void) { diff --git a/target/linux/generic/backport-6.6/819-v6.8-0006-nvmem-core-Expose-cells-through-sysfs.patch b/target/linux/generic/backport-6.6/819-v6.8-0006-nvmem-core-Expose-cells-through-sysfs.patch index 4a1f9aefc8..8442636b09 100644 --- a/target/linux/generic/backport-6.6/819-v6.8-0006-nvmem-core-Expose-cells-through-sysfs.patch +++ b/target/linux/generic/backport-6.6/819-v6.8-0006-nvmem-core-Expose-cells-through-sysfs.patch @@ -111,7 +111,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> static struct bin_attribute bin_attr_nvmem_eeprom_compat = { .attr = { .name = "eeprom", -@@ -380,6 +427,68 @@ static void nvmem_sysfs_remove_compat(st +@@ -379,6 +426,68 @@ static void nvmem_sysfs_remove_compat(st device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); } @@ -180,7 +180,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> #else /* CONFIG_NVMEM_SYSFS */ static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem, -@@ -739,11 +848,25 @@ static int nvmem_add_cells_from_fixed_la +@@ -738,11 +847,25 @@ static int nvmem_add_cells_from_fixed_la int nvmem_layout_register(struct nvmem_layout *layout) { @@ -207,7 +207,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> } EXPORT_SYMBOL_GPL(nvmem_layout_register); -@@ -902,10 +1025,20 @@ struct nvmem_device *nvmem_register(cons +@@ -901,10 +1024,20 @@ struct nvmem_device *nvmem_register(cons if (rval) goto err_remove_dev; diff --git a/target/linux/generic/backport-6.6/819-v6.8-0008-nvmem-layouts-refactor-.add_cells-callback-arguments.patch b/target/linux/generic/backport-6.6/819-v6.8-0008-nvmem-layouts-refactor-.add_cells-callback-arguments.patch index 400004c617..a95770a059 100644 --- a/target/linux/generic/backport-6.6/819-v6.8-0008-nvmem-layouts-refactor-.add_cells-callback-arguments.patch +++ b/target/linux/generic/backport-6.6/819-v6.8-0008-nvmem-layouts-refactor-.add_cells-callback-arguments.patch @@ -44,7 +44,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c -@@ -854,7 +854,7 @@ int nvmem_layout_register(struct nvmem_l +@@ -853,7 +853,7 @@ int nvmem_layout_register(struct nvmem_l return -EINVAL; /* Populate the cells */ diff --git a/target/linux/generic/backport-6.6/819-v6.8-0009-nvmem-drop-nvmem_layout_get_match_data.patch b/target/linux/generic/backport-6.6/819-v6.8-0009-nvmem-drop-nvmem_layout_get_match_data.patch index 510f3dd841..291854bcb5 100644 --- a/target/linux/generic/backport-6.6/819-v6.8-0009-nvmem-drop-nvmem_layout_get_match_data.patch +++ b/target/linux/generic/backport-6.6/819-v6.8-0009-nvmem-drop-nvmem_layout_get_match_data.patch @@ -24,7 +24,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c -@@ -876,19 +876,6 @@ void nvmem_layout_unregister(struct nvme +@@ -875,19 +875,6 @@ void nvmem_layout_unregister(struct nvme } EXPORT_SYMBOL_GPL(nvmem_layout_unregister); diff --git a/target/linux/generic/backport-6.6/819-v6.8-0010-nvmem-core-add-nvmem_dev_size-helper.patch b/target/linux/generic/backport-6.6/819-v6.8-0010-nvmem-core-add-nvmem_dev_size-helper.patch index ccdcc09736..93fd1ce6ad 100644 --- a/target/linux/generic/backport-6.6/819-v6.8-0010-nvmem-core-add-nvmem_dev_size-helper.patch +++ b/target/linux/generic/backport-6.6/819-v6.8-0010-nvmem-core-add-nvmem_dev_size-helper.patch @@ -21,7 +21,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c -@@ -2163,6 +2163,19 @@ const char *nvmem_dev_name(struct nvmem_ +@@ -2162,6 +2162,19 @@ const char *nvmem_dev_name(struct nvmem_ } EXPORT_SYMBOL_GPL(nvmem_dev_name); diff --git a/target/linux/generic/backport-6.6/834-v6.8-leds-trigger-netdev-Extend-speeds-up-to-10G.patch b/target/linux/generic/backport-6.6/834-v6.8-leds-trigger-netdev-Extend-speeds-up-to-10G.patch index 2ae209f9e1..4571d7d2bf 100644 --- a/target/linux/generic/backport-6.6/834-v6.8-leds-trigger-netdev-Extend-speeds-up-to-10G.patch +++ b/target/linux/generic/backport-6.6/834-v6.8-leds-trigger-netdev-Extend-speeds-up-to-10G.patch @@ -99,7 +99,7 @@ Signed-off-by: Lee Jones <lee@kernel.org> interval = jiffies_to_msecs( --- a/include/linux/leds.h +++ b/include/linux/leds.h -@@ -588,6 +588,9 @@ enum led_trigger_netdev_modes { +@@ -586,6 +586,9 @@ enum led_trigger_netdev_modes { TRIGGER_NETDEV_LINK_10, TRIGGER_NETDEV_LINK_100, TRIGGER_NETDEV_LINK_1000, diff --git a/target/linux/generic/backport-6.6/836-v6.9-net-phy-aquantia-clear-PMD-Global-Transmit-Disable-b.patch b/target/linux/generic/backport-6.6/836-v6.9-net-phy-aquantia-clear-PMD-Global-Transmit-Disable-b.patch new file mode 100644 index 0000000000..8b54881ab0 --- /dev/null +++ b/target/linux/generic/backport-6.6/836-v6.9-net-phy-aquantia-clear-PMD-Global-Transmit-Disable-b.patch @@ -0,0 +1,103 @@ +From cffac22c9215f1883d3848c788f9b03656dced27 Mon Sep 17 00:00:00 2001 +From: Robert Marko <robimarko@gmail.com> +Date: Sun, 11 Feb 2024 18:39:19 +0100 +Subject: [PATCH] net: phy: aquantia: clear PMD Global Transmit Disable bit + during init + +PMD Global Transmit Disable bit should be cleared for normal operation. +This should be HW default, however I found that on Asus RT-AX89X that uses +AQR113C PHY and firmware 5.4 this bit is set by default. + +With this bit set the AQR cannot achieve a link with its link-partner and +it took me multiple hours of digging through the vendor GPL source to find +this out, so lets always clear this bit during .config_init() to avoid a +situation like this in the future. + +aqr107_wait_processor_intensive_op() is moved up because datasheet notes +that any changes to this bit are processor intensive. + +Signed-off-by: Robert Marko <robimarko@gmail.com> +--- + drivers/net/phy/aquantia/aquantia_main.c | 57 ++++++++++++++---------- + 1 file changed, 33 insertions(+), 24 deletions(-) + +--- a/drivers/net/phy/aquantia/aquantia_main.c ++++ b/drivers/net/phy/aquantia/aquantia_main.c +@@ -473,6 +473,30 @@ static void aqr107_chip_info(struct phy_ + fw_major, fw_minor, build_id, prov_id); + } + ++static int aqr107_wait_processor_intensive_op(struct phy_device *phydev) ++{ ++ int val, err; ++ ++ /* The datasheet notes to wait at least 1ms after issuing a ++ * processor intensive operation before checking. ++ * We cannot use the 'sleep_before_read' parameter of read_poll_timeout ++ * because that just determines the maximum time slept, not the minimum. ++ */ ++ usleep_range(1000, 5000); ++ ++ err = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, ++ VEND1_GLOBAL_GEN_STAT2, val, ++ !(val & VEND1_GLOBAL_GEN_STAT2_OP_IN_PROG), ++ AQR107_OP_IN_PROG_SLEEP, ++ AQR107_OP_IN_PROG_TIMEOUT, false); ++ if (err) { ++ phydev_err(phydev, "timeout: processor-intensive MDIO operation\n"); ++ return err; ++ } ++ ++ return 0; ++} ++ + static int aqr107_config_init(struct phy_device *phydev) + { + struct aqr107_priv *priv = phydev->priv; +@@ -498,6 +522,15 @@ static int aqr107_config_init(struct phy + if (!ret) + aqr107_chip_info(phydev); + ++ ret = phy_clear_bits_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_TXDIS, ++ MDIO_PMD_TXDIS_GLOBAL); ++ if (ret) ++ return ret; ++ ++ ret = aqr107_wait_processor_intensive_op(phydev); ++ if (ret) ++ return ret; ++ + ret = aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT); + if (ret) + return ret; +@@ -580,30 +613,6 @@ static void aqr107_link_change_notify(st + phydev_info(phydev, "Aquantia 1000Base-T2 mode active\n"); + } + +-static int aqr107_wait_processor_intensive_op(struct phy_device *phydev) +-{ +- int val, err; +- +- /* The datasheet notes to wait at least 1ms after issuing a +- * processor intensive operation before checking. +- * We cannot use the 'sleep_before_read' parameter of read_poll_timeout +- * because that just determines the maximum time slept, not the minimum. +- */ +- usleep_range(1000, 5000); +- +- err = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, +- VEND1_GLOBAL_GEN_STAT2, val, +- !(val & VEND1_GLOBAL_GEN_STAT2_OP_IN_PROG), +- AQR107_OP_IN_PROG_SLEEP, +- AQR107_OP_IN_PROG_TIMEOUT, false); +- if (err) { +- phydev_err(phydev, "timeout: processor-intensive MDIO operation\n"); +- return err; +- } +- +- return 0; +-} +- + static int aqr107_get_rate_matching(struct phy_device *phydev, + phy_interface_t iface) + { diff --git a/target/linux/generic/backport-6.6/896-01-v6.9-net-dsa-mv88e6xxx-rename-mv88e6xxx_g2_scratch_gpio_s.patch b/target/linux/generic/backport-6.6/896-01-v6.9-net-dsa-mv88e6xxx-rename-mv88e6xxx_g2_scratch_gpio_s.patch index d9265cad10..48dd6ffb67 100644 --- a/target/linux/generic/backport-6.6/896-01-v6.9-net-dsa-mv88e6xxx-rename-mv88e6xxx_g2_scratch_gpio_s.patch +++ b/target/linux/generic/backport-6.6/896-01-v6.9-net-dsa-mv88e6xxx-rename-mv88e6xxx_g2_scratch_gpio_s.patch @@ -19,7 +19,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com> --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c -@@ -3668,7 +3668,7 @@ static int mv88e6xxx_mdio_register(struc +@@ -3669,7 +3669,7 @@ static int mv88e6xxx_mdio_register(struc if (external) { mv88e6xxx_reg_lock(chip); diff --git a/target/linux/generic/backport-6.6/896-02-v6.9-net-dsa-mv88e6xxx-add-Amethyst-specific-SMI-GPIO-fun.patch b/target/linux/generic/backport-6.6/896-02-v6.9-net-dsa-mv88e6xxx-add-Amethyst-specific-SMI-GPIO-fun.patch index 5661d50adb..e5931573f7 100644 --- a/target/linux/generic/backport-6.6/896-02-v6.9-net-dsa-mv88e6xxx-add-Amethyst-specific-SMI-GPIO-fun.patch +++ b/target/linux/generic/backport-6.6/896-02-v6.9-net-dsa-mv88e6xxx-add-Amethyst-specific-SMI-GPIO-fun.patch @@ -27,7 +27,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com> --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c -@@ -3668,7 +3668,10 @@ static int mv88e6xxx_mdio_register(struc +@@ -3669,7 +3669,10 @@ static int mv88e6xxx_mdio_register(struc if (external) { mv88e6xxx_reg_lock(chip); |