From a34cd4f66a12c6ff9cfbeda7a622f6a66f37112d Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 10 Sep 2022 03:22:17 +0100 Subject: [PATCH 001/114] mediatek: bananapi-r3: remove kmod-btmtkuart from default packages The package kmod-btmtkuart is specific for MT7622 and isn't available for MT7986 (which doesn't have this built-in Bluetooth like MT7622). Signed-off-by: Daniel Golle --- target/linux/mediatek/image/filogic.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index e366661240..cd74da7450 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -45,7 +45,7 @@ define Device/bananapi_bpi-r3 DEVICE_DTS_CONFIG := config-mt7986a-bananapi-bpi-r3 DEVICE_DTS_OVERLAY:= mt7986a-bananapi-bpi-r3-nor mt7986a-bananapi-bpi-r3-emmc-nor mt7986a-bananapi-bpi-r3-emmc-snand mt7986a-bananapi-bpi-r3-snand DEVICE_DTS_DIR := ../dts - DEVICE_PACKAGES := kmod-btmtkuart kmod-usb3 kmod-i2c-gpio kmod-sfp e2fsprogs f2fsck mkf2fs + DEVICE_PACKAGES := kmod-usb3 kmod-i2c-gpio kmod-sfp e2fsprogs f2fsck mkf2fs IMAGES := sysupgrade.itb KERNEL_INITRAMFS_SUFFIX := -recovery.itb ARTIFACTS := \ From f522c27385d6f94e5dbcc3e84968f0e38609ff1c Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Fri, 9 Sep 2022 21:09:30 +0200 Subject: [PATCH 002/114] CI: kernel: Cache external toolchain Cache external toolchain for each target to remove load from openwrt cdn server and make the external toolchain setup quicker. Signed-off-by: Christian Marangi --- .github/workflows/kernel.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/kernel.yml b/.github/workflows/kernel.yml index 05bc6ed8ee..43f843b256 100644 --- a/.github/workflows/kernel.yml +++ b/.github/workflows/kernel.yml @@ -102,12 +102,23 @@ jobs: - name: Parse toolchain file working-directory: openwrt run: | - TOOLCHAIN_FILE=$(curl "https://downloads.cdn.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums" \ - | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p') + TOOLCHAIN_STRING="$(curl "https://downloads.cdn.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums" \ + | grep ".*openwrt-toolchain.*tar.xz")" + TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p') + TOOLCHAIN_SHA256=$(echo "$TOOLCHAIN_STRING" | cut -d ' ' -f 1) echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV" + echo "TOOLCHAIN_SHA256=$TOOLCHAIN_SHA256" >> "$GITHUB_ENV" + + - name: Cache external toolchain + id: cache-external-toolchain + uses: actions/cache@v3 + with: + path: openwrt/${{ env.TOOLCHAIN_FILE }} + key: ${{ env.TOOLCHAIN_FILE }}-${{ env.TOOLCHAIN_SHA256 }} - name: Download external toolchain + if: ${{ steps.cache-external-toolchain.outputs.cache-hit != 'true' }} shell: su buildbot -c "sh -e {0}" working-directory: openwrt run: | From 90c6e3aedf167b0ae1baf376e7800a631681e69a Mon Sep 17 00:00:00 2001 From: Josh Roys Date: Sat, 23 Jul 2022 11:23:16 -0400 Subject: [PATCH 003/114] scripts: always check certificates Remove flags from wget and curl instructing them to ignore bad server certificates. Although other mechanisms can protect against malicious modifications of downloads, other vectors of attack may be available to an adversary. TLS certificate verification can be disabled by turning oof the "Enable TLS certificate verification during package download" option enabled by default in the "Global build settings" in "make menuconfig" Signed-off-by: Josh Roys [ add additional info on how to disable this option ] Signed-off-by: Christian Marangi --- config/Config-build.in | 4 ++++ rules.mk | 3 +++ scripts/download.pl | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config/Config-build.in b/config/Config-build.in index 400bf15665..2eded2b288 100644 --- a/config/Config-build.in +++ b/config/Config-build.in @@ -58,6 +58,10 @@ menu "Global build settings" bool "Enable signature checking in opkg" default SIGNED_PACKAGES + config DOWNLOAD_CHECK_CERTIFICATE + bool "Enable TLS certificate verification during package download" + default y + comment "General build options" config TESTING_KERNEL diff --git a/rules.mk b/rules.mk index 5a56fd6f4a..c893f61b0f 100644 --- a/rules.mk +++ b/rules.mk @@ -257,6 +257,9 @@ ESED:=$(STAGING_DIR_HOST)/bin/sed -E -i -e MKHASH:=$(STAGING_DIR_HOST)/bin/mkhash # MKHASH is used in /scripts, so we export it here. export MKHASH +# DOWNLOAD_CHECK_CERTIFICATE is used in /scripts, so we export it here. +DOWNLOAD_CHECK_CERTIFICATE:=$(CONFIG_DOWNLOAD_CHECK_CERTIFICATE) +export DOWNLOAD_CHECK_CERTIFICATE CP:=cp -fpR LN:=ln -sf XARGS:=xargs -r diff --git a/scripts/download.pl b/scripts/download.pl index af13c0ae00..ab1801aad5 100755 --- a/scripts/download.pl +++ b/scripts/download.pl @@ -24,6 +24,8 @@ my $scriptdir = dirname($0); my @mirrors; my $ok; +my $check_certificate = $ENV{DOWNLOAD_CHECK_CERTIFICATE} eq "y"; + $url_filename or $url_filename = $filename; sub localmirrors { @@ -80,8 +82,8 @@ sub download_cmd($) { } return $have_curl - ? (qw(curl -f --connect-timeout 20 --retry 5 --location --insecure), shellwords($ENV{CURL_OPTIONS} || ''), $url) - : (qw(wget --tries=5 --timeout=20 --no-check-certificate --output-document=-), shellwords($ENV{WGET_OPTIONS} || ''), $url) + ? (qw(curl -f --connect-timeout 20 --retry 5 --location), $check_certificate ? '' : '--insecure', shellwords($ENV{CURL_OPTIONS} || ''), $url) + : (qw(wget --tries=5 --timeout=20 --output-document=-), $check_certificate ? '' : '--no-check-certificate', shellwords($ENV{WGET_OPTIONS} || ''), $url) ; } From d02e887d7ceb25008fa70c42174207dfeb65b5f0 Mon Sep 17 00:00:00 2001 From: Mehdi Ahmadi Date: Fri, 26 Aug 2022 23:56:45 +0200 Subject: [PATCH 004/114] kernel: add Aquantia AQtion Atlantic 10Gbps Ethernet Driver support for Aquantia AQtion Atlantic 10Gbps Ethernet NIC with the AQC107, AQC108 and others chipsets found on: - TP-Link: TX401 - Asus: XG-C100C, ROG Areion 10G NIC - & more ... Successfully tested using a build with 22.03.0-rc6 (x86_64/EFI image) and the following outputs: ``` [ 3.092053] pci 0000:06:00.0: [1d6a:07b1] type 00 class 0x020000 [ 3.094983] pci 0000:06:00.0: reg 0x10: [mem 0x50800000-0x5080ffff 64bit] [ 3.098880] pci 0000:06:00.0: reg 0x18: [mem 0x50810000-0x50810fff 64bit] [ 3.108868] pci 0000:06:00.0: reg 0x20: [mem 0x50400000-0x507fffff 64bit] [ 3.108883] pci 0000:06:00.0: enabling Extended Tags [ 3.118874] pci 0000:06:00.0: supports D1 D2 [ 3.118874] pci 0000:06:00.0: PME# supported from D0 D1 D2 D3hot D3cold [ 3.128891] pci 0000:06:00.0: 7.876 Gb/s available PCIe bandwidth, limited by 8.0 GT/s PCIe x1 link at 0000:00:1d.0 (capable of 31.504 Gb/s with 8.0 GT/s PCIe x4 link) [ 10.312793] atlantic 0000:06:00.0: enabling device (0000 -> 0002) [ 23.223813] atlantic 0000:06:00.0 eth0: atlantic: link change old 0 new 10000 lsmod && uname -ar ; # atlantic 147456 0 # # // ... # Linux version 5.10.138 (vagrant@make-host) (x86_64-openwrt-linux-musl-gcc (OpenWrt GCC 11.3.0 r20430-18a2b29aa1) 11.3.0, GNU ld (GNU Binutils) 2.37) #0 SMP Mon Aug 29 09:54:00 2022 ``` Signed-off-by: Mehdi Ahmadi Reviewed-by: Robert Marko [ fix wrong commit author as requested by author itself ] Signed-off-by: Christian Marangi --- package/kernel/linux/modules/netdevices.mk | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk index 140459ab25..f048b01d8b 100644 --- a/package/kernel/linux/modules/netdevices.mk +++ b/package/kernel/linux/modules/netdevices.mk @@ -1457,3 +1457,19 @@ define KernelPackage/mhi-wwan-mbim/description endef $(eval $(call KernelPackage,mhi-wwan-mbim)) + +define KernelPackage/atlantic + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Aquantia AQtion 10Gbps Ethernet NIC + DEPENDS:=@PCI_SUPPORT +kmod-ptp + KCONFIG:=CONFIG_AQTION + FILES:=$(LINUX_DIR)/drivers/net/ethernet/aquantia/atlantic/atlantic.ko + AUTOLOAD:=$(call AutoProbe,atlantic) +endef + +define KernelPackage/atlantic/description + Kernel modules for Aquantia AQtion 10Gbps Ethernet NIC +endef + +$(eval $(call KernelPackage,atlantic)) + From 22b7bd6b1355baf7220136b6bd8277a321b70c39 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 20 Aug 2022 14:12:32 -0700 Subject: [PATCH 005/114] Makefile: replace head call with grep's -m head is not necessary here. Signed-off-by: Rosen Penev --- Makefile | 2 +- target/sdk/files/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3ac110367d..bfb52c5ddd 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt dir world: -DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep -E '\/usr' | head -n 1) +DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep -E '\/usr' -m 1) export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH) ifneq ($(OPENWRT_BUILD),1) diff --git a/target/sdk/files/Makefile b/target/sdk/files/Makefile index a710ca5f51..f620f0ef01 100644 --- a/target/sdk/files/Makefile +++ b/target/sdk/files/Makefile @@ -14,7 +14,7 @@ export TOPDIR LC_ALL LANG SDK world: -DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep -E '\/usr' | head -n 1) +DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep -E '\/usr' -m 1) export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH) ifneq ($(OPENWRT_BUILD),1) From 7f443d2d9aa1170d6b68f0dc6d5b5552882ee327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Sat, 3 Sep 2022 14:31:29 +0200 Subject: [PATCH 006/114] base-files: support "metric" in board.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It allows prepopulating /etc/config/network interface-s with predefined metric. It may be useful for devices with multiple WAN ports. Signed-off-by: Rafał Miłecki --- package/base-files/files/bin/config_generate | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 596fcf41fa..38362813d1 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -96,7 +96,7 @@ generate_network() { json_select network json_select "$1" - json_get_vars device macaddr protocol ipaddr netmask vlan + json_get_vars device macaddr metric protocol ipaddr netmask vlan json_get_values ports ports json_select .. json_select .. @@ -154,6 +154,7 @@ generate_network() { set network.$1='interface' set network.$1.type='$type' set network.$1.device='$device' + set network.$1.metric='$metric' set network.$1.proto='none' EOF From 964b82218057989d1143d04216d4dfe2a101d8dd Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 10 Sep 2022 18:21:39 +0100 Subject: [PATCH 007/114] kernel: fix Aquantia AQtion Atlantic module dependencies The buildbot revealed that Package kmod-atlantic is missing dependencies for the following libraries: hwmon.ko macsec.ko make[2]: *** [modules/netdevices.mk:1474: /builder/shared-workdir/build/bin/targets/mediatek/mt7629/packages/kmod-atlantic_5.15.67-1_arm_cortex-a7.ipk] Error 1 make[2]: Leaving directory '/builder/shared-workdir/build/package/kernel/linux' time: package/kernel/linux/compile#43.51#17.03#415.37 ERROR: package/kernel/linux failed to build. make[1]: *** [package/Makefile:116: package/kernel/linux/compile] Error 1 make[1]: *** Waiting for unfinished jobs.... Add those missing dependencies to fix the build. Fixes: d02e887d7c ("kernel: add Aquantia AQtion Atlantic 10Gbps Ethernet") Signed-off-by: Daniel Golle --- package/kernel/linux/modules/netdevices.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk index f048b01d8b..394180902d 100644 --- a/package/kernel/linux/modules/netdevices.mk +++ b/package/kernel/linux/modules/netdevices.mk @@ -1461,7 +1461,7 @@ $(eval $(call KernelPackage,mhi-wwan-mbim)) define KernelPackage/atlantic SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Aquantia AQtion 10Gbps Ethernet NIC - DEPENDS:=@PCI_SUPPORT +kmod-ptp + DEPENDS:=@PCI_SUPPORT +kmod-ptp +kmod-hwmon-core +kmod-macsec KCONFIG:=CONFIG_AQTION FILES:=$(LINUX_DIR)/drivers/net/ethernet/aquantia/atlantic/atlantic.ko AUTOLOAD:=$(call AutoProbe,atlantic) From f7dbdcfa54adf474880be2e90e772f93fadae3b7 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Fri, 9 Sep 2022 20:44:46 +0100 Subject: [PATCH 008/114] mediatek: filogic: use WPS button instead of RST on BPi-R3 The GPIO used for the RST button is also used for PCIe-CLKREQ signal. Hence it cannot be used as button signal if PCIe is also used. Wire up WPS button to serve as KEY_RESTART in Linux and "reset" button in U-Boot. Signed-off-by: Daniel Golle --- .../boot/uboot-mediatek/patches/430-add-bpi-r3.patch | 6 +++--- .../linux/mediatek/dts/mt7986a-bananapi-bpi-r3.dts | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch b/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch index d48de66064..834fc730b0 100644 --- a/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch +++ b/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch @@ -866,14 +866,14 @@ + + keys { + compatible = "gpio-keys"; -+ ++/* + factory { + label = "reset"; + gpios = <&gpio 9 GPIO_ACTIVE_LOW>; + }; -+ ++*/ + wps { -+ label = "wps"; ++ label = "reset"; + gpios = <&gpio 10 GPIO_ACTIVE_LOW>; + }; + }; diff --git a/target/linux/mediatek/dts/mt7986a-bananapi-bpi-r3.dts b/target/linux/mediatek/dts/mt7986a-bananapi-bpi-r3.dts index 2d9b0ac3b1..218fef5cec 100644 --- a/target/linux/mediatek/dts/mt7986a-bananapi-bpi-r3.dts +++ b/target/linux/mediatek/dts/mt7986a-bananapi-bpi-r3.dts @@ -63,6 +63,11 @@ keys { compatible = "gpio-keys"; +/* + * RST button is also PCIe-CLKREQ signal, use WPS button as reset + * instead as RST button doesn't make sense and cannot be used. + * + * intended buttons: factory { label = "reset"; linux,code = ; @@ -74,6 +79,13 @@ linux,code = ; gpios = <&pio 10 GPIO_ACTIVE_LOW>; }; + * actual setup: + */ + wps { + label = "wps"; + linux,code = ; + gpios = <&pio 10 GPIO_ACTIVE_LOW>; + }; }; leds { From fee31628c422e71c5ab0985ce10e960dad3c87f2 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Sat, 10 Sep 2022 16:35:31 +0200 Subject: [PATCH 009/114] imagebuilder: clean KDIR_TMP before building Building images usally stores them in KDIR_TMP and then copies them over to BIN_DIR. This is fine as rebuilding of images overwrites existing images. When using the EXTRA_IMAGE_NAME variable frequently this fills up the ImageBuilder KDIR_TMP folder since every built image is stored forever. This commit clears the KDIR_TMP folder before building a new image. Below an example how sysupgrade.openwrt.org filled up after the release of 22.03.0 where every created image contains a hash of the package selction in the filename: aparcar@asu-01:~/asu/worker1/cache/22.03.0$ du -d 1 -h 400M ./kirkwood 260M ./gemini 2.0G ./ipq806x 1.7G ./ipq40xx 8.1G ./ramips 4.0K ./octeon 495M ./sunxi 728M ./lantiq 1.8G ./rockchip 3.7G ./mediatek 4.0K ./realtek 5.4G ./mvebu 8.9G ./ath79 3.0G ./bcm47xx 14G ./bcm27xx 11G ./x86 4.0K ./bcm63xx 312M ./mpc85xx 600M ./apm821xx 5.4G ./bcm53xx 66G . Signed-off-by: Paul Spooren --- include/image.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/include/image.mk b/include/image.mk index bdcf20d30c..9e4e999581 100644 --- a/include/image.mk +++ b/include/image.mk @@ -756,6 +756,7 @@ define BuildImage else image_prepare: + rm -rf $(KDIR)/tmp mkdir -p $(BIN_DIR) $(KDIR)/tmp endif From b688bf83f9d6084b00719672ec197faf7adb493e Mon Sep 17 00:00:00 2001 From: Martin Kennedy Date: Sun, 21 Aug 2022 20:37:18 -0400 Subject: [PATCH 010/114] base-files: rename ethernet devs on known boards Some platforms lack an established way to name netdevs; for example, on x86, PCIe-based ethernet interfaces will be named starting from eth0 in the order they are probed. This is a problem for many devices supported explicitly by OpenWrt which have hard-wired, standalone or on-CPU NICs not supported by DSA (which is usually used to rename the ports based on their ostensible function). To fix this, add a mapping between ethernet device name and sysfs device path to board.json; this allows us to configure ethernet device names we know about for a given board so that they correspond to external labeling. Signed-off-by: Martin Kennedy --- .../files/lib/functions/uci-defaults.sh | 8 ++++ .../files/lib/preinit/10_indicate_preinit | 43 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index f96e645e73..4f5b9634bb 100644 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -114,6 +114,14 @@ ucidef_set_network_device_mac() { json_select .. } +ucidef_set_network_device_path() { + json_select_object "network_device" + json_select_object "$1" + json_add_string path "$2" + json_select .. + json_select .. +} + _ucidef_add_switch_port() { # inherited: $num $device $need_tag $want_untag $role $index $prev_role # inherited: $n_cpu $n_ports $n_vlan $cpu0 $cpu1 $cpu2 $cpu3 $cpu4 $cpu5 diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit index debb3d4480..87a4f4da3e 100644 --- a/package/base-files/files/lib/preinit/10_indicate_preinit +++ b/package/base-files/files/lib/preinit/10_indicate_preinit @@ -63,6 +63,20 @@ preinit_config_switch() { json_select .. } +preinit_config_port() { + local original + + local netdev="$1" + local path="$2" + + [ -d "/sys/devices/$path/net" ] || return + original="$(ls "/sys/devices/$path/net" | head -1)" + + [ "$netdev" = "$original" ] && return + + ip link set "$original" name "$netdev" +} + preinit_config_board() { /bin/board_detect /tmp/board.json @@ -73,6 +87,35 @@ preinit_config_board() { json_init json_load "$(cat /tmp/board.json)" + # Find the current highest eth* + max_eth=$(grep -o '^ *eth[0-9]*:' /proc/net/dev | tr -dc '[0-9]\n' | sort -n | tail -1) + # Find and move netdevs using eth*s we are configuring + json_get_keys keys "network_device" + for netdev in $keys; do + json_select "network_device" + json_select "$netdev" + json_get_vars path path + next_eth="$(echo "$netdev" | grep 'eth[0-9]*' | tr -dc '[0-9]')" + [ "$next_eth" -gt "$max_eth" ] && max_eth=$next_eth + if [ -n "$path" -a -h "/sys/class/net/$netdev" ]; then + ip link set "$netdev" down + ip link set "$netdev" name eth$((++max_eth)) + fi + json_select .. + json_select .. + done + + # Move interfaces by path to their netdev name + json_get_keys keys "network_device" + for netdev in $keys; do + json_select "network_device" + json_select "$netdev" + json_get_vars path path + [ -n "$path" ] && preinit_config_port "$netdev" "$path" + json_select .. + json_select .. + done + json_select network json_select "lan" json_get_vars device From eb425f9ec9a276a0013db06faa076e4ae9640a7d Mon Sep 17 00:00:00 2001 From: Martin Kennedy Date: Sun, 21 Aug 2022 20:37:18 -0400 Subject: [PATCH 011/114] x86: setup netdev paths for MX100 The Meraki MX100 has ten 1000BASE-T and 2 SFP ethernet ports through 3, 4-port PCIe devices. The default enumeration of these network devices' names does not correspond to their labeling. Fix this by explicitly naming the devices, mapping against their sysfs path. Note that these default network names can only be up to 8 characters, because we can have up to 8 characters of modifiers (e.g. ^br-, .4096$), and because the maximum network interface name is 16 characters long. Signed-off-by: Martin Kennedy [lowercase subject] Signed-off-by: Paul Spooren --- target/linux/x86/base-files/etc/board.d/02_network | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/target/linux/x86/base-files/etc/board.d/02_network b/target/linux/x86/base-files/etc/board.d/02_network index e4451461db..9335e297ba 100644 --- a/target/linux/x86/base-files/etc/board.d/02_network +++ b/target/linux/x86/base-files/etc/board.d/02_network @@ -9,7 +9,19 @@ board_config_update case "$(board_name)" in cisco-mx100-hw) - ucidef_set_interfaces_lan_wan "eth0 eth1 eth2 eth3 eth4 eth5 eth7 eth8 eth9 eth10 eth11" "eth6" + ucidef_set_network_device_path "mgmt" "pci0000:00/0000:00:01.2/0000:03:00.3" + ucidef_set_network_device_path "wan" "pci0000:00/0000:00:01.2/0000:03:00.2" + ucidef_set_network_device_path "eth2" "pci0000:00/0000:00:01.2/0000:03:00.1" + ucidef_set_network_device_path "eth3" "pci0000:00/0000:00:01.2/0000:03:00.0" + ucidef_set_network_device_path "eth4" "pci0000:00/0000:00:01.0/0000:01:00.2" + ucidef_set_network_device_path "eth5" "pci0000:00/0000:00:01.0/0000:01:00.1" + ucidef_set_network_device_path "eth6" "pci0000:00/0000:00:01.0/0000:01:00.4" + ucidef_set_network_device_path "eth7" "pci0000:00/0000:00:01.0/0000:01:00.3" + ucidef_set_network_device_path "eth8" "pci0000:00/0000:00:01.1/0000:02:00.1" + ucidef_set_network_device_path "eth9" "pci0000:00/0000:00:01.1/0000:02:00.0" + ucidef_set_network_device_path "eth10" "pci0000:00/0000:00:01.1/0000:02:00.3" + ucidef_set_network_device_path "eth11" "pci0000:00/0000:00:01.1/0000:02:00.2" + ucidef_set_interfaces_lan_wan "mgmt eth2 eth3 eth4 eth5 eth6 eth7 eth8 eth9 eth10 eth11" "wan" ;; pc-engines-apu1|pc-engines-apu2|pc-engines-apu3) ucidef_set_interfaces_lan_wan "eth1 eth2" "eth0" From 5f8c86e654c5215b7f23bde3f6bfe8fd169b3640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20B=C3=B6hler?= Date: Fri, 26 Aug 2022 11:21:40 +0200 Subject: [PATCH 012/114] realtek: add support for TP-Link SG2452P v4 aka T1600G-52PS v4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is an RTL8393-based switch with 802.3af on all 48 ports. Specifications: --------------- * SoC: Realtek RTL8393M * Flash: 32 MiB SPI flash * RAM: 256 MiB * Ethernet: 48x 10/100/1000 Mbps with PoE+ * Buttons: 1x "Reset" button, 1x "Speed" button * UART: 1x serial header, unpopulated * PoE: 12x TI TPS23861 I2C PoE controller, 384W PoE budget * SFP: 4 SFP ports Works: ------ - (48) RJ-45 ethernet ports - Switch functions - Buttons - All LEDs on front panel except port LEDs - Fan monitoring and basic control Not yet enabled: ---------------- - PoE - ICs are not in AUTO mode, so the kernel driver is not usable - Port LEDs - SFP cages Install via web interface: ------------------------- Not supported at this time. Install via serial console/tftp: -------------------------------- The U-Boot firmware drops to a TP-Link specific "BOOTUTIL" shell at 38400 baud. There is no known way to exit out of this shell, and no way to do anything useful. Ideally, one would trick the bootloader into flashing the sysupgrade image first. However, if the image exceeds 6MiB in size, it will not work. To install OpenWRT: Prepare a tftp server with: 1. server address: 192.168.0.146 2. the image as: "uImage.img" Power on device, and stop boot by pressing any key. Once the shell is active: 1. Ground out the CLK (pin 16) of the ROM (U6) 2. Select option "3. Start" 3. Bootloader notes that "The kernel has been damaged!" 4. Release CLK as soon as bootloader thinks image is corrupted. 5. Bootloader enters automatic recovery -- details printed on console 6. Watch as the bootloader flashes and boots OpenWRT. Blind install via tftp: ----------------------- This method works when it's not feasible to install a serial header. Prepare a tftp server with: 1. server address: 192.168.0.146 2. the image as: "uImage.img" 3. Watch network traffic (tcpdump or wireshark works) 4. Power on the device. 5. Wait 1-2 seconds then ground out the CLK (pin 16) of the ROM (U6) 6. When 192.168.0.30 makes tftp requests, release pin 16 7. Wait 2-3 minutes for device to auto-flash and boot OpenWRT Signed-off-by: Andreas Böhler --- package/boot/uboot-envtools/files/realtek | 3 +- .../realtek/base-files/etc/board.d/02_network | 3 +- .../dts-5.10/rtl8393_tplink_sg2452p-v4.dts | 411 ++++++++++++++++++ target/linux/realtek/dts-5.10/rtl839x.dtsi | 4 + target/linux/realtek/image/rtl839x.mk | 11 + 5 files changed, 430 insertions(+), 2 deletions(-) create mode 100644 target/linux/realtek/dts-5.10/rtl8393_tplink_sg2452p-v4.dts diff --git a/package/boot/uboot-envtools/files/realtek b/package/boot/uboot-envtools/files/realtek index e1eb1a6ac6..22568afd12 100644 --- a/package/boot/uboot-envtools/files/realtek +++ b/package/boot/uboot-envtools/files/realtek @@ -29,7 +29,8 @@ zyxel,gs1900-24hp-v2) [ -n "$idx2" ] && \ ubootenv_add_uci_sys_config "/dev/mtd$idx2" "0x0" "0x1000" "0x10000" ;; -tplink,sg2008p-v1) +tplink,sg2008p-v1|\ +tplink,sg2452p-v4) idx="$(find_mtd_index u-boot-env)" [ -n "$idx" ] && \ ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x20000" "0x10000" diff --git a/target/linux/realtek/base-files/etc/board.d/02_network b/target/linux/realtek/base-files/etc/board.d/02_network index d797960faf..6e0e0e7e03 100644 --- a/target/linux/realtek/base-files/etc/board.d/02_network +++ b/target/linux/realtek/base-files/etc/board.d/02_network @@ -39,7 +39,8 @@ hpe,1920-24g) lan_mac_start=$(macaddr_add $lan_mac 2) lan_mac_end=$(macaddr_add $lan_mac $((mac_count2-mac_count1))) ;; -tplink,sg2008p-v1) +tplink,sg2008p-v1|\ +tplink,sg2452p-v4) label_mac=$(mtd_get_mac_binary para 0xfdff4) lan_mac="$label_mac" ;; diff --git a/target/linux/realtek/dts-5.10/rtl8393_tplink_sg2452p-v4.dts b/target/linux/realtek/dts-5.10/rtl8393_tplink_sg2452p-v4.dts new file mode 100644 index 0000000000..0649c9fb37 --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8393_tplink_sg2452p-v4.dts @@ -0,0 +1,411 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rtl839x.dtsi" + +#include +#include +#include + +/ { + compatible = "tplink,sg2452p-v4", "realtek,rtl8393-soc"; + model = "TP-Link SG2452P v4"; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x10000000>; + }; + + aliases { + led-boot = &led_sys; + led-failsafe = &led_sys; + led-running = &led_sys; + led-upgrade = &led_sys; + }; + + chosen { + bootargs = "console=ttyS0,38400"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio0 20 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + speed { + label = "speed"; + gpios = <&gpio0 19 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + gpio_fan_sys { + compatible = "gpio-fan"; + alarm-gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; + }; + + gpio_fan_psu_1 { + pinctrl-names = "default"; + pinctrl-0 = <&disable_jtag>; + compatible = "gpio-fan"; + + alarm-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>; + gpios = <&gpio0 4 GPIO_ACTIVE_LOW>; + /* the actual speeds (rpm) are unknown, just use dummy values */ + gpio-fan,speed-map = <1 0>, <2 1>; + #cooling-cells = <2>; + }; + + gpio_fan_psu_2 { + /* This fan runs in parallel to PSU1 fan, but has a separate + * alarm GPIO. This is not (yet) supported by the gpio-fan driver, + * so a separate instance is added + */ + compatible = "gpio-fan"; + alarm-gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; + }; + + leds { + pinctrl-names = "default"; + compatible = "gpio-leds"; + + led-0 { + label = "green:speed"; + gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_INDICATOR; + }; + + led-1 { + label = "green:poe"; + gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_INDICATOR; + }; + + led_sys: led-2 { + label = "green:sys"; + gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led-3 { + label = "green:fan"; + gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led-4 { + label = "amber:fan"; + gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + color = ; + function = "fault-fan"; + }; + + led-5 { + label = "green:poe-max"; + gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; + color = ; + function = "alarm-poe"; + }; + }; + + i2c-gpio-0 { + compatible = "i2c-gpio"; + sda-gpios = <&gpio0 2 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio0 1 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + + /* LAN9 - LAN12 */ + tps23861@5 { + compatible = "ti,tps23861"; + reg = <0x05>; + }; + + /* LAN17 - LAN20 */ + tps23861@6 { + compatible = "ti,tps23861"; + reg = <0x06>; + }; + + /* LAN45 - LAN48 */ + tps23861@9 { + compatible = "ti,tps23861"; + reg = <0x09>; + }; + + /* LAN37 - LAN40 */ + tps23861@a { + compatible = "ti,tps23861"; + reg = <0x0a>; + }; + + /* LAN1 - LAN4 */ + tps23861@14 { + compatible = "ti,tps23861"; + reg = <0x14>; + }; + + /* LAN25 - LAN28 */ + tps23861@24 { + compatible = "ti,tps23861"; + reg = <0x24>; + }; + + /* LAN33 - LAN 36 */ + tps23861@25 { + compatible = "ti,tps23861"; + reg = <0x25>; + }; + + /* LAN41 - LAN44 */ + tps23861@26 { + compatible = "ti,tps23861"; + reg = <0x26>; + }; + + /* LAN13 - LAN16 */ + tps23861@29 { + compatible = "ti,tps23861"; + reg = <0x29>; + }; + + /* LAN29 - LAN32 */ + tps23861@2c { + compatible = "ti,tps23861"; + reg = <0x2c>; + }; + + /* LAN5 - LAN8 */ + tps23861@48 { + compatible = "ti,tps23861"; + reg = <0x48>; + }; + + /* LAN21 - LAN24 */ + tps23861@49 { + compatible = "ti,tps23861"; + reg = <0x49>; + }; + }; + + gpio-restart { + compatible = "gpio-restart"; + gpios = <&gpio0 17 GPIO_ACTIVE_LOW>; + }; +}; + +&gpio0 { + poe-enable { + gpio-hog; + gpios = <23 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "poe-enable"; + }; +}; + +&spi0 { + status = "okay"; + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <10000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0xe0000>; + read-only; + }; + partition@e0000 { + label = "u-boot-env"; + reg = <0xe0000 0x20000>; + }; + + /* We use the "sys", "usrimg1" and "usrimg2" partitions + * as firmware since the kernel needs to be in "sys", but the + * partition is too small to hold the "rootfs" as well. + * The original partition map contains: + * + * partition@100000 { + * label = "sys"; + * reg = <0x100000 0x600000>; + * }; + * partition@700000 { + * label = "usrimg1"; + * reg = <0x700000 0xa00000>; + * }; + * partition@1100000 { + * label = "usrimg2"; + * reg = <0x1100000 0xa00000>; + * }; + */ + + partition@100000 { + label = "firmware"; + reg = <0x100000 0x1a00000>; + }; + partition@1b00000 { + label = "usrappfs"; + reg = <0x1b00000 0x400000>; + }; + partition@1f00000 { + label = "para"; + reg = <0x1f00000 0x100000>; + read-only; + }; + }; + }; +}; + +ðernet0 { + mdio: mdio-bus { + compatible = "realtek,rtl838x-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + /* External phy RTL8218B #1 */ + EXTERNAL_PHY(0) + EXTERNAL_PHY(1) + EXTERNAL_PHY(2) + EXTERNAL_PHY(3) + EXTERNAL_PHY(4) + EXTERNAL_PHY(5) + EXTERNAL_PHY(6) + EXTERNAL_PHY(7) + + /* External phy RTL8218B #2 */ + EXTERNAL_PHY(8) + EXTERNAL_PHY(9) + EXTERNAL_PHY(10) + EXTERNAL_PHY(11) + EXTERNAL_PHY(12) + EXTERNAL_PHY(13) + EXTERNAL_PHY(14) + EXTERNAL_PHY(15) + + /* External phy RTL8218B #3 */ + EXTERNAL_PHY(16) + EXTERNAL_PHY(17) + EXTERNAL_PHY(18) + EXTERNAL_PHY(19) + EXTERNAL_PHY(20) + EXTERNAL_PHY(21) + EXTERNAL_PHY(22) + EXTERNAL_PHY(23) + + /* External phy RTL8218B #4 */ + EXTERNAL_PHY(24) + EXTERNAL_PHY(25) + EXTERNAL_PHY(26) + EXTERNAL_PHY(27) + EXTERNAL_PHY(28) + EXTERNAL_PHY(29) + EXTERNAL_PHY(30) + EXTERNAL_PHY(31) + + /* External phy RTL8218B #5 */ + EXTERNAL_PHY(32) + EXTERNAL_PHY(33) + EXTERNAL_PHY(34) + EXTERNAL_PHY(35) + EXTERNAL_PHY(36) + EXTERNAL_PHY(37) + EXTERNAL_PHY(38) + EXTERNAL_PHY(39) + + /* External phy RTL8218B #6 */ + EXTERNAL_PHY(40) + EXTERNAL_PHY(41) + EXTERNAL_PHY(42) + EXTERNAL_PHY(43) + EXTERNAL_PHY(44) + EXTERNAL_PHY(45) + EXTERNAL_PHY(46) + EXTERNAL_PHY(47) + }; +}; + +&switch0 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + SWITCH_PORT(0, 01, qsgmii) + SWITCH_PORT(1, 02, qsgmii) + SWITCH_PORT(2, 03, qsgmii) + SWITCH_PORT(3, 04, qsgmii) + SWITCH_PORT(4, 05, qsgmii) + SWITCH_PORT(5, 06, qsgmii) + SWITCH_PORT(6, 07, qsgmii) + SWITCH_PORT(7, 08, qsgmii) + + SWITCH_PORT(8, 09, qsgmii) + SWITCH_PORT(9, 10, qsgmii) + SWITCH_PORT(10, 11, qsgmii) + SWITCH_PORT(11, 12, qsgmii) + SWITCH_PORT(12, 13, qsgmii) + SWITCH_PORT(13, 14, qsgmii) + SWITCH_PORT(14, 15, qsgmii) + SWITCH_PORT(15, 16, qsgmii) + + SWITCH_PORT(16, 17, qsgmii) + SWITCH_PORT(17, 18, qsgmii) + SWITCH_PORT(18, 19, qsgmii) + SWITCH_PORT(19, 20, qsgmii) + SWITCH_PORT(20, 21, qsgmii) + SWITCH_PORT(21, 22, qsgmii) + SWITCH_PORT(22, 23, qsgmii) + SWITCH_PORT(23, 24, qsgmii) + + SWITCH_PORT(24, 25, qsgmii) + SWITCH_PORT(25, 26, qsgmii) + SWITCH_PORT(26, 27, qsgmii) + SWITCH_PORT(27, 28, qsgmii) + SWITCH_PORT(28, 29, qsgmii) + SWITCH_PORT(29, 30, qsgmii) + SWITCH_PORT(30, 31, qsgmii) + SWITCH_PORT(31, 32, qsgmii) + + SWITCH_PORT(32, 33, qsgmii) + SWITCH_PORT(33, 34, qsgmii) + SWITCH_PORT(34, 35, qsgmii) + SWITCH_PORT(35, 36, qsgmii) + SWITCH_PORT(36, 37, qsgmii) + SWITCH_PORT(37, 38, qsgmii) + SWITCH_PORT(38, 39, qsgmii) + SWITCH_PORT(39, 40, qsgmii) + + SWITCH_PORT(40, 41, qsgmii) + SWITCH_PORT(41, 42, qsgmii) + SWITCH_PORT(42, 43, qsgmii) + SWITCH_PORT(43, 44, qsgmii) + SWITCH_PORT(44, 45, qsgmii) + SWITCH_PORT(45, 46, qsgmii) + SWITCH_PORT(46, 47, qsgmii) + SWITCH_PORT(47, 48, qsgmii) + + /* CPU-Port */ + port@52 { + ethernet = <ðernet0>; + reg = <52>; + phy-mode = "internal"; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; diff --git a/target/linux/realtek/dts-5.10/rtl839x.dtsi b/target/linux/realtek/dts-5.10/rtl839x.dtsi index b40ca83ac3..2091fe0ba3 100644 --- a/target/linux/realtek/dts-5.10/rtl839x.dtsi +++ b/target/linux/realtek/dts-5.10/rtl839x.dtsi @@ -247,6 +247,10 @@ enable_uart1: pinmux_enable_uart1 { pinctrl-single,bits = <0x0 0x1 0x3>; }; + + disable_jtag: pinmux_disable_jtag { + pinctrl-single,bits = <0x0 0x2 0x3>; + }; }; /* LED_GLB_CTRL */ diff --git a/target/linux/realtek/image/rtl839x.mk b/target/linux/realtek/image/rtl839x.mk index 8917e8550f..b47c409244 100644 --- a/target/linux/realtek/image/rtl839x.mk +++ b/target/linux/realtek/image/rtl839x.mk @@ -11,6 +11,17 @@ define Device/panasonic_m48eg-pn28480k endef TARGET_DEVICES += panasonic_m48eg-pn28480k +define Device/tplink_sg2452p-v4 + SOC := rtl8393 + KERNEL_SIZE := 6m + IMAGE_SIZE := 26m + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := SG2452P + DEVICE_VARIANT := v4 + DEVICE_PACKAGES := kmod-hwmon-gpiofan kmod-hwmon-tps23861 +endef +TARGET_DEVICES += tplink_sg2452p-v4 + define Device/zyxel_gs1900-48 SOC := rtl8393 IMAGE_SIZE := 13952k From 675cf7557829cdc637c037ea63dbcd2e3436b009 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 10 Sep 2022 20:59:16 +0100 Subject: [PATCH 013/114] ramips: add config-5.15 for mt7620 subtarget Add Kernel config for testing Linux 5.15 for the mt7620 subtarget. Tested on Youku YK-L1 which boots fine. Signed-off-by: Daniel Golle --- target/linux/ramips/mt7620/config-5.15 | 196 +++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 target/linux/ramips/mt7620/config-5.15 diff --git a/target/linux/ramips/mt7620/config-5.15 b/target/linux/ramips/mt7620/config-5.15 new file mode 100644 index 0000000000..5c6464d4a2 --- /dev/null +++ b/target/linux/ramips/mt7620/config-5.15 @@ -0,0 +1,196 @@ +CONFIG_AR8216_PHY=y +CONFIG_ARCH_32BIT_OFF_T=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_KEEP_MEMBLOCK=y +CONFIG_ARCH_MMAP_RND_BITS_MAX=15 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=15 +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_BLK_MQ_PCI=y +CONFIG_CEVT_R4K=y +CONFIG_CEVT_SYSTICK_QUIRK=y +CONFIG_CLKEVT_RT3352=y +CONFIG_CLKSRC_MMIO=y +CONFIG_CLONE_BACKWARDS=y +CONFIG_CMDLINE="rootfstype=squashfs,jffs2" +CONFIG_CMDLINE_BOOL=y +# CONFIG_CMDLINE_OVERRIDE is not set +CONFIG_COMMON_CLK=y +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_CPU_GENERIC_DUMP_TLB=y +CONFIG_CPU_HAS_DIEI=y +CONFIG_CPU_HAS_PREFETCH=y +CONFIG_CPU_HAS_RIXI=y +CONFIG_CPU_HAS_SYNC=y +CONFIG_CPU_MIPS32=y +# CONFIG_CPU_MIPS32_R1 is not set +CONFIG_CPU_MIPS32_R2=y +CONFIG_CPU_MIPSR2=y +CONFIG_CPU_MIPSR2_IRQ_VI=y +CONFIG_CPU_NEEDS_NO_SMARTMIPS_OR_MICROMIPS=y +CONFIG_CPU_R4K_CACHE_TLB=y +CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_HIGHMEM=y +CONFIG_CPU_SUPPORTS_MSA=y +CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y +CONFIG_CRYPTO_LIB_POLY1305_RSIZE=2 +CONFIG_CRYPTO_RNG2=y +CONFIG_CSRC_R4K=y +CONFIG_DEBUG_PINCTRL=y +CONFIG_DMA_NONCOHERENT=y +# CONFIG_DTB_MT7620A_EVAL is not set +# CONFIG_DTB_OMEGA2P is not set +CONFIG_DTB_RT_NONE=y +# CONFIG_DTB_VOCORE2 is not set +CONFIG_DTC=y +CONFIG_EARLY_PRINTK=y +CONFIG_ETHERNET_PACKET_MANGLE=y +CONFIG_FIXED_PHY=y +CONFIG_FWNODE_MDIO=y +CONFIG_FW_LOADER_PAGED_BUF=y +CONFIG_GENERIC_ATOMIC64=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CMOS_UPDATE=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_FIND_FIRST_BIT=y +CONFIG_GENERIC_GETTIMEOFDAY=y +CONFIG_GENERIC_IOMAP=y +CONFIG_GENERIC_IRQ_CHIP=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_LIB_ASHLDI3=y +CONFIG_GENERIC_LIB_ASHRDI3=y +CONFIG_GENERIC_LIB_CMPDI2=y +CONFIG_GENERIC_LIB_LSHRDI3=y +CONFIG_GENERIC_LIB_UCMPDI2=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_PHY=y +CONFIG_GENERIC_SCHED_CLOCK=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GPIO_CDEV=y +# CONFIG_GPIO_MT7621 is not set +CONFIG_GPIO_RALINK=y +CONFIG_GPIO_WATCHDOG=y +# CONFIG_GPIO_WATCHDOG_ARCH_INITCALL is not set +CONFIG_HANDLE_DOMAIN_IRQ=y +CONFIG_HARDWARE_WATCHPOINTS=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HZ_PERIODIC=y +CONFIG_ICPLUS_PHY=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_INTC=y +CONFIG_IRQ_MIPS_CPU=y +CONFIG_IRQ_WORK=y +CONFIG_LIBFDT=y +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_MARVELL_PHY=y +CONFIG_MDIO_BUS=y +CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_DEVRES=y +CONFIG_MEMFD_CREATE=y +CONFIG_MFD_SYSCON=y +CONFIG_MIGRATION=y +CONFIG_MIPS=y +CONFIG_MIPS_ASID_BITS=8 +CONFIG_MIPS_ASID_SHIFT=0 +CONFIG_MIPS_CLOCK_VSYSCALL=y +# CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND is not set +# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set +CONFIG_MIPS_CMDLINE_FROM_DTB=y +CONFIG_MIPS_EBPF_JIT=y +CONFIG_MIPS_L1_CACHE_SHIFT=5 +CONFIG_MIPS_LD_CAN_LINK_VDSO=y +# CONFIG_MIPS_NO_APPENDED_DTB is not set +CONFIG_MIPS_RAW_APPENDED_DTB=y +CONFIG_MIPS_SPRAM=y +CONFIG_MODULES_USE_ELF_REL=y +# CONFIG_MT7621_WDT is not set +# CONFIG_MTD_CFI_INTELEXT is not set +CONFIG_MTD_CMDLINE_PARTS=y +CONFIG_MTD_PHYSMAP=y +CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE=y +CONFIG_MTD_SPLIT_JIMAGE_FW=y +CONFIG_MTD_SPLIT_SEAMA_FW=y +CONFIG_MTD_SPLIT_TPLINK_FW=y +CONFIG_MTD_SPLIT_UIMAGE_FW=y +CONFIG_MTD_VIRT_CONCAT=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_PER_CPU_KM=y +CONFIG_NET_RALINK_GSW_MT7620=y +CONFIG_NET_RALINK_MDIO=y +CONFIG_NET_RALINK_MDIO_MT7620=y +CONFIG_NET_RALINK_MT7620=y +# CONFIG_NET_RALINK_RT3050 is not set +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_SELFTESTS=y +# CONFIG_NET_VENDOR_MEDIATEK is not set +CONFIG_NET_VENDOR_RALINK=y +CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y +CONFIG_NVMEM=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IRQ=y +CONFIG_OF_KOBJ=y +CONFIG_OF_MDIO=y +CONFIG_PCI=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCI_DRIVERS_LEGACY=y +CONFIG_PERF_USE_VMALLOC=y +CONFIG_PGTABLE_LEVELS=2 +CONFIG_PHYLIB=y +# CONFIG_PHY_MT7621_PCI is not set +CONFIG_PHY_RALINK_USB=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_MT7620=y +# CONFIG_PINCTRL_RALINK is not set +# CONFIG_PINCTRL_SINGLE is not set +CONFIG_PTP_1588_CLOCK_OPTIONAL=y +CONFIG_RALINK=y +CONFIG_RALINK_WDT=y +CONFIG_RATIONAL=y +CONFIG_REGMAP=y +CONFIG_REGMAP_MMIO=y +CONFIG_RESET_CONTROLLER=y +CONFIG_SERIAL_8250_RT288X=y +CONFIG_SERIAL_MCTRL_GPIO=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SOC_MT7620=y +# CONFIG_SOC_MT7621 is not set +# CONFIG_SOC_RT288X is not set +# CONFIG_SOC_RT305X is not set +# CONFIG_SOC_RT3883 is not set +CONFIG_SPI=y +CONFIG_SPI_MASTER=y +CONFIG_SPI_MEM=y +# CONFIG_SPI_MT7621 is not set +CONFIG_SPI_RT2880=y +CONFIG_SRCU=y +CONFIG_SWCONFIG=y +CONFIG_SWCONFIG_LEDS=y +CONFIG_SWPHY=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_SYS_HAS_CPU_MIPS32_R1=y +CONFIG_SYS_HAS_CPU_MIPS32_R2=y +CONFIG_SYS_HAS_EARLY_PRINTK=y +CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y +CONFIG_SYS_SUPPORTS_ARBIT_HZ=y +CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y +CONFIG_SYS_SUPPORTS_MIPS16=y +CONFIG_SYS_SUPPORTS_ZBOOT=y +CONFIG_TARGET_ISA_REV=2 +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TIMER_OF=y +CONFIG_TIMER_PROBE=y +CONFIG_TINY_SRCU=y +CONFIG_USB_SUPPORT=y +CONFIG_USE_OF=y +CONFIG_WATCHDOG_CORE=y From 7b1740e2088e20bfa304407bf57a2bef5e9b39f1 Mon Sep 17 00:00:00 2001 From: Jian Huang Date: Thu, 1 Sep 2022 14:05:47 +0000 Subject: [PATCH 014/114] px5g-wolfssl: replace unnecessary strncmp() Replace some of the calls to strncmp() with strcmp(). Signed-off-by: Jian Huang --- package/utils/px5g-wolfssl/px5g-wolfssl.c | 42 +++++++++++------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/package/utils/px5g-wolfssl/px5g-wolfssl.c b/package/utils/px5g-wolfssl/px5g-wolfssl.c index 86227d6afd..cd04a41dfb 100644 --- a/package/utils/px5g-wolfssl/px5g-wolfssl.c +++ b/package/utils/px5g-wolfssl/px5g-wolfssl.c @@ -142,42 +142,42 @@ int selfsigned(WC_RNG *rng, char **arg) { newCert.isCA = 0; while (*arg && **arg == '-') { - if (!strncmp(*arg, "-der", 4)) { + if (!strcmp(*arg, "-der")) { pem = false; - } else if (!strncmp(*arg, "-newkey", 6) && arg[1]) { + } else if (!strcmp(*arg, "-newkey") && arg[1]) { if (!strncmp(arg[1], "rsa:", 4)) { type = RSA_KEY_TYPE; - keySz = (unsigned int)atoi(arg[1] + 4); - } else if (!strncmp(arg[1], "ec", 2)) { + keySz = atoi(arg[1] + 4); + } else if (!strcmp(arg[1], "ec")) { type = EC_KEY_TYPE; } else { fprintf(stderr, "error: invalid algorithm\n"); return 1; } arg++; - } else if (!strncmp(*arg, "-days", 5) && arg[1]) { + } else if (!strcmp(*arg, "-days") && arg[1]) { days = (unsigned int)atoi(arg[1]); arg++; - } else if (!strncmp(*arg, "-pkeyopt", 8) && arg[1]) { + } else if (!strcmp(*arg, "-pkeyopt") && arg[1]) { if (strncmp(arg[1], "ec_paramgen_curve:", 18)) { fprintf(stderr, "error: invalid pkey option: %s\n", arg[1]); return 1; } - if (!strncmp(arg[1] + 18, "P-256:", 5)) { + if (!strcmp(arg[1] + 18, "P-256")) { curve = ECC_SECP256R1; - } else if (!strncmp(arg[1] + 18, "P-384:", 5)) { + } else if (!strcmp(arg[1] + 18, "P-384")) { curve = ECC_SECP384R1; - } else if (!strncmp(arg[1] + 18, "P-521:", 5)) { + } else if (!strcmp(arg[1] + 18, "P-521")) { curve = ECC_SECP521R1; } else { fprintf(stderr, "error: invalid curve name: %s\n", arg[1] + 18); return 1; } arg++; - } else if (!strncmp(*arg, "-keyout", 7) && arg[1]) { + } else if (!strcmp(*arg, "-keyout") && arg[1]) { keypath = arg[1]; arg++; - } else if (!strncmp(*arg, "-out", 4) && arg[1]) { + } else if (!strcmp(*arg, "-out") && arg[1]) { certpath = arg[1]; arg++; } else if (!strcmp(*arg, "-subj") && arg[1]) { @@ -306,25 +306,25 @@ int dokey(WC_RNG *rng, int type, char **arg) { bool pem = true; while (*arg && **arg == '-') { - if (!strncmp(*arg, "-out", 4) && arg[1]) { + if (!strcmp(*arg, "-out") && arg[1]) { path = arg[1]; arg++; - } else if (!strncmp(*arg, "-3", 2)) { + } else if (!strcmp(*arg, "-3")) { exp = 3; - } else if (!strncmp(*arg, "-der", 4)) { + } else if (!strcmp(*arg, "-der")) { pem = false; } arg++; } if (*arg && type == RSA_KEY_TYPE) { - keySz = (unsigned int)atoi(*arg); + keySz = atoi(*arg); } else if (*arg) { - if (!strncmp(*arg, "P-256", 5)) { + if (!strcmp(*arg, "P-256")) { curve = ECC_SECP256R1; - } else if (!strncmp(*arg, "P-384", 5)) { + } else if (!strcmp(*arg, "P-384")) { curve = ECC_SECP384R1; - } else if (!strncmp(*arg, "P-521", 5)) { + } else if (!strcmp(*arg, "P-521")) { curve = ECC_SECP521R1; } else { fprintf(stderr, "Invalid Curve Name: %s\n", *arg); @@ -356,13 +356,13 @@ int main(int argc, char *argv[]) { } if (argv[1]) { - if (!strncmp(argv[1], "eckey", 5)) + if (!strcmp(argv[1], "eckey")) return dokey(&rng, EC_KEY_TYPE, argv + 2); - if (!strncmp(argv[1], "rsakey", 5)) + if (!strcmp(argv[1], "rsakey")) return dokey(&rng, RSA_KEY_TYPE, argv + 2); - if (!strncmp(argv[1], "selfsigned", 10)) + if (!strcmp(argv[1], "selfsigned")) return selfsigned(&rng, argv + 2); } From fa468d4bcdc7e6eb84ea51d9b05368ed87c43aae Mon Sep 17 00:00:00 2001 From: Kien Truong Date: Sat, 10 Sep 2022 15:25:35 +0700 Subject: [PATCH 015/114] iproute2: add missing libbpf dependency This patch adds libbpf to the dependencies of tc-mod-iptables. The package tc-mod-iptables is missing libbpf as a dependency, which leads to the build failure described in bug #9491 LIBBPF_FORCE=on set, but couldn't find a usable libbpf The build dependency is already automatically added because some other packages from iproute2 depend on libbpf, but bpftools has multiple build variants. With multiple build variants none gets build by default and the build system will not build bpftools before iproute2. Fixes: #9491 Signed-off-by: Kien Truong Signed-off-by: Hauke Mehrtens --- package/network/utils/iproute2/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/utils/iproute2/Makefile b/package/network/utils/iproute2/Makefile index 4c21d4d877..5255400513 100644 --- a/package/network/utils/iproute2/Makefile +++ b/package/network/utils/iproute2/Makefile @@ -82,7 +82,7 @@ define Package/tc-mod-iptables $(call Package/iproute2/Default) TITLE:=Traffic control module - iptables action VARIANT:=tcfull - DEPENDS:=+libxtables + DEPENDS:=+libxtables +libbpf endef define Package/genl From 89a39876072d95fb0016acb989f6e2bc236a48ec Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Tue, 23 Aug 2022 15:57:49 +0200 Subject: [PATCH 016/114] libmd: add library providing message digest functions This library is needed by >= libbsd-0.11.3. Signed-off-by: Nick Hainke --- package/libs/libmd/Makefile | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 package/libs/libmd/Makefile diff --git a/package/libs/libmd/Makefile b/package/libs/libmd/Makefile new file mode 100644 index 0000000000..faba27e5e9 --- /dev/null +++ b/package/libs/libmd/Makefile @@ -0,0 +1,47 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=libmd +PKG_VERSION:=1.0.4 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=https://archive.hadrons.org/software/libmd/ +PKG_HASH:=f51c921042e34beddeded4b75557656559cf5b1f2448033b4c1eec11c07e530f + +PKG_LICENSE:=BSD-3-Clause +PKG_LICENSE_FILES:=COPYING + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-static + +define Package/libmd + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Message Digest functions from BSD systems + ABI_VERSION:=0 +endef + +define Package/libmd/description + This library provides message digest functions found on BSD systems either + on their libc or libmd libraries and lacking on others like GNU systems, + thus making it easier to port projects with strong BSD origins, without + needing to embed the same code over and over again on each project. +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmd.a $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libmd*.pc $(1)/usr/lib/pkgconfig/ + $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/ +endef + +$(eval $(call BuildPackage,libmd)) From f42e24f19df765b9da05c7bbcafa9428e1f8ef13 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Tue, 23 Aug 2022 16:04:42 +0200 Subject: [PATCH 017/114] libbsd: update to 0.11.6 Update to latest version. Needs libmd. Old size: 37615 libbsd0_0.10.0-1_aarch64_cortex-a53.ipk new size (libmd linked static): 38514 libbsd0_0.11.6-1_aarch64_cortex-a53.ipk Signed-off-by: Nick Hainke --- package/libs/libbsd/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/libs/libbsd/Makefile b/package/libs/libbsd/Makefile index 26e05f79a1..47af01f555 100644 --- a/package/libs/libbsd/Makefile +++ b/package/libs/libbsd/Makefile @@ -1,18 +1,19 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libbsd -PKG_VERSION:=0.10.0 +PKG_VERSION:=0.11.6 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://libbsd.freedesktop.org/releases -PKG_HASH:=34b8adc726883d0e85b3118fa13605e179a62b31ba51f676136ecb2d0bc1a887 +PKG_HASH:=19b38f3172eaf693e6e1c68714636190c7e48851e45224d720b3b5bc0499b5df PKG_LICENSE:=BSD-4-Clause PKG_LICENSE_FILES:=COPYING PKG_INSTALL:=1 PKG_BUILD_PARALLEL:=1 +PKG_BUILD_DEPENDS := libmd include $(INCLUDE_DIR)/package.mk @@ -42,4 +43,3 @@ define Package/libbsd/install endef $(eval $(call BuildPackage,libbsd)) - From 5a80226e96d5408fe266cdc8e4962d6199ad99c3 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Tue, 30 Aug 2022 10:59:31 +0200 Subject: [PATCH 018/114] lldpd: update to 1.0.15 Release Notes: https://github.com/lldpd/lldpd/releases/tag/1.0.15 Signed-off-by: Nick Hainke --- package/network/services/lldpd/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index 77b226a1e4..b99fc61e5a 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lldpd -PKG_VERSION:=1.0.14 +PKG_VERSION:=1.0.15 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/lldpd/lldpd/tar.gz/$(PKG_VERSION)? -PKG_HASH:=0cb77fd7634401347b8311db1bf64d4fc3890acba90915e2cc2c5f79045ddbf0 +PKG_HASH:=bdb1f9e29f61c3be99e421e88a431536c53e62f1ab7189a6d5b8e1d2d55d8899 PKG_MAINTAINER:=Stijn Tintel PKG_LICENSE:=ISC From e8a62a1e6040de71bdcb1be1a1c30c064acbc059 Mon Sep 17 00:00:00 2001 From: John Audia Date: Mon, 5 Sep 2022 06:47:34 -0400 Subject: [PATCH 019/114] kernel: bump 5.10 to 5.10.141 All patches automatically rebased. Signed-off-by: John Audia --- include/kernel-5.10 | 4 ++-- .../patches-5.10/910-unaligned_access_hacks.patch | 2 +- ...ct-napi-poll-functionality-to-__napi_poll.patch | 8 ++++---- ...ment-threaded-able-napi-poll-loop-support.patch | 14 +++++++------- ...fs-attribute-to-control-napi-threaded-mod.patch | 4 ++-- ...e-between-napi-kthread-mode-and-busy-poll.patch | 6 +++--- ...-hangup-on-napi_disable-for-threaded-napi.patch | 4 ++-- ...ftables-update-table-flags-from-the-commi.patch | 6 +++--- ...-forwarding-path-from-virtual-netdevice-a.patch | 8 ++++---- ...-resolve-forwarding-path-for-vlan-devices.patch | 2 +- ...resolve-forwarding-path-for-bridge-device.patch | 2 +- ...resolve-forwarding-path-for-VLAN-tag-acti.patch | 4 ++-- ...olve-forwarding-path-for-bridge-pppoe-dev.patch | 4 ++-- ...solve-forwarding-path-for-dsa-slave-ports.patch | 4 ++-- ...lowtable-bridge-vlan-hardware-offload-and.patch | 2 +- .../generic/hack-5.10/250-netfilter_depends.patch | 4 ++-- .../650-netfilter-add-xt_FLOWOFFLOAD-target.patch | 6 +++--- .../hack-5.10/721-net-add-packet-mangeling.patch | 12 ++++++------ .../linux/generic/hack-5.10/902-debloat_proc.patch | 2 +- .../pending-5.10/655-increase_skb_pad.patch | 2 +- ...80-NET-skip-GRO-for-foreign-MAC-addresses.patch | 12 ++++++------ ...t-mtk_eth_soc-implement-flow-offloading-t.patch | 4 ++-- ...x-dev_fill_forward_path-with-pppoe-bridge.patch | 2 +- ...t-IPQ4019-needs-rfs-vlan_tag-callbacks-in.patch | 4 ++-- 24 files changed, 61 insertions(+), 61 deletions(-) diff --git a/include/kernel-5.10 b/include/kernel-5.10 index 8933b1de83..48ee49c920 100644 --- a/include/kernel-5.10 +++ b/include/kernel-5.10 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.10 = .139 -LINUX_KERNEL_HASH-5.10.139 = 1c002ac275a44934a280a158a136735bf6665b26a42d344023b4648a7898bef1 +LINUX_VERSION-5.10 = .141 +LINUX_KERNEL_HASH-5.10.141 = 247afd935f96832eee07e6bcb97b6b0ee41efb4246803c9055df57ad2c1a0ef3 diff --git a/target/linux/ath79/patches-5.10/910-unaligned_access_hacks.patch b/target/linux/ath79/patches-5.10/910-unaligned_access_hacks.patch index 713f01f20f..cd335fbbc8 100644 --- a/target/linux/ath79/patches-5.10/910-unaligned_access_hacks.patch +++ b/target/linux/ath79/patches-5.10/910-unaligned_access_hacks.patch @@ -706,7 +706,7 @@ EXPORT_SYMBOL(xfrm_parse_spi); --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c -@@ -4093,14 +4093,16 @@ static bool tcp_parse_aligned_timestamp( +@@ -4116,14 +4116,16 @@ static bool tcp_parse_aligned_timestamp( { const __be32 *ptr = (const __be32 *)(th + 1); diff --git a/target/linux/generic/backport-5.10/600-v5.12-net-extract-napi-poll-functionality-to-__napi_poll.patch b/target/linux/generic/backport-5.10/600-v5.12-net-extract-napi-poll-functionality-to-__napi_poll.patch index 0a6f33a51e..16c6f3fdc4 100644 --- a/target/linux/generic/backport-5.10/600-v5.12-net-extract-napi-poll-functionality-to-__napi_poll.patch +++ b/target/linux/generic/backport-5.10/600-v5.12-net-extract-napi-poll-functionality-to-__napi_poll.patch @@ -18,7 +18,7 @@ Signed-off-by: David S. Miller --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -6809,15 +6809,10 @@ void __netif_napi_del(struct napi_struct +@@ -6810,15 +6810,10 @@ void __netif_napi_del(struct napi_struct } EXPORT_SYMBOL(__netif_napi_del); @@ -35,7 +35,7 @@ Signed-off-by: David S. Miller weight = n->weight; /* This NAPI_STATE_SCHED test is for avoiding a race -@@ -6837,7 +6832,7 @@ static int napi_poll(struct napi_struct +@@ -6838,7 +6833,7 @@ static int napi_poll(struct napi_struct n->poll, work, weight); if (likely(work < weight)) @@ -44,7 +44,7 @@ Signed-off-by: David S. Miller /* Drivers must not modify the NAPI state if they * consume the entire weight. In such cases this code -@@ -6846,7 +6841,7 @@ static int napi_poll(struct napi_struct +@@ -6847,7 +6842,7 @@ static int napi_poll(struct napi_struct */ if (unlikely(napi_disable_pending(n))) { napi_complete(n); @@ -53,7 +53,7 @@ Signed-off-by: David S. Miller } if (n->gro_bitmask) { -@@ -6864,12 +6859,29 @@ static int napi_poll(struct napi_struct +@@ -6865,12 +6860,29 @@ static int napi_poll(struct napi_struct if (unlikely(!list_empty(&n->poll_list))) { pr_warn_once("%s: Budget exhausted after napi rescheduled\n", n->dev ? n->dev->name : "backlog"); diff --git a/target/linux/generic/backport-5.10/601-v5.12-net-implement-threaded-able-napi-poll-loop-support.patch b/target/linux/generic/backport-5.10/601-v5.12-net-implement-threaded-able-napi-poll-loop-support.patch index 8543b305b5..0443ad4f93 100644 --- a/target/linux/generic/backport-5.10/601-v5.12-net-implement-threaded-able-napi-poll-loop-support.patch +++ b/target/linux/generic/backport-5.10/601-v5.12-net-implement-threaded-able-napi-poll-loop-support.patch @@ -76,7 +76,7 @@ Signed-off-by: David S. Miller /** * napi_synchronize - wait until NAPI is not running -@@ -1842,6 +1832,8 @@ enum netdev_ml_priv_type { +@@ -1856,6 +1846,8 @@ enum netdev_ml_priv_type { * * @wol_enabled: Wake-on-LAN is enabled * @@ -85,7 +85,7 @@ Signed-off-by: David S. Miller * @net_notifier_list: List of per-net netdev notifier block * that follow this device when it is moved * to another network namespace. -@@ -2161,6 +2153,7 @@ struct net_device { +@@ -2175,6 +2167,7 @@ struct net_device { struct lock_class_key *qdisc_running_key; bool proto_down; unsigned wol_enabled:1; @@ -131,7 +131,7 @@ Signed-off-by: David S. Miller static int __dev_open(struct net_device *dev, struct netlink_ext_ack *extack) { const struct net_device_ops *ops = dev->netdev_ops; -@@ -4271,6 +4293,21 @@ int gro_normal_batch __read_mostly = 8; +@@ -4272,6 +4294,21 @@ int gro_normal_batch __read_mostly = 8; static inline void ____napi_schedule(struct softnet_data *sd, struct napi_struct *napi) { @@ -153,7 +153,7 @@ Signed-off-by: David S. Miller list_add_tail(&napi->poll_list, &sd->poll_list); __raise_softirq_irqoff(NET_RX_SOFTIRQ); } -@@ -6762,6 +6799,12 @@ void netif_napi_add(struct net_device *d +@@ -6763,6 +6800,12 @@ void netif_napi_add(struct net_device *d set_bit(NAPI_STATE_NPSVC, &napi->state); list_add_rcu(&napi->dev_list, &dev->napi_list); napi_hash_add(napi); @@ -166,7 +166,7 @@ Signed-off-by: David S. Miller } EXPORT_SYMBOL(netif_napi_add); -@@ -6778,9 +6821,28 @@ void napi_disable(struct napi_struct *n) +@@ -6779,9 +6822,28 @@ void napi_disable(struct napi_struct *n) hrtimer_cancel(&n->timer); clear_bit(NAPI_STATE_DISABLE, &n->state); @@ -195,7 +195,7 @@ Signed-off-by: David S. Miller static void flush_gro_hash(struct napi_struct *napi) { int i; -@@ -6806,6 +6868,11 @@ void __netif_napi_del(struct napi_struct +@@ -6807,6 +6869,11 @@ void __netif_napi_del(struct napi_struct flush_gro_hash(napi); napi->gro_bitmask = 0; @@ -207,7 +207,7 @@ Signed-off-by: David S. Miller } EXPORT_SYMBOL(__netif_napi_del); -@@ -6887,6 +6954,51 @@ static int napi_poll(struct napi_struct +@@ -6888,6 +6955,51 @@ static int napi_poll(struct napi_struct return work; } diff --git a/target/linux/generic/backport-5.10/602-v5.12-net-add-sysfs-attribute-to-control-napi-threaded-mod.patch b/target/linux/generic/backport-5.10/602-v5.12-net-add-sysfs-attribute-to-control-napi-threaded-mod.patch index 9b73f8cbb4..68c9b3339f 100644 --- a/target/linux/generic/backport-5.10/602-v5.12-net-add-sysfs-attribute-to-control-napi-threaded-mod.patch +++ b/target/linux/generic/backport-5.10/602-v5.12-net-add-sysfs-attribute-to-control-napi-threaded-mod.patch @@ -57,7 +57,7 @@ Signed-off-by: David S. Miller * @n: NAPI context --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -4297,8 +4297,9 @@ static inline void ____napi_schedule(str +@@ -4298,8 +4298,9 @@ static inline void ____napi_schedule(str if (test_bit(NAPI_STATE_THREADED, &napi->state)) { /* Paired with smp_mb__before_atomic() in @@ -69,7 +69,7 @@ Signed-off-by: David S. Miller * wake_up_process() when it's not NULL. */ thread = READ_ONCE(napi->thread); -@@ -6772,6 +6773,49 @@ static void init_gro_hash(struct napi_st +@@ -6773,6 +6774,49 @@ static void init_gro_hash(struct napi_st napi->gro_bitmask = 0; } diff --git a/target/linux/generic/backport-5.10/603-v5.12-net-fix-race-between-napi-kthread-mode-and-busy-poll.patch b/target/linux/generic/backport-5.10/603-v5.12-net-fix-race-between-napi-kthread-mode-and-busy-poll.patch index a66198ac80..02973522bc 100644 --- a/target/linux/generic/backport-5.10/603-v5.12-net-fix-race-between-napi-kthread-mode-and-busy-poll.patch +++ b/target/linux/generic/backport-5.10/603-v5.12-net-fix-race-between-napi-kthread-mode-and-busy-poll.patch @@ -45,7 +45,7 @@ Cc: Hannes Frederic Sowa enum gro_result { --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -4304,6 +4304,8 @@ static inline void ____napi_schedule(str +@@ -4305,6 +4305,8 @@ static inline void ____napi_schedule(str */ thread = READ_ONCE(napi->thread); if (thread) { @@ -54,7 +54,7 @@ Cc: Hannes Frederic Sowa wake_up_process(thread); return; } -@@ -6564,7 +6566,8 @@ bool napi_complete_done(struct napi_stru +@@ -6565,7 +6567,8 @@ bool napi_complete_done(struct napi_stru WARN_ON_ONCE(!(val & NAPIF_STATE_SCHED)); @@ -64,7 +64,7 @@ Cc: Hannes Frederic Sowa /* If STATE_MISSED was set, leave STATE_SCHED set, * because we will call napi->poll() one more time. -@@ -7000,16 +7003,25 @@ static int napi_poll(struct napi_struct +@@ -7001,16 +7004,25 @@ static int napi_poll(struct napi_struct static int napi_thread_wait(struct napi_struct *napi) { diff --git a/target/linux/generic/backport-5.10/604-v5.12-net-fix-hangup-on-napi_disable-for-threaded-napi.patch b/target/linux/generic/backport-5.10/604-v5.12-net-fix-hangup-on-napi_disable-for-threaded-napi.patch index c960d1fba4..674f66e732 100644 --- a/target/linux/generic/backport-5.10/604-v5.12-net-fix-hangup-on-napi_disable-for-threaded-napi.patch +++ b/target/linux/generic/backport-5.10/604-v5.12-net-fix-hangup-on-napi_disable-for-threaded-napi.patch @@ -34,7 +34,7 @@ Signed-off-by: Jakub Kicinski --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -7007,7 +7007,7 @@ static int napi_thread_wait(struct napi_ +@@ -7008,7 +7008,7 @@ static int napi_thread_wait(struct napi_ set_current_state(TASK_INTERRUPTIBLE); @@ -43,7 +43,7 @@ Signed-off-by: Jakub Kicinski /* Testing SCHED_THREADED bit here to make sure the current * kthread owns this napi and could poll on this napi. * Testing SCHED bit is not enough because SCHED bit might be -@@ -7025,6 +7025,7 @@ static int napi_thread_wait(struct napi_ +@@ -7026,6 +7026,7 @@ static int napi_thread_wait(struct napi_ set_current_state(TASK_INTERRUPTIBLE); } __set_current_state(TASK_RUNNING); diff --git a/target/linux/generic/backport-5.10/610-v5.13-10-netfilter-nftables-update-table-flags-from-the-commi.patch b/target/linux/generic/backport-5.10/610-v5.13-10-netfilter-nftables-update-table-flags-from-the-commi.patch index eea0aed6aa..f9bb0e2cc3 100644 --- a/target/linux/generic/backport-5.10/610-v5.13-10-netfilter-nftables-update-table-flags-from-the-commi.patch +++ b/target/linux/generic/backport-5.10/610-v5.13-10-netfilter-nftables-update-table-flags-from-the-commi.patch @@ -12,7 +12,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h -@@ -1469,13 +1469,16 @@ struct nft_trans_chain { +@@ -1474,13 +1474,16 @@ struct nft_trans_chain { struct nft_trans_table { bool update; @@ -70,7 +70,7 @@ Signed-off-by: Pablo Neira Ayuso nft_trans_table_update(trans) = true; list_add_tail(&trans->list, &ctx->net->nft.commit_list); return 0; -@@ -7929,11 +7933,10 @@ static int nf_tables_commit(struct net * +@@ -7919,11 +7923,10 @@ static int nf_tables_commit(struct net * switch (trans->msg_type) { case NFT_MSG_NEWTABLE: if (nft_trans_table_update(trans)) { @@ -86,7 +86,7 @@ Signed-off-by: Pablo Neira Ayuso } else { nft_clear(net, trans->ctx.table); } -@@ -8147,11 +8150,9 @@ static int __nf_tables_abort(struct net +@@ -8137,11 +8140,9 @@ static int __nf_tables_abort(struct net switch (trans->msg_type) { case NFT_MSG_NEWTABLE: if (nft_trans_table_update(trans)) { diff --git a/target/linux/generic/backport-5.10/610-v5.13-11-net-resolve-forwarding-path-from-virtual-netdevice-a.patch b/target/linux/generic/backport-5.10/610-v5.13-11-net-resolve-forwarding-path-from-virtual-netdevice-a.patch index a8fc1cabe2..9b0100d6bc 100644 --- a/target/linux/generic/backport-5.10/610-v5.13-11-net-resolve-forwarding-path-from-virtual-netdevice-a.patch +++ b/target/linux/generic/backport-5.10/610-v5.13-11-net-resolve-forwarding-path-from-virtual-netdevice-a.patch @@ -58,7 +58,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -827,6 +827,27 @@ typedef u16 (*select_queue_fallback_t)(s +@@ -841,6 +841,27 @@ typedef u16 (*select_queue_fallback_t)(s struct sk_buff *skb, struct net_device *sb_dev); @@ -86,7 +86,7 @@ Signed-off-by: Pablo Neira Ayuso enum tc_setup_type { TC_SETUP_QDISC_MQPRIO, TC_SETUP_CLSU32, -@@ -1273,6 +1294,8 @@ struct netdev_net_notifier { +@@ -1287,6 +1308,8 @@ struct netdev_net_notifier { * struct net_device *(*ndo_get_peer_dev)(struct net_device *dev); * If a device is paired with a peer device, return the peer instance. * The caller must be under RCU read context. @@ -95,7 +95,7 @@ Signed-off-by: Pablo Neira Ayuso */ struct net_device_ops { int (*ndo_init)(struct net_device *dev); -@@ -1481,6 +1504,8 @@ struct net_device_ops { +@@ -1495,6 +1518,8 @@ struct net_device_ops { int (*ndo_tunnel_ctl)(struct net_device *dev, struct ip_tunnel_parm *p, int cmd); struct net_device * (*ndo_get_peer_dev)(struct net_device *dev); @@ -104,7 +104,7 @@ Signed-off-by: Pablo Neira Ayuso }; /** -@@ -2828,6 +2853,8 @@ void dev_remove_offload(struct packet_of +@@ -2842,6 +2867,8 @@ void dev_remove_offload(struct packet_of int dev_get_iflink(const struct net_device *dev); int dev_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb); diff --git a/target/linux/generic/backport-5.10/610-v5.13-12-net-8021q-resolve-forwarding-path-for-vlan-devices.patch b/target/linux/generic/backport-5.10/610-v5.13-12-net-8021q-resolve-forwarding-path-for-vlan-devices.patch index 32c8c9bb78..4e9a3bfa9f 100644 --- a/target/linux/generic/backport-5.10/610-v5.13-12-net-8021q-resolve-forwarding-path-for-vlan-devices.patch +++ b/target/linux/generic/backport-5.10/610-v5.13-12-net-8021q-resolve-forwarding-path-for-vlan-devices.patch @@ -28,7 +28,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -829,11 +829,18 @@ typedef u16 (*select_queue_fallback_t)(s +@@ -843,11 +843,18 @@ typedef u16 (*select_queue_fallback_t)(s enum net_device_path_type { DEV_PATH_ETHERNET = 0, diff --git a/target/linux/generic/backport-5.10/610-v5.13-13-net-bridge-resolve-forwarding-path-for-bridge-device.patch b/target/linux/generic/backport-5.10/610-v5.13-13-net-bridge-resolve-forwarding-path-for-bridge-device.patch index bdb12b13a6..2433d7e720 100644 --- a/target/linux/generic/backport-5.10/610-v5.13-13-net-bridge-resolve-forwarding-path-for-bridge-device.patch +++ b/target/linux/generic/backport-5.10/610-v5.13-13-net-bridge-resolve-forwarding-path-for-bridge-device.patch @@ -9,7 +9,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -830,6 +830,7 @@ typedef u16 (*select_queue_fallback_t)(s +@@ -844,6 +844,7 @@ typedef u16 (*select_queue_fallback_t)(s enum net_device_path_type { DEV_PATH_ETHERNET = 0, DEV_PATH_VLAN, diff --git a/target/linux/generic/backport-5.10/610-v5.13-14-net-bridge-resolve-forwarding-path-for-VLAN-tag-acti.patch b/target/linux/generic/backport-5.10/610-v5.13-14-net-bridge-resolve-forwarding-path-for-VLAN-tag-acti.patch index ba2b1a2877..0f09dfe06c 100644 --- a/target/linux/generic/backport-5.10/610-v5.13-14-net-bridge-resolve-forwarding-path-for-VLAN-tag-acti.patch +++ b/target/linux/generic/backport-5.10/610-v5.13-14-net-bridge-resolve-forwarding-path-for-VLAN-tag-acti.patch @@ -15,7 +15,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -841,10 +841,20 @@ struct net_device_path { +@@ -855,10 +855,20 @@ struct net_device_path { u16 id; __be16 proto; } encap; @@ -36,7 +36,7 @@ Signed-off-by: Pablo Neira Ayuso struct net_device_path_stack { int num_paths; -@@ -854,6 +864,12 @@ struct net_device_path_stack { +@@ -868,6 +878,12 @@ struct net_device_path_stack { struct net_device_path_ctx { const struct net_device *dev; const u8 *daddr; diff --git a/target/linux/generic/backport-5.10/610-v5.13-15-net-ppp-resolve-forwarding-path-for-bridge-pppoe-dev.patch b/target/linux/generic/backport-5.10/610-v5.13-15-net-ppp-resolve-forwarding-path-for-bridge-pppoe-dev.patch index 712bb9ec97..f9cb8643fb 100644 --- a/target/linux/generic/backport-5.10/610-v5.13-15-net-ppp-resolve-forwarding-path-for-bridge-pppoe-dev.patch +++ b/target/linux/generic/backport-5.10/610-v5.13-15-net-ppp-resolve-forwarding-path-for-bridge-pppoe-dev.patch @@ -83,7 +83,7 @@ Signed-off-by: Pablo Neira Ayuso static int pppoe_recvmsg(struct socket *sock, struct msghdr *m, --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -831,6 +831,7 @@ enum net_device_path_type { +@@ -845,6 +845,7 @@ enum net_device_path_type { DEV_PATH_ETHERNET = 0, DEV_PATH_VLAN, DEV_PATH_BRIDGE, @@ -91,7 +91,7 @@ Signed-off-by: Pablo Neira Ayuso }; struct net_device_path { -@@ -840,6 +841,7 @@ struct net_device_path { +@@ -854,6 +855,7 @@ struct net_device_path { struct { u16 id; __be16 proto; diff --git a/target/linux/generic/backport-5.10/610-v5.13-16-net-dsa-resolve-forwarding-path-for-dsa-slave-ports.patch b/target/linux/generic/backport-5.10/610-v5.13-16-net-dsa-resolve-forwarding-path-for-dsa-slave-ports.patch index 1d3021a575..51d609cde1 100644 --- a/target/linux/generic/backport-5.10/610-v5.13-16-net-dsa-resolve-forwarding-path-for-dsa-slave-ports.patch +++ b/target/linux/generic/backport-5.10/610-v5.13-16-net-dsa-resolve-forwarding-path-for-dsa-slave-ports.patch @@ -10,7 +10,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -832,6 +832,7 @@ enum net_device_path_type { +@@ -846,6 +846,7 @@ enum net_device_path_type { DEV_PATH_VLAN, DEV_PATH_BRIDGE, DEV_PATH_PPPOE, @@ -18,7 +18,7 @@ Signed-off-by: Pablo Neira Ayuso }; struct net_device_path { -@@ -852,6 +853,10 @@ struct net_device_path { +@@ -866,6 +867,10 @@ struct net_device_path { u16 vlan_id; __be16 vlan_proto; } bridge; diff --git a/target/linux/generic/backport-5.10/610-v5.13-27-netfilter-flowtable-bridge-vlan-hardware-offload-and.patch b/target/linux/generic/backport-5.10/610-v5.13-27-netfilter-flowtable-bridge-vlan-hardware-offload-and.patch index 7fa58ba844..015e899253 100644 --- a/target/linux/generic/backport-5.10/610-v5.13-27-netfilter-flowtable-bridge-vlan-hardware-offload-and.patch +++ b/target/linux/generic/backport-5.10/610-v5.13-27-netfilter-flowtable-bridge-vlan-hardware-offload-and.patch @@ -12,7 +12,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -849,6 +849,7 @@ struct net_device_path { +@@ -863,6 +863,7 @@ struct net_device_path { DEV_PATH_BR_VLAN_KEEP, DEV_PATH_BR_VLAN_TAG, DEV_PATH_BR_VLAN_UNTAG, diff --git a/target/linux/generic/hack-5.10/250-netfilter_depends.patch b/target/linux/generic/hack-5.10/250-netfilter_depends.patch index b27b440157..ec01854958 100644 --- a/target/linux/generic/hack-5.10/250-netfilter_depends.patch +++ b/target/linux/generic/hack-5.10/250-netfilter_depends.patch @@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig -@@ -228,7 +228,6 @@ config NF_CONNTRACK_FTP +@@ -227,7 +227,6 @@ config NF_CONNTRACK_FTP config NF_CONNTRACK_H323 tristate "H.323 protocol support" @@ -17,7 +17,7 @@ Signed-off-by: Felix Fietkau depends on NETFILTER_ADVANCED help H.323 is a VoIP signalling protocol from ITU-T. As one of the most -@@ -1072,7 +1071,6 @@ config NETFILTER_XT_TARGET_SECMARK +@@ -1071,7 +1070,6 @@ config NETFILTER_XT_TARGET_SECMARK config NETFILTER_XT_TARGET_TCPMSS tristate '"TCPMSS" target support' diff --git a/target/linux/generic/hack-5.10/650-netfilter-add-xt_FLOWOFFLOAD-target.patch b/target/linux/generic/hack-5.10/650-netfilter-add-xt_FLOWOFFLOAD-target.patch index 7037194eee..b83a185aeb 100644 --- a/target/linux/generic/hack-5.10/650-netfilter-add-xt_FLOWOFFLOAD-target.patch +++ b/target/linux/generic/hack-5.10/650-netfilter-add-xt_FLOWOFFLOAD-target.patch @@ -47,7 +47,7 @@ Signed-off-by: Felix Fietkau depends on !NF_CONNTRACK || NF_CONNTRACK --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig -@@ -683,8 +683,6 @@ config NFT_FIB_NETDEV +@@ -682,8 +682,6 @@ config NFT_FIB_NETDEV endif # NF_TABLES_NETDEV @@ -56,7 +56,7 @@ Signed-off-by: Felix Fietkau config NF_FLOW_TABLE_INET tristate "Netfilter flow table mixed IPv4/IPv6 module" depends on NF_FLOW_TABLE -@@ -693,11 +691,12 @@ config NF_FLOW_TABLE_INET +@@ -692,11 +690,12 @@ config NF_FLOW_TABLE_INET To compile it as a module, choose M here. @@ -70,7 +70,7 @@ Signed-off-by: Felix Fietkau help This option adds the flow table core infrastructure. -@@ -977,6 +976,15 @@ config NETFILTER_XT_TARGET_NOTRACK +@@ -976,6 +975,15 @@ config NETFILTER_XT_TARGET_NOTRACK depends on NETFILTER_ADVANCED select NETFILTER_XT_TARGET_CT diff --git a/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch b/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch index 9ad002e6a4..9c3cfb1885 100644 --- a/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch +++ b/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch @@ -19,7 +19,7 @@ Signed-off-by: Felix Fietkau --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -1625,6 +1625,7 @@ enum netdev_priv_flags { +@@ -1639,6 +1639,7 @@ enum netdev_priv_flags { IFF_FAILOVER_SLAVE = 1<<28, IFF_L3MDEV_RX_HANDLER = 1<<29, IFF_LIVE_RENAME_OK = 1<<30, @@ -27,7 +27,7 @@ Signed-off-by: Felix Fietkau }; #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN -@@ -1657,6 +1658,7 @@ enum netdev_priv_flags { +@@ -1671,6 +1672,7 @@ enum netdev_priv_flags { #define IFF_FAILOVER_SLAVE IFF_FAILOVER_SLAVE #define IFF_L3MDEV_RX_HANDLER IFF_L3MDEV_RX_HANDLER #define IFF_LIVE_RENAME_OK IFF_LIVE_RENAME_OK @@ -35,7 +35,7 @@ Signed-off-by: Felix Fietkau /* Specifies the type of the struct net_device::ml_priv pointer */ enum netdev_ml_priv_type { -@@ -1997,6 +1999,11 @@ struct net_device { +@@ -2011,6 +2013,11 @@ struct net_device { const struct tlsdev_ops *tlsdev_ops; #endif @@ -47,7 +47,7 @@ Signed-off-by: Felix Fietkau const struct header_ops *header_ops; unsigned int flags; -@@ -2087,6 +2094,10 @@ struct net_device { +@@ -2101,6 +2108,10 @@ struct net_device { struct mpls_dev __rcu *mpls_ptr; #endif @@ -60,7 +60,7 @@ Signed-off-by: Felix Fietkau */ --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -2710,6 +2710,10 @@ static inline int pskb_trim(struct sk_bu +@@ -2718,6 +2718,10 @@ static inline int pskb_trim(struct sk_bu return (len < skb->len) ? __pskb_trim(skb, len) : 0; } @@ -71,7 +71,7 @@ Signed-off-by: Felix Fietkau /** * pskb_trim_unique - remove end from a paged unique (not cloned) buffer * @skb: buffer to alter -@@ -2841,16 +2845,6 @@ static inline struct sk_buff *dev_alloc_ +@@ -2849,16 +2853,6 @@ static inline struct sk_buff *dev_alloc_ } diff --git a/target/linux/generic/hack-5.10/902-debloat_proc.patch b/target/linux/generic/hack-5.10/902-debloat_proc.patch index 0838e2c43c..913a5cb132 100644 --- a/target/linux/generic/hack-5.10/902-debloat_proc.patch +++ b/target/linux/generic/hack-5.10/902-debloat_proc.patch @@ -330,7 +330,7 @@ Signed-off-by: Felix Fietkau --- a/net/core/sock.c +++ b/net/core/sock.c -@@ -3699,6 +3699,8 @@ static __net_initdata struct pernet_oper +@@ -3701,6 +3701,8 @@ static __net_initdata struct pernet_oper static int __init proto_init(void) { diff --git a/target/linux/generic/pending-5.10/655-increase_skb_pad.patch b/target/linux/generic/pending-5.10/655-increase_skb_pad.patch index ff39ddb8b3..b9c463d570 100644 --- a/target/linux/generic/pending-5.10/655-increase_skb_pad.patch +++ b/target/linux/generic/pending-5.10/655-increase_skb_pad.patch @@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -2676,7 +2676,7 @@ static inline int pskb_network_may_pull( +@@ -2684,7 +2684,7 @@ static inline int pskb_network_may_pull( * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8) */ #ifndef NET_SKB_PAD diff --git a/target/linux/generic/pending-5.10/680-NET-skip-GRO-for-foreign-MAC-addresses.patch b/target/linux/generic/pending-5.10/680-NET-skip-GRO-for-foreign-MAC-addresses.patch index dceaedb381..5537e3081e 100644 --- a/target/linux/generic/pending-5.10/680-NET-skip-GRO-for-foreign-MAC-addresses.patch +++ b/target/linux/generic/pending-5.10/680-NET-skip-GRO-for-foreign-MAC-addresses.patch @@ -11,7 +11,7 @@ Signed-off-by: Felix Fietkau --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -2036,6 +2036,8 @@ struct net_device { +@@ -2050,6 +2050,8 @@ struct net_device { struct netdev_hw_addr_list mc; struct netdev_hw_addr_list dev_addrs; @@ -32,7 +32,7 @@ Signed-off-by: Felix Fietkau __u16 tc_index; /* traffic control index */ --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -6066,6 +6066,9 @@ static enum gro_result dev_gro_receive(s +@@ -6067,6 +6067,9 @@ static enum gro_result dev_gro_receive(s int same_flow; int grow; @@ -42,7 +42,7 @@ Signed-off-by: Felix Fietkau if (netif_elide_gro(skb->dev)) goto normal; -@@ -8043,6 +8046,48 @@ static void __netdev_adjacent_dev_unlink +@@ -8044,6 +8047,48 @@ static void __netdev_adjacent_dev_unlink &upper_dev->adj_list.lower); } @@ -91,7 +91,7 @@ Signed-off-by: Felix Fietkau static int __netdev_upper_dev_link(struct net_device *dev, struct net_device *upper_dev, bool master, void *upper_priv, void *upper_info, -@@ -8094,6 +8139,7 @@ static int __netdev_upper_dev_link(struc +@@ -8095,6 +8140,7 @@ static int __netdev_upper_dev_link(struc if (ret) return ret; @@ -99,7 +99,7 @@ Signed-off-by: Felix Fietkau ret = call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, &changeupper_info.info); ret = notifier_to_errno(ret); -@@ -8190,6 +8236,7 @@ static void __netdev_upper_dev_unlink(st +@@ -8191,6 +8237,7 @@ static void __netdev_upper_dev_unlink(st __netdev_adjacent_dev_unlink_neighbour(dev, upper_dev); @@ -107,7 +107,7 @@ Signed-off-by: Felix Fietkau call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, &changeupper_info.info); -@@ -8976,6 +9023,7 @@ int dev_set_mac_address(struct net_devic +@@ -8977,6 +9024,7 @@ int dev_set_mac_address(struct net_devic if (err) return err; dev->addr_assign_type = NET_ADDR_SET; diff --git a/target/linux/generic/pending-5.10/701-03-net-ethernet-mtk_eth_soc-implement-flow-offloading-t.patch b/target/linux/generic/pending-5.10/701-03-net-ethernet-mtk_eth_soc-implement-flow-offloading-t.patch index 1193cb0f9d..9b32782903 100644 --- a/target/linux/generic/pending-5.10/701-03-net-ethernet-mtk_eth_soc-implement-flow-offloading-t.patch +++ b/target/linux/generic/pending-5.10/701-03-net-ethernet-mtk_eth_soc-implement-flow-offloading-t.patch @@ -233,7 +233,7 @@ Signed-off-by: Felix Fietkau static inline void --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -833,6 +833,7 @@ enum net_device_path_type { +@@ -847,6 +847,7 @@ enum net_device_path_type { DEV_PATH_BRIDGE, DEV_PATH_PPPOE, DEV_PATH_DSA, @@ -241,7 +241,7 @@ Signed-off-by: Felix Fietkau }; struct net_device_path { -@@ -858,6 +859,12 @@ struct net_device_path { +@@ -872,6 +873,12 @@ struct net_device_path { int port; u16 proto; } dsa; diff --git a/target/linux/generic/pending-5.10/704-02-net-fix-dev_fill_forward_path-with-pppoe-bridge.patch b/target/linux/generic/pending-5.10/704-02-net-fix-dev_fill_forward_path-with-pppoe-bridge.patch index 04698f6d80..0faf1cff25 100644 --- a/target/linux/generic/pending-5.10/704-02-net-fix-dev_fill_forward_path-with-pppoe-bridge.patch +++ b/target/linux/generic/pending-5.10/704-02-net-fix-dev_fill_forward_path-with-pppoe-bridge.patch @@ -40,7 +40,7 @@ Signed-off-by: Felix Fietkau --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -878,7 +878,7 @@ struct net_device_path_stack { +@@ -892,7 +892,7 @@ struct net_device_path_stack { struct net_device_path_ctx { const struct net_device *dev; diff --git a/target/linux/ipq40xx/patches-5.10/703-net-IPQ4019-needs-rfs-vlan_tag-callbacks-in.patch b/target/linux/ipq40xx/patches-5.10/703-net-IPQ4019-needs-rfs-vlan_tag-callbacks-in.patch index 9029e69d85..739a603b07 100644 --- a/target/linux/ipq40xx/patches-5.10/703-net-IPQ4019-needs-rfs-vlan_tag-callbacks-in.patch +++ b/target/linux/ipq40xx/patches-5.10/703-net-IPQ4019-needs-rfs-vlan_tag-callbacks-in.patch @@ -24,7 +24,7 @@ Reviewed-by: Grant Grundler --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h -@@ -765,6 +765,16 @@ struct xps_map { +@@ -779,6 +779,16 @@ struct xps_map { #define XPS_MIN_MAP_ALLOC ((L1_CACHE_ALIGN(offsetof(struct xps_map, queues[1])) \ - sizeof(struct xps_map)) / sizeof(u16)) @@ -41,7 +41,7 @@ Reviewed-by: Grant Grundler /* * This structure holds all XPS maps for device. Maps are indexed by CPU. */ -@@ -1452,6 +1462,9 @@ struct net_device_ops { +@@ -1466,6 +1476,9 @@ struct net_device_ops { const struct sk_buff *skb, u16 rxq_index, u32 flow_id); From 837fd23c80b22c566b40181a28630ac29af8f96e Mon Sep 17 00:00:00 2001 From: John Audia Date: Thu, 8 Sep 2022 06:19:20 -0400 Subject: [PATCH 020/114] kernel: bump 5.10 to 5.10.142 All patches automatically rebased. Signed-off-by: John Audia --- include/kernel-5.10 | 4 ++-- .../patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch | 2 +- ...7-clk-use-clk_core_get_rate_recalc-in-clk_rate_get.patch | 2 +- ...-usb-xhci-add-support-for-performing-fake-doorbell.patch | 6 +++--- .../hack-5.10/780-usb-net-MeigLink_modem_support.patch | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/kernel-5.10 b/include/kernel-5.10 index 48ee49c920..e52f4b1c48 100644 --- a/include/kernel-5.10 +++ b/include/kernel-5.10 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.10 = .141 -LINUX_KERNEL_HASH-5.10.141 = 247afd935f96832eee07e6bcb97b6b0ee41efb4246803c9055df57ad2c1a0ef3 +LINUX_VERSION-5.10 = .142 +LINUX_KERNEL_HASH-5.10.142 = 3f47ebdb9afe152a0c32c1157336ef13fa5cc08ac6d884dfc1f6ddc2b7dba268 diff --git a/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch b/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch index e2b864df99..c995c90402 100644 --- a/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch +++ b/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch @@ -23,7 +23,7 @@ produce a noisy warning. xhci->quirks |= XHCI_RESET_ON_RESUME; --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c -@@ -425,10 +425,14 @@ static int xhci_try_enable_msi(struct us +@@ -427,10 +427,14 @@ static int xhci_try_enable_msi(struct us free_irq(hcd->irq, hcd); hcd->irq = 0; diff --git a/target/linux/at91/patches-5.10/247-clk-use-clk_core_get_rate_recalc-in-clk_rate_get.patch b/target/linux/at91/patches-5.10/247-clk-use-clk_core_get_rate_recalc-in-clk_rate_get.patch index 2e8893645c..6751edec5c 100644 --- a/target/linux/at91/patches-5.10/247-clk-use-clk_core_get_rate_recalc-in-clk_rate_get.patch +++ b/target/linux/at91/patches-5.10/247-clk-use-clk_core_get_rate_recalc-in-clk_rate_get.patch @@ -18,7 +18,7 @@ Signed-off-by: Stephen Boyd --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c -@@ -3106,7 +3106,10 @@ static int clk_rate_get(void *data, u64 +@@ -3105,7 +3105,10 @@ static int clk_rate_get(void *data, u64 { struct clk_core *core = data; diff --git a/target/linux/bcm53xx/patches-5.10/180-usb-xhci-add-support-for-performing-fake-doorbell.patch b/target/linux/bcm53xx/patches-5.10/180-usb-xhci-add-support-for-performing-fake-doorbell.patch index b51419c9b8..d6c206a5cd 100644 --- a/target/linux/bcm53xx/patches-5.10/180-usb-xhci-add-support-for-performing-fake-doorbell.patch +++ b/target/linux/bcm53xx/patches-5.10/180-usb-xhci-add-support-for-performing-fake-doorbell.patch @@ -40,7 +40,7 @@ it on BCM4708 family. /* called during probe() after chip reset completes */ --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c -@@ -156,6 +156,49 @@ int xhci_start(struct xhci_hcd *xhci) +@@ -158,6 +158,49 @@ int xhci_start(struct xhci_hcd *xhci) return ret; } @@ -90,7 +90,7 @@ it on BCM4708 family. /* * Reset a halted HC. * -@@ -606,10 +649,20 @@ static int xhci_init(struct usb_hcd *hcd +@@ -608,10 +651,20 @@ static int xhci_init(struct usb_hcd *hcd static int xhci_run_finished(struct xhci_hcd *xhci) { @@ -114,7 +114,7 @@ it on BCM4708 family. xhci->shared_hcd->state = HC_STATE_RUNNING; xhci->cmd_ring_state = CMD_RING_STATE_RUNNING; -@@ -619,6 +672,10 @@ static int xhci_run_finished(struct xhci +@@ -621,6 +674,10 @@ static int xhci_run_finished(struct xhci xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Finished xhci_run for USB3 roothub"); return 0; diff --git a/target/linux/generic/hack-5.10/780-usb-net-MeigLink_modem_support.patch b/target/linux/generic/hack-5.10/780-usb-net-MeigLink_modem_support.patch index 344ba809a9..0c0739e7eb 100644 --- a/target/linux/generic/hack-5.10/780-usb-net-MeigLink_modem_support.patch +++ b/target/linux/generic/hack-5.10/780-usb-net-MeigLink_modem_support.patch @@ -19,7 +19,7 @@ #define QUECTEL_VENDOR_ID 0x2c7c /* These Quectel products use Quectel's vendor ID */ -@@ -1133,6 +1135,11 @@ static const struct usb_device_id option +@@ -1140,6 +1142,11 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95, 0xff, 0, 0) }, { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), .driver_info = RSVD(4) }, From 0a79c77a4e9d33d352974874a8860c7412e49bd5 Mon Sep 17 00:00:00 2001 From: Andrey Butirsky Date: Thu, 8 Sep 2022 01:19:35 +0300 Subject: [PATCH 021/114] ramips: add support for Kroks Rt-Pot mXw DS RSIM router Aka "Kroks KNdRt31R19". Ported from v19.07.8 of OpenWrt fork: see https://github.com/kroks-free/openwrt for support of other models. Device specs: - CPU: MediaTek MT7628AN - Flash: 16MB SPI NOR - RAM: 64MB - Bootloader: U-Boot - Ethernet: 1x 10/100 Mbps - 2.4 GHz: b/g/n SoC - mPCIe: 1x (usually equipped with an LTE modem by vendor) - Buttons: reset - LEDs: 1x Modem, 1x Injector, 1x Wi-Fi, 1x Status Flashing: - sysupgrade image via stock firmware WEB interface. - U-Boot launches a WEB server if Reset button is held during power up. Server IP: 192.168.1.1 SIM card switching: The device supports up to 4 SIM cards - 2 locally on board and 2 on remote SIM-injector. By default, 1-st local SIM is active. To switch to e.g. 1-st remote SIM: echo 0 > /sys/class/gpio/modem1power/value echo 0 > /sys/class/gpio/modem1sim1/value echo 1 > /sys/class/gpio/modem1rsim1/value echo 1 > /sys/class/gpio/modem1power/value MAC addresses as verified by OEM firmware: vendor OpenWrt source LAN eth0 factory 0x4 (label) 2g wlan0 label Signed-off-by: Kroks [butirsky@gmail.com: port to master; drop dts-v1] Signed-off-by: Andrey Butirsky --- package/boot/uboot-envtools/files/ramips | 1 + target/linux/ramips/dts/mt7628an_kroks.dtsi | 116 ++++++++++++++++++ .../ramips/dts/mt7628an_kroks_kndrt31r19.dts | 64 ++++++++++ target/linux/ramips/image/mt76x8.mk | 11 ++ .../mt76x8/base-files/etc/board.d/02_network | 1 + 5 files changed, 193 insertions(+) create mode 100644 target/linux/ramips/dts/mt7628an_kroks.dtsi create mode 100644 target/linux/ramips/dts/mt7628an_kroks_kndrt31r19.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 597baef6cd..e27fed7b69 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -37,6 +37,7 @@ beeline,smartbox-turbo) ;; buffalo,wsr-1166dhp|\ buffalo,wsr-600dhp|\ +kroks,kndrt31r19|\ mediatek,linkit-smart-7688|\ samknows,whitebox-v8|\ xiaomi,mi-router-4c|\ diff --git a/target/linux/ramips/dts/mt7628an_kroks.dtsi b/target/linux/ramips/dts/mt7628an_kroks.dtsi new file mode 100644 index 0000000000..dc1eee9cca --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_kroks.dtsi @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7628an.dtsi" + +#include +#include + +/ { + aliases { + led-boot = &led_status; + led-failsafe = &led_status; + led-running = &led_status; + led-upgrade = &led_status; + serial1 = &uart1; + }; + + leds { + compatible = "gpio-leds"; + + led_status: status { + label = "led:status"; + gpios = <&gpio 2 GPIO_ACTIVE_LOW>; + }; + + wifi { + label = "led:wifi"; + gpios = <&gpio 44 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + m25p,fast-read; + + partitions: partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0xfb0000>; + }; + }; + }; +}; + +&state_default { + gpio_reset { + groups = "wdt"; + function = "gpio"; + }; + + p0led_an { + groups = "p0led_an"; + function = "p0led_an"; + }; +}; + +&factory { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_4: macaddr@4 { + reg = <0x4 0x6>; + }; +}; + +ðernet { + nvmem-cells = <&macaddr_factory_4>; + nvmem-cell-names = "mac-address"; +}; + +&wmac { + status = "okay"; + + mediatek,mtd-eeprom = <&factory 0x0000>; +}; + +&uart1 { + status = "okay"; +}; diff --git a/target/linux/ramips/dts/mt7628an_kroks_kndrt31r19.dts b/target/linux/ramips/dts/mt7628an_kroks_kndrt31r19.dts new file mode 100644 index 0000000000..eb36c986f6 --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_kroks_kndrt31r19.dts @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7628an_kroks.dtsi" + +/ { + compatible = "kroks,kndrt31r19", "mediatek,mt7628an-soc"; + model = "Kroks KNdRt31R19"; + + leds { + status { + label = "red:status"; + }; + + wifi { + label = "yellow:wifi"; + }; + }; + + gpio_export { + compatible = "gpio-export"; + #size-cells = <0>; + + modem1power { + gpio-export,name = "modem1power"; + gpio-export,output = <0>; + gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + }; + + modem1sim1 { + gpio-export,name = "modem1sim1"; + gpio-export,output = <1>; + gpios = <&gpio 3 GPIO_ACTIVE_HIGH>; + }; + + modem1sim2 { + gpio-export,name = "modem1sim2"; + gpio-export,output = <0>; + gpios = <&gpio 4 GPIO_ACTIVE_HIGH>; + }; + + modem1rsim1 { + gpio-export,name = "modem1rsim1"; + gpio-export,output = <0>; + gpios = <&gpio 39 GPIO_ACTIVE_HIGH>; + }; + + modem1rsim2 { + gpio-export,name = "modem1rsim2"; + gpio-export,output = <0>; + gpios = <&gpio 40 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&esw { + mediatek,portmap = <0x2f>; +}; + +&state_default { + gpio { + groups = "i2s", "i2c", "p4led_an", "p3led_an", "wled_an"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk index 21126c32d9..ecb4075d62 100644 --- a/target/linux/ramips/image/mt76x8.mk +++ b/target/linux/ramips/image/mt76x8.mk @@ -310,6 +310,17 @@ define Device/jotale_js76x8-32m endef TARGET_DEVICES += jotale_js76x8-32m +define Device/kroks_kndrt31r19 + IMAGE_SIZE := 16064k + DEVICE_VENDOR := Kroks + DEVICE_MODEL := Rt-Pot mXw DS RSIM + DEVICE_ALT0_VENDOR := Kroks + DEVICE_ALT0_MODEL := KNdRt31R19 + DEVICE_PACKAGES := kmod-usb2 uqmi + SUPPORTED_DEVICES += kndrt31r19 +endef +TARGET_DEVICES += kroks_kndrt31r19 + define Device/mediatek_linkit-smart-7688 IMAGE_SIZE := 32448k DEVICE_VENDOR := MediaTek diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network index 1c3d43d821..5c63f1e1b6 100644 --- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network @@ -131,6 +131,7 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0" ;; + kroks,kndrt31r19|\ tplink,tl-mr3020-v3) ucidef_add_switch "switch0" \ "0:lan" "6@eth0" From 5806914794b22cd7ff6c47bed9b54e0a5c4234f3 Mon Sep 17 00:00:00 2001 From: Andrey Butirsky Date: Tue, 7 Dec 2021 17:37:48 +0300 Subject: [PATCH 022/114] ramips: add support for Kroks Rt-Cse SIM Injector DS Aka Kroks Rt-Cse5 UW DRSIM (KNdRt31R16), ID 1958: https://kroks.ru/search/?text=1958 See Kroks OpenWrt fork for support of other models: https://github.com/kroks-free/openwrt Device specs: - CPU: MediaTek MT7628AN - Flash: 16MB SPI NOR - RAM: 64MB - Bootloader: U-Boot - Ethernet: 5x 10/100 Mbps - 2.4 GHz: b/g/n SoC - USB: 1x - SIM-reader: 2x (driven by a dedicated chip with it's own firmware) - Buttons: reset - LEDs: 1x Power, 1x Wi-Fi, 12x others (SIM status, Internet, etc.) Flashing: - sysupgrade image via stock firmware WEB interface, IP: 192.168.1.254 - U-Boot launches a WEB server if Reset button is held during power up, IP: 192.168.1.1 MAC addresses as verified by OEM firmware: vendor OpenWrt source LAN eth0 factory 0x4 (label) 2g wlan0 label Signed-off-by: Andrey Butirsky --- package/boot/uboot-envtools/files/ramips | 1 + .../ramips/dts/mt7628an_kroks_kndrt31r16.dts | 61 +++++++++++++++++++ target/linux/ramips/image/mt76x8.mk | 11 ++++ .../mt76x8/base-files/etc/board.d/02_network | 1 + 4 files changed, 74 insertions(+) create mode 100644 target/linux/ramips/dts/mt7628an_kroks_kndrt31r16.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index e27fed7b69..3f36cd6d68 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -37,6 +37,7 @@ beeline,smartbox-turbo) ;; buffalo,wsr-1166dhp|\ buffalo,wsr-600dhp|\ +kroks,kndrt31r16|\ kroks,kndrt31r19|\ mediatek,linkit-smart-7688|\ samknows,whitebox-v8|\ diff --git a/target/linux/ramips/dts/mt7628an_kroks_kndrt31r16.dts b/target/linux/ramips/dts/mt7628an_kroks_kndrt31r16.dts new file mode 100644 index 0000000000..b0b41f0420 --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_kroks_kndrt31r16.dts @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7628an_kroks.dtsi" + +/ { + compatible = "kroks,kndrt31r16", "mediatek,mt7628an-soc"; + model = "Kroks KNdRt31R16"; + + leds { + status { + label = "green:status"; + gpios = <&gpio 2 GPIO_ACTIVE_HIGH>; + }; + + wifi { + label = "blue:wifi"; + }; + }; + + gpio_export { + compatible = "gpio-export"; + #size-cells = <0>; + + usb1power { + gpio-export,name = "usb1power"; + gpio-export,output = <1>; + gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&esw { + mediatek,portmap = <0x3e>; +}; + +&state_default { + gpio { + groups = "i2s", "wled_an"; + function = "gpio"; + }; + + p1led_an { + groups = "p1led_an"; + function = "p1led_an"; + }; + + p2led_an { + groups = "p2led_an"; + function = "p2led_an"; + }; + + p3led_an { + groups = "p3led_an"; + function = "p3led_an"; + }; + + p4led_an { + groups = "p4led_an"; + function = "p4led_an"; + }; +}; diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk index ecb4075d62..69815f1858 100644 --- a/target/linux/ramips/image/mt76x8.mk +++ b/target/linux/ramips/image/mt76x8.mk @@ -310,6 +310,17 @@ define Device/jotale_js76x8-32m endef TARGET_DEVICES += jotale_js76x8-32m +define Device/kroks_kndrt31r16 + IMAGE_SIZE := 16064k + DEVICE_VENDOR := Kroks + DEVICE_MODEL := Rt-Cse5 UW DRSIM + DEVICE_ALT0_VENDOR := Kroks + DEVICE_ALT0_MODEL := KNdRt31R16 + DEVICE_PACKAGES := kmod-usb2 + SUPPORTED_DEVICES += kndrt31r16 +endef +TARGET_DEVICES += kroks_kndrt31r16 + define Device/kroks_kndrt31r19 IMAGE_SIZE := 16064k DEVICE_VENDOR := Kroks diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network index 5c63f1e1b6..963a20c653 100644 --- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network @@ -39,6 +39,7 @@ ramips_setup_interfaces() hilink,hlk-7628n|\ hilink,hlk-7688a|\ hiwifi,hc5861b|\ + kroks,kndrt31r16|\ skylab,skw92a|\ tplink,archer-c20-v4|\ tplink,archer-c20-v5|\ From fe609889e2f0f60f21bd36a05eb5ea7fee61bd1a Mon Sep 17 00:00:00 2001 From: Ray Wang Date: Wed, 31 Aug 2022 21:32:10 +0800 Subject: [PATCH 023/114] ramips: add RT-N600 alternative name to RT-AC1200 RT-N600 is internally the same as RT-AC1200, as veryfied by @russinnes . Adding alt_name so that people can find it in firmware selector. Signed-off-by: Ray Wang Tested-by: Russ Innes --- target/linux/ramips/image/mt76x8.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk index 69815f1858..100d5d9c6c 100644 --- a/target/linux/ramips/image/mt76x8.mk +++ b/target/linux/ramips/image/mt76x8.mk @@ -42,6 +42,8 @@ define Device/asus_rt-ac1200 IMAGE_SIZE := 16064k DEVICE_VENDOR := Asus DEVICE_MODEL := RT-AC1200 + DEVICE_ALT0_VENDOR := Asus + DEVICE_ALT0_MODEL := RT-N600 DEVICE_PACKAGES := kmod-mt76x2 kmod-usb2 kmod-usb-ohci \ kmod-usb-ledtrig-usbport endef From 26a6a6a60ba74875b5ef819ac5765d3bcbbb930e Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 22 Mar 2021 14:06:14 -0700 Subject: [PATCH 024/114] ramips: add support for Belkin RT1800 Belkin RT1800 is an 802.11ax (Wi-Fi 6) router, based on MediaTek MT7621A. Specifications: - SoC: MT7621 (880MHz, 2 Cores) - RAM: 256 MB - Flash: 128 MB NAND - Wi-Fi: - MT7915D: 2.4/5 GHz (DBDC) - Ethernet: 5x 1GiE MT7530 - USB: 1x USB 3.0 - UART: J4 (57600 baud) - Pinout: [3V3] (TXD) (RXD) (blank) (GND) Notes: * This device has a dual-boot partition scheme, but this firmware works only on boot partition 1. Installation: Upload the generated factory.bin image via the stock web firmware updater. Signed-off-by: Rosen Penev --- package/boot/uboot-envtools/files/ramips | 1 + .../linux/ramips/dts/mt7621_belkin_rt1800.dts | 165 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 45 +++++ .../mt7621/base-files/etc/board.d/01_leds | 3 + .../mt7621/base-files/etc/board.d/02_network | 5 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 5 + .../mt7621/base-files/etc/init.d/bootcount | 1 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 8 files changed, 226 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_belkin_rt1800.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 3f36cd6d68..46c218c885 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -47,6 +47,7 @@ zbtlink,zbt-wg2626|\ zte,mf283plus) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000" ;; +belkin,rt1800|\ h3c,tx1800-plus|\ h3c,tx1801-plus|\ h3c,tx1806|\ diff --git a/target/linux/ramips/dts/mt7621_belkin_rt1800.dts b/target/linux/ramips/dts/mt7621_belkin_rt1800.dts new file mode 100644 index 0000000000..7bf7d89445 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_belkin_rt1800.dts @@ -0,0 +1,165 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include +#include + +/ { + compatible = "belkin,rt1800", "mediatek,mt7621-soc"; + model = "Belkin RT1800"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: led-power { + label = "white:power"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + led-wan { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&switch0 0 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "Boot"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "Config"; + reg = <0x80000 0x80000>; + }; + + factory: partition@100000 { + label = "Factory"; + reg = <0x100000 0x80000>; + read-only; + }; + + partition@180000 { + label = "firmware"; + reg = <0x180000 0x3000000>; + + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "kernel"; + reg = <0x0 0x400000>; + }; + + partition@400000 { + label = "ubi"; + reg = <0x400000 0x2c00000>; + }; + }; + + partition@3180000 { + label = "alt_firmware"; + reg = <0x3180000 0x3000000>; + read-only; + }; + + partition@6180000 { + label = "cbtinfo"; + reg = <0x6180000 0x80000>; + read-only; + }; + /* seems to be the end here. Can't read past 0x6200000 */ + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + }; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy0>; +}; + +&mdio { + ethphy0: ethernet-phy@0 { + reg = <0>; + }; +}; + +&switch0 { + gpio-controller; + #gpio-cells = <2>; + + ports { + port@1 { + status = "okay"; + label = "lan4"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@3 { + status = "okay"; + label = "lan2"; + }; + + port@4 { + status = "okay"; + label = "lan1"; + }; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index dbafaaddde..974299f26b 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -70,6 +70,30 @@ define Build/iodata-mstc-header ) endef +define Build/belkin-header + $(eval magic=$(word 1,$(1))) + $(eval hw_ver=$(word 2,$(1))) + $(eval fw_ver=$(word 3,$(1))) + + ( \ + type_fw_date=$$(printf "01%02x%02x%02x" \ + $$(date -d "@$(SOURCE_DATE_EPOCH)" "+%y %m %d")); \ + hw_fw_ver=$$(printf "%02x%02x%02x%02x" \ + $(hw_ver) $$(echo $(fw_ver) | cut -d. -f-3 | tr . ' ')); \ + fw_len_crc=$$(gzip -c $@ | tail -c 8 | od -An -tx8 | tr -d ' \n'); \ + fw_crc_len="$${fw_len_crc:8:8}$${fw_len_crc:0:8}"; \ + \ + printf "$(magic)" | dd bs=4 count=1 conv=sync 2>/dev/null; \ + printf "$$(echo $${type_fw_date}$${hw_fw_ver} | \ + sed 's/../\\x&/g')"; \ + printf "$$(echo $${fw_crc_len}$${fw_crc_len} | \ + sed 's/../\\x&/g')"; \ + printf "\x5c\x78\x00\x00"; \ + cat $@; \ + ) > $@.new + mv $@.new $@ +endef + define Build/ubnt-erx-factory-image if [ -e $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) -a "$$(stat -c%s $@)" -lt "$(KERNEL_SIZE)" ]; then \ echo '21001:7' > $(1).compat; \ @@ -341,6 +365,27 @@ define Device/beeline_smartbox-turbo endef TARGET_DEVICES += beeline_smartbox-turbo +define Device/belkin_rt1800 + $(Device/dsa-migration) + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 4096k + IMAGE_SIZE := 49152k + DEVICE_VENDOR := Belkin + DEVICE_MODEL := RT1800 + DEVICE_PACKAGES := kmod-mt7915e kmod-usb3 uboot-envtools + UBINIZE_OPTS := -E 5 + KERNEL_LOADADDR := 0x82000000 + KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \ + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | \ + append-squashfs4-fakeroot + IMAGES += factory.bin + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | \ + append-ubi | check-size | belkin-header RT18 1 9.9.9 +endef +TARGET_DEVICES += belkin_rt1800 + define Device/buffalo_wsr-1166dhp $(Device/dsa-migration) $(Device/uimage-lzma-loader) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 5e1e707930..aebdcd5ad9 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -28,6 +28,9 @@ beeline,smartbox-giga|\ beeline,smartbox-turbo) ucidef_set_led_netdev "wan" "wan" "blue:wan" "wan" ;; +belkin,rt1800) + ucidef_set_led_netdev "wan" "wan" "white:wan" "wan" + ;; cudy,wr2100) ucidef_set_led_netdev "lan1" "lan1" "green:lan1" "lan1" ucidef_set_led_netdev "lan2" "lan2" "green:lan2" "lan2" diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 1fa6182c4d..5b9eca0779 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -205,6 +205,11 @@ ramips_setup_macs() wan_mac=$lan_mac label_mac=$lan_mac ;; + belkin,rt1800) + lan_mac=$(mtd_get_mac_ascii Config lan_hwaddr) + wan_mac=$(mtd_get_mac_ascii Config wan_hwaddr) + label_mac=$lan_mac + ;; mikrotik,routerboard-750gr3|\ mikrotik,routerboard-760igs|\ mikrotik,routerboard-m11g|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index d1ce370cad..98bc6c1ccf 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -84,6 +84,11 @@ case "$board" in [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress ;; + belkin,rt1800) + hw_mac_addr=$(mtd_get_mac_ascii Config wan_hwaddr) + [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress + ;; netgear,wax202) hw_mac_addr=$(mtd_get_mac_ascii Config mac) [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress diff --git a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount index 14e32f2968..a77fc41f07 100755 --- a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount @@ -22,6 +22,7 @@ boot() { linksys,ea8100-v2) mtd resetbc s_env || true ;; + belkin,rt1800|\ samknows,whitebox-v8) fw_setenv bootcount 0 ;; diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 7eb86b31de..997b4d35ff 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -57,6 +57,7 @@ platform_do_upgrade() { beeline,smartbox-flash|\ beeline,smartbox-giga|\ beeline,smartbox-turbo|\ + belkin,rt1800|\ dlink,dir-1960-a1|\ dlink,dir-2640-a1|\ dlink,dir-2660-a1|\ From f4eef5f2a18400bc7f548d629e1d5825a2b26e5a Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 22 Mar 2021 14:06:14 -0700 Subject: [PATCH 025/114] ramips: add support for Linksys E7350 Linksys E7350 is an 802.11ax (Wi-Fi 6) router, based on MediaTek MT7621A. Specifications: - SoC: MT7621 (880MHz, 2 Cores) - RAM: 256 MB - Flash: 128 MB NAND - Wi-Fi: - MT7915D: 2.4/5 GHz (DBDC) - Ethernet: 5x 1GiE MT7530 - USB: 1x USB 3.0 - UART: J4 (57600 baud) - Pinout: [3V3] (TXD) (RXD) (blank) (GND) Notes: * This device has a dual-boot partition scheme, but this firmware works only on boot partition 1. Installation: Upload the generated factory.bin image via the stock web firmware updater. Signed-off-by: Rosen Penev --- package/boot/uboot-envtools/files/ramips | 1 + .../linux/ramips/dts/mt7621_linksys_e7350.dts | 205 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 9 + .../mt7621/base-files/etc/board.d/01_leds | 7 + .../mt7621/base-files/etc/board.d/02_network | 3 +- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 3 +- .../mt7621/base-files/etc/init.d/bootcount | 1 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 8 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_linksys_e7350.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 46c218c885..194f6561d4 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -52,6 +52,7 @@ h3c,tx1800-plus|\ h3c,tx1801-plus|\ h3c,tx1806|\ jcg,q20|\ +linksys,e7350|\ netgear,wax202) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" ;; diff --git a/target/linux/ramips/dts/mt7621_linksys_e7350.dts b/target/linux/ramips/dts/mt7621_linksys_e7350.dts new file mode 100644 index 0000000000..0cdfcb4683 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_linksys_e7350.dts @@ -0,0 +1,205 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include +#include + +/ { + compatible = "linksys,e7350", "mediatek,mt7621-soc"; + model = "Linksys E7350"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led-wps { + color = ; + function = LED_FUNCTION_WPS; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + led_power: led-power { + label = "blue:power"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + led-wan { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + + led-wan2 { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&switch0 0 GPIO_ACTIVE_LOW>; + }; + + led-lan4 { + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <4>; + gpios = <&switch0 3 GPIO_ACTIVE_LOW>; + }; + + led-lan3 { + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <3>; + gpios = <&switch0 6 GPIO_ACTIVE_LOW>; + }; + + led-lan2 { + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <2>; + gpios = <&switch0 9 GPIO_ACTIVE_HIGH>; + }; + + led-lan1 { + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + gpios = <&switch0 12 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "Boot"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "Config"; + reg = <0x80000 0x80000>; + }; + + factory: partition@100000 { + label = "Factory"; + reg = <0x100000 0x80000>; + read-only; + }; + + partition@180000 { + label = "firmware"; + reg = <0x180000 0x3000000>; + + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "kernel"; + reg = <0x0 0x400000>; + }; + + partition@400000 { + label = "ubi"; + reg = <0x400000 0x2c00000>; + }; + }; + + partition@3180000 { + label = "alt_firmware"; + reg = <0x3180000 0x3000000>; + read-only; + }; + + partition@6180000 { + label = "cbtinfo"; + reg = <0x6180000 0x80000>; + read-only; + }; + /* seems to be the end here. Can't read past 0x6200000 */ + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + }; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy0>; +}; + +&mdio { + ethphy0: ethernet-phy@0 { + reg = <0>; + }; +}; + +&switch0 { + gpio-controller; + #gpio-cells = <2>; + + ports { + port@1 { + status = "okay"; + label = "lan4"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@3 { + status = "okay"; + label = "lan2"; + }; + + port@4 { + status = "okay"; + label = "lan1"; + }; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 974299f26b..661f44d5e9 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1192,6 +1192,15 @@ define Device/linksys_e5600 endef TARGET_DEVICES += linksys_e5600 +define Device/linksys_e7350 + $(Device/belkin_rt1800) + DEVICE_VENDOR := Linksys + DEVICE_MODEL := E7350 + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | \ + append-ubi | check-size | belkin-header GOLF 1 9.9.9 +endef +TARGET_DEVICES += linksys_e7350 + define Device/linksys_ea7xxx $(Device/dsa-migration) $(Device/uimage-lzma-loader) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index aebdcd5ad9..0ac67e9670 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -75,6 +75,13 @@ gnubee,gb-pc2) linksys,e5600) ucidef_set_led_netdev "wan" "wan link" "blue:wan" "wan" "link" ;; +linksys,e7350) + ucidef_set_led_netdev "lan1" "lan1" "blue:lan-1" "lan1" + ucidef_set_led_netdev "lan2" "lan2" "blue:lan-2" "lan2" + ucidef_set_led_netdev "lan3" "lan4" "blue:lan-3" "lan3" + ucidef_set_led_netdev "lan4" "lan4" "blue:lan-4" "lan4" + ucidef_set_led_netdev "wan" "wan" "blue:wan" "wan" + ;; linksys,ea6350-v4|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 5b9eca0779..f3913a1d1c 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -205,7 +205,8 @@ ramips_setup_macs() wan_mac=$lan_mac label_mac=$lan_mac ;; - belkin,rt1800) + belkin,rt1800|\ + linksys,e7350) lan_mac=$(mtd_get_mac_ascii Config lan_hwaddr) wan_mac=$(mtd_get_mac_ascii Config wan_hwaddr) label_mac=$lan_mac diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index 98bc6c1ccf..3c2872ae2c 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -84,7 +84,8 @@ case "$board" in [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress ;; - belkin,rt1800) + belkin,rt1800|\ + linksys,e7350) hw_mac_addr=$(mtd_get_mac_ascii Config wan_hwaddr) [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress diff --git a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount index a77fc41f07..99b318a922 100755 --- a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount @@ -23,6 +23,7 @@ boot() { mtd resetbc s_env || true ;; belkin,rt1800|\ + linksys,e7350|\ samknows,whitebox-v8) fw_setenv bootcount 0 ;; diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 997b4d35ff..05907536fe 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -71,6 +71,7 @@ platform_do_upgrade() { iptime,t5004|\ jcg,q20|\ linksys,e5600|\ + linksys,e7350|\ linksys,ea6350-v4|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ From 2f496c34b6dfbedbfbff8d2ade5d629f096e40bd Mon Sep 17 00:00:00 2001 From: Josef Schlehofer Date: Tue, 6 Sep 2022 13:17:02 +0200 Subject: [PATCH 026/114] mpc85xx: add patch to fix gpio mpc8xxx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backports patch, which is currently on review [1] for kernel 5.10 and kernel 5.15, where it applies cleanly. This was tested on CZ.NIC Turris 1.1 router running OpenWrt 21.02.03 with kernel 5.15. Before: - In /var/log/messages: ``` [ 16.392988] lm90 0-004c: cannot request IRQ 48 [ 16.398280] lm90: probe of 0-004c failed with error -22 ``` - Sensors does not work: ``` root@turris:~# sensors No sensors found! Make sure you loaded all the kernel drivers you need. Try sensors-detect to find out which these are. ``` After: ``` root@turris:/# sensors sa56004-i2c-0-4c Adapter: MPC adapter (i2c@3000) temp1: +44.0°C (low = +0.0°C, high = +70.0°C) (crit = +85.0°C, hyst = +75.0°C) temp2: +73.8°C (low = +0.0°C, high = +70.0°C) ALARM (HIGH) (crit = +85.0°C, hyst = +75.0°C) ``` [1] https://lore.kernel.org/linux-gpio/20220906105431.30911-1-pali@kernel.org/ Signed-off-by: Josef Schlehofer --- ...-support-for-IRQ_TYPE_LEVEL_LOW-flow.patch | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 target/linux/mpc85xx/patches-5.10/110-gpio-mpc8xxx-Fix-support-for-IRQ_TYPE_LEVEL_LOW-flow.patch diff --git a/target/linux/mpc85xx/patches-5.10/110-gpio-mpc8xxx-Fix-support-for-IRQ_TYPE_LEVEL_LOW-flow.patch b/target/linux/mpc85xx/patches-5.10/110-gpio-mpc8xxx-Fix-support-for-IRQ_TYPE_LEVEL_LOW-flow.patch new file mode 100644 index 0000000000..38ae4e08e6 --- /dev/null +++ b/target/linux/mpc85xx/patches-5.10/110-gpio-mpc8xxx-Fix-support-for-IRQ_TYPE_LEVEL_LOW-flow.patch @@ -0,0 +1,37 @@ +From 29af30435022442ec4eccf3166956b8e0b8a2134 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pali=20Roh=C3=A1r?= +Date: Mon, 5 Sep 2022 23:13:47 +0200 +Subject: [PATCH] gpio: mpc8xxx: Fix support for IRQ_TYPE_LEVEL_LOW flow_type + in mpc85xx +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit e39d5ef67804 ("powerpc/5xxx: extend mpc8xxx_gpio driver to support +mpc512x gpios") implemented support for IRQ_TYPE_LEVEL_LOW flow type in +mpc512x via falling edge type. Do same for mpc85xx which support was added +in commit 345e5c8a1cc3 ("powerpc: Add interrupt support to mpc8xxx_gpio"). + +Fixes probing of lm90 hwmon driver on mpc85xx based board which use level +interrupt. Without it kernel prints error and refuse lm90 to work: + + [ 15.258370] genirq: Setting trigger mode 8 for irq 49 failed (mpc8xxx_irq_set_type+0x0/0xf8) + [ 15.267168] lm90 0-004c: cannot request IRQ 49 + [ 15.272708] lm90: probe of 0-004c failed with error -22 + +Fixes: 345e5c8a1cc3 ("powerpc: Add interrupt support to mpc8xxx_gpio") +Signed-off-by: Pali Rohár +--- + drivers/gpio/gpio-mpc8xxx.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/gpio/gpio-mpc8xxx.c ++++ b/drivers/gpio/gpio-mpc8xxx.c +@@ -169,6 +169,7 @@ static int mpc8xxx_irq_set_type(struct i + + switch (flow_type) { + case IRQ_TYPE_EDGE_FALLING: ++ case IRQ_TYPE_LEVEL_LOW: + raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); + gc->write_reg(mpc8xxx_gc->regs + GPIO_ICR, + gc->read_reg(mpc8xxx_gc->regs + GPIO_ICR) From 9efbcdfdeeef430f654ef1bc47a1e80bf6289ae4 Mon Sep 17 00:00:00 2001 From: Martin Kennedy Date: Sun, 28 Aug 2022 00:05:46 -0400 Subject: [PATCH 027/114] mpc85xx: Make AP3825i boot env partition writable End-users may need to be able to rewrite u-boot configuration on the WS-AP3825i, which has had repeated issues with the exact configuration of u-boot, e.g. commit 1d06277407 ("mpc85xx: Fix output location of padded dtb") (alongside other failures documented for example in this post[^1] from the main AP3825i porting thread). To assist with this, remove the `read-only` property from the u-boot configuration partitions cfg1 and cfg2. [^1]: https://forum.openwrt.org/t/adding-openwrt-support-for-ws-ap3825i/101168/107 Signed-off-by: Martin Kennedy --- target/linux/mpc85xx/files/arch/powerpc/boot/dts/ws-ap3825i.dts | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/linux/mpc85xx/files/arch/powerpc/boot/dts/ws-ap3825i.dts b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/ws-ap3825i.dts index 2ea6718468..c4bce497cc 100644 --- a/target/linux/mpc85xx/files/arch/powerpc/boot/dts/ws-ap3825i.dts +++ b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/ws-ap3825i.dts @@ -126,13 +126,11 @@ partition@3f00000 { reg = <0x3f00000 0x20000>; label = "cfg2"; - read-only; }; partition@3f20000 { reg = <0x3f20000 0x20000>; label = "cfg1"; - read-only; }; }; }; From ef223e58a3f5b7877bfc9f4b65dd3ba51cce5b72 Mon Sep 17 00:00:00 2001 From: Josef Schlehofer Date: Tue, 2 Aug 2022 16:07:53 +0200 Subject: [PATCH 028/114] mvebu: PCI: aardvark: Implement workaround for PCIe Completion Timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turris MOX randomly crashes up, when there is connected miniPCIe card MediaTek MT7915 with the following output: [ 71.457007] Internal error: synchronous external abort: 96000210 [#1] SMP [ 71.464021] Modules linked in: xt_connlimit pppoe ppp_async nf_conncount iptable_nat ath9k xt_state xt_nat xt_helper xt_conntrack xt_connmark xt_connbytes xt_REDIREl [ 71.464187] btintel br_netfilter bnep bluetooth ath9k_hw ath10k_pci ath10k_core ath sch_tbf sch_ingress sch_htb sch_hfsc em_u32 cls_u32 cls_tcindex cls_route cls_mg [ 71.629589] CPU: 0 PID: 1298 Comm: kworker/u5:3 Not tainted 5.4.114 #0 [ 71.636319] Hardware name: CZ.NIC Turris Mox Board (DT) [ 71.641725] Workqueue: napi_workq napi_workfn [ 71.646221] pstate: 80400085 (Nzcv daIf +PAN -UAO) [ 71.651169] pc : mt76_set_irq_mask+0x118/0x150 [mt76] [ 71.656385] lr : mt7915_init_debugfs+0x358/0x368 [mt7915e] [ 71.662038] sp : ffffffc010003cd0 [ 71.665451] x29: ffffffc010003cd0 x28: 0000000000000060 [ 71.670929] x27: ffffffc010a56f98 x26: ffffffc010c0fa9a [ 71.676407] x25: ffffffc010ba8788 x24: ffffff803e01fe00 [ 71.681885] x23: 0000000000000030 x22: ffffffc010003dc4 [ 71.687361] x21: 0000000000000000 x20: ffffff803e01fea4 [ 71.692839] x19: ffffff803cb725c0 x18: 000000002d660780 [ 71.698317] x17: 0000000000000000 x16: 0000000000000001 [ 71.703795] x15: 0000000000005ee0 x14: ffffffc010d1d000 [ 71.709272] x13: 0000000000002f70 x12: 0000000000000000 [ 71.714749] x11: 0000000000000000 x10: 0000000000000040 [ 71.720226] x9 : ffffffc010bbe980 x8 : ffffffc010bbe978 [ 71.725704] x7 : ffffff803e4003f0 x6 : 0000000000000000 [ 71.731181] x5 : ffffffc02f240000 x4 : ffffffc010003e00 [ 71.736658] x3 : 0000000000000000 x2 : ffffffc008e3f230 [ 71.742135] x1 : 00000000000d7010 x0 : ffffffc0114d7010 [ 71.747613] Call trace: [ 71.750137] mt76_set_irq_mask+0x118/0x150 [mt76] [ 71.754990] mt7915_dual_hif_set_irq_mask+0x108/0xdc0 [mt7915e] [ 71.761098] __handle_irq_event_percpu+0x6c/0x170 [ 71.765950] handle_irq_event_percpu+0x34/0x88 [ 71.770531] handle_irq_event+0x40/0xb0 [ 71.774486] handle_level_irq+0xe0/0x170 [ 71.778530] generic_handle_irq+0x24/0x38 [ 71.782667] advk_pcie_irq_handler+0x11c/0x238 [ 71.787249] __handle_irq_event_percpu+0x6c/0x170 [ 71.792099] handle_irq_event_percpu+0x34/0x88 [ 71.796680] handle_irq_event+0x40/0xb0 [ 71.800633] handle_fasteoi_irq+0xdc/0x190 [ 71.804855] generic_handle_irq+0x24/0x38 [ 71.808988] __handle_domain_irq+0x60/0xb8 [ 71.813213] gic_handle_irq+0x8c/0x198 [ 71.817077] el1_irq+0xf0/0x1c0 [ 71.820314] el1_da+0xc/0xc0 [ 71.823288] mt76_set_irq_mask+0x118/0x150 [mt76] [ 71.828141] mt7915_mac_tx_free+0x4c4/0x828 [mt7915e] [ 71.833352] mt7915_queue_rx_skb+0x5c/0xa8 [mt7915e] [ 71.838473] mt76_dma_cleanup+0x89c/0x1248 [mt76] [ 71.843329] __napi_poll+0x38/0xf8 [ 71.846835] napi_workfn+0x58/0xb0 [ 71.850342] process_one_work+0x1fc/0x390 [ 71.854475] worker_thread+0x48/0x4d0 [ 71.858252] kthread+0x120/0x128 [ 71.861581] ret_from_fork+0x10/0x1c [ 71.865273] Code: 52800000 d65f03c0 f9562c00 8b214000 (b9400000) [ 71.871560] ---[ end trace 1d4e29987011411b ]--- [ 71.876320] Kernel panic - not syncing: Fatal exception in interrupt [ 71.882875] SMP: stopping secondary CPUs [ 71.886923] Kernel Offset: disabled [ 71.890519] CPU features: 0x0002,00002008 [ 71.894649] Memory Limit: none [ 71.897799] Rebooting in 3 seconds.. Patch is awaiting upstream merge: https://lore.kernel.org/linux-pci/20220802123816.21817-1-pali@kernel.org/T/#u There was also discussion about it in the linux-pci mailing list, where can be found response from Marvell's employee regarding A3720 PCIe erratum 3.12, which seems to provide further details which help this issue: https://lore.kernel.org/linux-pci/BN9PR18MB425154FE5019DCAF2028A1D5DB8D9@BN9PR18MB4251.namprd18.prod.outlook.com/t/#u Reported-by: Ondřej Caletka [Turris MOX] Signed-off-by: Josef Schlehofer Reviewed-by: Robert Marko --- .../100-aardvark-workaround-PCIe.patch | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 target/linux/mvebu/patches-5.15/100-aardvark-workaround-PCIe.patch diff --git a/target/linux/mvebu/patches-5.15/100-aardvark-workaround-PCIe.patch b/target/linux/mvebu/patches-5.15/100-aardvark-workaround-PCIe.patch new file mode 100644 index 0000000000..975eadb80e --- /dev/null +++ b/target/linux/mvebu/patches-5.15/100-aardvark-workaround-PCIe.patch @@ -0,0 +1,81 @@ +Subject: [PATCH v2] PCI: aardvark: Implement workaround for PCIe Completion Timeout +Date: Tue, 2 Aug 2022 14:38:16 +0200 +Message-Id: <20220802123816.21817-1-pali@kernel.org> +X-Mailer: git-send-email 2.20.1 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Precedence: bulk +List-ID: +X-Mailing-List: linux-pci@vger.kernel.org + +Marvell Armada 3700 Functional Errata, Guidelines, and Restrictions +document describes in erratum 3.12 PCIe Completion Timeout (Ref #: 251), +that PCIe IP does not support a strong-ordered model for inbound posted vs. +outbound completion. + +As a workaround for this erratum, DIS_ORD_CHK flag in Debug Mux Control +register must be set. It disables the ordering check in the core between +Completions and Posted requests received from the link. + +Marvell also suggests to do full memory barrier at the beginning of +aardvark summary interrupt handler before calling interrupt handlers of +endpoint drivers in order to minimize the risk for the race condition +documented in the Erratum between the DMA done status reading and the +completion of writing to the host memory. + +More details about this issue and suggested workarounds are in discussion: +https://lore.kernel.org/linux-pci/BN9PR18MB425154FE5019DCAF2028A1D5DB8D9@BN9PR18MB4251.namprd18.prod.outlook.com/t/#u + +It was reported that enabling this workaround fixes instability issues and +"Unhandled fault" errors when using 60 GHz WiFi 802.11ad card with Qualcomm +QCA6335 chip under significant load which were caused by interrupt status +stuck in the outbound CMPLT queue traced back to this erratum. + +This workaround fixes also kernel panic triggered after some minutes of +usage 5 GHz WiFi 802.11ax card with Mediatek MT7915 chip: + + Internal error: synchronous external abort: 96000210 [#1] SMP + Kernel panic - not syncing: Fatal exception in interrupt + +Signed-off-by: Thomas Petazzoni +Signed-off-by: Pali Rohár +Fixes: 8c39d710363c ("PCI: aardvark: Add Aardvark PCI host controller driver") +Cc: stable@vger.kernel.org +--- + drivers/pci/controller/pci-aardvark.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/pci/controller/pci-aardvark.c ++++ b/drivers/pci/controller/pci-aardvark.c +@@ -210,6 +210,8 @@ enum { + }; + + #define VENDOR_ID_REG (LMI_BASE_ADDR + 0x44) ++#define DEBUG_MUX_CTRL_REG (LMI_BASE_ADDR + 0x208) ++#define DIS_ORD_CHK BIT(30) + + /* PCIe core controller registers */ + #define CTRL_CORE_BASE_ADDR 0x18000 +@@ -558,6 +560,11 @@ static void advk_pcie_setup_hw(struct ad + PCIE_CORE_CTRL2_TD_ENABLE; + advk_writel(pcie, reg, PCIE_CORE_CTRL2_REG); + ++ /* Disable ordering checks, workaround for erratum 3.12 "PCIe completion timeout" */ ++ reg = advk_readl(pcie, DEBUG_MUX_CTRL_REG); ++ reg |= DIS_ORD_CHK; ++ advk_writel(pcie, reg, DEBUG_MUX_CTRL_REG); ++ + /* Set lane X1 */ + reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG); + reg &= ~LANE_CNT_MSK; +@@ -1580,6 +1587,9 @@ static irqreturn_t advk_pcie_irq_handler + struct advk_pcie *pcie = arg; + u32 status; + ++ /* Full memory barrier (ARM dsb sy), workaround for erratum 3.12 "PCIe completion timeout" */ ++ mb(); ++ + status = advk_readl(pcie, HOST_CTRL_INT_STATUS_REG); + if (!(status & PCIE_IRQ_CORE_INT)) + return IRQ_NONE; From 9423fc424c7313e470f61224eeebbaee3ff477a2 Mon Sep 17 00:00:00 2001 From: Aleksander Jan Bajkowski Date: Mon, 2 May 2022 20:31:17 +0200 Subject: [PATCH 029/114] lantiq: xrx200: backport upstream network fixes This series contains bug fixes that may occur under memory pressure. Signed-off-by: Aleksander Jan Bajkowski --- ...0-confirm-skb-is-allocated-before-us.patch | 33 +++++++++++++++++++ ...rx200-fix-lock-under-memory-pressure.patch | 33 +++++++++++++++++++ ...0-restore-buffer-if-memory-allocatio.patch | 27 +++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 target/linux/lantiq/patches-5.10/0717-v6.0-net-lantiq_xrx200-confirm-skb-is-allocated-before-us.patch create mode 100644 target/linux/lantiq/patches-5.10/0718-v6.0-net-lantiq_xrx200-fix-lock-under-memory-pressure.patch create mode 100644 target/linux/lantiq/patches-5.10/0719-v6.0-net-lantiq_xrx200-restore-buffer-if-memory-allocatio.patch diff --git a/target/linux/lantiq/patches-5.10/0717-v6.0-net-lantiq_xrx200-confirm-skb-is-allocated-before-us.patch b/target/linux/lantiq/patches-5.10/0717-v6.0-net-lantiq_xrx200-confirm-skb-is-allocated-before-us.patch new file mode 100644 index 0000000000..9eaec58033 --- /dev/null +++ b/target/linux/lantiq/patches-5.10/0717-v6.0-net-lantiq_xrx200-confirm-skb-is-allocated-before-us.patch @@ -0,0 +1,33 @@ +From c8b043702dc0894c07721c5b019096cebc8c798f Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Wed, 24 Aug 2022 23:54:06 +0200 +Subject: [PATCH] net: lantiq_xrx200: confirm skb is allocated before using + +xrx200_hw_receive() assumes build_skb() always works and goes straight +to skb_reserve(). However, build_skb() can fail under memory pressure. + +Add a check in case build_skb() failed to allocate and return NULL. + +Fixes: e015593573b3 ("net: lantiq_xrx200: convert to build_skb") +Reported-by: Eric Dumazet +Signed-off-by: Aleksander Jan Bajkowski +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/lantiq_xrx200.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/net/ethernet/lantiq_xrx200.c ++++ b/drivers/net/ethernet/lantiq_xrx200.c +@@ -239,6 +239,12 @@ static int xrx200_hw_receive(struct xrx2 + } + + skb = build_skb(buf, priv->rx_skb_size); ++ if (!skb) { ++ skb_free_frag(buf); ++ net_dev->stats.rx_dropped++; ++ return -ENOMEM; ++ } ++ + skb_reserve(skb, NET_SKB_PAD); + skb_put(skb, len); + diff --git a/target/linux/lantiq/patches-5.10/0718-v6.0-net-lantiq_xrx200-fix-lock-under-memory-pressure.patch b/target/linux/lantiq/patches-5.10/0718-v6.0-net-lantiq_xrx200-fix-lock-under-memory-pressure.patch new file mode 100644 index 0000000000..929ae57ace --- /dev/null +++ b/target/linux/lantiq/patches-5.10/0718-v6.0-net-lantiq_xrx200-fix-lock-under-memory-pressure.patch @@ -0,0 +1,33 @@ +From c4b6e9341f930e4dd089231c0414758f5f1f9dbd Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Wed, 24 Aug 2022 23:54:07 +0200 +Subject: [PATCH] net: lantiq_xrx200: fix lock under memory pressure + +When the xrx200_hw_receive() function returns -ENOMEM, the NAPI poll +function immediately returns an error. +This is incorrect for two reasons: +* the function terminates without enabling interrupts or scheduling NAPI, +* the error code (-ENOMEM) is returned instead of the number of received +packets. + +After the first memory allocation failure occurs, packet reception is +locked due to disabled interrupts from DMA.. + +Fixes: fe1a56420cf2 ("net: lantiq: Add Lantiq / Intel VRX200 Ethernet driver") +Signed-off-by: Aleksander Jan Bajkowski +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/lantiq_xrx200.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/lantiq_xrx200.c ++++ b/drivers/net/ethernet/lantiq_xrx200.c +@@ -294,7 +294,7 @@ static int xrx200_poll_rx(struct napi_st + if (ret == XRX200_DMA_PACKET_IN_PROGRESS) + continue; + if (ret != XRX200_DMA_PACKET_COMPLETE) +- return ret; ++ break; + rx++; + } else { + break; diff --git a/target/linux/lantiq/patches-5.10/0719-v6.0-net-lantiq_xrx200-restore-buffer-if-memory-allocatio.patch b/target/linux/lantiq/patches-5.10/0719-v6.0-net-lantiq_xrx200-restore-buffer-if-memory-allocatio.patch new file mode 100644 index 0000000000..182da58ed9 --- /dev/null +++ b/target/linux/lantiq/patches-5.10/0719-v6.0-net-lantiq_xrx200-restore-buffer-if-memory-allocatio.patch @@ -0,0 +1,27 @@ +From c9c3b1775f80fa21f5bff874027d2ccb10f5d90c Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Wed, 24 Aug 2022 23:54:08 +0200 +Subject: [PATCH] net: lantiq_xrx200: restore buffer if memory allocation + failed + +In a situation where memory allocation fails, an invalid buffer address +is stored. When this descriptor is used again, the system panics in the +build_skb() function when accessing memory. + +Fixes: 7ea6cd16f159 ("lantiq: net: fix duplicated skb in rx descriptor ring") +Signed-off-by: Aleksander Jan Bajkowski +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/lantiq_xrx200.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/ethernet/lantiq_xrx200.c ++++ b/drivers/net/ethernet/lantiq_xrx200.c +@@ -193,6 +193,7 @@ static int xrx200_alloc_buf(struct xrx20 + + ch->rx_buff[ch->dma.desc] = alloc(priv->rx_skb_size); + if (!ch->rx_buff[ch->dma.desc]) { ++ ch->rx_buff[ch->dma.desc] = buf; + ret = -ENOMEM; + goto skip; + } From 62b72eafe49d2eecd3692691152ed86a0327fcb0 Mon Sep 17 00:00:00 2001 From: John Thomson Date: Thu, 19 May 2022 09:18:20 +1000 Subject: [PATCH 030/114] ath79: mikrotik: use OpenWrt loader for initram image Return to using the OpenWrt kernel loader to decompress and load kernel initram image. Continue to use the vmlinuz kernel for squashfs. Mikrotik's bootloader RouterBOOT on some ath79 devices is failing to boot the current initram, due to the size of the initram image. On the ath79 wAP-ac: a 5.7MiB initram image would fail to boot After this change: a 6.6MiB initram image successfully loads This partially reverts commit e91344776b9ba7c864be88d915c9c0df0eb790dd. An alternative of using RouterBOOT's capability of loading an initrd ELF section was investigated, but the OpenWrt kernel loader allows larger image. Signed-off-by: John Thomson --- target/linux/ath79/image/common-mikrotik.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/linux/ath79/image/common-mikrotik.mk b/target/linux/ath79/image/common-mikrotik.mk index 5f5fa7899a..fb3dc78226 100644 --- a/target/linux/ath79/image/common-mikrotik.mk +++ b/target/linux/ath79/image/common-mikrotik.mk @@ -1,8 +1,10 @@ define Device/mikrotik DEVICE_VENDOR := MikroTik + LOADER_TYPE := elf KERNEL_NAME := vmlinuz KERNEL := kernel-bin | append-dtb-elf - KERNEL_INITRAMFS := kernel-bin | append-dtb-elf + KERNEL_INITRAMFS_NAME := vmlinux-initramfs + KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel endef define Device/mikrotik_nor From 59cb4dc91d500edc2e6b462e223e367806557cc5 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Sun, 22 May 2022 17:46:28 +0200 Subject: [PATCH 031/114] ath79: support Ruckus ZoneFlex 7372 Ruckus ZoneFlex 7372 is a dual-band, dual-radio 802.11n 2x2 MIMO enterprise access point. Ruckus ZoneFlex 7352 is also supported, lacking the 5GHz radio part. Hardware highligts: - CPU: Atheros AR9344 SoC at 560 MHz - RAM: 128MB DDR2 - Flash: 32MB SPI-NOR - Wi-Fi 2.4GHz: AR9344 built-in 2x2 MIMO radio - Wi-Fi 5Ghz: AR9582 2x2 MIMO radio (Only in ZF7372) - Antennas: - Separate internal active antennas with beamforming support on both bands with 7 elements per band, each controlled by 74LV164 GPIO expanders, attached to GPIOs of each radio. - Two dual-band external RP-SMA antenna connections on "7372-E" variant. - Ethernet 1: single Gigabit Ethernet port through AR8035 gigabit PHY - Ethernet 2: single Fast Ethernet port through AR9344 built-in switch - PoE: input through Gigabit port - Standalone 12V/1A power input - USB: optional single USB 2.0 host port on "-U" variants. The same image should support: - ZoneFlex 7372E (variant with external antennas, without beamforming capability) - ZoneFlex 7352 (single-band, 2.4GHz-only variant). which are based on same baseboard (codename St. Bernard), with different populated components. Serial console: 115200-8-N-1 on internal H1 header. Pinout: H1 --- |5| --- |4| --- |3| --- |x| --- |1| --- Pin 5 is near the "H1" marking. 1 - RX x - no pin 3 - VCC (3.3V) 4 - GND 5 - TX JTAG: Connector H2, similar to MIPS eJTAG, standard, but without the key in pin 12 and not every pin routed: ------- H2 |1 |2 | ------- |3 |4 | ------- |5 |6 | ------- |7 |8 | ------- |9 |10| ------- |11|12| ------- |13|14| ------- 3 - TDI 5 - TDO 7 - TMS 9 - TCK 2,4,6,8,10 - GND 14 - Vref 1,11,12,13 - Not connected Installation: There are two methods of installation: - Using serial console [1] - requires some disassembly, 3.3V USB-Serial adapter, TFTP server, and removing a single T10 screw, but with much less manual steps, and is generally recommended, being safer. - Using stock firmware root shell exploit, SSH and TFTP [2]. Does not work on some rare versions of stock firmware. A more involved, and requires installing `mkenvimage` from u-boot-tools package if you choose to rebuild your own environment, but can be used without disassembly or removal from installation point, if you have the credentials. If for some reason, size of your sysupgrade image exceeds 13312kB, proceed with method [1]. For official images this is not likely to happen ever. [1] Using serial console: 0. Connect serial console to H1 header. Ensure the serial converter does not back-power the board, otherwise it will fail to boot. 1. Power-on the board. Then quickly connect serial converter to PC and hit Ctrl+C in the terminal to break boot sequence. If you're lucky, you'll enter U-boot shell. Then skip to point 3. Connection parameters are 115200-8-N-1. 2. Allow the board to boot. Press the reset button, so the board reboots into U-boot again and go back to point 1. 3. Set the "bootcmd" variable to disable the dual-boot feature of the system and ensure that uImage is loaded. This is critical step, and needs to be done only on initial installation. > setenv bootcmd "bootm 0x9f040000" > saveenv 4. Boot the OpenWrt initramfs using TFTP. Replace IP addresses as needed: > setenv serverip 192.168.1.2 > setenv ipaddr 192.168.1.1 > tftpboot 0x81000000 openwrt-ath79-generic-ruckus_zf7372-initramfs-kernel.bin > bootm 0x81000000 5. Optional, but highly recommended: back up contents of "firmware" partition: $ ssh root@192.168.1.1 cat /dev/mtd1 > ruckus_zf7372_fw1_backup.bin $ ssh root@192.168.1.1 cat /dev/mtd5 > ruckus_zf7372_fw2_backup.bin 6. Copy over sysupgrade image, and perform actual installation. OpenWrt shall boot from flash afterwards: $ ssh root@192.168.1.1 # sysupgrade -n openwrt-ath79-generic-ruckus_zf7372-squashfs-sysupgrade.bin [2] Using stock root shell: 0. Reset the device to factory defaullts. Power-on the device and after it boots, hold the reset button near Ethernet connectors for 5 seconds. 1. Connect the device to the network. It will acquire address over DHCP, so either find its address using list of DHCP leases by looking for label MAC address, or try finding it by scanning for SSH port: $ nmap 10.42.0.0/24 -p22 From now on, we assume your computer has address 10.42.0.1 and the device has address 10.42.0.254. 2. Set up a TFTP server on your computer. We assume that TFTP server root is at /srv/tftp. 3. Obtain root shell. Connect to the device over SSH. The SSHD ond the frmware is pretty ancient and requires enabling HMAC-MD5. $ ssh 10.42.0.254 \ -o UserKnownHostsFile=/dev/null \ -o StrictHostKeyCheking=no \ -o MACs=hmac-md5 Login. User is "super", password is "sp-admin". Now execute a hidden command: Ruckus It is case-sensitive. Copy and paste the following string, including quotes. There will be no output on the console for that. ";/bin/sh;" Hit "enter". The AP will respond with: grrrr OK Now execute another hidden command: !v54! At "What's your chow?" prompt just hit "enter". Congratulations, you should now be dropped to Busybox shell with root permissions. 4. Optional, but highly recommended: backup the flash contents before installation. At your PC ensure the device can write the firmware over TFTP: $ sudo touch /srv/tftp/ruckus_zf7372_firmware{1,2}.bin $ sudo chmod 666 /srv/tftp/ruckus_zf7372_firmware{1,2}.bin Locate partitions for primary and secondary firmware image. NEVER blindly copy over MTD nodes, because MTD indices change depending on the currently active firmware, and all partitions are writable! # grep rcks_wlan /proc/mtd Copy over both images using TFTP, this will be useful in case you'd like to return to stock FW in future. Make sure to backup both, as OpenWrt uses bot firmwre partitions for storage! # tftp -l /dev/ -r ruckus_zf7372_firmware1.bin -p 10.42.0.1 # tftp -l /dev/ -r ruckus_zf7372_firmware2.bin -p 10.42.0.1 When the command finishes, copy over the dump to a safe place for storage. $ cp /srv/tftp/ruckus_zf7372_firmware{1,2}.bin ~/ 5. Ensure the system is running from the BACKUP image, i.e. from rcks_wlan.bkup partition or "image 2". Otherwise the installation WILL fail, and you will need to access mtd0 device to write image which risks overwriting the bootloader, and so is not covered here and not supported. Switching to backup firmware can be achieved by executing a few consecutive reboots of the device, or by updating the stock firmware. The system will boot from the image it was not running from previously. Stock firmware available to update was conveniently dumped in point 4 :-) 6. Prepare U-boot environment image. Install u-boot-tools package. Alternatively, if you build your own images, OpenWrt provides mkenvimage in host staging directory as well. It is recommended to extract environment from the device, and modify it, rather then relying on defaults: $ sudo touch /srv/tftp/u-boot-env.bin $ sudo chmod 666 /srv/tftp/u-boot-env.bin On the device, find the MTD partition on which environment resides. Beware, it may change depending on currently active firmware image! # grep u-boot-env /proc/mtd Now, copy over the partition # tftp -l /dev/mtd -r u-boot-env.bin -p 10.42.0.1 Store the stock environment in a safe place: $ cp /srv/tftp/u-boot-env.bin ~/ Extract the values from the dump: $ strings u-boot-env.bin | tee u-boot-env.txt Now clean up the debris at the end of output, you should end up with each variable defined once. After that, set the bootcmd variable like this: bootcmd=bootm 0x9f040000 You should end up with something like this: bootcmd=bootm 0x9f040000 bootargs=console=ttyS0,115200 rootfstype=squashfs init=/sbin/init baudrate=115200 ethaddr=0x00:0xaa:0xbb:0xcc:0xdd:0xee bootdelay=2 mtdids=nor0=ar7100-nor0 mtdparts=mtdparts=ar7100-nor0:256k(u-boot),13312k(rcks_wlan.main),2048k(datafs),256k(u-boot-env),512k(Board Data),13312k(rcks_wlan.bkup) ethact=eth0 filesize=1000000 fileaddr=81000000 ipaddr=192.168.0.7 serverip=192.168.0.51 partition=nor0,0 mtddevnum=0 mtddevname=u-boot stdin=serial stdout=serial stderr=serial These are the defaults, you can use most likely just this as input to mkenvimage. Now, create environment image and copy it over to TFTP root: $ mkenvimage -s 0x40000 -b -o u-boot-env.bin u-boot-env.txt $ sudo cp u-boot-env.bin /srv/tftp This is the same image, gzipped and base64-encoded: H4sIAAAAAAAAA+3QTW7TQBQAYB+AQ2TZSGk6Tpv+SbNBrNhyADSJHWolsYPtlJaDcAWOCXaqQhdIXOD7 Fm/ee+MZ+/nHu58fV03Tr/dFHNf9JDzdbcJVGGRjI7Vfurhu6q7ZlbHvnz+FWZ4vFyFM2mF30/XPhzJ2 X4+pe9h0k6qu+njRrar6YkyzVToWberL+HImK/uHVBRtDE8h3IenlIawWg1hvR5CUQyhLE/vLcpdeo6L bN8XVdHFumlDTO1NHsL5mI/9Q2r7Lv5J3uzeL5bX27Pj+XjRdJZfXuaL7Vm73nafv+1SPd+nqp7OFuHq dntWpD5tuqH6e+K8rB+ns+V45n2T2mLyYXjmH9estsfD9DTSuo/DErJNtSu76vswbjg5NU4D3752qsOp zu8W8/z6dh7mN1lXto9lWx3eNJd5Ng5V9VVTn2afnSYuysf6uI9/8rQv48s3Z93wn+o4XFWl3Vg0x/5N Vbbta5X9AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAID/+Q2Z/B7cAAAEAA== 7. Perform actual installation. Copy over OpenWrt sysupgrade image to TFTP root: $ sudo cp openwrt-ath79-generic-ruckus_zf7372-squashfs-sysupgrade.bin /srv/tftp Now load both to the device over TFTP: # tftp -l /tmp/u-boot-env.bin -r u-boot-env.bin -g 10.42.0.1 # tftp -l /tmp/openwrt.bin -r openwrt-ath79-generic-ruckus_zf7372-squashfs-sysupgrade.bin -g 10.42.0.1 Verify checksums of both images to ensure the transfer over TFTP was completed: # sha256sum /tmp/u-boot-env.bin /tmp/openwrt.bin And compare it against source images: $ sha256sum /srv/tftp/u-boot-env.bin /srv/tftp/openwrt-ath79-generic-ruckus_zf7372-squashfs-sysupgrade.bin Locate MTD partition of the primary image: # grep rcks_wlan.main /proc/mtd Now, write the images in place. Write U-boot environment last, so unit still can boot from backup image, should power failure occur during this. Replace MTD placeholders with real MTD nodes: # flashcp /tmp/openwrt.bin /dev/ # flashcp /tmp/u-boot-env.bin /dev/ Finally, reboot the device. The device should directly boot into OpenWrt. Look for the characteristic power LED blinking pattern. # reboot -f After unit boots, it should be available at the usual 192.168.1.1/24. Return to factory firmware: 1. Boot into OpenWrt initramfs as for initial installation. To do that without disassembly, you can write an initramfs image to the device using 'sysupgrade -F' first. 2. Unset the "bootcmd" variable: fw_setenv bootcmd "" 3. Write factory images downloaded from manufacturer website into fwconcat0 and fwconcat1 MTD partitions, or restore backup you took before installation: mtd write ruckus_zf7372_fw1_backup.bin /dev/mtd1 mtd write ruckus_zf7372_fw2_backup.bin /dev/mtd5 4. Reboot the system, it should load into factory firmware again. Quirks and known issues: - This is first device in ath79 target to support link state reporting on FE port attached trough the built-in switch. - Flash layout is changed from the factory, to use both firmware image partitions for storage using mtd-concat, and uImage format is used to actually boot the system, which rules out the dual-boot capability. The 5GHz radio has its own EEPROM on board, not connected to CPU. - The stock firmware has dual-boot capability, which is not supported in OpenWrt by choice. It is controlled by data in the top 64kB of RAM which is unmapped, to avoid the interference in the boot process and accidental switch to the inactive image, although boot script presence in form of "bootcmd" variable should prevent this entirely. - U-boot disables JTAG when starting. To re-enable it, you need to execute the following command before booting: mw.l 1804006c 40 And also you need to disable the reset button in device tree if you intend to debug Linux, because reset button on GPIO0 shares the TCK pin. - On some versions of stock firmware, it is possible to obtain root shell, however not much is available in terms of debugging facitilies. 1. Login to the rkscli 2. Execute hidden command "Ruckus" 3. Copy and paste ";/bin/sh;" including quotes. This is required only once, the payload will be stored in writable filesystem. 4. Execute hidden command "!v54!". Press Enter leaving empty reply for "What's your chow?" prompt. 5. Busybox shell shall open. Source: https://alephsecurity.com/vulns/aleph-2019014 - Stock firmware has beamforming functionality, known as BeamFlex, using active multi-segment antennas on both bands - controlled by RF analog switches, driven by a pair of 74LV164 shift registers. Shift registers used for each radio are connected to GPIO14 (clock) and GPIO15 of the respective chip. They are mapped as generic GPIOs in OpenWrt - in stock firmware, they were most likely handled directly by radio firmware, given the real-time nature of their control. Lack of this support in OpenWrt causes the antennas to behave as ordinary omnidirectional antennas, and does not affect throughput in normal conditions, but GPIOs are available to tinker with nonetheless. Signed-off-by: Lech Perczak --- package/boot/uboot-envtools/files/ath79 | 3 + .../linux/ath79/dts/ar9344_ruckus_zf7372.dts | 133 ++++++++++++ .../linux/ath79/dts/ar934x_ruckus_zf73xx.dtsi | 198 ++++++++++++++++++ .../generic/base-files/etc/board.d/01_leds | 3 + .../generic/base-files/etc/board.d/02_network | 5 + target/linux/ath79/image/generic.mk | 16 ++ 6 files changed, 358 insertions(+) create mode 100644 target/linux/ath79/dts/ar9344_ruckus_zf7372.dts create mode 100644 target/linux/ath79/dts/ar934x_ruckus_zf73xx.dtsi diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index a435e06a0d..9e4d0ff96d 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -126,6 +126,9 @@ plasmacloud,pa300e) qihoo,c301) ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x10000" "0x10000" ;; +ruckus,zf7372) + ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x40000" "0x10000" + ;; sophos,ap15|\ sophos,ap55|\ sophos,ap55c|\ diff --git a/target/linux/ath79/dts/ar9344_ruckus_zf7372.dts b/target/linux/ath79/dts/ar9344_ruckus_zf7372.dts new file mode 100644 index 0000000000..4bf7276db5 --- /dev/null +++ b/target/linux/ath79/dts/ar9344_ruckus_zf7372.dts @@ -0,0 +1,133 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ar934x_ruckus_zf73xx.dtsi" + +/ { + model = "Ruckus ZoneFlex 7352/7372[-E/-U]"; + compatible = "ruckus,zf7372", "qca,ar9344"; + + leds { + air-green { + label = "green:air"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + }; + + air-yellow { + label = "yellow:air"; + gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + }; + + dir-green { + label = "green:dir"; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + }; + + eth1-green { + label = "green:eth1"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + power_red: power-red { + label = "red:power"; + gpios = <&gpio 16 GPIO_ACTIVE_HIGH>; + panic-indicator; + }; + + wlan2g-green { + label = "green:wlan2g"; + gpios = <&gpio 19 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0assoc"; + }; + + wlan2g-yellow { + label = "yellow:wlan2g"; + gpios = <&gpio 20 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + wlan5g-green { + label = "green:wlan5g"; + gpios = <&gpio 21 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1assoc"; + }; + + wlan5g-yellow { + label = "yellow:wlan5g"; + gpios = <&gpio 22 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + }; + + beamforming-2g-spi { + compatible = "spi-gpio"; + mosi-gpios = <&gpio 15 GPIO_ACTIVE_HIGH>; + sck-gpios = <&gpio 14 GPIO_ACTIVE_HIGH>; + num-chipselects = <0>; + + beamforming-2g-gpio@0 { + compatible = "fairchild,74hc595"; + reg = <0>; + registers-number = <1>; + spi-max-frequency = <24000000>; + gpio-controller; + #gpio-cells = <2>; + }; + }; + + beamforming-5g-spi { + compatible = "spi-gpio"; + mosi-gpios = <&ath9k 15 GPIO_ACTIVE_HIGH>; + sck-gpios = <&ath9k 14 GPIO_ACTIVE_HIGH>; + num-chipselects = <0>; + + beamforming-5g-gpio@0 { + compatible = "fairchild,74hc595"; + reg = <0>; + registers-number = <1>; + spi-max-frequency = <24000000>; + gpio-controller; + #gpio-cells = <2>; + }; + }; +}; + +ð0 { + nvmem-cells = <&macaddr_board_data_6c>; +}; + +ð1 { + status = "okay"; + + nvmem-cells = <&macaddr_board_data_66>; + nvmem-cell-names = "mac-address"; + + gmac-config { + device = <&gmac>; + switch-phy-swap = <0>; + switch-only-mode = <1>; + }; +}; + +&pcie { + status = "okay"; + + ath9k: wifi@0,0 { + compatible = "pci168c,0033"; + reg = <0x0000 0 0 0 0>; + gpio-controller; + #gpio-cells = <2>; + + nvmem-cells = <&macaddr_board_data_76>; + nvmem-cell-names = "mac-address"; + }; +}; + +&board_data { + macaddr_board_data_6c: macaddr@6c { + reg = <0x6c 0x6>; + }; + + macaddr_board_data_76: macaddr@76 { + reg = <0x76 0x6>; + }; +}; diff --git a/target/linux/ath79/dts/ar934x_ruckus_zf73xx.dtsi b/target/linux/ath79/dts/ar934x_ruckus_zf73xx.dtsi new file mode 100644 index 0000000000..a0348e7213 --- /dev/null +++ b/target/linux/ath79/dts/ar934x_ruckus_zf73xx.dtsi @@ -0,0 +1,198 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ar9344.dtsi" + +#include +#include +#include + +/ { + aliases { + led-boot = &power_green; + led-failsafe = &power_red; + led-running = &power_green; + led-upgrade = &power_red; + }; + + firmware-concat { + compatible = "mtd-concat"; + devices = <&fwconcat0 &fwconcat1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + reg = <0x0 0x1f00000>; + label = "firmware"; + compatible = "openwrt,uimage", "denx,uimage"; + }; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + linux,code = ; + label = "Reset button"; + gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; + debounce-interval = <50>; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-names = "default"; + pinctrl-0 = <&enable_gpio_11>, + <&enable_gpio_16>, + <&enable_gpio_4>, + <&clks_disable_pins>; + + power_green: power-green { + label = "green:power"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + }; + + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + ruckus-himem@7ff0000 { + /* Ruckus Himem area used to control + * redundant boot image selection + */ + compatible = "nvmem-rmem"; + reg = <0x7ff0000 0x10000>; + no-map; + }; + }; +}; + +&ref { + clock-frequency = <40000000>; +}; + +&spi { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x000000 0x040000>; + read-only; + }; + + fwconcat0: partition@40000 { + label = "fwconcat0"; + reg = <0x040000 0xf00000>; + }; + + partition@f40000 { + compatible = "u-boot,env"; + label = "u-boot-env"; + reg = <0xf40000 0x040000>; + }; + + board_data: partition@f80000 { + label = "board-data"; + reg = <0xf80000 0x080000>; + read-only; + }; + + fwconcat1: partition@1000000 { + label = "fwconcat1"; + reg = <0x1000000 0x1000000>; + }; + }; + }; +}; + +&mdio0 { + status = "okay"; + + phy: ethernet-phy@6 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <6>; + }; +}; + +ð0 { + status = "okay"; + pll-data = <0x02000000 0x00000101 0x00001313>; + phy-mode = "rgmii-id"; + phy-handle = <&phy>; + + nvmem-cell-names = "mac-address"; + + gmac-config { + device = <&gmac>; + rgmii-gmac0 = <1>; + rxdv-delay = <3>; + rxd-delay = <3>; + }; +}; + +&pinmux { + clks_disable_pins: pinmux_clks_disable_pins { + pinctrl-single,bits = <0x40 0x0 0x20>; + }; + + enable_gpio_4: pinctrl_enable_gpio_4 { + pinctrl-single,bits = <0x4 0x0 0xff>; + }; + + enable_gpio_11: pinctrl_enable_gpio_11 { + pinctrl-single,bits = <0x8 0x0 0xff000000>; + }; + + enable_gpio_16: pinctrl_enable_gpio_16 { + pinctrl-single,bits = <0x10 0x0 0xff>; + }; +}; + +&wmac { + status = "okay"; + + nvmem-cells = <&macaddr_board_data_60>, <&cal_board_data_41000>; + nvmem-cell-names = "mac-address", "calibration"; +}; + +&usb { + status = "okay"; +}; + +&usb_phy { + status = "okay"; +}; + +&board_data { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_board_data_60: macaddr@60 { + reg = <0x60 0x6>; + }; + + macaddr_board_data_66: macaddr@66 { + reg = <0x66 0x6>; + }; + + cal_board_data_41000: cal@41000 { + reg = <0x41000 0x440>; + }; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index 188262018c..4773826520 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -324,6 +324,9 @@ qca,ap143-16m) qihoo,c301) ucidef_set_led_wlan "wlan" "WLAN" "green:wlan" "phy0tpt" ;; +ruckus,zf7372) + ucidef_set_led_switch "lan" "LAN" "green:eth1" "switch0" "0x02" + ;; samsung,wam250) ucidef_set_led_netdev "lan" "LAN" "white:lan" "eth0" ;; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index 20dc564117..27482129ce 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -131,6 +131,7 @@ ath79_setup_interfaces() engenius,enstationac-v1|\ engenius,ews511ap|\ ocedo,ursus|\ + ruckus,zf7372|\ ubnt,unifi-ap-outdoor-plus) ucidef_set_interface_lan "eth0 eth1" ;; @@ -698,6 +699,10 @@ ath79_setup_macs() wan_mac=$(mtd_get_mac_binary factory 0x0) lan_mac=$(macaddr_setbit_la "$wan_mac") ;; + ruckus,zf7372) + lan_mac=$(mtd_get_mac_binary board-data 0x807E) + label_mac=$lan_mac + ;; sitecom,wlr-7100|\ sitecom,wlr-8100) lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr) diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index d205fd8d9e..2439429c60 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -2380,6 +2380,22 @@ define Device/rosinson_wr818 endef TARGET_DEVICES += rosinson_wr818 +define Device/ruckus_zf73xx_common + DEVICE_VENDOR := Ruckus + DEVICE_PACKAGES := -swconfig kmod-usb2 kmod-usb-chipidea2 + IMAGE_SIZE := 31744k + LOADER_TYPE := bin + KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | uImage none + KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | uImage none +endef + +define Device/ruckus_zf7372 + $(Device/ruckus_zf73xx_common) + SOC := ar9344 + DEVICE_MODEL := ZoneFlex 7352/7372[-E/-U] +endef +TARGET_DEVICES += ruckus_zf7372 + define Device/samsung_wam250 SOC := ar9344 DEVICE_VENDOR := Samsung From f1d112ee5a43e8c4a22db05b94bbcd0677a34486 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Tue, 14 Jun 2022 22:49:40 +0200 Subject: [PATCH 032/114] ath79: support Ruckus ZoneFlex 7321 Ruckus ZoneFlex 7321 is a dual-band, single radio 802.11n 2x2 MIMO enterprise access point. It is very similar to its bigger brother, ZoneFlex 7372. Hardware highligts: - CPU: Atheros AR9342 SoC at 533 MHz - RAM: 64MB DDR2 - Flash: 32MB SPI-NOR - Wi-Fi: AR9342 built-in dual-band 2x2 MIMO radio - Ethernet: single Gigabit Ethernet port through AR8035 gigabit PHY - PoE: input through Gigabit port - Standalone 12V/1A power input - USB: optional single USB 2.0 host port on the 7321-U variant. Serial console: 115200-8-N-1 on internal H1 header. Pinout: H1 ---------- |1|x3|4|5| ---------- Pin 1 is near the "H1" marking. 1 - RX x - no pin 3 - VCC (3.3V) 4 - GND 5 - TX JTAG: Connector H5, unpopulated, similar to MIPS eJTAG, standard, but without the key in pin 12 and not every pin routed: ------- H5 |1 |2 | ------- |3 |4 | ------- |5 |6 | ------- |7 |8 | ------- |9 |10| ------- |11|12| ------- |13|14| ------- 3 - TDI 5 - TDO 7 - TMS 9 - TCK 2,4,6,8,10 - GND 14 - Vref 1,11,12,13 - Not connected Installation: There are two methods of installation: - Using serial console [1] - requires some disassembly, 3.3V USB-Serial adapter, TFTP server, and removing a single T10 screw, but with much less manual steps, and is generally recommended, being safer. - Using stock firmware root shell exploit, SSH and TFTP [2]. Does not work on some rare versions of stock firmware. A more involved, and requires installing `mkenvimage` from u-boot-tools package if you choose to rebuild your own environment, but can be used without disassembly or removal from installation point, if you have the credentials. If for some reason, size of your sysupgrade image exceeds 13312kB, proceed with method [1]. For official images this is not likely to happen ever. [1] Using serial console: 0. Connect serial console to H1 header. Ensure the serial converter does not back-power the board, otherwise it will fail to boot. 1. Power-on the board. Then quickly connect serial converter to PC and hit Ctrl+C in the terminal to break boot sequence. If you're lucky, you'll enter U-boot shell. Then skip to point 3. Connection parameters are 115200-8-N-1. 2. Allow the board to boot. Press the reset button, so the board reboots into U-boot again and go back to point 1. 3. Set the "bootcmd" variable to disable the dual-boot feature of the system and ensure that uImage is loaded. This is critical step, and needs to be done only on initial installation. > setenv bootcmd "bootm 0x9f040000" > saveenv 4. Boot the OpenWrt initramfs using TFTP. Replace IP addresses as needed: > setenv serverip 192.168.1.2 > setenv ipaddr 192.168.1.1 > tftpboot 0x81000000 openwrt-ath79-generic-ruckus_zf7321-initramfs-kernel.bin > bootm 0x81000000 5. Optional, but highly recommended: back up contents of "firmware" partition: $ ssh root@192.168.1.1 cat /dev/mtd1 > ruckus_zf7321_fw1_backup.bin $ ssh root@192.168.1.1 cat /dev/mtd5 > ruckus_zf7321_fw2_backup.bin 6. Copy over sysupgrade image, and perform actual installation. OpenWrt shall boot from flash afterwards: $ ssh root@192.168.1.1 # sysupgrade -n openwrt-ath79-generic-ruckus_zf7321-squashfs-sysupgrade.bin [2] Using stock root shell: 0. Reset the device to factory defaullts. Power-on the device and after it boots, hold the reset button near Ethernet connectors for 5 seconds. 1. Connect the device to the network. It will acquire address over DHCP, so either find its address using list of DHCP leases by looking for label MAC address, or try finding it by scanning for SSH port: $ nmap 10.42.0.0/24 -p22 From now on, we assume your computer has address 10.42.0.1 and the device has address 10.42.0.254. 2. Set up a TFTP server on your computer. We assume that TFTP server root is at /srv/tftp. 3. Obtain root shell. Connect to the device over SSH. The SSHD ond the frmware is pretty ancient and requires enabling HMAC-MD5. $ ssh 10.42.0.254 \ -o UserKnownHostsFile=/dev/null \ -o StrictHostKeyCheking=no \ -o MACs=hmac-md5 Login. User is "super", password is "sp-admin". Now execute a hidden command: Ruckus It is case-sensitive. Copy and paste the following string, including quotes. There will be no output on the console for that. ";/bin/sh;" Hit "enter". The AP will respond with: grrrr OK Now execute another hidden command: !v54! At "What's your chow?" prompt just hit "enter". Congratulations, you should now be dropped to Busybox shell with root permissions. 4. Optional, but highly recommended: backup the flash contents before installation. At your PC ensure the device can write the firmware over TFTP: $ sudo touch /srv/tftp/ruckus_zf7321_firmware{1,2}.bin $ sudo chmod 666 /srv/tftp/ruckus_zf7321_firmware{1,2}.bin Locate partitions for primary and secondary firmware image. NEVER blindly copy over MTD nodes, because MTD indices change depending on the currently active firmware, and all partitions are writable! # grep rcks_wlan /proc/mtd Copy over both images using TFTP, this will be useful in case you'd like to return to stock FW in future. Make sure to backup both, as OpenWrt uses bot firmwre partitions for storage! # tftp -l /dev/ -r ruckus_zf7321_firmware1.bin -p 10.42.0.1 # tftp -l /dev/ -r ruckus_zf7321_firmware2.bin -p 10.42.0.1 When the command finishes, copy over the dump to a safe place for storage. $ cp /srv/tftp/ruckus_zf7321_firmware{1,2}.bin ~/ 5. Ensure the system is running from the BACKUP image, i.e. from rcks_wlan.bkup partition or "image 2". Otherwise the installation WILL fail, and you will need to access mtd0 device to write image which risks overwriting the bootloader, and so is not covered here and not supported. Switching to backup firmware can be achieved by executing a few consecutive reboots of the device, or by updating the stock firmware. The system will boot from the image it was not running from previously. Stock firmware available to update was conveniently dumped in point 4 :-) 6. Prepare U-boot environment image. Install u-boot-tools package. Alternatively, if you build your own images, OpenWrt provides mkenvimage in host staging directory as well. It is recommended to extract environment from the device, and modify it, rather then relying on defaults: $ sudo touch /srv/tftp/u-boot-env.bin $ sudo chmod 666 /srv/tftp/u-boot-env.bin On the device, find the MTD partition on which environment resides. Beware, it may change depending on currently active firmware image! # grep u-boot-env /proc/mtd Now, copy over the partition # tftp -l /dev/mtd -r u-boot-env.bin -p 10.42.0.1 Store the stock environment in a safe place: $ cp /srv/tftp/u-boot-env.bin ~/ Extract the values from the dump: $ strings u-boot-env.bin | tee u-boot-env.txt Now clean up the debris at the end of output, you should end up with each variable defined once. After that, set the bootcmd variable like this: bootcmd=bootm 0x9f040000 You should end up with something like this: bootcmd=bootm 0x9f040000 bootargs=console=ttyS0,115200 rootfstype=squashfs init=/sbin/init baudrate=115200 ethaddr=0x00:0xaa:0xbb:0xcc:0xdd:0xee mtdparts=mtdparts=ar7100-nor0:256k(u-boot),13312k(rcks_wlan.main),2048k(datafs),256k(u-boot-env),512k(Board Data),13312k(rcks_wlan.bkup) mtdids=nor0=ar7100-nor0 bootdelay=2 ethact=eth0 filesize=78a000 fileaddr=81000000 partition=nor0,0 mtddevnum=0 mtddevname=u-boot ipaddr=10.0.0.1 serverip=10.0.0.5 stdin=serial stdout=serial stderr=serial These are the defaults, you can use most likely just this as input to mkenvimage. Now, create environment image and copy it over to TFTP root: $ mkenvimage -s 0x40000 -b -o u-boot-env.bin u-boot-env.txt $ sudo cp u-boot-env.bin /srv/tftp This is the same image, gzipped and base64-encoded: H4sIAAAAAAAAA+3QQW7TQBQAUF8EKRtQI6XtJDS0VJoN4gYcAE3iCbWS2MF2Sss1ORDYqVq6YMEB3rP0 Z/7Yf+aP3/56827VNP16X8Zx3E/Cw8dNuAqDYlxI7bcurpu6a3Y59v3jlzCbz5eLECbt8HbT9Y+HHLvv x9TdbbpJVVd9vOxWVX05TotVOpZt6nN8qilyf5fKso3hIYTb8JDSEFarIazXQyjLIeRc7PvykNq+iy+T 1F7PQzivmzbcLpYftmfH87G56Wz+/v18sT1r19vu649dqi/2qaqns0W4utmelalPm27I/lac5/p+OluO NZ+a1JaTz8M3/9hmtT0epmMjVdnF8djXLZx+TJl36TEuTlda93EYQrGpdrmrfuZ4fZPGHzjmp/vezMNJ MV6n6qumPm06C+MRZb6vj/v4Mk/7HJ+6LarDqXweLsZnXnS5vc9tdXheWRbd0GIdh/Uq7cakOfavsty2 z1nxGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAD+1x9eTkHLAAAEAA== 7. Perform actual installation. Copy over OpenWrt sysupgrade image to TFTP root: $ sudo cp openwrt-ath79-generic-ruckus_zf7321-squashfs-sysupgrade.bin /srv/tftp Now load both to the device over TFTP: # tftp -l /tmp/u-boot-env.bin -r u-boot-env.bin -g 10.42.0.1 # tftp -l /tmp/openwrt.bin -r openwrt-ath79-generic-ruckus_zf7321-squashfs-sysupgrade.bin -g 10.42.0.1 Vverify checksums of both images to ensure the transfer over TFTP was completed: # sha256sum /tmp/u-boot-env.bin /tmp/openwrt.bin And compare it against source images: $ sha256sum /srv/tftp/u-boot-env.bin /srv/tftp/openwrt-ath79-generic-ruckus_zf7321-squashfs-sysupgrade.bin Locate MTD partition of the primary image: # grep rcks_wlan.main /proc/mtd Now, write the images in place. Write U-boot environment last, so unit still can boot from backup image, should power failure occur during this. Replace MTD placeholders with real MTD nodes: # flashcp /tmp/openwrt.bin /dev/ # flashcp /tmp/u-boot-env.bin /dev/ Finally, reboot the device. The device should directly boot into OpenWrt. Look for the characteristic power LED blinking pattern. # reboot -f After unit boots, it should be available at the usual 192.168.1.1/24. Return to factory firmware: 1. Boot into OpenWrt initramfs as for initial installation. To do that without disassembly, you can write an initramfs image to the device using 'sysupgrade -F' first. 2. Unset the "bootcmd" variable: fw_setenv bootcmd "" 3. Write factory images downloaded from manufacturer website into fwconcat0 and fwconcat1 MTD partitions, or restore backup you took before installation: mtd write ruckus_zf7321_fw1_backup.bin /dev/mtd1 mtd write ruckus_zf7321_fw2_backup.bin /dev/mtd5 4. Reboot the system, it should load into factory firmware again. Quirks and known issues: - Flash layout is changed from the factory, to use both firmware image partitions for storage using mtd-concat, and uImage format is used to actually boot the system, which rules out the dual-boot capability. - The 5GHz radio has its own EEPROM on board, not connected to CPU. - The stock firmware has dual-boot capability, which is not supported in OpenWrt by choice. It is controlled by data in the top 64kB of RAM which is unmapped, to avoid the interference in the boot process and accidental switch to the inactive image, although boot script presence in form of "bootcmd" variable should prevent this entirely. - U-boot disables JTAG when starting. To re-enable it, you need to execute the following command before booting: mw.l 1804006c 40 And also you need to disable the reset button in device tree if you intend to debug Linux, because reset button on GPIO0 shares the TCK pin. - On some versions of stock firmware, it is possible to obtain root shell, however not much is available in terms of debugging facitilies. 1. Login to the rkscli 2. Execute hidden command "Ruckus" 3. Copy and paste ";/bin/sh;" including quotes. This is required only once, the payload will be stored in writable filesystem. 4. Execute hidden command "!v54!". Press Enter leaving empty reply for "What's your chow?" prompt. 5. Busybox shell shall open. Source: https://alephsecurity.com/vulns/aleph-2019014 Signed-off-by: Lech Perczak --- package/boot/uboot-envtools/files/ath79 | 1 + .../linux/ath79/dts/ar9342_ruckus_zf7321.dts | 54 +++++++++++++++++++ .../generic/base-files/etc/board.d/02_network | 2 + target/linux/ath79/image/generic.mk | 7 +++ 4 files changed, 64 insertions(+) create mode 100644 target/linux/ath79/dts/ar9342_ruckus_zf7321.dts diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index 9e4d0ff96d..a27b751d9b 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -126,6 +126,7 @@ plasmacloud,pa300e) qihoo,c301) ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x10000" "0x10000" ;; +ruckus,zf7321|\ ruckus,zf7372) ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x40000" "0x10000" ;; diff --git a/target/linux/ath79/dts/ar9342_ruckus_zf7321.dts b/target/linux/ath79/dts/ar9342_ruckus_zf7321.dts new file mode 100644 index 0000000000..7bfc85d086 --- /dev/null +++ b/target/linux/ath79/dts/ar9342_ruckus_zf7321.dts @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ar934x_ruckus_zf73xx.dtsi" + +/ { + model = "Ruckus ZoneFlex 7321[-U]"; + compatible = "ruckus,zf7321", "qca,ar9342"; + + leds { + air-green { + label = "green:air"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + dir-green { + label = "green:dir"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + }; + + power_red: power-red { + label = "red:power"; + gpios = <&gpio 11 GPIO_ACTIVE_HIGH>; + panic-indicator; + }; + + wlan2g-green { + label = "green:wlan2g"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0assoc"; + }; + + wlan2g-yellow { + label = "yellow:wlan2g"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + wlan5g-green { + label = "green:wlan5g"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0assoc"; + }; + + wlan5g-yellow { + label = "yellow:wlan5g"; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + }; +}; + +ð0 { + nvmem-cells = <&macaddr_board_data_66>; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index 27482129ce..4683264c1c 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -65,6 +65,7 @@ ath79_setup_interfaces() pisen,ts-d084|\ pisen,wmb001n|\ pisen,wmm003n|\ + ruckus,zf7321|\ siemens,ws-ap3610|\ sophos,ap15|\ sophos,ap55|\ @@ -699,6 +700,7 @@ ath79_setup_macs() wan_mac=$(mtd_get_mac_binary factory 0x0) lan_mac=$(macaddr_setbit_la "$wan_mac") ;; + ruckus,zf7321|\ ruckus,zf7372) lan_mac=$(mtd_get_mac_binary board-data 0x807E) label_mac=$lan_mac diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 2439429c60..ff7c3b156e 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -2389,6 +2389,13 @@ define Device/ruckus_zf73xx_common KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | uImage none endef +define Device/ruckus_zf7321 + $(Device/ruckus_zf73xx_common) + SOC := ar9342 + DEVICE_MODEL := ZoneFlex 7321[-U] +endef +TARGET_DEVICES += ruckus_zf7321 + define Device/ruckus_zf7372 $(Device/ruckus_zf73xx_common) SOC := ar9344 From 0be1b78856794589a552f662f428081600e837cc Mon Sep 17 00:00:00 2001 From: Gregory Detal Date: Fri, 2 Sep 2022 10:02:19 +0200 Subject: [PATCH 033/114] ipq40xx: cellc_rtl30vw: fix imagebuilder generation The image build process was modifying the generated IMAGE_KERNEL to append rootfs information (crc). This caused: - sysupgrade & factory images to contain 2 times the root.squashfs information due to both modifying the same IMAGE_KERNEL. - the generated imagebuilder to contain an erroneous IMAGE_KERNEL that contained references to an unexisting root.squashfs (the one from previous cause). The RTL30VW wasn't therefore able to boot the generated images as they contained checksums from non existing rootfs. This commit makes sure to use a temporary IMAGE_KERNEL to append the rootfs information for both factory and sysupgrade images. Fixes: #10511 Signed-off-by: Gregory Detal --- target/linux/ipq40xx/image/generic.mk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/target/linux/ipq40xx/image/generic.mk b/target/linux/ipq40xx/image/generic.mk index 102de5c8bf..8e15f7ea20 100644 --- a/target/linux/ipq40xx/image/generic.mk +++ b/target/linux/ipq40xx/image/generic.mk @@ -43,7 +43,8 @@ define Build/append-rootfshdr -O linux -T filesystem \ -C lzma -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \ -n root.squashfs -d $(IMAGE_ROOTFS) $@.new - dd if=$@.new bs=64 count=1 >> $(IMAGE_KERNEL) + cat $(IMAGE_KERNEL) > $@.$1 + dd if=$@.new bs=64 count=1 >> $@.$1 endef define Build/append-rutx-metadata @@ -89,7 +90,7 @@ endef define Build/qsdk-ipq-factory-nand-askey $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh $@.its\ - askey_kernel $(IMAGE_KERNEL) \ + askey_kernel $@.$1 \ askey_fs $(IMAGE_ROOTFS) \ ubifs $@ PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new @@ -313,8 +314,8 @@ define Device/cellc_rtl30vw KERNEL_NAME := zImage KERNEL_IN_UBI := IMAGES := nand-factory.bin nand-sysupgrade.bin - IMAGE/nand-factory.bin := append-rootfshdr | append-ubi | qsdk-ipq-factory-nand-askey - IMAGE/nand-sysupgrade.bin := append-rootfshdr | sysupgrade-tar | append-metadata + IMAGE/nand-factory.bin := append-rootfshdr kernel | append-ubi | qsdk-ipq-factory-nand-askey kernel + IMAGE/nand-sysupgrade.bin := append-rootfshdr kernel | sysupgrade-tar kernel=$$$$@.kernel | append-metadata DEVICE_VENDOR := Cell C DEVICE_MODEL := RTL30VW SOC := qcom-ipq4019 From 05158082f669aeb16a85604620abf7973a5ea807 Mon Sep 17 00:00:00 2001 From: Rui Salvaterra Date: Tue, 29 Mar 2022 17:10:48 +0100 Subject: [PATCH 034/114] kernel: add and enable MGLRU for Linux 5.15 Backport a preliminary version of Yu Zhao's multi-generational LRU, for improved memory management. Refresh the patches while at it. Signed-off-by: Rui Salvaterra --- target/linux/generic/config-5.15 | 5 + ...-x86-arm64-add-arch_has_hw_pte_young.patch | 169 +++ ...dd-CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG.patch | 111 ++ ...-02-mm-vmscan.c-refactor-shrink_node.patch | 224 ++++ ...-mm-multigenerational-lru-groundwork.patch | 996 ++++++++++++++ ...multigenerational-lru-mm_struct-list.patch | 760 +++++++++++ ...20-05-mm-multigenerational-lru-aging.patch | 1176 +++++++++++++++++ ...06-mm-multigenerational-lru-eviction.patch | 1002 ++++++++++++++ ...multigenerational-lru-user-interface.patch | 496 +++++++ ...-08-mm-multigenerational-lru-Kconfig.patch | 80 ++ ...-multigenerational-lru-documentation.patch | 161 +++ 11 files changed, 5180 insertions(+) create mode 100644 target/linux/generic/pending-5.15/020-00-mm-x86-arm64-add-arch_has_hw_pte_young.patch create mode 100644 target/linux/generic/pending-5.15/020-01-mm-x86-add-CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG.patch create mode 100644 target/linux/generic/pending-5.15/020-02-mm-vmscan.c-refactor-shrink_node.patch create mode 100644 target/linux/generic/pending-5.15/020-03-mm-multigenerational-lru-groundwork.patch create mode 100644 target/linux/generic/pending-5.15/020-04-mm-multigenerational-lru-mm_struct-list.patch create mode 100644 target/linux/generic/pending-5.15/020-05-mm-multigenerational-lru-aging.patch create mode 100644 target/linux/generic/pending-5.15/020-06-mm-multigenerational-lru-eviction.patch create mode 100644 target/linux/generic/pending-5.15/020-07-mm-multigenerational-lru-user-interface.patch create mode 100644 target/linux/generic/pending-5.15/020-08-mm-multigenerational-lru-Kconfig.patch create mode 100644 target/linux/generic/pending-5.15/020-09-mm-multigenerational-lru-documentation.patch diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index efeaf2c452..f188ce36ac 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -3195,6 +3195,9 @@ CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 # CONFIG_LPC_ICH is not set # CONFIG_LPC_SCH is not set # CONFIG_LP_CONSOLE is not set +CONFIG_LRU_GEN=y +CONFIG_LRU_GEN_ENABLED=y +# CONFIG_LRU_GEN_STATS is not set # CONFIG_LSI_ET1011C_PHY is not set CONFIG_LSM="lockdown,yama,loadpin,safesetid,integrity" CONFIG_LSM_MMAP_MIN_ADDR=65536 @@ -4388,6 +4391,7 @@ CONFIG_NMI_LOG_BUF_SHIFT=13 # CONFIG_NO_HZ is not set # CONFIG_NO_HZ_FULL is not set # CONFIG_NO_HZ_IDLE is not set +CONFIG_NR_LRU_GENS=7 # CONFIG_NS83820 is not set # CONFIG_NTB is not set # CONFIG_NTFS3_64BIT_CLUSTER is not set @@ -6480,6 +6484,7 @@ CONFIG_THIN_ARCHIVES=y # CONFIG_THUNDER_NIC_VF is not set # CONFIG_TICK_CPU_ACCOUNTING is not set CONFIG_TICK_ONESHOT=y +CONFIG_TIERS_PER_GEN=4 # CONFIG_TIFM_CORE is not set # CONFIG_TIGON3 is not set # CONFIG_TIMB_DMA is not set diff --git a/target/linux/generic/pending-5.15/020-00-mm-x86-arm64-add-arch_has_hw_pte_young.patch b/target/linux/generic/pending-5.15/020-00-mm-x86-arm64-add-arch_has_hw_pte_young.patch new file mode 100644 index 0000000000..548d8e61b2 --- /dev/null +++ b/target/linux/generic/pending-5.15/020-00-mm-x86-arm64-add-arch_has_hw_pte_young.patch @@ -0,0 +1,169 @@ +From a8e6015d9534f39abc08e6804566af059e498a60 Mon Sep 17 00:00:00 2001 +From: Yu Zhao +Date: Wed, 4 Aug 2021 01:31:34 -0600 +Subject: [PATCH 01/10] mm: x86, arm64: add arch_has_hw_pte_young() + +Some architectures automatically set the accessed bit in PTEs, e.g., +x86 and arm64 v8.2. On architectures that do not have this capability, +clearing the accessed bit in a PTE triggers a page fault following the +TLB miss of this PTE. + +Being aware of this capability can help make better decisions, i.e., +whether to limit the size of each batch of PTEs and the burst of +batches when clearing the accessed bit. + +Signed-off-by: Yu Zhao +Change-Id: Ib49b44fb56df3333a2ff1fcc496fb1980b976e7a +--- + arch/arm64/include/asm/cpufeature.h | 5 +++++ + arch/arm64/include/asm/pgtable.h | 13 ++++++++----- + arch/arm64/kernel/cpufeature.c | 10 ++++++++++ + arch/arm64/tools/cpucaps | 1 + + arch/x86/include/asm/pgtable.h | 6 +++--- + include/linux/pgtable.h | 13 +++++++++++++ + mm/memory.c | 14 +------------- + 7 files changed, 41 insertions(+), 21 deletions(-) + +--- a/arch/arm64/include/asm/cpufeature.h ++++ b/arch/arm64/include/asm/cpufeature.h +@@ -808,6 +808,11 @@ static inline bool system_supports_tlb_r + cpus_have_const_cap(ARM64_HAS_TLB_RANGE); + } + ++static inline bool system_has_hw_af(void) ++{ ++ return IS_ENABLED(CONFIG_ARM64_HW_AFDBM) && cpus_have_const_cap(ARM64_HW_AF); ++} ++ + extern int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt); + + static inline u32 id_aa64mmfr0_parange_to_phys_shift(int parange) +--- a/arch/arm64/include/asm/pgtable.h ++++ b/arch/arm64/include/asm/pgtable.h +@@ -999,13 +999,16 @@ static inline void update_mmu_cache(stru + * page after fork() + CoW for pfn mappings. We don't always have a + * hardware-managed access flag on arm64. + */ +-static inline bool arch_faults_on_old_pte(void) ++static inline bool arch_has_hw_pte_young(bool local) + { +- WARN_ON(preemptible()); ++ if (local) { ++ WARN_ON(preemptible()); ++ return cpu_has_hw_af(); ++ } + +- return !cpu_has_hw_af(); ++ return system_has_hw_af(); + } +-#define arch_faults_on_old_pte arch_faults_on_old_pte ++#define arch_has_hw_pte_young arch_has_hw_pte_young + + /* + * Experimentally, it's cheap to set the access flag in hardware and we +@@ -1013,7 +1016,7 @@ static inline bool arch_faults_on_old_pt + */ + static inline bool arch_wants_old_prefaulted_pte(void) + { +- return !arch_faults_on_old_pte(); ++ return arch_has_hw_pte_young(true); + } + #define arch_wants_old_prefaulted_pte arch_wants_old_prefaulted_pte + +--- a/arch/arm64/kernel/cpufeature.c ++++ b/arch/arm64/kernel/cpufeature.c +@@ -2184,6 +2184,16 @@ static const struct arm64_cpu_capabiliti + .matches = has_hw_dbm, + .cpu_enable = cpu_enable_hw_dbm, + }, ++ { ++ .desc = "Hardware update of the Access flag", ++ .type = ARM64_CPUCAP_SYSTEM_FEATURE, ++ .capability = ARM64_HW_AF, ++ .sys_reg = SYS_ID_AA64MMFR1_EL1, ++ .sign = FTR_UNSIGNED, ++ .field_pos = ID_AA64MMFR1_HADBS_SHIFT, ++ .min_field_value = 1, ++ .matches = has_cpuid_feature, ++ }, + #endif + { + .desc = "CRC32 instructions", +--- a/arch/arm64/tools/cpucaps ++++ b/arch/arm64/tools/cpucaps +@@ -35,6 +35,7 @@ HAS_STAGE2_FWB + HAS_SYSREG_GIC_CPUIF + HAS_TLB_RANGE + HAS_VIRT_HOST_EXTN ++HW_AF + HW_DBM + KVM_PROTECTED_MODE + MISMATCHED_CACHE_TYPE +--- a/arch/x86/include/asm/pgtable.h ++++ b/arch/x86/include/asm/pgtable.h +@@ -1397,10 +1397,10 @@ static inline bool arch_has_pfn_modify_c + return boot_cpu_has_bug(X86_BUG_L1TF); + } + +-#define arch_faults_on_old_pte arch_faults_on_old_pte +-static inline bool arch_faults_on_old_pte(void) ++#define arch_has_hw_pte_young arch_has_hw_pte_young ++static inline bool arch_has_hw_pte_young(bool local) + { +- return false; ++ return true; + } + + #endif /* __ASSEMBLY__ */ +--- a/include/linux/pgtable.h ++++ b/include/linux/pgtable.h +@@ -259,6 +259,19 @@ static inline int pmdp_clear_flush_young + #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ + #endif + ++#ifndef arch_has_hw_pte_young ++/* ++ * Return whether the accessed bit is supported by the local CPU or all CPUs. ++ * ++ * Those arches which have hw access flag feature need to implement their own ++ * helper. By default, "false" means pagefault will be hit on old pte. ++ */ ++static inline bool arch_has_hw_pte_young(bool local) ++{ ++ return false; ++} ++#endif ++ + #ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR + static inline pte_t ptep_get_and_clear(struct mm_struct *mm, + unsigned long address, +--- a/mm/memory.c ++++ b/mm/memory.c +@@ -121,18 +121,6 @@ int randomize_va_space __read_mostly = + 2; + #endif + +-#ifndef arch_faults_on_old_pte +-static inline bool arch_faults_on_old_pte(void) +-{ +- /* +- * Those arches which don't have hw access flag feature need to +- * implement their own helper. By default, "true" means pagefault +- * will be hit on old pte. +- */ +- return true; +-} +-#endif +- + #ifndef arch_wants_old_prefaulted_pte + static inline bool arch_wants_old_prefaulted_pte(void) + { +@@ -2782,7 +2770,7 @@ static inline bool cow_user_page(struct + * On architectures with software "accessed" bits, we would + * take a double page fault, so mark it accessed here. + */ +- if (arch_faults_on_old_pte() && !pte_young(vmf->orig_pte)) { ++ if (!arch_has_hw_pte_young(true) && !pte_young(vmf->orig_pte)) { + pte_t entry; + + vmf->pte = pte_offset_map_lock(mm, vmf->pmd, addr, &vmf->ptl); diff --git a/target/linux/generic/pending-5.15/020-01-mm-x86-add-CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG.patch b/target/linux/generic/pending-5.15/020-01-mm-x86-add-CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG.patch new file mode 100644 index 0000000000..785af275f5 --- /dev/null +++ b/target/linux/generic/pending-5.15/020-01-mm-x86-add-CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG.patch @@ -0,0 +1,111 @@ +From f8b663bbfa30af5515e222fd74df20ea4e8393a2 Mon Sep 17 00:00:00 2001 +From: Yu Zhao +Date: Sat, 26 Sep 2020 21:17:18 -0600 +Subject: [PATCH 02/10] mm: x86: add CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG + +Some architectures support the accessed bit on non-leaf PMD entries, +e.g., x86_64 sets the accessed bit on a non-leaf PMD entry when using +it as part of linear address translation [1]. As an optimization, page +table walkers who are interested in the accessed bit can skip the PTEs +under a non-leaf PMD entry if the accessed bit is cleared on this PMD +entry. + +Although an inline function may be preferable, this capability is +added as a configuration option to look consistent when used with the +existing macros. + +[1]: Intel 64 and IA-32 Architectures Software Developer's Manual + Volume 3 (June 2021), section 4.8 + +Signed-off-by: Yu Zhao +Tested-by: Konstantin Kharlamov +Change-Id: I1a17be3ae926f721f7b17ea1539e5c39e8c4f9a8 +--- + arch/Kconfig | 9 +++++++++ + arch/x86/Kconfig | 1 + + arch/x86/include/asm/pgtable.h | 3 ++- + arch/x86/mm/pgtable.c | 5 ++++- + include/linux/pgtable.h | 4 ++-- + 5 files changed, 18 insertions(+), 4 deletions(-) + +--- a/arch/Kconfig ++++ b/arch/Kconfig +@@ -1295,6 +1295,15 @@ config ARCH_HAS_ELFCORE_COMPAT + config ARCH_HAS_PARANOID_L1D_FLUSH + bool + ++config ARCH_HAS_NONLEAF_PMD_YOUNG ++ bool ++ depends on PGTABLE_LEVELS > 2 ++ help ++ Architectures that select this are able to set the accessed bit on ++ non-leaf PMD entries in addition to leaf PTE entries where pages are ++ mapped. For them, page table walkers that clear the accessed bit may ++ stop at non-leaf PMD entries if they do not see the accessed bit. ++ + source "kernel/gcov/Kconfig" + + source "scripts/gcc-plugins/Kconfig" +--- a/arch/x86/Kconfig ++++ b/arch/x86/Kconfig +@@ -84,6 +84,7 @@ config X86 + select ARCH_HAS_PMEM_API if X86_64 + select ARCH_HAS_PTE_DEVMAP if X86_64 + select ARCH_HAS_PTE_SPECIAL ++ select ARCH_HAS_NONLEAF_PMD_YOUNG if X86_64 + select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 + select ARCH_HAS_COPY_MC if X86_64 + select ARCH_HAS_SET_MEMORY +--- a/arch/x86/include/asm/pgtable.h ++++ b/arch/x86/include/asm/pgtable.h +@@ -817,7 +817,8 @@ static inline unsigned long pmd_page_vad + + static inline int pmd_bad(pmd_t pmd) + { +- return (pmd_flags(pmd) & ~_PAGE_USER) != _KERNPG_TABLE; ++ return (pmd_flags(pmd) & ~(_PAGE_USER | _PAGE_ACCESSED)) != ++ (_KERNPG_TABLE & ~_PAGE_ACCESSED); + } + + static inline unsigned long pages_to_mb(unsigned long npg) +--- a/arch/x86/mm/pgtable.c ++++ b/arch/x86/mm/pgtable.c +@@ -550,7 +550,7 @@ int ptep_test_and_clear_young(struct vm_ + return ret; + } + +-#ifdef CONFIG_TRANSPARENT_HUGEPAGE ++#if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG) + int pmdp_test_and_clear_young(struct vm_area_struct *vma, + unsigned long addr, pmd_t *pmdp) + { +@@ -562,6 +562,9 @@ int pmdp_test_and_clear_young(struct vm_ + + return ret; + } ++#endif ++ ++#ifdef CONFIG_TRANSPARENT_HUGEPAGE + int pudp_test_and_clear_young(struct vm_area_struct *vma, + unsigned long addr, pud_t *pudp) + { +--- a/include/linux/pgtable.h ++++ b/include/linux/pgtable.h +@@ -212,7 +212,7 @@ static inline int ptep_test_and_clear_yo + #endif + + #ifndef __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG +-#ifdef CONFIG_TRANSPARENT_HUGEPAGE ++#if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG) + static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma, + unsigned long address, + pmd_t *pmdp) +@@ -233,7 +233,7 @@ static inline int pmdp_test_and_clear_yo + BUILD_BUG(); + return 0; + } +-#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ ++#endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG */ + #endif + + #ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH diff --git a/target/linux/generic/pending-5.15/020-02-mm-vmscan.c-refactor-shrink_node.patch b/target/linux/generic/pending-5.15/020-02-mm-vmscan.c-refactor-shrink_node.patch new file mode 100644 index 0000000000..f466f1105c --- /dev/null +++ b/target/linux/generic/pending-5.15/020-02-mm-vmscan.c-refactor-shrink_node.patch @@ -0,0 +1,224 @@ +From a810f8e2f1bdd0707eaf05c8b4ba84a3ff2801bd Mon Sep 17 00:00:00 2001 +From: Yu Zhao +Date: Sun, 27 Sep 2020 20:49:08 -0600 +Subject: [PATCH 03/10] mm/vmscan.c: refactor shrink_node() + +This patch refactors shrink_node(). This will make the upcoming +changes to mm/vmscan.c more readable. + +Signed-off-by: Yu Zhao +Tested-by: Konstantin Kharlamov +Change-Id: Iae734b5b4030205b7db6e8c841f747b6f6ae1a04 +--- + mm/vmscan.c | 186 +++++++++++++++++++++++++++------------------------- + 1 file changed, 98 insertions(+), 88 deletions(-) + +--- a/mm/vmscan.c ++++ b/mm/vmscan.c +@@ -2562,6 +2562,103 @@ enum scan_balance { + SCAN_FILE, + }; + ++static void prepare_scan_count(pg_data_t *pgdat, struct scan_control *sc) ++{ ++ unsigned long file; ++ struct lruvec *target_lruvec; ++ ++ target_lruvec = mem_cgroup_lruvec(sc->target_mem_cgroup, pgdat); ++ ++ /* ++ * Determine the scan balance between anon and file LRUs. ++ */ ++ spin_lock_irq(&target_lruvec->lru_lock); ++ sc->anon_cost = target_lruvec->anon_cost; ++ sc->file_cost = target_lruvec->file_cost; ++ spin_unlock_irq(&target_lruvec->lru_lock); ++ ++ /* ++ * Target desirable inactive:active list ratios for the anon ++ * and file LRU lists. ++ */ ++ if (!sc->force_deactivate) { ++ unsigned long refaults; ++ ++ refaults = lruvec_page_state(target_lruvec, ++ WORKINGSET_ACTIVATE_ANON); ++ if (refaults != target_lruvec->refaults[0] || ++ inactive_is_low(target_lruvec, LRU_INACTIVE_ANON)) ++ sc->may_deactivate |= DEACTIVATE_ANON; ++ else ++ sc->may_deactivate &= ~DEACTIVATE_ANON; ++ ++ /* ++ * When refaults are being observed, it means a new ++ * workingset is being established. Deactivate to get ++ * rid of any stale active pages quickly. ++ */ ++ refaults = lruvec_page_state(target_lruvec, ++ WORKINGSET_ACTIVATE_FILE); ++ if (refaults != target_lruvec->refaults[1] || ++ inactive_is_low(target_lruvec, LRU_INACTIVE_FILE)) ++ sc->may_deactivate |= DEACTIVATE_FILE; ++ else ++ sc->may_deactivate &= ~DEACTIVATE_FILE; ++ } else ++ sc->may_deactivate = DEACTIVATE_ANON | DEACTIVATE_FILE; ++ ++ /* ++ * If we have plenty of inactive file pages that aren't ++ * thrashing, try to reclaim those first before touching ++ * anonymous pages. ++ */ ++ file = lruvec_page_state(target_lruvec, NR_INACTIVE_FILE); ++ if (file >> sc->priority && !(sc->may_deactivate & DEACTIVATE_FILE)) ++ sc->cache_trim_mode = 1; ++ else ++ sc->cache_trim_mode = 0; ++ ++ /* ++ * Prevent the reclaimer from falling into the cache trap: as ++ * cache pages start out inactive, every cache fault will tip ++ * the scan balance towards the file LRU. And as the file LRU ++ * shrinks, so does the window for rotation from references. ++ * This means we have a runaway feedback loop where a tiny ++ * thrashing file LRU becomes infinitely more attractive than ++ * anon pages. Try to detect this based on file LRU size. ++ */ ++ if (!cgroup_reclaim(sc)) { ++ unsigned long total_high_wmark = 0; ++ unsigned long free, anon; ++ int z; ++ ++ free = sum_zone_node_page_state(pgdat->node_id, NR_FREE_PAGES); ++ file = node_page_state(pgdat, NR_ACTIVE_FILE) + ++ node_page_state(pgdat, NR_INACTIVE_FILE); ++ ++ for (z = 0; z < MAX_NR_ZONES; z++) { ++ struct zone *zone = &pgdat->node_zones[z]; ++ ++ if (!managed_zone(zone)) ++ continue; ++ ++ total_high_wmark += high_wmark_pages(zone); ++ } ++ ++ /* ++ * Consider anon: if that's low too, this isn't a ++ * runaway file reclaim problem, but rather just ++ * extreme pressure. Reclaim as per usual then. ++ */ ++ anon = node_page_state(pgdat, NR_INACTIVE_ANON); ++ ++ sc->file_is_tiny = ++ file + free <= total_high_wmark && ++ !(sc->may_deactivate & DEACTIVATE_ANON) && ++ anon >> sc->priority; ++ } ++} ++ + /* + * Determine how aggressively the anon and file LRU lists should be + * scanned. The relative value of each set of LRU lists is determined +@@ -3032,7 +3129,6 @@ static void shrink_node(pg_data_t *pgdat + unsigned long nr_reclaimed, nr_scanned; + struct lruvec *target_lruvec; + bool reclaimable = false; +- unsigned long file; + + target_lruvec = mem_cgroup_lruvec(sc->target_mem_cgroup, pgdat); + +@@ -3048,93 +3144,7 @@ again: + nr_reclaimed = sc->nr_reclaimed; + nr_scanned = sc->nr_scanned; + +- /* +- * Determine the scan balance between anon and file LRUs. +- */ +- spin_lock_irq(&target_lruvec->lru_lock); +- sc->anon_cost = target_lruvec->anon_cost; +- sc->file_cost = target_lruvec->file_cost; +- spin_unlock_irq(&target_lruvec->lru_lock); +- +- /* +- * Target desirable inactive:active list ratios for the anon +- * and file LRU lists. +- */ +- if (!sc->force_deactivate) { +- unsigned long refaults; +- +- refaults = lruvec_page_state(target_lruvec, +- WORKINGSET_ACTIVATE_ANON); +- if (refaults != target_lruvec->refaults[0] || +- inactive_is_low(target_lruvec, LRU_INACTIVE_ANON)) +- sc->may_deactivate |= DEACTIVATE_ANON; +- else +- sc->may_deactivate &= ~DEACTIVATE_ANON; +- +- /* +- * When refaults are being observed, it means a new +- * workingset is being established. Deactivate to get +- * rid of any stale active pages quickly. +- */ +- refaults = lruvec_page_state(target_lruvec, +- WORKINGSET_ACTIVATE_FILE); +- if (refaults != target_lruvec->refaults[1] || +- inactive_is_low(target_lruvec, LRU_INACTIVE_FILE)) +- sc->may_deactivate |= DEACTIVATE_FILE; +- else +- sc->may_deactivate &= ~DEACTIVATE_FILE; +- } else +- sc->may_deactivate = DEACTIVATE_ANON | DEACTIVATE_FILE; +- +- /* +- * If we have plenty of inactive file pages that aren't +- * thrashing, try to reclaim those first before touching +- * anonymous pages. +- */ +- file = lruvec_page_state(target_lruvec, NR_INACTIVE_FILE); +- if (file >> sc->priority && !(sc->may_deactivate & DEACTIVATE_FILE)) +- sc->cache_trim_mode = 1; +- else +- sc->cache_trim_mode = 0; +- +- /* +- * Prevent the reclaimer from falling into the cache trap: as +- * cache pages start out inactive, every cache fault will tip +- * the scan balance towards the file LRU. And as the file LRU +- * shrinks, so does the window for rotation from references. +- * This means we have a runaway feedback loop where a tiny +- * thrashing file LRU becomes infinitely more attractive than +- * anon pages. Try to detect this based on file LRU size. +- */ +- if (!cgroup_reclaim(sc)) { +- unsigned long total_high_wmark = 0; +- unsigned long free, anon; +- int z; +- +- free = sum_zone_node_page_state(pgdat->node_id, NR_FREE_PAGES); +- file = node_page_state(pgdat, NR_ACTIVE_FILE) + +- node_page_state(pgdat, NR_INACTIVE_FILE); +- +- for (z = 0; z < MAX_NR_ZONES; z++) { +- struct zone *zone = &pgdat->node_zones[z]; +- if (!managed_zone(zone)) +- continue; +- +- total_high_wmark += high_wmark_pages(zone); +- } +- +- /* +- * Consider anon: if that's low too, this isn't a +- * runaway file reclaim problem, but rather just +- * extreme pressure. Reclaim as per usual then. +- */ +- anon = node_page_state(pgdat, NR_INACTIVE_ANON); +- +- sc->file_is_tiny = +- file + free <= total_high_wmark && +- !(sc->may_deactivate & DEACTIVATE_ANON) && +- anon >> sc->priority; +- } ++ prepare_scan_count(pgdat, sc); + + shrink_node_memcgs(pgdat, sc); + diff --git a/target/linux/generic/pending-5.15/020-03-mm-multigenerational-lru-groundwork.patch b/target/linux/generic/pending-5.15/020-03-mm-multigenerational-lru-groundwork.patch new file mode 100644 index 0000000000..146f510d28 --- /dev/null +++ b/target/linux/generic/pending-5.15/020-03-mm-multigenerational-lru-groundwork.patch @@ -0,0 +1,996 @@ +From 05f366c941ae2bb8ba21c79fafcb747a5a6b967b Mon Sep 17 00:00:00 2001 +From: Yu Zhao +Date: Mon, 25 Jan 2021 21:12:33 -0700 +Subject: [PATCH 04/10] mm: multigenerational lru: groundwork + +For each lruvec, evictable pages are divided into multiple +generations. The youngest generation number is stored in +lrugen->max_seq for both anon and file types as they are aged on an +equal footing. The oldest generation numbers are stored in +lrugen->min_seq[] separately for anon and file types as clean file +pages can be evicted regardless of swap constraints. These three +variables are monotonically increasing. Generation numbers are +truncated into order_base_2(MAX_NR_GENS+1) bits in order to fit into +page->flags. The sliding window technique is used to prevent truncated +generation numbers from overlapping. Each truncated generation number +is an index to +lrugen->lists[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES]. + +The framework comprises two conceptually independent components: the +aging, which produces young generations, and the eviction, which +consumes old generations. Both can be invoked independently from user +space for the purpose of working set estimation and proactive reclaim. + +The protection of hot pages and the selection of cold pages are based +on page access types and patterns. There are two access types: one via +page tables and the other via file descriptors. The protection of the +former type is by design stronger because: + 1) The uncertainty in determining the access patterns of the former + type is higher due to the coalesced nature of the accessed bit. + 2) The cost of evicting the former type is higher due to the TLB + flushes required and the likelihood of involving I/O. + 3) The penalty of under-protecting the former type is higher because + applications usually do not prepare themselves for major faults like + they do for blocked I/O. For example, client applications commonly + dedicate blocked I/O to separate threads to avoid UI janks that + negatively affect user experience. + +There are also two access patterns: one with temporal locality and the +other without. The latter pattern, e.g., random and sequential, needs +to be explicitly excluded to avoid weakening the protection of the +former pattern. Generally the former type follows the former pattern +unless MADV_SEQUENTIAL is specified and the latter type follows the +latter pattern unless outlying refaults have been observed. + +Upon faulting, a page is added to the youngest generation, which +provides the strongest protection as the eviction will not consider +this page before the aging has scanned it at least twice. The first +scan clears the accessed bit set during the initial fault. And the +second scan makes sure this page has not been used since the first +scan. A page from any other generations is brought back to the +youngest generation whenever the aging finds the accessed bit set on +any of the PTEs mapping this page. + +Unmapped pages are initially added to the oldest generation and then +conditionally protected by tiers. This is done later [PATCH 07/10]. + +Signed-off-by: Yu Zhao +Tested-by: Konstantin Kharlamov +Change-Id: I71de7cd15b8dfa6f9fdd838023474693c4fee0a7 +--- + fs/fuse/dev.c | 3 +- + include/linux/cgroup.h | 15 +- + include/linux/mm.h | 36 ++++ + include/linux/mm_inline.h | 182 ++++++++++++++++++++ + include/linux/mmzone.h | 70 ++++++++ + include/linux/page-flags-layout.h | 19 ++- + include/linux/page-flags.h | 4 +- + include/linux/sched.h | 3 + + kernel/bounds.c | 3 + + kernel/cgroup/cgroup-internal.h | 1 - + mm/huge_memory.c | 3 +- + mm/memcontrol.c | 1 + + mm/memory.c | 7 + + mm/mm_init.c | 6 +- + mm/page_alloc.c | 1 + + mm/swap.c | 9 +- + mm/swapfile.c | 2 + + mm/vmscan.c | 268 ++++++++++++++++++++++++++++++ + 18 files changed, 618 insertions(+), 15 deletions(-) + +--- a/fs/fuse/dev.c ++++ b/fs/fuse/dev.c +@@ -785,7 +785,8 @@ static int fuse_check_page(struct page * + 1 << PG_active | + 1 << PG_workingset | + 1 << PG_reclaim | +- 1 << PG_waiters))) { ++ 1 << PG_waiters | ++ LRU_GEN_MASK | LRU_REFS_MASK))) { + dump_page(page, "fuse: trying to steal weird page"); + return 1; + } +--- a/include/linux/cgroup.h ++++ b/include/linux/cgroup.h +@@ -432,6 +432,18 @@ static inline void cgroup_put(struct cgr + css_put(&cgrp->self); + } + ++extern struct mutex cgroup_mutex; ++ ++static inline void cgroup_lock(void) ++{ ++ mutex_lock(&cgroup_mutex); ++} ++ ++static inline void cgroup_unlock(void) ++{ ++ mutex_unlock(&cgroup_mutex); ++} ++ + /** + * task_css_set_check - obtain a task's css_set with extra access conditions + * @task: the task to obtain css_set for +@@ -446,7 +458,6 @@ static inline void cgroup_put(struct cgr + * as locks used during the cgroup_subsys::attach() methods. + */ + #ifdef CONFIG_PROVE_RCU +-extern struct mutex cgroup_mutex; + extern spinlock_t css_set_lock; + #define task_css_set_check(task, __c) \ + rcu_dereference_check((task)->cgroups, \ +@@ -707,6 +718,8 @@ struct cgroup; + static inline u64 cgroup_id(const struct cgroup *cgrp) { return 1; } + static inline void css_get(struct cgroup_subsys_state *css) {} + static inline void css_put(struct cgroup_subsys_state *css) {} ++static inline void cgroup_lock(void) {} ++static inline void cgroup_unlock(void) {} + static inline int cgroup_attach_task_all(struct task_struct *from, + struct task_struct *t) { return 0; } + static inline int cgroupstats_build(struct cgroupstats *stats, +--- a/include/linux/mm.h ++++ b/include/linux/mm.h +@@ -1093,6 +1093,8 @@ vm_fault_t finish_mkwrite_fault(struct v + #define ZONES_PGOFF (NODES_PGOFF - ZONES_WIDTH) + #define LAST_CPUPID_PGOFF (ZONES_PGOFF - LAST_CPUPID_WIDTH) + #define KASAN_TAG_PGOFF (LAST_CPUPID_PGOFF - KASAN_TAG_WIDTH) ++#define LRU_GEN_PGOFF (KASAN_TAG_PGOFF - LRU_GEN_WIDTH) ++#define LRU_REFS_PGOFF (LRU_GEN_PGOFF - LRU_REFS_WIDTH) + + /* + * Define the bit shifts to access each section. For non-existent +@@ -1807,6 +1809,40 @@ static inline void unmap_mapping_range(s + loff_t const holebegin, loff_t const holelen, int even_cows) { } + #endif + ++#ifdef CONFIG_LRU_GEN ++static inline void task_enter_nonseq_fault(void) ++{ ++ WARN_ON(current->in_nonseq_fault); ++ ++ current->in_nonseq_fault = 1; ++} ++ ++static inline void task_exit_nonseq_fault(void) ++{ ++ WARN_ON(!current->in_nonseq_fault); ++ ++ current->in_nonseq_fault = 0; ++} ++ ++static inline bool task_in_nonseq_fault(void) ++{ ++ return current->in_nonseq_fault; ++} ++#else ++static inline void task_enter_nonseq_fault(void) ++{ ++} ++ ++static inline void task_exit_nonseq_fault(void) ++{ ++} ++ ++static inline bool task_in_nonseq_fault(void) ++{ ++ return false; ++} ++#endif /* CONFIG_LRU_GEN */ ++ + static inline void unmap_shared_mapping_range(struct address_space *mapping, + loff_t const holebegin, loff_t const holelen) + { +--- a/include/linux/mm_inline.h ++++ b/include/linux/mm_inline.h +@@ -79,11 +79,187 @@ static __always_inline enum lru_list pag + return lru; + } + ++#ifdef CONFIG_LRU_GEN ++ ++static inline bool lru_gen_enabled(void) ++{ ++#ifdef CONFIG_LRU_GEN_ENABLED ++ DECLARE_STATIC_KEY_TRUE(lru_gen_static_key); ++ ++ return static_branch_likely(&lru_gen_static_key); ++#else ++ DECLARE_STATIC_KEY_FALSE(lru_gen_static_key); ++ ++ return static_branch_unlikely(&lru_gen_static_key); ++#endif ++} ++ ++/* Return an index within the sliding window that tracks MAX_NR_GENS generations. */ ++static inline int lru_gen_from_seq(unsigned long seq) ++{ ++ return seq % MAX_NR_GENS; ++} ++ ++/* The youngest and the second youngest generations are counted as active. */ ++static inline bool lru_gen_is_active(struct lruvec *lruvec, int gen) ++{ ++ unsigned long max_seq = lruvec->evictable.max_seq; ++ ++ VM_BUG_ON(gen >= MAX_NR_GENS); ++ ++ return gen == lru_gen_from_seq(max_seq) || gen == lru_gen_from_seq(max_seq - 1); ++} ++ ++/* Update the sizes of the multigenerational lru lists. */ ++static inline void lru_gen_update_size(struct page *page, struct lruvec *lruvec, ++ int old_gen, int new_gen) ++{ ++ int type = page_is_file_lru(page); ++ int zone = page_zonenum(page); ++ int delta = thp_nr_pages(page); ++ enum lru_list lru = type * LRU_FILE; ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ lockdep_assert_held(&lruvec->lru_lock); ++ VM_BUG_ON(old_gen != -1 && old_gen >= MAX_NR_GENS); ++ VM_BUG_ON(new_gen != -1 && new_gen >= MAX_NR_GENS); ++ VM_BUG_ON(old_gen == -1 && new_gen == -1); ++ ++ if (old_gen >= 0) ++ WRITE_ONCE(lrugen->sizes[old_gen][type][zone], ++ lrugen->sizes[old_gen][type][zone] - delta); ++ if (new_gen >= 0) ++ WRITE_ONCE(lrugen->sizes[new_gen][type][zone], ++ lrugen->sizes[new_gen][type][zone] + delta); ++ ++ if (old_gen < 0) { ++ if (lru_gen_is_active(lruvec, new_gen)) ++ lru += LRU_ACTIVE; ++ update_lru_size(lruvec, lru, zone, delta); ++ return; ++ } ++ ++ if (new_gen < 0) { ++ if (lru_gen_is_active(lruvec, old_gen)) ++ lru += LRU_ACTIVE; ++ update_lru_size(lruvec, lru, zone, -delta); ++ return; ++ } ++ ++ if (!lru_gen_is_active(lruvec, old_gen) && lru_gen_is_active(lruvec, new_gen)) { ++ update_lru_size(lruvec, lru, zone, -delta); ++ update_lru_size(lruvec, lru + LRU_ACTIVE, zone, delta); ++ } ++ ++ VM_BUG_ON(lru_gen_is_active(lruvec, old_gen) && !lru_gen_is_active(lruvec, new_gen)); ++} ++ ++/* Add a page to one of the multigenerational lru lists. Return true on success. */ ++static inline bool lru_gen_add_page(struct page *page, struct lruvec *lruvec, bool reclaiming) ++{ ++ int gen; ++ unsigned long old_flags, new_flags; ++ int type = page_is_file_lru(page); ++ int zone = page_zonenum(page); ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ if (PageUnevictable(page) || !lrugen->enabled[type]) ++ return false; ++ /* ++ * If a page shouldn't be considered for eviction, i.e., a page mapped ++ * upon fault during which the accessed bit is set, add it to the ++ * youngest generation. ++ * ++ * If a page can't be evicted immediately, i.e., an anon page not in ++ * swap cache or a dirty page pending writeback, add it to the second ++ * oldest generation. ++ * ++ * If a page could be evicted immediately, e.g., a clean page, add it to ++ * the oldest generation. ++ */ ++ if (PageActive(page)) ++ gen = lru_gen_from_seq(lrugen->max_seq); ++ else if ((!type && !PageSwapCache(page)) || ++ (PageReclaim(page) && (PageDirty(page) || PageWriteback(page)))) ++ gen = lru_gen_from_seq(lrugen->min_seq[type] + 1); ++ else ++ gen = lru_gen_from_seq(lrugen->min_seq[type]); ++ ++ do { ++ new_flags = old_flags = READ_ONCE(page->flags); ++ VM_BUG_ON_PAGE(new_flags & LRU_GEN_MASK, page); ++ ++ new_flags &= ~(LRU_GEN_MASK | BIT(PG_active)); ++ new_flags |= (gen + 1UL) << LRU_GEN_PGOFF; ++ } while (cmpxchg(&page->flags, old_flags, new_flags) != old_flags); ++ ++ lru_gen_update_size(page, lruvec, -1, gen); ++ /* for rotate_reclaimable_page() */ ++ if (reclaiming) ++ list_add_tail(&page->lru, &lrugen->lists[gen][type][zone]); ++ else ++ list_add(&page->lru, &lrugen->lists[gen][type][zone]); ++ ++ return true; ++} ++ ++/* Delete a page from one of the multigenerational lru lists. Return true on success. */ ++static inline bool lru_gen_del_page(struct page *page, struct lruvec *lruvec, bool reclaiming) ++{ ++ int gen; ++ unsigned long old_flags, new_flags; ++ ++ do { ++ new_flags = old_flags = READ_ONCE(page->flags); ++ if (!(new_flags & LRU_GEN_MASK)) ++ return false; ++ ++ VM_BUG_ON_PAGE(PageActive(page), page); ++ VM_BUG_ON_PAGE(PageUnevictable(page), page); ++ ++ gen = ((new_flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1; ++ ++ new_flags &= ~LRU_GEN_MASK; ++ /* for shrink_page_list() */ ++ if (reclaiming) ++ new_flags &= ~(BIT(PG_referenced) | BIT(PG_reclaim)); ++ else if (lru_gen_is_active(lruvec, gen)) ++ new_flags |= BIT(PG_active); ++ } while (cmpxchg(&page->flags, old_flags, new_flags) != old_flags); ++ ++ lru_gen_update_size(page, lruvec, gen, -1); ++ list_del(&page->lru); ++ ++ return true; ++} ++ ++#else ++ ++static inline bool lru_gen_enabled(void) ++{ ++ return false; ++} ++ ++static inline bool lru_gen_add_page(struct page *page, struct lruvec *lruvec, bool reclaiming) ++{ ++ return false; ++} ++ ++static inline bool lru_gen_del_page(struct page *page, struct lruvec *lruvec, bool reclaiming) ++{ ++ return false; ++} ++ ++#endif /* CONFIG_LRU_GEN */ ++ + static __always_inline void add_page_to_lru_list(struct page *page, + struct lruvec *lruvec) + { + enum lru_list lru = page_lru(page); + ++ if (lru_gen_add_page(page, lruvec, false)) ++ return; ++ + update_lru_size(lruvec, lru, page_zonenum(page), thp_nr_pages(page)); + list_add(&page->lru, &lruvec->lists[lru]); + } +@@ -93,6 +269,9 @@ static __always_inline void add_page_to_ + { + enum lru_list lru = page_lru(page); + ++ if (lru_gen_add_page(page, lruvec, true)) ++ return; ++ + update_lru_size(lruvec, lru, page_zonenum(page), thp_nr_pages(page)); + list_add_tail(&page->lru, &lruvec->lists[lru]); + } +@@ -100,6 +279,9 @@ static __always_inline void add_page_to_ + static __always_inline void del_page_from_lru_list(struct page *page, + struct lruvec *lruvec) + { ++ if (lru_gen_del_page(page, lruvec, false)) ++ return; ++ + list_del(&page->lru); + update_lru_size(lruvec, page_lru(page), page_zonenum(page), + -thp_nr_pages(page)); +--- a/include/linux/mmzone.h ++++ b/include/linux/mmzone.h +@@ -294,6 +294,72 @@ enum lruvec_flags { + */ + }; + ++struct lruvec; ++ ++#define LRU_GEN_MASK ((BIT(LRU_GEN_WIDTH) - 1) << LRU_GEN_PGOFF) ++#define LRU_REFS_MASK ((BIT(LRU_REFS_WIDTH) - 1) << LRU_REFS_PGOFF) ++ ++#ifdef CONFIG_LRU_GEN ++ ++/* ++ * For each lruvec, evictable pages are divided into multiple generations. The ++ * youngest and the oldest generation numbers, AKA max_seq and min_seq, are ++ * monotonically increasing. The sliding window technique is used to track at ++ * least MIN_NR_GENS and at most MAX_NR_GENS generations. An offset within the ++ * window, AKA gen, indexes an array of per-type and per-zone lists for the ++ * corresponding generation. The counter in page->flags stores gen+1 while a ++ * page is on one of the multigenerational lru lists. Otherwise, it stores 0. ++ * ++ * After a page is faulted in, the aging must check the accessed bit at least ++ * twice before the eviction would consider it. The first check clears the ++ * accessed bit set during the initial fault. The second check makes sure this ++ * page hasn't been used since then. ++ */ ++#define MIN_NR_GENS 2 ++#define MAX_NR_GENS ((unsigned int)CONFIG_NR_LRU_GENS) ++ ++struct lrugen { ++ /* the aging increments the max generation number */ ++ unsigned long max_seq; ++ /* the eviction increments the min generation numbers */ ++ unsigned long min_seq[ANON_AND_FILE]; ++ /* the birth time of each generation in jiffies */ ++ unsigned long timestamps[MAX_NR_GENS]; ++ /* the multigenerational lru lists */ ++ struct list_head lists[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES]; ++ /* the sizes of the multigenerational lru lists in pages */ ++ unsigned long sizes[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES]; ++ /* whether the multigenerational lru is enabled */ ++ bool enabled[ANON_AND_FILE]; ++}; ++ ++#define MAX_BATCH_SIZE 8192 ++ ++void lru_gen_init_state(struct mem_cgroup *memcg, struct lruvec *lruvec); ++void lru_gen_change_state(bool enable, bool main, bool swap); ++ ++#ifdef CONFIG_MEMCG ++void lru_gen_init_memcg(struct mem_cgroup *memcg); ++#endif ++ ++#else /* !CONFIG_LRU_GEN */ ++ ++static inline void lru_gen_init_state(struct mem_cgroup *memcg, struct lruvec *lruvec) ++{ ++} ++ ++static inline void lru_gen_change_state(bool enable, bool main, bool swap) ++{ ++} ++ ++#ifdef CONFIG_MEMCG ++static inline void lru_gen_init_memcg(struct mem_cgroup *memcg) ++{ ++} ++#endif ++ ++#endif /* CONFIG_LRU_GEN */ ++ + struct lruvec { + struct list_head lists[NR_LRU_LISTS]; + /* per lruvec lru_lock for memcg */ +@@ -311,6 +377,10 @@ struct lruvec { + unsigned long refaults[ANON_AND_FILE]; + /* Various lruvec state flags (enum lruvec_flags) */ + unsigned long flags; ++#ifdef CONFIG_LRU_GEN ++ /* unevictable pages are on LRU_UNEVICTABLE */ ++ struct lrugen evictable; ++#endif + #ifdef CONFIG_MEMCG + struct pglist_data *pgdat; + #endif +--- a/include/linux/page-flags-layout.h ++++ b/include/linux/page-flags-layout.h +@@ -26,6 +26,14 @@ + + #define ZONES_WIDTH ZONES_SHIFT + ++#ifdef CONFIG_LRU_GEN ++/* LRU_GEN_WIDTH is generated from order_base_2(CONFIG_NR_LRU_GENS + 1). */ ++#define LRU_REFS_WIDTH (CONFIG_TIERS_PER_GEN - 2) ++#else ++#define LRU_GEN_WIDTH 0 ++#define LRU_REFS_WIDTH 0 ++#endif /* CONFIG_LRU_GEN */ ++ + #ifdef CONFIG_SPARSEMEM + #include + #define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS) +@@ -55,7 +63,8 @@ + #define SECTIONS_WIDTH 0 + #endif + +-#if ZONES_WIDTH + SECTIONS_WIDTH + NODES_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS ++#if ZONES_WIDTH + LRU_GEN_WIDTH + LRU_REFS_WIDTH + SECTIONS_WIDTH + NODES_SHIFT \ ++ <= BITS_PER_LONG - NR_PAGEFLAGS + #define NODES_WIDTH NODES_SHIFT + #elif defined(CONFIG_SPARSEMEM_VMEMMAP) + #error "Vmemmap: No space for nodes field in page flags" +@@ -89,8 +98,8 @@ + #define LAST_CPUPID_SHIFT 0 + #endif + +-#if ZONES_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + KASAN_TAG_WIDTH + LAST_CPUPID_SHIFT \ +- <= BITS_PER_LONG - NR_PAGEFLAGS ++#if ZONES_WIDTH + LRU_GEN_WIDTH + LRU_REFS_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + \ ++ KASAN_TAG_WIDTH + LAST_CPUPID_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS + #define LAST_CPUPID_WIDTH LAST_CPUPID_SHIFT + #else + #define LAST_CPUPID_WIDTH 0 +@@ -100,8 +109,8 @@ + #define LAST_CPUPID_NOT_IN_PAGE_FLAGS + #endif + +-#if ZONES_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + KASAN_TAG_WIDTH + LAST_CPUPID_WIDTH \ +- > BITS_PER_LONG - NR_PAGEFLAGS ++#if ZONES_WIDTH + LRU_GEN_WIDTH + LRU_REFS_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + \ ++ KASAN_TAG_WIDTH + LAST_CPUPID_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS + #error "Not enough bits in page flags" + #endif + +--- a/include/linux/page-flags.h ++++ b/include/linux/page-flags.h +@@ -845,7 +845,7 @@ static inline void ClearPageSlabPfmemall + 1UL << PG_private | 1UL << PG_private_2 | \ + 1UL << PG_writeback | 1UL << PG_reserved | \ + 1UL << PG_slab | 1UL << PG_active | \ +- 1UL << PG_unevictable | __PG_MLOCKED) ++ 1UL << PG_unevictable | __PG_MLOCKED | LRU_GEN_MASK) + + /* + * Flags checked when a page is prepped for return by the page allocator. +@@ -856,7 +856,7 @@ static inline void ClearPageSlabPfmemall + * alloc-free cycle to prevent from reusing the page. + */ + #define PAGE_FLAGS_CHECK_AT_PREP \ +- (PAGEFLAGS_MASK & ~__PG_HWPOISON) ++ ((PAGEFLAGS_MASK & ~__PG_HWPOISON) | LRU_GEN_MASK | LRU_REFS_MASK) + + #define PAGE_FLAGS_PRIVATE \ + (1UL << PG_private | 1UL << PG_private_2) +--- a/include/linux/sched.h ++++ b/include/linux/sched.h +@@ -911,6 +911,9 @@ struct task_struct { + #ifdef CONFIG_MEMCG + unsigned in_user_fault:1; + #endif ++#ifdef CONFIG_LRU_GEN ++ unsigned in_nonseq_fault:1; ++#endif + #ifdef CONFIG_COMPAT_BRK + unsigned brk_randomized:1; + #endif +--- a/kernel/bounds.c ++++ b/kernel/bounds.c +@@ -22,6 +22,9 @@ int main(void) + DEFINE(NR_CPUS_BITS, ilog2(CONFIG_NR_CPUS)); + #endif + DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t)); ++#ifdef CONFIG_LRU_GEN ++ DEFINE(LRU_GEN_WIDTH, order_base_2(CONFIG_NR_LRU_GENS + 1)); ++#endif + /* End of constants */ + + return 0; +--- a/kernel/cgroup/cgroup-internal.h ++++ b/kernel/cgroup/cgroup-internal.h +@@ -165,7 +165,6 @@ struct cgroup_mgctx { + #define DEFINE_CGROUP_MGCTX(name) \ + struct cgroup_mgctx name = CGROUP_MGCTX_INIT(name) + +-extern struct mutex cgroup_mutex; + extern spinlock_t css_set_lock; + extern struct cgroup_subsys *cgroup_subsys[]; + extern struct list_head cgroup_roots; +--- a/mm/huge_memory.c ++++ b/mm/huge_memory.c +@@ -2364,7 +2364,8 @@ static void __split_huge_page_tail(struc + #ifdef CONFIG_64BIT + (1L << PG_arch_2) | + #endif +- (1L << PG_dirty))); ++ (1L << PG_dirty) | ++ LRU_GEN_MASK | LRU_REFS_MASK)); + + /* ->mapping in first tail page is compound_mapcount */ + VM_BUG_ON_PAGE(tail > 2 && page_tail->mapping != TAIL_MAPPING, +--- a/mm/memcontrol.c ++++ b/mm/memcontrol.c +@@ -5226,6 +5226,7 @@ static struct mem_cgroup *mem_cgroup_all + memcg->deferred_split_queue.split_queue_len = 0; + #endif + idr_replace(&mem_cgroup_idr, memcg, memcg->id.id); ++ lru_gen_init_memcg(memcg); + return memcg; + fail: + mem_cgroup_id_remove(memcg); +--- a/mm/memory.c ++++ b/mm/memory.c +@@ -4788,6 +4788,7 @@ vm_fault_t handle_mm_fault(struct vm_are + unsigned int flags, struct pt_regs *regs) + { + vm_fault_t ret; ++ bool nonseq_fault = !(vma->vm_flags & VM_SEQ_READ); + + __set_current_state(TASK_RUNNING); + +@@ -4809,11 +4810,17 @@ vm_fault_t handle_mm_fault(struct vm_are + if (flags & FAULT_FLAG_USER) + mem_cgroup_enter_user_fault(); + ++ if (nonseq_fault) ++ task_enter_nonseq_fault(); ++ + if (unlikely(is_vm_hugetlb_page(vma))) + ret = hugetlb_fault(vma->vm_mm, vma, address, flags); + else + ret = __handle_mm_fault(vma, address, flags); + ++ if (nonseq_fault) ++ task_exit_nonseq_fault(); ++ + if (flags & FAULT_FLAG_USER) { + mem_cgroup_exit_user_fault(); + /* +--- a/mm/mm_init.c ++++ b/mm/mm_init.c +@@ -65,14 +65,16 @@ void __init mminit_verify_pageflags_layo + + shift = 8 * sizeof(unsigned long); + width = shift - SECTIONS_WIDTH - NODES_WIDTH - ZONES_WIDTH +- - LAST_CPUPID_SHIFT - KASAN_TAG_WIDTH; ++ - LAST_CPUPID_SHIFT - KASAN_TAG_WIDTH - LRU_GEN_WIDTH - LRU_REFS_WIDTH; + mminit_dprintk(MMINIT_TRACE, "pageflags_layout_widths", +- "Section %d Node %d Zone %d Lastcpupid %d Kasantag %d Flags %d\n", ++ "Section %d Node %d Zone %d Lastcpupid %d Kasantag %d Gen %d Tier %d Flags %d\n", + SECTIONS_WIDTH, + NODES_WIDTH, + ZONES_WIDTH, + LAST_CPUPID_WIDTH, + KASAN_TAG_WIDTH, ++ LRU_GEN_WIDTH, ++ LRU_REFS_WIDTH, + NR_PAGEFLAGS); + mminit_dprintk(MMINIT_TRACE, "pageflags_layout_shifts", + "Section %d Node %d Zone %d Lastcpupid %d Kasantag %d\n", +--- a/mm/page_alloc.c ++++ b/mm/page_alloc.c +@@ -7411,6 +7411,7 @@ static void __meminit pgdat_init_interna + + pgdat_page_ext_init(pgdat); + lruvec_init(&pgdat->__lruvec); ++ lru_gen_init_state(NULL, &pgdat->__lruvec); + } + + static void __meminit zone_init_internals(struct zone *zone, enum zone_type idx, int nid, +--- a/mm/swap.c ++++ b/mm/swap.c +@@ -446,6 +446,11 @@ void lru_cache_add(struct page *page) + VM_BUG_ON_PAGE(PageActive(page) && PageUnevictable(page), page); + VM_BUG_ON_PAGE(PageLRU(page), page); + ++ /* see the comment in lru_gen_add_page() */ ++ if (lru_gen_enabled() && !PageUnevictable(page) && ++ task_in_nonseq_fault() && !(current->flags & PF_MEMALLOC)) ++ SetPageActive(page); ++ + get_page(page); + local_lock(&lru_pvecs.lock); + pvec = this_cpu_ptr(&lru_pvecs.lru_add); +@@ -547,7 +552,7 @@ static void lru_deactivate_file_fn(struc + + static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec) + { +- if (PageActive(page) && !PageUnevictable(page)) { ++ if (!PageUnevictable(page) && (PageActive(page) || lru_gen_enabled())) { + int nr_pages = thp_nr_pages(page); + + del_page_from_lru_list(page, lruvec); +@@ -661,7 +666,7 @@ void deactivate_file_page(struct page *p + */ + void deactivate_page(struct page *page) + { +- if (PageLRU(page) && PageActive(page) && !PageUnevictable(page)) { ++ if (PageLRU(page) && !PageUnevictable(page) && (PageActive(page) || lru_gen_enabled())) { + struct pagevec *pvec; + + local_lock(&lru_pvecs.lock); +--- a/mm/swapfile.c ++++ b/mm/swapfile.c +@@ -2688,6 +2688,7 @@ SYSCALL_DEFINE1(swapoff, const char __us + err = 0; + atomic_inc(&proc_poll_event); + wake_up_interruptible(&proc_poll_wait); ++ lru_gen_change_state(false, false, true); + + out_dput: + filp_close(victim, NULL); +@@ -3349,6 +3350,7 @@ SYSCALL_DEFINE2(swapon, const char __use + mutex_unlock(&swapon_mutex); + atomic_inc(&proc_poll_event); + wake_up_interruptible(&proc_poll_wait); ++ lru_gen_change_state(true, false, true); + + error = 0; + goto out; +--- a/mm/vmscan.c ++++ b/mm/vmscan.c +@@ -50,6 +50,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -2880,6 +2881,273 @@ static bool can_age_anon_pages(struct pg + return can_demote(pgdat->node_id, sc); + } + ++#ifdef CONFIG_LRU_GEN ++ ++/****************************************************************************** ++ * shorthand helpers ++ ******************************************************************************/ ++ ++#define for_each_gen_type_zone(gen, type, zone) \ ++ for ((gen) = 0; (gen) < MAX_NR_GENS; (gen)++) \ ++ for ((type) = 0; (type) < ANON_AND_FILE; (type)++) \ ++ for ((zone) = 0; (zone) < MAX_NR_ZONES; (zone)++) ++ ++static int page_lru_gen(struct page *page) ++{ ++ unsigned long flags = READ_ONCE(page->flags); ++ ++ return ((flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1; ++} ++ ++static struct lruvec *get_lruvec(int nid, struct mem_cgroup *memcg) ++{ ++ struct pglist_data *pgdat = NODE_DATA(nid); ++ ++#ifdef CONFIG_MEMCG ++ if (memcg) { ++ struct lruvec *lruvec = &memcg->nodeinfo[nid]->lruvec; ++ ++ if (lruvec->pgdat != pgdat) ++ lruvec->pgdat = pgdat; ++ ++ return lruvec; ++ } ++#endif ++ return pgdat ? &pgdat->__lruvec : NULL; ++} ++ ++static int get_nr_gens(struct lruvec *lruvec, int type) ++{ ++ return lruvec->evictable.max_seq - lruvec->evictable.min_seq[type] + 1; ++} ++ ++static bool __maybe_unused seq_is_valid(struct lruvec *lruvec) ++{ ++ return get_nr_gens(lruvec, 1) >= MIN_NR_GENS && ++ get_nr_gens(lruvec, 1) <= get_nr_gens(lruvec, 0) && ++ get_nr_gens(lruvec, 0) <= MAX_NR_GENS; ++} ++ ++/****************************************************************************** ++ * state change ++ ******************************************************************************/ ++ ++#ifdef CONFIG_LRU_GEN_ENABLED ++DEFINE_STATIC_KEY_TRUE(lru_gen_static_key); ++#else ++DEFINE_STATIC_KEY_FALSE(lru_gen_static_key); ++#endif ++ ++static int lru_gen_nr_swapfiles; ++ ++static bool __maybe_unused state_is_valid(struct lruvec *lruvec) ++{ ++ int gen, type, zone; ++ enum lru_list lru; ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ for_each_evictable_lru(lru) { ++ type = is_file_lru(lru); ++ ++ if (lrugen->enabled[type] && !list_empty(&lruvec->lists[lru])) ++ return false; ++ } ++ ++ for_each_gen_type_zone(gen, type, zone) { ++ if (!lrugen->enabled[type] && !list_empty(&lrugen->lists[gen][type][zone])) ++ return false; ++ ++ /* unlikely but not a bug when reset_batch_size() is pending */ ++ VM_WARN_ON(!lrugen->enabled[type] && lrugen->sizes[gen][type][zone]); ++ } ++ ++ return true; ++} ++ ++static bool fill_lists(struct lruvec *lruvec) ++{ ++ enum lru_list lru; ++ int remaining = MAX_BATCH_SIZE; ++ ++ for_each_evictable_lru(lru) { ++ int type = is_file_lru(lru); ++ bool active = is_active_lru(lru); ++ struct list_head *head = &lruvec->lists[lru]; ++ ++ if (!lruvec->evictable.enabled[type]) ++ continue; ++ ++ while (!list_empty(head)) { ++ bool success; ++ struct page *page = lru_to_page(head); ++ ++ VM_BUG_ON_PAGE(PageTail(page), page); ++ VM_BUG_ON_PAGE(PageUnevictable(page), page); ++ VM_BUG_ON_PAGE(PageActive(page) != active, page); ++ VM_BUG_ON_PAGE(page_is_file_lru(page) != type, page); ++ VM_BUG_ON_PAGE(page_lru_gen(page) < MAX_NR_GENS, page); ++ ++ prefetchw_prev_lru_page(page, head, flags); ++ ++ del_page_from_lru_list(page, lruvec); ++ success = lru_gen_add_page(page, lruvec, false); ++ VM_BUG_ON(!success); ++ ++ if (!--remaining) ++ return false; ++ } ++ } ++ ++ return true; ++} ++ ++static bool drain_lists(struct lruvec *lruvec) ++{ ++ int gen, type, zone; ++ int remaining = MAX_BATCH_SIZE; ++ ++ for_each_gen_type_zone(gen, type, zone) { ++ struct list_head *head = &lruvec->evictable.lists[gen][type][zone]; ++ ++ if (lruvec->evictable.enabled[type]) ++ continue; ++ ++ while (!list_empty(head)) { ++ bool success; ++ struct page *page = lru_to_page(head); ++ ++ VM_BUG_ON_PAGE(PageTail(page), page); ++ VM_BUG_ON_PAGE(PageUnevictable(page), page); ++ VM_BUG_ON_PAGE(PageActive(page), page); ++ VM_BUG_ON_PAGE(page_is_file_lru(page) != type, page); ++ VM_BUG_ON_PAGE(page_zonenum(page) != zone, page); ++ ++ prefetchw_prev_lru_page(page, head, flags); ++ ++ success = lru_gen_del_page(page, lruvec, false); ++ VM_BUG_ON(!success); ++ add_page_to_lru_list(page, lruvec); ++ ++ if (!--remaining) ++ return false; ++ } ++ } ++ ++ return true; ++} ++ ++/* ++ * For file page tracking, we enable/disable it according to the main switch. ++ * For anon page tracking, we only enabled it when the main switch is on and ++ * there is at least one swapfile; we disable it when there are no swapfiles ++ * regardless of the value of the main switch. Otherwise, we will eventually ++ * reach the max size of the sliding window and have to call inc_min_seq(). ++ */ ++void lru_gen_change_state(bool enable, bool main, bool swap) ++{ ++ static DEFINE_MUTEX(state_mutex); ++ ++ struct mem_cgroup *memcg; ++ ++ mem_hotplug_begin(); ++ cgroup_lock(); ++ mutex_lock(&state_mutex); ++ ++ if (swap) { ++ if (enable) ++ swap = !lru_gen_nr_swapfiles++; ++ else ++ swap = !--lru_gen_nr_swapfiles; ++ } ++ ++ if (main && enable != lru_gen_enabled()) { ++ if (enable) ++ static_branch_enable(&lru_gen_static_key); ++ else ++ static_branch_disable(&lru_gen_static_key); ++ } else if (!swap || !lru_gen_enabled()) ++ goto unlock; ++ ++ memcg = mem_cgroup_iter(NULL, NULL, NULL); ++ do { ++ int nid; ++ ++ for_each_node(nid) { ++ struct lruvec *lruvec = get_lruvec(nid, memcg); ++ ++ if (!lruvec) ++ continue; ++ ++ spin_lock_irq(&lruvec->lru_lock); ++ ++ VM_BUG_ON(!seq_is_valid(lruvec)); ++ VM_BUG_ON(!state_is_valid(lruvec)); ++ ++ lruvec->evictable.enabled[0] = lru_gen_enabled() && lru_gen_nr_swapfiles; ++ lruvec->evictable.enabled[1] = lru_gen_enabled(); ++ ++ while (!(enable ? fill_lists(lruvec) : drain_lists(lruvec))) { ++ spin_unlock_irq(&lruvec->lru_lock); ++ cond_resched(); ++ spin_lock_irq(&lruvec->lru_lock); ++ } ++ ++ spin_unlock_irq(&lruvec->lru_lock); ++ } ++ ++ cond_resched(); ++ } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL))); ++unlock: ++ mutex_unlock(&state_mutex); ++ cgroup_unlock(); ++ mem_hotplug_done(); ++} ++ ++/****************************************************************************** ++ * initialization ++ ******************************************************************************/ ++ ++void lru_gen_init_state(struct mem_cgroup *memcg, struct lruvec *lruvec) ++{ ++ int i; ++ int gen, type, zone; ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ lrugen->max_seq = MIN_NR_GENS + 1; ++ lrugen->enabled[0] = lru_gen_enabled() && lru_gen_nr_swapfiles; ++ lrugen->enabled[1] = lru_gen_enabled(); ++ ++ for (i = 0; i <= MIN_NR_GENS + 1; i++) ++ lrugen->timestamps[i] = jiffies; ++ ++ for_each_gen_type_zone(gen, type, zone) ++ INIT_LIST_HEAD(&lrugen->lists[gen][type][zone]); ++} ++ ++#ifdef CONFIG_MEMCG ++void lru_gen_init_memcg(struct mem_cgroup *memcg) ++{ ++ int nid; ++ ++ for_each_node(nid) { ++ struct lruvec *lruvec = get_lruvec(nid, memcg); ++ ++ lru_gen_init_state(memcg, lruvec); ++ } ++} ++#endif ++ ++static int __init init_lru_gen(void) ++{ ++ BUILD_BUG_ON(MIN_NR_GENS + 1 >= MAX_NR_GENS); ++ BUILD_BUG_ON(BIT(LRU_GEN_WIDTH) <= MAX_NR_GENS); ++ ++ return 0; ++}; ++late_initcall(init_lru_gen); ++ ++#endif /* CONFIG_LRU_GEN */ ++ + static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) + { + unsigned long nr[NR_LRU_LISTS]; diff --git a/target/linux/generic/pending-5.15/020-04-mm-multigenerational-lru-mm_struct-list.patch b/target/linux/generic/pending-5.15/020-04-mm-multigenerational-lru-mm_struct-list.patch new file mode 100644 index 0000000000..75fd39d99d --- /dev/null +++ b/target/linux/generic/pending-5.15/020-04-mm-multigenerational-lru-mm_struct-list.patch @@ -0,0 +1,760 @@ +From 534bcc4a0bb5b24600891ce793f0295a142e9dae Mon Sep 17 00:00:00 2001 +From: Yu Zhao +Date: Mon, 5 Apr 2021 04:17:41 -0600 +Subject: [PATCH 05/10] mm: multigenerational lru: mm_struct list + +To scan PTEs for accessed pages, a mm_struct list is maintained for +each memcg. When multiple threads traverse the same memcg->mm_list, +each of them gets a unique mm_struct and therefore they can run +walk_page_range() concurrently to reach page tables of all processes +of this memcg. + +This infrastructure also provides the following optimizations: + 1) it allows walkers to skip processes that have been sleeping since + the last walk by tracking the usage of mm_struct between context + switches. + 2) it allows walkers to add interesting items they find during a + walk to a Bloom filter so that they can skip uninteresting items + during the next walk by testing whether an item is in this Bloom + filter. + +Signed-off-by: Yu Zhao +Tested-by: Konstantin Kharlamov +Change-Id: I25d9eda8c6bdc7c3653b9f210a159d6c247c81e8 +--- + fs/exec.c | 2 + + include/linux/memcontrol.h | 4 + + include/linux/mm_inline.h | 6 + + include/linux/mm_types.h | 75 +++++++++ + include/linux/mmzone.h | 63 +++++++ + kernel/exit.c | 1 + + kernel/fork.c | 9 + + kernel/sched/core.c | 1 + + mm/memcontrol.c | 25 +++ + mm/vmscan.c | 331 +++++++++++++++++++++++++++++++++++++ + 10 files changed, 517 insertions(+) + +--- a/fs/exec.c ++++ b/fs/exec.c +@@ -1013,6 +1013,7 @@ static int exec_mmap(struct mm_struct *m + active_mm = tsk->active_mm; + tsk->active_mm = mm; + tsk->mm = mm; ++ lru_gen_add_mm(mm); + /* + * This prevents preemption while active_mm is being loaded and + * it and mm are being updated, which could cause problems for +@@ -1023,6 +1024,7 @@ static int exec_mmap(struct mm_struct *m + if (!IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM)) + local_irq_enable(); + activate_mm(active_mm, mm); ++ lru_gen_activate_mm(mm); + if (IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM)) + local_irq_enable(); + tsk->mm->vmacache_seqnum = 0; +--- a/include/linux/memcontrol.h ++++ b/include/linux/memcontrol.h +@@ -348,6 +348,10 @@ struct mem_cgroup { + struct deferred_split deferred_split_queue; + #endif + ++#ifdef CONFIG_LRU_GEN ++ struct lru_gen_mm_list mm_list; ++#endif ++ + struct mem_cgroup_per_node *nodeinfo[]; + }; + +--- a/include/linux/mm_inline.h ++++ b/include/linux/mm_inline.h +@@ -100,6 +100,12 @@ static inline int lru_gen_from_seq(unsig + return seq % MAX_NR_GENS; + } + ++/* Return a proper index regardless whether we keep stats for historical generations. */ ++static inline int lru_hist_from_seq(unsigned long seq) ++{ ++ return seq % NR_HIST_GENS; ++} ++ + /* The youngest and the second youngest generations are counted as active. */ + static inline bool lru_gen_is_active(struct lruvec *lruvec, int gen) + { +--- a/include/linux/mm_types.h ++++ b/include/linux/mm_types.h +@@ -3,6 +3,7 @@ + #define _LINUX_MM_TYPES_H + + #include ++#include + + #include + #include +@@ -15,6 +16,8 @@ + #include + #include + #include ++#include ++#include + + #include + +@@ -580,6 +583,18 @@ struct mm_struct { + #ifdef CONFIG_IOMMU_SUPPORT + u32 pasid; + #endif ++#ifdef CONFIG_LRU_GEN ++ struct { ++ /* the node of a global or per-memcg mm_struct list */ ++ struct list_head list; ++#ifdef CONFIG_MEMCG ++ /* points to the memcg of the owner task above */ ++ struct mem_cgroup *memcg; ++#endif ++ /* whether this mm_struct has been used since the last walk */ ++ nodemask_t nodes; ++ } lrugen; ++#endif /* CONFIG_LRU_GEN */ + } __randomize_layout; + + /* +@@ -606,6 +621,66 @@ static inline cpumask_t *mm_cpumask(stru + return (struct cpumask *)&mm->cpu_bitmap; + } + ++#ifdef CONFIG_LRU_GEN ++ ++struct lru_gen_mm_list { ++ /* a global or per-memcg mm_struct list */ ++ struct list_head fifo; ++ /* protects the list above */ ++ spinlock_t lock; ++}; ++ ++void lru_gen_add_mm(struct mm_struct *mm); ++void lru_gen_del_mm(struct mm_struct *mm); ++#ifdef CONFIG_MEMCG ++void lru_gen_migrate_mm(struct mm_struct *mm); ++#endif ++ ++static inline void lru_gen_init_mm(struct mm_struct *mm) ++{ ++ INIT_LIST_HEAD(&mm->lrugen.list); ++#ifdef CONFIG_MEMCG ++ mm->lrugen.memcg = NULL; ++#endif ++ nodes_clear(mm->lrugen.nodes); ++} ++ ++/* Track the usage of each mm_struct so that we can skip inactive ones. */ ++static inline void lru_gen_activate_mm(struct mm_struct *mm) ++{ ++ /* unlikely but not a bug when racing with lru_gen_migrate_mm() */ ++ VM_WARN_ON(list_empty(&mm->lrugen.list)); ++ ++ if (!(current->flags & PF_KTHREAD) && !nodes_full(mm->lrugen.nodes)) ++ nodes_setall(mm->lrugen.nodes); ++} ++ ++#else /* !CONFIG_LRU_GEN */ ++ ++static inline void lru_gen_add_mm(struct mm_struct *mm) ++{ ++} ++ ++static inline void lru_gen_del_mm(struct mm_struct *mm) ++{ ++} ++ ++#ifdef CONFIG_MEMCG ++static inline void lru_gen_migrate_mm(struct mm_struct *mm) ++{ ++} ++#endif ++ ++static inline void lru_gen_init_mm(struct mm_struct *mm) ++{ ++} ++ ++static inline void lru_gen_activate_mm(struct mm_struct *mm) ++{ ++} ++ ++#endif /* CONFIG_LRU_GEN */ ++ + struct mmu_gather; + extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm); + extern void tlb_gather_mmu_fullmm(struct mmu_gather *tlb, struct mm_struct *mm); +--- a/include/linux/mmzone.h ++++ b/include/linux/mmzone.h +@@ -318,6 +318,13 @@ struct lruvec; + #define MIN_NR_GENS 2 + #define MAX_NR_GENS ((unsigned int)CONFIG_NR_LRU_GENS) + ++/* Whether to keep stats for historical generations. */ ++#ifdef CONFIG_LRU_GEN_STATS ++#define NR_HIST_GENS ((unsigned int)CONFIG_NR_LRU_GENS) ++#else ++#define NR_HIST_GENS 1U ++#endif ++ + struct lrugen { + /* the aging increments the max generation number */ + unsigned long max_seq; +@@ -333,13 +340,63 @@ struct lrugen { + bool enabled[ANON_AND_FILE]; + }; + ++enum { ++ MM_LEAF_TOTAL, /* total leaf entries */ ++ MM_LEAF_OLD, /* old leaf entries */ ++ MM_LEAF_YOUNG, /* young leaf entries */ ++ MM_NONLEAF_TOTAL, /* total non-leaf entries */ ++ MM_NONLEAF_PREV, /* previously worthy non-leaf entries */ ++ MM_NONLEAF_CUR, /* currently worthy non-leaf entries */ ++ NR_MM_STATS ++}; ++ ++/* mnemonic codes for the stats above */ ++#define MM_STAT_CODES "toydpc" ++ ++/* double buffering bloom filters */ ++#define NR_BLOOM_FILTERS 2 ++ ++struct lru_gen_mm_walk { ++ /* set to max_seq after each round of walk */ ++ unsigned long seq; ++ /* the next mm_struct on the list to walk */ ++ struct list_head *head; ++ /* the first mm_struct never walked before */ ++ struct list_head *tail; ++ /* to wait for the last walker to finish */ ++ struct wait_queue_head wait; ++ /* bloom filters flip after each round of walk */ ++ unsigned long *filters[NR_BLOOM_FILTERS]; ++ /* page table stats for debugging */ ++ unsigned long stats[NR_HIST_GENS][NR_MM_STATS]; ++ /* the number of concurrent walkers */ ++ int nr_walkers; ++}; ++ ++#define MIN_BATCH_SIZE 64 + #define MAX_BATCH_SIZE 8192 + ++struct mm_walk_args { ++ struct mem_cgroup *memcg; ++ unsigned long max_seq; ++ unsigned long start_pfn; ++ unsigned long end_pfn; ++ unsigned long next_addr; ++ unsigned long bitmap[BITS_TO_LONGS(MIN_BATCH_SIZE)]; ++ int node_id; ++ int swappiness; ++ int batch_size; ++ int nr_pages[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES]; ++ int mm_stats[NR_MM_STATS]; ++ bool use_filter; ++}; ++ + void lru_gen_init_state(struct mem_cgroup *memcg, struct lruvec *lruvec); + void lru_gen_change_state(bool enable, bool main, bool swap); + + #ifdef CONFIG_MEMCG + void lru_gen_init_memcg(struct mem_cgroup *memcg); ++void lru_gen_free_memcg(struct mem_cgroup *memcg); + #endif + + #else /* !CONFIG_LRU_GEN */ +@@ -356,6 +413,10 @@ static inline void lru_gen_change_state( + static inline void lru_gen_init_memcg(struct mem_cgroup *memcg) + { + } ++ ++static inline void lru_gen_free_memcg(struct mem_cgroup *memcg) ++{ ++} + #endif + + #endif /* CONFIG_LRU_GEN */ +@@ -380,6 +441,8 @@ struct lruvec { + #ifdef CONFIG_LRU_GEN + /* unevictable pages are on LRU_UNEVICTABLE */ + struct lrugen evictable; ++ /* state for mm list and page table walks */ ++ struct lru_gen_mm_walk mm_walk; + #endif + #ifdef CONFIG_MEMCG + struct pglist_data *pgdat; +--- a/kernel/exit.c ++++ b/kernel/exit.c +@@ -422,6 +422,7 @@ assign_new_owner: + goto retry; + } + WRITE_ONCE(mm->owner, c); ++ lru_gen_migrate_mm(mm); + task_unlock(c); + put_task_struct(c); + } +--- a/kernel/fork.c ++++ b/kernel/fork.c +@@ -1080,6 +1080,7 @@ static struct mm_struct *mm_init(struct + goto fail_nocontext; + + mm->user_ns = get_user_ns(user_ns); ++ lru_gen_init_mm(mm); + return mm; + + fail_nocontext: +@@ -1122,6 +1123,7 @@ static inline void __mmput(struct mm_str + } + if (mm->binfmt) + module_put(mm->binfmt->module); ++ lru_gen_del_mm(mm); + mmdrop(mm); + } + +@@ -2616,6 +2618,13 @@ pid_t kernel_clone(struct kernel_clone_a + get_task_struct(p); + } + ++ if (IS_ENABLED(CONFIG_LRU_GEN) && !(clone_flags & CLONE_VM)) { ++ /* lock the task to synchronize with memcg migration */ ++ task_lock(p); ++ lru_gen_add_mm(p->mm); ++ task_unlock(p); ++ } ++ + wake_up_new_task(p); + + /* forking complete and child started to run, tell ptracer */ +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -4978,6 +4978,7 @@ context_switch(struct rq *rq, struct tas + * finish_task_switch()'s mmdrop(). + */ + switch_mm_irqs_off(prev->active_mm, next->mm, next); ++ lru_gen_activate_mm(next->mm); + + if (!prev->mm) { // from kernel + /* will mmdrop() in finish_task_switch(). */ +--- a/mm/memcontrol.c ++++ b/mm/memcontrol.c +@@ -5163,6 +5163,7 @@ static void __mem_cgroup_free(struct mem + + static void mem_cgroup_free(struct mem_cgroup *memcg) + { ++ lru_gen_free_memcg(memcg); + memcg_wb_domain_exit(memcg); + __mem_cgroup_free(memcg); + } +@@ -6195,6 +6196,29 @@ static void mem_cgroup_move_task(void) + } + #endif + ++#ifdef CONFIG_LRU_GEN ++static void mem_cgroup_attach(struct cgroup_taskset *tset) ++{ ++ struct cgroup_subsys_state *css; ++ struct task_struct *task = NULL; ++ ++ cgroup_taskset_for_each_leader(task, css, tset) ++ break; ++ ++ if (!task) ++ return; ++ ++ task_lock(task); ++ if (task->mm && task->mm->owner == task) ++ lru_gen_migrate_mm(task->mm); ++ task_unlock(task); ++} ++#else ++static void mem_cgroup_attach(struct cgroup_taskset *tset) ++{ ++} ++#endif /* CONFIG_LRU_GEN */ ++ + static int seq_puts_memcg_tunable(struct seq_file *m, unsigned long value) + { + if (value == PAGE_COUNTER_MAX) +@@ -6538,6 +6562,7 @@ struct cgroup_subsys memory_cgrp_subsys + .css_reset = mem_cgroup_css_reset, + .css_rstat_flush = mem_cgroup_css_rstat_flush, + .can_attach = mem_cgroup_can_attach, ++ .attach = mem_cgroup_attach, + .cancel_attach = mem_cgroup_cancel_attach, + .post_attach = mem_cgroup_move_task, + .dfl_cftypes = memory_files, +--- a/mm/vmscan.c ++++ b/mm/vmscan.c +@@ -2929,6 +2929,306 @@ static bool __maybe_unused seq_is_valid( + } + + /****************************************************************************** ++ * mm_struct list ++ ******************************************************************************/ ++ ++static struct lru_gen_mm_list *get_mm_list(struct mem_cgroup *memcg) ++{ ++ static struct lru_gen_mm_list mm_list = { ++ .fifo = LIST_HEAD_INIT(mm_list.fifo), ++ .lock = __SPIN_LOCK_UNLOCKED(mm_list.lock), ++ }; ++ ++#ifdef CONFIG_MEMCG ++ if (memcg) ++ return &memcg->mm_list; ++#endif ++ return &mm_list; ++} ++ ++void lru_gen_add_mm(struct mm_struct *mm) ++{ ++ int nid; ++ struct mem_cgroup *memcg = get_mem_cgroup_from_mm(mm); ++ struct lru_gen_mm_list *mm_list = get_mm_list(memcg); ++ ++ VM_BUG_ON_MM(!list_empty(&mm->lrugen.list), mm); ++#ifdef CONFIG_MEMCG ++ VM_BUG_ON_MM(mm->lrugen.memcg, mm); ++ mm->lrugen.memcg = memcg; ++#endif ++ spin_lock(&mm_list->lock); ++ ++ list_add_tail(&mm->lrugen.list, &mm_list->fifo); ++ ++ for_each_node(nid) { ++ struct lruvec *lruvec = get_lruvec(nid, memcg); ++ ++ if (!lruvec) ++ continue; ++ ++ if (lruvec->mm_walk.tail == &mm_list->fifo) ++ lruvec->mm_walk.tail = lruvec->mm_walk.tail->prev; ++ } ++ ++ spin_unlock(&mm_list->lock); ++} ++ ++void lru_gen_del_mm(struct mm_struct *mm) ++{ ++ int nid; ++ struct lru_gen_mm_list *mm_list; ++ struct mem_cgroup *memcg = NULL; ++ ++ if (list_empty(&mm->lrugen.list)) ++ return; ++ ++#ifdef CONFIG_MEMCG ++ memcg = mm->lrugen.memcg; ++#endif ++ mm_list = get_mm_list(memcg); ++ ++ spin_lock(&mm_list->lock); ++ ++ for_each_node(nid) { ++ struct lruvec *lruvec = get_lruvec(nid, memcg); ++ ++ if (!lruvec) ++ continue; ++ ++ if (lruvec->mm_walk.tail == &mm->lrugen.list) ++ lruvec->mm_walk.tail = lruvec->mm_walk.tail->next; ++ ++ if (lruvec->mm_walk.head != &mm->lrugen.list) ++ continue; ++ ++ lruvec->mm_walk.head = lruvec->mm_walk.head->next; ++ if (lruvec->mm_walk.head == &mm_list->fifo) ++ WRITE_ONCE(lruvec->mm_walk.seq, lruvec->mm_walk.seq + 1); ++ } ++ ++ list_del_init(&mm->lrugen.list); ++ ++ spin_unlock(&mm_list->lock); ++ ++#ifdef CONFIG_MEMCG ++ mem_cgroup_put(mm->lrugen.memcg); ++ mm->lrugen.memcg = NULL; ++#endif ++} ++ ++#ifdef CONFIG_MEMCG ++void lru_gen_migrate_mm(struct mm_struct *mm) ++{ ++ struct mem_cgroup *memcg; ++ ++ lockdep_assert_held(&mm->owner->alloc_lock); ++ ++ if (mem_cgroup_disabled()) ++ return; ++ ++ rcu_read_lock(); ++ memcg = mem_cgroup_from_task(mm->owner); ++ rcu_read_unlock(); ++ if (memcg == mm->lrugen.memcg) ++ return; ++ ++ VM_BUG_ON_MM(!mm->lrugen.memcg, mm); ++ VM_BUG_ON_MM(list_empty(&mm->lrugen.list), mm); ++ ++ lru_gen_del_mm(mm); ++ lru_gen_add_mm(mm); ++} ++#endif ++ ++#define BLOOM_FILTER_SHIFT 15 ++ ++static inline int filter_gen_from_seq(unsigned long seq) ++{ ++ return seq % NR_BLOOM_FILTERS; ++} ++ ++static void get_item_key(void *item, int *key) ++{ ++ u32 hash = hash_ptr(item, BLOOM_FILTER_SHIFT * 2); ++ ++ BUILD_BUG_ON(BLOOM_FILTER_SHIFT * 2 > BITS_PER_TYPE(u32)); ++ ++ key[0] = hash & (BIT(BLOOM_FILTER_SHIFT) - 1); ++ key[1] = hash >> BLOOM_FILTER_SHIFT; ++} ++ ++static void clear_bloom_filter(struct lruvec *lruvec, unsigned long seq) ++{ ++ unsigned long *filter; ++ int gen = filter_gen_from_seq(seq); ++ ++ lockdep_assert_held(&get_mm_list(lruvec_memcg(lruvec))->lock); ++ ++ filter = lruvec->mm_walk.filters[gen]; ++ if (filter) { ++ bitmap_clear(filter, 0, BIT(BLOOM_FILTER_SHIFT)); ++ return; ++ } ++ ++ filter = bitmap_zalloc(BIT(BLOOM_FILTER_SHIFT), GFP_ATOMIC); ++ WRITE_ONCE(lruvec->mm_walk.filters[gen], filter); ++} ++ ++static void set_bloom_filter(struct lruvec *lruvec, unsigned long seq, void *item) ++{ ++ int key[2]; ++ unsigned long *filter; ++ int gen = filter_gen_from_seq(seq); ++ ++ filter = READ_ONCE(lruvec->mm_walk.filters[gen]); ++ if (!filter) ++ return; ++ ++ get_item_key(item, key); ++ ++ if (!test_bit(key[0], filter)) ++ set_bit(key[0], filter); ++ if (!test_bit(key[1], filter)) ++ set_bit(key[1], filter); ++} ++ ++static bool test_bloom_filter(struct lruvec *lruvec, unsigned long seq, void *item) ++{ ++ int key[2]; ++ unsigned long *filter; ++ int gen = filter_gen_from_seq(seq); ++ ++ filter = READ_ONCE(lruvec->mm_walk.filters[gen]); ++ if (!filter) ++ return false; ++ ++ get_item_key(item, key); ++ ++ return test_bit(key[0], filter) && test_bit(key[1], filter); ++} ++ ++static void reset_mm_stats(struct lruvec *lruvec, bool last, struct mm_walk_args *args) ++{ ++ int i; ++ int hist = lru_hist_from_seq(args->max_seq); ++ ++ lockdep_assert_held(&get_mm_list(lruvec_memcg(lruvec))->lock); ++ ++ for (i = 0; i < NR_MM_STATS; i++) { ++ WRITE_ONCE(lruvec->mm_walk.stats[hist][i], ++ lruvec->mm_walk.stats[hist][i] + args->mm_stats[i]); ++ args->mm_stats[i] = 0; ++ } ++ ++ if (!last || NR_HIST_GENS == 1) ++ return; ++ ++ hist = lru_hist_from_seq(args->max_seq + 1); ++ for (i = 0; i < NR_MM_STATS; i++) ++ WRITE_ONCE(lruvec->mm_walk.stats[hist][i], 0); ++} ++ ++static bool should_skip_mm(struct mm_struct *mm, struct mm_walk_args *args) ++{ ++ int type; ++ unsigned long size = 0; ++ ++ if (cpumask_empty(mm_cpumask(mm)) && !node_isset(args->node_id, mm->lrugen.nodes)) ++ return true; ++ ++ if (mm_is_oom_victim(mm)) ++ return true; ++ ++ for (type = !args->swappiness; type < ANON_AND_FILE; type++) { ++ size += type ? get_mm_counter(mm, MM_FILEPAGES) : ++ get_mm_counter(mm, MM_ANONPAGES) + ++ get_mm_counter(mm, MM_SHMEMPAGES); ++ } ++ ++ if (size < MIN_BATCH_SIZE) ++ return true; ++ ++ if (!mmget_not_zero(mm)) ++ return true; ++ ++ node_clear(args->node_id, mm->lrugen.nodes); ++ ++ return false; ++} ++ ++/* To support multiple walkers that concurrently walk an mm_struct list. */ ++static bool get_next_mm(struct lruvec *lruvec, struct mm_walk_args *args, ++ struct mm_struct **iter) ++{ ++ bool first = false; ++ bool last = true; ++ struct mm_struct *mm = NULL; ++ struct lru_gen_mm_walk *mm_walk = &lruvec->mm_walk; ++ struct lru_gen_mm_list *mm_list = get_mm_list(args->memcg); ++ ++ if (*iter) ++ mmput_async(*iter); ++ else if (args->max_seq <= READ_ONCE(mm_walk->seq)) ++ return false; ++ ++ spin_lock(&mm_list->lock); ++ ++ VM_BUG_ON(args->max_seq > mm_walk->seq + 1); ++ VM_BUG_ON(*iter && args->max_seq < mm_walk->seq); ++ VM_BUG_ON(*iter && !mm_walk->nr_walkers); ++ ++ if (args->max_seq <= mm_walk->seq) { ++ if (!*iter) ++ last = false; ++ goto done; ++ } ++ ++ if (mm_walk->head == &mm_list->fifo) { ++ VM_BUG_ON(mm_walk->nr_walkers); ++ mm_walk->head = mm_walk->head->next; ++ first = true; ++ } ++ ++ while (!mm && mm_walk->head != &mm_list->fifo) { ++ mm = list_entry(mm_walk->head, struct mm_struct, lrugen.list); ++ ++ mm_walk->head = mm_walk->head->next; ++ ++ if (mm_walk->tail == &mm->lrugen.list) { ++ mm_walk->tail = mm_walk->tail->next; ++ args->use_filter = false; ++ } ++ ++ if (should_skip_mm(mm, args)) ++ mm = NULL; ++ } ++ ++ if (mm_walk->head == &mm_list->fifo) ++ WRITE_ONCE(mm_walk->seq, mm_walk->seq + 1); ++done: ++ if (*iter && !mm) ++ mm_walk->nr_walkers--; ++ if (!*iter && mm) ++ mm_walk->nr_walkers++; ++ ++ if (mm_walk->nr_walkers) ++ last = false; ++ ++ if (mm && first) ++ clear_bloom_filter(lruvec, args->max_seq + 1); ++ ++ if (*iter || last) ++ reset_mm_stats(lruvec, last, args); ++ ++ spin_unlock(&mm_list->lock); ++ ++ *iter = mm; ++ ++ return last; ++} ++ ++/****************************************************************************** + * state change + ******************************************************************************/ + +@@ -3112,6 +3412,7 @@ void lru_gen_init_state(struct mem_cgrou + int i; + int gen, type, zone; + struct lrugen *lrugen = &lruvec->evictable; ++ struct lru_gen_mm_list *mm_list = get_mm_list(memcg); + + lrugen->max_seq = MIN_NR_GENS + 1; + lrugen->enabled[0] = lru_gen_enabled() && lru_gen_nr_swapfiles; +@@ -3122,6 +3423,17 @@ void lru_gen_init_state(struct mem_cgrou + + for_each_gen_type_zone(gen, type, zone) + INIT_LIST_HEAD(&lrugen->lists[gen][type][zone]); ++ ++ if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG) && !memcg) ++ spin_lock(&mm_list->lock); ++ ++ lruvec->mm_walk.seq = MIN_NR_GENS; ++ lruvec->mm_walk.head = &mm_list->fifo; ++ lruvec->mm_walk.tail = &mm_list->fifo; ++ init_waitqueue_head(&lruvec->mm_walk.wait); ++ ++ if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG) && !memcg) ++ spin_unlock(&mm_list->lock); + } + + #ifdef CONFIG_MEMCG +@@ -3129,18 +3441,37 @@ void lru_gen_init_memcg(struct mem_cgrou + { + int nid; + ++ INIT_LIST_HEAD(&memcg->mm_list.fifo); ++ spin_lock_init(&memcg->mm_list.lock); ++ + for_each_node(nid) { + struct lruvec *lruvec = get_lruvec(nid, memcg); + + lru_gen_init_state(memcg, lruvec); + } + } ++ ++void lru_gen_free_memcg(struct mem_cgroup *memcg) ++{ ++ int nid; ++ ++ for_each_node(nid) { ++ int i; ++ struct lruvec *lruvec = get_lruvec(nid, memcg); ++ ++ for (i = 0; i < NR_BLOOM_FILTERS; i++) { ++ bitmap_free(lruvec->mm_walk.filters[i]); ++ lruvec->mm_walk.filters[i] = NULL; ++ } ++ } ++} + #endif + + static int __init init_lru_gen(void) + { + BUILD_BUG_ON(MIN_NR_GENS + 1 >= MAX_NR_GENS); + BUILD_BUG_ON(BIT(LRU_GEN_WIDTH) <= MAX_NR_GENS); ++ BUILD_BUG_ON(sizeof(MM_STAT_CODES) != NR_MM_STATS + 1); + + return 0; + }; diff --git a/target/linux/generic/pending-5.15/020-05-mm-multigenerational-lru-aging.patch b/target/linux/generic/pending-5.15/020-05-mm-multigenerational-lru-aging.patch new file mode 100644 index 0000000000..e5622ccbbe --- /dev/null +++ b/target/linux/generic/pending-5.15/020-05-mm-multigenerational-lru-aging.patch @@ -0,0 +1,1176 @@ +From 8217cd2238c40cf77208aa27a7cc09879e685890 Mon Sep 17 00:00:00 2001 +From: Yu Zhao +Date: Mon, 5 Apr 2021 04:35:07 -0600 +Subject: [PATCH 06/10] mm: multigenerational lru: aging + +The aging produces young generations. Given an lruvec, the aging +traverses lruvec_memcg()->mm_list and calls walk_page_range() to scan +PTEs for accessed pages. Upon finding one, the aging updates its +generation number to max_seq (modulo MAX_NR_GENS). After each round of +traversal, the aging increments max_seq. The aging is due when +min_seq[] reaches max_seq-1. + +The aging uses the following optimizations when walking page tables: + 1) It skips non-leaf PMD entries that have the accessed bit cleared + when CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG=y. + 2) It does not zigzag between a PGD table and the same PMD or PTE + table spanning multiple VMAs. In other words, it finishes all the + VMAs within the range of the same PMD or PTE table before it returns + to this PGD table. This optimizes workloads that have large numbers + of tiny VMAs, especially when CONFIG_PGTABLE_LEVELS=5. + +Signed-off-by: Yu Zhao +Tested-by: Konstantin Kharlamov +Change-Id: I3ae8abc3100d023cecb3a699d86020ae6fc10a45 +--- + include/linux/memcontrol.h | 3 + + include/linux/mmzone.h | 9 + + include/linux/oom.h | 16 + + include/linux/swap.h | 3 + + mm/memcontrol.c | 5 + + mm/oom_kill.c | 4 +- + mm/rmap.c | 8 + + mm/vmscan.c | 948 +++++++++++++++++++++++++++++++++++++ + 8 files changed, 994 insertions(+), 2 deletions(-) + +--- a/include/linux/memcontrol.h ++++ b/include/linux/memcontrol.h +@@ -1367,10 +1367,13 @@ mem_cgroup_print_oom_meminfo(struct mem_ + + static inline void lock_page_memcg(struct page *page) + { ++ /* to match page_memcg_rcu() */ ++ rcu_read_lock(); + } + + static inline void unlock_page_memcg(struct page *page) + { ++ rcu_read_unlock(); + } + + static inline void mem_cgroup_handle_over_high(void) +--- a/include/linux/mmzone.h ++++ b/include/linux/mmzone.h +@@ -295,6 +295,7 @@ enum lruvec_flags { + }; + + struct lruvec; ++struct page_vma_mapped_walk; + + #define LRU_GEN_MASK ((BIT(LRU_GEN_WIDTH) - 1) << LRU_GEN_PGOFF) + #define LRU_REFS_MASK ((BIT(LRU_REFS_WIDTH) - 1) << LRU_REFS_PGOFF) +@@ -393,6 +394,7 @@ struct mm_walk_args { + + void lru_gen_init_state(struct mem_cgroup *memcg, struct lruvec *lruvec); + void lru_gen_change_state(bool enable, bool main, bool swap); ++void lru_gen_look_around(struct page_vma_mapped_walk *pvmw); + + #ifdef CONFIG_MEMCG + void lru_gen_init_memcg(struct mem_cgroup *memcg); +@@ -409,6 +411,10 @@ static inline void lru_gen_change_state( + { + } + ++static inline void lru_gen_look_around(struct page_vma_mapped_walk *pvmw) ++{ ++} ++ + #ifdef CONFIG_MEMCG + static inline void lru_gen_init_memcg(struct mem_cgroup *memcg) + { +@@ -1028,6 +1034,9 @@ typedef struct pglist_data { + + unsigned long flags; + ++#ifdef CONFIG_LRU_GEN ++ struct mm_walk_args mm_walk_args; ++#endif + ZONE_PADDING(_pad2_) + + /* Per-node vmstats */ +--- a/include/linux/oom.h ++++ b/include/linux/oom.h +@@ -57,6 +57,22 @@ struct oom_control { + extern struct mutex oom_lock; + extern struct mutex oom_adj_mutex; + ++#ifdef CONFIG_MMU ++extern struct task_struct *oom_reaper_list; ++extern struct wait_queue_head oom_reaper_wait; ++ ++static inline bool oom_reaping_in_progress(void) ++{ ++ /* racy check to see if oom reaping could be in progress */ ++ return READ_ONCE(oom_reaper_list) || !waitqueue_active(&oom_reaper_wait); ++} ++#else ++static inline bool oom_reaping_in_progress(void) ++{ ++ return false; ++} ++#endif ++ + static inline void set_current_oom_origin(void) + { + current->signal->oom_flag_origin = true; +--- a/include/linux/swap.h ++++ b/include/linux/swap.h +@@ -137,6 +137,9 @@ union swap_header { + */ + struct reclaim_state { + unsigned long reclaimed_slab; ++#ifdef CONFIG_LRU_GEN ++ struct mm_walk_args *mm_walk_args; ++#endif + }; + + #ifdef __KERNEL__ +--- a/mm/memcontrol.c ++++ b/mm/memcontrol.c +@@ -1304,12 +1304,17 @@ void mem_cgroup_update_lru_size(struct l + *lru_size += nr_pages; + + size = *lru_size; ++#ifdef CONFIG_LRU_GEN ++ /* unlikely but not a bug when reset_batch_size() is pending */ ++ VM_WARN_ON(size + MAX_BATCH_SIZE < 0); ++#else + if (WARN_ONCE(size < 0, + "%s(%p, %d, %d): lru_size %ld\n", + __func__, lruvec, lru, nr_pages, size)) { + VM_BUG_ON(1); + *lru_size = 0; + } ++#endif + + if (nr_pages > 0) + *lru_size += nr_pages; +--- a/mm/oom_kill.c ++++ b/mm/oom_kill.c +@@ -508,8 +508,8 @@ bool process_shares_mm(struct task_struc + * victim (if that is possible) to help the OOM killer to move on. + */ + static struct task_struct *oom_reaper_th; +-static DECLARE_WAIT_QUEUE_HEAD(oom_reaper_wait); +-static struct task_struct *oom_reaper_list; ++DECLARE_WAIT_QUEUE_HEAD(oom_reaper_wait); ++struct task_struct *oom_reaper_list; + static DEFINE_SPINLOCK(oom_reaper_lock); + + bool __oom_reap_task_mm(struct mm_struct *mm) +--- a/mm/rmap.c ++++ b/mm/rmap.c +@@ -73,6 +73,7 @@ + #include + #include + #include ++#include + + #include + +@@ -790,6 +791,13 @@ static bool page_referenced_one(struct p + } + + if (pvmw.pte) { ++ /* the multigenerational lru exploits the spatial locality */ ++ if (lru_gen_enabled() && pte_young(*pvmw.pte) && ++ !(vma->vm_flags & VM_SEQ_READ)) { ++ lru_gen_look_around(&pvmw); ++ referenced++; ++ } ++ + if (ptep_clear_flush_young_notify(vma, address, + pvmw.pte)) { + /* +--- a/mm/vmscan.c ++++ b/mm/vmscan.c +@@ -51,6 +51,8 @@ + #include + #include + #include ++#include ++#include + + #include + #include +@@ -2887,6 +2889,15 @@ static bool can_age_anon_pages(struct pg + * shorthand helpers + ******************************************************************************/ + ++#define DEFINE_MAX_SEQ(lruvec) \ ++ unsigned long max_seq = READ_ONCE((lruvec)->evictable.max_seq) ++ ++#define DEFINE_MIN_SEQ(lruvec) \ ++ unsigned long min_seq[ANON_AND_FILE] = { \ ++ READ_ONCE((lruvec)->evictable.min_seq[0]), \ ++ READ_ONCE((lruvec)->evictable.min_seq[1]), \ ++ } ++ + #define for_each_gen_type_zone(gen, type, zone) \ + for ((gen) = 0; (gen) < MAX_NR_GENS; (gen)++) \ + for ((type) = 0; (type) < ANON_AND_FILE; (type)++) \ +@@ -2899,6 +2910,12 @@ static int page_lru_gen(struct page *pag + return ((flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1; + } + ++static int get_swappiness(struct mem_cgroup *memcg) ++{ ++ return mem_cgroup_get_nr_swap_pages(memcg) >= MIN_BATCH_SIZE ? ++ mem_cgroup_swappiness(memcg) : 0; ++} ++ + static struct lruvec *get_lruvec(int nid, struct mem_cgroup *memcg) + { + struct pglist_data *pgdat = NODE_DATA(nid); +@@ -3229,6 +3246,926 @@ done: + } + + /****************************************************************************** ++ * the aging ++ ******************************************************************************/ ++ ++static int page_update_gen(struct page *page, int gen) ++{ ++ unsigned long old_flags, new_flags; ++ ++ VM_BUG_ON(gen >= MAX_NR_GENS); ++ ++ do { ++ new_flags = old_flags = READ_ONCE(page->flags); ++ ++ if (!(new_flags & LRU_GEN_MASK)) { ++ new_flags |= BIT(PG_referenced); ++ continue; ++ } ++ ++ new_flags &= ~LRU_GEN_MASK; ++ new_flags |= (gen + 1UL) << LRU_GEN_PGOFF; ++ } while (new_flags != old_flags && ++ cmpxchg(&page->flags, old_flags, new_flags) != old_flags); ++ ++ return ((old_flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1; ++} ++ ++static void page_inc_gen(struct page *page, struct lruvec *lruvec, bool reclaiming) ++{ ++ int old_gen, new_gen; ++ unsigned long old_flags, new_flags; ++ int type = page_is_file_lru(page); ++ int zone = page_zonenum(page); ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ old_gen = lru_gen_from_seq(lrugen->min_seq[type]); ++ ++ do { ++ new_flags = old_flags = READ_ONCE(page->flags); ++ VM_BUG_ON_PAGE(!(new_flags & LRU_GEN_MASK), page); ++ ++ new_gen = ((new_flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1; ++ /* page_update_gen() has updated this page? */ ++ if (new_gen >= 0 && new_gen != old_gen) { ++ list_move(&page->lru, &lrugen->lists[new_gen][type][zone]); ++ return; ++ } ++ ++ new_gen = (old_gen + 1) % MAX_NR_GENS; ++ ++ new_flags &= ~LRU_GEN_MASK; ++ new_flags |= (new_gen + 1UL) << LRU_GEN_PGOFF; ++ /* for end_page_writeback() */ ++ if (reclaiming) ++ new_flags |= BIT(PG_reclaim); ++ } while (cmpxchg(&page->flags, old_flags, new_flags) != old_flags); ++ ++ lru_gen_update_size(page, lruvec, old_gen, new_gen); ++ if (reclaiming) ++ list_move(&page->lru, &lrugen->lists[new_gen][type][zone]); ++ else ++ list_move_tail(&page->lru, &lrugen->lists[new_gen][type][zone]); ++} ++ ++static void update_batch_size(struct page *page, int old_gen, int new_gen, ++ struct mm_walk_args *args) ++{ ++ int type = page_is_file_lru(page); ++ int zone = page_zonenum(page); ++ int delta = thp_nr_pages(page); ++ ++ VM_BUG_ON(old_gen >= MAX_NR_GENS); ++ VM_BUG_ON(new_gen >= MAX_NR_GENS); ++ ++ args->batch_size++; ++ ++ args->nr_pages[old_gen][type][zone] -= delta; ++ args->nr_pages[new_gen][type][zone] += delta; ++} ++ ++static void reset_batch_size(struct lruvec *lruvec, struct mm_walk_args *args) ++{ ++ int gen, type, zone; ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ args->batch_size = 0; ++ ++ for_each_gen_type_zone(gen, type, zone) { ++ enum lru_list lru = type * LRU_FILE; ++ int delta = args->nr_pages[gen][type][zone]; ++ ++ if (!delta) ++ continue; ++ ++ args->nr_pages[gen][type][zone] = 0; ++ WRITE_ONCE(lrugen->sizes[gen][type][zone], ++ lrugen->sizes[gen][type][zone] + delta); ++ ++ if (lru_gen_is_active(lruvec, gen)) ++ lru += LRU_ACTIVE; ++ update_lru_size(lruvec, lru, zone, delta); ++ } ++} ++ ++static int should_skip_vma(unsigned long start, unsigned long end, struct mm_walk *walk) ++{ ++ struct address_space *mapping; ++ struct vm_area_struct *vma = walk->vma; ++ struct mm_walk_args *args = walk->private; ++ ++ if (!vma_is_accessible(vma) || is_vm_hugetlb_page(vma) || ++ (vma->vm_flags & (VM_LOCKED | VM_SPECIAL | VM_SEQ_READ))) ++ return true; ++ ++ if (vma_is_anonymous(vma)) ++ return !args->swappiness; ++ ++ if (WARN_ON_ONCE(!vma->vm_file || !vma->vm_file->f_mapping)) ++ return true; ++ ++ mapping = vma->vm_file->f_mapping; ++ if (!mapping->a_ops->writepage) ++ return true; ++ ++ return (shmem_mapping(mapping) && !args->swappiness) || mapping_unevictable(mapping); ++} ++ ++/* ++ * Some userspace memory allocators create many single-page VMAs. So instead of ++ * returning back to the PGD table for each of such VMAs, we finish at least an ++ * entire PMD table and therefore avoid many zigzags. ++ */ ++static bool get_next_vma(struct mm_walk *walk, unsigned long mask, unsigned long size, ++ unsigned long *start, unsigned long *end) ++{ ++ unsigned long next = round_up(*end, size); ++ ++ VM_BUG_ON(mask & size); ++ VM_BUG_ON(*start >= *end); ++ VM_BUG_ON((next & mask) != (*start & mask)); ++ ++ while (walk->vma) { ++ if (next >= walk->vma->vm_end) { ++ walk->vma = walk->vma->vm_next; ++ continue; ++ } ++ ++ if ((next & mask) != (walk->vma->vm_start & mask)) ++ return false; ++ ++ if (should_skip_vma(walk->vma->vm_start, walk->vma->vm_end, walk)) { ++ walk->vma = walk->vma->vm_next; ++ continue; ++ } ++ ++ *start = max(next, walk->vma->vm_start); ++ next = (next | ~mask) + 1; ++ /* rounded-up boundaries can wrap to 0 */ ++ *end = next && next < walk->vma->vm_end ? next : walk->vma->vm_end; ++ ++ return true; ++ } ++ ++ return false; ++} ++ ++static bool walk_pte_range(pmd_t *pmd, unsigned long start, unsigned long end, ++ struct mm_walk *walk) ++{ ++ int i; ++ pte_t *pte; ++ spinlock_t *ptl; ++ unsigned long addr; ++ int worth = 0; ++ struct mm_walk_args *args = walk->private; ++ int old_gen, new_gen = lru_gen_from_seq(args->max_seq); ++ ++ VM_BUG_ON(pmd_leaf(*pmd)); ++ ++ pte = pte_offset_map_lock(walk->mm, pmd, start & PMD_MASK, &ptl); ++ arch_enter_lazy_mmu_mode(); ++restart: ++ for (i = pte_index(start), addr = start; addr != end; i++, addr += PAGE_SIZE) { ++ struct page *page; ++ unsigned long pfn = pte_pfn(pte[i]); ++ ++ args->mm_stats[MM_LEAF_TOTAL]++; ++ ++ if (!pte_present(pte[i]) || is_zero_pfn(pfn)) ++ continue; ++ ++ if (WARN_ON_ONCE(pte_devmap(pte[i]) || pte_special(pte[i]))) ++ continue; ++ ++ if (!pte_young(pte[i])) { ++ args->mm_stats[MM_LEAF_OLD]++; ++ continue; ++ } ++ ++ VM_BUG_ON(!pfn_valid(pfn)); ++ if (pfn < args->start_pfn || pfn >= args->end_pfn) ++ continue; ++ ++ page = compound_head(pfn_to_page(pfn)); ++ if (page_to_nid(page) != args->node_id) ++ continue; ++ ++ if (page_memcg_rcu(page) != args->memcg) ++ continue; ++ ++ VM_BUG_ON(addr < walk->vma->vm_start || addr >= walk->vma->vm_end); ++ if (!ptep_test_and_clear_young(walk->vma, addr, pte + i)) ++ continue; ++ ++ args->mm_stats[MM_LEAF_YOUNG]++; ++ ++ if (pte_dirty(pte[i]) && !PageDirty(page) && ++ !(PageAnon(page) && PageSwapBacked(page) && !PageSwapCache(page))) ++ set_page_dirty(page); ++ ++ old_gen = page_update_gen(page, new_gen); ++ if (old_gen >= 0 && old_gen != new_gen) ++ update_batch_size(page, old_gen, new_gen, args); ++ ++ worth++; ++ } ++ ++ if (i < PTRS_PER_PTE && get_next_vma(walk, PMD_MASK, PAGE_SIZE, &start, &end)) ++ goto restart; ++ ++ arch_leave_lazy_mmu_mode(); ++ pte_unmap_unlock(pte, ptl); ++ ++ return worth >= MIN_BATCH_SIZE / 2; ++} ++ ++/* ++ * We scan PMD entries in two passes. The first pass reaches to PTE tables and ++ * doesn't take the PMD lock. The second pass clears the accessed bit on PMD ++ * entries and needs to take the PMD lock. ++ */ ++#if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG) ++static void walk_pmd_range_locked(pud_t *pud, unsigned long start, int offset, ++ struct vm_area_struct *vma, struct mm_walk *walk) ++{ ++ int i; ++ pmd_t *pmd; ++ spinlock_t *ptl; ++ struct mm_walk_args *args = walk->private; ++ int old_gen, new_gen = lru_gen_from_seq(args->max_seq); ++ ++ VM_BUG_ON(pud_leaf(*pud)); ++ ++ start = (start & PUD_MASK) + offset * PMD_SIZE; ++ pmd = pmd_offset(pud, start); ++ ptl = pmd_lock(walk->mm, pmd); ++ arch_enter_lazy_mmu_mode(); ++ ++ for_each_set_bit(i, args->bitmap, MIN_BATCH_SIZE) { ++ struct page *page; ++ unsigned long pfn = pmd_pfn(pmd[i]); ++ unsigned long addr = start + i * PMD_SIZE; ++ ++ if (!pmd_present(pmd[i]) || is_huge_zero_pmd(pmd[i])) ++ continue; ++ ++ if (WARN_ON_ONCE(pmd_devmap(pmd[i]))) ++ continue; ++ ++ if (!pmd_trans_huge(pmd[i])) { ++ if (IS_ENABLED(CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG)) ++ pmdp_test_and_clear_young(vma, addr, pmd + i); ++ continue; ++ } ++ ++ VM_BUG_ON(!pfn_valid(pfn)); ++ if (pfn < args->start_pfn || pfn >= args->end_pfn) ++ continue; ++ ++ page = pfn_to_page(pfn); ++ VM_BUG_ON_PAGE(PageTail(page), page); ++ if (page_to_nid(page) != args->node_id) ++ continue; ++ ++ if (page_memcg_rcu(page) != args->memcg) ++ continue; ++ ++ VM_BUG_ON(addr < vma->vm_start || addr >= vma->vm_end); ++ if (!pmdp_test_and_clear_young(vma, addr, pmd + i)) ++ continue; ++ ++ args->mm_stats[MM_LEAF_YOUNG]++; ++ ++ if (pmd_dirty(pmd[i]) && !PageDirty(page) && ++ !(PageAnon(page) && PageSwapBacked(page) && !PageSwapCache(page))) ++ set_page_dirty(page); ++ ++ old_gen = page_update_gen(page, new_gen); ++ if (old_gen >= 0 && old_gen != new_gen) ++ update_batch_size(page, old_gen, new_gen, args); ++ } ++ ++ arch_leave_lazy_mmu_mode(); ++ spin_unlock(ptl); ++ ++ bitmap_zero(args->bitmap, MIN_BATCH_SIZE); ++} ++#else ++static void walk_pmd_range_locked(pud_t *pud, unsigned long start, int offset, ++ struct vm_area_struct *vma, struct mm_walk *walk) ++{ ++} ++#endif ++ ++static void walk_pmd_range(pud_t *pud, unsigned long start, unsigned long end, ++ struct mm_walk *walk) ++{ ++ int i; ++ pmd_t *pmd; ++ unsigned long next; ++ unsigned long addr; ++ struct vm_area_struct *vma; ++ int offset = -1; ++ bool reset = false; ++ struct mm_walk_args *args = walk->private; ++ struct lruvec *lruvec = get_lruvec(args->node_id, args->memcg); ++ ++ VM_BUG_ON(pud_leaf(*pud)); ++ ++ pmd = pmd_offset(pud, start & PUD_MASK); ++restart: ++ vma = walk->vma; ++ for (i = pmd_index(start), addr = start; addr != end; i++, addr = next) { ++ pmd_t val = pmd_read_atomic(pmd + i); ++ ++ /* for pmd_read_atomic() */ ++ barrier(); ++ ++ next = pmd_addr_end(addr, end); ++ ++ if (!pmd_present(val)) { ++ args->mm_stats[MM_LEAF_TOTAL]++; ++ continue; ++ } ++ ++#ifdef CONFIG_TRANSPARENT_HUGEPAGE ++ if (pmd_trans_huge(val)) { ++ unsigned long pfn = pmd_pfn(val); ++ ++ args->mm_stats[MM_LEAF_TOTAL]++; ++ ++ if (is_huge_zero_pmd(val)) ++ continue; ++ ++ if (!pmd_young(val)) { ++ args->mm_stats[MM_LEAF_OLD]++; ++ continue; ++ } ++ ++ if (pfn < args->start_pfn || pfn >= args->end_pfn) ++ continue; ++ ++ if (offset < 0) ++ offset = i; ++ else if (i - offset >= MIN_BATCH_SIZE) { ++ walk_pmd_range_locked(pud, start, offset, vma, walk); ++ offset = i; ++ } ++ __set_bit(i - offset, args->bitmap); ++ reset = true; ++ continue; ++ } ++#endif ++ args->mm_stats[MM_NONLEAF_TOTAL]++; ++ ++#ifdef CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG ++ if (!pmd_young(val)) ++ continue; ++ ++ if (offset < 0) ++ offset = i; ++ else if (i - offset >= MIN_BATCH_SIZE) { ++ walk_pmd_range_locked(pud, start, offset, vma, walk); ++ offset = i; ++ reset = false; ++ } ++ __set_bit(i - offset, args->bitmap); ++#endif ++ if (args->use_filter && !test_bloom_filter(lruvec, args->max_seq, pmd + i)) ++ continue; ++ ++ args->mm_stats[MM_NONLEAF_PREV]++; ++ ++ if (!walk_pte_range(&val, addr, next, walk)) ++ continue; ++ ++ args->mm_stats[MM_NONLEAF_CUR]++; ++ ++ set_bloom_filter(lruvec, args->max_seq + 1, pmd + i); ++ } ++ ++ if (reset) { ++ walk_pmd_range_locked(pud, start, offset, vma, walk); ++ offset = -1; ++ reset = false; ++ } ++ ++ if (i < PTRS_PER_PMD && get_next_vma(walk, PUD_MASK, PMD_SIZE, &start, &end)) ++ goto restart; ++ ++ if (offset >= 0) ++ walk_pmd_range_locked(pud, start, offset, vma, walk); ++} ++ ++static int walk_pud_range(p4d_t *p4d, unsigned long start, unsigned long end, ++ struct mm_walk *walk) ++{ ++ int i; ++ pud_t *pud; ++ unsigned long addr; ++ unsigned long next; ++ struct mm_walk_args *args = walk->private; ++ ++ VM_BUG_ON(p4d_leaf(*p4d)); ++ ++ pud = pud_offset(p4d, start & P4D_MASK); ++restart: ++ for (i = pud_index(start), addr = start; addr != end; i++, addr = next) { ++ pud_t val = READ_ONCE(pud[i]); ++ ++ next = pud_addr_end(addr, end); ++ ++ if (!pud_present(val) || WARN_ON_ONCE(pud_leaf(val))) ++ continue; ++ ++ walk_pmd_range(&val, addr, next, walk); ++ ++ if (args->batch_size >= MAX_BATCH_SIZE) { ++ end = (addr | ~PUD_MASK) + 1; ++ goto done; ++ } ++ } ++ ++ if (i < PTRS_PER_PUD && get_next_vma(walk, P4D_MASK, PUD_SIZE, &start, &end)) ++ goto restart; ++ ++ end = round_up(end, P4D_SIZE); ++done: ++ /* rounded-up boundaries can wrap to 0 */ ++ args->next_addr = end && walk->vma ? max(end, walk->vma->vm_start) : 0; ++ ++ return -EAGAIN; ++} ++ ++static void walk_mm(struct lruvec *lruvec, struct mm_struct *mm, struct mm_walk_args *args) ++{ ++ static const struct mm_walk_ops mm_walk_ops = { ++ .test_walk = should_skip_vma, ++ .p4d_entry = walk_pud_range, ++ }; ++ ++ int err; ++ ++ args->next_addr = FIRST_USER_ADDRESS; ++ ++ do { ++ unsigned long start = args->next_addr; ++ unsigned long end = mm->highest_vm_end; ++ ++ err = -EBUSY; ++ ++ rcu_read_lock(); ++#ifdef CONFIG_MEMCG ++ if (args->memcg && atomic_read(&args->memcg->moving_account)) ++ goto contended; ++#endif ++ if (!mmap_read_trylock(mm)) ++ goto contended; ++ ++ err = walk_page_range(mm, start, end, &mm_walk_ops, args); ++ ++ mmap_read_unlock(mm); ++ ++ if (args->batch_size) { ++ spin_lock_irq(&lruvec->lru_lock); ++ reset_batch_size(lruvec, args); ++ spin_unlock_irq(&lruvec->lru_lock); ++ } ++contended: ++ rcu_read_unlock(); ++ ++ cond_resched(); ++ } while (err == -EAGAIN && args->next_addr && !mm_is_oom_victim(mm)); ++} ++ ++static struct mm_walk_args *alloc_mm_walk_args(void) ++{ ++ if (!current->reclaim_state || !current->reclaim_state->mm_walk_args) ++ return kvzalloc(sizeof(struct mm_walk_args), GFP_KERNEL); ++ ++ return current->reclaim_state->mm_walk_args; ++} ++ ++static void free_mm_walk_args(struct mm_walk_args *args) ++{ ++ if (!current->reclaim_state || !current->reclaim_state->mm_walk_args) ++ kvfree(args); ++} ++ ++static bool inc_min_seq(struct lruvec *lruvec, int type) ++{ ++ int gen, zone; ++ int remaining = MAX_BATCH_SIZE; ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ VM_BUG_ON(!seq_is_valid(lruvec)); ++ ++ if (get_nr_gens(lruvec, type) != MAX_NR_GENS) ++ return true; ++ ++ gen = lru_gen_from_seq(lrugen->min_seq[type]); ++ ++ for (zone = 0; zone < MAX_NR_ZONES; zone++) { ++ struct list_head *head = &lrugen->lists[gen][type][zone]; ++ ++ while (!list_empty(head)) { ++ struct page *page = lru_to_page(head); ++ ++ VM_BUG_ON_PAGE(PageTail(page), page); ++ VM_BUG_ON_PAGE(PageUnevictable(page), page); ++ VM_BUG_ON_PAGE(PageActive(page), page); ++ VM_BUG_ON_PAGE(page_is_file_lru(page) != type, page); ++ VM_BUG_ON_PAGE(page_zonenum(page) != zone, page); ++ ++ prefetchw_prev_lru_page(page, head, flags); ++ ++ page_inc_gen(page, lruvec, false); ++ ++ if (!--remaining) ++ return false; ++ } ++ } ++ ++ WRITE_ONCE(lrugen->min_seq[type], lrugen->min_seq[type] + 1); ++ ++ return true; ++} ++ ++static bool try_to_inc_min_seq(struct lruvec *lruvec, int swappiness) ++{ ++ int gen, type, zone; ++ bool success = false; ++ struct lrugen *lrugen = &lruvec->evictable; ++ DEFINE_MIN_SEQ(lruvec); ++ ++ VM_BUG_ON(!seq_is_valid(lruvec)); ++ ++ for (type = 0; type < ANON_AND_FILE; type++) { ++ while (lrugen->max_seq - min_seq[type] >= MIN_NR_GENS) { ++ gen = lru_gen_from_seq(min_seq[type]); ++ ++ for (zone = 0; zone < MAX_NR_ZONES; zone++) { ++ if (!list_empty(&lrugen->lists[gen][type][zone])) ++ goto next; ++ } ++ ++ min_seq[type]++; ++ } ++next: ++ ; ++ } ++ ++ min_seq[0] = min(min_seq[0], min_seq[1]); ++ if (swappiness) ++ min_seq[1] = max(min_seq[0], lrugen->min_seq[1]); ++ ++ for (type = 0; type < ANON_AND_FILE; type++) { ++ if (min_seq[type] == lrugen->min_seq[type]) ++ continue; ++ ++ WRITE_ONCE(lrugen->min_seq[type], min_seq[type]); ++ success = true; ++ } ++ ++ return success; ++} ++ ++static void inc_max_seq(struct lruvec *lruvec, unsigned long max_seq) ++{ ++ int gen, type, zone; ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ spin_lock_irq(&lruvec->lru_lock); ++ ++ VM_BUG_ON(!seq_is_valid(lruvec)); ++ ++ if (max_seq != lrugen->max_seq) ++ goto unlock; ++ ++ if (!try_to_inc_min_seq(lruvec, true)) { ++ for (type = ANON_AND_FILE - 1; type >= 0; type--) { ++ while (!inc_min_seq(lruvec, type)) { ++ spin_unlock_irq(&lruvec->lru_lock); ++ cond_resched(); ++ spin_lock_irq(&lruvec->lru_lock); ++ } ++ } ++ } ++ ++ gen = lru_gen_from_seq(lrugen->max_seq - 1); ++ for (type = 0; type < ANON_AND_FILE; type++) { ++ for (zone = 0; zone < MAX_NR_ZONES; zone++) { ++ enum lru_list lru = type * LRU_FILE; ++ long delta = lrugen->sizes[gen][type][zone]; ++ ++ if (!delta) ++ continue; ++ ++ WARN_ON_ONCE(delta != (int)delta); ++ ++ update_lru_size(lruvec, lru, zone, delta); ++ update_lru_size(lruvec, lru + LRU_ACTIVE, zone, -delta); ++ } ++ } ++ ++ gen = lru_gen_from_seq(lrugen->max_seq + 1); ++ for (type = 0; type < ANON_AND_FILE; type++) { ++ for (zone = 0; zone < MAX_NR_ZONES; zone++) { ++ enum lru_list lru = type * LRU_FILE; ++ long delta = lrugen->sizes[gen][type][zone]; ++ ++ if (!delta) ++ continue; ++ ++ WARN_ON_ONCE(delta != (int)delta); ++ ++ update_lru_size(lruvec, lru, zone, -delta); ++ update_lru_size(lruvec, lru + LRU_ACTIVE, zone, delta); ++ } ++ } ++ ++ WRITE_ONCE(lrugen->timestamps[gen], jiffies); ++ /* make sure all preceding modifications appear first */ ++ smp_store_release(&lrugen->max_seq, lrugen->max_seq + 1); ++unlock: ++ spin_unlock_irq(&lruvec->lru_lock); ++} ++ ++/* Main function used by the foreground, the background and the user-triggered aging. */ ++static bool try_to_inc_max_seq(struct lruvec *lruvec, struct scan_control *sc, int swappiness, ++ unsigned long max_seq, bool use_filter) ++{ ++ bool last; ++ struct mm_walk_args *args; ++ struct mm_struct *mm = NULL; ++ struct lrugen *lrugen = &lruvec->evictable; ++ struct mem_cgroup *memcg = lruvec_memcg(lruvec); ++ struct pglist_data *pgdat = lruvec_pgdat(lruvec); ++ int nid = pgdat->node_id; ++ ++ VM_BUG_ON(max_seq > READ_ONCE(lrugen->max_seq)); ++ ++ /* ++ * If we are not from run_aging() and clearing the accessed bit may ++ * trigger page faults, then don't proceed to clearing all accessed ++ * PTEs. Instead, fallback to lru_gen_look_around(), which only clears a ++ * handful of accessed PTEs. This is less efficient but causes fewer ++ * page faults on CPUs that don't have the capability. ++ */ ++ if ((current->flags & PF_MEMALLOC) && !arch_has_hw_pte_young(false)) { ++ inc_max_seq(lruvec, max_seq); ++ return true; ++ } ++ ++ args = alloc_mm_walk_args(); ++ if (!args) ++ return false; ++ ++ args->memcg = memcg; ++ args->max_seq = max_seq; ++ args->start_pfn = pgdat->node_start_pfn; ++ args->end_pfn = pgdat_end_pfn(pgdat); ++ args->node_id = nid; ++ args->swappiness = swappiness; ++ args->use_filter = use_filter; ++ ++ do { ++ last = get_next_mm(lruvec, args, &mm); ++ if (mm) ++ walk_mm(lruvec, mm, args); ++ ++ cond_resched(); ++ } while (mm); ++ ++ free_mm_walk_args(args); ++ ++ if (!last) { ++ /* don't wait unless we may have trouble reclaiming */ ++ if (!current_is_kswapd() && sc->priority < DEF_PRIORITY - 2) ++ wait_event_killable(lruvec->mm_walk.wait, ++ max_seq < READ_ONCE(lrugen->max_seq)); ++ ++ return max_seq < READ_ONCE(lrugen->max_seq); ++ } ++ ++ VM_BUG_ON(max_seq != READ_ONCE(lrugen->max_seq)); ++ ++ inc_max_seq(lruvec, max_seq); ++ /* either we see any waiters or they will see updated max_seq */ ++ if (wq_has_sleeper(&lruvec->mm_walk.wait)) ++ wake_up_all(&lruvec->mm_walk.wait); ++ ++ wakeup_flusher_threads(WB_REASON_VMSCAN); ++ ++ return true; ++} ++ ++static long get_nr_evictable(struct lruvec *lruvec, struct scan_control *sc, int swappiness, ++ unsigned long max_seq, unsigned long *min_seq, bool *low) ++{ ++ int gen, type, zone; ++ long max = 0; ++ long min = 0; ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ for (type = !swappiness; type < ANON_AND_FILE; type++) { ++ unsigned long seq; ++ ++ for (seq = min_seq[type]; seq <= max_seq; seq++) { ++ long size = 0; ++ ++ gen = lru_gen_from_seq(seq); ++ ++ for (zone = 0; zone <= sc->reclaim_idx; zone++) ++ size += READ_ONCE(lrugen->sizes[gen][type][zone]); ++ ++ max += size; ++ if (type && max_seq - seq >= MIN_NR_GENS) ++ min += size; ++ } ++ } ++ ++ *low = max_seq - min_seq[1] <= MIN_NR_GENS && min < MIN_BATCH_SIZE; ++ ++ return max > 0 ? max : 0; ++} ++ ++static bool age_lruvec(struct lruvec *lruvec, struct scan_control *sc, ++ unsigned long min_ttl) ++{ ++ bool low; ++ long nr_to_scan; ++ struct mem_cgroup *memcg = lruvec_memcg(lruvec); ++ int swappiness = get_swappiness(memcg); ++ DEFINE_MAX_SEQ(lruvec); ++ DEFINE_MIN_SEQ(lruvec); ++ ++ if (mem_cgroup_below_min(memcg)) ++ return false; ++ ++ if (min_ttl) { ++ int gen = lru_gen_from_seq(min_seq[1]); ++ unsigned long birth = READ_ONCE(lruvec->evictable.timestamps[gen]); ++ ++ if (time_is_after_jiffies(birth + min_ttl)) ++ return false; ++ } ++ ++ nr_to_scan = get_nr_evictable(lruvec, sc, swappiness, max_seq, min_seq, &low); ++ if (!nr_to_scan) ++ return false; ++ ++ nr_to_scan >>= sc->priority; ++ ++ if (!mem_cgroup_online(memcg)) ++ nr_to_scan++; ++ ++ if (nr_to_scan && low && (!mem_cgroup_below_low(memcg) || sc->memcg_low_reclaim)) ++ try_to_inc_max_seq(lruvec, sc, swappiness, max_seq, true); ++ ++ return true; ++} ++ ++/* Protect the working set accessed within the last N milliseconds. */ ++static unsigned long lru_gen_min_ttl __read_mostly; ++ ++static void lru_gen_age_node(struct pglist_data *pgdat, struct scan_control *sc) ++{ ++ struct mem_cgroup *memcg; ++ bool success = false; ++ unsigned long min_ttl = READ_ONCE(lru_gen_min_ttl); ++ ++ VM_BUG_ON(!current_is_kswapd()); ++ ++ if (!sc->force_deactivate) { ++ sc->force_deactivate = 1; ++ return; ++ } ++ ++ current->reclaim_state->mm_walk_args = &pgdat->mm_walk_args; ++ ++ memcg = mem_cgroup_iter(NULL, NULL, NULL); ++ do { ++ struct lruvec *lruvec = mem_cgroup_lruvec(memcg, pgdat); ++ ++ if (age_lruvec(lruvec, sc, min_ttl)) ++ success = true; ++ ++ cond_resched(); ++ } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL))); ++ ++ if (!success && mutex_trylock(&oom_lock)) { ++ struct oom_control oc = { ++ .gfp_mask = sc->gfp_mask, ++ .order = sc->order, ++ }; ++ ++ /* to avoid overkilling */ ++ if (!oom_reaping_in_progress()) ++ out_of_memory(&oc); ++ ++ mutex_unlock(&oom_lock); ++ } ++ ++ current->reclaim_state->mm_walk_args = NULL; ++} ++ ++/* Scan the vicinity of an accessed PTE when shrink_page_list() uses the rmap. */ ++void lru_gen_look_around(struct page_vma_mapped_walk *pvmw) ++{ ++ int i; ++ pte_t *pte; ++ struct page *page; ++ int old_gen, new_gen; ++ unsigned long start; ++ unsigned long end; ++ unsigned long addr; ++ struct mm_walk_args *args; ++ int worth = 0; ++ struct mem_cgroup *memcg = page_memcg(pvmw->page); ++ struct pglist_data *pgdat = page_pgdat(pvmw->page); ++ struct lruvec *lruvec = mem_cgroup_lruvec(memcg, pgdat); ++ DEFINE_MAX_SEQ(lruvec); ++ ++ lockdep_assert_held(pvmw->ptl); ++ VM_BUG_ON_PAGE(PageLRU(pvmw->page), pvmw->page); ++ ++ args = current->reclaim_state ? current->reclaim_state->mm_walk_args : NULL; ++ if (!args) ++ return; ++ ++ start = max(pvmw->address & PMD_MASK, pvmw->vma->vm_start); ++ end = min(pvmw->address | ~PMD_MASK, pvmw->vma->vm_end - 1) + 1; ++ ++ if (end - start > MIN_BATCH_SIZE * PAGE_SIZE) { ++ if (pvmw->address - start < MIN_BATCH_SIZE * PAGE_SIZE / 2) ++ end = start + MIN_BATCH_SIZE * PAGE_SIZE; ++ else if (end - pvmw->address < MIN_BATCH_SIZE * PAGE_SIZE / 2) ++ start = end - MIN_BATCH_SIZE * PAGE_SIZE; ++ else { ++ start = pvmw->address - MIN_BATCH_SIZE * PAGE_SIZE / 2; ++ end = pvmw->address + MIN_BATCH_SIZE * PAGE_SIZE / 2; ++ } ++ } ++ ++ pte = pvmw->pte - (pvmw->address - start) / PAGE_SIZE; ++ new_gen = lru_gen_from_seq(max_seq); ++ ++ lock_page_memcg(pvmw->page); ++ arch_enter_lazy_mmu_mode(); ++ ++ for (i = 0, addr = start; addr != end; i++, addr += PAGE_SIZE) { ++ unsigned long pfn = pte_pfn(pte[i]); ++ ++ if (!pte_present(pte[i]) || is_zero_pfn(pfn)) ++ continue; ++ ++ if (WARN_ON_ONCE(pte_devmap(pte[i]) || pte_special(pte[i]))) ++ continue; ++ ++ VM_BUG_ON(!pfn_valid(pfn)); ++ if (pfn < pgdat->node_start_pfn || pfn >= pgdat_end_pfn(pgdat)) ++ continue; ++ ++ worth++; ++ ++ if (!pte_young(pte[i])) ++ continue; ++ ++ page = compound_head(pfn_to_page(pfn)); ++ if (page_to_nid(page) != pgdat->node_id) ++ continue; ++ ++ if (page_memcg_rcu(page) != memcg) ++ continue; ++ ++ VM_BUG_ON(addr < pvmw->vma->vm_start || addr >= pvmw->vma->vm_end); ++ if (!ptep_test_and_clear_young(pvmw->vma, addr, pte + i)) ++ continue; ++ ++ if (pte_dirty(pte[i]) && !PageDirty(page) && ++ !(PageAnon(page) && PageSwapBacked(page) && !PageSwapCache(page))) ++ __set_bit(i, args->bitmap); ++ ++ old_gen = page_update_gen(page, new_gen); ++ if (old_gen >= 0 && old_gen != new_gen) ++ update_batch_size(page, old_gen, new_gen, args); ++ } ++ ++ arch_leave_lazy_mmu_mode(); ++ unlock_page_memcg(pvmw->page); ++ ++ if (worth >= MIN_BATCH_SIZE / 2) ++ set_bloom_filter(lruvec, max_seq, pvmw->pmd); ++ ++ for_each_set_bit(i, args->bitmap, MIN_BATCH_SIZE) ++ set_page_dirty(pte_page(pte[i])); ++ ++ bitmap_zero(args->bitmap, MIN_BATCH_SIZE); ++} ++ ++/****************************************************************************** + * state change + ******************************************************************************/ + +@@ -3477,6 +4414,12 @@ static int __init init_lru_gen(void) + }; + late_initcall(init_lru_gen); + ++#else ++ ++static void lru_gen_age_node(struct pglist_data *pgdat, struct scan_control *sc) ++{ ++} ++ + #endif /* CONFIG_LRU_GEN */ + + static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) +@@ -4333,6 +5276,11 @@ static void age_active_anon(struct pglis + struct mem_cgroup *memcg; + struct lruvec *lruvec; + ++ if (lru_gen_enabled()) { ++ lru_gen_age_node(pgdat, sc); ++ return; ++ } ++ + if (!can_age_anon_pages(pgdat, sc)) + return; + diff --git a/target/linux/generic/pending-5.15/020-06-mm-multigenerational-lru-eviction.patch b/target/linux/generic/pending-5.15/020-06-mm-multigenerational-lru-eviction.patch new file mode 100644 index 0000000000..09e4315dcc --- /dev/null +++ b/target/linux/generic/pending-5.15/020-06-mm-multigenerational-lru-eviction.patch @@ -0,0 +1,1002 @@ +From f4b881ce07ccb2a519f664afaa2a68225b612ca3 Mon Sep 17 00:00:00 2001 +From: Yu Zhao +Date: Tue, 29 Jun 2021 20:46:47 -0600 +Subject: [PATCH 07/10] mm: multigenerational lru: eviction + +The eviction consumes old generations. Given an lruvec, the eviction +scans pages on lrugen->lists indexed by anon and file min_seq[] +(modulo MAX_NR_GENS). It first tries to select a type based on the +values of min_seq[]. If they are equal, it selects the type that has +a lower refaulted %. The eviction sorts a page according to its +updated generation number if the aging has found this page accessed. +It also moves a page to the next generation if this page is from an +upper tier that has a higher refaulted % than the base tier. The +eviction increments min_seq[] of a selected type when it finds +lrugen->lists indexed by min_seq[] of this selected type are empty. + +Each generation is divided into multiple tiers. Tiers represent +different ranges of numbers of accesses from file descriptors only. +Pages accessed N times via file descriptors belong to tier +order_base_2(N). Each generation contains at most MAX_NR_TIERS tiers, +and they require additional MAX_NR_TIERS-2 bits in page->flags. In +contrast to moving between generations which requires list operations, +moving between tiers only involves operations on page->flags and +therefore has a negligible cost. A feedback loop modeled after the PID +controller monitors refaulted % across all tiers and decides when to +protect pages from which tiers. + +Unmapped pages are initially added to the oldest generation and then +conditionally protected by tiers. Each tier keeps track of how many +pages from it have refaulted. Tier 0 is the base tier and pages from +it are evicted unconditionally because there are no better candidates. +Pages from an upper tier are either evicted or moved to the next +generation, depending on whether this upper tier has a higher +refaulted % than the base tier. This model has the following +advantages: + 1) It removes the cost in the buffered access path and reduces the + overall cost of protection because pages are conditionally protected + in the reclaim path. + 2) It takes mapped pages into account and avoids overprotecting + pages accessed multiple times via file descriptors. + 3 Additional tiers improve the protection of pages accessed more + than twice. + +Signed-off-by: Yu Zhao +Tested-by: Konstantin Kharlamov +Change-Id: I64c06d8f2cdb83ac7d56c7e1d07f043483956cac +--- + include/linux/mm_inline.h | 10 + + include/linux/mmzone.h | 33 +++ + mm/swap.c | 42 +++ + mm/vmscan.c | 555 +++++++++++++++++++++++++++++++++++++- + mm/workingset.c | 120 ++++++++- + 5 files changed, 757 insertions(+), 3 deletions(-) + +--- a/include/linux/mm_inline.h ++++ b/include/linux/mm_inline.h +@@ -106,6 +106,14 @@ static inline int lru_hist_from_seq(unsi + return seq % NR_HIST_GENS; + } + ++/* Convert the number of accesses to a tier. See the comment on MAX_NR_TIERS. */ ++static inline int lru_tier_from_refs(int refs) ++{ ++ VM_BUG_ON(refs > BIT(LRU_REFS_WIDTH)); ++ ++ return order_base_2(refs + 1); ++} ++ + /* The youngest and the second youngest generations are counted as active. */ + static inline bool lru_gen_is_active(struct lruvec *lruvec, int gen) + { +@@ -226,6 +234,8 @@ static inline bool lru_gen_del_page(stru + gen = ((new_flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1; + + new_flags &= ~LRU_GEN_MASK; ++ if ((new_flags & LRU_REFS_FLAGS) != LRU_REFS_FLAGS) ++ new_flags &= ~(LRU_REFS_MASK | LRU_REFS_FLAGS); + /* for shrink_page_list() */ + if (reclaiming) + new_flags &= ~(BIT(PG_referenced) | BIT(PG_reclaim)); +--- a/include/linux/mmzone.h ++++ b/include/linux/mmzone.h +@@ -319,6 +319,30 @@ struct page_vma_mapped_walk; + #define MIN_NR_GENS 2 + #define MAX_NR_GENS ((unsigned int)CONFIG_NR_LRU_GENS) + ++/* ++ * Each generation is divided into multiple tiers. Tiers represent different ++ * ranges of numbers of accesses from file descriptors, i.e., ++ * mark_page_accessed(). In contrast to moving between generations which ++ * requires the lru lock, moving between tiers only involves an atomic ++ * operation on page->flags and therefore has a negligible cost. ++ * ++ * The purposes of tiers are to: ++ * 1) estimate whether pages accessed multiple times via file descriptors are ++ * more active than pages accessed only via page tables by separating the two ++ * access types into upper tiers and the base tier, and comparing refaulted % ++ * across all tiers. ++ * 2) improve buffered io performance by deferring the protection of pages ++ * accessed multiple times until the eviction. That is the protection happens ++ * in the reclaim path, not the access path. ++ * ++ * Pages accessed N times via file descriptors belong to tier order_base_2(N). ++ * The base tier may be marked by PageReferenced(). All upper tiers are marked ++ * by PageReferenced() && PageWorkingset(). Additional bits from page->flags are ++ * used to support more than one upper tier. ++ */ ++#define MAX_NR_TIERS ((unsigned int)CONFIG_TIERS_PER_GEN) ++#define LRU_REFS_FLAGS (BIT(PG_referenced) | BIT(PG_workingset)) ++ + /* Whether to keep stats for historical generations. */ + #ifdef CONFIG_LRU_GEN_STATS + #define NR_HIST_GENS ((unsigned int)CONFIG_NR_LRU_GENS) +@@ -337,6 +361,15 @@ struct lrugen { + struct list_head lists[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES]; + /* the sizes of the multigenerational lru lists in pages */ + unsigned long sizes[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES]; ++ /* the exponential moving average of refaulted */ ++ unsigned long avg_refaulted[ANON_AND_FILE][MAX_NR_TIERS]; ++ /* the exponential moving average of protected+evicted */ ++ unsigned long avg_total[ANON_AND_FILE][MAX_NR_TIERS]; ++ /* the base tier isn't protected, hence the minus one */ ++ unsigned long protected[NR_HIST_GENS][ANON_AND_FILE][MAX_NR_TIERS - 1]; ++ /* incremented without holding the lru lock */ ++ atomic_long_t evicted[NR_HIST_GENS][ANON_AND_FILE][MAX_NR_TIERS]; ++ atomic_long_t refaulted[NR_HIST_GENS][ANON_AND_FILE][MAX_NR_TIERS]; + /* whether the multigenerational lru is enabled */ + bool enabled[ANON_AND_FILE]; + }; +--- a/mm/swap.c ++++ b/mm/swap.c +@@ -389,6 +389,43 @@ static void __lru_cache_activate_page(st + local_unlock(&lru_pvecs.lock); + } + ++#ifdef CONFIG_LRU_GEN ++static void page_inc_refs(struct page *page) ++{ ++ unsigned long refs; ++ unsigned long old_flags, new_flags; ++ ++ if (PageUnevictable(page)) ++ return; ++ ++ /* see the comment on MAX_NR_TIERS */ ++ do { ++ new_flags = old_flags = READ_ONCE(page->flags); ++ ++ if (!(new_flags & BIT(PG_referenced))) { ++ new_flags |= BIT(PG_referenced); ++ continue; ++ } ++ ++ if (!(new_flags & BIT(PG_workingset))) { ++ new_flags |= BIT(PG_workingset); ++ continue; ++ } ++ ++ refs = new_flags & LRU_REFS_MASK; ++ refs = min(refs + BIT(LRU_REFS_PGOFF), LRU_REFS_MASK); ++ ++ new_flags &= ~LRU_REFS_MASK; ++ new_flags |= refs; ++ } while (new_flags != old_flags && ++ cmpxchg(&page->flags, old_flags, new_flags) != old_flags); ++} ++#else ++static void page_inc_refs(struct page *page) ++{ ++} ++#endif /* CONFIG_LRU_GEN */ ++ + /* + * Mark a page as having seen activity. + * +@@ -403,6 +440,11 @@ void mark_page_accessed(struct page *pag + { + page = compound_head(page); + ++ if (lru_gen_enabled()) { ++ page_inc_refs(page); ++ return; ++ } ++ + if (!PageReferenced(page)) { + SetPageReferenced(page); + } else if (PageUnevictable(page)) { +--- a/mm/vmscan.c ++++ b/mm/vmscan.c +@@ -1145,9 +1145,11 @@ static int __remove_mapping(struct addre + + if (PageSwapCache(page)) { + swp_entry_t swap = { .val = page_private(page) }; +- mem_cgroup_swapout(page, swap); ++ ++ /* get a shadow entry before page_memcg() is cleared */ + if (reclaimed && !mapping_exiting(mapping)) + shadow = workingset_eviction(page, target_memcg); ++ mem_cgroup_swapout(page, swap); + __delete_from_swap_cache(page, swap, shadow); + xa_unlock_irq(&mapping->i_pages); + put_swap_page(page, swap); +@@ -1410,6 +1412,11 @@ retry: + if (!sc->may_unmap && page_mapped(page)) + goto keep_locked; + ++ /* lru_gen_look_around() has updated this page? */ ++ if (lru_gen_enabled() && !ignore_references && ++ page_mapped(page) && PageReferenced(page)) ++ goto keep_locked; ++ + may_enter_fs = (sc->gfp_mask & __GFP_FS) || + (PageSwapCache(page) && (sc->gfp_mask & __GFP_IO)); + +@@ -2570,6 +2577,9 @@ static void prepare_scan_count(pg_data_t + unsigned long file; + struct lruvec *target_lruvec; + ++ if (lru_gen_enabled()) ++ return; ++ + target_lruvec = mem_cgroup_lruvec(sc->target_mem_cgroup, pgdat); + + /* +@@ -2910,6 +2920,17 @@ static int page_lru_gen(struct page *pag + return ((flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1; + } + ++static int page_lru_tier(struct page *page) ++{ ++ int refs; ++ unsigned long flags = READ_ONCE(page->flags); ++ ++ refs = (flags & LRU_REFS_FLAGS) == LRU_REFS_FLAGS ? ++ ((flags & LRU_REFS_MASK) >> LRU_REFS_PGOFF) + 1 : 0; ++ ++ return lru_tier_from_refs(refs); ++} ++ + static int get_swappiness(struct mem_cgroup *memcg) + { + return mem_cgroup_get_nr_swap_pages(memcg) >= MIN_BATCH_SIZE ? +@@ -3246,6 +3267,91 @@ done: + } + + /****************************************************************************** ++ * refault feedback loop ++ ******************************************************************************/ ++ ++/* ++ * A feedback loop modeled after the PID controller. Currently supports the ++ * proportional (P) and the integral (I) terms; the derivative (D) term can be ++ * added if necessary. The setpoint (SP) is the desired position; the process ++ * variable (PV) is the measured position. The error is the difference between ++ * the SP and the PV. A positive error results in a positive control output ++ * correction, which, in our case, is to allow eviction. ++ * ++ * The P term is refaulted % of the current generation being evicted. The I ++ * term is the exponential moving average of refaulted % of previously evicted ++ * generations, using the smoothing factor 1/2. ++ * ++ * Our goal is to maintain proportional refaulted % across all tiers. ++ */ ++struct ctrl_pos { ++ unsigned long refaulted; ++ unsigned long total; ++ int gain; ++}; ++ ++static void read_ctrl_pos(struct lruvec *lruvec, int type, int tier, int gain, ++ struct ctrl_pos *pos) ++{ ++ struct lrugen *lrugen = &lruvec->evictable; ++ int hist = lru_hist_from_seq(lrugen->min_seq[type]); ++ ++ pos->refaulted = lrugen->avg_refaulted[type][tier] + ++ atomic_long_read(&lrugen->refaulted[hist][type][tier]); ++ pos->total = lrugen->avg_total[type][tier] + ++ atomic_long_read(&lrugen->evicted[hist][type][tier]); ++ if (tier) ++ pos->total += lrugen->protected[hist][type][tier - 1]; ++ pos->gain = gain; ++} ++ ++static void reset_ctrl_pos(struct lruvec *lruvec, int gen, int type) ++{ ++ int tier; ++ int hist = lru_hist_from_seq(gen); ++ struct lrugen *lrugen = &lruvec->evictable; ++ bool carryover = gen == lru_gen_from_seq(lrugen->min_seq[type]); ++ bool clear = carryover ? NR_HIST_GENS == 1 : NR_HIST_GENS > 1; ++ ++ if (!carryover && !clear) ++ return; ++ ++ for (tier = 0; tier < MAX_NR_TIERS; tier++) { ++ if (carryover) { ++ unsigned long sum; ++ ++ sum = lrugen->avg_refaulted[type][tier] + ++ atomic_long_read(&lrugen->refaulted[hist][type][tier]); ++ WRITE_ONCE(lrugen->avg_refaulted[type][tier], sum / 2); ++ ++ sum = lrugen->avg_total[type][tier] + ++ atomic_long_read(&lrugen->evicted[hist][type][tier]); ++ if (tier) ++ sum += lrugen->protected[hist][type][tier - 1]; ++ WRITE_ONCE(lrugen->avg_total[type][tier], sum / 2); ++ } ++ ++ if (clear) { ++ atomic_long_set(&lrugen->refaulted[hist][type][tier], 0); ++ atomic_long_set(&lrugen->evicted[hist][type][tier], 0); ++ if (tier) ++ WRITE_ONCE(lrugen->protected[hist][type][tier - 1], 0); ++ } ++ } ++} ++ ++static bool positive_ctrl_err(struct ctrl_pos *sp, struct ctrl_pos *pv) ++{ ++ /* ++ * Allow eviction if the PV has a limited number of refaulted pages or a ++ * lower refaulted % than the SP. ++ */ ++ return pv->refaulted < MIN_BATCH_SIZE || ++ pv->refaulted * max(sp->total, 1UL) * sp->gain <= ++ sp->refaulted * max(pv->total, 1UL) * pv->gain; ++} ++ ++/****************************************************************************** + * the aging + ******************************************************************************/ + +@@ -3265,6 +3371,7 @@ static int page_update_gen(struct page * + + new_flags &= ~LRU_GEN_MASK; + new_flags |= (gen + 1UL) << LRU_GEN_PGOFF; ++ new_flags &= ~(LRU_REFS_MASK | LRU_REFS_FLAGS); + } while (new_flags != old_flags && + cmpxchg(&page->flags, old_flags, new_flags) != old_flags); + +@@ -3296,6 +3403,7 @@ static void page_inc_gen(struct page *pa + + new_flags &= ~LRU_GEN_MASK; + new_flags |= (new_gen + 1UL) << LRU_GEN_PGOFF; ++ new_flags &= ~(LRU_REFS_MASK | LRU_REFS_FLAGS); + /* for end_page_writeback() */ + if (reclaiming) + new_flags |= BIT(PG_reclaim); +@@ -3787,6 +3895,7 @@ static bool inc_min_seq(struct lruvec *l + } + } + ++ reset_ctrl_pos(lruvec, gen, type); + WRITE_ONCE(lrugen->min_seq[type], lrugen->min_seq[type] + 1); + + return true; +@@ -3824,6 +3933,8 @@ next: + if (min_seq[type] == lrugen->min_seq[type]) + continue; + ++ gen = lru_gen_from_seq(lrugen->min_seq[type]); ++ reset_ctrl_pos(lruvec, gen, type); + WRITE_ONCE(lrugen->min_seq[type], min_seq[type]); + success = true; + } +@@ -3885,6 +3996,9 @@ static void inc_max_seq(struct lruvec *l + } + } + ++ for (type = 0; type < ANON_AND_FILE; type++) ++ reset_ctrl_pos(lruvec, gen, type); ++ + WRITE_ONCE(lrugen->timestamps[gen], jiffies); + /* make sure all preceding modifications appear first */ + smp_store_release(&lrugen->max_seq, lrugen->max_seq + 1); +@@ -4166,6 +4280,433 @@ void lru_gen_look_around(struct page_vma + } + + /****************************************************************************** ++ * the eviction ++ ******************************************************************************/ ++ ++static bool sort_page(struct page *page, struct lruvec *lruvec, int tier_idx) ++{ ++ bool success; ++ int gen = page_lru_gen(page); ++ int type = page_is_file_lru(page); ++ int zone = page_zonenum(page); ++ int tier = page_lru_tier(page); ++ int delta = thp_nr_pages(page); ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ VM_BUG_ON_PAGE(gen >= MAX_NR_GENS, page); ++ ++ /* an mlocked page? */ ++ if (!page_evictable(page)) { ++ success = lru_gen_del_page(page, lruvec, true); ++ VM_BUG_ON_PAGE(!success, page); ++ SetPageUnevictable(page); ++ add_page_to_lru_list(page, lruvec); ++ __count_vm_events(UNEVICTABLE_PGCULLED, delta); ++ return true; ++ } ++ ++ /* a lazy-free page that has been written into? */ ++ if (type && PageDirty(page) && PageAnon(page)) { ++ success = lru_gen_del_page(page, lruvec, true); ++ VM_BUG_ON_PAGE(!success, page); ++ SetPageSwapBacked(page); ++ add_page_to_lru_list_tail(page, lruvec); ++ return true; ++ } ++ ++ /* page_update_gen() has updated this page? */ ++ if (gen != lru_gen_from_seq(lrugen->min_seq[type])) { ++ list_move(&page->lru, &lrugen->lists[gen][type][zone]); ++ return true; ++ } ++ ++ /* protect this page if its tier has a higher refaulted % */ ++ if (tier > tier_idx) { ++ int hist = lru_hist_from_seq(gen); ++ ++ page_inc_gen(page, lruvec, false); ++ WRITE_ONCE(lrugen->protected[hist][type][tier - 1], ++ lrugen->protected[hist][type][tier - 1] + delta); ++ __mod_lruvec_state(lruvec, WORKINGSET_ACTIVATE_BASE + type, delta); ++ return true; ++ } ++ ++ /* mark this page for reclaim if it's pending writeback */ ++ if (PageWriteback(page) || (type && PageDirty(page))) { ++ page_inc_gen(page, lruvec, true); ++ return true; ++ } ++ ++ return false; ++} ++ ++static bool isolate_page(struct page *page, struct lruvec *lruvec, struct scan_control *sc) ++{ ++ bool success; ++ ++ if (!sc->may_unmap && page_mapped(page)) ++ return false; ++ ++ if (!(sc->may_writepage && (sc->gfp_mask & __GFP_IO)) && ++ (PageDirty(page) || (PageAnon(page) && !PageSwapCache(page)))) ++ return false; ++ ++ if (!get_page_unless_zero(page)) ++ return false; ++ ++ if (!TestClearPageLRU(page)) { ++ put_page(page); ++ return false; ++ } ++ ++ success = lru_gen_del_page(page, lruvec, true); ++ VM_BUG_ON_PAGE(!success, page); ++ ++ return true; ++} ++ ++static int scan_pages(struct lruvec *lruvec, struct scan_control *sc, ++ int type, int tier, struct list_head *list) ++{ ++ int gen, zone; ++ enum vm_event_item item; ++ int sorted = 0; ++ int scanned = 0; ++ int isolated = 0; ++ int remaining = MAX_BATCH_SIZE; ++ struct lrugen *lrugen = &lruvec->evictable; ++ struct mem_cgroup *memcg = lruvec_memcg(lruvec); ++ ++ VM_BUG_ON(!list_empty(list)); ++ ++ if (get_nr_gens(lruvec, type) == MIN_NR_GENS) ++ return 0; ++ ++ gen = lru_gen_from_seq(lrugen->min_seq[type]); ++ ++ for (zone = sc->reclaim_idx; zone >= 0; zone--) { ++ LIST_HEAD(moved); ++ int skipped = 0; ++ struct list_head *head = &lrugen->lists[gen][type][zone]; ++ ++ while (!list_empty(head)) { ++ struct page *page = lru_to_page(head); ++ int delta = thp_nr_pages(page); ++ ++ VM_BUG_ON_PAGE(PageTail(page), page); ++ VM_BUG_ON_PAGE(PageUnevictable(page), page); ++ VM_BUG_ON_PAGE(PageActive(page), page); ++ VM_BUG_ON_PAGE(page_is_file_lru(page) != type, page); ++ VM_BUG_ON_PAGE(page_zonenum(page) != zone, page); ++ ++ prefetchw_prev_lru_page(page, head, flags); ++ ++ scanned += delta; ++ ++ if (sort_page(page, lruvec, tier)) ++ sorted += delta; ++ else if (isolate_page(page, lruvec, sc)) { ++ list_add(&page->lru, list); ++ isolated += delta; ++ } else { ++ list_move(&page->lru, &moved); ++ skipped += delta; ++ } ++ ++ if (!--remaining || max(isolated, skipped) >= MIN_BATCH_SIZE) ++ break; ++ } ++ ++ if (skipped) { ++ list_splice(&moved, head); ++ __count_zid_vm_events(PGSCAN_SKIP, zone, skipped); ++ } ++ ++ if (!remaining || isolated >= MIN_BATCH_SIZE) ++ break; ++ } ++ ++ item = current_is_kswapd() ? PGSCAN_KSWAPD : PGSCAN_DIRECT; ++ if (!cgroup_reclaim(sc)) { ++ __count_vm_events(item, isolated); ++ __count_vm_events(PGREFILL, sorted); ++ } ++ __count_memcg_events(memcg, item, isolated); ++ __count_memcg_events(memcg, PGREFILL, sorted); ++ __count_vm_events(PGSCAN_ANON + type, isolated); ++ ++ /* ++ * We may have trouble finding eligible pages due to reclaim_idx, ++ * may_unmap and may_writepage. Check `remaining` to make sure we won't ++ * be stuck if we aren't making enough progress. ++ */ ++ return isolated || !remaining ? scanned : 0; ++} ++ ++static int get_tier_idx(struct lruvec *lruvec, int type) ++{ ++ int tier; ++ struct ctrl_pos sp, pv; ++ ++ /* ++ * Ideally we don't want to evict upper tiers that have higher refaulted ++ * %. However, we need to leave a margin for the fluctuation in ++ * refaulted %. So we use a larger gain factor to make sure upper tiers ++ * are indeed more active. We choose 2 because the lowest upper tier ++ * would have twice of refaulted % of the base tier, according to their ++ * numbers of accesses. ++ */ ++ read_ctrl_pos(lruvec, type, 0, 1, &sp); ++ for (tier = 1; tier < MAX_NR_TIERS; tier++) { ++ read_ctrl_pos(lruvec, type, tier, 2, &pv); ++ if (!positive_ctrl_err(&sp, &pv)) ++ break; ++ } ++ ++ return tier - 1; ++} ++ ++static int get_type_to_scan(struct lruvec *lruvec, int swappiness, int *tier_idx) ++{ ++ int type, tier; ++ struct ctrl_pos sp, pv; ++ int gain[ANON_AND_FILE] = { swappiness, 200 - swappiness }; ++ ++ /* ++ * Compare refaulted % between the base tiers of anon and file to ++ * determine which type to evict. Also need to compare refaulted % of ++ * the upper tiers of the selected type with that of the base tier of ++ * the other type to determine which tier of the selected type to evict. ++ */ ++ read_ctrl_pos(lruvec, 0, 0, gain[0], &sp); ++ read_ctrl_pos(lruvec, 1, 0, gain[1], &pv); ++ type = positive_ctrl_err(&sp, &pv); ++ ++ read_ctrl_pos(lruvec, !type, 0, gain[!type], &sp); ++ for (tier = 1; tier < MAX_NR_TIERS; tier++) { ++ read_ctrl_pos(lruvec, type, tier, gain[type], &pv); ++ if (!positive_ctrl_err(&sp, &pv)) ++ break; ++ } ++ ++ *tier_idx = tier - 1; ++ ++ return type; ++} ++ ++static int isolate_pages(struct lruvec *lruvec, struct scan_control *sc, int swappiness, ++ int *type_scanned, struct list_head *list) ++{ ++ int i; ++ int type; ++ int scanned; ++ int tier = -1; ++ DEFINE_MIN_SEQ(lruvec); ++ ++ VM_BUG_ON(!seq_is_valid(lruvec)); ++ ++ /* ++ * Try to select a type based on generations and swappiness, and if that ++ * fails, fall back to get_type_to_scan(). When anon and file are both ++ * available from the same generation, swappiness 200 is interpreted as ++ * anon first and swappiness 1 is interpreted as file first. ++ */ ++ if (!swappiness) ++ type = 1; ++ else if (min_seq[0] < min_seq[1]) ++ type = 0; ++ else if (swappiness == 1) ++ type = 1; ++ else if (swappiness == 200) ++ type = 0; ++ else ++ type = get_type_to_scan(lruvec, swappiness, &tier); ++ ++ for (i = !swappiness; i < ANON_AND_FILE; i++) { ++ if (tier < 0) ++ tier = get_tier_idx(lruvec, type); ++ ++ scanned = scan_pages(lruvec, sc, type, tier, list); ++ if (scanned) ++ break; ++ ++ type = !type; ++ tier = -1; ++ } ++ ++ *type_scanned = type; ++ ++ return scanned; ++} ++ ++/* Main function used by the foreground, the background and the user-triggered eviction. */ ++static int evict_pages(struct lruvec *lruvec, struct scan_control *sc, int swappiness) ++{ ++ int type; ++ int scanned; ++ int reclaimed; ++ LIST_HEAD(list); ++ struct page *page; ++ enum vm_event_item item; ++ struct reclaim_stat stat; ++ struct mm_walk_args *args; ++ struct mem_cgroup *memcg = lruvec_memcg(lruvec); ++ struct pglist_data *pgdat = lruvec_pgdat(lruvec); ++ ++ spin_lock_irq(&lruvec->lru_lock); ++ ++ scanned = isolate_pages(lruvec, sc, swappiness, &type, &list); ++ ++ if (try_to_inc_min_seq(lruvec, swappiness)) ++ scanned++; ++ ++ if (get_nr_gens(lruvec, 1) == MIN_NR_GENS) ++ scanned = 0; ++ ++ spin_unlock_irq(&lruvec->lru_lock); ++ ++ if (list_empty(&list)) ++ return scanned; ++ ++ reclaimed = shrink_page_list(&list, pgdat, sc, &stat, false); ++ /* ++ * We need to prevent rejected pages from being added back to the same ++ * lists they were isolated from. Otherwise we may risk looping on them ++ * forever. ++ */ ++ list_for_each_entry(page, &list, lru) { ++ if (!PageReclaim(page) || !(PageDirty(page) || PageWriteback(page))) ++ SetPageActive(page); ++ ++ ClearPageReferenced(page); ++ ClearPageWorkingset(page); ++ } ++ ++ spin_lock_irq(&lruvec->lru_lock); ++ ++ move_pages_to_lru(lruvec, &list); ++ ++ args = current->reclaim_state ? current->reclaim_state->mm_walk_args : NULL; ++ if (args && args->batch_size) ++ reset_batch_size(lruvec, args); ++ ++ item = current_is_kswapd() ? PGSTEAL_KSWAPD : PGSTEAL_DIRECT; ++ if (!cgroup_reclaim(sc)) ++ __count_vm_events(item, reclaimed); ++ __count_memcg_events(memcg, item, reclaimed); ++ __count_vm_events(PGSTEAL_ANON + type, reclaimed); ++ ++ spin_unlock_irq(&lruvec->lru_lock); ++ ++ mem_cgroup_uncharge_list(&list); ++ free_unref_page_list(&list); ++ ++ sc->nr_reclaimed += reclaimed; ++ ++ return scanned; ++} ++ ++static long get_nr_to_scan(struct lruvec *lruvec, struct scan_control *sc, int swappiness) ++{ ++ bool low; ++ long nr_to_scan; ++ struct mem_cgroup *memcg = lruvec_memcg(lruvec); ++ int priority = sc->priority; ++ DEFINE_MAX_SEQ(lruvec); ++ DEFINE_MIN_SEQ(lruvec); ++ ++ if (mem_cgroup_below_min(memcg) || ++ (mem_cgroup_below_low(memcg) && !sc->memcg_low_reclaim)) ++ return 0; ++ ++ if (sc->nr_reclaimed >= sc->nr_to_reclaim) { ++ priority = DEF_PRIORITY; ++ sc->force_deactivate = 0; ++ } ++ ++ nr_to_scan = get_nr_evictable(lruvec, sc, swappiness, max_seq, min_seq, &low); ++ if (!nr_to_scan) ++ return 0; ++ ++ nr_to_scan >>= priority; ++ ++ if (!mem_cgroup_online(memcg)) ++ nr_to_scan++; ++ ++ if (!nr_to_scan) ++ return 0; ++ ++ if (current_is_kswapd()) { ++ /* leave the work to lru_gen_age_node() */ ++ if (max_seq - min_seq[1] < MIN_NR_GENS) ++ return 0; ++ ++ if (!low) ++ sc->force_deactivate = 0; ++ ++ return nr_to_scan; ++ } ++ ++ if (max_seq - min_seq[1] >= MIN_NR_GENS) ++ return nr_to_scan; ++ ++ /* move onto slab and other memcgs if we haven't tried them all */ ++ if (!sc->force_deactivate) { ++ sc->skipped_deactivate = 1; ++ return 0; ++ } ++ ++ return try_to_inc_max_seq(lruvec, sc, swappiness, max_seq, true) ? nr_to_scan : 0; ++} ++ ++static void lru_gen_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) ++{ ++ struct blk_plug plug; ++ long scanned = 0; ++ struct mem_cgroup *memcg = lruvec_memcg(lruvec); ++ struct pglist_data *pgdat = lruvec_pgdat(lruvec); ++ ++ lru_add_drain(); ++ ++ if (current_is_kswapd()) ++ current->reclaim_state->mm_walk_args = &pgdat->mm_walk_args; ++ ++ blk_start_plug(&plug); ++ ++ while (true) { ++ int delta; ++ int swappiness; ++ long nr_to_scan; ++ ++ if (sc->may_swap) ++ swappiness = get_swappiness(memcg); ++ else if (!cgroup_reclaim(sc) && get_swappiness(memcg)) ++ swappiness = 1; ++ else ++ swappiness = 0; ++ ++ nr_to_scan = get_nr_to_scan(lruvec, sc, swappiness); ++ if (!nr_to_scan) ++ break; ++ ++ delta = evict_pages(lruvec, sc, swappiness); ++ if (!delta) ++ break; ++ ++ scanned += delta; ++ if (scanned >= nr_to_scan) ++ break; ++ ++ cond_resched(); ++ } ++ ++ blk_finish_plug(&plug); ++ ++ if (current_is_kswapd()) ++ current->reclaim_state->mm_walk_args = NULL; ++} ++ ++/****************************************************************************** + * state change + ******************************************************************************/ + +@@ -4420,6 +4961,10 @@ static void lru_gen_age_node(struct pgli + { + } + ++static void lru_gen_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) ++{ ++} ++ + #endif /* CONFIG_LRU_GEN */ + + static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) +@@ -4433,6 +4978,11 @@ static void shrink_lruvec(struct lruvec + struct blk_plug plug; + bool scan_adjusted; + ++ if (lru_gen_enabled()) { ++ lru_gen_shrink_lruvec(lruvec, sc); ++ return; ++ } ++ + get_scan_count(lruvec, sc, nr); + + /* Record the original scan target for proportional adjustments later */ +@@ -4906,6 +5456,9 @@ static void snapshot_refaults(struct mem + struct lruvec *target_lruvec; + unsigned long refaults; + ++ if (lru_gen_enabled()) ++ return; ++ + target_lruvec = mem_cgroup_lruvec(target_memcg, pgdat); + refaults = lruvec_page_state(target_lruvec, WORKINGSET_ACTIVATE_ANON); + target_lruvec->refaults[0] = refaults; +--- a/mm/workingset.c ++++ b/mm/workingset.c +@@ -187,7 +187,6 @@ static unsigned int bucket_order __read_ + static void *pack_shadow(int memcgid, pg_data_t *pgdat, unsigned long eviction, + bool workingset) + { +- eviction >>= bucket_order; + eviction &= EVICTION_MASK; + eviction = (eviction << MEM_CGROUP_ID_SHIFT) | memcgid; + eviction = (eviction << NODES_SHIFT) | pgdat->node_id; +@@ -212,10 +211,117 @@ static void unpack_shadow(void *shadow, + + *memcgidp = memcgid; + *pgdat = NODE_DATA(nid); +- *evictionp = entry << bucket_order; ++ *evictionp = entry; + *workingsetp = workingset; + } + ++#ifdef CONFIG_LRU_GEN ++ ++static int page_lru_refs(struct page *page) ++{ ++ unsigned long flags = READ_ONCE(page->flags); ++ ++ BUILD_BUG_ON(LRU_GEN_WIDTH + LRU_REFS_WIDTH > BITS_PER_LONG - EVICTION_SHIFT); ++ ++ /* see the comment on MAX_NR_TIERS */ ++ return flags & BIT(PG_workingset) ? (flags & LRU_REFS_MASK) >> LRU_REFS_PGOFF : 0; ++} ++ ++/* Return a token to be stored in the shadow entry of a page being evicted. */ ++static void *lru_gen_eviction(struct page *page) ++{ ++ int hist, tier; ++ unsigned long token; ++ unsigned long min_seq; ++ struct lruvec *lruvec; ++ struct lrugen *lrugen; ++ int type = page_is_file_lru(page); ++ int refs = page_lru_refs(page); ++ int delta = thp_nr_pages(page); ++ bool workingset = PageWorkingset(page); ++ struct mem_cgroup *memcg = page_memcg(page); ++ struct pglist_data *pgdat = page_pgdat(page); ++ ++ lruvec = mem_cgroup_lruvec(memcg, pgdat); ++ lrugen = &lruvec->evictable; ++ min_seq = READ_ONCE(lrugen->min_seq[type]); ++ token = (min_seq << LRU_REFS_WIDTH) | refs; ++ ++ hist = lru_hist_from_seq(min_seq); ++ tier = lru_tier_from_refs(refs + workingset); ++ atomic_long_add(delta, &lrugen->evicted[hist][type][tier]); ++ ++ return pack_shadow(mem_cgroup_id(memcg), pgdat, token, workingset); ++} ++ ++/* Count a refaulted page based on the token stored in its shadow entry. */ ++static void lru_gen_refault(struct page *page, void *shadow) ++{ ++ int hist, tier, refs; ++ int memcg_id; ++ bool workingset; ++ unsigned long token; ++ unsigned long min_seq; ++ struct lruvec *lruvec; ++ struct lrugen *lrugen; ++ struct mem_cgroup *memcg; ++ struct pglist_data *pgdat; ++ int type = page_is_file_lru(page); ++ int delta = thp_nr_pages(page); ++ ++ unpack_shadow(shadow, &memcg_id, &pgdat, &token, &workingset); ++ if (page_pgdat(page) != pgdat) ++ return; ++ ++ rcu_read_lock(); ++ memcg = page_memcg_rcu(page); ++ if (mem_cgroup_id(memcg) != memcg_id) ++ goto unlock; ++ ++ refs = token & (BIT(LRU_REFS_WIDTH) - 1); ++ if (refs && !workingset) ++ goto unlock; ++ ++ token >>= LRU_REFS_WIDTH; ++ lruvec = mem_cgroup_lruvec(memcg, pgdat); ++ lrugen = &lruvec->evictable; ++ min_seq = READ_ONCE(lrugen->min_seq[type]); ++ if (token != (min_seq & (EVICTION_MASK >> LRU_REFS_WIDTH))) ++ goto unlock; ++ ++ hist = lru_hist_from_seq(min_seq); ++ tier = lru_tier_from_refs(refs + workingset); ++ atomic_long_add(delta, &lrugen->refaulted[hist][type][tier]); ++ mod_lruvec_state(lruvec, WORKINGSET_REFAULT_BASE + type, delta); ++ ++ /* ++ * Tiers don't offer any protection to pages accessed via page tables. ++ * That's what generations do. Tiers can't fully protect pages after ++ * their numbers of accesses has exceeded the max value. Conservatively ++ * count these two conditions as stalls even though they might not ++ * indicate any real memory pressure. ++ */ ++ if (task_in_nonseq_fault() || refs + workingset == BIT(LRU_REFS_WIDTH)) { ++ SetPageWorkingset(page); ++ mod_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + type, delta); ++ } ++unlock: ++ rcu_read_unlock(); ++} ++ ++#else ++ ++static void *lru_gen_eviction(struct page *page) ++{ ++ return NULL; ++} ++ ++static void lru_gen_refault(struct page *page, void *shadow) ++{ ++} ++ ++#endif /* CONFIG_LRU_GEN */ ++ + /** + * workingset_age_nonresident - age non-resident entries as LRU ages + * @lruvec: the lruvec that was aged +@@ -264,10 +370,14 @@ void *workingset_eviction(struct page *p + VM_BUG_ON_PAGE(page_count(page), page); + VM_BUG_ON_PAGE(!PageLocked(page), page); + ++ if (lru_gen_enabled()) ++ return lru_gen_eviction(page); ++ + lruvec = mem_cgroup_lruvec(target_memcg, pgdat); + /* XXX: target_memcg can be NULL, go through lruvec */ + memcgid = mem_cgroup_id(lruvec_memcg(lruvec)); + eviction = atomic_long_read(&lruvec->nonresident_age); ++ eviction >>= bucket_order; + workingset_age_nonresident(lruvec, thp_nr_pages(page)); + return pack_shadow(memcgid, pgdat, eviction, PageWorkingset(page)); + } +@@ -296,7 +406,13 @@ void workingset_refault(struct page *pag + bool workingset; + int memcgid; + ++ if (lru_gen_enabled()) { ++ lru_gen_refault(page, shadow); ++ return; ++ } ++ + unpack_shadow(shadow, &memcgid, &pgdat, &eviction, &workingset); ++ eviction <<= bucket_order; + + rcu_read_lock(); + /* diff --git a/target/linux/generic/pending-5.15/020-07-mm-multigenerational-lru-user-interface.patch b/target/linux/generic/pending-5.15/020-07-mm-multigenerational-lru-user-interface.patch new file mode 100644 index 0000000000..a1a749fc38 --- /dev/null +++ b/target/linux/generic/pending-5.15/020-07-mm-multigenerational-lru-user-interface.patch @@ -0,0 +1,496 @@ +From 5cc7fdec54e87e32b4fb0f07d84b21769d5f8d92 Mon Sep 17 00:00:00 2001 +From: Yu Zhao +Date: Mon, 25 Jan 2021 21:38:02 -0700 +Subject: [PATCH 08/10] mm: multigenerational lru: user interface + +Add /sys/kernel/mm/lru_gen/enabled to enable and disable the +multigenerational lru at runtime. + +Add /sys/kernel/mm/lru_gen/min_ttl_ms to protect the working set of a +given number of milliseconds. The OOM killer is invoked if this +working set cannot be kept in memory. + +Add /sys/kernel/debug/lru_gen to monitor the multigenerational lru and +invoke the aging and the eviction. This file has the following output: + memcg memcg_id memcg_path + node node_id + min_gen birth_time anon_size file_size + ... + max_gen birth_time anon_size file_size + +min_gen is the oldest generation number and max_gen is the youngest +generation number. birth_time is in milliseconds. anon_size and +file_size are in pages. + +This file takes the following input: + + memcg_id node_id max_gen [swappiness] [use_bloom_filter] + - memcg_id node_id min_gen [swappiness] [nr_to_reclaim] + +The first command line invokes the aging, which scans PTEs for +accessed pages and then creates the next generation max_gen+1. A swap +file and a non-zero swappiness, which overrides vm.swappiness, are +required to scan PTEs mapping anon pages. The second command line +invokes the eviction, which evicts generations less than or equal to +min_gen. min_gen should be less than max_gen-1 as max_gen and +max_gen-1 are not fully aged and therefore cannot be evicted. +Setting nr_to_reclaim to N limits the number of pages to evict. +Setting use_bloom_filter to 0 overrides the default behavior which +only scans PTE tables found populated. Multiple command lines are +supported, as is concatenation with delimiters "," and ";". + +Signed-off-by: Yu Zhao +Tested-by: Konstantin Kharlamov +Change-Id: I4448e60029badbe347aa3b624f429b280cc3a3d3 +--- + include/linux/nodemask.h | 1 + + mm/vmscan.c | 415 +++++++++++++++++++++++++++++++++++++++ + 2 files changed, 416 insertions(+) + +--- a/include/linux/nodemask.h ++++ b/include/linux/nodemask.h +@@ -485,6 +485,7 @@ static inline int num_node_state(enum no + #define first_online_node 0 + #define first_memory_node 0 + #define next_online_node(nid) (MAX_NUMNODES) ++#define next_memory_node(nid) (MAX_NUMNODES) + #define nr_node_ids 1U + #define nr_online_nodes 1U + +--- a/mm/vmscan.c ++++ b/mm/vmscan.c +@@ -53,6 +53,8 @@ + #include + #include + #include ++#include ++#include + + #include + #include +@@ -4882,6 +4884,413 @@ unlock: + } + + /****************************************************************************** ++ * sysfs interface ++ ******************************************************************************/ ++ ++static ssize_t show_min_ttl(struct kobject *kobj, struct kobj_attribute *attr, char *buf) ++{ ++ return sprintf(buf, "%u\n", jiffies_to_msecs(READ_ONCE(lru_gen_min_ttl))); ++} ++ ++static ssize_t store_min_ttl(struct kobject *kobj, struct kobj_attribute *attr, ++ const char *buf, size_t len) ++{ ++ unsigned int msecs; ++ ++ if (kstrtouint(buf, 10, &msecs)) ++ return -EINVAL; ++ ++ WRITE_ONCE(lru_gen_min_ttl, msecs_to_jiffies(msecs)); ++ ++ return len; ++} ++ ++static struct kobj_attribute lru_gen_min_ttl_attr = __ATTR( ++ min_ttl_ms, 0644, show_min_ttl, store_min_ttl ++); ++ ++static ssize_t show_enable(struct kobject *kobj, struct kobj_attribute *attr, char *buf) ++{ ++ return snprintf(buf, PAGE_SIZE, "%d\n", lru_gen_enabled()); ++} ++ ++static ssize_t store_enable(struct kobject *kobj, struct kobj_attribute *attr, ++ const char *buf, size_t len) ++{ ++ bool enable; ++ ++ if (kstrtobool(buf, &enable)) ++ return -EINVAL; ++ ++ lru_gen_change_state(enable, true, false); ++ ++ return len; ++} ++ ++static struct kobj_attribute lru_gen_enabled_attr = __ATTR( ++ enabled, 0644, show_enable, store_enable ++); ++ ++static struct attribute *lru_gen_attrs[] = { ++ &lru_gen_min_ttl_attr.attr, ++ &lru_gen_enabled_attr.attr, ++ NULL ++}; ++ ++static struct attribute_group lru_gen_attr_group = { ++ .name = "lru_gen", ++ .attrs = lru_gen_attrs, ++}; ++ ++/****************************************************************************** ++ * debugfs interface ++ ******************************************************************************/ ++ ++static void *lru_gen_seq_start(struct seq_file *m, loff_t *pos) ++{ ++ struct mem_cgroup *memcg; ++ loff_t nr_to_skip = *pos; ++ ++ m->private = kvmalloc(PATH_MAX, GFP_KERNEL); ++ if (!m->private) ++ return ERR_PTR(-ENOMEM); ++ ++ memcg = mem_cgroup_iter(NULL, NULL, NULL); ++ do { ++ int nid; ++ ++ for_each_node_state(nid, N_MEMORY) { ++ if (!nr_to_skip--) ++ return get_lruvec(nid, memcg); ++ } ++ } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL))); ++ ++ return NULL; ++} ++ ++static void lru_gen_seq_stop(struct seq_file *m, void *v) ++{ ++ if (!IS_ERR_OR_NULL(v)) ++ mem_cgroup_iter_break(NULL, lruvec_memcg(v)); ++ ++ kvfree(m->private); ++ m->private = NULL; ++} ++ ++static void *lru_gen_seq_next(struct seq_file *m, void *v, loff_t *pos) ++{ ++ int nid = lruvec_pgdat(v)->node_id; ++ struct mem_cgroup *memcg = lruvec_memcg(v); ++ ++ ++*pos; ++ ++ nid = next_memory_node(nid); ++ if (nid == MAX_NUMNODES) { ++ memcg = mem_cgroup_iter(NULL, memcg, NULL); ++ if (!memcg) ++ return NULL; ++ ++ nid = first_memory_node; ++ } ++ ++ return get_lruvec(nid, memcg); ++} ++ ++static void lru_gen_seq_show_full(struct seq_file *m, struct lruvec *lruvec, ++ unsigned long max_seq, unsigned long *min_seq, ++ unsigned long seq) ++{ ++ int i; ++ int type, tier; ++ int hist = lru_hist_from_seq(seq); ++ struct lrugen *lrugen = &lruvec->evictable; ++ ++ for (tier = 0; tier < MAX_NR_TIERS; tier++) { ++ seq_printf(m, " %10d", tier); ++ for (type = 0; type < ANON_AND_FILE; type++) { ++ unsigned long n[3] = {}; ++ ++ if (seq == max_seq) { ++ n[0] = READ_ONCE(lrugen->avg_refaulted[type][tier]); ++ n[1] = READ_ONCE(lrugen->avg_total[type][tier]); ++ ++ seq_printf(m, " %10luR %10luT %10lu ", n[0], n[1], n[2]); ++ } else if (seq == min_seq[type] || NR_HIST_GENS > 1) { ++ n[0] = atomic_long_read(&lrugen->refaulted[hist][type][tier]); ++ n[1] = atomic_long_read(&lrugen->evicted[hist][type][tier]); ++ if (tier) ++ n[2] = READ_ONCE(lrugen->protected[hist][type][tier - 1]); ++ ++ seq_printf(m, " %10lur %10lue %10lup", n[0], n[1], n[2]); ++ } else ++ seq_puts(m, " 0 0 0 "); ++ } ++ seq_putc(m, '\n'); ++ } ++ ++ seq_puts(m, " "); ++ for (i = 0; i < NR_MM_STATS; i++) { ++ if (seq == max_seq && NR_HIST_GENS == 1) ++ seq_printf(m, " %10lu%c", READ_ONCE(lruvec->mm_walk.stats[hist][i]), ++ toupper(MM_STAT_CODES[i])); ++ else if (seq != max_seq && NR_HIST_GENS > 1) ++ seq_printf(m, " %10lu%c", READ_ONCE(lruvec->mm_walk.stats[hist][i]), ++ MM_STAT_CODES[i]); ++ else ++ seq_puts(m, " 0 "); ++ } ++ seq_putc(m, '\n'); ++} ++ ++static int lru_gen_seq_show(struct seq_file *m, void *v) ++{ ++ unsigned long seq; ++ bool full = !debugfs_real_fops(m->file)->write; ++ struct lruvec *lruvec = v; ++ struct lrugen *lrugen = &lruvec->evictable; ++ int nid = lruvec_pgdat(lruvec)->node_id; ++ struct mem_cgroup *memcg = lruvec_memcg(lruvec); ++ DEFINE_MAX_SEQ(lruvec); ++ DEFINE_MIN_SEQ(lruvec); ++ ++ if (nid == first_memory_node) { ++ const char *path = memcg ? m->private : ""; ++ ++#ifdef CONFIG_MEMCG ++ if (memcg) ++ cgroup_path(memcg->css.cgroup, m->private, PATH_MAX); ++#endif ++ seq_printf(m, "memcg %5hu %s\n", mem_cgroup_id(memcg), path); ++ } ++ ++ seq_printf(m, " node %5d\n", nid); ++ ++ if (!full) ++ seq = min_seq[0]; ++ else if (max_seq >= MAX_NR_GENS) ++ seq = max_seq - MAX_NR_GENS + 1; ++ else ++ seq = 0; ++ ++ for (; seq <= max_seq; seq++) { ++ int gen, type, zone; ++ unsigned int msecs; ++ ++ gen = lru_gen_from_seq(seq); ++ msecs = jiffies_to_msecs(jiffies - READ_ONCE(lrugen->timestamps[gen])); ++ ++ seq_printf(m, " %10lu %10u", seq, msecs); ++ ++ for (type = 0; type < ANON_AND_FILE; type++) { ++ long size = 0; ++ ++ if (seq < min_seq[type]) { ++ seq_puts(m, " -0 "); ++ continue; ++ } ++ ++ for (zone = 0; zone < MAX_NR_ZONES; zone++) ++ size += READ_ONCE(lrugen->sizes[gen][type][zone]); ++ ++ seq_printf(m, " %10lu ", max(size, 0L)); ++ } ++ ++ seq_putc(m, '\n'); ++ ++ if (full) ++ lru_gen_seq_show_full(m, lruvec, max_seq, min_seq, seq); ++ } ++ ++ return 0; ++} ++ ++static const struct seq_operations lru_gen_seq_ops = { ++ .start = lru_gen_seq_start, ++ .stop = lru_gen_seq_stop, ++ .next = lru_gen_seq_next, ++ .show = lru_gen_seq_show, ++}; ++ ++static int run_aging(struct lruvec *lruvec, struct scan_control *sc, int swappiness, ++ unsigned long seq, bool use_filter) ++{ ++ DEFINE_MAX_SEQ(lruvec); ++ ++ if (seq == max_seq) ++ try_to_inc_max_seq(lruvec, sc, swappiness, max_seq, use_filter); ++ ++ return seq > max_seq ? -EINVAL : 0; ++} ++ ++static int run_eviction(struct lruvec *lruvec, struct scan_control *sc, int swappiness, ++ unsigned long seq, unsigned long nr_to_reclaim) ++{ ++ struct blk_plug plug; ++ int err = -EINTR; ++ DEFINE_MAX_SEQ(lruvec); ++ ++ if (seq >= max_seq - 1) ++ return -EINVAL; ++ ++ sc->nr_reclaimed = 0; ++ ++ blk_start_plug(&plug); ++ ++ while (!signal_pending(current)) { ++ DEFINE_MIN_SEQ(lruvec); ++ ++ if (seq < min_seq[!swappiness] || sc->nr_reclaimed >= nr_to_reclaim || ++ !evict_pages(lruvec, sc, swappiness)) { ++ err = 0; ++ break; ++ } ++ ++ cond_resched(); ++ } ++ ++ blk_finish_plug(&plug); ++ ++ return err; ++} ++ ++static int run_cmd(char cmd, int memcg_id, int nid, struct scan_control *sc, ++ int swappiness, unsigned long seq, unsigned long opt) ++{ ++ struct lruvec *lruvec; ++ int err = -EINVAL; ++ struct mem_cgroup *memcg = NULL; ++ ++ if (!mem_cgroup_disabled()) { ++ rcu_read_lock(); ++ memcg = mem_cgroup_from_id(memcg_id); ++#ifdef CONFIG_MEMCG ++ if (memcg && !css_tryget(&memcg->css)) ++ memcg = NULL; ++#endif ++ rcu_read_unlock(); ++ ++ if (!memcg) ++ goto done; ++ } ++ if (memcg_id != mem_cgroup_id(memcg)) ++ goto done; ++ ++ if (nid < 0 || nid >= MAX_NUMNODES || !node_state(nid, N_MEMORY)) ++ goto done; ++ ++ lruvec = get_lruvec(nid, memcg); ++ ++ if (swappiness < 0) ++ swappiness = get_swappiness(memcg); ++ else if (swappiness > 200) ++ goto done; ++ ++ switch (cmd) { ++ case '+': ++ err = run_aging(lruvec, sc, swappiness, seq, opt); ++ break; ++ case '-': ++ err = run_eviction(lruvec, sc, swappiness, seq, opt); ++ break; ++ } ++done: ++ mem_cgroup_put(memcg); ++ ++ return err; ++} ++ ++static ssize_t lru_gen_seq_write(struct file *file, const char __user *src, ++ size_t len, loff_t *pos) ++{ ++ void *buf; ++ char *cur, *next; ++ unsigned int flags; ++ int err = 0; ++ struct scan_control sc = { ++ .may_writepage = 1, ++ .may_unmap = 1, ++ .may_swap = 1, ++ .reclaim_idx = MAX_NR_ZONES - 1, ++ .gfp_mask = GFP_KERNEL, ++ }; ++ ++ buf = kvmalloc(len + 1, GFP_KERNEL); ++ if (!buf) ++ return -ENOMEM; ++ ++ if (copy_from_user(buf, src, len)) { ++ kvfree(buf); ++ return -EFAULT; ++ } ++ ++ next = buf; ++ next[len] = '\0'; ++ ++ sc.reclaim_state.mm_walk_args = alloc_mm_walk_args(); ++ if (!sc.reclaim_state.mm_walk_args) { ++ kvfree(buf); ++ return -ENOMEM; ++ } ++ ++ flags = memalloc_noreclaim_save(); ++ set_task_reclaim_state(current, &sc.reclaim_state); ++ ++ while ((cur = strsep(&next, ",;\n"))) { ++ int n; ++ int end; ++ char cmd; ++ unsigned int memcg_id; ++ unsigned int nid; ++ unsigned long seq; ++ unsigned int swappiness = -1; ++ unsigned long opt = -1; ++ ++ cur = skip_spaces(cur); ++ if (!*cur) ++ continue; ++ ++ n = sscanf(cur, "%c %u %u %lu %n %u %n %lu %n", &cmd, &memcg_id, &nid, ++ &seq, &end, &swappiness, &end, &opt, &end); ++ if (n < 4 || cur[end]) { ++ err = -EINVAL; ++ break; ++ } ++ ++ err = run_cmd(cmd, memcg_id, nid, &sc, swappiness, seq, opt); ++ if (err) ++ break; ++ } ++ ++ set_task_reclaim_state(current, NULL); ++ memalloc_noreclaim_restore(flags); ++ ++ free_mm_walk_args(sc.reclaim_state.mm_walk_args); ++ kvfree(buf); ++ ++ return err ? : len; ++} ++ ++static int lru_gen_seq_open(struct inode *inode, struct file *file) ++{ ++ return seq_open(file, &lru_gen_seq_ops); ++} ++ ++static const struct file_operations lru_gen_rw_fops = { ++ .open = lru_gen_seq_open, ++ .read = seq_read, ++ .write = lru_gen_seq_write, ++ .llseek = seq_lseek, ++ .release = seq_release, ++}; ++ ++static const struct file_operations lru_gen_ro_fops = { ++ .open = lru_gen_seq_open, ++ .read = seq_read, ++ .llseek = seq_lseek, ++ .release = seq_release, ++}; ++ ++/****************************************************************************** + * initialization + ******************************************************************************/ + +@@ -4951,6 +5360,12 @@ static int __init init_lru_gen(void) + BUILD_BUG_ON(BIT(LRU_GEN_WIDTH) <= MAX_NR_GENS); + BUILD_BUG_ON(sizeof(MM_STAT_CODES) != NR_MM_STATS + 1); + ++ if (sysfs_create_group(mm_kobj, &lru_gen_attr_group)) ++ pr_err("lru_gen: failed to create sysfs group\n"); ++ ++ debugfs_create_file("lru_gen", 0644, NULL, NULL, &lru_gen_rw_fops); ++ debugfs_create_file("lru_gen_full", 0444, NULL, NULL, &lru_gen_ro_fops); ++ + return 0; + }; + late_initcall(init_lru_gen); diff --git a/target/linux/generic/pending-5.15/020-08-mm-multigenerational-lru-Kconfig.patch b/target/linux/generic/pending-5.15/020-08-mm-multigenerational-lru-Kconfig.patch new file mode 100644 index 0000000000..4462549f99 --- /dev/null +++ b/target/linux/generic/pending-5.15/020-08-mm-multigenerational-lru-Kconfig.patch @@ -0,0 +1,80 @@ +From 3008095eb835d207dd7e5b60899aad17f32aa9f7 Mon Sep 17 00:00:00 2001 +From: Yu Zhao +Date: Mon, 25 Jan 2021 21:47:24 -0700 +Subject: [PATCH 09/10] mm: multigenerational lru: Kconfig + +Add configuration options for the multigenerational lru. + +Signed-off-by: Yu Zhao +Tested-by: Konstantin Kharlamov +Change-Id: Ic74ea07f8fb5f56e6904a1b80c3c286bc2911635 +--- + mm/Kconfig | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 59 insertions(+) + +--- a/mm/Kconfig ++++ b/mm/Kconfig +@@ -899,4 +899,63 @@ config SECRETMEM + + source "mm/damon/Kconfig" + ++# the multigenerational lru { ++config LRU_GEN ++ bool "Multigenerational LRU" ++ depends on MMU ++ # the following options may leave not enough spare bits in page->flags ++ depends on !MAXSMP && (64BIT || !SPARSEMEM || SPARSEMEM_VMEMMAP) ++ help ++ A high performance LRU implementation to heavily overcommit workloads ++ that are not IO bound. See Documentation/vm/multigen_lru.rst for ++ details. ++ ++ Warning: do not enable this option unless you plan to use it because ++ it introduces a small per-process and per-memcg and per-node memory ++ overhead. ++ ++config LRU_GEN_ENABLED ++ bool "Turn on by default" ++ depends on LRU_GEN ++ help ++ The default value of /sys/kernel/mm/lru_gen/enabled is 0. This option ++ changes it to 1. ++ ++ Warning: the default value is the fast path. See ++ Documentation/static-keys.txt for details. ++ ++config LRU_GEN_STATS ++ bool "Full stats for debugging" ++ depends on LRU_GEN ++ help ++ This option keeps full stats for each generation, which can be read ++ from /sys/kernel/debug/lru_gen_full. ++ ++ Warning: do not enable this option unless you plan to use it because ++ it introduces an additional small per-process and per-memcg and ++ per-node memory overhead. ++ ++config NR_LRU_GENS ++ int "Max number of generations" ++ depends on LRU_GEN ++ range 4 31 ++ default 7 ++ help ++ This will use order_base_2(N+1) spare bits from page flags. ++ ++ Warning: do not use numbers larger than necessary because each ++ generation introduces a small per-node and per-memcg memory overhead. ++ ++config TIERS_PER_GEN ++ int "Number of tiers per generation" ++ depends on LRU_GEN ++ range 2 5 ++ default 4 ++ help ++ This will use N-2 spare bits from page flags. ++ ++ Larger values generally offer better protection to active pages under ++ heavy buffered I/O workloads. ++# } ++ + endmenu diff --git a/target/linux/generic/pending-5.15/020-09-mm-multigenerational-lru-documentation.patch b/target/linux/generic/pending-5.15/020-09-mm-multigenerational-lru-documentation.patch new file mode 100644 index 0000000000..f4716fb68d --- /dev/null +++ b/target/linux/generic/pending-5.15/020-09-mm-multigenerational-lru-documentation.patch @@ -0,0 +1,161 @@ +From f59c618ed70a1e48accc4cad91a200966f2569c9 Mon Sep 17 00:00:00 2001 +From: Yu Zhao +Date: Tue, 2 Feb 2021 01:27:45 -0700 +Subject: [PATCH 10/10] mm: multigenerational lru: documentation + +Add Documentation/vm/multigen_lru.rst. + +Signed-off-by: Yu Zhao +Tested-by: Konstantin Kharlamov +Change-Id: I1902178bcbb5adfa0a748c4d284a6456059bdd7e +--- + Documentation/vm/index.rst | 1 + + Documentation/vm/multigen_lru.rst | 132 ++++++++++++++++++++++++++++++ + 2 files changed, 133 insertions(+) + create mode 100644 Documentation/vm/multigen_lru.rst + +--- a/Documentation/vm/index.rst ++++ b/Documentation/vm/index.rst +@@ -17,6 +17,7 @@ various features of the Linux memory man + + swap_numa + zswap ++ multigen_lru + + Kernel developers MM documentation + ================================== +--- /dev/null ++++ b/Documentation/vm/multigen_lru.rst +@@ -0,0 +1,132 @@ ++.. SPDX-License-Identifier: GPL-2.0 ++ ++===================== ++Multigenerational LRU ++===================== ++ ++Quick Start ++=========== ++Build Configurations ++-------------------- ++:Required: Set ``CONFIG_LRU_GEN=y``. ++ ++:Optional: Set ``CONFIG_LRU_GEN_ENABLED=y`` to turn the feature on by ++ default. ++ ++Runtime Configurations ++---------------------- ++:Required: Write ``1`` to ``/sys/kernel/mm/lru_gen/enable`` if the ++ feature was not turned on by default. ++ ++:Optional: Write ``N`` to ``/sys/kernel/mm/lru_gen/min_ttl_ms`` to ++ protect the working set of ``N`` milliseconds. The OOM killer is ++ invoked if this working set cannot be kept in memory. ++ ++:Optional: Read ``/sys/kernel/debug/lru_gen`` to confirm the feature ++ is turned on. This file has the following output: ++ ++:: ++ ++ memcg memcg_id memcg_path ++ node node_id ++ min_gen birth_time anon_size file_size ++ ... ++ max_gen birth_time anon_size file_size ++ ++``min_gen`` is the oldest generation number and ``max_gen`` is the ++youngest generation number. ``birth_time`` is in milliseconds. ++``anon_size`` and ``file_size`` are in pages. ++ ++Phones/Laptops/Workstations ++--------------------------- ++No additional configurations required. ++ ++Servers/Data Centers ++-------------------- ++:To support more generations: Change ``CONFIG_NR_LRU_GENS`` to a ++ larger number. ++ ++:To support more tiers: Change ``CONFIG_TIERS_PER_GEN`` to a larger ++ number. ++ ++:To support full stats: Set ``CONFIG_LRU_GEN_STATS=y``. ++ ++:Working set estimation: Write ``+ memcg_id node_id max_gen ++ [swappiness] [use_bloom_filter]`` to ``/sys/kernel/debug/lru_gen`` to ++ invoke the aging, which scans PTEs for accessed pages and then ++ creates the next generation ``max_gen+1``. A swap file and a non-zero ++ ``swappiness``, which overrides ``vm.swappiness``, are required to ++ scan PTEs mapping anon pages. Set ``use_bloom_filter`` to 0 to ++ override the default behavior which only scans PTE tables found ++ populated. ++ ++:Proactive reclaim: Write ``- memcg_id node_id min_gen [swappiness] ++ [nr_to_reclaim]`` to ``/sys/kernel/debug/lru_gen`` to invoke the ++ eviction, which evicts generations less than or equal to ``min_gen``. ++ ``min_gen`` should be less than ``max_gen-1`` as ``max_gen`` and ++ ``max_gen-1`` are not fully aged and therefore cannot be evicted. ++ Use ``nr_to_reclaim`` to limit the number of pages to evict. Multiple ++ command lines are supported, so does concatenation with delimiters ++ ``,`` and ``;``. ++ ++Framework ++========= ++For each ``lruvec``, evictable pages are divided into multiple ++generations. The youngest generation number is stored in ++``lrugen->max_seq`` for both anon and file types as they are aged on ++an equal footing. The oldest generation numbers are stored in ++``lrugen->min_seq[]`` separately for anon and file types as clean ++file pages can be evicted regardless of swap and writeback ++constraints. These three variables are monotonically increasing. ++Generation numbers are truncated into ++``order_base_2(CONFIG_NR_LRU_GENS+1)`` bits in order to fit into ++``page->flags``. The sliding window technique is used to prevent ++truncated generation numbers from overlapping. Each truncated ++generation number is an index to an array of per-type and per-zone ++lists ``lrugen->lists``. ++ ++Each generation is divided into multiple tiers. Tiers represent ++different ranges of numbers of accesses from file descriptors only. ++Pages accessed ``N`` times via file descriptors belong to tier ++``order_base_2(N)``. Each generation contains at most ++``CONFIG_TIERS_PER_GEN`` tiers, and they require additional ++``CONFIG_TIERS_PER_GEN-2`` bits in ``page->flags``. In contrast to ++moving between generations which requires list operations, moving ++between tiers only involves operations on ``page->flags`` and ++therefore has a negligible cost. A feedback loop modeled after the PID ++controller monitors refaulted % across all tiers and decides when to ++protect pages from which tiers. ++ ++The framework comprises two conceptually independent components: the ++aging and the eviction, which can be invoked separately from user ++space for the purpose of working set estimation and proactive reclaim. ++ ++Aging ++----- ++The aging produces young generations. Given an ``lruvec``, the aging ++traverses ``lruvec_memcg()->mm_list`` and calls ``walk_page_range()`` ++to scan PTEs for accessed pages (a ``mm_struct`` list is maintained ++for each ``memcg``). Upon finding one, the aging updates its ++generation number to ``max_seq`` (modulo ``CONFIG_NR_LRU_GENS``). ++After each round of traversal, the aging increments ``max_seq``. The ++aging is due when ``min_seq[]`` reaches ``max_seq-1``. ++ ++Eviction ++-------- ++The eviction consumes old generations. Given an ``lruvec``, the ++eviction scans pages on the per-zone lists indexed by anon and file ++``min_seq[]`` (modulo ``CONFIG_NR_LRU_GENS``). It first tries to ++select a type based on the values of ``min_seq[]``. If they are ++equal, it selects the type that has a lower refaulted %. The eviction ++sorts a page according to its updated generation number if the aging ++has found this page accessed. It also moves a page to the next ++generation if this page is from an upper tier that has a higher ++refaulted % than the base tier. The eviction increments ``min_seq[]`` ++of a selected type when it finds all the per-zone lists indexed by ++``min_seq[]`` of this selected type are empty. ++ ++To-do List ++========== ++KVM Optimization ++---------------- ++Support shadow page table walk. From 001176994a581ed61be63fb9f8d0c0dba9c8ede3 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 11 Sep 2022 00:12:29 +0100 Subject: [PATCH 035/114] ramips: add config-5.15 for mt76x8 subtarget Add Kernel config for testing Linux 5.15 for the mt76x8 subtarget. Compile tested only. Signed-off-by: Daniel Golle --- target/linux/ramips/mt76x8/config-5.15 | 193 +++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 target/linux/ramips/mt76x8/config-5.15 diff --git a/target/linux/ramips/mt76x8/config-5.15 b/target/linux/ramips/mt76x8/config-5.15 new file mode 100644 index 0000000000..b16a9a5cde --- /dev/null +++ b/target/linux/ramips/mt76x8/config-5.15 @@ -0,0 +1,193 @@ +CONFIG_ARCH_32BIT_OFF_T=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_KEEP_MEMBLOCK=y +CONFIG_ARCH_MMAP_RND_BITS_MAX=15 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=15 +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_AT803X_PHY=y +CONFIG_BLK_MQ_PCI=y +CONFIG_CEVT_R4K=y +CONFIG_CEVT_SYSTICK_QUIRK=y +CONFIG_CLKEVT_RT3352=y +CONFIG_CLKSRC_MMIO=y +CONFIG_CLONE_BACKWARDS=y +CONFIG_CMDLINE="rootfstype=squashfs,jffs2" +CONFIG_CMDLINE_BOOL=y +# CONFIG_CMDLINE_OVERRIDE is not set +CONFIG_COMMON_CLK=y +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_CPU_GENERIC_DUMP_TLB=y +CONFIG_CPU_HAS_DIEI=y +CONFIG_CPU_HAS_PREFETCH=y +CONFIG_CPU_HAS_RIXI=y +CONFIG_CPU_HAS_SYNC=y +CONFIG_CPU_MIPS32=y +# CONFIG_CPU_MIPS32_R1 is not set +CONFIG_CPU_MIPS32_R2=y +CONFIG_CPU_MIPSR2=y +CONFIG_CPU_MIPSR2_IRQ_VI=y +CONFIG_CPU_NEEDS_NO_SMARTMIPS_OR_MICROMIPS=y +CONFIG_CPU_R4K_CACHE_TLB=y +CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_HIGHMEM=y +CONFIG_CPU_SUPPORTS_MSA=y +CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y +CONFIG_CRYPTO_LIB_POLY1305_RSIZE=2 +CONFIG_CRYPTO_RNG2=y +CONFIG_CSRC_R4K=y +CONFIG_DEBUG_PINCTRL=y +CONFIG_DMA_NONCOHERENT=y +# CONFIG_DTB_MT7620A_EVAL is not set +# CONFIG_DTB_OMEGA2P is not set +CONFIG_DTB_RT_NONE=y +# CONFIG_DTB_VOCORE2 is not set +CONFIG_DTC=y +CONFIG_EARLY_PRINTK=y +CONFIG_FIXED_PHY=y +CONFIG_FWNODE_MDIO=y +CONFIG_FW_LOADER_PAGED_BUF=y +CONFIG_GENERIC_ATOMIC64=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CMOS_UPDATE=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_FIND_FIRST_BIT=y +CONFIG_GENERIC_GETTIMEOFDAY=y +CONFIG_GENERIC_IOMAP=y +CONFIG_GENERIC_IRQ_CHIP=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_LIB_ASHLDI3=y +CONFIG_GENERIC_LIB_ASHRDI3=y +CONFIG_GENERIC_LIB_CMPDI2=y +CONFIG_GENERIC_LIB_LSHRDI3=y +CONFIG_GENERIC_LIB_UCMPDI2=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_PHY=y +CONFIG_GENERIC_PINCONF=y +CONFIG_GENERIC_SCHED_CLOCK=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GPIOLIB_IRQCHIP=y +CONFIG_GPIO_CDEV=y +CONFIG_GPIO_GENERIC=y +CONFIG_GPIO_MT7621=y +# CONFIG_GPIO_RALINK is not set +CONFIG_HANDLE_DOMAIN_IRQ=y +CONFIG_HARDWARE_WATCHPOINTS=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HZ_PERIODIC=y +CONFIG_ICPLUS_PHY=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_INTC=y +CONFIG_IRQ_MIPS_CPU=y +CONFIG_IRQ_WORK=y +CONFIG_LIBFDT=y +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_MDIO_BUS=y +CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_DEVRES=y +CONFIG_MEMFD_CREATE=y +CONFIG_MFD_SYSCON=y +CONFIG_MIGRATION=y +CONFIG_MIPS=y +CONFIG_MIPS_ASID_BITS=8 +CONFIG_MIPS_ASID_SHIFT=0 +CONFIG_MIPS_CLOCK_VSYSCALL=y +# CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND is not set +# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set +CONFIG_MIPS_CMDLINE_FROM_DTB=y +CONFIG_MIPS_EBPF_JIT=y +CONFIG_MIPS_L1_CACHE_SHIFT=5 +CONFIG_MIPS_LD_CAN_LINK_VDSO=y +# CONFIG_MIPS_NO_APPENDED_DTB is not set +CONFIG_MIPS_RAW_APPENDED_DTB=y +CONFIG_MIPS_SPRAM=y +CONFIG_MODULES_USE_ELF_REL=y +CONFIG_MT7621_WDT=y +# CONFIG_MTD_CFI_INTELEXT is not set +CONFIG_MTD_CMDLINE_PARTS=y +CONFIG_MTD_PARSER_TRX=y +CONFIG_MTD_PHYSMAP=y +CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_SPLIT_TPLINK_FW=y +CONFIG_MTD_SPLIT_UIMAGE_FW=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_PER_CPU_KM=y +CONFIG_NET_RALINK_ESW_RT3050=y +# CONFIG_NET_RALINK_MT7620 is not set +CONFIG_NET_RALINK_RT3050=y +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_SELFTESTS=y +# CONFIG_NET_VENDOR_MEDIATEK is not set +CONFIG_NET_VENDOR_RALINK=y +CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y +CONFIG_NVMEM=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IRQ=y +CONFIG_OF_KOBJ=y +CONFIG_OF_MDIO=y +CONFIG_PCI=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCI_DRIVERS_LEGACY=y +CONFIG_PERF_USE_VMALLOC=y +CONFIG_PGTABLE_LEVELS=2 +CONFIG_PHYLIB=y +# CONFIG_PHY_MT7621_PCI is not set +CONFIG_PHY_RALINK_USB=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_MT7620=y +CONFIG_PINCTRL_RALINK=y +# CONFIG_PINCTRL_SINGLE is not set +CONFIG_PTP_1588_CLOCK_OPTIONAL=y +CONFIG_RALINK=y +# CONFIG_RALINK_WDT is not set +CONFIG_RATIONAL=y +CONFIG_REGMAP=y +CONFIG_REGMAP_MMIO=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_RESET_CONTROLLER=y +CONFIG_SERIAL_8250_NR_UARTS=3 +CONFIG_SERIAL_8250_RUNTIME_UARTS=3 +CONFIG_SERIAL_MCTRL_GPIO=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SOC_MT7620=y +# CONFIG_SOC_MT7621 is not set +# CONFIG_SOC_RT288X is not set +# CONFIG_SOC_RT305X is not set +# CONFIG_SOC_RT3883 is not set +CONFIG_SPI=y +CONFIG_SPI_MASTER=y +CONFIG_SPI_MEM=y +CONFIG_SPI_MT7621=y +# CONFIG_SPI_RT2880 is not set +CONFIG_SRCU=y +CONFIG_SWCONFIG=y +CONFIG_SWCONFIG_LEDS=y +CONFIG_SWPHY=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_SYS_HAS_CPU_MIPS32_R1=y +CONFIG_SYS_HAS_CPU_MIPS32_R2=y +CONFIG_SYS_HAS_EARLY_PRINTK=y +CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y +CONFIG_SYS_SUPPORTS_ARBIT_HZ=y +CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y +CONFIG_SYS_SUPPORTS_MIPS16=y +CONFIG_SYS_SUPPORTS_ZBOOT=y +CONFIG_TARGET_ISA_REV=2 +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TIMER_OF=y +CONFIG_TIMER_PROBE=y +CONFIG_TINY_SRCU=y +CONFIG_USB_SUPPORT=y +CONFIG_USE_OF=y +CONFIG_WATCHDOG_CORE=y From b9d9f33c330ed67e771379a4f070915ee32479d0 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 11 Sep 2022 00:51:08 +0100 Subject: [PATCH 036/114] ramips: add config-5.15 for rt288x subtarget Add Kernel config for testing Linux 5.15 for the rt288x subtarget. Compile tested only. Signed-off-by: Daniel Golle --- target/linux/ramips/rt288x/config-5.15 | 180 +++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 target/linux/ramips/rt288x/config-5.15 diff --git a/target/linux/ramips/rt288x/config-5.15 b/target/linux/ramips/rt288x/config-5.15 new file mode 100644 index 0000000000..07e839999e --- /dev/null +++ b/target/linux/ramips/rt288x/config-5.15 @@ -0,0 +1,180 @@ +CONFIG_ARCH_32BIT_OFF_T=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_KEEP_MEMBLOCK=y +CONFIG_ARCH_MMAP_RND_BITS_MAX=15 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=15 +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_BLK_MQ_PCI=y +CONFIG_CEVT_R4K=y +CONFIG_CLONE_BACKWARDS=y +CONFIG_CMDLINE="rootfstype=squashfs,jffs2" +CONFIG_CMDLINE_BOOL=y +# CONFIG_CMDLINE_OVERRIDE is not set +CONFIG_COMMON_CLK=y +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_CPU_GENERIC_DUMP_TLB=y +CONFIG_CPU_HAS_DIEI=y +CONFIG_CPU_HAS_PREFETCH=y +CONFIG_CPU_HAS_RIXI=y +CONFIG_CPU_HAS_SYNC=y +CONFIG_CPU_MIPS32=y +# CONFIG_CPU_MIPS32_R1 is not set +CONFIG_CPU_MIPS32_R2=y +CONFIG_CPU_MIPSR2=y +CONFIG_CPU_NEEDS_NO_SMARTMIPS_OR_MICROMIPS=y +CONFIG_CPU_R4K_CACHE_TLB=y +CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_HIGHMEM=y +CONFIG_CPU_SUPPORTS_MSA=y +CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y +CONFIG_CRYPTO_LIB_POLY1305_RSIZE=2 +CONFIG_CRYPTO_RNG2=y +CONFIG_CSRC_R4K=y +CONFIG_DMA_NONCOHERENT=y +# CONFIG_DTB_RT2880_EVAL is not set +CONFIG_DTB_RT_NONE=y +CONFIG_DTC=y +CONFIG_EARLY_PRINTK=y +CONFIG_FIXED_PHY=y +CONFIG_FWNODE_MDIO=y +CONFIG_FW_LOADER_PAGED_BUF=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_GENERIC_ATOMIC64=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CMOS_UPDATE=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_FIND_FIRST_BIT=y +CONFIG_GENERIC_GETTIMEOFDAY=y +CONFIG_GENERIC_IOMAP=y +CONFIG_GENERIC_IRQ_CHIP=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_LIB_ASHLDI3=y +CONFIG_GENERIC_LIB_ASHRDI3=y +CONFIG_GENERIC_LIB_CMPDI2=y +CONFIG_GENERIC_LIB_LSHRDI3=y +CONFIG_GENERIC_LIB_UCMPDI2=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_PINCONF=y +CONFIG_GENERIC_SCHED_CLOCK=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GPIO_CDEV=y +CONFIG_GPIO_RALINK=y +CONFIG_HANDLE_DOMAIN_IRQ=y +CONFIG_HARDWARE_WATCHPOINTS=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HZ_PERIODIC=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_IP17XX_PHY=y +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_INTC=y +CONFIG_IRQ_MIPS_CPU=y +CONFIG_IRQ_WORK=y +CONFIG_LIBFDT=y +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_MDIO_BUS=y +CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_DEVRES=y +CONFIG_MEMFD_CREATE=y +CONFIG_MIGRATION=y +CONFIG_MIPS=y +CONFIG_MIPS_ASID_BITS=8 +CONFIG_MIPS_ASID_SHIFT=0 +CONFIG_MIPS_AUTO_PFN_OFFSET=y +CONFIG_MIPS_CLOCK_VSYSCALL=y +# CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND is not set +# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set +CONFIG_MIPS_CMDLINE_FROM_DTB=y +CONFIG_MIPS_EBPF_JIT=y +CONFIG_MIPS_L1_CACHE_SHIFT=4 +CONFIG_MIPS_L1_CACHE_SHIFT_4=y +CONFIG_MIPS_LD_CAN_LINK_VDSO=y +# CONFIG_MIPS_NO_APPENDED_DTB is not set +CONFIG_MIPS_RAW_APPENDED_DTB=y +CONFIG_MIPS_SPRAM=y +CONFIG_MODULES_USE_ELF_REL=y +# CONFIG_MTD_CFI_INTELEXT is not set +CONFIG_MTD_CMDLINE_PARTS=y +CONFIG_MTD_PHYSMAP=y +CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_SPLIT_LZMA_FW=y +CONFIG_MTD_SPLIT_UIMAGE_FW=y +CONFIG_MTD_SPLIT_WRGG_FW=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_PER_CPU_KM=y +CONFIG_NET_RALINK_MDIO=y +CONFIG_NET_RALINK_MDIO_RT2880=y +CONFIG_NET_RALINK_RT2880=y +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_SELFTESTS=y +CONFIG_NET_VENDOR_RALINK=y +CONFIG_NLS=m +CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y +CONFIG_NVMEM=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IRQ=y +CONFIG_OF_KOBJ=y +CONFIG_OF_MDIO=y +CONFIG_PCI=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCI_DRIVERS_LEGACY=y +CONFIG_PERF_USE_VMALLOC=y +CONFIG_PGTABLE_LEVELS=2 +CONFIG_PHYLIB=y +# CONFIG_PHY_MT7621_PCI is not set +# CONFIG_PHY_RALINK_USB is not set +CONFIG_PINCTRL=y +CONFIG_PINCTRL_RALINK=y +CONFIG_PINCTRL_RT288X=y +# CONFIG_PINCTRL_SINGLE is not set +CONFIG_PTP_1588_CLOCK_OPTIONAL=y +CONFIG_RALINK=y +CONFIG_RALINK_WDT=y +CONFIG_RATIONAL=y +CONFIG_RESET_CONTROLLER=y +CONFIG_SERIAL_8250_RT288X=y +CONFIG_SERIAL_MCTRL_GPIO=y +CONFIG_SERIAL_OF_PLATFORM=y +# CONFIG_SOC_MT7620 is not set +# CONFIG_SOC_MT7621 is not set +CONFIG_SOC_RT288X=y +# CONFIG_SOC_RT305X is not set +# CONFIG_SOC_RT3883 is not set +CONFIG_SPI=y +CONFIG_SPI_MASTER=y +CONFIG_SPI_MEM=y +# CONFIG_SPI_MT7621 is not set +CONFIG_SPI_RT2880=y +CONFIG_SRCU=y +CONFIG_SWCONFIG=y +CONFIG_SWPHY=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_SYS_HAS_CPU_MIPS32_R1=y +CONFIG_SYS_HAS_CPU_MIPS32_R2=y +CONFIG_SYS_HAS_EARLY_PRINTK=y +CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y +CONFIG_SYS_SUPPORTS_ARBIT_HZ=y +CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y +CONFIG_SYS_SUPPORTS_MIPS16=y +CONFIG_SYS_SUPPORTS_ZBOOT=y +CONFIG_TARGET_ISA_REV=2 +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TINY_SRCU=y +CONFIG_USB=m +CONFIG_USB_COMMON=m +CONFIG_USB_EHCI_HCD=m +CONFIG_USB_EHCI_HCD_PLATFORM=m +CONFIG_USB_OHCI_HCD=m +CONFIG_USB_OHCI_HCD_PLATFORM=m +CONFIG_USB_SUPPORT=y +CONFIG_USE_OF=y +CONFIG_WATCHDOG_CORE=y From 0164dc0c2563e75a3f2fa5a099ec6944815e7b36 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 11 Sep 2022 00:51:38 +0100 Subject: [PATCH 037/114] ramips: add config-5.15 for rt305x subtarget Add Kernel config for testing Linux 5.15 for the rt305x subtarget. Tested on ZyXEL NBG-419N, works but bad wireless performance. Signed-off-by: Daniel Golle --- target/linux/ramips/rt305x/config-5.15 | 179 +++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 target/linux/ramips/rt305x/config-5.15 diff --git a/target/linux/ramips/rt305x/config-5.15 b/target/linux/ramips/rt305x/config-5.15 new file mode 100644 index 0000000000..d4833b61b0 --- /dev/null +++ b/target/linux/ramips/rt305x/config-5.15 @@ -0,0 +1,179 @@ +CONFIG_ARCH_32BIT_OFF_T=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_KEEP_MEMBLOCK=y +CONFIG_ARCH_MMAP_RND_BITS_MAX=15 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=15 +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_CEVT_R4K=y +CONFIG_CEVT_SYSTICK_QUIRK=y +CONFIG_CLKEVT_RT3352=y +CONFIG_CLKSRC_MMIO=y +CONFIG_CLONE_BACKWARDS=y +CONFIG_CMDLINE="rootfstype=squashfs,jffs2" +CONFIG_CMDLINE_BOOL=y +# CONFIG_CMDLINE_OVERRIDE is not set +CONFIG_COMMON_CLK=y +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_CPU_GENERIC_DUMP_TLB=y +CONFIG_CPU_HAS_DIEI=y +CONFIG_CPU_HAS_PREFETCH=y +CONFIG_CPU_HAS_RIXI=y +CONFIG_CPU_HAS_SYNC=y +CONFIG_CPU_MIPS32=y +# CONFIG_CPU_MIPS32_R1 is not set +CONFIG_CPU_MIPS32_R2=y +CONFIG_CPU_MIPSR2=y +CONFIG_CPU_NEEDS_NO_SMARTMIPS_OR_MICROMIPS=y +CONFIG_CPU_R4K_CACHE_TLB=y +CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_HIGHMEM=y +CONFIG_CPU_SUPPORTS_MSA=y +CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y +CONFIG_CRYPTO_LIB_POLY1305_RSIZE=2 +CONFIG_CRYPTO_RNG2=y +CONFIG_CSRC_R4K=y +CONFIG_DEBUG_PINCTRL=y +CONFIG_DMA_NONCOHERENT=y +# CONFIG_DTB_RT305X_EVAL is not set +CONFIG_DTB_RT_NONE=y +CONFIG_DTC=y +CONFIG_EARLY_PRINTK=y +CONFIG_FIXED_PHY=y +CONFIG_FWNODE_MDIO=y +CONFIG_FW_LOADER_PAGED_BUF=y +CONFIG_GENERIC_ATOMIC64=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CMOS_UPDATE=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_FIND_FIRST_BIT=y +CONFIG_GENERIC_GETTIMEOFDAY=y +CONFIG_GENERIC_IOMAP=y +CONFIG_GENERIC_IRQ_CHIP=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_LIB_ASHLDI3=y +CONFIG_GENERIC_LIB_ASHRDI3=y +CONFIG_GENERIC_LIB_CMPDI2=y +CONFIG_GENERIC_LIB_LSHRDI3=y +CONFIG_GENERIC_LIB_UCMPDI2=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_PHY=y +CONFIG_GENERIC_PINCONF=y +CONFIG_GENERIC_SCHED_CLOCK=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GPIO_CDEV=y +CONFIG_GPIO_RALINK=y +CONFIG_GPIO_WATCHDOG=y +# CONFIG_GPIO_WATCHDOG_ARCH_INITCALL is not set +CONFIG_HANDLE_DOMAIN_IRQ=y +CONFIG_HARDWARE_WATCHPOINTS=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HZ_PERIODIC=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_INTC=y +CONFIG_IRQ_MIPS_CPU=y +CONFIG_IRQ_WORK=y +CONFIG_LIBFDT=y +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_MDIO_BUS=y +CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_DEVRES=y +CONFIG_MEMFD_CREATE=y +CONFIG_MFD_SYSCON=y +CONFIG_MIGRATION=y +CONFIG_MIPS=y +CONFIG_MIPS_ASID_BITS=8 +CONFIG_MIPS_ASID_SHIFT=0 +CONFIG_MIPS_CLOCK_VSYSCALL=y +# CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND is not set +# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set +CONFIG_MIPS_CMDLINE_FROM_DTB=y +CONFIG_MIPS_EBPF_JIT=y +CONFIG_MIPS_L1_CACHE_SHIFT=5 +CONFIG_MIPS_LD_CAN_LINK_VDSO=y +# CONFIG_MIPS_NO_APPENDED_DTB is not set +CONFIG_MIPS_RAW_APPENDED_DTB=y +CONFIG_MIPS_SPRAM=y +CONFIG_MODULES_USE_ELF_REL=y +# CONFIG_MTD_CFI_INTELEXT is not set +CONFIG_MTD_CMDLINE_PARTS=y +CONFIG_MTD_PHYSMAP=y +CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y +CONFIG_MTD_SPLIT_JIMAGE_FW=y +CONFIG_MTD_SPLIT_SEAMA_FW=y +CONFIG_MTD_SPLIT_UIMAGE_FW=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_PER_CPU_KM=y +CONFIG_NET_RALINK_ESW_RT3050=y +CONFIG_NET_RALINK_RT3050=y +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_SELFTESTS=y +CONFIG_NET_VENDOR_RALINK=y +CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y +CONFIG_NVMEM=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IRQ=y +CONFIG_OF_KOBJ=y +CONFIG_OF_MDIO=y +CONFIG_PCI_DRIVERS_LEGACY=y +CONFIG_PERF_USE_VMALLOC=y +CONFIG_PGTABLE_LEVELS=2 +CONFIG_PHYLIB=y +# CONFIG_PHY_MT7621_PCI is not set +CONFIG_PHY_RALINK_USB=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_RALINK=y +CONFIG_PINCTRL_RT305X=y +# CONFIG_PINCTRL_SINGLE is not set +CONFIG_PTP_1588_CLOCK_OPTIONAL=y +CONFIG_RALINK=y +# CONFIG_RALINK_ILL_ACC is not set +CONFIG_RALINK_WDT=y +CONFIG_RATIONAL=y +CONFIG_REGMAP=y +CONFIG_REGMAP_MMIO=y +CONFIG_RESET_CONTROLLER=y +CONFIG_SERIAL_8250_RT288X=y +CONFIG_SERIAL_MCTRL_GPIO=y +CONFIG_SERIAL_OF_PLATFORM=y +# CONFIG_SOC_MT7620 is not set +# CONFIG_SOC_MT7621 is not set +# CONFIG_SOC_RT288X is not set +CONFIG_SOC_RT305X=y +# CONFIG_SOC_RT3883 is not set +CONFIG_SPI=y +CONFIG_SPI_MASTER=y +CONFIG_SPI_MEM=y +# CONFIG_SPI_MT7621 is not set +CONFIG_SPI_RT2880=y +CONFIG_SRCU=y +CONFIG_SWCONFIG=y +CONFIG_SWPHY=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_SYS_HAS_CPU_MIPS32_R1=y +CONFIG_SYS_HAS_CPU_MIPS32_R2=y +CONFIG_SYS_HAS_EARLY_PRINTK=y +CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y +CONFIG_SYS_SUPPORTS_ARBIT_HZ=y +CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y +CONFIG_SYS_SUPPORTS_MIPS16=y +CONFIG_SYS_SUPPORTS_ZBOOT=y +CONFIG_TARGET_ISA_REV=2 +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TIMER_OF=y +CONFIG_TIMER_PROBE=y +CONFIG_TINY_SRCU=y +CONFIG_USB_SUPPORT=y +CONFIG_USE_OF=y +CONFIG_WATCHDOG_CORE=y From ef59da866982b4891f64d01c15967877c2898e26 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 11 Sep 2022 00:52:06 +0100 Subject: [PATCH 038/114] ramips: add config-5.15 for rt3883 subtarget Add Kernel config for testing Linux 5.15 for the rt3883 subtarget. Compile tested only. Signed-off-by: Daniel Golle --- target/linux/ramips/rt3883/config-5.15 | 179 +++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 target/linux/ramips/rt3883/config-5.15 diff --git a/target/linux/ramips/rt3883/config-5.15 b/target/linux/ramips/rt3883/config-5.15 new file mode 100644 index 0000000000..8637885254 --- /dev/null +++ b/target/linux/ramips/rt3883/config-5.15 @@ -0,0 +1,179 @@ +CONFIG_AR8216_PHY=y +CONFIG_ARCH_32BIT_OFF_T=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_KEEP_MEMBLOCK=y +CONFIG_ARCH_MMAP_RND_BITS_MAX=15 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=15 +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_BLK_MQ_PCI=y +CONFIG_CEVT_R4K=y +CONFIG_CLONE_BACKWARDS=y +CONFIG_CMDLINE="rootfstype=squashfs,jffs2" +CONFIG_CMDLINE_BOOL=y +# CONFIG_CMDLINE_OVERRIDE is not set +CONFIG_COMMON_CLK=y +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_CPU_GENERIC_DUMP_TLB=y +CONFIG_CPU_HAS_DIEI=y +CONFIG_CPU_HAS_PREFETCH=y +CONFIG_CPU_HAS_RIXI=y +CONFIG_CPU_HAS_SYNC=y +CONFIG_CPU_MIPS32=y +# CONFIG_CPU_MIPS32_R1 is not set +CONFIG_CPU_MIPS32_R2=y +CONFIG_CPU_MIPSR2=y +CONFIG_CPU_NEEDS_NO_SMARTMIPS_OR_MICROMIPS=y +CONFIG_CPU_R4K_CACHE_TLB=y +CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_HIGHMEM=y +CONFIG_CPU_SUPPORTS_MSA=y +CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y +CONFIG_CRYPTO_LIB_POLY1305_RSIZE=2 +CONFIG_CRYPTO_RNG2=y +CONFIG_CSRC_R4K=y +CONFIG_DEBUG_PINCTRL=y +CONFIG_DMA_NONCOHERENT=y +# CONFIG_DTB_RT3883_EVAL is not set +CONFIG_DTB_RT_NONE=y +CONFIG_DTC=y +CONFIG_EARLY_PRINTK=y +CONFIG_ETHERNET_PACKET_MANGLE=y +CONFIG_FIXED_PHY=y +CONFIG_FWNODE_MDIO=y +CONFIG_FW_LOADER_PAGED_BUF=y +CONFIG_GENERIC_ATOMIC64=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CMOS_UPDATE=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_FIND_FIRST_BIT=y +CONFIG_GENERIC_GETTIMEOFDAY=y +CONFIG_GENERIC_IOMAP=y +CONFIG_GENERIC_IRQ_CHIP=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_LIB_ASHLDI3=y +CONFIG_GENERIC_LIB_ASHRDI3=y +CONFIG_GENERIC_LIB_CMPDI2=y +CONFIG_GENERIC_LIB_LSHRDI3=y +CONFIG_GENERIC_LIB_UCMPDI2=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_PHY=y +CONFIG_GENERIC_PINCONF=y +CONFIG_GENERIC_SCHED_CLOCK=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GPIO_CDEV=y +CONFIG_GPIO_RALINK=y +CONFIG_HANDLE_DOMAIN_IRQ=y +CONFIG_HARDWARE_WATCHPOINTS=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HZ_PERIODIC=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_INTC=y +CONFIG_IRQ_MIPS_CPU=y +CONFIG_IRQ_WORK=y +CONFIG_LIBFDT=y +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_MDIO_BUS=y +CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_DEVRES=y +CONFIG_MEMFD_CREATE=y +CONFIG_MFD_SYSCON=y +CONFIG_MIGRATION=y +CONFIG_MIPS=y +CONFIG_MIPS_ASID_BITS=8 +CONFIG_MIPS_ASID_SHIFT=0 +CONFIG_MIPS_CLOCK_VSYSCALL=y +# CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND is not set +# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set +CONFIG_MIPS_CMDLINE_FROM_DTB=y +CONFIG_MIPS_EBPF_JIT=y +CONFIG_MIPS_L1_CACHE_SHIFT=5 +CONFIG_MIPS_LD_CAN_LINK_VDSO=y +# CONFIG_MIPS_NO_APPENDED_DTB is not set +CONFIG_MIPS_RAW_APPENDED_DTB=y +CONFIG_MIPS_SPRAM=y +CONFIG_MODULES_USE_ELF_REL=y +# CONFIG_MTD_CFI_INTELEXT is not set +CONFIG_MTD_CMDLINE_PARTS=y +CONFIG_MTD_PHYSMAP=y +CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y +CONFIG_MTD_SPLIT_SEAMA_FW=y +CONFIG_MTD_SPLIT_UIMAGE_FW=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_PER_CPU_KM=y +CONFIG_NET_RALINK_MDIO=y +CONFIG_NET_RALINK_MDIO_RT2880=y +CONFIG_NET_RALINK_RT3883=y +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_SELFTESTS=y +CONFIG_NET_VENDOR_RALINK=y +CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y +CONFIG_NVMEM=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IRQ=y +CONFIG_OF_KOBJ=y +CONFIG_OF_MDIO=y +CONFIG_PCI=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCI_DRIVERS_LEGACY=y +CONFIG_PERF_USE_VMALLOC=y +CONFIG_PGTABLE_LEVELS=2 +CONFIG_PHYLIB=y +# CONFIG_PHY_MT7621_PCI is not set +CONFIG_PHY_RALINK_USB=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_RALINK=y +CONFIG_PINCTRL_RT3883=y +# CONFIG_PINCTRL_SINGLE is not set +CONFIG_PTP_1588_CLOCK_OPTIONAL=y +CONFIG_RALINK=y +CONFIG_RALINK_WDT=y +CONFIG_RATIONAL=y +CONFIG_REGMAP=y +CONFIG_REGMAP_MMIO=y +CONFIG_RESET_CONTROLLER=y +CONFIG_RTL8366_SMI=y +CONFIG_RTL8367B_PHY=y +CONFIG_RTL8367_PHY=y +CONFIG_SERIAL_8250_RT288X=y +CONFIG_SERIAL_MCTRL_GPIO=y +CONFIG_SERIAL_OF_PLATFORM=y +# CONFIG_SOC_MT7620 is not set +# CONFIG_SOC_MT7621 is not set +# CONFIG_SOC_RT288X is not set +# CONFIG_SOC_RT305X is not set +CONFIG_SOC_RT3883=y +CONFIG_SPI=y +CONFIG_SPI_MASTER=y +CONFIG_SPI_MEM=y +# CONFIG_SPI_MT7621 is not set +CONFIG_SPI_RT2880=y +CONFIG_SRCU=y +CONFIG_SWCONFIG=y +CONFIG_SWPHY=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_SYS_HAS_CPU_MIPS32_R1=y +CONFIG_SYS_HAS_CPU_MIPS32_R2=y +CONFIG_SYS_HAS_EARLY_PRINTK=y +CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y +CONFIG_SYS_SUPPORTS_ARBIT_HZ=y +CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y +CONFIG_SYS_SUPPORTS_MIPS16=y +CONFIG_SYS_SUPPORTS_ZBOOT=y +CONFIG_TARGET_ISA_REV=2 +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TINY_SRCU=y +CONFIG_USB_SUPPORT=y +CONFIG_USE_OF=y +CONFIG_WATCHDOG_CORE=y From a9dda40fe21be2890fd864c6b70810c2042ddb7f Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 11 Sep 2022 02:31:21 +0100 Subject: [PATCH 039/114] oxnas: add testing support for Linux 5.15 Rebase patches and port SATA driver to work with Linux > 5.13. Tested on Shuttle KD-20. Signed-off-by: Daniel Golle --- target/linux/oxnas/Makefile | 1 + target/linux/oxnas/config-5.15 | 289 ++++++++++++++++++ .../oxnas/files/drivers/ata/sata_oxnas.c | 3 + target/linux/oxnas/ox820/config-default | 4 + .../patches-5.15/010-pogoplug-series-3.patch | 82 +++++ .../050-ox820-remove-left-overs.patch | 63 ++++ .../100-oxnas-clk-plla-pllb.patch | 273 +++++++++++++++++ .../patches-5.15/150-oxnas-restart.patch | 25 ++ .../patches-5.15/320-oxnas-phy-pcie.patch | 44 +++ .../oxnas/patches-5.15/340-oxnas-pcie.patch | 122 ++++++++ .../oxnas/patches-5.15/500-oxnas-sata.patch | 60 ++++ .../patches-5.15/510-ox820-libata-leds.patch | 10 + .../oxnas/patches-5.15/800-oxnas-ehci.patch | 73 +++++ ...Mangle-bootloader-s-kernel-arguments.patch | 189 ++++++++++++ .../oxnas/patches-5.15/999-libata-hacks.patch | 57 ++++ 15 files changed, 1295 insertions(+) create mode 100644 target/linux/oxnas/config-5.15 create mode 100644 target/linux/oxnas/patches-5.15/010-pogoplug-series-3.patch create mode 100644 target/linux/oxnas/patches-5.15/050-ox820-remove-left-overs.patch create mode 100644 target/linux/oxnas/patches-5.15/100-oxnas-clk-plla-pllb.patch create mode 100644 target/linux/oxnas/patches-5.15/150-oxnas-restart.patch create mode 100644 target/linux/oxnas/patches-5.15/320-oxnas-phy-pcie.patch create mode 100644 target/linux/oxnas/patches-5.15/340-oxnas-pcie.patch create mode 100644 target/linux/oxnas/patches-5.15/500-oxnas-sata.patch create mode 100644 target/linux/oxnas/patches-5.15/510-ox820-libata-leds.patch create mode 100644 target/linux/oxnas/patches-5.15/800-oxnas-ehci.patch create mode 100644 target/linux/oxnas/patches-5.15/996-generic-Mangle-bootloader-s-kernel-arguments.patch create mode 100644 target/linux/oxnas/patches-5.15/999-libata-hacks.patch diff --git a/target/linux/oxnas/Makefile b/target/linux/oxnas/Makefile index f52a0ceca5..9dfdb5c86e 100644 --- a/target/linux/oxnas/Makefile +++ b/target/linux/oxnas/Makefile @@ -8,6 +8,7 @@ FEATURES:=gpio ramdisk rtc squashfs DEVICE_TYPE:=nas KERNEL_PATCHVER:=5.10 +KERNEL_TESTING_PATCHVER:=5.15 include $(INCLUDE_DIR)/target.mk diff --git a/target/linux/oxnas/config-5.15 b/target/linux/oxnas/config-5.15 new file mode 100644 index 0000000000..aff528e34f --- /dev/null +++ b/target/linux/oxnas/config-5.15 @@ -0,0 +1,289 @@ +CONFIG_ALIGNMENT_TRAP=y +CONFIG_ARCH_32BIT_OFF_T=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_KEEP_MEMBLOCK=y +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +CONFIG_ARCH_MULTIPLATFORM=y +CONFIG_ARCH_MULTI_CPU_AUTO=y +# CONFIG_ARCH_MULTI_V4 is not set +# CONFIG_ARCH_MULTI_V4T is not set +CONFIG_ARCH_MULTI_V4_V5=y +CONFIG_ARCH_MULTI_V5=y +CONFIG_ARCH_NR_GPIO=0 +CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y +CONFIG_ARCH_OXNAS=y +CONFIG_ARCH_SELECT_MEMORY_MODEL=y +CONFIG_ARCH_SPARSEMEM_ENABLE=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ARCH_WANT_LIBATA_LEDS=y +CONFIG_ARM=y +CONFIG_ARM_APPENDED_DTB=y +CONFIG_ARM_ATAG_DTB_COMPAT=y +# CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER is not set +CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE=y +CONFIG_ARM_CPU_SUSPEND=y +CONFIG_ARM_HAS_SG_CHAIN=y +CONFIG_ARM_L1_CACHE_SHIFT=5 +CONFIG_ARM_PATCH_PHYS_VIRT=y +# CONFIG_ARM_SMMU is not set +CONFIG_ARM_THUMB=y +CONFIG_ARM_UNWIND=y +CONFIG_ATAGS=y +CONFIG_AUTO_ZRELADDR=y +CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK=y +CONFIG_BLK_DEBUG_FS=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=65536 +CONFIG_BLK_PM=y +CONFIG_CLKSRC_MMIO=y +CONFIG_CLONE_BACKWARDS=y +CONFIG_CMA=y +CONFIG_CMA_ALIGNMENT=8 +CONFIG_CMA_AREAS=7 +# CONFIG_CMA_DEBUG is not set +# CONFIG_CMA_DEBUGFS is not set +CONFIG_CMA_SIZE_MBYTES=64 +# CONFIG_CMA_SIZE_SEL_MAX is not set +CONFIG_CMA_SIZE_SEL_MBYTES=y +# CONFIG_CMA_SIZE_SEL_MIN is not set +# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set +# CONFIG_CMA_SYSFS is not set +CONFIG_CMDLINE_PARTITION=y +CONFIG_COMMON_CLK=y +CONFIG_COMMON_CLK_OXNAS=y +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_CONTIG_ALLOC=y +CONFIG_COREDUMP=y +CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y +CONFIG_CPU_32v5=y +CONFIG_CPU_ABRT_EV5TJ=y +CONFIG_CPU_ARM926T=y +# CONFIG_CPU_CACHE_ROUND_ROBIN is not set +CONFIG_CPU_CACHE_VIVT=y +CONFIG_CPU_COPY_V4WB=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y +# CONFIG_CPU_DCACHE_WRITETHROUGH is not set +CONFIG_CPU_PABRT_LEGACY=y +CONFIG_CPU_PM=y +CONFIG_CPU_THUMB_CAPABLE=y +CONFIG_CPU_TLB_V4WBI=y +CONFIG_CPU_USE_DOMAINS=y +CONFIG_CRASH_CORE=y +CONFIG_CRC16=y +# CONFIG_CRC32_SARWATE is not set +CONFIG_CRC32_SLICEBY8=y +CONFIG_CROSS_MEMORY_ATTACH=y +CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y +CONFIG_CRYPTO_RNG2=y +CONFIG_DEBUG_ALIGN_RODATA=y +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S" +CONFIG_DECOMPRESS_BZIP2=y +CONFIG_DECOMPRESS_GZIP=y +CONFIG_DECOMPRESS_LZ4=y +CONFIG_DECOMPRESS_LZMA=y +CONFIG_DECOMPRESS_LZO=y +CONFIG_DECOMPRESS_XZ=y +CONFIG_DMA_CMA=y +CONFIG_DMA_OPS=y +CONFIG_DMA_REMAP=y +CONFIG_DNOTIFY=y +CONFIG_DTC=y +CONFIG_DWMAC_GENERIC=y +CONFIG_DWMAC_OXNAS=y +CONFIG_EDAC_ATOMIC_SCRUB=y +CONFIG_EDAC_SUPPORT=y +CONFIG_ELF_CORE=y +CONFIG_FAT_FS=y +CONFIG_FIXED_PHY=y +CONFIG_FIX_EARLYCON_MEM=y +CONFIG_FREEZER=y +CONFIG_FWNODE_MDIO=y +# CONFIG_FW_CACHE is not set +CONFIG_FW_LOADER_PAGED_BUF=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_GENERIC_ATOMIC64=y +CONFIG_GENERIC_BUG=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_EARLY_IOREMAP=y +CONFIG_GENERIC_IDLE_POLL_SETUP=y +CONFIG_GENERIC_IRQ_MULTI_HANDLER=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_IRQ_SHOW_LEVEL=y +CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_PHY=y +CONFIG_GENERIC_PINCONF=y +CONFIG_GENERIC_SCHED_CLOCK=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GPIOLIB_IRQCHIP=y +CONFIG_GPIO_CDEV=y +CONFIG_GPIO_GENERIC=y +CONFIG_GPIO_GENERIC_PLATFORM=y +CONFIG_HANDLE_DOMAIN_IRQ=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HID=y +CONFIG_HID_GENERIC=y +CONFIG_HWMON=y +CONFIG_HZ_FIXED=0 +CONFIG_ICPLUS_PHY=y +CONFIG_INET_DIAG=y +# CONFIG_INET_DIAG_DESTROY is not set +# CONFIG_INET_RAW_DIAG is not set +CONFIG_INET_TCP_DIAG=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_INPUT=y +# CONFIG_IOMMU_DEBUGFS is not set +# CONFIG_IOMMU_IO_PGTABLE_ARMV7S is not set +# CONFIG_IOMMU_IO_PGTABLE_LPAE is not set +CONFIG_IOMMU_SUPPORT=y +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_WORK=y +# CONFIG_ISDN is not set +# CONFIG_JFFS2_FS is not set +CONFIG_KALLSYMS=y +CONFIG_KERNEL_GZIP=y +# CONFIG_KERNEL_XZ is not set +CONFIG_KEXEC=y +CONFIG_KEXEC_CORE=y +# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set +CONFIG_LEDS_GPIO=y +CONFIG_LEDS_TRIGGER_CPU=y +CONFIG_LEDS_TRIGGER_GPIO=y +CONFIG_LEDS_TRIGGER_ONESHOT=y +CONFIG_LIBFDT=y +CONFIG_LOCALVERSION_AUTO=y +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_LZ4_DECOMPRESS=y +CONFIG_LZO_DECOMPRESS=y +# CONFIG_MACH_OX810SE is not set +CONFIG_MDIO_BUS=y +CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_DEVRES=y +CONFIG_MEMFD_CREATE=y +CONFIG_MEMORY_ISOLATION=y +CONFIG_MFD_SYSCON=y +CONFIG_MIGRATION=y +CONFIG_MODULES_USE_ELF_REL=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_KUSER_HELPERS=y +CONFIG_NEED_PER_CPU_KM=y +CONFIG_NET_PTP_CLASSIFY=y +CONFIG_NET_SELFTESTS=y +CONFIG_NLS=y +CONFIG_NO_HZ=y +CONFIG_NO_HZ_COMMON=y +CONFIG_NO_HZ_IDLE=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IRQ=y +CONFIG_OF_KOBJ=y +CONFIG_OF_MDIO=y +CONFIG_OLD_SIGACTION=y +CONFIG_OLD_SIGSUSPEND3=y +CONFIG_OXNAS_RPS_TIMER=y +CONFIG_PAGE_OFFSET=0xC0000000 +CONFIG_PAGE_POOL=y +# CONFIG_PANIC_ON_OOPS is not set +CONFIG_PANIC_ON_OOPS_VALUE=0 +CONFIG_PANIC_TIMEOUT=0 +CONFIG_PCS_XPCS=y +CONFIG_PERF_USE_VMALLOC=y +CONFIG_PGTABLE_LEVELS=2 +CONFIG_PHYLIB=y +CONFIG_PHYLINK=y +CONFIG_PHY_OXNAS=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_OXNAS=y +# CONFIG_PINCTRL_SINGLE is not set +CONFIG_PM=y +CONFIG_PM_CLK=y +CONFIG_PM_SLEEP=y +CONFIG_POWER_RESET=y +CONFIG_POWER_RESET_OXNAS=y +CONFIG_PPS=y +CONFIG_PTP_1588_CLOCK=y +CONFIG_PTP_1588_CLOCK_OPTIONAL=y +CONFIG_RAS=y +CONFIG_RATIONAL=y +CONFIG_RCU_TRACE=y +CONFIG_RD_BZIP2=y +CONFIG_RD_GZIP=y +CONFIG_RD_LZ4=y +CONFIG_RD_LZMA=y +CONFIG_RD_LZO=y +CONFIG_RD_XZ=y +CONFIG_REALTEK_PHY=y +CONFIG_REGMAP=y +CONFIG_REGMAP_MMIO=y +CONFIG_RESET_CONTROLLER=y +CONFIG_RESET_OXNAS=y +CONFIG_SCHED_DEBUG=y +CONFIG_SERIAL_8250_DEPRECATED_OPTIONS=y +CONFIG_SERIAL_8250_FSL=y +CONFIG_SERIAL_8250_NR_UARTS=4 +CONFIG_SERIAL_8250_RUNTIME_UARTS=4 +CONFIG_SERIAL_MCTRL_GPIO=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SERIO=y +CONFIG_SERIO_LIBPS2=y +CONFIG_SERIO_SERPORT=y +CONFIG_SLUB_DEBUG=y +CONFIG_SOCK_DIAG=y +CONFIG_SPARSE_IRQ=y +CONFIG_SPLIT_PTLOCK_CPUS=999999 +CONFIG_SRCU=y +CONFIG_STACKTRACE=y +CONFIG_STMMAC_ETH=y +CONFIG_STMMAC_PLATFORM=y +# CONFIG_STRIP_ASM_SYMS is not set +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +CONFIG_SWPHY=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_THERMAL=y +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 +CONFIG_THERMAL_GOV_STEP_WISE=y +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_OF=y +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TIMER_OF=y +CONFIG_TIMER_PROBE=y +CONFIG_TINY_SRCU=y +CONFIG_TRACE_CLOCK=y +CONFIG_UEVENT_HELPER_PATH="" +CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" +CONFIG_UNWINDER_ARM=y +CONFIG_USB_SUPPORT=y +CONFIG_USE_OF=y +CONFIG_VERSATILE_FPGA_IRQ=y +CONFIG_VERSATILE_FPGA_IRQ_NR=4 +CONFIG_VFAT_FS=y +# CONFIG_VFP is not set +CONFIG_VM_EVENT_COUNTERS=y +# CONFIG_WATCHDOG is not set +# CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set +CONFIG_XZ_DEC_ARM=y +CONFIG_XZ_DEC_BCJ=y +CONFIG_XZ_DEC_IA64=y +CONFIG_XZ_DEC_POWERPC=y +CONFIG_XZ_DEC_SPARC=y +CONFIG_XZ_DEC_X86=y +CONFIG_ZBOOT_ROM_BSS=0 +CONFIG_ZBOOT_ROM_TEXT=0 +CONFIG_ZLIB_INFLATE=y diff --git a/target/linux/oxnas/files/drivers/ata/sata_oxnas.c b/target/linux/oxnas/files/drivers/ata/sata_oxnas.c index b55995ccad..a5d7b3de72 100644 --- a/target/linux/oxnas/files/drivers/ata/sata_oxnas.c +++ b/target/linux/oxnas/files/drivers/ata/sata_oxnas.c @@ -31,6 +31,7 @@ #include #include +#include static inline void oxnas_register_clear_mask(void __iomem *p, unsigned mask) { @@ -2231,7 +2232,9 @@ static struct scsi_host_template sata_oxnas_sht = { .can_queue = SATA_OXNAS_QUEUE_DEPTH, .sg_tablesize = SATA_OXNAS_MAX_PRD, .dma_boundary = ATA_DMA_BOUNDARY, +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0) .unchecked_isa_dma = 0, +#endif }; diff --git a/target/linux/oxnas/ox820/config-default b/target/linux/oxnas/ox820/config-default index b81f76cc25..8395d75815 100644 --- a/target/linux/oxnas/ox820/config-default +++ b/target/linux/oxnas/ox820/config-default @@ -52,7 +52,11 @@ CONFIG_MIGHT_HAVE_PCI=y CONFIG_MTD_CMDLINE_PARTS=y # CONFIG_MTD_COMPLEX_MAPPINGS is not set CONFIG_MTD_NAND=y +CONFIG_MTD_NAND_CORE=y CONFIG_MTD_NAND_ECC=y +# CONFIG_MTD_NAND_ECC_SW_BCH is not set +CONFIG_MTD_NAND_ECC_SW_HAMMING=y +# CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC is not set CONFIG_MTD_NAND_OXNAS=y CONFIG_MTD_RAW_NAND=y CONFIG_MTD_UBI=y diff --git a/target/linux/oxnas/patches-5.15/010-pogoplug-series-3.patch b/target/linux/oxnas/patches-5.15/010-pogoplug-series-3.patch new file mode 100644 index 0000000000..44102352af --- /dev/null +++ b/target/linux/oxnas/patches-5.15/010-pogoplug-series-3.patch @@ -0,0 +1,82 @@ +- add compatible string +- add console to bootargs +- add led aliases +- adjust nand partition table +--- +--- a/arch/arm/boot/dts/ox820-cloudengines-pogoplug-series-3.dts ++++ b/arch/arm/boot/dts/ox820-cloudengines-pogoplug-series-3.dts +@@ -11,10 +11,10 @@ + / { + model = "Cloud Engines PogoPlug Series 3"; + +- compatible = "cloudengines,pogoplugv3", "oxsemi,ox820"; ++ compatible = "cloudengines,pogoplug-series-3", "cloudengines,pogoplugv3", "oxsemi,ox820"; + + chosen { +- bootargs = "earlyprintk"; ++ bootargs = "earlyprintk console=ttyS0,115200"; + stdout-path = "serial0:115200n8"; + }; + +@@ -27,24 +27,28 @@ + serial0 = &uart0; + gpio0 = &gpio0; + gpio1 = &gpio1; ++ led-boot = &led_status; ++ led-failsafe = &led_warn; ++ led-running = &led_act; ++ led-upgrade = &led_warn; + }; + + leds { + compatible = "gpio-leds"; + +- blue { ++ led_status: blue { + label = "pogoplug:blue"; + gpios = <&gpio0 2 0>; + default-state = "keep"; + }; + +- orange { ++ led_warn: orange { + label = "pogoplug:orange"; + gpios = <&gpio1 16 1>; + default-state = "keep"; + }; + +- green { ++ led_act: green { + label = "pogoplug:green"; + gpios = <&gpio1 17 1>; + default-state = "keep"; +@@ -73,11 +77,27 @@ + nand-ecc-algo = "hamming"; + + partition@0 { +- label = "boot"; +- reg = <0x00000000 0x00e00000>; ++ label = "stage1"; ++ reg = <0x00000000 0x00040000>; + read-only; + }; + ++ partition@40000 { ++ label = "u-boot"; ++ reg = <0x00040000 0x00380000>; ++ read-only; ++ }; ++ ++ partition@3c0000 { ++ label = "u-boot-env"; ++ reg = <0x003c0000 0x00080000>; ++ }; ++ ++ partition@440000 { ++ label = "kernel"; ++ reg = <0x00440000 0x009c0000>; ++ }; ++ + partition@e00000 { + label = "ubi"; + reg = <0x00e00000 0x07200000>; diff --git a/target/linux/oxnas/patches-5.15/050-ox820-remove-left-overs.patch b/target/linux/oxnas/patches-5.15/050-ox820-remove-left-overs.patch new file mode 100644 index 0000000000..e30f328792 --- /dev/null +++ b/target/linux/oxnas/patches-5.15/050-ox820-remove-left-overs.patch @@ -0,0 +1,63 @@ +From 552ed4955c1fee1109bf5ba137dc35a411a1448c Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Fri, 1 Jun 2018 02:41:15 +0200 +Subject: [PATCH] arm: ox820: remove left-overs + +Signed-off-by: Daniel Golle +--- + drivers/clk/clk-oxnas.c | 2 -- + include/dt-bindings/clock/oxsemi,ox820.h | 32 +++++++++++------------- + 2 files changed, 14 insertions(+), 20 deletions(-) + +--- a/drivers/clk/clk-oxnas.c ++++ b/drivers/clk/clk-oxnas.c +@@ -29,8 +29,6 @@ struct oxnas_stdclk_data { + struct clk_hw_onecell_data *onecell_data; + struct clk_oxnas_gate **gates; + unsigned int ngates; +- struct clk_oxnas_pll **plls; +- unsigned int nplls; + }; + + /* Regmap offsets */ +--- a/include/dt-bindings/clock/oxsemi,ox820.h ++++ b/include/dt-bindings/clock/oxsemi,ox820.h +@@ -6,24 +6,20 @@ + #ifndef DT_CLOCK_OXSEMI_OX820_H + #define DT_CLOCK_OXSEMI_OX820_H + +-/* PLLs */ +-#define CLK_820_PLLA 0 +-#define CLK_820_PLLB 1 +- + /* Gate Clocks */ +-#define CLK_820_LEON 2 +-#define CLK_820_DMA_SGDMA 3 +-#define CLK_820_CIPHER 4 +-#define CLK_820_SD 5 +-#define CLK_820_SATA 6 +-#define CLK_820_AUDIO 7 +-#define CLK_820_USBMPH 8 +-#define CLK_820_ETHA 9 +-#define CLK_820_PCIEA 10 +-#define CLK_820_NAND 11 +-#define CLK_820_PCIEB 12 +-#define CLK_820_ETHB 13 +-#define CLK_820_REF600 14 +-#define CLK_820_USBDEV 15 ++#define CLK_820_LEON 0 ++#define CLK_820_DMA_SGDMA 1 ++#define CLK_820_CIPHER 2 ++#define CLK_820_SD 3 ++#define CLK_820_SATA 4 ++#define CLK_820_AUDIO 5 ++#define CLK_820_USBMPH 6 ++#define CLK_820_ETHA 7 ++#define CLK_820_PCIEA 8 ++#define CLK_820_NAND 9 ++#define CLK_820_PCIEB 10 ++#define CLK_820_ETHB 11 ++#define CLK_820_REF600 12 ++#define CLK_820_USBDEV 13 + + #endif /* DT_CLOCK_OXSEMI_OX820_H */ diff --git a/target/linux/oxnas/patches-5.15/100-oxnas-clk-plla-pllb.patch b/target/linux/oxnas/patches-5.15/100-oxnas-clk-plla-pllb.patch new file mode 100644 index 0000000000..6c795c1d25 --- /dev/null +++ b/target/linux/oxnas/patches-5.15/100-oxnas-clk-plla-pllb.patch @@ -0,0 +1,273 @@ +--- a/drivers/clk/clk-oxnas.c ++++ b/drivers/clk/clk-oxnas.c +@@ -5,19 +5,42 @@ + * Copyright (C) 2016 Neil Armstrong + */ + ++#include ++#include + #include + #include + #include ++#include + #include + #include + #include + #include + #include + #include ++#include + + #include + #include + ++#define REF300_DIV_INT_SHIFT 8 ++#define REF300_DIV_FRAC_SHIFT 0 ++#define REF300_DIV_INT(val) ((val) << REF300_DIV_INT_SHIFT) ++#define REF300_DIV_FRAC(val) ((val) << REF300_DIV_FRAC_SHIFT) ++ ++#define PLLB_BYPASS 1 ++#define PLLB_ENSAT 3 ++#define PLLB_OUTDIV 4 ++#define PLLB_REFDIV 8 ++#define PLLB_DIV_INT_SHIFT 8 ++#define PLLB_DIV_FRAC_SHIFT 0 ++#define PLLB_DIV_INT(val) ((val) << PLLB_DIV_INT_SHIFT) ++#define PLLB_DIV_FRAC(val) ((val) << PLLB_DIV_FRAC_SHIFT) ++ ++#define PLLA_REFDIV_MASK 0x3F ++#define PLLA_REFDIV_SHIFT 8 ++#define PLLA_OUTDIV_MASK 0x7 ++#define PLLA_OUTDIV_SHIFT 4 ++ + /* Standard regmap gate clocks */ + struct clk_oxnas_gate { + struct clk_hw hw; +@@ -36,6 +59,135 @@ struct oxnas_stdclk_data { + #define CLK_SET_REGOFFSET 0x2c + #define CLK_CLR_REGOFFSET 0x30 + ++#define PLLA_CTRL0_REGOFFSET 0x1f0 ++#define PLLA_CTRL1_REGOFFSET 0x1f4 ++#define PLLB_CTRL0_REGOFFSET 0x1001f0 ++#define MHZ (1000 * 1000) ++ ++struct clk_oxnas_pll { ++ struct clk_hw hw; ++ struct device_node *devnode; ++ struct reset_control *rstc; ++ struct regmap *syscon; ++}; ++ ++#define to_clk_oxnas_pll(_hw) container_of(_hw, struct clk_oxnas_pll, hw) ++ ++static unsigned long plla_clk_recalc_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ struct clk_oxnas_pll *plla = to_clk_oxnas_pll(hw); ++ unsigned long fin = parent_rate; ++ unsigned long refdiv, outdiv; ++ unsigned int pll0, fbdiv; ++ ++ BUG_ON(regmap_read(plla->syscon, PLLA_CTRL0_REGOFFSET, &pll0)); ++ ++ refdiv = (pll0 >> PLLA_REFDIV_SHIFT) & PLLA_REFDIV_MASK; ++ refdiv += 1; ++ outdiv = (pll0 >> PLLA_OUTDIV_SHIFT) & PLLA_OUTDIV_MASK; ++ outdiv += 1; ++ ++ BUG_ON(regmap_read(plla->syscon, PLLA_CTRL1_REGOFFSET, &fbdiv)); ++ /* seems we will not be here when pll is bypassed, so ignore this ++ * case */ ++ ++ return fin / MHZ * fbdiv / (refdiv * outdiv) / 32768 * MHZ; ++} ++ ++static const char *pll_clk_parents[] = { ++ "oscillator", ++}; ++ ++static struct clk_ops plla_ops = { ++ .recalc_rate = plla_clk_recalc_rate, ++}; ++ ++static struct clk_init_data clk_plla_init = { ++ .name = "plla", ++ .ops = &plla_ops, ++ .parent_names = pll_clk_parents, ++ .num_parents = ARRAY_SIZE(pll_clk_parents), ++}; ++ ++static int pllb_clk_is_prepared(struct clk_hw *hw) ++{ ++ struct clk_oxnas_pll *pllb = to_clk_oxnas_pll(hw); ++ ++ return !!pllb->rstc; ++} ++ ++static int pllb_clk_prepare(struct clk_hw *hw) ++{ ++ struct clk_oxnas_pll *pllb = to_clk_oxnas_pll(hw); ++ ++ pllb->rstc = of_reset_control_get(pllb->devnode, NULL); ++ ++ return IS_ERR(pllb->rstc) ? PTR_ERR(pllb->rstc) : 0; ++} ++ ++static void pllb_clk_unprepare(struct clk_hw *hw) ++{ ++ struct clk_oxnas_pll *pllb = to_clk_oxnas_pll(hw); ++ ++ BUG_ON(IS_ERR(pllb->rstc)); ++ ++ reset_control_put(pllb->rstc); ++ pllb->rstc = NULL; ++} ++ ++static int pllb_clk_enable(struct clk_hw *hw) ++{ ++ struct clk_oxnas_pll *pllb = to_clk_oxnas_pll(hw); ++ ++ BUG_ON(IS_ERR(pllb->rstc)); ++ ++ /* put PLL into bypass */ ++ regmap_update_bits(pllb->syscon, PLLB_CTRL0_REGOFFSET, BIT(PLLB_BYPASS), BIT(PLLB_BYPASS)); ++ wmb(); ++ udelay(10); ++ reset_control_assert(pllb->rstc); ++ udelay(10); ++ /* set PLL B control information */ ++ regmap_write_bits(pllb->syscon, PLLB_CTRL0_REGOFFSET, 0xffff, ++ (1 << PLLB_ENSAT) | (1 << PLLB_OUTDIV) | (2 << PLLB_REFDIV)); ++ reset_control_deassert(pllb->rstc); ++ udelay(100); ++ regmap_update_bits(pllb->syscon, PLLB_CTRL0_REGOFFSET, BIT(PLLB_BYPASS), 0); ++ ++ return 0; ++} ++ ++static void pllb_clk_disable(struct clk_hw *hw) ++{ ++ struct clk_oxnas_pll *pllb = to_clk_oxnas_pll(hw); ++ ++ BUG_ON(IS_ERR(pllb->rstc)); ++ ++ /* put PLL into bypass */ ++ regmap_update_bits(pllb->syscon, PLLB_CTRL0_REGOFFSET, BIT(PLLB_BYPASS), BIT(PLLB_BYPASS)); ++ ++ wmb(); ++ udelay(10); ++ ++ reset_control_assert(pllb->rstc); ++} ++ ++static struct clk_ops pllb_ops = { ++ .prepare = pllb_clk_prepare, ++ .unprepare = pllb_clk_unprepare, ++ .is_prepared = pllb_clk_is_prepared, ++ .enable = pllb_clk_enable, ++ .disable = pllb_clk_disable, ++}; ++ ++static struct clk_init_data clk_pllb_init = { ++ .name = "pllb", ++ .ops = &pllb_ops, ++ .parent_names = pll_clk_parents, ++ .num_parents = ARRAY_SIZE(pll_clk_parents), ++}; ++ + static inline struct clk_oxnas_gate *to_clk_oxnas_gate(struct clk_hw *hw) + { + return container_of(hw, struct clk_oxnas_gate, hw); +@@ -249,3 +401,42 @@ static struct platform_driver oxnas_stdc + }, + }; + builtin_platform_driver(oxnas_stdclk_driver); ++ ++void __init oxnas_init_plla(struct device_node *np) ++{ ++ struct clk *clk; ++ struct clk_oxnas_pll *plla; ++ ++ plla = kmalloc(sizeof(*plla), GFP_KERNEL); ++ BUG_ON(!plla); ++ ++ plla->syscon = syscon_node_to_regmap(of_get_parent(np)); ++ plla->hw.init = &clk_plla_init; ++ plla->devnode = np; ++ plla->rstc = NULL; ++ clk = clk_register(NULL, &plla->hw); ++ BUG_ON(IS_ERR(clk)); ++ /* mark it as enabled */ ++ clk_prepare_enable(clk); ++ of_clk_add_provider(np, of_clk_src_simple_get, clk); ++} ++CLK_OF_DECLARE(oxnas_plla, "plxtech,nas782x-plla", oxnas_init_plla); ++ ++void __init oxnas_init_pllb(struct device_node *np) ++{ ++ struct clk *clk; ++ struct clk_oxnas_pll *pllb; ++ ++ pllb = kmalloc(sizeof(*pllb), GFP_KERNEL); ++ BUG_ON(!pllb); ++ ++ pllb->syscon = syscon_node_to_regmap(of_get_parent(np)); ++ pllb->hw.init = &clk_pllb_init; ++ pllb->devnode = np; ++ pllb->rstc = NULL; ++ ++ clk = clk_register(NULL, &pllb->hw); ++ BUG_ON(IS_ERR(clk)); ++ of_clk_add_provider(np, of_clk_src_simple_get, clk); ++} ++CLK_OF_DECLARE(oxnas_pllb, "plxtech,nas782x-pllb", oxnas_init_pllb); +--- a/arch/arm/boot/dts/ox820.dtsi ++++ b/arch/arm/boot/dts/ox820.dtsi +@@ -61,12 +61,6 @@ + clocks = <&osc>; + }; + +- plla: plla { +- compatible = "fixed-clock"; +- #clock-cells = <0>; +- clock-frequency = <850000000>; +- }; +- + armclk: armclk { + compatible = "fixed-factor-clock"; + #clock-cells = <0>; +@@ -266,6 +260,19 @@ + compatible = "oxsemi,ox820-stdclk", "oxsemi,ox810se-stdclk"; + #clock-cells = <1>; + }; ++ ++ plla: plla { ++ compatible = "plxtech,nas782x-plla"; ++ #clock-cells = <0>; ++ clocks = <&osc>; ++ }; ++ ++ pllb: pllb { ++ compatible = "plxtech,nas782x-pllb"; ++ #clock-cells = <0>; ++ clocks = <&osc>; ++ resets = <&reset RESET_PLLB>; ++ }; + }; + }; + +@@ -287,6 +294,13 @@ + clocks = <&armclk>; + }; + ++ watchdog@620 { ++ compatible = "mpcore_wdt"; ++ reg = <0x620 0x20>; ++ interrupts = ; ++ clocks = <&armclk>; ++ }; ++ + gic: interrupt-controller@1000 { + compatible = "arm,arm11mp-gic"; + interrupt-controller; diff --git a/target/linux/oxnas/patches-5.15/150-oxnas-restart.patch b/target/linux/oxnas/patches-5.15/150-oxnas-restart.patch new file mode 100644 index 0000000000..e16d6ee85c --- /dev/null +++ b/target/linux/oxnas/patches-5.15/150-oxnas-restart.patch @@ -0,0 +1,25 @@ +--- a/drivers/power/reset/Kconfig ++++ b/drivers/power/reset/Kconfig +@@ -148,6 +148,12 @@ config POWER_RESET_OXNAS + help + Restart support for OXNAS/PLXTECH OX820 SoC. + ++config POWER_RESET_OXNAS ++ bool "OXNAS SoC restart driver" ++ depends on ARCH_OXNAS ++ help ++ Restart support for OXNAS boards. ++ + config POWER_RESET_PIIX4_POWEROFF + tristate "Intel PIIX4 power-off driver" + depends on PCI +--- a/drivers/power/reset/Makefile ++++ b/drivers/power/reset/Makefile +@@ -19,6 +19,7 @@ obj-$(CONFIG_POWER_RESET_QCOM_PON) += qc + obj-$(CONFIG_POWER_RESET_OCELOT_RESET) += ocelot-reset.o + obj-$(CONFIG_POWER_RESET_PIIX4_POWEROFF) += piix4-poweroff.o + obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o ++obj-$(CONFIG_POWER_RESET_OXNAS) += oxnas-restart.o + obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o + obj-$(CONFIG_POWER_RESET_REGULATOR) += regulator-poweroff.o + obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o diff --git a/target/linux/oxnas/patches-5.15/320-oxnas-phy-pcie.patch b/target/linux/oxnas/patches-5.15/320-oxnas-phy-pcie.patch new file mode 100644 index 0000000000..7ee4daf0c5 --- /dev/null +++ b/target/linux/oxnas/patches-5.15/320-oxnas-phy-pcie.patch @@ -0,0 +1,44 @@ +--- a/arch/arm/boot/dts/ox820.dtsi ++++ b/arch/arm/boot/dts/ox820.dtsi +@@ -247,6 +247,15 @@ + }; + }; + ++ pcie_phy: pcie-phy@a00000 { ++ compatible = "oxsemi,ox820-pcie-phy"; ++ reg = <0xa00000 0x10>; ++ #phy-cells = <0>; ++ resets = <&reset RESET_PCIEPHY>; ++ reset-names = "phy"; ++ status = "disabled"; ++ }; ++ + sys: sys-ctrl@e00000 { + compatible = "oxsemi,ox820-sys-ctrl", "syscon", "simple-mfd"; + reg = <0xe00000 0x200000>; +--- a/drivers/phy/Kconfig ++++ b/drivers/phy/Kconfig +@@ -35,6 +35,13 @@ config PHY_LPC18XX_USB_OTG + This driver is need for USB0 support on LPC18xx/43xx and takes + care of enabling and clock setup. + ++config PHY_OXNAS ++ tristate "Oxford Semi. OX820 PCI-E PHY support" ++ depends on HAS_IOMEM && OF && (ARM || COMPILE_TEST) ++ select GENERIC_PHY ++ help ++ This option enables support for OXNAS OX820 SoC PCIE PHY. ++ + config PHY_PISTACHIO_USB + tristate "IMG Pistachio USB2.0 PHY driver" + depends on MIPS || COMPILE_TEST +--- a/drivers/phy/Makefile ++++ b/drivers/phy/Makefile +@@ -7,6 +7,7 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o + obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY) += phy-core-mipi-dphy.o + obj-$(CONFIG_PHY_CAN_TRANSCEIVER) += phy-can-transceiver.o + obj-$(CONFIG_PHY_LPC18XX_USB_OTG) += phy-lpc18xx-usb-otg.o ++obj-$(CONFIG_PHY_OXNAS) += phy-oxnas-pcie.o + obj-$(CONFIG_PHY_XGENE) += phy-xgene.o + obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o + obj-$(CONFIG_USB_LGM_PHY) += phy-lgm-usb.o diff --git a/target/linux/oxnas/patches-5.15/340-oxnas-pcie.patch b/target/linux/oxnas/patches-5.15/340-oxnas-pcie.patch new file mode 100644 index 0000000000..8de7ec5386 --- /dev/null +++ b/target/linux/oxnas/patches-5.15/340-oxnas-pcie.patch @@ -0,0 +1,122 @@ +--- a/drivers/pci/controller/Kconfig ++++ b/drivers/pci/controller/Kconfig +@@ -312,6 +312,11 @@ config PCIE_HISI_ERR + Say Y here if you want error handling support + for the PCIe controller's errors on HiSilicon HIP SoCs + ++config PCIE_OXNAS ++ bool "PLX Oxnas PCIe controller" ++ depends on ARCH_OXNAS ++ select PCIEPORTBUS ++ + source "drivers/pci/controller/dwc/Kconfig" + source "drivers/pci/controller/mobiveil/Kconfig" + source "drivers/pci/controller/cadence/Kconfig" +--- a/drivers/pci/controller/Makefile ++++ b/drivers/pci/controller/Makefile +@@ -33,6 +33,7 @@ obj-$(CONFIG_PCIE_ROCKCHIP_HOST) += pcie + obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o + obj-$(CONFIG_PCIE_MEDIATEK_GEN3) += pcie-mediatek-gen3.o + obj-$(CONFIG_PCIE_MICROCHIP_HOST) += pcie-microchip-host.o ++obj-$(CONFIG_PCIE_OXNAS) += pcie-oxnas.o + obj-$(CONFIG_VMD) += vmd.o + obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o + obj-$(CONFIG_PCI_LOONGSON) += pci-loongson.o +--- a/arch/arm/boot/dts/ox820.dtsi ++++ b/arch/arm/boot/dts/ox820.dtsi +@@ -289,7 +289,7 @@ + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; +- ranges = <0 0x47000000 0x1000000>; ++ ranges = <0 0x47000000 0x2000>; + + scu: scu@0 { + compatible = "arm,arm11mp-scu"; +@@ -318,5 +318,86 @@ + <0x100 0x500>; + }; + }; ++ ++ pcie0: pcie-controller@47c00000 { ++ compatible = "plxtech,nas782x-pcie"; ++ device_type = "pci"; ++ #address-cells = <3>; ++ #size-cells = <2>; ++ ++ /* flag & space bus address host address size */ ++ ranges = < 0x82000000 0 0x48000000 0x48000000 0 0x2000000 ++ 0xC2000000 0 0x4A000000 0x4A000000 0 0x1E00000 ++ 0x81000000 0 0x4BE00000 0x4BE00000 0 0x0100000 ++ 0x80000000 0 0x4BF00000 0x4BF00000 0 0x0100000>; ++ ++ bus-range = <0x00 0x7f>; ++ ++ /* cfg inbound translator */ ++ reg = <0x47c00000 0x1000>, <0x47d00000 0x100>; ++ ++ phys = <&pcie_phy>; ++ phy-names = "pcie-phy"; ++ ++ #interrupt-cells = <1>; ++ /* wild card mask, match all bus address & interrupt specifier */ ++ /* format: bus address mask, interrupt specifier mask */ ++ /* each bit 1 means need match, 0 means ignored when match */ ++ interrupt-map-mask = <0 0 0 0>; ++ /* format: a list of: bus address, interrupt specifier, ++ * parent interrupt controller & specifier */ ++ interrupt-map = <0 0 0 0 &gic 0 19 0x304>; ++ gpios = <&gpio1 12 0>; ++ clocks = <&stdclk CLK_820_PCIEA>, <&pllb>; ++ clock-names = "pcie", "busclk"; ++ resets = <&reset RESET_PCIEA>; ++ reset-names = "pcie"; ++ ++ plxtech,pcie-hcsl-bit = <2>; ++ plxtech,pcie-ctrl-offset = <0x120>; ++ plxtech,pcie-outbound-offset = <0x138>; ++ status = "disabled"; ++ }; ++ ++ pcie1: pcie-controller@47e00000 { ++ compatible = "plxtech,nas782x-pcie"; ++ device_type = "pci"; ++ #address-cells = <3>; ++ #size-cells = <2>; ++ ++ /* flag & space bus address host address size */ ++ ranges = < 0x82000000 0 0x4C000000 0x4C000000 0 0x2000000 ++ 0xC2000000 0 0x4E000000 0x4E000000 0 0x1E00000 ++ 0x81000000 0 0x4FE00000 0x4FE00000 0 0x0100000 ++ 0x80000000 0 0x4FF00000 0x4FF00000 0 0x0100000>; ++ ++ bus-range = <0x80 0xff>; ++ ++ /* cfg inbound translator */ ++ reg = <0x47e00000 0x1000>, <0x47f00000 0x100>; ++ ++ phys = <&pcie_phy>; ++ phy-names = "pcie-phy"; ++ ++ #interrupt-cells = <1>; ++ /* wild card mask, match all bus address & interrupt specifier */ ++ /* format: bus address mask, interrupt specifier mask */ ++ /* each bit 1 means need match, 0 means ignored when match */ ++ interrupt-map-mask = <0 0 0 0>; ++ /* format: a list of: bus address, interrupt specifier, ++ * parent interrupt controller & specifier */ ++ interrupt-map = <0 0 0 0 &gic 0 20 0x304>; ++ ++ /* gpios = <&gpio1 12 0>; */ ++ clocks = <&stdclk CLK_820_PCIEB>, <&pllb>; ++ clock-names = "pcie", "busclk"; ++ resets = <&reset RESET_PCIEB>; ++ reset-names = "pcie"; ++ ++ plxtech,pcie-hcsl-bit = <3>; ++ plxtech,pcie-ctrl-offset = <0x124>; ++ plxtech,pcie-outbound-offset = <0x174>; ++ status = "disabled"; ++ }; + }; + }; diff --git a/target/linux/oxnas/patches-5.15/500-oxnas-sata.patch b/target/linux/oxnas/patches-5.15/500-oxnas-sata.patch new file mode 100644 index 0000000000..d3ec2e2d48 --- /dev/null +++ b/target/linux/oxnas/patches-5.15/500-oxnas-sata.patch @@ -0,0 +1,60 @@ +--- a/drivers/ata/Kconfig ++++ b/drivers/ata/Kconfig +@@ -568,6 +568,14 @@ config SATA_VITESSE + + If unsure, say N. + ++config SATA_OXNAS ++ tristate "PLXTECH NAS782X SATA support" ++ select SATA_HOST ++ help ++ This option enables support for Nas782x Serial ATA controller. ++ ++ If unsure, say N. ++ + comment "PATA SFF controllers with BMDMA" + + config PATA_ALI +--- a/drivers/ata/Makefile ++++ b/drivers/ata/Makefile +@@ -46,6 +46,7 @@ obj-$(CONFIG_SATA_SVW) += sata_svw.o + obj-$(CONFIG_SATA_ULI) += sata_uli.o + obj-$(CONFIG_SATA_VIA) += sata_via.o + obj-$(CONFIG_SATA_VITESSE) += sata_vsc.o ++obj-$(CONFIG_SATA_OXNAS) += sata_oxnas.o + + # SFF PATA w/ BMDMA + obj-$(CONFIG_PATA_ALI) += pata_ali.o +--- a/arch/arm/boot/dts/ox820.dtsi ++++ b/arch/arm/boot/dts/ox820.dtsi +@@ -399,5 +399,20 @@ + plxtech,pcie-outbound-offset = <0x174>; + status = "disabled"; + }; ++ ++ sata: sata@45900000 { ++ compatible = "plxtech,nas782x-sata"; ++ /* ports dmactl sgdma */ ++ reg = <0x45900000 0x20000>, <0x459A0000 0x40>, <0x459B0000 0x20>, ++ /* core phy descriptors (optional) */ ++ <0x459E0000 0x2000>, <0x44900000 0x0C>, <0x50000000 0x1000>; ++ interrupts = ; ++ clocks = <&stdclk CLK_820_SATA>; ++ resets = <&reset RESET_SATA>, <&reset RESET_SATA_LINK>, <&reset RESET_SATA_PHY>; ++ reset-names = "sata", "link", "phy"; ++ nr-ports = <1>; ++ status = "disabled"; ++ }; ++ + }; + }; +--- a/arch/arm/boot/dts/ox820-cloudengines-pogoplug-series-3.dts ++++ b/arch/arm/boot/dts/ox820-cloudengines-pogoplug-series-3.dts +@@ -111,3 +111,7 @@ + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_etha_mdio>; + }; ++ ++&sata { ++ status = "okay"; ++}; diff --git a/target/linux/oxnas/patches-5.15/510-ox820-libata-leds.patch b/target/linux/oxnas/patches-5.15/510-ox820-libata-leds.patch new file mode 100644 index 0000000000..05ae9ba44b --- /dev/null +++ b/target/linux/oxnas/patches-5.15/510-ox820-libata-leds.patch @@ -0,0 +1,10 @@ +--- a/arch/arm/mach-oxnas/Kconfig ++++ b/arch/arm/mach-oxnas/Kconfig +@@ -2,6 +2,7 @@ + menuconfig ARCH_OXNAS + bool "Oxford Semiconductor OXNAS Family SoCs" + select ARCH_HAS_RESET_CONTROLLER ++ select ARCH_WANT_LIBATA_LEDS + select COMMON_CLK_OXNAS + select GPIOLIB + select MFD_SYSCON diff --git a/target/linux/oxnas/patches-5.15/800-oxnas-ehci.patch b/target/linux/oxnas/patches-5.15/800-oxnas-ehci.patch new file mode 100644 index 0000000000..23826f5363 --- /dev/null +++ b/target/linux/oxnas/patches-5.15/800-oxnas-ehci.patch @@ -0,0 +1,73 @@ +--- a/drivers/usb/host/Kconfig ++++ b/drivers/usb/host/Kconfig +@@ -339,6 +339,13 @@ config USB_OCTEON_EHCI + USB 2.0 device support. All CN6XXX based chips with USB are + supported. + ++config USB_EHCI_OXNAS ++ tristate "OXNAS EHCI Module" ++ depends on USB_EHCI_HCD && ARCH_OXNAS ++ select USB_EHCI_ROOT_HUB_TT ++ help ++ Enable support for the OX820 SOC's on-chip EHCI controller. ++ + endif # USB_EHCI_HCD + + config USB_OXU210HP_HCD +--- a/drivers/usb/host/Makefile ++++ b/drivers/usb/host/Makefile +@@ -46,6 +46,7 @@ obj-$(CONFIG_USB_EHCI_HCD_STI) += ehci-s + obj-$(CONFIG_USB_EHCI_EXYNOS) += ehci-exynos.o + obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o + obj-$(CONFIG_USB_EHCI_BRCMSTB) += ehci-brcm.o ++obj-$(CONFIG_USB_EHCI_OXNAS) += ehci-oxnas.o + + obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o + obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o +--- a/arch/arm/boot/dts/ox820.dtsi ++++ b/arch/arm/boot/dts/ox820.dtsi +@@ -106,6 +106,31 @@ + status = "disabled"; + }; + ++ ehci: ehci@40200100 { ++ compatible = "plxtech,nas782x-ehci"; ++ reg = <0x40200100 0xf00>; ++ interrupts = ; ++ clocks = <&stdclk CLK_820_USBMPH>, <&pllb>, <&stdclk CLK_820_REF600>; ++ clock-names = "usb", "refsrc", "phyref"; ++ resets = <&reset RESET_USBHS>, <&reset RESET_USBPHYA>, <&reset RESET_USBPHYB>; ++ reset-names = "host", "phya", "phyb"; ++ oxsemi,sys-ctrl = <&sys>; ++ /* Otherwise ref300 is used, which is derived from sata phy ++ * in that case, usb depends on sata initialization */ ++ /* FIXME: how to make this dependency explicit ? */ ++ oxsemi,ehci_use_pllb; ++ status = "disabled"; ++ ++ ehci_port1: port@1 { ++ reg = <1>; ++ #trigger-source-cells = <0>; ++ }; ++ ehci_port2: port@2 { ++ reg = <2>; ++ #trigger-source-cells = <0>; ++ }; ++ }; ++ + apb-bridge@44000000 { + #address-cells = <1>; + #size-cells = <1>; +--- a/arch/arm/boot/dts/ox820-cloudengines-pogoplug-series-3.dts ++++ b/arch/arm/boot/dts/ox820-cloudengines-pogoplug-series-3.dts +@@ -105,6 +105,10 @@ + }; + }; + ++&ehci { ++ status = "okay"; ++}; ++ + ða { + status = "okay"; + diff --git a/target/linux/oxnas/patches-5.15/996-generic-Mangle-bootloader-s-kernel-arguments.patch b/target/linux/oxnas/patches-5.15/996-generic-Mangle-bootloader-s-kernel-arguments.patch new file mode 100644 index 0000000000..8cf935ad12 --- /dev/null +++ b/target/linux/oxnas/patches-5.15/996-generic-Mangle-bootloader-s-kernel-arguments.patch @@ -0,0 +1,189 @@ +From 71270226b14733a4b1f2cde58ea9265caa50b38d Mon Sep 17 00:00:00 2001 +From: Adrian Panella +Date: Thu, 9 Mar 2017 09:37:17 +0100 +Subject: [PATCH 67/69] generic: Mangle bootloader's kernel arguments + +The command-line arguments provided by the boot loader will be +appended to a new device tree property: bootloader-args. +If there is a property "append-rootblock" in DT under /chosen +and a root= option in bootloaders command line it will be parsed +and added to DT bootargs with the form: XX. +Only command line ATAG will be processed, the rest of the ATAGs +sent by bootloader will be ignored. +This is usefull in dual boot systems, to get the current root partition +without afecting the rest of the system. + +Signed-off-by: Adrian Panella +--- + arch/arm/Kconfig | 11 +++++ + arch/arm/boot/compressed/atags_to_fdt.c | 72 ++++++++++++++++++++++++++++++++- + init/main.c | 16 ++++++++ + 3 files changed, 98 insertions(+), 1 deletion(-) + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1727,6 +1727,17 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN + The command-line arguments provided by the boot loader will be + appended to the the device tree bootargs property. + ++config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE ++ bool "Append rootblock parsing bootloader's kernel arguments" ++ help ++ The command-line arguments provided by the boot loader will be ++ appended to a new device tree property: bootloader-args. ++ If there is a property "append-rootblock" in DT under /chosen ++ and a root= option in bootloaders command line it will be parsed ++ and added to DT bootargs with the form: XX. ++ Only command line ATAG will be processed, the rest of the ATAGs ++ sent by bootloader will be ignored. ++ + endchoice + + config CMDLINE +--- a/arch/arm/boot/compressed/atags_to_fdt.c ++++ b/arch/arm/boot/compressed/atags_to_fdt.c +@@ -5,6 +5,8 @@ + + #if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND) + #define do_extend_cmdline 1 ++#elif defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) ++#define do_extend_cmdline 1 + #else + #define do_extend_cmdline 0 + #endif +@@ -69,6 +71,59 @@ static uint32_t get_cell_size(const void + return cell_size; + } + ++#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) ++ ++static char *append_rootblock(char *dest, const char *str, int len, void *fdt) ++{ ++ char *ptr, *end; ++ char *root="root="; ++ int i, l; ++ const char *rootblock; ++ ++ //ARM doesn't have __HAVE_ARCH_STRSTR, so search manually ++ ptr = str - 1; ++ ++ do { ++ //first find an 'r' at the begining or after a space ++ do { ++ ptr++; ++ ptr = strchr(ptr, 'r'); ++ if(!ptr) return dest; ++ ++ } while (ptr != str && *(ptr-1) != ' '); ++ ++ //then check for the rest ++ for(i = 1; i <= 4; i++) ++ if(*(ptr+i) != *(root+i)) break; ++ ++ } while (i != 5); ++ ++ end = strchr(ptr, ' '); ++ end = end ? (end - 1) : (strchr(ptr, 0) - 1); ++ ++ //find partition number (assumes format root=/dev/mtdXX | /dev/mtdblockXX | yy:XX ) ++ for( i = 0; end >= ptr && *end >= '0' && *end <= '9'; end--, i++); ++ ptr = end + 1; ++ ++ /* if append-rootblock property is set use it to append to command line */ ++ rootblock = getprop(fdt, "/chosen", "append-rootblock", &l); ++ if(rootblock != NULL) { ++ if(*dest != ' ') { ++ *dest = ' '; ++ dest++; ++ len++; ++ } ++ if (len + l + i <= COMMAND_LINE_SIZE) { ++ memcpy(dest, rootblock, l); ++ dest += l - 1; ++ memcpy(dest, ptr, i); ++ dest += i; ++ } ++ } ++ return dest; ++} ++#endif ++ + static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) + { + char cmdline[COMMAND_LINE_SIZE]; +@@ -88,12 +143,21 @@ static void merge_fdt_bootargs(void *fdt + + /* and append the ATAG_CMDLINE */ + if (fdt_cmdline) { ++ ++#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) ++ //save original bootloader args ++ //and append ubi.mtd with root partition number to current cmdline ++ setprop_string(fdt, "/chosen", "bootloader-args", fdt_cmdline); ++ ptr = append_rootblock(ptr, fdt_cmdline, len, fdt); ++ ++#else + len = strlen(fdt_cmdline); + if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) { + *ptr++ = ' '; + memcpy(ptr, fdt_cmdline, len); + ptr += len; + } ++#endif + } + *ptr = '\0'; + +@@ -168,7 +232,9 @@ int atags_to_fdt(void *atag_list, void * + else + setprop_string(fdt, "/chosen", "bootargs", + atag->u.cmdline.cmdline); +- } else if (atag->hdr.tag == ATAG_MEM) { ++ } ++#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE ++ else if (atag->hdr.tag == ATAG_MEM) { + if (memcount >= sizeof(mem_reg_property)/4) + continue; + if (!atag->u.mem.size) +@@ -212,6 +278,10 @@ int atags_to_fdt(void *atag_list, void * + setprop(fdt, "/memory", "reg", mem_reg_property, + 4 * memcount * memsize); + } ++#else ++ ++ } ++#endif + + return fdt_pack(fdt); + } +--- a/init/main.c ++++ b/init/main.c +@@ -114,6 +114,10 @@ + + #include + ++#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) ++#include ++#endif ++ + static int kernel_init(void *); + + extern void init_IRQ(void); +@@ -991,6 +995,18 @@ asmlinkage __visible void __init __no_sa + page_alloc_init(); + + pr_notice("Kernel command line: %s\n", saved_command_line); ++ ++#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) ++ //Show bootloader's original command line for reference ++ if(of_chosen) { ++ const char *prop = of_get_property(of_chosen, "bootloader-args", NULL); ++ if(prop) ++ pr_notice("Bootloader command line (ignored): %s\n", prop); ++ else ++ pr_notice("Bootloader command line not present\n"); ++ } ++#endif ++ + /* parameters may set static keys */ + jump_label_init(); + parse_early_param(); diff --git a/target/linux/oxnas/patches-5.15/999-libata-hacks.patch b/target/linux/oxnas/patches-5.15/999-libata-hacks.patch new file mode 100644 index 0000000000..73700f5c61 --- /dev/null +++ b/target/linux/oxnas/patches-5.15/999-libata-hacks.patch @@ -0,0 +1,57 @@ +--- a/drivers/ata/libata-core.c ++++ b/drivers/ata/libata-core.c +@@ -1531,6 +1531,14 @@ unsigned ata_exec_internal_sg(struct ata + return AC_ERR_SYSTEM; + } + ++ if (ap->ops->acquire_hw && !ap->ops->acquire_hw(ap, 0, 0)) { ++ spin_unlock_irqrestore(ap->lock, flags); ++ if (!ap->ops->acquire_hw(ap, 1, (2*HZ))) { ++ return AC_ERR_TIMEOUT; ++ } ++ spin_lock_irqsave(ap->lock, flags); ++ } ++ + /* initialize internal qc */ + qc = __ata_qc_from_tag(ap, ATA_TAG_INTERNAL); + +@@ -4583,6 +4591,9 @@ struct ata_queued_cmd *ata_qc_new_init(s + if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) + return NULL; + ++ if (ap->ops->qc_new && ap->ops->qc_new(ap)) ++ return NULL; ++ + /* libsas case */ + if (ap->flags & ATA_FLAG_SAS_HOST) { + tag = ata_sas_allocate_tag(ap); +@@ -4628,6 +4639,8 @@ void ata_qc_free(struct ata_queued_cmd * + qc->tag = ATA_TAG_POISON; + if (ap->flags & ATA_FLAG_SAS_HOST) + ata_sas_free_tag(tag, ap); ++ if (ap->ops->qc_free) ++ ap->ops->qc_free(qc); + } + } + +--- a/include/linux/libata.h ++++ b/include/linux/libata.h +@@ -917,6 +917,8 @@ struct ata_port_operations { + enum ata_completion_errors (*qc_prep)(struct ata_queued_cmd *qc); + unsigned int (*qc_issue)(struct ata_queued_cmd *qc); + bool (*qc_fill_rtf)(struct ata_queued_cmd *qc); ++ int (*qc_new)(struct ata_port *ap); ++ void (*qc_free)(struct ata_queued_cmd *qc); + + /* + * Configuration and exception handling +@@ -1007,6 +1009,9 @@ struct ata_port_operations { + void (*phy_reset)(struct ata_port *ap); + void (*eng_timeout)(struct ata_port *ap); + ++ int (*acquire_hw)(struct ata_port *ap, int may_sleep, ++ int timeout_jiffies); ++ + /* + * ->inherits must be the last field and all the preceding + * fields must be pointers. From 0c45db5560df47a0344a21c2443a4f2889c42ac8 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sat, 10 Sep 2022 21:18:10 +0200 Subject: [PATCH 040/114] CI: package kmods in kernel workflow Actually package kmods in kernel workflow to catch dependency error and other problem that may arise from kmods packaging. Signed-off-by: Christian Marangi --- .github/workflows/kernel.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/kernel.yml b/.github/workflows/kernel.yml index 43f843b256..4f8c6b9317 100644 --- a/.github/workflows/kernel.yml +++ b/.github/workflows/kernel.yml @@ -158,6 +158,11 @@ jobs: working-directory: openwrt run: make target/compile -j$(nproc) BUILD_LOG=1 + - name: Build Kernel Kmods + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: make package/linux/compile -j$(nproc) BUILD_LOG=1 + - name: Upload logs if: failure() uses: actions/upload-artifact@v2 From f34690e487e13ee772b2dca3e7fab2a2bd1e77a1 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 9 Sep 2022 16:01:21 -0400 Subject: [PATCH 041/114] depends.mk: fix typo in rdep function Just like later in the file, the precursor to _check _check.1 is supposed to be moved to _check before it is touched. This line would error if it was ever run. Signed-off-by: Michael Pratt --- include/depends.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/depends.mk b/include/depends.mk index 465e4e952a..073fb03632 100644 --- a/include/depends.mk +++ b/include/depends.mk @@ -27,7 +27,7 @@ ifneq ($(wildcard $(2)),) { [ \! -f "$(3)" ] || diff $(3) $(3).1 >/dev/null; } && \ ) \ { \ - [ -f "$(2)_check.1" ] && mv "$(2)_check.1"; \ + [ -f "$(2)_check.1" ] && mv "$(2)_check.1" "$(2)_check"; \ $(TOPDIR)/scripts/timestamp.pl $(DEP_FINDPARAMS) $(4) -n $(2) $(1) && { \ $(call debug_eval,$(SUBDIR),r,echo "No need to rebuild $(2)";) \ touch -r "$(2)" "$(2)_check"; \ From d7382cc0e4446d4db1978055b0ba59259ac66751 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Sat, 10 Sep 2022 23:41:55 +0200 Subject: [PATCH 042/114] toolchain: gcc: improve patch handling by introducing major version Every minor version bump of a major version will result in a huge patch diff because of the moving of all the patches from version e.g. 11.2.0 to 11.3.0. This commit only use the major version for the patch folders to differentiate between the different gcc versions. This will significantly improve the reviewing of the smaller version bump patches and help to see what really changed in a minor version bump. Signed-off-by: Nick Hainke --- toolchain/gcc/common.mk | 3 ++- .../10.3.0 => patches-10.x}/002-case_insensitive.patch | 0 .../{patches/10.3.0 => patches-10.x}/010-documentation.patch | 0 .../10.3.0 => patches-10.x}/110-Fix-MIPS-PR-84790.patch | 0 .../gcc/{patches/10.3.0 => patches-10.x}/230-musl_libssp.patch | 0 .../300-mips_Os_cpu_rtx_cost_model.patch | 0 .../10.3.0 => patches-10.x}/810-arm-softfloat-libgcc.patch | 0 .../gcc/{patches/10.3.0 => patches-10.x}/820-libgcc_pic.patch | 0 .../840-armv4_pass_fix-v4bx_to_ld.patch | 0 .../10.3.0 => patches-10.x}/850-use_shared_libgcc.patch | 0 .../10.3.0 => patches-10.x}/851-libgcc_no_compat.patch | 0 .../10.3.0 => patches-10.x}/870-ppc_no_crtsavres.patch | 0 .../{patches/10.3.0 => patches-10.x}/881-no_tm_section.patch | 0 .../{patches/10.3.0 => patches-10.x}/900-bad-mips16-crt.patch | 0 .../gcc/{patches/10.3.0 => patches-10.x}/910-mbsd_multi.patch | 0 .../10.3.0 => patches-10.x}/920-specs_nonfatal_getenv.patch | 0 .../10.3.0 => patches-10.x}/930-fix-mips-noexecstack.patch | 0 .../931-libffi-fix-MIPS-softfloat-build-issue.patch | 0 ...60-gotools-fix-compilation-when-making-cross-compiler.patch | 0 .../11.3.0 => patches-11.x}/002-case_insensitive.patch | 0 .../{patches/11.3.0 => patches-11.x}/010-documentation.patch | 0 ...011-v12-configure-define-TARGET_LIBC_GNUSTACK-on-musl.patch | 0 .../11.3.0 => patches-11.x}/110-Fix-MIPS-PR-84790.patch | 0 .../gcc/{patches/11.3.0 => patches-11.x}/230-musl_libssp.patch | 0 .../300-mips_Os_cpu_rtx_cost_model.patch | 0 .../11.3.0 => patches-11.x}/810-arm-softfloat-libgcc.patch | 0 .../gcc/{patches/11.3.0 => patches-11.x}/820-libgcc_pic.patch | 0 .../840-armv4_pass_fix-v4bx_to_ld.patch | 0 .../11.3.0 => patches-11.x}/850-use_shared_libgcc.patch | 0 .../11.3.0 => patches-11.x}/851-libgcc_no_compat.patch | 0 .../11.3.0 => patches-11.x}/870-ppc_no_crtsavres.patch | 0 .../{patches/11.3.0 => patches-11.x}/881-no_tm_section.patch | 0 .../{patches/11.3.0 => patches-11.x}/900-bad-mips16-crt.patch | 0 .../gcc/{patches/11.3.0 => patches-11.x}/910-mbsd_multi.patch | 0 .../11.3.0 => patches-11.x}/920-specs_nonfatal_getenv.patch | 0 .../931-libffi-fix-MIPS-softfloat-build-issue.patch | 0 ...60-gotools-fix-compilation-when-making-cross-compiler.patch | 0 .../11.3.0 => patches-11.x}/970-macos_arm64-building-fix.patch | 0 .../12.2.0 => patches-12.x}/002-case_insensitive.patch | 0 .../{patches/12.2.0 => patches-12.x}/010-documentation.patch | 0 .../12.2.0 => patches-12.x}/110-Fix-MIPS-PR-84790.patch | 0 .../gcc/{patches/12.2.0 => patches-12.x}/230-musl_libssp.patch | 0 .../300-mips_Os_cpu_rtx_cost_model.patch | 0 .../12.2.0 => patches-12.x}/810-arm-softfloat-libgcc.patch | 0 .../gcc/{patches/12.2.0 => patches-12.x}/820-libgcc_pic.patch | 0 .../840-armv4_pass_fix-v4bx_to_ld.patch | 0 .../12.2.0 => patches-12.x}/850-use_shared_libgcc.patch | 0 .../12.2.0 => patches-12.x}/851-libgcc_no_compat.patch | 0 .../12.2.0 => patches-12.x}/870-ppc_no_crtsavres.patch | 0 .../{patches/12.2.0 => patches-12.x}/881-no_tm_section.patch | 0 .../{patches/12.2.0 => patches-12.x}/900-bad-mips16-crt.patch | 0 .../gcc/{patches/12.2.0 => patches-12.x}/910-mbsd_multi.patch | 0 .../12.2.0 => patches-12.x}/920-specs_nonfatal_getenv.patch | 0 ...60-gotools-fix-compilation-when-making-cross-compiler.patch | 0 .../12.2.0 => patches-12.x}/970-macos_arm64-building-fix.patch | 0 .../{patches/8.4.0 => patches-8.x}/002-case_insensitive.patch | 0 .../gcc/{patches/8.4.0 => patches-8.x}/010-documentation.patch | 0 .../{patches/8.4.0 => patches-8.x}/110-Fix-MIPS-PR-84790.patch | 0 .../gcc/{patches/8.4.0 => patches-8.x}/230-musl_libssp.patch | 0 .../8.4.0 => patches-8.x}/300-mips_Os_cpu_rtx_cost_model.patch | 0 .../8.4.0 => patches-8.x}/800-arm_v5te_no_ldrd_strd.patch | 0 .../8.4.0 => patches-8.x}/810-arm-softfloat-libgcc.patch | 0 .../gcc/{patches/8.4.0 => patches-8.x}/820-libgcc_pic.patch | 0 .../8.4.0 => patches-8.x}/840-armv4_pass_fix-v4bx_to_ld.patch | 0 .../{patches/8.4.0 => patches-8.x}/850-use_shared_libgcc.patch | 0 .../{patches/8.4.0 => patches-8.x}/851-libgcc_no_compat.patch | 0 .../{patches/8.4.0 => patches-8.x}/870-ppc_no_crtsavres.patch | 0 .../gcc/{patches/8.4.0 => patches-8.x}/881-no_tm_section.patch | 0 .../{patches/8.4.0 => patches-8.x}/900-bad-mips16-crt.patch | 0 .../gcc/{patches/8.4.0 => patches-8.x}/910-mbsd_multi.patch | 0 .../8.4.0 => patches-8.x}/920-specs_nonfatal_getenv.patch | 0 .../8.4.0 => patches-8.x}/930-fix-mips-noexecstack.patch | 0 .../931-libffi-fix-MIPS-softfloat-build-issue.patch | 0 ...60-gotools-fix-compilation-when-making-cross-compiler.patch | 0 74 files changed, 2 insertions(+), 1 deletion(-) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/002-case_insensitive.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/010-documentation.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/110-Fix-MIPS-PR-84790.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/230-musl_libssp.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/300-mips_Os_cpu_rtx_cost_model.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/810-arm-softfloat-libgcc.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/820-libgcc_pic.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/840-armv4_pass_fix-v4bx_to_ld.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/850-use_shared_libgcc.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/851-libgcc_no_compat.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/870-ppc_no_crtsavres.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/881-no_tm_section.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/900-bad-mips16-crt.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/910-mbsd_multi.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/920-specs_nonfatal_getenv.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/930-fix-mips-noexecstack.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/931-libffi-fix-MIPS-softfloat-build-issue.patch (100%) rename toolchain/gcc/{patches/10.3.0 => patches-10.x}/960-gotools-fix-compilation-when-making-cross-compiler.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/002-case_insensitive.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/010-documentation.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/011-v12-configure-define-TARGET_LIBC_GNUSTACK-on-musl.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/110-Fix-MIPS-PR-84790.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/230-musl_libssp.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/300-mips_Os_cpu_rtx_cost_model.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/810-arm-softfloat-libgcc.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/820-libgcc_pic.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/840-armv4_pass_fix-v4bx_to_ld.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/850-use_shared_libgcc.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/851-libgcc_no_compat.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/870-ppc_no_crtsavres.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/881-no_tm_section.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/900-bad-mips16-crt.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/910-mbsd_multi.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/920-specs_nonfatal_getenv.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/931-libffi-fix-MIPS-softfloat-build-issue.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/960-gotools-fix-compilation-when-making-cross-compiler.patch (100%) rename toolchain/gcc/{patches/11.3.0 => patches-11.x}/970-macos_arm64-building-fix.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/002-case_insensitive.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/010-documentation.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/110-Fix-MIPS-PR-84790.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/230-musl_libssp.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/300-mips_Os_cpu_rtx_cost_model.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/810-arm-softfloat-libgcc.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/820-libgcc_pic.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/840-armv4_pass_fix-v4bx_to_ld.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/850-use_shared_libgcc.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/851-libgcc_no_compat.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/870-ppc_no_crtsavres.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/881-no_tm_section.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/900-bad-mips16-crt.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/910-mbsd_multi.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/920-specs_nonfatal_getenv.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/960-gotools-fix-compilation-when-making-cross-compiler.patch (100%) rename toolchain/gcc/{patches/12.2.0 => patches-12.x}/970-macos_arm64-building-fix.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/002-case_insensitive.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/010-documentation.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/110-Fix-MIPS-PR-84790.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/230-musl_libssp.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/300-mips_Os_cpu_rtx_cost_model.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/800-arm_v5te_no_ldrd_strd.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/810-arm-softfloat-libgcc.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/820-libgcc_pic.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/840-armv4_pass_fix-v4bx_to_ld.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/850-use_shared_libgcc.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/851-libgcc_no_compat.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/870-ppc_no_crtsavres.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/881-no_tm_section.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/900-bad-mips16-crt.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/910-mbsd_multi.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/920-specs_nonfatal_getenv.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/930-fix-mips-noexecstack.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/931-libffi-fix-MIPS-softfloat-build-issue.patch (100%) rename toolchain/gcc/{patches/8.4.0 => patches-8.x}/960-gotools-fix-compilation-when-making-cross-compiler.patch (100%) diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk index f116af7e1a..83884dd54c 100644 --- a/toolchain/gcc/common.mk +++ b/toolchain/gcc/common.mk @@ -23,6 +23,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gcc GCC_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION)) PKG_VERSION:=$(firstword $(subst +, ,$(GCC_VERSION))) +GCC_MAJOR_VERSION:=$(word 1,$(subst ., ,$(PKG_VERSION))) GCC_DIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION) @@ -44,7 +45,7 @@ ifeq ($(PKG_VERSION),12.2.0) PKG_HASH:=e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff endif -PATCH_DIR=../patches/$(GCC_VERSION) +PATCH_DIR=../patches-$(GCC_MAJOR_VERSION).x BUGURL=http://bugs.openwrt.org/ PKGVERSION=OpenWrt GCC $(PKG_VERSION) $(REVISION) diff --git a/toolchain/gcc/patches/10.3.0/002-case_insensitive.patch b/toolchain/gcc/patches-10.x/002-case_insensitive.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/002-case_insensitive.patch rename to toolchain/gcc/patches-10.x/002-case_insensitive.patch diff --git a/toolchain/gcc/patches/10.3.0/010-documentation.patch b/toolchain/gcc/patches-10.x/010-documentation.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/010-documentation.patch rename to toolchain/gcc/patches-10.x/010-documentation.patch diff --git a/toolchain/gcc/patches/10.3.0/110-Fix-MIPS-PR-84790.patch b/toolchain/gcc/patches-10.x/110-Fix-MIPS-PR-84790.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/110-Fix-MIPS-PR-84790.patch rename to toolchain/gcc/patches-10.x/110-Fix-MIPS-PR-84790.patch diff --git a/toolchain/gcc/patches/10.3.0/230-musl_libssp.patch b/toolchain/gcc/patches-10.x/230-musl_libssp.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/230-musl_libssp.patch rename to toolchain/gcc/patches-10.x/230-musl_libssp.patch diff --git a/toolchain/gcc/patches/10.3.0/300-mips_Os_cpu_rtx_cost_model.patch b/toolchain/gcc/patches-10.x/300-mips_Os_cpu_rtx_cost_model.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/300-mips_Os_cpu_rtx_cost_model.patch rename to toolchain/gcc/patches-10.x/300-mips_Os_cpu_rtx_cost_model.patch diff --git a/toolchain/gcc/patches/10.3.0/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches-10.x/810-arm-softfloat-libgcc.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/810-arm-softfloat-libgcc.patch rename to toolchain/gcc/patches-10.x/810-arm-softfloat-libgcc.patch diff --git a/toolchain/gcc/patches/10.3.0/820-libgcc_pic.patch b/toolchain/gcc/patches-10.x/820-libgcc_pic.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/820-libgcc_pic.patch rename to toolchain/gcc/patches-10.x/820-libgcc_pic.patch diff --git a/toolchain/gcc/patches/10.3.0/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches-10.x/840-armv4_pass_fix-v4bx_to_ld.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/840-armv4_pass_fix-v4bx_to_ld.patch rename to toolchain/gcc/patches-10.x/840-armv4_pass_fix-v4bx_to_ld.patch diff --git a/toolchain/gcc/patches/10.3.0/850-use_shared_libgcc.patch b/toolchain/gcc/patches-10.x/850-use_shared_libgcc.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/850-use_shared_libgcc.patch rename to toolchain/gcc/patches-10.x/850-use_shared_libgcc.patch diff --git a/toolchain/gcc/patches/10.3.0/851-libgcc_no_compat.patch b/toolchain/gcc/patches-10.x/851-libgcc_no_compat.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/851-libgcc_no_compat.patch rename to toolchain/gcc/patches-10.x/851-libgcc_no_compat.patch diff --git a/toolchain/gcc/patches/10.3.0/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches-10.x/870-ppc_no_crtsavres.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/870-ppc_no_crtsavres.patch rename to toolchain/gcc/patches-10.x/870-ppc_no_crtsavres.patch diff --git a/toolchain/gcc/patches/10.3.0/881-no_tm_section.patch b/toolchain/gcc/patches-10.x/881-no_tm_section.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/881-no_tm_section.patch rename to toolchain/gcc/patches-10.x/881-no_tm_section.patch diff --git a/toolchain/gcc/patches/10.3.0/900-bad-mips16-crt.patch b/toolchain/gcc/patches-10.x/900-bad-mips16-crt.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/900-bad-mips16-crt.patch rename to toolchain/gcc/patches-10.x/900-bad-mips16-crt.patch diff --git a/toolchain/gcc/patches/10.3.0/910-mbsd_multi.patch b/toolchain/gcc/patches-10.x/910-mbsd_multi.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/910-mbsd_multi.patch rename to toolchain/gcc/patches-10.x/910-mbsd_multi.patch diff --git a/toolchain/gcc/patches/10.3.0/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches-10.x/920-specs_nonfatal_getenv.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/920-specs_nonfatal_getenv.patch rename to toolchain/gcc/patches-10.x/920-specs_nonfatal_getenv.patch diff --git a/toolchain/gcc/patches/10.3.0/930-fix-mips-noexecstack.patch b/toolchain/gcc/patches-10.x/930-fix-mips-noexecstack.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/930-fix-mips-noexecstack.patch rename to toolchain/gcc/patches-10.x/930-fix-mips-noexecstack.patch diff --git a/toolchain/gcc/patches/10.3.0/931-libffi-fix-MIPS-softfloat-build-issue.patch b/toolchain/gcc/patches-10.x/931-libffi-fix-MIPS-softfloat-build-issue.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/931-libffi-fix-MIPS-softfloat-build-issue.patch rename to toolchain/gcc/patches-10.x/931-libffi-fix-MIPS-softfloat-build-issue.patch diff --git a/toolchain/gcc/patches/10.3.0/960-gotools-fix-compilation-when-making-cross-compiler.patch b/toolchain/gcc/patches-10.x/960-gotools-fix-compilation-when-making-cross-compiler.patch similarity index 100% rename from toolchain/gcc/patches/10.3.0/960-gotools-fix-compilation-when-making-cross-compiler.patch rename to toolchain/gcc/patches-10.x/960-gotools-fix-compilation-when-making-cross-compiler.patch diff --git a/toolchain/gcc/patches/11.3.0/002-case_insensitive.patch b/toolchain/gcc/patches-11.x/002-case_insensitive.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/002-case_insensitive.patch rename to toolchain/gcc/patches-11.x/002-case_insensitive.patch diff --git a/toolchain/gcc/patches/11.3.0/010-documentation.patch b/toolchain/gcc/patches-11.x/010-documentation.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/010-documentation.patch rename to toolchain/gcc/patches-11.x/010-documentation.patch diff --git a/toolchain/gcc/patches/11.3.0/011-v12-configure-define-TARGET_LIBC_GNUSTACK-on-musl.patch b/toolchain/gcc/patches-11.x/011-v12-configure-define-TARGET_LIBC_GNUSTACK-on-musl.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/011-v12-configure-define-TARGET_LIBC_GNUSTACK-on-musl.patch rename to toolchain/gcc/patches-11.x/011-v12-configure-define-TARGET_LIBC_GNUSTACK-on-musl.patch diff --git a/toolchain/gcc/patches/11.3.0/110-Fix-MIPS-PR-84790.patch b/toolchain/gcc/patches-11.x/110-Fix-MIPS-PR-84790.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/110-Fix-MIPS-PR-84790.patch rename to toolchain/gcc/patches-11.x/110-Fix-MIPS-PR-84790.patch diff --git a/toolchain/gcc/patches/11.3.0/230-musl_libssp.patch b/toolchain/gcc/patches-11.x/230-musl_libssp.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/230-musl_libssp.patch rename to toolchain/gcc/patches-11.x/230-musl_libssp.patch diff --git a/toolchain/gcc/patches/11.3.0/300-mips_Os_cpu_rtx_cost_model.patch b/toolchain/gcc/patches-11.x/300-mips_Os_cpu_rtx_cost_model.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/300-mips_Os_cpu_rtx_cost_model.patch rename to toolchain/gcc/patches-11.x/300-mips_Os_cpu_rtx_cost_model.patch diff --git a/toolchain/gcc/patches/11.3.0/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches-11.x/810-arm-softfloat-libgcc.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/810-arm-softfloat-libgcc.patch rename to toolchain/gcc/patches-11.x/810-arm-softfloat-libgcc.patch diff --git a/toolchain/gcc/patches/11.3.0/820-libgcc_pic.patch b/toolchain/gcc/patches-11.x/820-libgcc_pic.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/820-libgcc_pic.patch rename to toolchain/gcc/patches-11.x/820-libgcc_pic.patch diff --git a/toolchain/gcc/patches/11.3.0/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches-11.x/840-armv4_pass_fix-v4bx_to_ld.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/840-armv4_pass_fix-v4bx_to_ld.patch rename to toolchain/gcc/patches-11.x/840-armv4_pass_fix-v4bx_to_ld.patch diff --git a/toolchain/gcc/patches/11.3.0/850-use_shared_libgcc.patch b/toolchain/gcc/patches-11.x/850-use_shared_libgcc.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/850-use_shared_libgcc.patch rename to toolchain/gcc/patches-11.x/850-use_shared_libgcc.patch diff --git a/toolchain/gcc/patches/11.3.0/851-libgcc_no_compat.patch b/toolchain/gcc/patches-11.x/851-libgcc_no_compat.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/851-libgcc_no_compat.patch rename to toolchain/gcc/patches-11.x/851-libgcc_no_compat.patch diff --git a/toolchain/gcc/patches/11.3.0/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches-11.x/870-ppc_no_crtsavres.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/870-ppc_no_crtsavres.patch rename to toolchain/gcc/patches-11.x/870-ppc_no_crtsavres.patch diff --git a/toolchain/gcc/patches/11.3.0/881-no_tm_section.patch b/toolchain/gcc/patches-11.x/881-no_tm_section.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/881-no_tm_section.patch rename to toolchain/gcc/patches-11.x/881-no_tm_section.patch diff --git a/toolchain/gcc/patches/11.3.0/900-bad-mips16-crt.patch b/toolchain/gcc/patches-11.x/900-bad-mips16-crt.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/900-bad-mips16-crt.patch rename to toolchain/gcc/patches-11.x/900-bad-mips16-crt.patch diff --git a/toolchain/gcc/patches/11.3.0/910-mbsd_multi.patch b/toolchain/gcc/patches-11.x/910-mbsd_multi.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/910-mbsd_multi.patch rename to toolchain/gcc/patches-11.x/910-mbsd_multi.patch diff --git a/toolchain/gcc/patches/11.3.0/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches-11.x/920-specs_nonfatal_getenv.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/920-specs_nonfatal_getenv.patch rename to toolchain/gcc/patches-11.x/920-specs_nonfatal_getenv.patch diff --git a/toolchain/gcc/patches/11.3.0/931-libffi-fix-MIPS-softfloat-build-issue.patch b/toolchain/gcc/patches-11.x/931-libffi-fix-MIPS-softfloat-build-issue.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/931-libffi-fix-MIPS-softfloat-build-issue.patch rename to toolchain/gcc/patches-11.x/931-libffi-fix-MIPS-softfloat-build-issue.patch diff --git a/toolchain/gcc/patches/11.3.0/960-gotools-fix-compilation-when-making-cross-compiler.patch b/toolchain/gcc/patches-11.x/960-gotools-fix-compilation-when-making-cross-compiler.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/960-gotools-fix-compilation-when-making-cross-compiler.patch rename to toolchain/gcc/patches-11.x/960-gotools-fix-compilation-when-making-cross-compiler.patch diff --git a/toolchain/gcc/patches/11.3.0/970-macos_arm64-building-fix.patch b/toolchain/gcc/patches-11.x/970-macos_arm64-building-fix.patch similarity index 100% rename from toolchain/gcc/patches/11.3.0/970-macos_arm64-building-fix.patch rename to toolchain/gcc/patches-11.x/970-macos_arm64-building-fix.patch diff --git a/toolchain/gcc/patches/12.2.0/002-case_insensitive.patch b/toolchain/gcc/patches-12.x/002-case_insensitive.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/002-case_insensitive.patch rename to toolchain/gcc/patches-12.x/002-case_insensitive.patch diff --git a/toolchain/gcc/patches/12.2.0/010-documentation.patch b/toolchain/gcc/patches-12.x/010-documentation.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/010-documentation.patch rename to toolchain/gcc/patches-12.x/010-documentation.patch diff --git a/toolchain/gcc/patches/12.2.0/110-Fix-MIPS-PR-84790.patch b/toolchain/gcc/patches-12.x/110-Fix-MIPS-PR-84790.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/110-Fix-MIPS-PR-84790.patch rename to toolchain/gcc/patches-12.x/110-Fix-MIPS-PR-84790.patch diff --git a/toolchain/gcc/patches/12.2.0/230-musl_libssp.patch b/toolchain/gcc/patches-12.x/230-musl_libssp.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/230-musl_libssp.patch rename to toolchain/gcc/patches-12.x/230-musl_libssp.patch diff --git a/toolchain/gcc/patches/12.2.0/300-mips_Os_cpu_rtx_cost_model.patch b/toolchain/gcc/patches-12.x/300-mips_Os_cpu_rtx_cost_model.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/300-mips_Os_cpu_rtx_cost_model.patch rename to toolchain/gcc/patches-12.x/300-mips_Os_cpu_rtx_cost_model.patch diff --git a/toolchain/gcc/patches/12.2.0/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches-12.x/810-arm-softfloat-libgcc.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/810-arm-softfloat-libgcc.patch rename to toolchain/gcc/patches-12.x/810-arm-softfloat-libgcc.patch diff --git a/toolchain/gcc/patches/12.2.0/820-libgcc_pic.patch b/toolchain/gcc/patches-12.x/820-libgcc_pic.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/820-libgcc_pic.patch rename to toolchain/gcc/patches-12.x/820-libgcc_pic.patch diff --git a/toolchain/gcc/patches/12.2.0/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches-12.x/840-armv4_pass_fix-v4bx_to_ld.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/840-armv4_pass_fix-v4bx_to_ld.patch rename to toolchain/gcc/patches-12.x/840-armv4_pass_fix-v4bx_to_ld.patch diff --git a/toolchain/gcc/patches/12.2.0/850-use_shared_libgcc.patch b/toolchain/gcc/patches-12.x/850-use_shared_libgcc.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/850-use_shared_libgcc.patch rename to toolchain/gcc/patches-12.x/850-use_shared_libgcc.patch diff --git a/toolchain/gcc/patches/12.2.0/851-libgcc_no_compat.patch b/toolchain/gcc/patches-12.x/851-libgcc_no_compat.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/851-libgcc_no_compat.patch rename to toolchain/gcc/patches-12.x/851-libgcc_no_compat.patch diff --git a/toolchain/gcc/patches/12.2.0/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches-12.x/870-ppc_no_crtsavres.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/870-ppc_no_crtsavres.patch rename to toolchain/gcc/patches-12.x/870-ppc_no_crtsavres.patch diff --git a/toolchain/gcc/patches/12.2.0/881-no_tm_section.patch b/toolchain/gcc/patches-12.x/881-no_tm_section.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/881-no_tm_section.patch rename to toolchain/gcc/patches-12.x/881-no_tm_section.patch diff --git a/toolchain/gcc/patches/12.2.0/900-bad-mips16-crt.patch b/toolchain/gcc/patches-12.x/900-bad-mips16-crt.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/900-bad-mips16-crt.patch rename to toolchain/gcc/patches-12.x/900-bad-mips16-crt.patch diff --git a/toolchain/gcc/patches/12.2.0/910-mbsd_multi.patch b/toolchain/gcc/patches-12.x/910-mbsd_multi.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/910-mbsd_multi.patch rename to toolchain/gcc/patches-12.x/910-mbsd_multi.patch diff --git a/toolchain/gcc/patches/12.2.0/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches-12.x/920-specs_nonfatal_getenv.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/920-specs_nonfatal_getenv.patch rename to toolchain/gcc/patches-12.x/920-specs_nonfatal_getenv.patch diff --git a/toolchain/gcc/patches/12.2.0/960-gotools-fix-compilation-when-making-cross-compiler.patch b/toolchain/gcc/patches-12.x/960-gotools-fix-compilation-when-making-cross-compiler.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/960-gotools-fix-compilation-when-making-cross-compiler.patch rename to toolchain/gcc/patches-12.x/960-gotools-fix-compilation-when-making-cross-compiler.patch diff --git a/toolchain/gcc/patches/12.2.0/970-macos_arm64-building-fix.patch b/toolchain/gcc/patches-12.x/970-macos_arm64-building-fix.patch similarity index 100% rename from toolchain/gcc/patches/12.2.0/970-macos_arm64-building-fix.patch rename to toolchain/gcc/patches-12.x/970-macos_arm64-building-fix.patch diff --git a/toolchain/gcc/patches/8.4.0/002-case_insensitive.patch b/toolchain/gcc/patches-8.x/002-case_insensitive.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/002-case_insensitive.patch rename to toolchain/gcc/patches-8.x/002-case_insensitive.patch diff --git a/toolchain/gcc/patches/8.4.0/010-documentation.patch b/toolchain/gcc/patches-8.x/010-documentation.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/010-documentation.patch rename to toolchain/gcc/patches-8.x/010-documentation.patch diff --git a/toolchain/gcc/patches/8.4.0/110-Fix-MIPS-PR-84790.patch b/toolchain/gcc/patches-8.x/110-Fix-MIPS-PR-84790.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/110-Fix-MIPS-PR-84790.patch rename to toolchain/gcc/patches-8.x/110-Fix-MIPS-PR-84790.patch diff --git a/toolchain/gcc/patches/8.4.0/230-musl_libssp.patch b/toolchain/gcc/patches-8.x/230-musl_libssp.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/230-musl_libssp.patch rename to toolchain/gcc/patches-8.x/230-musl_libssp.patch diff --git a/toolchain/gcc/patches/8.4.0/300-mips_Os_cpu_rtx_cost_model.patch b/toolchain/gcc/patches-8.x/300-mips_Os_cpu_rtx_cost_model.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/300-mips_Os_cpu_rtx_cost_model.patch rename to toolchain/gcc/patches-8.x/300-mips_Os_cpu_rtx_cost_model.patch diff --git a/toolchain/gcc/patches/8.4.0/800-arm_v5te_no_ldrd_strd.patch b/toolchain/gcc/patches-8.x/800-arm_v5te_no_ldrd_strd.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/800-arm_v5te_no_ldrd_strd.patch rename to toolchain/gcc/patches-8.x/800-arm_v5te_no_ldrd_strd.patch diff --git a/toolchain/gcc/patches/8.4.0/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches-8.x/810-arm-softfloat-libgcc.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/810-arm-softfloat-libgcc.patch rename to toolchain/gcc/patches-8.x/810-arm-softfloat-libgcc.patch diff --git a/toolchain/gcc/patches/8.4.0/820-libgcc_pic.patch b/toolchain/gcc/patches-8.x/820-libgcc_pic.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/820-libgcc_pic.patch rename to toolchain/gcc/patches-8.x/820-libgcc_pic.patch diff --git a/toolchain/gcc/patches/8.4.0/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches-8.x/840-armv4_pass_fix-v4bx_to_ld.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/840-armv4_pass_fix-v4bx_to_ld.patch rename to toolchain/gcc/patches-8.x/840-armv4_pass_fix-v4bx_to_ld.patch diff --git a/toolchain/gcc/patches/8.4.0/850-use_shared_libgcc.patch b/toolchain/gcc/patches-8.x/850-use_shared_libgcc.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/850-use_shared_libgcc.patch rename to toolchain/gcc/patches-8.x/850-use_shared_libgcc.patch diff --git a/toolchain/gcc/patches/8.4.0/851-libgcc_no_compat.patch b/toolchain/gcc/patches-8.x/851-libgcc_no_compat.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/851-libgcc_no_compat.patch rename to toolchain/gcc/patches-8.x/851-libgcc_no_compat.patch diff --git a/toolchain/gcc/patches/8.4.0/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches-8.x/870-ppc_no_crtsavres.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/870-ppc_no_crtsavres.patch rename to toolchain/gcc/patches-8.x/870-ppc_no_crtsavres.patch diff --git a/toolchain/gcc/patches/8.4.0/881-no_tm_section.patch b/toolchain/gcc/patches-8.x/881-no_tm_section.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/881-no_tm_section.patch rename to toolchain/gcc/patches-8.x/881-no_tm_section.patch diff --git a/toolchain/gcc/patches/8.4.0/900-bad-mips16-crt.patch b/toolchain/gcc/patches-8.x/900-bad-mips16-crt.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/900-bad-mips16-crt.patch rename to toolchain/gcc/patches-8.x/900-bad-mips16-crt.patch diff --git a/toolchain/gcc/patches/8.4.0/910-mbsd_multi.patch b/toolchain/gcc/patches-8.x/910-mbsd_multi.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/910-mbsd_multi.patch rename to toolchain/gcc/patches-8.x/910-mbsd_multi.patch diff --git a/toolchain/gcc/patches/8.4.0/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches-8.x/920-specs_nonfatal_getenv.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/920-specs_nonfatal_getenv.patch rename to toolchain/gcc/patches-8.x/920-specs_nonfatal_getenv.patch diff --git a/toolchain/gcc/patches/8.4.0/930-fix-mips-noexecstack.patch b/toolchain/gcc/patches-8.x/930-fix-mips-noexecstack.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/930-fix-mips-noexecstack.patch rename to toolchain/gcc/patches-8.x/930-fix-mips-noexecstack.patch diff --git a/toolchain/gcc/patches/8.4.0/931-libffi-fix-MIPS-softfloat-build-issue.patch b/toolchain/gcc/patches-8.x/931-libffi-fix-MIPS-softfloat-build-issue.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/931-libffi-fix-MIPS-softfloat-build-issue.patch rename to toolchain/gcc/patches-8.x/931-libffi-fix-MIPS-softfloat-build-issue.patch diff --git a/toolchain/gcc/patches/8.4.0/960-gotools-fix-compilation-when-making-cross-compiler.patch b/toolchain/gcc/patches-8.x/960-gotools-fix-compilation-when-making-cross-compiler.patch similarity index 100% rename from toolchain/gcc/patches/8.4.0/960-gotools-fix-compilation-when-making-cross-compiler.patch rename to toolchain/gcc/patches-8.x/960-gotools-fix-compilation-when-making-cross-compiler.patch From dccee21792b89031bcd801030de403f195d80278 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Wed, 7 Sep 2022 23:50:36 +0200 Subject: [PATCH 043/114] build: handle directory with whitespace in AUTOREMOVE clean Package with whitespace in their build directory are not correctly removed when CONFIG_AUTOREMOVE is enabled. This is caused by xargs that use whitespace as delimiters. To handle this use \0 as the delimiter and set find to use \0 as the delimiter. Signed-off-by: Christian Marangi --- include/host-build.mk | 4 ++-- include/package.mk | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/host-build.mk b/include/host-build.mk index 7f76eb1a2f..f06dd80230 100644 --- a/include/host-build.mk +++ b/include/host-build.mk @@ -198,8 +198,8 @@ ifndef DUMP ifneq ($(CONFIG_AUTOREMOVE),) host-compile: - $(FIND) $(HOST_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' | \ - $(XARGS) rm -rf + $(FIND) $(HOST_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -print0 | \ + $(XARGS) -0 rm -rf endif endef endif diff --git a/include/package.mk b/include/package.mk index 509ef61e08..5861533bf5 100644 --- a/include/package.mk +++ b/include/package.mk @@ -259,8 +259,8 @@ define Build/CoreTargets ifneq ($(CONFIG_AUTOREMOVE),) compile: -touch -r $(PKG_BUILD_DIR)/.built $(PKG_BUILD_DIR)/.autoremove 2>/dev/null >/dev/null - $(FIND) $(PKG_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -and -not -name '.pkgdir' | \ - $(XARGS) rm -rf + $(FIND) $(PKG_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -and -not -name '.pkgdir' -print0 | \ + $(XARGS) -0 rm -rf endif endef From 548db4980f92b05d63ef37de9441d0c0280d264e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Santamar=C3=ADa=20Rogado?= Date: Fri, 27 May 2022 23:50:10 +0200 Subject: [PATCH 044/114] ramips: ASUS RT-ACx5P phy[01]radio to phy[01]tpt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit phy[01]radio leaves the leds always on, if they are set through sysfs the leds get off. Set the triggers to phy[01]tpt to make them work. Signed-off-by: David Santamaría Rogado --- target/linux/ramips/dts/mt7621_asus_rt-acx5p.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/ramips/dts/mt7621_asus_rt-acx5p.dtsi b/target/linux/ramips/dts/mt7621_asus_rt-acx5p.dtsi index b71437bfe6..59b93db5de 100644 --- a/target/linux/ramips/dts/mt7621_asus_rt-acx5p.dtsi +++ b/target/linux/ramips/dts/mt7621_asus_rt-acx5p.dtsi @@ -40,13 +40,13 @@ wlan5g { label = "blue:wlan5g"; gpios = <&gpio 8 GPIO_ACTIVE_LOW>; - linux,default-trigger = "phy1radio"; + linux,default-trigger = "phy1tpt"; }; wlan2g { label = "blue:wlan2g"; gpios = <&gpio 10 GPIO_ACTIVE_LOW>; - linux,default-trigger = "phy0radio"; + linux,default-trigger = "phy0tpt"; }; }; }; From 4d014a7bd6d8fbfe7dc4cebd6c55d85601231fa4 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Sat, 10 Sep 2022 14:05:34 +0200 Subject: [PATCH 045/114] ipq40xx: add WAN LED mapping for GL-AP1300 Signed-off-by: David Bauer --- target/linux/ipq40xx/base-files/etc/board.d/01_leds | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/linux/ipq40xx/base-files/etc/board.d/01_leds b/target/linux/ipq40xx/base-files/etc/board.d/01_leds index 884b265dcb..0e473534f5 100644 --- a/target/linux/ipq40xx/base-files/etc/board.d/01_leds +++ b/target/linux/ipq40xx/base-files/etc/board.d/01_leds @@ -52,6 +52,9 @@ engenius,ens620ext) ucidef_set_led_netdev "lan1" "LAN1" "green:lan1" "eth0" ucidef_set_led_netdev "lan2" "LAN2" "green:lan2" "eth1" ;; +glinet,gl-ap1300) + ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1" + ;; mikrotik,cap-ac) ucidef_set_led_default "power" "POWER" "blue:power" "1" ucidef_set_led_default "user" "USER" "green:user" "0" From be6f0125514db8967a7181420db8ef20990bd93c Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 9 Sep 2022 12:28:08 -0700 Subject: [PATCH 046/114] prereq-build: fix python distutils detection Debian and by extension Ubuntu packages distutils in a suboptimal way where import distutils works but none of the methods do. This alternative check verifies that distutils is actually usable. Signed-off-by: Rosen Penev --- include/prereq-build.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/prereq-build.mk b/include/prereq-build.mk index 0a023c2c6f..67993cf7e3 100644 --- a/include/prereq-build.mk +++ b/include/prereq-build.mk @@ -188,7 +188,7 @@ $(eval $(call SetupHostCommand,python3,Please install Python >= 3.6, \ $(eval $(call TestHostCommand,python3-distutils, \ Please install the Python3 distutils module, \ - $(STAGING_DIR_HOST)/bin/python3 -c 'import distutils')) + $(STAGING_DIR_HOST)/bin/python3 -c 'from distutils import util')) $(eval $(call SetupHostCommand,file,Please install the 'file' package, \ file --version 2>&1 | grep file)) From 805be7e90eacf67f0fb3f65304fcd7a65cfc0418 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 9 Sep 2022 12:31:44 -0700 Subject: [PATCH 047/114] prereq-build: add check for stdlib One way to solve the python3 dependency check is to install python3-minimal instead of python3 on Debian based systems. Unfortunately, this results in a fairly unusable python. Added check for ntpath, which is how the issue originally presented itself. Signed-off-by: Rosen Penev --- include/prereq-build.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/prereq-build.mk b/include/prereq-build.mk index 67993cf7e3..e1687da370 100644 --- a/include/prereq-build.mk +++ b/include/prereq-build.mk @@ -190,6 +190,10 @@ $(eval $(call TestHostCommand,python3-distutils, \ Please install the Python3 distutils module, \ $(STAGING_DIR_HOST)/bin/python3 -c 'from distutils import util')) +$(eval $(call TestHostCommand,python3-stdlib, \ + Please install the Python3 stdlib module, \ + $(STAGING_DIR_HOST)/bin/python3 -c 'import ntpath')) + $(eval $(call SetupHostCommand,file,Please install the 'file' package, \ file --version 2>&1 | grep file)) From 470ca65bda154fb5a601c6bbe20e20646535563f Mon Sep 17 00:00:00 2001 From: David Bauer Date: Sun, 11 Sep 2022 16:23:03 +0200 Subject: [PATCH 048/114] ipq40xx: add GL-AP1300 label-mac-device Signed-off-by: David Bauer --- .../ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-gl-ap1300.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-gl-ap1300.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-gl-ap1300.dts index fa81bfbf52..b96f014dd2 100644 --- a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-gl-ap1300.dts +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-gl-ap1300.dts @@ -14,6 +14,7 @@ led-failsafe = &led_power; led-running = &led_power; led-upgrade = &led_power; + label-mac-device = &gmac0; }; memory { From 4133102898502c9bb453e8603b6c891aa103bce4 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 11 Sep 2022 14:26:25 +0100 Subject: [PATCH 049/114] kernel: modules: package kmod-crypto-essiv Package kernel module providing ESSIV support for block encryption. Signed-off-by: Daniel Golle --- package/kernel/linux/modules/crypto.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/package/kernel/linux/modules/crypto.mk b/package/kernel/linux/modules/crypto.mk index 35113e12d0..f8af5f0a3b 100644 --- a/package/kernel/linux/modules/crypto.mk +++ b/package/kernel/linux/modules/crypto.mk @@ -239,6 +239,18 @@ endef $(eval $(call KernelPackage,crypto-echainiv)) +define KernelPackage/crypto-essiv + TITLE:=ESSIV support for block encryption + DEPENDS:=+kmod-crypto-authenc + KCONFIG:=CONFIG_CRYPTO_ESSIV + FILES:= $(LINUX_DIR)/crypto/essiv.ko + AUTOLOAD:=$(call AutoLoad,10,essiv) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-essiv)) + + define KernelPackage/crypto-fcrypt TITLE:=FCRYPT cipher CryptoAPI module KCONFIG:=CONFIG_CRYPTO_FCRYPT From 56c2d15587dfe5285f1cf3bfb236c827bc446465 Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Sat, 12 Jun 2021 21:56:21 +0200 Subject: [PATCH 050/114] mediatek: do not use gpiod_set_raw_value() The polarity of the signal is set in the device dts. Signed-off-by: Sven Wegener --- target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c index 9c68d40eec..c5d668836b 100644 --- a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c +++ b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c @@ -68,7 +68,7 @@ static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar) led_msg[UBNT_LEDBAR_TRANSACTION_GREEN_IDX] = ledbar->led_green.brightness; led_msg[UBNT_LEDBAR_TRANSACTION_RED_IDX] = ledbar->led_red.brightness; - gpiod_set_raw_value(ledbar->enable_gpio, 1); + gpiod_set_value(ledbar->enable_gpio, 1); msleep(10); @@ -88,7 +88,7 @@ static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar) msleep(10); out_gpio: - gpiod_set_raw_value(ledbar->enable_gpio, 0); + gpiod_set_value(ledbar->enable_gpio, 0); mutex_unlock(&ledbar->lock); From a188356484f434c72ea536d91d7f93f59c562eb5 Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Sat, 12 Jun 2021 21:56:21 +0200 Subject: [PATCH 051/114] mediatek: remove gpiod_direction_output() It's already set to output with GPIOD_OUT_LOW. Signed-off-by: Sven Wegener --- target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c index c5d668836b..9f12cda5d1 100644 --- a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c +++ b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c @@ -153,8 +153,6 @@ static int ubnt_ledbar_probe(struct i2c_client *client, return ret; } - gpiod_direction_output(ledbar->enable_gpio, 0); - ledbar->client = client; mutex_init(&ledbar->lock); From c4f9f9b44c82ffeacd9d3c00ba07171c35831337 Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Sat, 12 Jun 2021 21:56:21 +0200 Subject: [PATCH 052/114] mediatek: correctly log i2c response The read response is in the i2c_response variable. Also use %hhx format, because we're dealing with a single char. Signed-off-by: Sven Wegener --- target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c index 9f12cda5d1..9bfe0e62f4 100644 --- a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c +++ b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c @@ -74,14 +74,14 @@ static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar) i2c_response = ubnt_ledbar_perform_transaction(ledbar, setup_msg); if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) { - dev_err(&ledbar->client->dev, "Error initializing LED transaction: %02x\n", ret); + dev_err(&ledbar->client->dev, "Error initializing LED transaction: %02hhx\n", i2c_response); ret = -EINVAL; goto out_gpio; } i2c_response = ubnt_ledbar_perform_transaction(ledbar, led_msg); if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) { - dev_err(&ledbar->client->dev, "Failed LED transaction: %02x\n", ret); + dev_err(&ledbar->client->dev, "Failed LED transaction: %02hhx\n", i2c_response); ret = -EINVAL; goto out_gpio; } From e9a22ce2535c4a0faf83d5595304fe0e2c7bd1b2 Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Sat, 12 Jun 2021 21:56:21 +0200 Subject: [PATCH 053/114] mediatek: cast literal value to char Or the comparison against a signed char is always true, because the literal 0xaa is treated as an unsigned int, to which the signed char is casted during comparison. 0xaa is above the positive values of a signed char and negative signed char values result in values larger than 0xaa when casted to unsigned int. Signed-off-by: Sven Wegener --- target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c index 9bfe0e62f4..8168391d7e 100644 --- a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c +++ b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c @@ -26,7 +26,7 @@ #define UBNT_LEDBAR_MAX_BRIGHTNESS 0xff #define UBNT_LEDBAR_TRANSACTION_LENGTH 8 -#define UBNT_LEDBAR_TRANSACTION_SUCCESS 0xaa +#define UBNT_LEDBAR_TRANSACTION_SUCCESS (char) 0xaa #define UBNT_LEDBAR_TRANSACTION_BLUE_IDX 2 #define UBNT_LEDBAR_TRANSACTION_GREEN_IDX 3 From 7c852e7df50e370b26b060c96c3cc4491cee88eb Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Sat, 12 Jun 2021 21:56:21 +0200 Subject: [PATCH 054/114] mediatek: support reading more than one byte of response There are commands that return more than one byte of response. Signed-off-by: Sven Wegener --- .../files/drivers/leds/leds-ubnt-ledbar.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c index 8168391d7e..c62e233e6d 100644 --- a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c +++ b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c @@ -41,16 +41,17 @@ struct ubnt_ledbar { struct gpio_desc *enable_gpio; }; -static int ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar, - char *transaction) +static void ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar, + const char *transaction, int len, + char *result, int result_len) { - int ret; int i; - for (i = 0; i < UBNT_LEDBAR_TRANSACTION_LENGTH; i++) + for (i = 0; i < len; i++) i2c_smbus_write_byte(ledbar->client, transaction[i]); - return i2c_smbus_read_byte(ledbar->client); + for (i = 0; i < result_len; i++) + result[i] = i2c_smbus_read_byte(ledbar->client); } static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar) @@ -72,14 +73,14 @@ static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar) msleep(10); - i2c_response = ubnt_ledbar_perform_transaction(ledbar, setup_msg); + ubnt_ledbar_perform_transaction(ledbar, setup_msg, sizeof(setup_msg), &i2c_response, sizeof(i2c_response)); if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) { dev_err(&ledbar->client->dev, "Error initializing LED transaction: %02hhx\n", i2c_response); ret = -EINVAL; goto out_gpio; } - i2c_response = ubnt_ledbar_perform_transaction(ledbar, led_msg); + ubnt_ledbar_perform_transaction(ledbar, led_msg, sizeof(led_msg), &i2c_response, sizeof(i2c_response)); if (i2c_response != UBNT_LEDBAR_TRANSACTION_SUCCESS) { dev_err(&ledbar->client->dev, "Failed LED transaction: %02hhx\n", i2c_response); ret = -EINVAL; From 84e4bbf5f049cdb862eb25c446bd6973ed4238aa Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Sat, 12 Jun 2021 21:56:22 +0200 Subject: [PATCH 055/114] mediatek: add support for reset gpio Some versions of the ledbar MCU have a reset pin. It needs to be correctly initialized or we might keep the MCU in reset state. Signed-off-by: Sven Wegener --- .../files/drivers/leds/leds-ubnt-ledbar.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c index c62e233e6d..1d687b7686 100644 --- a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c +++ b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c @@ -39,6 +39,7 @@ struct ubnt_ledbar { struct led_classdev led_green; struct led_classdev led_blue; struct gpio_desc *enable_gpio; + struct gpio_desc *reset_gpio; }; static void ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar, @@ -96,6 +97,20 @@ out_gpio: return ret; } +static void ubnt_ledbar_reset(struct ubnt_ledbar *ledbar) +{ + if (!ledbar->reset_gpio) + return; + + mutex_lock(&ledbar->lock); + + gpiod_set_value(ledbar->reset_gpio, 1); + msleep(10); + gpiod_set_value(ledbar->reset_gpio, 0); + + mutex_unlock(&ledbar->lock); +} + #define UBNT_LEDBAR_CONTROL_RGBS(name) \ static int ubnt_ledbar_set_##name##_brightness(struct led_classdev *led_cdev,\ enum led_brightness value) \ @@ -154,12 +169,23 @@ static int ubnt_ledbar_probe(struct i2c_client *client, return ret; } + ledbar->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW); + + if (IS_ERR(ledbar->reset_gpio)) { + ret = PTR_ERR(ledbar->reset_gpio); + dev_err(&client->dev, "Failed to get reset gpio: %d\n", ret); + return ret; + } + ledbar->client = client; mutex_init(&ledbar->lock); i2c_set_clientdata(client, ledbar); + // Reset and initialize the MCU + ubnt_ledbar_reset(ledbar); + ledbar->led_red.brightness_set_blocking = ubnt_ledbar_set_red_brightness; ubnt_ledbar_init_led(of_get_child_by_name(np, "red"), ledbar, &ledbar->led_red); From 013a956f086dc5d88f6e9cbd852ed4d900d436e0 Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Sat, 12 Jun 2021 21:56:22 +0200 Subject: [PATCH 056/114] mediatek: add initialization after reset During GPIO initialization the pin state flips and triggers a reset of the ledbar MCU. It needs to be moved through an initialization sequence before working correctly. Signed-off-by: Sven Wegener --- .../mediatek/files/drivers/leds/leds-ubnt-ledbar.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c index 1d687b7686..10d240d2be 100644 --- a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c +++ b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c @@ -99,6 +99,12 @@ out_gpio: static void ubnt_ledbar_reset(struct ubnt_ledbar *ledbar) { + static const char init_msg[16] = {0x02, 0x81, 0xfd, 0x7e, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00}; + char init_response[4]; + if (!ledbar->reset_gpio) return; @@ -108,6 +114,14 @@ static void ubnt_ledbar_reset(struct ubnt_ledbar *ledbar) msleep(10); gpiod_set_value(ledbar->reset_gpio, 0); + msleep(10); + + gpiod_set_value(ledbar->enable_gpio, 1); + msleep(10); + ubnt_ledbar_perform_transaction(ledbar, init_msg, sizeof(init_msg), init_response, sizeof(init_response)); + msleep(10); + gpiod_set_value(ledbar->enable_gpio, 0); + mutex_unlock(&ledbar->lock); } From 76198e8f09a607c6aca2621f59d7a4cd7f6653e3 Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Sat, 12 Jun 2021 21:56:22 +0200 Subject: [PATCH 057/114] mediatek: add led count The LEDs connected to the MCU are so-called smart LEDs and their signal is daisy-chained. Because of this, the MCU needs to be told how many LEDs are connected. It also means the LEDs could be individually controlled, if the MCU has a command for this. Signed-off-by: Sven Wegener --- .../linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c index 10d240d2be..555340c5e8 100644 --- a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c +++ b/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c @@ -31,9 +31,11 @@ #define UBNT_LEDBAR_TRANSACTION_BLUE_IDX 2 #define UBNT_LEDBAR_TRANSACTION_GREEN_IDX 3 #define UBNT_LEDBAR_TRANSACTION_RED_IDX 4 +#define UBNT_LEDBAR_TRANSACTION_LED_COUNT_IDX 6 struct ubnt_ledbar { struct mutex lock; + u32 led_count; struct i2c_client *client; struct led_classdev led_red; struct led_classdev led_green; @@ -60,7 +62,7 @@ static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar) char setup_msg[UBNT_LEDBAR_TRANSACTION_LENGTH] = {0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11}; char led_msg[UBNT_LEDBAR_TRANSACTION_LENGTH] = {0x40, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x00}; + 0x00, 0x00, 0x00, 0x00}; char i2c_response; int ret = 0; @@ -69,6 +71,7 @@ static int ubnt_ledbar_apply_state(struct ubnt_ledbar *ledbar) led_msg[UBNT_LEDBAR_TRANSACTION_BLUE_IDX] = ledbar->led_blue.brightness; led_msg[UBNT_LEDBAR_TRANSACTION_GREEN_IDX] = ledbar->led_green.brightness; led_msg[UBNT_LEDBAR_TRANSACTION_RED_IDX] = ledbar->led_red.brightness; + led_msg[UBNT_LEDBAR_TRANSACTION_LED_COUNT_IDX] = ledbar->led_count; gpiod_set_value(ledbar->enable_gpio, 1); @@ -191,6 +194,9 @@ static int ubnt_ledbar_probe(struct i2c_client *client, return ret; } + ledbar->led_count = 1; + of_property_read_u32(np, "led-count", &ledbar->led_count); + ledbar->client = client; mutex_init(&ledbar->lock); From 53fc987b25524c28525313347f0e2e5653dce43c Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Mon, 2 May 2022 22:13:14 +0200 Subject: [PATCH 058/114] generic: move ledbar driver from mediatek target This moves the ledbar driver to generic, to be also used by the ramips target. Signed-off-by: Sven Wegener --- target/linux/generic/config-5.10 | 1 + target/linux/generic/config-5.15 | 1 + .../files/drivers/leds/leds-ubnt-ledbar.c | 0 .../hack-5.10/800-ubnt-ledbar-driver.patch | 29 +++++++++++++++++++ .../hack-5.15}/800-ubnt-ledbar-driver.patch | 0 5 files changed, 31 insertions(+) rename target/linux/{mediatek => generic}/files/drivers/leds/leds-ubnt-ledbar.c (100%) create mode 100644 target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch rename target/linux/{mediatek/patches-5.15 => generic/hack-5.15}/800-ubnt-ledbar-driver.patch (100%) diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index 7e9eb6143a..392de3095f 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -3042,6 +3042,7 @@ CONFIG_LEDS_TRIGGER_NETDEV=y CONFIG_LEDS_TRIGGER_TIMER=y # CONFIG_LEDS_TRIGGER_TRANSIENT is not set # CONFIG_LEDS_TURRIS_OMNIA is not set +# CONFIG_LEDS_UBNT_LEDBAR is not set # CONFIG_LEDS_USER is not set # CONFIG_LED_TRIGGER_PHY is not set # CONFIG_LEGACY_PTYS is not set diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index f188ce36ac..596485f2f7 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -3143,6 +3143,7 @@ CONFIG_LEDS_TRIGGER_TIMER=y # CONFIG_LEDS_TRIGGER_TRANSIENT is not set # CONFIG_LEDS_TRIGGER_TTY is not set # CONFIG_LEDS_TURRIS_OMNIA is not set +# CONFIG_LEDS_UBNT_LEDBAR is not set # CONFIG_LEDS_USER is not set # CONFIG_LED_TRIGGER_PHY is not set # CONFIG_LEGACY_PTYS is not set diff --git a/target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c b/target/linux/generic/files/drivers/leds/leds-ubnt-ledbar.c similarity index 100% rename from target/linux/mediatek/files/drivers/leds/leds-ubnt-ledbar.c rename to target/linux/generic/files/drivers/leds/leds-ubnt-ledbar.c diff --git a/target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch b/target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch new file mode 100644 index 0000000000..92264eedf9 --- /dev/null +++ b/target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch @@ -0,0 +1,29 @@ +--- a/drivers/leds/Kconfig ++++ b/drivers/leds/Kconfig +@@ -929,6 +929,16 @@ config LEDS_ACER_A500 + This option enables support for the Power Button LED of + Acer Iconia Tab A500. + ++config LEDS_UBNT_LEDBAR ++ tristate "LED support for Ubiquiti UniFi 6 LR" ++ depends on LEDS_CLASS && I2C && OF ++ help ++ This option enables support for the Ubiquiti LEDBAR ++ LED driver. ++ ++ To compile this driver as a module, choose M here: the module ++ will be called leds-ubnt-ledbar. ++ + comment "LED Triggers" + source "drivers/leds/trigger/Kconfig" + +--- a/drivers/leds/Makefile ++++ b/drivers/leds/Makefile +@@ -93,6 +93,7 @@ obj-$(CONFIG_LEDS_TURRIS_OMNIA) += leds + obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o + obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o + obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o ++obj-$(CONFIG_LEDS_UBNT_LEDBAR) += leds-ubnt-ledbar.o + + # LED SPI Drivers + obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o diff --git a/target/linux/mediatek/patches-5.15/800-ubnt-ledbar-driver.patch b/target/linux/generic/hack-5.15/800-ubnt-ledbar-driver.patch similarity index 100% rename from target/linux/mediatek/patches-5.15/800-ubnt-ledbar-driver.patch rename to target/linux/generic/hack-5.15/800-ubnt-ledbar-driver.patch From 820f0c07c544652c1c53a45262a481ac5dbe139b Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Sat, 1 May 2021 13:51:51 +0200 Subject: [PATCH 059/114] ramips: add support for Ubiquiti UniFi FlexHD Hardware -------- - SoC: MediaTek MT7621AT with 128 MiB RAM and 32 MiB Flash - Wi-Fi: MediaTek MT7603 (b/g/n, 2x2) and MediaTek MT7615 (ac, 4x4) - Bluetooth: CSR8811 (internal USB, install kmod-bluetooth) Installation ------------ 1. Connect to the booted device at 192.168.1.20 using username/password "ubnt". 2. Update the bootloader environment. $ fw_setenv devmode TRUE $ fw_setenv boot_openwrt "fdt addr \$(fdtcontroladdr); fdt rm /signature; bootubnt" $ fw_setenv bootcmd "run boot_openwrt" 3. Transfer the OpenWrt sysupgrade image to the device using SCP. 4. Check the mtd partition number for bs / kernel0 / kernel1 $ cat /proc/mtd 5. Set the bootselect flag to boot from kernel0 $ dd if=/dev/zero bs=1 count=1 of=/dev/mtdblock4 6. Write the OpenWrt sysupgrade image to both kernel0 as well as kernel1 $ dd if=openwrt.bin of=/dev/mtdblock6 $ dd if=openwrt.bin of=/dev/mtdblock7 7. Reboot the device. It should boot into OpenWrt. Signed-off-by: Sven Wegener --- .../ramips/dts/mt7621_ubnt_unifi-flexhd.dts | 181 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 11 ++ .../mt7621/base-files/etc/board.d/02_network | 1 + target/linux/ramips/mt7621/config-5.10 | 1 + target/linux/ramips/mt7621/config-5.15 | 1 + 5 files changed, 195 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_ubnt_unifi-flexhd.dts diff --git a/target/linux/ramips/dts/mt7621_ubnt_unifi-flexhd.dts b/target/linux/ramips/dts/mt7621_ubnt_unifi-flexhd.dts new file mode 100644 index 0000000000..615bdf4e13 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_ubnt_unifi-flexhd.dts @@ -0,0 +1,181 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "ubnt,unifi-flexhd", "mediatek,mt7621-soc"; + model = "Ubiquiti UniFi FlexHD"; + + aliases { + label-mac-device = &gmac0; + led-boot = &led_blue; + led-failsafe = &led_blue; + led-running = &led_blue; + led-upgrade = &led_blue; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x60000>; + read-only; + }; + + partition@60000 { + label = "u-boot-env"; + reg = <0x60000 0x10000>; + read-only; + }; + + factory: partition@70000 { + label = "factory"; + reg = <0x70000 0x10000>; + read-only; + }; + + eeprom: partition@80000 { + label = "eeprom"; + reg = <0x80000 0x10000>; + read-only; + }; + + partition@90000 { + label = "bs"; + reg = <0x90000 0x10000>; + }; + + partition@a0000 { + label = "cfg"; + reg = <0xa0000 0x100000>; + read-only; + }; + + partition@1a0000 { + compatible = "denx,fit"; + label = "firmware"; + reg = <0x1a0000 0xf30000>; + }; + + partition@10d0000 { + label = "kernel1"; + reg = <0x10d0000 0xf30000>; + read-only; + }; + }; + }; +}; + +&eeprom { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_eeprom_0: macaddr@0 { + reg = <0x0 0x6>; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_eeprom_0>; + nvmem-cell-names = "mac-address"; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan"; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + reg = <0x0 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + // On newer devices there is a MediaTek MAC in the above + // device EEPROM, so override it with a calculated one. + nvmem-cells = <&macaddr_eeprom_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <1>; + }; +}; + +&pcie1 { + wifi@0,0 { + reg = <0x0 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + // On newer devices there is a MediaTek MAC in the above + // device EEPROM, so override it with a calculated one. + nvmem-cells = <&macaddr_eeprom_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <2>; + }; +}; + +&i2c { + status = "okay"; + clock-frequency = <400000>; + + led-controller@30 { + compatible = "ubnt,ledbar"; + reg = <0x30>; + + enable-gpio = <&gpio 44 GPIO_ACTIVE_HIGH>; + reset-gpio = <&gpio 41 GPIO_ACTIVE_LOW>; + led-count = <8>; + + red { + label = "red"; + }; + + green { + label = "green"; + }; + + led_blue: blue { + label = "blue"; + }; + }; +}; + +&state_default { + gpio { + groups = "uart2"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 661f44d5e9..ca6ee4cc1f 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1947,6 +1947,17 @@ define Device/ubnt_unifi-6-lite endef TARGET_DEVICES += ubnt_unifi-6-lite +define Device/ubnt_unifi-flexhd + $(Device/dsa-migration) + DEVICE_VENDOR := Ubiquiti + DEVICE_MODEL := UniFi FlexHD + DEVICE_DTS_CONFIG := config@2 + KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb + DEVICE_PACKAGES += kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware + IMAGE_SIZE := 15552k +endef +TARGET_DEVICES += ubnt_unifi-flexhd + define Device/ubnt_unifi-nanohd $(Device/dsa-migration) DEVICE_VENDOR := Ubiquiti diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index f3913a1d1c..8a9a0af7b0 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -22,6 +22,7 @@ ramips_setup_interfaces() tplink,re650-v1|\ tplink,re650-v2|\ ubnt,unifi-6-lite|\ + ubnt,unifi-flexhd|\ ubnt,unifi-nanohd|\ zyxel,nwa50ax|\ zyxel,nwa55axe) diff --git a/target/linux/ramips/mt7621/config-5.10 b/target/linux/ramips/mt7621/config-5.10 index 1b415f3e66..213fce2c36 100644 --- a/target/linux/ramips/mt7621/config-5.10 +++ b/target/linux/ramips/mt7621/config-5.10 @@ -110,6 +110,7 @@ CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y # CONFIG_KERNEL_ZSTD is not set CONFIG_LED_TRIGGER_PHY=y +CONFIG_LEDS_UBNT_LEDBAR=y CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LZO_COMPRESS=y diff --git a/target/linux/ramips/mt7621/config-5.15 b/target/linux/ramips/mt7621/config-5.15 index cbab647d7c..53127a5760 100644 --- a/target/linux/ramips/mt7621/config-5.15 +++ b/target/linux/ramips/mt7621/config-5.15 @@ -116,6 +116,7 @@ CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y CONFIG_KMAP_LOCAL=y CONFIG_LED_TRIGGER_PHY=y +CONFIG_LEDS_UBNT_LEDBAR=y CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LZO_COMPRESS=y From 0b5cf952cf5b70d3af2424d05b15ce2730a3dc11 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 11 Sep 2022 20:24:05 +0100 Subject: [PATCH 060/114] mediatek: fix ledbar of UniFi 6 LR when running custom U-Boot The RGB LED of the UniFi 6 LR v1 doesn't work when using the Openwrt- built U-Boot. This is because the vendor loader resets the ledbar controller while our U-Boot doesn't care. Add reset-gpio so the ledbar driver in Linux will always reset the ledbar controller. Signed-off-by: Daniel Golle --- target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr-v1.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr-v1.dtsi b/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr-v1.dtsi index 8f15d3f110..b3299a988f 100644 --- a/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr-v1.dtsi +++ b/target/linux/mediatek/dts/mt7622-ubnt-unifi-6-lr-v1.dtsi @@ -9,7 +9,8 @@ compatible = "ubnt,ledbar"; reg = <0x30>; - enable-gpio = <&pio 59 0>; + enable-gpio = <&pio 59 GPIO_ACTIVE_LOW>; + reset-gpio = <&pio 60 GPIO_ACTIVE_LOW>; red { label = "red"; From 513f9855e9ce710c379cb3af4cd86b899f637c6e Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sat, 12 Jun 2021 15:24:49 -0400 Subject: [PATCH 061/114] ath79: rename an engenius DTSI to generic senao name Other vendors can use this DTSI, for example, WatchGuard there are likely several brands that use the same board design because of outsourcing hardware from Senao. For example, Watchguard AP300 has the same hardware as Engenius EAP600 so we use ar9344_engenius_exx600.dtsi for that Signed-off-by: Michael Pratt --- target/linux/ath79/dts/ar9344_engenius_eap600.dts | 2 +- target/linux/ath79/dts/ar9344_engenius_ecb600.dts | 2 +- .../{ar9344_engenius_exx600.dtsi => ar9344_senao_ap-dual.dtsi} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename target/linux/ath79/dts/{ar9344_engenius_exx600.dtsi => ar9344_senao_ap-dual.dtsi} (100%) diff --git a/target/linux/ath79/dts/ar9344_engenius_eap600.dts b/target/linux/ath79/dts/ar9344_engenius_eap600.dts index 5ad8078f83..50e0674be4 100644 --- a/target/linux/ath79/dts/ar9344_engenius_eap600.dts +++ b/target/linux/ath79/dts/ar9344_engenius_eap600.dts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "ar9344_engenius_exx600.dtsi" +#include "ar9344_senao_ap-dual.dtsi" / { model = "EnGenius EAP600"; diff --git a/target/linux/ath79/dts/ar9344_engenius_ecb600.dts b/target/linux/ath79/dts/ar9344_engenius_ecb600.dts index e064994dba..ad32dc9e39 100644 --- a/target/linux/ath79/dts/ar9344_engenius_ecb600.dts +++ b/target/linux/ath79/dts/ar9344_engenius_ecb600.dts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "ar9344_engenius_exx600.dtsi" +#include "ar9344_senao_ap-dual.dtsi" / { model = "EnGenius ECB600"; diff --git a/target/linux/ath79/dts/ar9344_engenius_exx600.dtsi b/target/linux/ath79/dts/ar9344_senao_ap-dual.dtsi similarity index 100% rename from target/linux/ath79/dts/ar9344_engenius_exx600.dtsi rename to target/linux/ath79/dts/ar9344_senao_ap-dual.dtsi From c10750688366d14146cf6d2f0b73fd9480b29537 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sat, 12 Jun 2021 15:37:38 -0400 Subject: [PATCH 062/114] ath79: fix RGMII delay for ar9344 Senao APs after some trial and error, it was discovered that by setting TX only delay on the AR8035 PHY that setting GMAC registers is no longer necessary. Signed-off-by: Michael Pratt --- target/linux/ath79/dts/ar9344_senao_ap-dual.dtsi | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/target/linux/ath79/dts/ar9344_senao_ap-dual.dtsi b/target/linux/ath79/dts/ar9344_senao_ap-dual.dtsi index 09dc5806d7..c963138f6a 100644 --- a/target/linux/ath79/dts/ar9344_senao_ap-dual.dtsi +++ b/target/linux/ath79/dts/ar9344_senao_ap-dual.dtsi @@ -51,16 +51,9 @@ status = "okay"; phy-handle = <&phy0>; - phy-mode = "rgmii-id"; + phy-mode = "rgmii-txid"; pll-data = <0x02000000 0x00000101 0x00001313>; - - gmac-config { - device = <&gmac>; - rgmii-gmac0 = <1>; - rxdv-delay = <3>; - rxd-delay = <3>; - }; }; &pcie { From 146aaeafb7e364ca667f6ddf5c1857148e8bffb2 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 10 Feb 2021 23:28:49 -0500 Subject: [PATCH 063/114] ath79: add support for Senao WatchGuard AP300 FCC ID: Q6G-AP300 WatchGuard AP300 is an indoor wireless access point with 1 Gb ethernet port, dual-band wireless, internal antenna plates, and 802.3at PoE+ this board is a Senao device: the hardware is equivalent to EnGenius EAP1750 the software is modified Senao SDK which is based on openwrt and uboot including image checksum verification at boot time, and a failsafe image that boots if checksum fails **Specification:** - QCA9558 SOC MIPS 74kc, 2.4 GHz WMAC, 3x3 - QCA9880 WLAN PCI card 168c:003c, 5 GHz, 3x3, 26dBm - AR8035-A PHY RGMII GbE with PoE+ IN - 40 MHz clock - 32 MB FLASH S25FL512S - 2x 64 MB RAM NT5TU32M16 - UART console J10, populated - GPIO watchdog GPIO 16, 20 sec toggle - 6 antennas 5 dBi, internal omni-directional plates - 5 LEDs power, eth0 link/data, 2G, 5G - 1 button reset **MAC addresses:** MAC address labeled as ETH Only one Vendor MAC address in flash at art 0x0 eth0 ETH *:3c art 0x0 phy1 ---- *:3d --- phy0 ---- *:3e --- **Serial console access:** For this board, its not certain whether UART is possible it is likely that software is blocking console access the RX line on the board for UART is shorted to ground by resistor R176 the resistors R175 and R176 are next to the UART RX pin at J10 however console output is garbage even after this fix **Installation:** Method 1: OEM webpage use OEM webpage for firmware upgrade to upload factory.bin Method 2: root shell access downgrade XTM firewall to v2.0.0.1 downgrade AP300 firmware: v1.0.1 remove / unpair AP from controller perform factory reset with reset button connect ethernet to a computer login to OEM webpage with default address / pass: wgwap enable SSHD in OEM webpage settings access root shell with SSH as user 'root' modify uboot environment to automatically try TFTP at boot time (see command below) rename initramfs-kernel.bin to test.bin load test.bin over TFTP (see TFTP recovery) (optionally backup all mtdblocks to have flash backup) perform a sysupgrade with sysupgrade.bin NOTE: DHCP is not enabled by default after flashing **TFTP recovery:** server ip: 192.168.1.101 reset button seems to do nothing at boot time... only possible with modified uboot environment, running this command in the root shell: fw_setenv bootcmd 'if ping 192.168.1.101; then tftp 0x82000000 test.bin && bootm 0x82000000; else bootm 0x9f0a0000; fi' and verify that it is correct with fw_printenv then, before boot, the device will attempt TFTP from 192.168.1.101 looking for file 'test.bin' to return uboot environment to normal: fw_setenv bootcmd 'bootm 0x9f0a0000' **Return to OEM:** user should make backup of MTD partitions and write the backups back to mtd devices in order to revert to OEM (see installation method 2) It may be possible to use sysupgrade with an OEM image as well... (not tested) **OEM upgrade info:** The OEM upgrade script is at /etc/fwupgrade.sh OKLI kernel loader is required because the OEM software expects the kernel to be no greater than 1536k and the factory.bin upgrade procedure would otherwise overwrite part of the kernel when writing rootfs. **Note on eth0 PLL-data:** The default Ethernet Configuration register values will not work because of the external AR8035 switch between the SOC and the ethernet port. For QCA955x series, the PLL registers for eth0 and eth1 can be see in the DTSI as 0x28 and 0x48 respectively. Therefore the PLL registers can be read from uboot for each link speed after attempting tftpboot or another network action using that link speed with `md 0x18050028 1` and `md 0x18050048 1`. The clock delay required for RGMII can be applied at the PHY side, using the at803x driver `phy-mode`. Therefore the PLL registers for GMAC0 do not need the bits for delay on the MAC side. This is possible due to fixes in at803x driver since Linux 5.1 and 5.3 **Note on WatchGuard Magic string:** The OEM upgrade script is a modified version of the generic Senao sysupgrade script which is used on EnGenius devices. On WatchGuard boards produced by Senao, images are verified using a md5sum checksum of the upgrade image concatenated with a magic string. this checksum is then appended to the end of the final image. This variable does not apply to all the senao devices so set to null string as default Tested-by: Alessandro Kornowski Tested-by: John Wagner Signed-off-by: Michael Pratt --- package/boot/uboot-envtools/files/ath79 | 1 + .../ath79/dts/qca9558_watchguard_ap300.dts | 132 ++++++++++++++++++ .../generic/base-files/etc/board.d/01_leds | 3 +- .../generic/base-files/etc/board.d/02_network | 1 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 3 +- .../base-files/lib/upgrade/platform.sh | 3 +- target/linux/ath79/image/common-senao.mk | 9 +- target/linux/ath79/image/generic.mk | 15 ++ 8 files changed, 163 insertions(+), 4 deletions(-) create mode 100644 target/linux/ath79/dts/qca9558_watchguard_ap300.dts diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index a27b751d9b..64b2b34d8a 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -67,6 +67,7 @@ openmesh,om5p-ac-v1|\ openmesh,om5p-ac-v2|\ samsung,wam250|\ ubnt,nanostation-m|\ +watchguard,ap300|\ yuncore,a770|\ yuncore,a782|\ yuncore,a930|\ diff --git a/target/linux/ath79/dts/qca9558_watchguard_ap300.dts b/target/linux/ath79/dts/qca9558_watchguard_ap300.dts new file mode 100644 index 0000000000..90f5cddfa7 --- /dev/null +++ b/target/linux/ath79/dts/qca9558_watchguard_ap300.dts @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "qca955x_senao_loader.dtsi" + +#include +#include + +/ { + compatible = "watchguard,ap300", "qca,qca9558"; + model = "WatchGuard AP300"; + + aliases { + label-mac-device = ð0; + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + keys { + compatible = "gpio-keys"; + + reset { + linux,code = ; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "green:power"; + gpios = <&gpio 22 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + lan_data { + label = "orange:lan_data"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + }; + + lan_link { + label = "green:lan_link"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + wifi_amber { + label = "amber:wifi"; + gpios = <&gpio 23 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + wifi_green { + label = "green:wifi"; + gpios = <&gpio 19 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + }; + + virtual_flash { + devices = <&fwconcat0 &fwconcat1 &fwconcat2>; + }; + + watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + hw_algo = "toggle"; + hw_margin_ms = <20000>; + always-running; + }; +}; + +ð0 { + status = "okay"; + + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + + phy-handle = <&phy5>; + phy-mode = "rgmii-id"; + + pll-data = <0x82000000 0x80000101 0x80001313>; +}; + +&mdio0 { + status = "okay"; + + phy5: ethernet-phy@5 { + reg = <5>; + eee-broken-100tx; + eee-broken-1000t; + }; +}; + +&partitions { + fwconcat2: partition@ff0000 { + label = "fwconcat2"; + reg = <0xff0000 0x1000000>; + }; + + art: partition@1ff0000 { + label = "art"; + reg = <0x1ff0000 0x010000>; + read-only; + }; +}; + +&wdt { + status = "disabled"; +}; + +&wmac { + status = "okay"; + + mtd-cal-data = <&art 0x1000>; + + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <1>; +}; + +&art { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_art_0: macaddr@0 { + reg = <0x0 0x6>; + }; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index 4773826520..d5395e74b7 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -40,7 +40,8 @@ alfa-network,n5q) ucidef_set_led_rssi "signal3" "SIGNAL3" "green:signal3" "wlan0" "50" "100" ucidef_set_led_rssi "signal4" "SIGNAL4" "green:signal4" "wlan0" "75" "100" ;; -alfa-network,pi-wifi4) +alfa-network,pi-wifi4|\ +watchguard,ap300) ucidef_set_led_netdev "lan_data" "LAN_DATA" "orange:lan_data" "eth0" "tx rx" ucidef_set_led_netdev "lan_link" "LAN_LINK" "green:lan_link" "eth0" "link" ;; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index 4683264c1c..95260c016a 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -110,6 +110,7 @@ ath79_setup_interfaces() ubnt,unifiac-lr|\ ubnt,unifiac-mesh|\ ubnt,unifi|\ + watchguard,ap300|\ wd,mynet-wifi-rangeextender|\ winchannel,wb2000|\ zyxel,nwa1100-nh|\ diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 9d25808307..a47b29e7c7 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -15,7 +15,8 @@ case "$FIRMWARE" in araknis,an-700-ap-i-ac|\ engenius,eap1200h|\ engenius,enstationac-v1|\ - glinet,gl-x750) + glinet,gl-x750|\ + watchguard,ap300) caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) 2) ;; diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh index f161540a68..d80927679d 100644 --- a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh @@ -40,7 +40,8 @@ platform_do_upgrade() { engenius,eap600|\ engenius,ecb600|\ engenius,ens202ext-v1|\ - engenius,enstationac-v1) + engenius,enstationac-v1|\ + watchguard,ap300) IMAGE_LIST="tar tzf $1" IMAGE_CMD="tar xzOf $1" KERNEL_PART="loader" diff --git a/target/linux/ath79/image/common-senao.mk b/target/linux/ath79/image/common-senao.mk index dda7da6776..e0e60dbe27 100644 --- a/target/linux/ath79/image/common-senao.mk +++ b/target/linux/ath79/image/common-senao.mk @@ -1,4 +1,4 @@ -DEVICE_VARS += SENAO_IMGNAME +DEVICE_VARS += SENAO_IMGNAME WATCHGUARD_MAGIC # This needs to make OEM config archive 'sysupgrade.tgz' an empty file prior to OEM # sysupgrade, as otherwise it will implant the old configuration from @@ -27,6 +27,13 @@ define Build/senao-tar-gz rm -rf $@.tmp $@.len $@.md5 endef +define Build/watchguard-cksum + -echo -n $(word 1,$(1)) | cat $@ - | md5sum | \ + cut -d ' ' -f1 | tr -d '\n' > $@.md5 && \ + cat $@.md5 >> $@ && \ + rm -rf $@.md5 +endef + define Device/senao_loader_okli $(Device/loader-okli-uimage) KERNEL := kernel-bin | append-dtb | lzma | uImage lzma -M 0x73714f4b diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index ff7c3b156e..b0b8b70ba4 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -2589,6 +2589,21 @@ define Device/wallys_dr531 endef TARGET_DEVICES += wallys_dr531 +define Device/watchguard_ap300 + $(Device/senao_loader_okli) + SOC := qca9558 + DEVICE_VENDOR := WatchGuard + DEVICE_MODEL := AP300 + DEVICE_PACKAGES := ath10k-firmware-qca988x-ct kmod-ath10k-ct + IMAGE_SIZE := 11584k + LOADER_FLASH_OFFS := 0x220000 + SENAO_IMGNAME := senao-ap300 + WATCHGUARD_MAGIC := 82kdlzk2 + IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | \ + check-size | senao-tar-gz $$$$(SENAO_IMGNAME) | watchguard-cksum $$$$(WATCHGUARD_MAGIC) +endef +TARGET_DEVICES += watchguard_ap300 + define Device/wd_mynet-n600 $(Device/seama) SOC := ar9344 From 9f6e24785439d7838fc7a338505cbfac9687a90d Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sat, 12 Jun 2021 15:08:18 -0400 Subject: [PATCH 064/114] ath79: add support for Senao WatchGuard AP200 FCC ID: U2M-CAP4200AG WatchGuard AP200 is an indoor wireless access point with 1 Gb ethernet port, dual-band wireless, internal antenna plates, and 802.3at PoE+ this board is a Senao device: the hardware is equivalent to EnGenius EAP600 the software is modified Senao SDK which is based on openwrt and uboot including image checksum verification at boot time, and a failsafe image that boots if checksum fails **Specification:** - AR9344 SOC MIPS 74kc, 2.4 GHz WMAC, 2x2 - AR9382 WLAN PCI card 168c:0030, 5 GHz, 2x2, 26dBm - AR8035-A EPHY RGMII GbE with PoE+ IN - 25 MHz clock - 16 MB FLASH mx25l12805d - 2x 64 MB RAM - UART console J11, populated - GPIO watchdog GPIO 16, 20 sec toggle - 4 antennas 5 dBi, internal omni-directional plates - 5 LEDs power, eth0 link/data, 2G, 5G - 1 button reset **MAC addresses:** Label has no MAC Only one Vendor MAC address in flash at art 0x0 eth0 ---- *:be art 0x0 -2 phy1 ---- *:bf art 0x0 -1 phy0 ---- *:be art 0x0 -2 **Installation:** Method 1: OEM webpage use OEM webpage for firmware upgrade to upload factory.bin Method 2: root shell It may be necessary to use a Watchguard router to flash the image to the AP and / or to downgrade the software on the AP to access SSH For some Watchguard devices, serial console over UART is disabled. NOTE: DHCP is not enabled by default after flashing **TFTP recovery:** reset button has no function at boot time only possible with modified uboot environment, (see commit message for Watchguard AP300) **Return to OEM:** user should make backup of MTD partitions and write the backups back to mtd devices in order to revert to OEM reliably It may be possible to use sysupgrade with an OEM image as well... (not tested) **OEM upgrade info:** The OEM upgrade script is at /etc/fwupgrade.sh OKLI kernel loader is required because the OEM software expects the kernel to be no greater than 1536k and the factory.bin upgrade procedure would otherwise overwrite part of the kernel when writing rootfs. **Note on eth0 PLL-data:** The default Ethernet Configuration register values will not work because of the external AR8035 switch between the SOC and the ethernet port. For AR934x series, the PLL registers for eth0 can be see in the DTSI as 0x2c. Therefore the PLL registers can be read from uboot for each link speed after attempting tftpboot or another network action using that link speed with `md 0x1805002c 1`. The clock delay required for RGMII can be applied at the PHY side, using the at803x driver `phy-mode`. Therefore the PLL registers for GMAC0 do not need the bits for delay on the MAC side. This is possible due to fixes in at803x driver since Linux 5.1 and 5.3 **Note on WatchGuard Magic string:** The OEM upgrade script is a modified version of the generic Senao sysupgrade script which is used on EnGenius devices. On WatchGuard boards produced by Senao, images are verified using a md5sum checksum of the upgrade image concatenated with a magic string. this checksum is then appended to the end of the final image. This variable does not apply to all the senao devices so set to null string as default Tested-by: Steve Wheeler Tested-by: John Delaney Signed-off-by: Michael Pratt --- package/boot/uboot-envtools/files/ath79 | 1 + .../ath79/dts/ar9344_watchguard_ap200.dts | 86 +++++++++++++++++++ .../generic/base-files/etc/board.d/01_leds | 1 + .../generic/base-files/etc/board.d/02_network | 1 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 1 + .../base-files/lib/upgrade/platform.sh | 1 + target/linux/ath79/image/generic.mk | 14 +++ 7 files changed, 105 insertions(+) create mode 100644 target/linux/ath79/dts/ar9344_watchguard_ap200.dts diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index 64b2b34d8a..588c7dee02 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -67,6 +67,7 @@ openmesh,om5p-ac-v1|\ openmesh,om5p-ac-v2|\ samsung,wam250|\ ubnt,nanostation-m|\ +watchguard,ap200|\ watchguard,ap300|\ yuncore,a770|\ yuncore,a782|\ diff --git a/target/linux/ath79/dts/ar9344_watchguard_ap200.dts b/target/linux/ath79/dts/ar9344_watchguard_ap200.dts new file mode 100644 index 0000000000..0cd966476c --- /dev/null +++ b/target/linux/ath79/dts/ar9344_watchguard_ap200.dts @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ar9344_senao_ap-dual.dtsi" + +/ { + compatible = "watchguard,ap200", "qca,ar9344"; + model = "WatchGuard AP200"; + + aliases { + led-boot = &led_power_amber; + led-failsafe = &led_power_amber; + led-running = &led_power_green; + led-upgrade = &led_power_amber; + }; + + leds { + compatible = "gpio-leds"; + + led_power_amber: power_amber { + label = "amber:power"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + led_power_green: power_green { + label = "green:power"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + lan_data { + label = "orange:lan_data"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + + lan_link { + label = "green:lan_link"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + wifi_amber { + label = "amber:wifi"; + gpios = <&gpio 19 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + wifi_green { + label = "green:wifi"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + }; +}; + +&ref { + clock-frequency = <25000000>; +}; + +ð0 { + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <(-2)>; +}; + +&pcie { + wifi@0,0,0 { + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <(-1)>; + }; +}; + +&wmac { + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <(-2)>; +}; + +&art { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_art_0: macaddr@0 { + reg = <0x0 0x6>; + }; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index d5395e74b7..57cd78989a 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -41,6 +41,7 @@ alfa-network,n5q) ucidef_set_led_rssi "signal4" "SIGNAL4" "green:signal4" "wlan0" "75" "100" ;; alfa-network,pi-wifi4|\ +watchguard,ap200|\ watchguard,ap300) ucidef_set_led_netdev "lan_data" "LAN_DATA" "orange:lan_data" "eth0" "tx rx" ucidef_set_led_netdev "lan_link" "LAN_LINK" "green:lan_link" "eth0" "link" diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index 95260c016a..f5adf354a0 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -110,6 +110,7 @@ ath79_setup_interfaces() ubnt,unifiac-lr|\ ubnt,unifiac-mesh|\ ubnt,unifi|\ + watchguard,ap200|\ watchguard,ap300|\ wd,mynet-wifi-rangeextender|\ winchannel,wb2000|\ diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index df293c44db..532f084c86 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -91,6 +91,7 @@ case "$FIRMWARE" in tplink,tl-wdr4310-v1|\ tplink,tl-wdr4900-v2|\ ubnt,unifi-ap-pro|\ + watchguard,ap200|\ winchannel,wb2000) caldata_extract "art" 0x5000 0x440 ;; diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh index d80927679d..104eaf302e 100644 --- a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh @@ -41,6 +41,7 @@ platform_do_upgrade() { engenius,ecb600|\ engenius,ens202ext-v1|\ engenius,enstationac-v1|\ + watchguard,ap200|\ watchguard,ap300) IMAGE_LIST="tar tzf $1" IMAGE_CMD="tar xzOf $1" diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index b0b8b70ba4..6d23ba4be6 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -2589,6 +2589,20 @@ define Device/wallys_dr531 endef TARGET_DEVICES += wallys_dr531 +define Device/watchguard_ap200 + $(Device/senao_loader_okli) + SOC := ar9344 + DEVICE_VENDOR := WatchGuard + DEVICE_MODEL := AP200 + IMAGE_SIZE := 12096k + LOADER_FLASH_OFFS := 0x220000 + SENAO_IMGNAME := senao-ap200 + WATCHGUARD_MAGIC := 82kdlzk2 + IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | \ + check-size | senao-tar-gz $$$$(SENAO_IMGNAME) | watchguard-cksum $$$$(WATCHGUARD_MAGIC) +endef +TARGET_DEVICES += watchguard_ap200 + define Device/watchguard_ap300 $(Device/senao_loader_okli) SOC := qca9558 From 5df1b33298d1b35a47d24e9b4b941d2786633fb2 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Tue, 2 Nov 2021 13:41:41 -0400 Subject: [PATCH 065/114] ath79: add support for Senao Watchguard AP100 FCC ID: U2M-CAP2100AG WatchGuard AP100 is an indoor wireless access point with 1 Gb ethernet port, dual-band but single-radio wireless, internal antenna plates, and 802.3at PoE+ this board is a Senao device: the hardware is equivalent to EnGenius EAP300 v2 the software is modified Senao SDK which is based on openwrt and uboot including image checksum verification at boot time, and a failsafe image that boots if checksum fails **Specification:** - AR9344 SOC MIPS 74kc, 2.4 GHz AND 5 GHz WMAC, 2x2 - AR8035-A EPHY RGMII GbE with PoE+ IN - 25 MHz clock - 16 MB FLASH mx25l12805d - 2x 64 MB RAM - UART console J11, populated - GPIO watchdog GPIO 16, 20 sec toggle - 2 antennas 5 dBi, internal omni-directional plates - 5 LEDs power, eth0 link/data, 2G, 5G - 1 button reset **MAC addresses:** Label has no MAC Only one Vendor MAC address in flash at art 0x0 eth0 ---- *:e5 art 0x0 -2 phy0 ---- *:e5 art 0x0 -2 **Installation:** Method 1: OEM webpage use OEM webpage for firmware upgrade to upload factory.bin Method 2: root shell It may be necessary to use a Watchguard router to flash the image to the AP and / or to downgrade the software on the AP to access SSH For some Watchguard devices, serial console over UART is disabled. NOTE: DHCP is not enabled by default after flashing **TFTP recovery:** reset button has no function at boot time only possible with modified uboot environment, (see commit message for Watchguard AP300) **Return to OEM:** user should make backup of MTD partitions and write the backups back to mtd devices in order to revert to OEM reliably It may be possible to use sysupgrade with an OEM image as well... (not tested) **OEM upgrade info:** The OEM upgrade script is at /etc/fwupgrade.sh OKLI kernel loader is required because the OEM software expects the kernel to be no greater than 1536k and the factory.bin upgrade procedure would otherwise overwrite part of the kernel when writing rootfs. **Note on eth0 PLL-data:** The default Ethernet Configuration register values will not work because of the external AR8035 switch between the SOC and the ethernet port. For AR934x series, the PLL registers for eth0 can be see in the DTSI as 0x2c. Therefore the PLL registers can be read from uboot for each link speed after attempting tftpboot or another network action using that link speed with `md 0x1805002c 1`. The clock delay required for RGMII can be applied at the PHY side, using the at803x driver `phy-mode`. Therefore the PLL registers for GMAC0 do not need the bits for delay on the MAC side. This is possible due to fixes in at803x driver since Linux 5.1 and 5.3 **Note on WatchGuard Magic string:** The OEM upgrade script is a modified version of the generic Senao sysupgrade script which is used on EnGenius devices. On WatchGuard boards produced by Senao, images are verified using a md5sum checksum of the upgrade image concatenated with a magic string. this checksum is then appended to the end of the final image. This variable does not apply to all the senao devices so set to null string as default Tested-by: Steve Wheeler Signed-off-by: Michael Pratt --- package/boot/uboot-envtools/files/ath79 | 1 + .../ath79/dts/ar9344_watchguard_ap100.dts | 84 +++++++++++++++++++ .../generic/base-files/etc/board.d/01_leds | 1 + .../generic/base-files/etc/board.d/02_network | 1 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 1 + .../base-files/lib/upgrade/platform.sh | 1 + target/linux/ath79/image/generic.mk | 14 ++++ 7 files changed, 103 insertions(+) create mode 100644 target/linux/ath79/dts/ar9344_watchguard_ap100.dts diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index 588c7dee02..d9e504bf89 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -67,6 +67,7 @@ openmesh,om5p-ac-v1|\ openmesh,om5p-ac-v2|\ samsung,wam250|\ ubnt,nanostation-m|\ +watchguard,ap100|\ watchguard,ap200|\ watchguard,ap300|\ yuncore,a770|\ diff --git a/target/linux/ath79/dts/ar9344_watchguard_ap100.dts b/target/linux/ath79/dts/ar9344_watchguard_ap100.dts new file mode 100644 index 0000000000..d2ebe14979 --- /dev/null +++ b/target/linux/ath79/dts/ar9344_watchguard_ap100.dts @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ar9344_senao_ap-dual.dtsi" + +/ { + compatible = "watchguard,ap100", "qca,ar9344"; + model = "WatchGuard AP100"; + + aliases { + led-boot = &led_power_amber; + led-failsafe = &led_power_amber; + led-running = &led_power_green; + led-upgrade = &led_power_amber; + }; + + leds { + compatible = "gpio-leds"; + + led_power_amber: power_amber { + label = "amber:power"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + led_power_green: power_green { + label = "green:power"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + lan_data { + label = "orange:lan_data"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + + lan_link { + label = "green:lan_link"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + wifi_amber { + label = "amber:wifi"; + gpios = <&gpio 19 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + wifi_green { + label = "green:wifi"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + }; +}; + +&ref { + clock-frequency = <25000000>; +}; + +ð0 { + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <(-2)>; +}; + +&pcie { + status = "disabled"; +}; + +&wmac { + /delete-property/ qca,disable-2ghz; + + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <(-2)>; +}; + +&art { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_art_0: macaddr@0 { + reg = <0x0 0x6>; + }; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index 57cd78989a..606a194f7e 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -41,6 +41,7 @@ alfa-network,n5q) ucidef_set_led_rssi "signal4" "SIGNAL4" "green:signal4" "wlan0" "75" "100" ;; alfa-network,pi-wifi4|\ +watchguard,ap100|\ watchguard,ap200|\ watchguard,ap300) ucidef_set_led_netdev "lan_data" "LAN_DATA" "orange:lan_data" "eth0" "tx rx" diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index f5adf354a0..3b69c2bded 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -110,6 +110,7 @@ ath79_setup_interfaces() ubnt,unifiac-lr|\ ubnt,unifiac-mesh|\ ubnt,unifi|\ + watchguard,ap100|\ watchguard,ap200|\ watchguard,ap300|\ wd,mynet-wifi-rangeextender|\ diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 532f084c86..9127aed36e 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -91,6 +91,7 @@ case "$FIRMWARE" in tplink,tl-wdr4310-v1|\ tplink,tl-wdr4900-v2|\ ubnt,unifi-ap-pro|\ + watchguard,ap100|\ watchguard,ap200|\ winchannel,wb2000) caldata_extract "art" 0x5000 0x440 diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh index 104eaf302e..8aa7e90ab8 100644 --- a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh @@ -41,6 +41,7 @@ platform_do_upgrade() { engenius,ecb600|\ engenius,ens202ext-v1|\ engenius,enstationac-v1|\ + watchguard,ap100|\ watchguard,ap200|\ watchguard,ap300) IMAGE_LIST="tar tzf $1" diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 6d23ba4be6..1ba02fc0fc 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -2589,6 +2589,20 @@ define Device/wallys_dr531 endef TARGET_DEVICES += wallys_dr531 +define Device/watchguard_ap100 + $(Device/senao_loader_okli) + SOC := ar9344 + DEVICE_VENDOR := WatchGuard + DEVICE_MODEL := AP100 + IMAGE_SIZE := 12096k + LOADER_FLASH_OFFS := 0x220000 + SENAO_IMGNAME := senao-ap100 + WATCHGUARD_MAGIC := 82kdlzk2 + IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | \ + check-size | senao-tar-gz $$$$(SENAO_IMGNAME) | watchguard-cksum $$$$(WATCHGUARD_MAGIC) +endef +TARGET_DEVICES += watchguard_ap100 + define Device/watchguard_ap200 $(Device/senao_loader_okli) SOC := ar9344 From 600741bf2e194284e4641ad29568711e36d5138c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 11 Sep 2022 21:46:12 +0200 Subject: [PATCH 066/114] firmware-utils: update to git HEAD 71e1db6 tplink-safeloader: add TP-Link Deco S4 v2 support Signed-off-by: Hauke Mehrtens --- tools/firmware-utils/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile index ffb3c09780..63db641c3e 100644 --- a/tools/firmware-utils/Makefile +++ b/tools/firmware-utils/Makefile @@ -11,9 +11,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git -PKG_SOURCE_DATE:=2022-07-28 -PKG_SOURCE_VERSION:=2483fe782e0d406b65eaa73b39fc27afabd8a9ea -PKG_MIRROR_HASH:=140b84b33cdae1520304cd6798604a51d2f4281b828808a5913d0b2d4b1f551f +PKG_SOURCE_DATE:=2022-09-11 +PKG_SOURCE_VERSION:=71e1db65a5487bcbb18b2757655d2b59ae96292a +PKG_MIRROR_HASH:=3f9e7648afc82432a8011491af6354f8a82ccc3ba6d762af72649117e22d7054 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk From 20581ee8b590afc56cda013272861e1e614a078e Mon Sep 17 00:00:00 2001 From: Nick French Date: Sat, 13 Aug 2022 12:09:50 -0500 Subject: [PATCH 067/114] ath79: add support for TP-Link Deco S4 Add support for TP-Link Deco S4 wifi router The label refers to the device as S4R and the TP-Link firmware site calls it the Deco S4 v2. (There does not appear to be a v1) Hardware (and FCC id) are identical to the Deco M4R v2 but the flash layout is ordered differently and the OEM firmware encrypts some config parameters (including the label mac address) in flash In order to set the encrypted mac address, the wlan's caldata node is removed from the DTS so the mac can be decrypted with the help of the uencrypt tool and patched into the wlan fw via hotplug Specifications: SoC: QCA9563-AL3A RAM: Zentel A3R1GE40JBF Wireless 2.4GHz: QCA9563-AL3A (main SoC) Wireless 5GHz: QCA9886 Ethernet Switch: QCA8337N-AL3C Flash: 16 MB SPI NOR UART serial access (115200N1) on board via solder pads: RX = TP1 pad TX = TP2 pad GND = C201 (pad nearest board edge) The device's bootloader and web gui will only accept images that were signed using TP-Link's RSA key, however a memory safety bug in the bootloader can be leveraged to install openwrt without accessing the serial console. See developer forum S4 support page for link to a "firmware" file that starts a tftp client, or you may generate one on your own like this: ``` python - > deco_s4_faux_fw_tftp.bin <I', 0x00008000) + b'X'*16 + b"fw-type:" \ + b'x'*256 + b"S000S001S002" + pack('>I', 0x80060200) \ b += b"\x00"*(0x200-len(b)) \ + pack(">33I", *[0x3c0887fc, 0x35083ddc, 0xad000000, 0x24050000, 0x3c048006, 0x348402a0, 0x3c1987f9, 0x373947f4, 0x0320f809, 0x00000000, 0x24050000, 0x3c048006, 0x348402d0, 0x3c1987f9, 0x373947f4, 0x0320f809, 0x00000000, 0x24050000, 0x3c048006, 0x34840300, 0x3c1987f9, 0x373947f4, 0x0320f809, 0x00000000, 0x24050000, 0x3c048006, 0x34840400, 0x3c1987f9, 0x373947f4, 0x0320f809, 0x00000000, 0x1000fff1, 0x00000000]) b += b"\xff"*(0x2A0-len(b)) + b"setenv serverip 192.168.0.2\x00" b += b"\xff"*(0x2D0-len(b)) + b"setenv ipaddr 192.168.0.1\x00" b += b"\xff"*(0x300-len(b)) + b"tftpboot 0x81000000 initramfs-kernel.bin\x00" b += b"\xff"*(0x400-len(b)) + b"bootm 0x81000000\x00" b += b"\xff"*(0x8000-len(b)) sys.stdout.buffer.write(b) EOF ``` Installation: 1. Run tftp server on pc with static ip 192.168.0.2 2. Place openwrt "initramfs-kernel.bin" image in tftp root dir 3. Connect pc to router ethernet port1 4. While holding in reset button on bottom of router, power on router 5. From pc access router webgui at http://192.168.0.1 6. Upload deco_s4_faux_fw_tftp.bin 7. Router will load and execture in-memory openwrt 8. Switch pc back to dhcp or static 192.168.1.x 9. Flash openwrt sysupgrade image via luci/ssh at 192.168.1.1 Revert to stock: Press and hold reset button while powering device to start the bootloader's recovery mode, where stock firmware can be uploaded via web gui at 192.168.0.1 Please note that one additional non-github commits is also needed: firmware-utils: add tplink-safeloader support for Deco S4 Signed-off-by: Nick French --- .../base-files/files/lib/functions/system.sh | 19 +++ .../ath79/dts/qca9563_tplink_deco-s4-v2.dts | 131 ++++++++++++++++++ .../generic/base-files/etc/board.d/02_network | 7 +- .../etc/hotplug.d/firmware/10-ath9k-eeprom | 5 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 7 + .../base-files/lib/preinit/10_fix_eth_mac.sh | 6 +- target/linux/ath79/image/generic-tp-link.mk | 12 ++ 7 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 target/linux/ath79/dts/qca9563_tplink_deco-s4-v2.dts diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index c17354d945..22eb00c515 100644 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -110,6 +110,25 @@ mtd_get_mac_encrypted_arcadyan() { [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty" } +mtd_get_mac_encrypted_deco() { + local mtdname="$1" + + if ! [ -e "$mtdname" ]; then + echo "mtd_get_mac_encrypted_deco: file $mtdname not found!" >&2 + return + fi + + tplink_key="3336303032384339" + + key=$(dd if=$mtdname bs=1 skip=16 count=8 2>/dev/null | \ + uencrypt -n -d -k $tplink_key -c des-ecb | hexdump -v -n 8 -e '1/1 "%02x"') + + macaddr=$(dd if=$mtdname bs=1 skip=32 count=8 2>/dev/null | \ + uencrypt -n -d -k $key -c des-ecb | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"') + + echo $macaddr +} + mtd_get_mac_text() { local mtdname=$1 local offset=$(($2)) diff --git a/target/linux/ath79/dts/qca9563_tplink_deco-s4-v2.dts b/target/linux/ath79/dts/qca9563_tplink_deco-s4-v2.dts new file mode 100644 index 0000000000..e4bb88807e --- /dev/null +++ b/target/linux/ath79/dts/qca9563_tplink_deco-s4-v2.dts @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include +#include + +#include "qca956x.dtsi" + +/ { + compatible = "tplink,deco-s4-v2", "qca,qca9563"; + model = "TP-Link Deco S4 v2"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + leds { + compatible = "gpio-leds"; + + wlan2g { + label = "red:wlan2g"; + gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + led_power: power { + label = "green:power"; + gpios = <&gpio 7 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + wlan5g { + label = "blue:wlan5g"; + gpios = <&gpio 9 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + }; + + + keys { + compatible = "gpio-keys"; + + reset { + label = "Reset button"; + linux,code = ; + gpios = <&gpio 2 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&mdio0 { + status = "okay"; + + phy0: ethernet-phy@0 { + reg = <0>; + phy-mode = "sgmii"; + qca,mib-poll-interval = <500>; + + qca,ar8327-initvals = < + 0x04 0x00080080 /* PORT0 PAD MODE CTRL */ + 0x7c 0x0000007e /* PORT0_STATUS */ + >; + }; +}; + +&spi { + status = "okay"; + num-cs = <1>; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + uboot: partition@0 { + label = "u-boot"; + reg = <0x000000 0x080000>; + read-only; + }; + + partition@80000 { + label = "product-info"; + reg = <0x80000 0x05000>; + read-only; + }; + + config: partition@85000 { + label = "config"; + reg = <0x85000 0x16b000>; + read-only; + }; + + art: partition@1f0000 { + label = "art"; + reg = <0x1f0000 0x10000>; + read-only; + }; + + partition@200000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x200000 0xe00000>; + }; + }; + }; +}; + +ð0 { + status = "okay"; + + phy-mode = "sgmii"; + phy-handle = <&phy0>; +}; + +&wmac { + status = "okay"; + + qca,no-eeprom; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index 3b69c2bded..a2ae5cb8de 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -519,7 +519,8 @@ ath79_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth0" "1:lan" "2:lan" ;; - tplink,deco-m4r-v1) + tplink,deco-m4r-v1|\ + tplink,deco-s4-v2) ucidef_add_switch "switch0" \ "0@eth0" "3:lan:1" "5:lan:2" ;; @@ -677,6 +678,10 @@ ath79_setup_macs() base_mac=$(mtd_get_mac_binary u-boot 0x1fc00) wan_mac=$(macaddr_add "$base_mac" 1) ;; + tplink,deco-s4-v2) + lan_mac=$(mtd_get_mac_encrypted_deco $(find_mtd_part config)) + label_mac=$lan_mac + ;; nec,wf1200cr|\ nec,wg1200cr) lan_mac=$(mtd_get_mac_ascii devdata "lanmac") diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 9127aed36e..04705aadf8 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -71,6 +71,11 @@ case "$FIRMWARE" in caldata_extract "radiocfg" 0x1000 0x440 ath9k_patch_mac $(mtd_get_mac_ascii devdata "wlan24mac") ;; + tplink,deco-s4-v2) + caldata_extract "art" 0x1000 0x440 + base_mac=$(mtd_get_mac_encrypted_deco $(find_mtd_part config)) + ath9k_patch_mac $(macaddr_add $base_mac 1) + ;; *) caldata_die "board $board is not supported yet" ;; diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index a47b29e7c7..57e59a89d6 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -263,6 +263,13 @@ case "$FIRMWARE" in ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin ;; + tplink,deco-s4-v2) + caldata_extract "art" 0x5000 0x2f20 + base_mac=$(mtd_get_mac_encrypted_deco $(find_mtd_part config)) + ath10k_patch_mac $(macaddr_add $base_mac 2) + ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ + /lib/firmware/ath10k/QCA9888/hw2.0/board.bin + ;; esac ;; *) diff --git a/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh b/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh index d9cb8d2b82..d06f043ad4 100644 --- a/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh +++ b/target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh @@ -1,4 +1,4 @@ -. /lib/functions.sh +. /lib/functions/system.sh preinit_set_mac_address() { case $(board_name) in @@ -19,6 +19,10 @@ preinit_set_mac_address() { siemens,ws-ap3610) ip link set dev eth0 address $(mtd_get_mac_ascii cfg1 ethaddr) ;; + tplink,deco-s4-v2) + base_mac=$(mtd_get_mac_encrypted_deco $(find_mtd_part config)) + ip link set dev eth0 address $base_mac + ;; zyxel,nbg6616) ethaddr=$(mtd_get_mac_ascii u-boot-env ethaddr) ip link set dev eth0 address $(macaddr_add $ethaddr 2) diff --git a/target/linux/ath79/image/generic-tp-link.mk b/target/linux/ath79/image/generic-tp-link.mk index ffe1d6e290..598085e50b 100644 --- a/target/linux/ath79/image/generic-tp-link.mk +++ b/target/linux/ath79/image/generic-tp-link.mk @@ -493,6 +493,18 @@ define Device/tplink_deco-m4r-v1 endef TARGET_DEVICES += tplink_deco-m4r-v1 +define Device/tplink_deco-s4-v2 + $(Device/tplink-safeloader-uimage) + SOC := qca9563 + IMAGE_SIZE := 13824k + DEVICE_MODEL := Deco S4 + DEVICE_VARIANT := v2 + DEVICE_PACKAGES := kmod-ath10k-ct ath10k-firmware-qca9888-ct uencrypt + SUPPORTED_DEVICES += deco-s4-v2 + TPLINK_BOARD_ID := DECO-S4-V2 +endef +TARGET_DEVICES += tplink_deco-s4-v2 + define Device/tplink_re350k-v1 $(Device/tplink-safeloader) SOC := qca9558 From e22ca21daab6d5be87b2b005b5a9440629730169 Mon Sep 17 00:00:00 2001 From: Will Moss Date: Wed, 3 Aug 2022 11:16:35 +0000 Subject: [PATCH 068/114] ath79: add support for TP-Link TL-WR941ND v5 Specifications: - SoC: ar9341 - RAM: 32M - Flash: 4M - Ethernet: 5x FE ports - WiFi: ar9341-wmac Flash instruction: Upload generated factory firmware on vendor's web interface. This device is very similar to the TL-WR841N v8, only two LED GPIOs are different. Buttons configuration is similar to TL-WR842ND v2 but both buttons are active low. Signed-off-by: Will Moss --- .../ath79/dts/ar9341_tplink_tl-wr941nd-v5.dts | 103 ++++++++++++++++++ target/linux/ath79/image/tiny-tp-link.mk | 10 ++ .../ath79/tiny/base-files/etc/board.d/01_leds | 3 +- .../tiny/base-files/etc/board.d/02_network | 3 +- 4 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 target/linux/ath79/dts/ar9341_tplink_tl-wr941nd-v5.dts diff --git a/target/linux/ath79/dts/ar9341_tplink_tl-wr941nd-v5.dts b/target/linux/ath79/dts/ar9341_tplink_tl-wr941nd-v5.dts new file mode 100644 index 0000000000..a61f4a381e --- /dev/null +++ b/target/linux/ath79/dts/ar9341_tplink_tl-wr941nd-v5.dts @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ar9341_tplink.dtsi" + +/ { + model = "TP-Link TL-WR941ND v5"; + compatible = "tplink,tl-wr941nd-v5", "qca,ar9341"; + + aliases { + label-mac-device = &wmac; + }; + + keys { + compatible = "gpio-keys"; + + rfkill { + label = "WiFi"; + linux,code = ; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + + reset { + label = "Reset/WPS"; + linux,code = ; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; +}; + +&leds { + + lan3 { + gpios = <&gpio 2 GPIO_ACTIVE_LOW>; + }; + + lan4 { + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + }; +}; + +&spi { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + uboot: partition@0 { + label = "u-boot"; + reg = <0x000000 0x020000>; + read-only; + }; + + partition@20000 { + compatible = "tplink,firmware"; + label = "firmware"; + reg = <0x020000 0x3d0000>; + }; + + art: partition@3f0000 { + label = "art"; + reg = <0x3f0000 0x010000>; + read-only; + }; + }; + }; +}; + +ð0 { // WAN port, initialized last as eth1 + nvmem-cells = <&macaddr_uboot_1fc00>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <1>; +}; + +ð1 { // LAN ports, initialized first as eth0 + nvmem-cells = <&macaddr_uboot_1fc00>; + nvmem-cell-names = "mac-address"; +}; + +&wmac { + mtd-cal-data = <&art 0x1000>; + + nvmem-cells = <&macaddr_uboot_1fc00>; + nvmem-cell-names = "mac-address"; +}; + +&uboot { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_uboot_1fc00: macaddr@1fc00 { + reg = <0x1fc00 0x6>; + }; +}; diff --git a/target/linux/ath79/image/tiny-tp-link.mk b/target/linux/ath79/image/tiny-tp-link.mk index 2110f08b52..30474149d3 100644 --- a/target/linux/ath79/image/tiny-tp-link.mk +++ b/target/linux/ath79/image/tiny-tp-link.mk @@ -503,6 +503,16 @@ define Device/tplink_tl-wr941-v4 endef TARGET_DEVICES += tplink_tl-wr941-v4 +define Device/tplink_tl-wr941nd-v5 + $(Device/tplink-4mlzma) + SOC := ar9341 + DEVICE_MODEL := TL-WR941ND + DEVICE_VARIANT := v5 + TPLINK_HWID := 0x09410005 + SUPPORTED_DEVICES += tl-wr941nd-v5 +endef +TARGET_DEVICES += tplink_tl-wr941nd-v5 + define Device/tplink_tl-wr941nd-v6 $(Device/tplink-4mlzma) SOC := tp9343 diff --git a/target/linux/ath79/tiny/base-files/etc/board.d/01_leds b/target/linux/ath79/tiny/base-files/etc/board.d/01_leds index 7ba2c2c897..92c4499580 100644 --- a/target/linux/ath79/tiny/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/tiny/base-files/etc/board.d/01_leds @@ -65,7 +65,8 @@ tplink,tl-mr3420-v2|\ tplink,tl-wr740n-v4|\ tplink,tl-wr740n-v5|\ tplink,tl-wr741nd-v4|\ -tplink,tl-wr841-v8) +tplink,tl-wr841-v8|\ +tplink,tl-wr941nd-v5) ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1" ucidef_set_led_switch "lan1" "LAN1" "green:lan1" "switch0" "0x04" ucidef_set_led_switch "lan2" "LAN2" "green:lan2" "switch0" "0x08" diff --git a/target/linux/ath79/tiny/base-files/etc/board.d/02_network b/target/linux/ath79/tiny/base-files/etc/board.d/02_network index 664359ce9a..4f6e2918a4 100644 --- a/target/linux/ath79/tiny/base-files/etc/board.d/02_network +++ b/target/linux/ath79/tiny/base-files/etc/board.d/02_network @@ -84,7 +84,8 @@ ath79_setup_interfaces() tplink,tl-wr740n-v4|\ tplink,tl-wr740n-v5|\ tplink,tl-wr741nd-v4|\ - tplink,tl-wr841-v8) + tplink,tl-wr841-v8|\ + tplink,tl-wr941nd-v5) ucidef_set_interface_wan "eth1" ucidef_add_switch "switch0" \ "0@eth0" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3" From 76fc277917fc847892dbbf525aea9f90a035d296 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 11 Sep 2022 22:17:47 +0200 Subject: [PATCH 069/114] ath79: Make patches apply again The patch adding support for LEDs connected to a reset controller did not apply any more, refresh it on top of current master. Fixes: 53fc987b2552 ("generic: move ledbar driver from mediatek target") Signed-off-by: Hauke Mehrtens --- .../0003-leds-add-reset-controller-based-driver.patch | 10 +++++----- .../0003-leds-add-reset-controller-based-driver.patch | 10 +++++----- .../generic/hack-5.10/800-ubnt-ledbar-driver.patch | 6 +++--- .../020-05-mm-multigenerational-lru-aging.patch | 2 +- ...alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/target/linux/ath79/patches-5.10/0003-leds-add-reset-controller-based-driver.patch b/target/linux/ath79/patches-5.10/0003-leds-add-reset-controller-based-driver.patch index 4a721f2af2..7505f682ab 100644 --- a/target/linux/ath79/patches-5.10/0003-leds-add-reset-controller-based-driver.patch +++ b/target/linux/ath79/patches-5.10/0003-leds-add-reset-controller-based-driver.patch @@ -13,9 +13,9 @@ Signed-off-by: John Crispin --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig -@@ -931,6 +931,17 @@ config LEDS_ACER_A500 - - source "drivers/leds/blink/Kconfig" +@@ -941,6 +941,17 @@ config LEDS_UBNT_LEDBAR + To compile this driver as a module, choose M here: the module + will be called leds-ubnt-ledbar. +config LEDS_RESET + tristate "LED support for reset-controller API" @@ -176,10 +176,10 @@ Signed-off-by: John Crispin +MODULE_ALIAS("platform:leds-reset"); --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile -@@ -93,6 +93,7 @@ obj-$(CONFIG_LEDS_TURRIS_OMNIA) += leds - obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o +@@ -94,6 +94,7 @@ obj-$(CONFIG_LEDS_WM831X_STATUS) += leds obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o + obj-$(CONFIG_LEDS_UBNT_LEDBAR) += leds-ubnt-ledbar.o +obj-$(CONFIG_LEDS_RESET) += leds-reset.o # LED SPI Drivers diff --git a/target/linux/ath79/patches-5.15/0003-leds-add-reset-controller-based-driver.patch b/target/linux/ath79/patches-5.15/0003-leds-add-reset-controller-based-driver.patch index 7122756c52..f958e79608 100644 --- a/target/linux/ath79/patches-5.15/0003-leds-add-reset-controller-based-driver.patch +++ b/target/linux/ath79/patches-5.15/0003-leds-add-reset-controller-based-driver.patch @@ -13,9 +13,9 @@ Signed-off-by: John Crispin --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig -@@ -876,6 +876,17 @@ source "drivers/leds/blink/Kconfig" - comment "Flash and Torch LED drivers" - source "drivers/leds/flash/Kconfig" +@@ -886,6 +886,17 @@ config LEDS_UBNT_LEDBAR + To compile this driver as a module, choose M here: the module + will be called leds-ubnt-ledbar. +config LEDS_RESET + tristate "LED support for reset-controller API" @@ -176,10 +176,10 @@ Signed-off-by: John Crispin +MODULE_ALIAS("platform:leds-reset"); --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile -@@ -87,6 +87,7 @@ obj-$(CONFIG_LEDS_TURRIS_OMNIA) += leds - obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o +@@ -88,6 +88,7 @@ obj-$(CONFIG_LEDS_WM831X_STATUS) += leds obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o + obj-$(CONFIG_LEDS_UBNT_LEDBAR) += leds-ubnt-ledbar.o +obj-$(CONFIG_LEDS_RESET) += leds-reset.o # LED SPI Drivers diff --git a/target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch b/target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch index 92264eedf9..2b4baab456 100644 --- a/target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch +++ b/target/linux/generic/hack-5.10/800-ubnt-ledbar-driver.patch @@ -1,8 +1,8 @@ --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig -@@ -929,6 +929,16 @@ config LEDS_ACER_A500 - This option enables support for the Power Button LED of - Acer Iconia Tab A500. +@@ -931,6 +931,16 @@ config LEDS_ACER_A500 + + source "drivers/leds/blink/Kconfig" +config LEDS_UBNT_LEDBAR + tristate "LED support for Ubiquiti UniFi 6 LR" diff --git a/target/linux/generic/pending-5.15/020-05-mm-multigenerational-lru-aging.patch b/target/linux/generic/pending-5.15/020-05-mm-multigenerational-lru-aging.patch index e5622ccbbe..6fc93d9422 100644 --- a/target/linux/generic/pending-5.15/020-05-mm-multigenerational-lru-aging.patch +++ b/target/linux/generic/pending-5.15/020-05-mm-multigenerational-lru-aging.patch @@ -168,7 +168,7 @@ Change-Id: I3ae8abc3100d023cecb3a699d86020ae6fc10a45 #include -@@ -790,6 +791,13 @@ static bool page_referenced_one(struct p +@@ -793,6 +794,13 @@ static bool page_referenced_one(struct p } if (pvmw.pte) { diff --git a/target/linux/generic/pending-5.15/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch b/target/linux/generic/pending-5.15/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch index 4e347a4671..b0b399a2dd 100644 --- a/target/linux/generic/pending-5.15/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch +++ b/target/linux/generic/pending-5.15/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch @@ -71,7 +71,7 @@ Signed-off-by: Tobias Wolf --- a/mm/page_alloc.c +++ b/mm/page_alloc.c -@@ -7556,7 +7556,7 @@ static void __init alloc_node_mem_map(st +@@ -7557,7 +7557,7 @@ static void __init alloc_node_mem_map(st if (pgdat == NODE_DATA(0)) { mem_map = NODE_DATA(0)->node_mem_map; if (page_to_pfn(mem_map) != pgdat->node_start_pfn) From 4fcfb61ec9c711eab165617524da9a8599824201 Mon Sep 17 00:00:00 2001 From: Jasper Scholte Date: Wed, 17 Aug 2022 21:30:04 +0200 Subject: [PATCH 070/114] ramips: use lzma-loader on Sitecom WLR-6000 Fixes the boot loader LZMA decompression issue: LZMA ERROR 1 - must RESET board to recover Signed-off-by: Jasper Scholte --- target/linux/ramips/image/rt3883.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/ramips/image/rt3883.mk b/target/linux/ramips/image/rt3883.mk index db4ffc83df..e76678be1a 100644 --- a/target/linux/ramips/image/rt3883.mk +++ b/target/linux/ramips/image/rt3883.mk @@ -108,6 +108,7 @@ endef TARGET_DEVICES += samsung_cy-swr1100 define Device/sitecom_wlr-6000 + $(Device/uimage-lzma-loader) SOC := rt3883 BLOCKSIZE := 4k IMAGE_SIZE := 7244k From 6cbcc34f50a3280f5897a86d69225c081711ca24 Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Wed, 7 Sep 2022 16:08:33 +0800 Subject: [PATCH 071/114] ramips: disable unsupported background radar detection Background radar detection is not supported on devices that using MT7905, so disable this feature in the following devices: asus,rt-ax53u jcg,q20 tplink,eap615-wall-v1 xiaomi,mi-router-cr6606 xiaomi,mi-router-cr6608 xiaomi,mi-router-cr6609 yuncore,ax820 Devices with MT7915 lacking a DFS antenna also do not support background DFS: totolink,x5000r cudy,x6 Signed-off-by: Shiji Yang --- target/linux/ramips/dts/mt7621_asus_rt-ax53u.dts | 1 + target/linux/ramips/dts/mt7621_cudy_x6.dts | 1 + target/linux/ramips/dts/mt7621_jcg_q20.dts | 1 + target/linux/ramips/dts/mt7621_totolink_x5000r.dts | 1 + target/linux/ramips/dts/mt7621_tplink_eap615-wall-v1.dts | 1 + target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr660x.dtsi | 1 + target/linux/ramips/dts/mt7621_yuncore_ax820.dts | 1 + 7 files changed, 7 insertions(+) diff --git a/target/linux/ramips/dts/mt7621_asus_rt-ax53u.dts b/target/linux/ramips/dts/mt7621_asus_rt-ax53u.dts index 329121595a..fc1a00a1c9 100644 --- a/target/linux/ramips/dts/mt7621_asus_rt-ax53u.dts +++ b/target/linux/ramips/dts/mt7621_asus_rt-ax53u.dts @@ -118,6 +118,7 @@ compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x0000>; + mediatek,disable-radar-background; }; }; diff --git a/target/linux/ramips/dts/mt7621_cudy_x6.dts b/target/linux/ramips/dts/mt7621_cudy_x6.dts index ad51aca28f..6cff9c25f3 100644 --- a/target/linux/ramips/dts/mt7621_cudy_x6.dts +++ b/target/linux/ramips/dts/mt7621_cudy_x6.dts @@ -120,6 +120,7 @@ compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x0000>; + mediatek,disable-radar-background; }; }; diff --git a/target/linux/ramips/dts/mt7621_jcg_q20.dts b/target/linux/ramips/dts/mt7621_jcg_q20.dts index 0425c53438..34236954d0 100644 --- a/target/linux/ramips/dts/mt7621_jcg_q20.dts +++ b/target/linux/ramips/dts/mt7621_jcg_q20.dts @@ -140,6 +140,7 @@ compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x0>; + mediatek,disable-radar-background; }; }; diff --git a/target/linux/ramips/dts/mt7621_totolink_x5000r.dts b/target/linux/ramips/dts/mt7621_totolink_x5000r.dts index bc03ed8690..79667caf73 100644 --- a/target/linux/ramips/dts/mt7621_totolink_x5000r.dts +++ b/target/linux/ramips/dts/mt7621_totolink_x5000r.dts @@ -93,6 +93,7 @@ compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x0000>; + mediatek,disable-radar-background; }; }; diff --git a/target/linux/ramips/dts/mt7621_tplink_eap615-wall-v1.dts b/target/linux/ramips/dts/mt7621_tplink_eap615-wall-v1.dts index 4fa799789c..594a9e7bb1 100644 --- a/target/linux/ramips/dts/mt7621_tplink_eap615-wall-v1.dts +++ b/target/linux/ramips/dts/mt7621_tplink_eap615-wall-v1.dts @@ -144,6 +144,7 @@ compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&radio 0x0>; + mediatek,disable-radar-background; }; }; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr660x.dtsi b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr660x.dtsi index a6c0033227..14ad0f26ba 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr660x.dtsi +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr660x.dtsi @@ -136,6 +136,7 @@ compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x0>; + mediatek,disable-radar-background; }; }; diff --git a/target/linux/ramips/dts/mt7621_yuncore_ax820.dts b/target/linux/ramips/dts/mt7621_yuncore_ax820.dts index 6ea3c922db..1aba94a912 100644 --- a/target/linux/ramips/dts/mt7621_yuncore_ax820.dts +++ b/target/linux/ramips/dts/mt7621_yuncore_ax820.dts @@ -135,6 +135,7 @@ compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x0>; + mediatek,disable-radar-background; }; }; From 60384d8a743666f8cbda6446b86067ef6246d032 Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Wed, 7 Sep 2022 16:08:33 +0800 Subject: [PATCH 072/114] mediatek: disable unsupported background radar detection MT7915 requires an additional antenna for background radar scanning. Disable this feature in the following devices that do not have a separate DFS antenna: linksys,e8450 ruijie,rg-ew3200gx-pro xiaomi,redmi-router-ax6s Signed-off-by: Shiji Yang --- target/linux/mediatek/dts/mt7622-linksys-e8450.dtsi | 4 +++- target/linux/mediatek/dts/mt7622-ruijie-rg-ew3200gx-pro.dts | 4 +++- target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/target/linux/mediatek/dts/mt7622-linksys-e8450.dtsi b/target/linux/mediatek/dts/mt7622-linksys-e8450.dtsi index 9f0dabdb4e..1fe839575e 100644 --- a/target/linux/mediatek/dts/mt7622-linksys-e8450.dtsi +++ b/target/linux/mediatek/dts/mt7622-linksys-e8450.dtsi @@ -336,9 +336,11 @@ }; &slot0 { - wmac1: mt7915@0,0 { + wmac1: wifi@0,0 { + compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; ieee80211-freq-limit = <5000000 6000000>; + mediatek,disable-radar-background; }; }; diff --git a/target/linux/mediatek/dts/mt7622-ruijie-rg-ew3200gx-pro.dts b/target/linux/mediatek/dts/mt7622-ruijie-rg-ew3200gx-pro.dts index df8f2a5814..fba9a1b8f7 100644 --- a/target/linux/mediatek/dts/mt7622-ruijie-rg-ew3200gx-pro.dts +++ b/target/linux/mediatek/dts/mt7622-ruijie-rg-ew3200gx-pro.dts @@ -164,10 +164,12 @@ }; &slot0 { - mt7915@0,0 { + wifi@0,0 { + compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x5000>; ieee80211-freq-limit = <5000000 6000000>; + mediatek,disable-radar-background; }; }; diff --git a/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts b/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts index 6c1208d4a8..73ee41bb2d 100644 --- a/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts +++ b/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts @@ -328,6 +328,7 @@ reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x5000>; ieee80211-freq-limit = <5000000 6000000>; + mediatek,disable-radar-background; }; }; From f5d6ed3007cb04bfef388e986d3b148b609cb959 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 12 Sep 2022 01:13:59 +0100 Subject: [PATCH 073/114] xdp-tools: don't rely on host bpf headers xdp-tools build currently breaks on build hosts which do not have libbpf headers installed because the build system wrongly tries to use the host's include path. Properly pass path to libbpf headers to xdp-tools build system to fix build e.g. on the buildbots. Signed-off-by: Daniel Golle --- package/network/utils/xdp-tools/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package/network/utils/xdp-tools/Makefile b/package/network/utils/xdp-tools/Makefile index 32f302543a..42a8a0695b 100644 --- a/package/network/utils/xdp-tools/Makefile +++ b/package/network/utils/xdp-tools/Makefile @@ -85,7 +85,6 @@ CONFIGURE_VARS += \ CFLAGS="$(TARGET_CFLAGS)" \ LDFLAGS="$(TARGET_LDFLAGS)" \ CLANG="$(CLANG)" \ - BPF_CFLAGS="$(BPF_CFLAGS)" \ BPF_TARGET="$(BPF_TARGET)" \ LLC="$(LLVM_LLC)" @@ -93,6 +92,11 @@ MAKE_VARS += \ PREFIX=/usr \ RUNDIR=/tmp/run +define Build/Configure + $(call Build/Configure/Default) + echo "BPF_CFLAGS += -I$(BPF_HEADERS_DIR)/tools/lib" >> $(PKG_BUILD_DIR)/config.mk +endef + define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include/xdp $(CP) $(PKG_INSTALL_DIR)/usr/include/xdp/*.h $(1)/usr/include/xdp/ From b4d81147708f715b771aee0143c74cd9a7ee8241 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 12 Sep 2022 01:43:04 +0100 Subject: [PATCH 074/114] firmware-utils: update to git HEAD 0c92b20 iptime-crc32: add support for A6004MX Signed-off-by: Daniel Golle --- tools/firmware-utils/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile index 63db641c3e..731bc8a04c 100644 --- a/tools/firmware-utils/Makefile +++ b/tools/firmware-utils/Makefile @@ -11,9 +11,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git -PKG_SOURCE_DATE:=2022-09-11 -PKG_SOURCE_VERSION:=71e1db65a5487bcbb18b2757655d2b59ae96292a -PKG_MIRROR_HASH:=3f9e7648afc82432a8011491af6354f8a82ccc3ba6d762af72649117e22d7054 +PKG_SOURCE_DATE:=2022-09-12 +PKG_SOURCE_VERSION:=0c92b20ad488a4fb5fb290f6d1b893df45761275 +PKG_MIRROR_HASH:=2cfd36e749b51d539cffe22c77a4c3ccd3bac2eca482affe23e1cab539e8bd16 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk From 49763d907b0d87769c3e5885f1c11b5b62ccfa2b Mon Sep 17 00:00:00 2001 From: Yoonji Park Date: Sun, 5 Jun 2022 18:04:18 +0000 Subject: [PATCH 075/114] kernel: add support for mtdsplit-fit offset Support devices that has vendor custom header before FIT image. Some devices has vendor custom header before FIT image. In this case mtd- split can not find FIT image and it results in rootfs mount failure. Please refer iptime,a6004mx device for further examples. Signed-off-by: Yoonji Park --- .../generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c index d8fb74ea38..3b71597d23 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c @@ -199,6 +199,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd, struct fdt_header hdr; size_t hdr_len, retlen; size_t offset; + u32 offset_start = 0; size_t fit_offset, fit_size; size_t rootfs_offset, rootfs_size; size_t data_size, img_total, max_size = 0; @@ -211,11 +212,13 @@ mtdsplit_fit_parse(struct mtd_info *mtd, if (cmdline_match && !strstr(saved_command_line, cmdline_match)) return -ENODEV; + of_property_read_u32(np, "openwrt,fit-offset", &offset_start); + hdr_len = sizeof(struct fdt_header); /* Parse the MTD device & search for the FIT image location */ for(offset = 0; offset + hdr_len <= mtd->size; offset += mtd->erasesize) { - ret = mtd_read(mtd, offset, hdr_len, &retlen, (void*) &hdr); + ret = mtd_read(mtd, offset + offset_start, hdr_len, &retlen, (void*) &hdr); if (ret) { pr_err("read error in \"%s\" at offset 0x%llx\n", mtd->name, (unsigned long long) offset); @@ -259,7 +262,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd, enum mtdsplit_part_type type; /* Search for the rootfs partition after the FIT image */ - ret = mtd_find_rootfs_from(mtd, fit_offset + fit_size, mtd->size, + ret = mtd_find_rootfs_from(mtd, fit_offset + fit_size + offset_start, mtd->size, &rootfs_offset, &type); if (ret) { pr_info("no rootfs found after FIT image in \"%s\"\n", @@ -275,7 +278,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd, parts[0].name = KERNEL_PART_NAME; parts[0].offset = fit_offset; - parts[0].size = mtd_rounddown_to_eb(fit_size, mtd) + mtd->erasesize; + parts[0].size = mtd_rounddown_to_eb(fit_size + offset_start, mtd) + mtd->erasesize; if (type == MTDSPLIT_PART_TYPE_UBI) parts[1].name = UBI_PART_NAME; @@ -290,7 +293,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd, } else { /* Search for rootfs_data after FIT external data */ fit = kzalloc(fit_size, GFP_KERNEL); - ret = mtd_read(mtd, offset, fit_size, &retlen, fit); + ret = mtd_read(mtd, offset, fit_size + offset_start, &retlen, fit); if (ret) { pr_err("read error in \"%s\" at offset 0x%llx\n", mtd->name, (unsigned long long) offset); From c27279dc26a26b8ad054882d4c5f86a85526fd16 Mon Sep 17 00:00:00 2001 From: Yoonji Park Date: Mon, 6 Jun 2022 07:44:48 +0000 Subject: [PATCH 076/114] mediatek: add support for ipTIME A6004MX Add basic support for ipTIME A6004MX. Hardware: SoC: MediaTek MT7629 Cortex-A7 (ARMv7 1.25GHz, Dual-Core) RAM: DDR3 128MB Flash: Macronix MX35LF1GE4AB (SPI-NAND 128MB) WiFi: MediaTek MT7761N (2.4GHz) / MediaTek MT7762N (5GHz) - no driver Ethernet: SoC (WAN) / MediaTek MT7531 (LAN x4) UART: [GND, RX, TX, 3.3V] (115200) Installation: - Flash recovery image with TFTP recovery Revert to stock firmware: - Flash stock firmware with TFTP recovery TFTP Recovery method: 1. Unplug the router 2. Hold the reset button and plug in 3. Release when the power LED stops flashing and go off 4. Set your computer IP address manually to 192.168.0.x / 255.255.255.0 5. Flash image with TFTP client to 192.168.0.1 Signed-off-by: Yoonji Park --- .../boot/uboot-envtools/files/mediatek_mt7629 | 23 ++ .../mediatek/dts/mt7629-iptime-a6004mx.dts | 294 ++++++++++++++++++ target/linux/mediatek/image/mt7629.mk | 17 + .../mt7629/base-files/etc/board.d/01_leds | 16 + .../mt7629/base-files/etc/board.d/02_network | 3 + .../mt7629/base-files/etc/init.d/bootcount | 17 + .../mt7629/base-files/lib/upgrade/platform.sh | 3 + target/linux/mediatek/mt7629/config-5.15 | 6 + .../901-arm-add-cmdline-override.patch | 37 +++ 9 files changed, 416 insertions(+) create mode 100644 package/boot/uboot-envtools/files/mediatek_mt7629 create mode 100644 target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts create mode 100644 target/linux/mediatek/mt7629/base-files/etc/board.d/01_leds create mode 100755 target/linux/mediatek/mt7629/base-files/etc/init.d/bootcount create mode 100644 target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch diff --git a/package/boot/uboot-envtools/files/mediatek_mt7629 b/package/boot/uboot-envtools/files/mediatek_mt7629 new file mode 100644 index 0000000000..a5aa2b58a6 --- /dev/null +++ b/package/boot/uboot-envtools/files/mediatek_mt7629 @@ -0,0 +1,23 @@ +# +# Copyright (C) 2021 OpenWrt.org +# + +[ -e /etc/config/ubootenv ] && exit 0 + +touch /etc/config/ubootenv + +. /lib/uboot-envtools.sh +. /lib/functions.sh + +board=$(board_name) + +case "$board" in +iptime,a6004mx) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" + ;; +esac + +config_load ubootenv +config_foreach ubootenv_add_app_config ubootenv + +exit 0 diff --git a/target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts b/target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts new file mode 100644 index 0000000000..b40ac52848 --- /dev/null +++ b/target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: GPL-2.0 + +/dts-v1/; +#include +#include "mt7629.dtsi" + +/ { + model = "ipTIME A6004MX"; + compatible = "iptime,a6004mx", "mediatek,mt7629"; + + aliases { + led-boot = &led_cpu; + led-failsafe = &led_cpu; + led-running = &led_cpu; + led-upgrade = &led_cpu; + serial0 = &uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-override = "console=ttyS0,115200n8"; + }; + + leds { + compatible = "gpio-leds"; + + led_cpu: cpu { + label = "orange:cpu"; + gpios = <&pio 57 GPIO_ACTIVE_LOW>; + }; + + wlan5g { + label = "orange:wlan5g"; + gpios = <&pio 22 GPIO_ACTIVE_LOW>; + // linux,default-trigger = "phy0radio"; + }; + + wlan2g { + label = "orange:wlan2g"; + gpios = <&pio 21 GPIO_ACTIVE_LOW>; + // linux,default-trigger = "phy1radio"; + }; + + wan { + label = "orange:wan"; + gpios = <&pio 12 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "factory"; + linux,code = ; + gpios = <&pio 60 GPIO_ACTIVE_LOW>; + }; + + wps { + label = "wps"; + linux,code = ; + gpios = <&pio 58 GPIO_ACTIVE_LOW>; + }; + }; + + memory@40000000 { + device_type = "memory"; + reg = <0x40000000 0x10000000>; + }; + + reg_3p3v: regulator-3p3v { + compatible = "regulator-fixed"; + regulator-name = "fixed-3.3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + regulator-always-on; + }; + + reg_5v: regulator-5v { + compatible = "regulator-fixed"; + regulator-name = "fixed-5V"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + regulator-always-on; + }; +}; + +ð { + pinctrl-names = "default"; + pinctrl-0 = <ð_pins>; + pinctrl-1 = <&ephy_leds_pins>; + status = "okay"; + + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; + nvmem-cells = <&macaddr_factory_4>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <3>; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + + gmac1: mac@1 { + compatible = "mediatek,eth-mac"; + reg = <1>; + phy-mode = "gmii"; + phy-handle = <&phy0>; + nvmem-cells = <&macaddr_factory_4>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <1>; + }; + + mdio: mdio-bus { + #address-cells = <1>; + #size-cells = <0>; + + phy0: ethernet-phy@0 { + reg = <0>; + }; + + switch@2 { + compatible = "mediatek,mt7531"; + reg = <2>; + reset-gpios = <&pio 28 0>; + interrupt-controller; + #interrupt-cells = <1>; + interrupt-parent = <&pio>; + interrupts = <6 IRQ_TYPE_LEVEL_HIGH>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan1"; + }; + + port@1 { + reg = <1>; + label = "lan2"; + }; + + port@2 { + reg = <2>; + label = "lan3"; + }; + + port@3 { + reg = <3>; + label = "lan4"; + }; + + port@6 { + reg = <6>; + label = "cpu"; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; + }; + }; +}; + +&bch { + status = "okay"; +}; + +&snfi { + pinctrl-names = "default"; + pinctrl-0 = <&serial_nand_pins>; + status = "okay"; + flash@0 { + compatible = "spi-nand"; + reg = <0>; + spi-tx-bus-width = <4>; + spi-rx-bus-width = <4>; + nand-ecc-engine = <&snfi>; + mediatek,bmt-v2; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "Bootloader"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "Config"; + reg = <0x100000 0x40000>; + }; + + partition@140000 { + label = "factory"; + reg = <0x140000 0x80000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_4: macaddr@4 { + reg = <0x4 0x6>; + }; + }; + + partition@1c0000 { + label = "firmware"; + reg = <0x1c0000 0x7400000>; + compatible = "denx,fit"; + openwrt,fit-offset = <0x800>; + }; + }; + }; +}; + +&pio { + eth_pins: eth-pins { + mux { + function = "eth"; + groups = "mdc_mdio"; + }; + }; + + ephy_leds_pins: ephy-leds-pins { + mux { + function = "led"; + groups = "ephy_leds"; + }; + }; + + /* Serial NAND is shared pin with SPI-NOR */ + serial_nand_pins: serial-nand-pins { + mux { + function = "flash"; + groups = "snfi"; + }; + }; + + uart0_pins: uart0-pins { + mux { + function = "uart"; + groups = "uart0_txd_rxd" ; + }; + }; + + watchdog_pins: watchdog-pins { + mux { + function = "watchdog"; + groups = "watchdog"; + }; + }; +}; + +&ssusb { + vusb33-supply = <®_3p3v>; + vbus-supply = <®_5v>; + status = "okay"; +}; + +&uart0 { + pinctrl-names = "default"; + pinctrl-0 = <&uart0_pins>; + status = "okay"; +}; + +&watchdog { + pinctrl-names = "default"; + pinctrl-0 = <&watchdog_pins>; + status = "okay"; + + interrupt-controller; + #interrupt-cells = <1>; + interrupt-parent = <&pio>; + interrupts = ; +}; diff --git a/target/linux/mediatek/image/mt7629.mk b/target/linux/mediatek/image/mt7629.mk index 754ce974b1..891b65c4e7 100644 --- a/target/linux/mediatek/image/mt7629.mk +++ b/target/linux/mediatek/image/mt7629.mk @@ -7,3 +7,20 @@ define Device/mediatek_mt7629-rfb DEVICE_PACKAGES := swconfig endef TARGET_DEVICES += mediatek_mt7629-rfb + +define Device/iptime_a6004mx + DEVICE_VENDOR := ipTIME + DEVICE_MODEL := A6004MX + DEVICE_DTS := mt7629-iptime-a6004mx + DEVICE_DTS_DIR := ../dts + DEVICE_PACKAGES := kmod-usb3 uboot-envtools + UBINIZE_OPTS := -E 5 + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL := $$(KERNEL) | pad-offset 128k 2048 | iptime-crc32 a6004mx + KERNEL_INITRAMFS := $$(KERNEL_INITRAMFS) | pad-offset 128k 2048 | iptime-crc32 a6004mx + IMAGES += recovery.bin + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + IMAGE/recovery.bin := append-kernel | pad-to 128k | append-ubi | append-metadata +endef +TARGET_DEVICES += iptime_a6004mx diff --git a/target/linux/mediatek/mt7629/base-files/etc/board.d/01_leds b/target/linux/mediatek/mt7629/base-files/etc/board.d/01_leds new file mode 100644 index 0000000000..42b6fcbbb3 --- /dev/null +++ b/target/linux/mediatek/mt7629/base-files/etc/board.d/01_leds @@ -0,0 +1,16 @@ +. /lib/functions/leds.sh +. /lib/functions/uci-defaults.sh + +board=$(board_name) + +board_config_update + +case $board in +iptime,a6004mx) + ucidef_set_led_netdev "wan" "WAN" "orange:wan" "eth1" + ;; +esac + +board_config_flush + +exit 0 diff --git a/target/linux/mediatek/mt7629/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7629/base-files/etc/board.d/02_network index c39417abbc..4254f39ca0 100644 --- a/target/linux/mediatek/mt7629/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/mt7629/base-files/etc/board.d/02_network @@ -8,6 +8,9 @@ mediatek_setup_interfaces() local board="$1" case $board in + iptime,a6004mx) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "eth1" + ;; mediatek,mt7629-rfb) ucidef_set_interface_wan "eth1" ucidef_add_switch "switch0" \ diff --git a/target/linux/mediatek/mt7629/base-files/etc/init.d/bootcount b/target/linux/mediatek/mt7629/base-files/etc/init.d/bootcount new file mode 100755 index 0000000000..a6b8fac1d9 --- /dev/null +++ b/target/linux/mediatek/mt7629/base-files/etc/init.d/bootcount @@ -0,0 +1,17 @@ +#!/bin/sh /etc/rc.common +# SPDX-License-Identifier: GPL-2.0-only + +START=99 + +boot() { + case $(board_name) in + iptime,a6004mx) + if [ `fw_printenv boot_sector` = "boot_sector=B" ]; then + echo "bootcount: boot_sector must be A. Rebooting..." + fw_setenv boot_sector A + reboot + exit 1 + fi + ;; + esac +} diff --git a/target/linux/mediatek/mt7629/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7629/base-files/lib/upgrade/platform.sh index 9a613c43b1..f10ad14b49 100755 --- a/target/linux/mediatek/mt7629/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7629/base-files/lib/upgrade/platform.sh @@ -9,6 +9,9 @@ platform_do_upgrade() { local board=$(board_name) case "$board" in + iptime,a6004mx) + nand_do_upgrade "$1" + ;; *) default_do_upgrade "$1" ;; diff --git a/target/linux/mediatek/mt7629/config-5.15 b/target/linux/mediatek/mt7629/config-5.15 index 010151d4b3..39596717ae 100644 --- a/target/linux/mediatek/mt7629/config-5.15 +++ b/target/linux/mediatek/mt7629/config-5.15 @@ -44,6 +44,7 @@ CONFIG_CLKSRC_MMIO=y CONFIG_CLONE_BACKWARDS=y CONFIG_CMDLINE="rootfstype=squashfs,jffs2" CONFIG_CMDLINE_FROM_BOOTLOADER=y +CONFIG_CMDLINE_OVERRIDE=y CONFIG_COMMON_CLK=y CONFIG_COMMON_CLK_MEDIATEK=y # CONFIG_COMMON_CLK_MT2701 is not set @@ -195,11 +196,16 @@ CONFIG_MTK_TIMER=y CONFIG_MUTEX_SPIN_ON_OWNER=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NETFILTER=y +CONFIG_NET_DEVLINK=y +CONFIG_NET_DSA=y +CONFIG_NET_DSA_MT7530=y +CONFIG_NET_DSA_TAG_MTK=y CONFIG_NET_FLOW_LIMIT=y CONFIG_NET_MEDIATEK_SOC=y CONFIG_NET_MEDIATEK_SOC_WED=y CONFIG_NET_SELFTESTS=y CONFIG_NET_SOCK_MSG=y +CONFIG_NET_SWITCHDEV=y CONFIG_NET_VENDOR_MEDIATEK=y CONFIG_NLS=y CONFIG_NO_HZ_COMMON=y diff --git a/target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch b/target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch new file mode 100644 index 0000000000..a11219d353 --- /dev/null +++ b/target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch @@ -0,0 +1,37 @@ +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1794,6 +1794,14 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGL + + endchoice + ++config CMDLINE_OVERRIDE ++ bool "Use alternative cmdline from device tree" ++ help ++ Some bootloaders may have uneditable bootargs. While CMDLINE_FORCE can ++ be used, this is not a good option for kernels that are shared across ++ devices. This setting enables using "chosen/cmdline-override" as the ++ cmdline if it exists in the device tree. ++ + config CMDLINE + string "Default kernel command string" + default "" +--- a/drivers/of/fdt.c ++++ b/drivers/of/fdt.c +@@ -1059,6 +1059,17 @@ int __init early_init_dt_scan_chosen(uns + if (p != NULL && l > 0) + strlcat(data, p, min_t(int, strlen(data) + (int)l, COMMAND_LINE_SIZE)); + ++ /* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different ++ * device tree option of chosen/bootargs-override. This is ++ * helpful on boards where u-boot sets bootargs, and is unable ++ * to be modified. ++ */ ++#ifdef CONFIG_CMDLINE_OVERRIDE ++ p = of_get_flat_dt_prop(node, "bootargs-override", &l); ++ if (p != NULL && l > 0) ++ strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE)); ++#endif ++ + /* + * CONFIG_CMDLINE is meant to be a default in case nothing else + * managed to set the command line, unless CONFIG_CMDLINE_FORCE From a46e91e8a1c0e4e38d6c0bcb26eb49c54bc3a408 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 12 Sep 2022 14:10:26 +0100 Subject: [PATCH 077/114] mediatek: unset CONFIG_CMDLINE_OVERRIDE for all targets but mt7629 The newly introduced config symbol CONFIG_CMDLINE_OVERRIDE is only set for mt7629 for now which breaks automated build on all other mediatek subtargets. Make sure the symbol is configured as 'is not set' for all remaining subtargets. Fixes: c27279dc26 ("mediatek: add support for ipTIME A6004MX Add basic support for ipTIME A6004MX.") Signed-off-by: Daniel Golle --- target/linux/mediatek/filogic/config-5.15 | 1 + target/linux/mediatek/mt7622/config-5.15 | 1 + target/linux/mediatek/mt7623/config-5.15 | 1 + 3 files changed, 3 insertions(+) diff --git a/target/linux/mediatek/filogic/config-5.15 b/target/linux/mediatek/filogic/config-5.15 index 3c73e003c9..0c026e0e01 100644 --- a/target/linux/mediatek/filogic/config-5.15 +++ b/target/linux/mediatek/filogic/config-5.15 @@ -50,6 +50,7 @@ CONFIG_BSD_PROCESS_ACCT_V3=y CONFIG_CC_HAVE_STACKPROTECTOR_SYSREG=y CONFIG_CLKSRC_MMIO=y CONFIG_CLONE_BACKWARDS=y +# CONFIG_CMDLINE_OVERRIDE is not set CONFIG_COMMON_CLK=y CONFIG_COMMON_CLK_MEDIATEK=y # CONFIG_COMMON_CLK_MT2712 is not set diff --git a/target/linux/mediatek/mt7622/config-5.15 b/target/linux/mediatek/mt7622/config-5.15 index 47464eb40f..8717e799ed 100644 --- a/target/linux/mediatek/mt7622/config-5.15 +++ b/target/linux/mediatek/mt7622/config-5.15 @@ -54,6 +54,7 @@ CONFIG_BSD_PROCESS_ACCT_V3=y CONFIG_CC_HAVE_STACKPROTECTOR_SYSREG=y CONFIG_CLKSRC_MMIO=y CONFIG_CLONE_BACKWARDS=y +# CONFIG_CMDLINE_OVERRIDE is not set CONFIG_COMMON_CLK=y CONFIG_COMMON_CLK_MEDIATEK=y CONFIG_COMMON_CLK_MT2712=y diff --git a/target/linux/mediatek/mt7623/config-5.15 b/target/linux/mediatek/mt7623/config-5.15 index 215bd2186c..d28b051c85 100644 --- a/target/linux/mediatek/mt7623/config-5.15 +++ b/target/linux/mediatek/mt7623/config-5.15 @@ -54,6 +54,7 @@ CONFIG_CLONE_BACKWARDS=y CONFIG_CMDLINE="earlyprintk console=ttyS0,115200 rootfstype=squashfs,jffs2" CONFIG_CMDLINE_FROM_BOOTLOADER=y CONFIG_CMDLINE_PARTITION=y +# CONFIG_CMDLINE_OVERRIDE is not set CONFIG_COMMON_CLK=y CONFIG_COMMON_CLK_MEDIATEK=y CONFIG_COMMON_CLK_MT2701=y From 2905ce3d643f1a098139d16d9c73ff7e802ee04e Mon Sep 17 00:00:00 2001 From: Sergei Burakov Date: Fri, 20 May 2022 16:20:23 +0300 Subject: [PATCH 078/114] ramips: add support for ZyXEL Keenetic 4G Rev.B Device Specification: SoC: RT5350 CPU Frequency: 360 MHz Flash Chip: Macronix MX25L6406E (8192 KiB) RAM: Winbond W9825G6JH-6 (32768 KiB) 3x 10/100 Mbps Ethernet (2x LAN, 1x WAN) 1x external antenna UART (J1) header on PCB (57800 8n1) Wireless: SoC-intergated: 2.4GHz 802.11bgn USB: Yes 8x LED, 2x button Flash instruction: Configure PC with static IP 192.168.99.8/24 and start TFTP server. Rename "openwrt-ramips-rt305x-zyxel_keenetic-4g-b-squashfs-sysupgrade.bin" to "rt305x_firmware.bin" and place it in TFTP server directory. Connect PC with one of LAN ports, press the reset button, power up the router and keep button pressed until power LED start blinking. Router will download file from TFTP server, write it to flash and reboot. Signed-off-by: Sergei Burakov --- .../ramips/dts/rt5350_zyxel_keenetic-4g-b.dts | 136 ++++++++++++++++++ target/linux/ramips/image/rt305x.mk | 10 ++ .../rt305x/base-files/etc/board.d/02_network | 4 + 3 files changed, 150 insertions(+) create mode 100644 target/linux/ramips/dts/rt5350_zyxel_keenetic-4g-b.dts diff --git a/target/linux/ramips/dts/rt5350_zyxel_keenetic-4g-b.dts b/target/linux/ramips/dts/rt5350_zyxel_keenetic-4g-b.dts new file mode 100644 index 0000000000..9b5c45347b --- /dev/null +++ b/target/linux/ramips/dts/rt5350_zyxel_keenetic-4g-b.dts @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "rt5350.dtsi" + +#include +#include + +/ { + compatible = "zyxel,keenetic-4g-b", "ralink,rt5350-soc"; + model = "ZyXEL Keenetic 4G Rev.B"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "green:power"; + gpios = <&gpio0 9 GPIO_ACTIVE_LOW>; + }; + + usb { + label = "green:usb"; + gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>; + }; + + reserved { + label = "green:reserved"; + gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>; + }; + + internet { + label = "green:internet"; + gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>; + }; + + wlan { + label = "green:wlan"; + gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>; + }; + + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + gpios = <&gpio0 0 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&gpio0 10 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <30000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0x7b0000>; + }; + }; + }; +}; + +&state_default { + gpio { + groups = "uartf"; + function = "gpio"; + }; +}; + +ðernet { + nvmem-cells = <&macaddr_factory_28>; + nvmem-cell-names = "mac-address"; +}; + +&esw { + mediatek,portmap = <0x2f>; + mediatek,led_polarity = <0x17>; +}; + +&wmac { + ralink,led-polarity = <1>; + ralink,mtd-eeprom = <&factory 0x0>; +}; + +&factory { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_28: macaddr@28 { + reg = <0x28 0x6>; + }; +}; diff --git a/target/linux/ramips/image/rt305x.mk b/target/linux/ramips/image/rt305x.mk index 708aeb8555..6b8dada3c9 100644 --- a/target/linux/ramips/image/rt305x.mk +++ b/target/linux/ramips/image/rt305x.mk @@ -1206,6 +1206,16 @@ define Device/zyxel_keenetic endef TARGET_DEVICES += zyxel_keenetic +define Device/zyxel_keenetic-4g-b + $(Device/uimage-lzma-loader) + SOC := rt5350 + IMAGE_SIZE := 7872k + DEVICE_VENDOR := ZyXEL + DEVICE_MODEL := Keenetic 4G + DEVICE_VARIANT := B +endef +TARGET_DEVICES += zyxel_keenetic-4g-b + define Device/zyxel_keenetic-lite-b $(Device/uimage-lzma-loader) SOC := rt5350 diff --git a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network index db200de9fa..64c3997f27 100644 --- a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network +++ b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network @@ -167,6 +167,10 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:lan" "3:lan" "6@eth0" ;; + zyxel,keenetic-4g-b) + ucidef_add_switch "switch0" \ + "0:lan:1" "1:lan:0" "4:wan" "6@eth0" + ;; zyxel,keenetic-lite-b|\ zyxel,keenetic-start) ucidef_add_switch "switch0" \ From 55aa11d121a33fc597890ac7cbe7484791abde28 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 12 Sep 2022 21:30:54 +0200 Subject: [PATCH 079/114] unetd: only depend on bpf-headers if BPF toolchain support is available If BPF is unavailable, unetd can be built without it (by disabling VXLAN support). Signed-off-by: Felix Fietkau --- package/network/services/unetd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/unetd/Makefile b/package/network/services/unetd/Makefile index 06e95b3326..c645ee57d8 100644 --- a/package/network/services/unetd/Makefile +++ b/package/network/services/unetd/Makefile @@ -17,7 +17,7 @@ PKG_MIRROR_HASH:=a693c2b4b4bda5e1e44b493019e8e6e6d39c4048f417b581c801a9931e6b9b3 PKG_LICENSE:=GPL-2.0 PKG_MAINTAINER:=Felix Fietkau -PKG_BUILD_DEPENDS:=bpf-headers +PKG_BUILD_DEPENDS:=HAS_BPF_TOOLCHAIN:bpf-headers PKG_BUILD_PARALLEL:=1 From d4feb66048f6a8f387eedfb162a1184cdae9d756 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 12 Sep 2022 21:21:05 +0100 Subject: [PATCH 080/114] mac80211: add patch descriptions to rt2x00 patches Prepare patches for sending upstream by adding patch descriptions generated from the original OpenWrt commits adding each patch. Signed-off-by: Daniel Golle --- ...612-rt2x00-add-throughput-LED-trigger.patch} | 3 +++ ...2-rt2x00-add-RF-self-TXDC-calibration.patch} | 14 ++++++++++++++ .../rt2x00/983-rt2x00-add-r-calibration.patch | 14 ++++++++++++++ ... => 984-rt2x00-add-RXDCOC-calibration.patch} | 14 ++++++++++++++ ...ch => 985-rt2x00-add-RXIQ-calibration.patch} | 15 +++++++++++++++ .../986-rt2x00-add-TX-LOFT-calibration.patch | 17 ++++++++++++++++- 6 files changed, 76 insertions(+), 1 deletion(-) rename package/kernel/mac80211/patches/rt2x00/{612-rt2x00-led-tpt-trigger-support.patch => 612-rt2x00-add-throughput-LED-trigger.patch} (93%) rename package/kernel/mac80211/patches/rt2x00/{982-rt2x00-add-rf-self-txdc-calibration.patch => 982-rt2x00-add-RF-self-TXDC-calibration.patch} (83%) rename package/kernel/mac80211/patches/rt2x00/{984-rt2x00-add-rxdcoc-calibration.patch => 984-rt2x00-add-RXDCOC-calibration.patch} (84%) rename package/kernel/mac80211/patches/rt2x00/{985-rt2x00-add-rxiq-calibration.patch => 985-rt2x00-add-RXIQ-calibration.patch} (95%) diff --git a/package/kernel/mac80211/patches/rt2x00/612-rt2x00-led-tpt-trigger-support.patch b/package/kernel/mac80211/patches/rt2x00/612-rt2x00-add-throughput-LED-trigger.patch similarity index 93% rename from package/kernel/mac80211/patches/rt2x00/612-rt2x00-led-tpt-trigger-support.patch rename to package/kernel/mac80211/patches/rt2x00/612-rt2x00-add-throughput-LED-trigger.patch index 6e6564f870..f27873acc0 100644 --- a/package/kernel/mac80211/patches/rt2x00/612-rt2x00-led-tpt-trigger-support.patch +++ b/package/kernel/mac80211/patches/rt2x00/612-rt2x00-add-throughput-LED-trigger.patch @@ -8,6 +8,9 @@ was limited to a single VAP. Signed-off-by: David Bauer Tested-by: Christoph Krapp +--- + drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c diff --git a/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch b/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-RF-self-TXDC-calibration.patch similarity index 83% rename from package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch rename to package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-RF-self-TXDC-calibration.patch index b798dcc6d8..b74bea2020 100644 --- a/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-RF-self-TXDC-calibration.patch @@ -1,3 +1,17 @@ +From: =?UTF-8?q?Tomislav=20Po=C5=BEega?= +Date: Mon, 8 Jan 2018 13:42:27 +0100 +Subject: [PATCH] rt2x00: add RF self TXDC calibration +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add TX self calibration based on mtk driver. + +Signed-off-by: Tomislav Požega +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 51 +++++++++++++++++++ + 1 file changed, 51 insertions(+) + --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c @@ -8438,6 +8438,56 @@ static void rt2800_init_rfcsr_5592(struc diff --git a/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch b/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch index cf21c39a6c..04ea802117 100644 --- a/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch @@ -1,3 +1,17 @@ +From: =?UTF-8?q?Tomislav=20Po=C5=BEega?= +Date: Mon, 8 Jan 2018 13:42:58 +0100 +Subject: [PATCH] rt2x00: add r calibration +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add r calibration code as found in mtk driver. + +Signed-off-by: Tomislav Požega +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 150 ++++++++++++++++++ + 1 file changed, 150 insertions(+) + --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c @@ -8488,6 +8488,155 @@ static void rt2800_rf_self_txdc_cal(stru diff --git a/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch b/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-RXDCOC-calibration.patch similarity index 84% rename from package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch rename to package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-RXDCOC-calibration.patch index 1f8684b0bf..821af87ec1 100644 --- a/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-RXDCOC-calibration.patch @@ -1,3 +1,17 @@ +From: =?UTF-8?q?Tomislav=20Po=C5=BEega?= +Date: Mon, 8 Jan 2018 13:43:37 +0100 +Subject: [PATCH] rt2x00: add RXDCOC calibration +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add RXDCOC calibration code from mtk driver. + +Signed-off-by: Tomislav Požega +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 65 +++++++++++++++++++ + 1 file changed, 65 insertions(+) + --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c @@ -8637,6 +8637,70 @@ static void rt2800_r_calibration(struct diff --git a/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch b/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-RXIQ-calibration.patch similarity index 95% rename from package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch rename to package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-RXIQ-calibration.patch index 98f2e245ce..1c07cc7520 100644 --- a/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-RXIQ-calibration.patch @@ -1,3 +1,18 @@ +From: =?UTF-8?q?Tomislav=20Po=C5=BEega?= +Date: Mon, 8 Jan 2018 13:43:56 +0100 +Subject: [PATCH] rt2x00: add RXIQ calibration +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add RXIQ calibration found in mtk driver. With old openwrt builds this +gets us ~8Mbps more of RX bandwidth (test with iPA/eLNA layout). + +Signed-off-by: Tomislav Požega +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 379 ++++++++++++++++++ + 1 file changed, 379 insertions(+) + --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c @@ -8701,6 +8701,384 @@ static void rt2800_rxdcoc_calibration(st diff --git a/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch b/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch index 6a685f80ab..a816aaf52a 100644 --- a/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch @@ -1,3 +1,18 @@ +From: =?UTF-8?q?Tomislav=20Po=C5=BEega?= +Date: Thu, 11 Jan 2018 19:53:49 +0100 +Subject: [PATCH] rt2x00: add TX LOFT calibration +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add TX LOFT calibration from mtk driver. + +Signed-off-by: Tomislav Požega +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 938 ++++++++++++++++++ + .../net/wireless/ralink/rt2x00/rt2800lib.h | 10 + + 2 files changed, 948 insertions(+) + --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c @@ -9079,6 +9079,943 @@ restore_value: @@ -630,7 +645,7 @@ + + if (vga_gain[ch_idx] < 0) + vga_gain[ch_idx] = 0; -+ } ++ } + + rfvalue = rfvga_gain_table[vga_gain[ch_idx]]; + From 31a6605de04218e1c04bd5c2436c24d7d1c07506 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 28 Jul 2022 13:40:12 +0200 Subject: [PATCH 081/114] mac80211: rt2x00: experimental improvements for MT7620 wifi Serge Vasilugin reports: To improve mt7620 built-in wifi performance some changes: 1. Correct BW20/BW40 switching (see comments with mark (1)) 2. Correct TX_SW_CFG1 MAC reg from v3 of vendor driver see https://gitlab.com/dm38/padavan-ng/-/blob/master/trunk/proprietary/rt_wifi/rtpci/3.0.X.X/mt76x2/chips/rt6352.c#L531 3. Set bbp66 for all chains. 4. US_CYC_CNT init based on Programming guide, default value was 33 (pci), set chipset bus clock with fallback to cpu clock/3. 5. Don't overwrite default values for mt7620. 6. Correct some typos. 7. Add support for external LNA: a) RF and BBP regs never be corrected for this mode b) eLNA is driven the same way as ePA with mt7620's pin PA but vendor driver explicitly pin PA to gpio mode (for forrect calibration?) so I'm not sure that request for pa_pin in dts-file will be enough First 5 changes (really 2) improve performance for boards w/o eLNA/ePA. Changes 7 add support for eLNA Configuration w/o eLAN/ePA and with eLNA show results tx/rx (from router point of view) for each stream: 35-40/30-35 Mbps for HT20 65-70/60-65 Mbps for HT40 Yes. Max results for 2T2R client is 140-145/135-140 with peaks 160/150, It correspond to mediatek driver results. Boards with ePA untested. Reported-by: Serge Vasilugin Signed-off-by: Daniel Golle --- .../rt2x00/992-rt2x00-more-fixes.patch | 423 ++++++++++++++++++ target/linux/ramips/dts/mt7620a.dtsi | 7 + .../ramips/dts/mt7620a_buffalo_whr-300hp2.dts | 3 +- .../linux/ramips/dts/mt7620a_cameo_810.dtsi | 3 +- .../ramips/dts/mt7620a_dlink_dch-m225.dts | 3 +- .../linux/ramips/dts/mt7620a_fon_fon2601.dts | 4 +- .../ramips/dts/mt7620a_hiwifi_hc5861.dts | 3 +- .../ramips/dts/mt7620a_lenovo_newifi-y1.dtsi | 6 +- .../ramips/dts/mt7620a_phicomm_k2-v22.4.dts | 3 +- .../ramips/dts/mt7620a_phicomm_k2-v22.5.dts | 3 +- .../linux/ramips/dts/mt7620a_phicomm_k2g.dts | 3 +- .../dts/mt7620a_tplink_archer-c20-v1.dts | 3 +- .../dts/mt7620a_tplink_archer-c50-v1.dts | 3 +- .../dts/mt7620a_wavlink_wl-wn530hg4.dts | 3 +- .../ramips/dts/mt7620a_xiaomi_miwifi-mini.dts | 4 +- .../linux/ramips/dts/mt7620a_youku_yk-l1.dtsi | 4 + .../dts/mt7620a_zbtlink_zbt-ape522ii.dts | 4 +- 17 files changed, 467 insertions(+), 15 deletions(-) create mode 100644 package/kernel/mac80211/patches/rt2x00/992-rt2x00-more-fixes.patch diff --git a/package/kernel/mac80211/patches/rt2x00/992-rt2x00-more-fixes.patch b/package/kernel/mac80211/patches/rt2x00/992-rt2x00-more-fixes.patch new file mode 100644 index 0000000000..2ad6219014 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/992-rt2x00-more-fixes.patch @@ -0,0 +1,423 @@ +From: Daniel Golle +Date: Mon, 12 Sep 2022 21:33:13 +0100 +Subject: [PATCH] rt2x00: various experimental fixes for MT7620 + +Serge Vasilugin reports: + +To improve mt7620 built-in wifi performance some changes: +1. Correct BW20/BW40 switching (see comments with mark see commets with mark (1)) +2. Correct TX_SW_CFG1 MAC reg from v3 of vendor driver see + https://gitlab.com/dm38/padavan-ng/-/blob/master/trunk/proprietary/rt_wifi/rtpci/3.0.X.X/mt76x2/chips/rt6352.c#L531 +3. Set bbp66 for all chains. +4. US_CYC_CNT init based on Programming guide, default value was 33 (pci), + set chipset bus clock with fallback to cpu clock/3. +5. Don't overwrite default values for mt7620. +6. Correct some typos. +7. Add support for external LNA: + a) RF and BBP regs never be corrected for this mode + b) eLNA is driven the same way as ePA with mt7620's pin PA + but vendor driver explicitly pin PA to gpio mode (for forrect calibration?) + so I'm not sure that request for pa_pin in dts-file will be enough + +First 5 changes (really 2) improve performance for boards w/o eLNA/ePA. +Changes 7 add support for eLNA + +Configuration w/o eLAN/ePA and with eLNA show results +tx/rx (from router point of view) for each stream: + 35-40/30-35 Mbps for HT20 + 65-70/60-65 Mbps for HT40 + +Yes. Max results for 2T2R client is 140-145/135-140 +with peaks 160/150, It correspond to mediatek driver results. +Boards with ePA untested. + +Reported-by: Serge Vasilugin +Signed-off-by: Daniel Golle +--- +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -137,6 +137,26 @@ static u8 rt2800_bbp_read(struct rt2x00_ + + return value; + } ++//serge: move here for use in test ++static void rt2800_bbp_glrt_write(struct rt2x00_dev *rt2x00dev, ++ const u8 reg, const u8 value) ++{ ++ rt2800_bbp_write(rt2x00dev, 195, reg); ++ rt2800_bbp_write(rt2x00dev, 196, value); ++} ++ ++static void rt2800_bbp_dcoc_write(struct rt2x00_dev *rt2x00dev, ++ const u8 reg, const u8 value) ++{ ++ rt2800_bbp_write(rt2x00dev, 158, reg); ++ rt2800_bbp_write(rt2x00dev, 159, value); ++} ++ ++static u8 rt2800_bbp_dcoc_read(struct rt2x00_dev *rt2x00dev, const u8 reg) ++{ ++ rt2800_bbp_write(rt2x00dev, 158, reg); ++ return rt2800_bbp_read(rt2x00dev, 159); ++} + + static void rt2800_rfcsr_write(struct rt2x00_dev *rt2x00dev, + const unsigned int word, const u8 value) +@@ -284,6 +304,28 @@ static void rt2800_rf_write(struct rt2x0 + mutex_unlock(&rt2x00dev->csr_mutex); + } + ++void rt6352_enable_pa_pin(struct rt2x00_dev *rt2x00dev, int enable) ++{ ++ if (!rt2x00dev->pinctrl) ++ return; ++ ++ if (enable) { ++ if (!rt2x00dev->pins_default) { ++ rt2x00_warn(rt2x00dev, "cannot enable PA pin! no default pinctrl\n"); ++ return; ++ } ++ ++ pinctrl_select_state(rt2x00dev->pinctrl, rt2x00dev->pins_default); ++ } else { ++ if (!rt2x00dev->pins_pa_gpio) { ++ rt2x00_warn(rt2x00dev, "cannot disable PA pin! no pa_gpio pinctrl\n"); ++ return; ++ } ++ ++ pinctrl_select_state(rt2x00dev->pinctrl, rt2x00dev->pins_pa_gpio); ++ } ++} ++ + static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = { + [EEPROM_CHIP_ID] = 0x0000, + [EEPROM_VERSION] = 0x0001, +@@ -3801,6 +3843,20 @@ static void rt2800_config_channel_rf7620 + rfcsr |= tx_agc_fc; + rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr); + } ++ ++ if (conf_is_ht40(conf)) {//serge:skipped this step (1) ++ rt2800_bbp_write(rt2x00dev, 195, 141); ++ rt2800_bbp_write(rt2x00dev, 196, 0x10); ++ rt2800_bbp_write(rt2x00dev, 195, 157); ++ rt2800_bbp_write(rt2x00dev, 196, 0x2f); ++ //rt2800_bbp_write(rt2x00dev, 105, 0x3C); ++ } else { ++ rt2800_bbp_write(rt2x00dev, 195, 141); ++ rt2800_bbp_write(rt2x00dev, 196, 0x1a); ++ rt2800_bbp_write(rt2x00dev, 195, 157); ++ rt2800_bbp_write(rt2x00dev, 196, 0x40); ++ //rt2800_bbp_write(rt2x00dev, 105, 0x1C); ++ } + } + + static void rt2800_config_alc(struct rt2x00_dev *rt2x00dev, +@@ -4172,6 +4228,11 @@ static void rt2800_config_channel(struct + rt2800_bbp_write(rt2x00dev, 86, 0x46); + else + rt2800_bbp_write(rt2x00dev, 86, 0); ++ } else if (rt2x00_rt(rt2x00dev, RT6352)) {//serge: don't overwite bbp r86 (5) ++ rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); ++ rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); ++ rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); ++ rt2800_bbp_write(rt2x00dev, 86, 0x38); + } else { + rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); + rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); +@@ -4377,7 +4438,8 @@ static void rt2800_config_channel(struct + reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); + +- rt2800_iq_calibrate(rt2x00dev, rf->channel); ++ if (!rt2x00_rt(rt2x00dev, RT6352))//serge: this function for rt5592 only, for rt6352 it switch off compensations (5) ++ rt2800_iq_calibrate(rt2x00dev, rf->channel); + } + + if (rt2x00_rt(rt2x00dev, RT6352)) { +@@ -4417,6 +4479,31 @@ static void rt2800_config_channel(struct + rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, + 0x6C6C6B6C); + } ++ ++ if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {//serge: for support eLNA (7a) ++ rt2x00_warn(rt2x00dev, "Correct RF/BBP for eLNA!\n"); ++ reg = rt2800_register_read(rt2x00dev, RF_CONTROL3); ++ reg |= 0x00000101; ++ rt2800_register_write(rt2x00dev, RF_CONTROL3, reg); ++ ++ reg = rt2800_register_read(rt2x00dev, RF_BYPASS3); ++ reg |= 0x00000101; ++ rt2800_register_write(rt2x00dev, RF_BYPASS3, reg); ++ ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x66); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x20); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x42); ++ rt2800_bbp_write(rt2x00dev, 75, 0x68);//serge: move bbp eLNA init here? ++ rt2800_bbp_write(rt2x00dev, 76, 0x4C); ++ rt2800_bbp_write(rt2x00dev, 79, 0x1C); ++ rt2800_bbp_write(rt2x00dev, 80, 0x0C); ++ rt2800_bbp_write(rt2x00dev, 82, 0xB6); ++ /* bank 0 RF reg 42 and glrt BBP reg 141 ++ will be set in config channel function ++ in dependence of channel and HT20/HT40 ++ so don't touch it ++ */ ++ } + } + + bbp = rt2800_bbp_read(rt2x00dev, 4); +@@ -4457,6 +4544,9 @@ static void rt2800_config_channel(struct + rt2x00_set_field8(&bbp, BBP49_UPDATE_FLAG, 0); + rt2800_bbp_write(rt2x00dev, 49, bbp); + } ++//serge:just print results after config channel - don't forget to remove nahren (c) <- this is copyright, not ref to comments :) ++ bbp = rt2800_bbp_dcoc_read(rt2x00dev, 0x03); ++ pr_info("BBP tx/rx compensation control=0x%02x\n", bbp); + } + + static int rt2800_get_gain_calibration_delta(struct rt2x00_dev *rt2x00dev) +@@ -5527,7 +5617,7 @@ void rt2800_vco_calibration(struct rt2x0 + } + rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); + +- if (rt2x00_rt(rt2x00dev, RT6352)) { ++ if (rt2x00_rt(rt2x00dev, RT6352)) {//serge:remark - move all this code to rfcsr_6352 init? + if (rt2x00dev->default_ant.rx_chain_num == 1) { + rt2800_bbp_write(rt2x00dev, 91, 0x07); + rt2800_bbp_write(rt2x00dev, 95, 0x1A); +@@ -5695,7 +5785,8 @@ static inline void rt2800_set_vgc(struct + if (qual->vgc_level != vgc_level) { + if (rt2x00_rt(rt2x00dev, RT3572) || + rt2x00_rt(rt2x00dev, RT3593) || +- rt2x00_rt(rt2x00dev, RT3883)) { ++ rt2x00_rt(rt2x00dev, RT3883) || ++ rt2x00_rt(rt2x00dev, RT6352)) {//serge: rt6352 too (3) + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, + vgc_level); + } else if (rt2x00_rt(rt2x00dev, RT5592)) { +@@ -5930,7 +6021,7 @@ static int rt2800_init_registers(struct + 0x00550055); + } else { + rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000401); +- rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0000); ++ rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0001);//serge:was 0x000C0000 (2) + rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); + rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x00000000); + rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0); +@@ -6195,6 +6286,29 @@ static int rt2800_init_registers(struct + reg = rt2800_register_read(rt2x00dev, US_CYC_CNT); + rt2x00_set_field32(®, US_CYC_CNT_CLOCK_CYCLE, 125); + rt2800_register_write(rt2x00dev, US_CYC_CNT, reg); ++ } else if (rt2x00_is_soc(rt2x00dev)) {//serge:which value correct? (4) ++ struct clk *clk = clk_get_sys("bus", NULL); ++ int rate; ++ ++ if (IS_ERR(clk)) { ++ rt2x00_warn(rt2x00dev, "system bus clock undefined\n"); ++ clk = clk_get_sys("cpu", NULL); ++ ++ if (IS_ERR(clk)) ++ rate = 125; ++ else { ++ rate = clk_get_rate(clk) / 3000000; ++ clk_put(clk); ++ } ++ } else { ++ rate = clk_get_rate(clk) / 1000000; ++ clk_put(clk); ++ } ++ ++ rt2x00_info(rt2x00dev, "set US_CYC=%dMHz\n", rate); ++ reg = rt2800_register_read(rt2x00dev, US_CYC_CNT); ++ rt2x00_set_field32(®, US_CYC_CNT_CLOCK_CYCLE, rate); ++ rt2800_register_write(rt2x00dev, US_CYC_CNT, reg); + } + + reg = rt2800_register_read(rt2x00dev, HT_FBK_CFG0); +@@ -6981,26 +7095,7 @@ static void rt2800_init_bbp_5592(struct + if (rt2x00_rt_rev_gte(rt2x00dev, RT5592, REV_RT5592C)) + rt2800_bbp_write(rt2x00dev, 103, 0xc0); + } +- +-static void rt2800_bbp_glrt_write(struct rt2x00_dev *rt2x00dev, +- const u8 reg, const u8 value) +-{ +- rt2800_bbp_write(rt2x00dev, 195, reg); +- rt2800_bbp_write(rt2x00dev, 196, value); +-} +- +-static void rt2800_bbp_dcoc_write(struct rt2x00_dev *rt2x00dev, +- const u8 reg, const u8 value) +-{ +- rt2800_bbp_write(rt2x00dev, 158, reg); +- rt2800_bbp_write(rt2x00dev, 159, value); +-} +- +-static u8 rt2800_bbp_dcoc_read(struct rt2x00_dev *rt2x00dev, const u8 reg) +-{ +- rt2800_bbp_write(rt2x00dev, 158, reg); +- return rt2800_bbp_read(rt2x00dev, 159); +-} ++//serge: move these function upper + + static void rt2800_init_bbp_6352(struct rt2x00_dev *rt2x00dev) + { +@@ -8635,7 +8730,7 @@ static void rt2800_r_calibration(struct + r_cal_code = (u8)rcalcode; + + rt2800_rfcsr_write_bank(rt2x00dev, 0, 7, r_cal_code); +- ++ pr_info("RF bank 0 reg 5=0x%02x\n", r_cal_code);//serge: just for info to compare with vendor driver + rt2800_bbp_write(rt2x00dev, 22, 0x0); + + bytevalue = rt2800_bbp_read(rt2x00dev, 21); +@@ -8693,7 +8788,7 @@ static void rt2800_rxdcoc_calibration(st + break; + } + +- saverfb5r4 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 0); ++ saverfb5r4 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4);//serge: was 0 - typo? (6) + saverfb7r4 = rt2800_rfcsr_read_bank(rt2x00dev, 7, 4); + saverfb5r4 = saverfb5r4 & (~0x40); + saverfb7r4 = saverfb7r4 & (~0x40); +@@ -9022,13 +9117,15 @@ static void rt2800_rxiq_calibration(stru + rt2x00_info(rt2x00dev, "RXIQ G_imb=%d, Ph_rx=%d\n", g_imb, ph_rx); + + if ((ph_rx > 20) || (ph_rx < -20)) { ++ rt2x00_warn(rt2x00dev, "RXIQ calibration FAIL(ph_rx=%d out of [-20..20]", ph_rx);//serge:just to see value + ph_rx = 0; +- rt2x00_warn(rt2x00dev, "RXIQ calibration FAIL"); ++ //rt2x00_warn(rt2x00dev, "RXIQ calibration FAIL"); + } + + if ((g_imb > 12) || (g_imb < -12)) { ++ rt2x00_warn(rt2x00dev, "RXIQ calibration FAIL(g_imb=%d out of (-12..12]", g_imb);//serge:just to see the reason + g_imb = 0; +- rt2x00_warn(rt2x00dev, "RXIQ calibration FAIL"); ++ //rt2x00_warn(rt2x00dev, "RXIQ calibration FAIL"); + } + } + else { +@@ -9039,11 +9136,21 @@ static void rt2800_rxiq_calibration(stru + } + + if (ch_idx == 0) { ++ //serge: just to see values ++ pr_info("RXIQ RX0 g_imb (0x37, %2x) ph_rx (0x35, %2x)\n", ++ g_imb & 0x3f, ++ ph_rx & 0x3f ++ ); + rt2800_bbp_write(rt2x00dev, 158, 0x37); + rt2800_bbp_write(rt2x00dev, 159, g_imb & 0x3f); + rt2800_bbp_write(rt2x00dev, 158, 0x35); + rt2800_bbp_write(rt2x00dev, 159, ph_rx & 0x3f); + } else { ++ //serge: just to see values ++ pr_info("RXIQ RX1 g_imb (0x55, %2x) ph_rx (0x53, %2x)\n", ++ g_imb & 0x3f, ++ ph_rx & 0x3f ++ ); + rt2800_bbp_write(rt2x00dev, 158, 0x55); + rt2800_bbp_write(rt2x00dev, 159, g_imb & 0x3f); + rt2800_bbp_write(rt2x00dev, 158, 0x53); +@@ -9745,6 +9852,15 @@ void rt2800_loft_iq_calibration(struct r + } + + for (rf_alc_idx = 0; rf_alc_idx < 3; rf_alc_idx++) { ++ //serge: just to see values ++ pr_info("LOFT ALC (0xb0, %2x) I0 (0xb1, %2x) Q0 (0xb2, %2x) I1 (0xb8, %2x) Q1 (0xb9, %2x)\n", ++ rf_alc_idx, ++ loft_dc_search_result[CHAIN_0][rf_alc_idx][0x00] & 0x3F, ++ loft_dc_search_result[CHAIN_0][rf_alc_idx][0x01] & 0x3F, ++ loft_dc_search_result[CHAIN_1][rf_alc_idx][0x00] & 0x3F, ++ loft_dc_search_result[CHAIN_1][rf_alc_idx][0x01] & 0x3F ++ ); ++ + for (idx = 0; idx < 4; idx++) { + rt2800_bbp_write(rt2x00dev, 158, 0xB0); + bbp = (idx<<2) + rf_alc_idx; +@@ -10669,6 +10785,7 @@ static void rt2800_init_rfcsr_6352(struc + rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C); + } + ++ rt6352_enable_pa_pin(rt2x00dev, 0);//serge: vendor driver do it before calibration (7b) + rt2800_r_calibration(rt2x00dev); + rt2800_rf_self_txdc_cal(rt2x00dev); + rt2800_rxdcoc_calibration(rt2x00dev); +@@ -10676,6 +10793,29 @@ static void rt2800_init_rfcsr_6352(struc + rt2800_bw_filter_calibration(rt2x00dev, false); + rt2800_loft_iq_calibration(rt2x00dev); + rt2800_rxiq_calibration(rt2x00dev); ++ rt6352_enable_pa_pin(rt2x00dev, 1);//serge: vendor driver do it after calibration (7b) ++ /* Vendor driver restore iLNA/iPA before ++ recalibration and set correct values after. ++ Openwrt driver init iLNA and iPA but restore only ++ ePA values after recalibration. ++ So set eLNA values only ++ */ ++ if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {//serge: rf regs never corrected for eLNA (7a) ++ rt2x00_info(rt2x00dev, "Correct RF/BBP for eLNA!\n"); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x66); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x20); ++ rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x42); ++ rt2800_bbp_write(rt2x00dev, 75, 0x68);//serge: move bbp eLNA init here? ++ rt2800_bbp_write(rt2x00dev, 76, 0x4C); ++ rt2800_bbp_write(rt2x00dev, 79, 0x1C); ++ rt2800_bbp_write(rt2x00dev, 80, 0x0C); ++ rt2800_bbp_write(rt2x00dev, 82, 0xB6); ++ /* bank 0 RF reg 42 and glrt BBP reg 141 ++ will be set in config channel function ++ in dependence of channel and HT20/HT40 ++ so don't touch it ++ */ ++ } + } + + static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + #include + + #include +@@ -1029,6 +1030,11 @@ struct rt2x00_dev { + + /* Clock for System On Chip devices. */ + struct clk *clk; ++ ++ /* pinctrl and states for System On Chip devices with PA/LNA. */ ++ struct pinctrl *pinctrl; ++ struct pinctrl_state *pins_default; ++ struct pinctrl_state *pins_pa_gpio; + }; + + struct rt2x00_bar_list_entry { +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c +@@ -97,6 +97,21 @@ int rt2x00soc_probe(struct platform_devi + if (retval) + goto exit_free_reg; + ++ rt2x00dev->pinctrl = devm_pinctrl_get(&pdev->dev); ++ if (IS_ERR(rt2x00dev->pinctrl)) { ++ rt2x00dev->pinctrl = NULL; ++ rt2x00dev->pins_default = NULL; ++ rt2x00dev->pins_pa_gpio = NULL; ++ } else { ++ rt2x00dev->pins_default = pinctrl_lookup_state(rt2x00dev->pinctrl, "default"); ++ if (IS_ERR(rt2x00dev->pins_default)) ++ rt2x00dev->pins_default = NULL; ++ ++ rt2x00dev->pins_pa_gpio = pinctrl_lookup_state(rt2x00dev->pinctrl, "pa_gpio"); ++ if (IS_ERR(rt2x00dev->pins_pa_gpio)) ++ rt2x00dev->pins_pa_gpio = NULL; ++ } ++ + return 0; + + exit_free_reg: diff --git a/target/linux/ramips/dts/mt7620a.dtsi b/target/linux/ramips/dts/mt7620a.dtsi index c33dd135fe..4b6fa60dc8 100644 --- a/target/linux/ramips/dts/mt7620a.dtsi +++ b/target/linux/ramips/dts/mt7620a.dtsi @@ -420,6 +420,13 @@ }; }; + pa_gpio_pins: pa_gpio { + pa { + groups = "pa"; + function = "gpio"; + }; + }; + sdhci_pins: sdhci { sdhci { groups = "nd_sd"; diff --git a/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts b/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts index 7c8caa5066..4b960da312 100644 --- a/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts +++ b/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts @@ -147,8 +147,9 @@ &wmac { ralink,mtd-eeprom = <&factory 0x0>; - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; }; &factory { diff --git a/target/linux/ramips/dts/mt7620a_cameo_810.dtsi b/target/linux/ramips/dts/mt7620a_cameo_810.dtsi index 3174b98bbf..d0113f5560 100644 --- a/target/linux/ramips/dts/mt7620a_cameo_810.dtsi +++ b/target/linux/ramips/dts/mt7620a_cameo_810.dtsi @@ -138,8 +138,9 @@ }; &wmac { - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; ralink,mtd-eeprom = <&factory 0x0>; nvmem-cells = <&macaddr_factory_28>; diff --git a/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts b/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts index 68b733cade..2884bfdb04 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts @@ -174,8 +174,9 @@ &wmac { ralink,mtd-eeprom = <&factory 0x0>; - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; }; &factory { diff --git a/target/linux/ramips/dts/mt7620a_fon_fon2601.dts b/target/linux/ramips/dts/mt7620a_fon_fon2601.dts index 69ddea589b..8f95204ad1 100644 --- a/target/linux/ramips/dts/mt7620a_fon_fon2601.dts +++ b/target/linux/ramips/dts/mt7620a_fon_fon2601.dts @@ -143,8 +143,10 @@ &wmac { ralink,mtd-eeprom = <&factory 0x0>; - pinctrl-names = "default"; + + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>, <&wled_pins>; + pinctrl-1 = <&pa_gpio_pins>, <&wled_pins>; }; &pcie { diff --git a/target/linux/ramips/dts/mt7620a_hiwifi_hc5861.dts b/target/linux/ramips/dts/mt7620a_hiwifi_hc5861.dts index 10aa0ddf6f..87eacb13d7 100644 --- a/target/linux/ramips/dts/mt7620a_hiwifi_hc5861.dts +++ b/target/linux/ramips/dts/mt7620a_hiwifi_hc5861.dts @@ -107,6 +107,7 @@ }; &wmac { - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; }; diff --git a/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1.dtsi b/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1.dtsi index c7b7ea7b90..5e834d291d 100644 --- a/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1.dtsi +++ b/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1.dtsi @@ -90,9 +90,11 @@ }; &wmac { - ralink,mtd-eeprom = <&factory 0x0>; - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; + + ralink,mtd-eeprom = <&factory 0x0>; }; &state_default { diff --git a/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.4.dts b/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.4.dts index 4e9fc1307b..52d131556d 100644 --- a/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.4.dts +++ b/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.4.dts @@ -18,6 +18,7 @@ }; &wmac { - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; }; diff --git a/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.5.dts b/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.5.dts index 2a682872c6..cf9d0b290c 100644 --- a/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.5.dts +++ b/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.5.dts @@ -24,6 +24,7 @@ }; &wmac { - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; }; diff --git a/target/linux/ramips/dts/mt7620a_phicomm_k2g.dts b/target/linux/ramips/dts/mt7620a_phicomm_k2g.dts index d113edc19f..bc934d7058 100644 --- a/target/linux/ramips/dts/mt7620a_phicomm_k2g.dts +++ b/target/linux/ramips/dts/mt7620a_phicomm_k2g.dts @@ -42,6 +42,7 @@ }; &wmac { - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; }; diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer-c20-v1.dts b/target/linux/ramips/dts/mt7620a_tplink_archer-c20-v1.dts index e3c077cb0d..8fe5b9c3a2 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_archer-c20-v1.dts +++ b/target/linux/ramips/dts/mt7620a_tplink_archer-c20-v1.dts @@ -69,8 +69,9 @@ }; &wmac { - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; nvmem-cells = <&macaddr_rom_f100>; nvmem-cell-names = "mac-address"; diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer-c50-v1.dts b/target/linux/ramips/dts/mt7620a_tplink_archer-c50-v1.dts index aefd951f43..4dbd1b2a98 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_archer-c50-v1.dts +++ b/target/linux/ramips/dts/mt7620a_tplink_archer-c50-v1.dts @@ -69,8 +69,9 @@ }; &wmac { - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; nvmem-cells = <&macaddr_rom_f100>; nvmem-cell-names = "mac-address"; diff --git a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn530hg4.dts b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn530hg4.dts index b0522de7d0..9f58fb86ee 100644 --- a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn530hg4.dts +++ b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn530hg4.dts @@ -131,8 +131,9 @@ }; &wmac { - pinctrl-names = "default"; + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_xiaomi_miwifi-mini.dts b/target/linux/ramips/dts/mt7620a_xiaomi_miwifi-mini.dts index 9f5df5dd79..1dd3f2eb47 100644 --- a/target/linux/ramips/dts/mt7620a_xiaomi_miwifi-mini.dts +++ b/target/linux/ramips/dts/mt7620a_xiaomi_miwifi-mini.dts @@ -146,8 +146,10 @@ &wmac { ralink,mtd-eeprom = <&factory 0x0>; - pinctrl-names = "default"; + + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; }; &pcie { diff --git a/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi index ac874cef3d..d15d2c0f4b 100644 --- a/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi +++ b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi @@ -113,6 +113,10 @@ &wmac { ralink,mtd-eeprom = <&factory 0x0>; + + pinctrl-names = "default", "pa_gpio"; + pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; }; &sdhci { diff --git a/target/linux/ramips/dts/mt7620a_zbtlink_zbt-ape522ii.dts b/target/linux/ramips/dts/mt7620a_zbtlink_zbt-ape522ii.dts index 6fcda971a6..ceb348e1d2 100644 --- a/target/linux/ramips/dts/mt7620a_zbtlink_zbt-ape522ii.dts +++ b/target/linux/ramips/dts/mt7620a_zbtlink_zbt-ape522ii.dts @@ -106,8 +106,10 @@ &wmac { ralink,mtd-eeprom = <&factory 0x0>; - pinctrl-names = "default"; + + pinctrl-names = "default", "pa_gpio"; pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; }; &pcie { From 9403810c020cca136149973a3929bf77a1f501aa Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 12 Sep 2022 00:29:00 +0200 Subject: [PATCH 082/114] toolchain: Select USE_SSTRIP with external musl toolchain When we use the internal toolchain USE_SSTRIP will be selected by default for musl libc and USE_STRIP when glibc is used. Do the same when an external toolchain is used. USE_GLIBC will also be set for external toolchain builds based on the EXTERNAL_TOOLCHAIN_LIBC_USE_GLIBC setting. Signed-off-by: Hauke Mehrtens --- config/Config-build.in | 1 - target/sdk/files/Config.in | 1 - 2 files changed, 2 deletions(-) diff --git a/config/Config-build.in b/config/Config-build.in index 2eded2b288..c2303637cb 100644 --- a/config/Config-build.in +++ b/config/Config-build.in @@ -160,7 +160,6 @@ menu "Global build settings" choice prompt "Binary stripping method" - default USE_STRIP if EXTERNAL_TOOLCHAIN default USE_STRIP if USE_GLIBC default USE_SSTRIP help diff --git a/target/sdk/files/Config.in b/target/sdk/files/Config.in index aab6352118..12c0f6a624 100644 --- a/target/sdk/files/Config.in +++ b/target/sdk/files/Config.in @@ -31,7 +31,6 @@ menu "Global build settings" choice prompt "Binary stripping method" - default USE_STRIP if EXTERNAL_TOOLCHAIN default USE_STRIP if USE_GLIBC default USE_SSTRIP help From b21ddbfa18cd1e437e31dc0fa29408721a186c2a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 12 Sep 2022 00:31:43 +0200 Subject: [PATCH 083/114] toolchain: Include ./include/fortify for external musl toolchain When building with an external toolcahin with musl also include ./include/fortify by default. This is also done when we build with the internal toolchain using musl libc. Without this extra include the fortify source feature is not working when using an external musl toolchain. All binaries were compiled without fortify source when an external musl toolchain was used. All binaries release done by the OpenWrt project use the internal toolcahin where fortify source is working. Signed-off-by: Hauke Mehrtens --- toolchain/Config.in | 1 + 1 file changed, 1 insertion(+) diff --git a/toolchain/Config.in b/toolchain/Config.in index fb14006055..6d3cc0a200 100644 --- a/toolchain/Config.in +++ b/toolchain/Config.in @@ -169,6 +169,7 @@ menuconfig EXTERNAL_TOOLCHAIN string prompt "Toolchain include path" if DEVEL depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN + default "./usr/include ./include/fortify ./include" if EXTERNAL_TOOLCHAIN_LIBC_USE_MUSL default "./usr/include ./include" help Specify additional directories searched for header files (override From c836ca84e8f641e10a8349a8f9b7432b33d6cec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Tue, 13 Sep 2022 07:38:10 +0200 Subject: [PATCH 084/114] scripts/download.pl: silence can't exec curl warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running build in verbose mode `make V=s` we can see a lot of following warnings when curl is not available in the system: Can't exec "curl": No such file or directory at scripts/download.pl line 77. So lets fix it by redirecting of the stderr to null hole. Signed-off-by: Petr Štetiar --- scripts/download.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/download.pl b/scripts/download.pl index ab1801aad5..90a1be4e26 100755 --- a/scripts/download.pl +++ b/scripts/download.pl @@ -74,7 +74,7 @@ sub download_cmd($) { my $url = shift; my $have_curl = 0; - if (open CURL, '-|', 'curl', '--version') { + if (open CURL, "curl --version 2>/dev/null |") { if (defined(my $line = readline CURL)) { $have_curl = 1 if $line =~ /^curl /; } From 50a48faa1b8424e6b4b436b7118fffa2cba14b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Tue, 13 Sep 2022 07:40:37 +0200 Subject: [PATCH 085/114] scripts/download.pl: fix downloads with wget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several users of wget for downloads (curl is not available in the system) have reported broken download functionality: wget --tries=5 --timeout=20 --output-document=- https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.142.tar.xz http://: Invalid host name. Thats all happening due to '' was passed as an argument, which got later expanded to http://. In the context of a list constructor '' is not nothing, it is an empty string element. So fix it by using () as it will yield "nothing" and thus not introduce an empty string element. Fixes: #10692 Fixes: 90c6e3aedf16 ("scripts: always check certificates") Signed-off-by: Jo-Philipp Wich [shellwords() -> ()] Signed-off-by: Petr Štetiar --- scripts/download.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/download.pl b/scripts/download.pl index 90a1be4e26..33e1e12c1e 100755 --- a/scripts/download.pl +++ b/scripts/download.pl @@ -82,8 +82,14 @@ sub download_cmd($) { } return $have_curl - ? (qw(curl -f --connect-timeout 20 --retry 5 --location), $check_certificate ? '' : '--insecure', shellwords($ENV{CURL_OPTIONS} || ''), $url) - : (qw(wget --tries=5 --timeout=20 --output-document=-), $check_certificate ? '' : '--no-check-certificate', shellwords($ENV{WGET_OPTIONS} || ''), $url) + ? (qw(curl -f --connect-timeout 20 --retry 5 --location), + $check_certificate ? () : '--insecure', + shellwords($ENV{CURL_OPTIONS} || ''), + $url) + : (qw(wget --tries=5 --timeout=20 --output-document=-), + $check_certificate ? () : '--no-check-certificate', + shellwords($ENV{WGET_OPTIONS} || ''), + $url) ; } From a575788b8f170be1087444e2e746196128719e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Tue, 13 Sep 2022 09:06:50 +0200 Subject: [PATCH 086/114] uboot-mediatek: fix extraneous right parens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes following warning: Makefile:310: extraneous text after 'ifeq' directive Signed-off-by: Petr Štetiar --- package/boot/uboot-mediatek/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/boot/uboot-mediatek/Makefile b/package/boot/uboot-mediatek/Makefile index 7bfc8fd64b..7e813b2a5e 100644 --- a/package/boot/uboot-mediatek/Makefile +++ b/package/boot/uboot-mediatek/Makefile @@ -291,7 +291,7 @@ endef define Build/Compile $(call Build/Compile/U-Boot) -ifeq ($(UBOOT_IMAGE),u-boot.fip)) +ifeq ($(UBOOT_IMAGE),u-boot.fip) $(call Build/fip-image) endif endef From bc9dcfb1ce656e1da694d9d9a6f927b3142ab76a Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Sat, 20 Aug 2022 16:10:42 -0500 Subject: [PATCH 087/114] realtek: split TP-Link SG2000 series devicetree The TP-Link TL-SG2008, TL-SG2008P, and TL-SG2210P use the same board. The main difference is that some footprints are not populated in the lower-end models. To model this with minimal duplication, move the devicetree to a common dtsi, leaving out just the board name. Signed-off-by: Alexandru Gagniuc [remove port relabelling from commit message, already merged with commit 18a2b29aa1c9 ("realtek: tl-sg2008p: fix labeling of lan ports")] Signed-off-by: Sander Vanheule --- .../dts-5.10/rtl8380_tplink_sg2008p-v1.dts | 178 +---------------- .../dts-5.10/rtl8380_tplink_sg2xxx.dtsi | 181 ++++++++++++++++++ 2 files changed, 182 insertions(+), 177 deletions(-) create mode 100644 target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi diff --git a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts index d464921e50..0fef52984c 100644 --- a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts +++ b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts @@ -1,184 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later -#include "rtl838x.dtsi" - -#include -#include +#include "rtl8380_tplink_sg2xxx.dtsi" / { compatible = "tplink,sg2008p-v1", "realtek,rtl838x-soc"; model = "TP-Link SG2008P v1"; - - aliases { - led-boot = &led_power; - led-failsafe = &led_power; - led-running = &led_power; - led-upgrade = &led_power; - }; - - memory@0 { - device_type = "memory"; - reg = <0x0 0x10000000>; - }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; - linux,code = ; - }; - }; - - gpio-restart { - compatible = "gpio-restart"; - gpios = <&gpio0 3 GPIO_ACTIVE_LOW>; - }; - - leds { - compatible = "gpio-leds"; - - led_power: led-0 { - label = "green:power"; - gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>; - }; - }; - - i2c1: i2c-gpio-1 { - compatible = "i2c-gpio"; - scl-gpios = <&gpio0 0 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - sda-gpios = <&gpio0 1 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - i2c-gpio,delay-us = <2>; - #address-cells = <1>; - #size-cells = <0>; - - tps23861@28 { - compatible = "ti,tps23861"; - reg = <0x28>; - shunt-resistor-micro-ohms = <255000>; - }; - }; - - watchdog { - compatible = "linux,wdt-gpio"; - gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>; - hw_algo = "toggle"; - /* SGM706 specs: typical 1.6s, but minimum 1.0s. */ - hw_margin_ms = <1000>; - }; - - virtual_flash { - compatible = "mtd-concat"; - - devices = <&syspart &usrpart>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - compatible = "denx,uimage"; - label = "firmware"; - reg = <0x0 0x1a00000>; - }; - }; - }; -}; - -&gpio0 { - watchdog-enable { - gpio-hog; - gpios = <14 GPIO_ACTIVE_LOW>; - output-low; - line-name = "watchdog-enable"; - }; -}; - -&spi0 { - status = "okay"; - - flash@0 { - compatible = "jedec,spi-nor"; - reg = <0>; - spi-max-frequency = <10000000>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "u-boot"; - reg = <0x0 0xe0000>; - read-only; - }; - partition@e0000 { - label = "u-boot-env"; - reg = <0xe0000 0x20000>; - }; - syspart: partition@100000 { - label = "sys"; - reg = <0x100000 0x600000>; - }; - usrpart: partition@700000 { - label = "usrimg1"; - reg = <0x700000 0x1400000>; - }; - partition@1b00000 { - label = "usrappfs"; - reg = <0x1b00000 0x400000>; - }; - partition@1f00000 { - label = "para"; - reg = <0x1f00000 0x100000>; - read-only; - }; - }; - }; -}; - -ðernet0 { - mdio: mdio-bus { - compatible = "realtek,rtl838x-mdio"; - #address-cells = <1>; - #size-cells = <0>; - - INTERNAL_PHY(8) - INTERNAL_PHY(9) - INTERNAL_PHY(10) - INTERNAL_PHY(11) - INTERNAL_PHY(12) - INTERNAL_PHY(13) - INTERNAL_PHY(14) - INTERNAL_PHY(15) - }; -}; - -&switch0 { - ports { - #address-cells = <1>; - #size-cells = <0>; - - SWITCH_PORT(15, 1, internal) - SWITCH_PORT(14, 2, internal) - SWITCH_PORT(13, 3, internal) - SWITCH_PORT(12, 4, internal) - SWITCH_PORT(11, 5, internal) - SWITCH_PORT(10, 6, internal) - SWITCH_PORT(9, 7, internal) - SWITCH_PORT(8, 8, internal) - - port@28 { - ethernet = <ðernet0>; - reg = <28>; - phy-mode = "internal"; - - fixed-link { - speed = <1000>; - full-duplex; - }; - }; - }; }; diff --git a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi new file mode 100644 index 0000000000..8aa82831ab --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi @@ -0,0 +1,181 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "rtl838x.dtsi" + +#include +#include + +/ { + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x10000000>; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + gpio-restart { + compatible = "gpio-restart"; + gpios = <&gpio0 3 GPIO_ACTIVE_LOW>; + }; + + leds { + compatible = "gpio-leds"; + + led_power: led-0 { + label = "green:power"; + gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>; + }; + }; + + i2c1: i2c-gpio-1 { + compatible = "i2c-gpio"; + scl-gpios = <&gpio0 0 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + sda-gpios = <&gpio0 1 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + i2c-gpio,delay-us = <2>; + #address-cells = <1>; + #size-cells = <0>; + + tps23861@28 { + compatible = "ti,tps23861"; + reg = <0x28>; + shunt-resistor-micro-ohms = <255000>; + }; + }; + + watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>; + hw_algo = "toggle"; + /* SGM706 specs: typical 1.6s, but minimum 1.0s. */ + hw_margin_ms = <1000>; + }; + + virtual_flash { + compatible = "mtd-concat"; + + devices = <&syspart &usrpart>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x0 0x1a00000>; + }; + }; + }; +}; + +&gpio0 { + watchdog-enable { + gpio-hog; + gpios = <14 GPIO_ACTIVE_LOW>; + output-low; + line-name = "watchdog-enable"; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <10000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0xe0000>; + read-only; + }; + partition@e0000 { + label = "u-boot-env"; + reg = <0xe0000 0x20000>; + }; + syspart: partition@100000 { + label = "sys"; + reg = <0x100000 0x600000>; + }; + usrpart: partition@700000 { + label = "usrimg1"; + reg = <0x700000 0x1400000>; + }; + partition@1b00000 { + label = "usrappfs"; + reg = <0x1b00000 0x400000>; + }; + partition@1f00000 { + label = "para"; + reg = <0x1f00000 0x100000>; + read-only; + }; + }; + }; +}; + +ðernet0 { + mdio: mdio-bus { + compatible = "realtek,rtl838x-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + INTERNAL_PHY(8) + INTERNAL_PHY(9) + INTERNAL_PHY(10) + INTERNAL_PHY(11) + INTERNAL_PHY(12) + INTERNAL_PHY(13) + INTERNAL_PHY(14) + INTERNAL_PHY(15) + }; +}; + +&switch0 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + SWITCH_PORT(15, 1, internal) + SWITCH_PORT(14, 2, internal) + SWITCH_PORT(13, 3, internal) + SWITCH_PORT(12, 4, internal) + SWITCH_PORT(11, 5, internal) + SWITCH_PORT(10, 6, internal) + SWITCH_PORT(9, 7, internal) + SWITCH_PORT(8, 8, internal) + + port@28 { + ethernet = <ðernet0>; + reg = <28>; + phy-mode = "internal"; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; From 5f026f12728fbe9fe909c44c293f4ea58311d50f Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Mon, 29 Aug 2022 09:25:55 -0500 Subject: [PATCH 088/114] realtek: rtl838x: label switch port dts nodes Although PHY nodes are labeled, the port nodes were not. Labeling of ports is useful for 'status = "disabled"' ports, which is supported since commit 9a7f17e11f5d ("realtek: ignore disabled switch ports") Signed-off-by: Alexandru Gagniuc --- target/linux/realtek/dts-5.10/rtl838x.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/realtek/dts-5.10/rtl838x.dtsi b/target/linux/realtek/dts-5.10/rtl838x.dtsi index f92af17ef1..256efb1c05 100644 --- a/target/linux/realtek/dts-5.10/rtl838x.dtsi +++ b/target/linux/realtek/dts-5.10/rtl838x.dtsi @@ -37,7 +37,7 @@ }; #define SWITCH_PORT(n, s, m) \ - port@##n { \ + port##n: port@##n { \ reg = <##n>; \ label = SWITCH_PORT_LABEL(s) ; \ phy-handle = <&phy##n>; \ @@ -45,7 +45,7 @@ }; #define SWITCH_SFP_PORT(n, s, m) \ - port@##n { \ + port##n: port@##n { \ reg = <##n>; \ label = SWITCH_PORT_LABEL(s) ; \ phy-handle = <&phy##n>; \ From d55c08739032e906ece6f842f8fac97265018c4f Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Sat, 20 Aug 2022 18:22:40 -0500 Subject: [PATCH 089/114] realtek: tl-sg2xxx: read MAC address from nvmem-cells The TP-Link RTL83xx based switches have their MAC address programmed in the "para" partition. While in theory, the format of this partition is dynamic, in practice, the MAC address appears to be located at a consistent address. Thus, use nvmem-cells to read this MAC address. The main MAC is required for deriving the MAC address of the switch ports. Instead of reading it via mtd_get_mac_binary(), alias the ethernet0 node as the label-mac-device, and use get_mac_label(). Signed-off-by: Alexandru Gagniuc --- .../linux/realtek/base-files/etc/board.d/02_network | 2 +- .../linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi | 11 +++++++++++ .../realtek/dts-5.10/rtl8393_tplink_sg2452p-v4.dts | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/target/linux/realtek/base-files/etc/board.d/02_network b/target/linux/realtek/base-files/etc/board.d/02_network index 6e0e0e7e03..aacbef77b4 100644 --- a/target/linux/realtek/base-files/etc/board.d/02_network +++ b/target/linux/realtek/base-files/etc/board.d/02_network @@ -41,7 +41,7 @@ hpe,1920-24g) ;; tplink,sg2008p-v1|\ tplink,sg2452p-v4) - label_mac=$(mtd_get_mac_binary para 0xfdff4) + label_mac=$(get_mac_label) lan_mac="$label_mac" ;; *) diff --git a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi index 8aa82831ab..20e96af2e7 100644 --- a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi +++ b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi @@ -11,6 +11,7 @@ led-failsafe = &led_power; led-running = &led_power; led-upgrade = &led_power; + label-mac-device = ðernet0; }; memory@0 { @@ -128,15 +129,25 @@ reg = <0x1b00000 0x400000>; }; partition@1f00000 { + compatible = "nvmem-cells"; label = "para"; reg = <0x1f00000 0x100000>; + #address-cells = <1>; + #size-cells = <1>; read-only; + + factory_macaddr: macaddr@fdff4 { + reg = <0xfdff4 0x6>; + }; }; }; }; }; ðernet0 { + nvmem-cells = <&factory_macaddr>; + nvmem-cell-names = "mac-address"; + mdio: mdio-bus { compatible = "realtek,rtl838x-mdio"; #address-cells = <1>; diff --git a/target/linux/realtek/dts-5.10/rtl8393_tplink_sg2452p-v4.dts b/target/linux/realtek/dts-5.10/rtl8393_tplink_sg2452p-v4.dts index 0649c9fb37..b7300cfcbe 100644 --- a/target/linux/realtek/dts-5.10/rtl8393_tplink_sg2452p-v4.dts +++ b/target/linux/realtek/dts-5.10/rtl8393_tplink_sg2452p-v4.dts @@ -20,6 +20,7 @@ led-failsafe = &led_sys; led-running = &led_sys; led-upgrade = &led_sys; + label-mac-device = ðernet0; }; chosen { @@ -261,15 +262,25 @@ reg = <0x1b00000 0x400000>; }; partition@1f00000 { + compatible = "nvmem-cells"; label = "para"; reg = <0x1f00000 0x100000>; + #address-cells = <1>; + #size-cells = <1>; read-only; + + factory_macaddr: macaddr@fdff4 { + reg = <0xfdff4 0x6>; + }; }; }; }; }; ðernet0 { + nvmem-cells = <&factory_macaddr>; + nvmem-cell-names = "mac-address"; + mdio: mdio-bus { compatible = "realtek,rtl838x-mdio"; #address-cells = <1>; From ab2a4c1e016ed7948362e7e37c47ac390d7623f2 Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Sat, 10 Sep 2022 15:48:22 -0500 Subject: [PATCH 090/114] realtek: rtl8380-tl-sg2xxx: use a single "firmware" partition The "firmware" partition was assembled from two contiguous partitions. This complexity is unnecessary. Instead of using mtd-concat over "sys" and "usrimg1", simply declare the "firmware" partition to cover the flash space instead. Signed-off-by: Alexandru Gagniuc --- .../dts-5.10/rtl8380_tplink_sg2xxx.dtsi | 29 +++---------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi index 20e96af2e7..8eb309d8a8 100644 --- a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi +++ b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi @@ -65,24 +65,6 @@ /* SGM706 specs: typical 1.6s, but minimum 1.0s. */ hw_margin_ms = <1000>; }; - - virtual_flash { - compatible = "mtd-concat"; - - devices = <&syspart &usrpart>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - compatible = "denx,uimage"; - label = "firmware"; - reg = <0x0 0x1a00000>; - }; - }; - }; }; &gpio0 { @@ -116,13 +98,10 @@ label = "u-boot-env"; reg = <0xe0000 0x20000>; }; - syspart: partition@100000 { - label = "sys"; - reg = <0x100000 0x600000>; - }; - usrpart: partition@700000 { - label = "usrimg1"; - reg = <0x700000 0x1400000>; + partition@100000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x100000 0x1a00000>; }; partition@1b00000 { label = "usrappfs"; From 01e2184c49c52ac5169207cd9fabf662f50b56b8 Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Sat, 20 Aug 2022 13:49:52 -0500 Subject: [PATCH 091/114] realtek: add support for TP-Link SG2210P Add support for the TP-Link SG2210P switch. This is an RTL8380 based switch with eight RJ-45 ports with 802.3af PoE, and two SFP ports. This device shares the same board with the SG2008P and SG2008. To model this, declare all the capabilities in the sg2xxx dtsi, and disable unpopulated on the lower end models. Specifications: --------------- - SoC: Realtek RTL8380M - Flash: 32 MiB SPI flash (Vendor varies) - RAM: 256 MiB (Vendor varies) - Ethernet: 8x 10/100/1000 Mbps with PoE (all ports) 2x SFP ports - Buttons: 1x "Reset" button on front panel - Power: 53.5V DC barrel jack - UART: 1x serial header, unpopulated - PoE: 2x TI TPS23861 I2C PoE controller Works: ------ - (8) RJ-45 ethernet ports - (2) SFP ports (with caveats) - Switch functions - System LED Not yet enabled: ---------------- - Power-over-Ethernet (driver works, but doesn't enable "auto" mode) - PoE LEDs Enabling SFP ports: ------------------- The SFP port control lines are hardwired, except for tx-disable. These lines are controller by the RTL8231 in shift register mode. There is no driver support for this yet. However, to enable the lasers on SFP1 and SFP2 respectively: echo 0x0510ff00 > /sys/kernel/debug/rtl838x/led/led_p_en_ctrl echo 0x140 > /sys/kernel/debug/rtl838x/led/led_sw_p_ctrl.26 echo 0x140 > /sys/kernel/debug/rtl838x/led/led_sw_p_ctrl.24 Install via serial console/tftp: -------------------------------- The footprints R27 (0201) and R28 (0402) are not populated. To enable serial console, 50 ohm resistors should be soldered -- any value from 0 ohm to 50 ohm will work. R27 can be replaced by a solder bridge. The u-boot firmware drops to a TP-Link specific "BOOTUTIL" shell at 38400 baud. There is no known way to exit out of this shell, and no way to do anything useful. Ideally, one would trick the bootloader into flashing the sysupgrade image first. However, if the image exceeds 6MiB in size, it will not work. The sysupgrade image can also be flashed. To install OpenWrt: Prepare a tftp server with: 1. server address: 192.168.0.146 2. the image as: "uImage.img" Power on device, and stop boot by pressing any key. Once the shell is active: 1. Ground out the CLK (pin 16) of the ROM (U7) 2. Select option "3. Start" 3. Bootloader notes that "The kernel has been damaged!" 4. Release CLK as sson as bootloader thinks image is corrupted. 5. Bootloader enters automatic recovery -- details printed on console 6. Watch as the bootloader flashes and boots OpenWrt. Signed-off-by: Alexandru Gagniuc [OpenWrt capitalisation in commit message] Signed-off-by: Sander Vanheule --- package/boot/uboot-envtools/files/realtek | 1 + .../realtek/base-files/etc/board.d/02_network | 1 + .../base-files/lib/upgrade/platform.sh | 3 ++- .../dts-5.10/rtl8380_tplink_sg2008p-v1.dts | 20 +++++++++++++++++++ .../dts-5.10/rtl8380_tplink_sg2210p-v3.dts | 16 +++++++++++++++ .../dts-5.10/rtl8380_tplink_sg2xxx.dtsi | 14 ++++++++++++- target/linux/realtek/image/rtl838x.mk | 11 ++++++++++ 7 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 target/linux/realtek/dts-5.10/rtl8380_tplink_sg2210p-v3.dts diff --git a/package/boot/uboot-envtools/files/realtek b/package/boot/uboot-envtools/files/realtek index 22568afd12..f191503876 100644 --- a/package/boot/uboot-envtools/files/realtek +++ b/package/boot/uboot-envtools/files/realtek @@ -30,6 +30,7 @@ zyxel,gs1900-24hp-v2) ubootenv_add_uci_sys_config "/dev/mtd$idx2" "0x0" "0x1000" "0x10000" ;; tplink,sg2008p-v1|\ +tplink,sg2210p-v3|\ tplink,sg2452p-v4) idx="$(find_mtd_index u-boot-env)" [ -n "$idx" ] && \ diff --git a/target/linux/realtek/base-files/etc/board.d/02_network b/target/linux/realtek/base-files/etc/board.d/02_network index aacbef77b4..1dea2ad5a6 100644 --- a/target/linux/realtek/base-files/etc/board.d/02_network +++ b/target/linux/realtek/base-files/etc/board.d/02_network @@ -40,6 +40,7 @@ hpe,1920-24g) lan_mac_end=$(macaddr_add $lan_mac $((mac_count2-mac_count1))) ;; tplink,sg2008p-v1|\ +tplink,sg2210p-v3|\ tplink,sg2452p-v4) label_mac=$(get_mac_label) lan_mac="$label_mac" diff --git a/target/linux/realtek/base-files/lib/upgrade/platform.sh b/target/linux/realtek/base-files/lib/upgrade/platform.sh index b39b332063..6faded74b5 100644 --- a/target/linux/realtek/base-files/lib/upgrade/platform.sh +++ b/target/linux/realtek/base-files/lib/upgrade/platform.sh @@ -27,7 +27,8 @@ platform_do_upgrade() { local board=$(board_name) case "$board" in - tplink,sg2008p-v1) + tplink,sg2008p-v1|\ + tplink,sg2210p-v3) tplink_sg2xxx_fix_mtdparts default_do_upgrade "$1" ;; diff --git a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts index 0fef52984c..bf43e412b1 100644 --- a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts +++ b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2008p-v1.dts @@ -6,3 +6,23 @@ compatible = "tplink,sg2008p-v1", "realtek,rtl838x-soc"; model = "TP-Link SG2008P v1"; }; + +&tps23861_20 { + status = "disabled"; +}; + +&phy24 { + status = "disabled"; +}; + +&phy26 { + status = "disabled"; +}; + +&port24 { + status = "disabled"; +}; + +&port26 { + status = "disabled"; +}; diff --git a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2210p-v3.dts b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2210p-v3.dts new file mode 100644 index 0000000000..4b0022c388 --- /dev/null +++ b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2210p-v3.dts @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "rtl8380_tplink_sg2xxx.dtsi" + +/ { + compatible = "tplink,sg2210p-v3", "realtek,rtl838x-soc"; + model = "TP-Link SG2210P v3"; +}; + +&port24 { + label = "lan-sfp2"; +}; + +&port26 { + label = "lan-sfp1"; +}; diff --git a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi index 8eb309d8a8..e727a9405a 100644 --- a/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi +++ b/target/linux/realtek/dts-5.10/rtl8380_tplink_sg2xxx.dtsi @@ -51,7 +51,13 @@ #address-cells = <1>; #size-cells = <0>; - tps23861@28 { + tps23861_20: tps23861@20 { + compatible = "ti,tps23861"; + reg = <0x20>; + shunt-resistor-micro-ohms = <255000>; + }; + + tps23861_28: tps23861@28 { compatible = "ti,tps23861"; reg = <0x28>; shunt-resistor-micro-ohms = <255000>; @@ -140,6 +146,9 @@ INTERNAL_PHY(13) INTERNAL_PHY(14) INTERNAL_PHY(15) + + INTERNAL_PHY(24) + INTERNAL_PHY(26) }; }; @@ -157,6 +166,9 @@ SWITCH_PORT(9, 7, internal) SWITCH_PORT(8, 8, internal) + SWITCH_SFP_PORT(24, 9, 1000base-x) + SWITCH_SFP_PORT(26, 10, 1000base-x) + port@28 { ethernet = <ðernet0>; reg = <28>; diff --git a/target/linux/realtek/image/rtl838x.mk b/target/linux/realtek/image/rtl838x.mk index 3e27576bda..36b19b3cbb 100644 --- a/target/linux/realtek/image/rtl838x.mk +++ b/target/linux/realtek/image/rtl838x.mk @@ -188,6 +188,17 @@ define Device/tplink_sg2008p-v1 endef TARGET_DEVICES += tplink_sg2008p-v1 +define Device/tplink_sg2210p-v3 + SOC := rtl8380 + KERNEL_SIZE := 6m + IMAGE_SIZE := 26m + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := SG2210P + DEVICE_VARIANT := v3 + DEVICE_PACKAGES := kmod-hwmon-tps23861 +endef +TARGET_DEVICES += tplink_sg2210p-v3 + define Device/zyxel_gs1900 SOC := rtl8380 IMAGE_SIZE := 6976k From 4f42566d47999c392c8ea41dc27215b43ed9ee40 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Mon, 20 Jun 2022 13:13:30 +0200 Subject: [PATCH 092/114] CI: include automatic Pull Request Labeler This adds GitHub CI action which makes use of 'Labeler', allowing automatic labeling of new PRs, based on the modified files paths. Below labels are supported and more can be added later: - 'target/*' - 'target/imagebuilder' - 'kernel' - 'core packages' - 'build/scripts/tools' - 'toolchain' - 'GitHub/CI' For more information: https://github.com/marketplace/actions/labeler Signed-off-by: Piotr Dymacz --- .github/labeler.yml | 103 ++++++++++++++++++++++++++++++++++ .github/workflows/labeler.yml | 12 ++++ 2 files changed, 115 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000000..0910d37bd5 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,103 @@ +# target/* +"target/airoha": + - "target/linux/airoha/**" +"target/apm821xx": + - "target/linux/apm821xx/**" +"target/archs38": + - "target/linux/archs38/**" +"target/armvirt": + - "target/linux/armvirt/**" +"target/at91": + - "target/linux/at91/**" +"target/ath25": + - "target/linux/ath25/**" +"target/ath79": + - "target/linux/ath79/**" +"target/bcm27xx": + - "target/linux/bcm27xx/**" +"target/bcm47xx": + - "target/linux/bcm47xx/**" +"target/bcm4908": + - "target/linux/bcm4908/**" +"target/bcm53xx": + - "target/linux/bcm53xx/**" +"target/bcm63xx": + - "target/linux/bcm63xx/**" +"target/bmips": + - "target/linux/bmips/**" +"target/gemini": + - "target/linux/gemini/**" +"target/imx": + - "target/linux/imx/**" +"target/ipq40xx": + - "target/linux/ipq40xx/**" +"target/ipq806x": + - "target/linux/ipq806x/**" +"target/kirkwood": + - "target/linux/kirkwood/**" +"target/lantiq": + - "target/linux/lantiq/**" +"target/layerscape": + - "target/linux/layerscape/**" +"target/malta": + - "target/linux/malta/**" +"target/mediatek": + - "target/linux/mediatek/**" +"target/mpc85xx": + - "target/linux/mpc85xx/**" +"target/mvebu": + - "target/linux/mvebu/**" +"target/mxs": + - "target/linux/mxs/**" +"target/octeon": + - "target/linux/octeon/**" +"target/octeontx": + - "target/linux/octeontx/**" +"target/omap": + - "target/linux/omap/**" +"target/oxnas": + - "target/linux/oxnas/**" +"target/pistachio": + - "target/linux/pistachio/**" +"target/qoriq": + - "target/linux/qoriq/**" +"target/ramips": + - "target/linux/ramips/**" +"target/realtek": + - "target/linux/realtek/**" +"target/rockchip": + - "target/linux/rockchip/**" +"target/sunxi": + - "target/linux/sunxi/**" +"target/tegra": + - "target/linux/tegra/**" +"target/uml": + - "target/linux/uml/**" +"target/x86": + - "target/linux/x86/**" +"target/zynq": + - "target/linux/zynq/**" +# target/imagebuilder +"target/imagebuilder": + - "target/imagebuilder/**" +# kernel +"kernel": + - "target/linux/generic/**" + - "target/linux/**/config-*" + - "target/linux/**/patches-*" + - "target/linux/**/files/**" + - "package/kernel/linux/**" +# core packages +"core packages": + - "package/**" +# build/scripts/tools +"build/scripts/tools": + - "include/**" + - "scripts/**" + - "tools/**" +# toolchain +"toolchain": + - "toolchain/**" +# GitHub/CI +"GitHub/CI": + - ".github/**" diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000000..6bcdf51a89 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,12 @@ +name: 'Pull Request Labeler' +on: + - pull_request_target + +jobs: + labeler: + name: Pull Request Labeler + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v4.0.1 + with: + repo-token: '${{ secrets.GITHUB_TOKEN }}' From fb59070466a4d50938888d9d23e592598f686019 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 12 Sep 2022 00:55:58 -0700 Subject: [PATCH 093/114] mt7621: fix Belkin RT1800 GPIO When converting this device to use both GMACs, I mistakenly removed state_default, which prevented GPIO LEDs and keys from being used. Add back and and extra LEDs that were missing. Tested all LEDs by turning them on. Fixes: 26a6a6a60ba7 ("ramips: add support for Belkin RT1800") Signed-off-by: Rosen Penev --- .../linux/ramips/dts/mt7621_belkin_rt1800.dts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/target/linux/ramips/dts/mt7621_belkin_rt1800.dts b/target/linux/ramips/dts/mt7621_belkin_rt1800.dts index 7bf7d89445..16ae732429 100644 --- a/target/linux/ramips/dts/mt7621_belkin_rt1800.dts +++ b/target/linux/ramips/dts/mt7621_belkin_rt1800.dts @@ -40,12 +40,24 @@ leds { compatible = "gpio-leds"; + led-wps { + color = ; + function = LED_FUNCTION_WPS; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + led_power: led-power { label = "white:power"; gpios = <&gpio 14 GPIO_ACTIVE_LOW>; default-state = "on"; }; + led-wan2 { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + led-wan { color = ; function = LED_FUNCTION_WAN; @@ -125,6 +137,13 @@ }; }; +&state_default { + gpio { + groups = "i2c", "uart3", "jtag", "wdt"; + function = "gpio"; + }; +}; + &gmac1 { status = "okay"; label = "wan"; From cfd916065f54ca439a4b3bad9869023fe64d1c0b Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 12 Sep 2022 00:59:13 -0700 Subject: [PATCH 094/114] mt7621: fix Linksys E7350 GPIO When converting this device to use both GMACs, I mistakenly removed state_default, which prevented GPIO LEDs and keys from being used. Fixes: f4eef5f2a184 ("ramips: add support for Linksys E7350") Signed-off-by: Rosen Penev --- target/linux/ramips/dts/mt7621_linksys_e7350.dts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/linux/ramips/dts/mt7621_linksys_e7350.dts b/target/linux/ramips/dts/mt7621_linksys_e7350.dts index 0cdfcb4683..d7b8c214b9 100644 --- a/target/linux/ramips/dts/mt7621_linksys_e7350.dts +++ b/target/linux/ramips/dts/mt7621_linksys_e7350.dts @@ -165,6 +165,13 @@ }; }; +&state_default { + gpio { + groups = "i2c", "uart3", "jtag", "wdt"; + function = "gpio"; + }; +}; + &gmac1 { status = "okay"; label = "wan"; From c3e4a0d99b972b91dd65f535365b9b71fcb541ae Mon Sep 17 00:00:00 2001 From: Kabuli Chana Date: Sun, 7 Aug 2022 17:05:51 -0600 Subject: [PATCH 095/114] kernel: netsupport: Add FQ-PIE as an optional sched kmod and extract PIE add Flow Queuing with Proportional Integral controller Enhanced (FQ-PIE) as an optional kmod in network support and extract sched-pie from kmod-sched to allow dependency on just kmod-sched-pie (PIE). Signed-off-by: Kabuli Chana --- package/kernel/linux/modules/netsupport.mk | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/package/kernel/linux/modules/netsupport.mk b/package/kernel/linux/modules/netsupport.mk index be0347527d..9afee41aed 100644 --- a/package/kernel/linux/modules/netsupport.mk +++ b/package/kernel/linux/modules/netsupport.mk @@ -892,6 +892,22 @@ endef $(eval $(call KernelPackage,sched-flower)) +define KernelPackage/sched-fq-pie + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Flow Queue Proportional Integral Enhanced (FQ-PIE) + DEPENDS:=+kmod-sched-core +kmod-sched-pie + KCONFIG:=CONFIG_NET_SCH_FQ_PIE + FILES:=$(LINUX_DIR)/net/sched/sch_fq_pie.ko + AUTOLOAD:=$(call AutoProbe, sch_fq_pie) +endef + +define KernelPackage/sched-fq-pie/description + A queuing discipline that combines Flow Queuing with the PIE AQM. +endef + +$(eval $(call KernelPackage,sched-fq-pie)) + + define KernelPackage/sched-ipset SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=Traffic shaper ipset support @@ -922,6 +938,22 @@ endef $(eval $(call KernelPackage,sched-mqprio)) +define KernelPackage/sched-pie + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Proportional Integral controller-Enhanced AQM (PIE) + DEPENDS:=+kmod-sched-core + KCONFIG:=CONFIG_NET_SCH_PIE + FILES:=$(LINUX_DIR)/net/sched/sch_pie.ko + AUTOLOAD:=$(call AutoProbe, sch_pie) +endef + +define KernelPackage/sched-pie/description + A control theoretic active queue management scheme. +endef + +$(eval $(call KernelPackage,sched-pie)) + + define KernelPackage/sched-prio SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=Multi Band Priority Queueing (PRIO) @@ -964,7 +996,7 @@ endef $(eval $(call KernelPackage,bpf-test)) -SCHED_MODULES_EXTRA = sch_codel sch_dsmark sch_gred sch_multiq sch_sfq sch_teql sch_fq sch_pie act_pedit act_simple act_csum em_cmp em_nbyte em_meta em_text +SCHED_MODULES_EXTRA = sch_codel sch_dsmark sch_gred sch_multiq sch_sfq sch_teql sch_fq act_pedit act_simple act_csum em_cmp em_nbyte em_meta em_text SCHED_FILES_EXTRA = $(foreach mod,$(SCHED_MODULES_EXTRA),$(LINUX_DIR)/net/sched/$(mod).ko) define KernelPackage/sched @@ -979,7 +1011,6 @@ define KernelPackage/sched CONFIG_NET_SCH_SFQ \ CONFIG_NET_SCH_TEQL \ CONFIG_NET_SCH_FQ \ - CONFIG_NET_SCH_PIE \ CONFIG_NET_ACT_PEDIT \ CONFIG_NET_ACT_SIMP \ CONFIG_NET_ACT_CSUM \ From 21dfd7289b72fefd8d97c89a08ad7c3e0fb791af Mon Sep 17 00:00:00 2001 From: Ilya Katsnelson Date: Thu, 8 Sep 2022 12:04:05 +0300 Subject: [PATCH 096/114] tools/bc: use more compatible shebang Update the existing patch to use a shebang that works on systems that don't have a /bin/bash, e.g. NixOS or GuixSD. Signed-off-by: Ilya Katsnelson --- tools/bc/patches/002-fix-libmath.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bc/patches/002-fix-libmath.patch b/tools/bc/patches/002-fix-libmath.patch index 1a8439542d..f2212f0953 100644 --- a/tools/bc/patches/002-fix-libmath.patch +++ b/tools/bc/patches/002-fix-libmath.patch @@ -10,7 +10,7 @@ -w -q -EOS-EOS -+#! /bin/bash ++#!/usr/bin/env bash +sed -e '1 s/^/{"/' \ + -e 's/$/",/' \ + -e '2,$ s/^/"/' \ From e8135247c19924a4bd164f422dd589465aaa294d Mon Sep 17 00:00:00 2001 From: Ilya Katsnelson Date: Tue, 7 Jun 2022 10:23:31 +0300 Subject: [PATCH 097/114] libcap: use more compatible shebang Patch a script to use a shebang that works on systems that don't have a /bin/bash, e.g. NixOS or GuixSD. Signed-off-by: Ilya Katsnelson --- .../libcap/patches/900-use-more-compatible-shebang.patch | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 package/libs/libcap/patches/900-use-more-compatible-shebang.patch diff --git a/package/libs/libcap/patches/900-use-more-compatible-shebang.patch b/package/libs/libcap/patches/900-use-more-compatible-shebang.patch new file mode 100644 index 0000000000..454c703fbe --- /dev/null +++ b/package/libs/libcap/patches/900-use-more-compatible-shebang.patch @@ -0,0 +1,8 @@ +--- a/progs/mkcapshdoc.sh ++++ b/progs/mkcapshdoc.sh +@@ -1,4 +1,4 @@ +-#!/bin/bash ++#!/usr/bin/env bash + # This script generates some C code for inclusion in the capsh binary. + # The Makefile generally only generates the .c code and compares it + # with the checked in code in the progs directory. From 428c5bf3d1b8a245d1fc3e8be6e23058c59aba8c Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Thu, 31 Mar 2022 21:15:51 +0200 Subject: [PATCH 098/114] scripts: add additional regex for dl_cleanup Add additional regex for dl_cleanup script to handle case with xxx-v1.2a and xxx-v1.2.3a Signed-off-by: Ansuel Smith --- scripts/dl_cleanup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/dl_cleanup.py b/scripts/dl_cleanup.py index ad1b88c8b9..d22762136a 100755 --- a/scripts/dl_cleanup.py +++ b/scripts/dl_cleanup.py @@ -119,8 +119,10 @@ versionRegex = ( (re.compile(r"(.+)[-_](\d\d\d\d)-?(\d\d)-?(\d\d)"), parseVer_ymd), # xxx-YYYY-MM-DD (re.compile(r"(.+)[-_]([0-9a-fA-F]{40,40})"), parseVer_GIT), # xxx-GIT_SHASUM (re.compile(r"(.+)[-_](\d+)\.(\d+)\.(\d+)(\w?)"), parseVer_123), # xxx-1.2.3a + (re.compile(r"(.+)[-_]v(\d+)\.(\d+)\.(\d+)(\w?)"), parseVer_123), # xxx-v1.2.3a (re.compile(r"(.+)[-_](\d+)_(\d+)_(\d+)"), parseVer_123), # xxx-1_2_3 (re.compile(r"(.+)[-_](\d+)\.(\d+)(\w?)"), parseVer_12), # xxx-1.2a + (re.compile(r"(.+)[-_]v(\d+)\.(\d+)(\w?)"), parseVer_12), # xxx-v1.2a (re.compile(r"(.+)[-_]r?(\d+)"), parseVer_r), # xxx-r1111 ) From 69760d415dddb0325bd0eb6bb607624747a2da6e Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Tue, 6 Jul 2021 03:25:06 +0200 Subject: [PATCH 099/114] scripts: assume dl/ the default dir for dl_cleanup script Assume dl/ the default dl dir and make it configurable if someone have that in a different place. Signed-off-by: Ansuel Smith --- scripts/dl_cleanup.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/dl_cleanup.py b/scripts/dl_cleanup.py index d22762136a..c3b427c436 100755 --- a/scripts/dl_cleanup.py +++ b/scripts/dl_cleanup.py @@ -185,6 +185,9 @@ def usage(): print(" -d|--dry-run Do a dry-run. Don't delete any files") print(" -B|--show-blacklist Show the blacklist and exit") print(" -w|--whitelist ITEM Remove ITEM from blacklist") + print( + " -D|--download-dir Provide path to dl dir to clean also the build directory" + ) def main(argv): @@ -193,25 +196,20 @@ def main(argv): try: (opts, args) = getopt.getopt( argv[1:], - "hdBw:", + "hdBwD:", [ "help", "dry-run", "show-blacklist", "whitelist=", + "download-dir=", ], ) - if len(args) != 1: - usage() - return 1 except getopt.GetoptError as e: usage() return 1 - directory = args[0] - if not os.path.exists(directory): - print("Can't find dl path", directory) - return 1 + directory = "dl/" for (o, v) in opts: if o in ("-h", "--help"): @@ -235,6 +233,12 @@ def main(argv): sep = "\t" print("%s%s(%s)" % (name, sep, regex.pattern)) return 0 + if o in ("-D", "--download-dir"): + directory = v + + if not os.path.exists(directory): + print("Can't find dl path", directory) + return 1 # Create a directory listing and parse the file names. entries = [] From cf2c9498bed5e2f34170ada394be26348949f107 Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Tue, 6 Jul 2021 03:28:55 +0200 Subject: [PATCH 100/114] scripts: add clean of build dir to dl_cleanup script Improve dl_cleanup by adding an option to also clean the build directory related to the downloaded package. The script will check every directory in build_dir/ and check if any old package is present there. If outdated package are found, the old one are cleared leaving only the last one. Signed-off-by: Ansuel Smith --- scripts/dl_cleanup.py | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/scripts/dl_cleanup.py b/scripts/dl_cleanup.py index c3b427c436..f7232b78c9 100755 --- a/scripts/dl_cleanup.py +++ b/scripts/dl_cleanup.py @@ -13,6 +13,7 @@ import sys import os import re import getopt +import shutil # Commandline options opt_dryrun = False @@ -140,15 +141,18 @@ class EntryParseError(Exception): class Entry: - def __init__(self, directory, filename): + def __init__(self, directory, builddir, filename): self.directory = directory self.filename = filename + self.builddir = builddir self.progname = "" self.fileext = "" + self.filenoext = "" for ext in extensions: if filename.endswith(ext): filename = filename[0 : 0 - len(ext)] + self.filenoext = filename self.fileext = ext break else: @@ -168,12 +172,27 @@ class Entry: def getPath(self): return (self.directory + "/" + self.filename).replace("//", "/") + def getBuildPaths(self): + paths = [] + for subdir in os.scandir(self.builddir): + package_build_dir = os.path.join(subdir.path, self.filenoext) + if os.path.exists(package_build_dir): + paths.append(package_build_dir) + return paths + def deleteFile(self): path = self.getPath() print("Deleting", path) if not opt_dryrun: os.unlink(path) + def deleteBuildDir(self): + paths = self.getBuildPaths() + for path in paths: + print("Deleting BuildDir", path) + if not opt_dryrun: + shutil.rmtree(path) + def __ge__(self, y): return self.version >= y.version @@ -188,6 +207,9 @@ def usage(): print( " -D|--download-dir Provide path to dl dir to clean also the build directory" ) + print( + " -b|--build-dir Provide path to build dir to clean also the build directory" + ) def main(argv): @@ -196,13 +218,14 @@ def main(argv): try: (opts, args) = getopt.getopt( argv[1:], - "hdBwD:", + "hdBwDb:", [ "help", "dry-run", "show-blacklist", "whitelist=", "download-dir=", + "build-dir=", ], ) except getopt.GetoptError as e: @@ -210,6 +233,7 @@ def main(argv): return 1 directory = "dl/" + builddir = "build_dir/" for (o, v) in opts: if o in ("-h", "--help"): @@ -235,11 +259,17 @@ def main(argv): return 0 if o in ("-D", "--download-dir"): directory = v + if o in ("-b", "--build-dir"): + builddir = v if not os.path.exists(directory): print("Can't find dl path", directory) return 1 + if not os.path.exists(builddir): + print("Can't find dl path", builddir) + return 1 + # Create a directory listing and parse the file names. entries = [] for filename in os.listdir(directory): @@ -252,7 +282,7 @@ def main(argv): break else: try: - entries.append(Entry(directory, filename)) + entries.append(Entry(directory, builddir, filename)) except EntryParseError as e: pass @@ -277,6 +307,8 @@ def main(argv): for version in versions: if version is not lastVersion: version.deleteFile() + if builddir: + version.deleteBuildDir() if opt_dryrun: print("Keeping", lastVersion.getPath()) From 9cec4a0ea45b241cc54c5bc172510b843f19229e Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Wed, 31 Aug 2022 17:20:52 +0200 Subject: [PATCH 101/114] realtek: Use built-in functionality for timeout loop In commit 81e3017609be ("realtek: clean up rtl838x MDIO busy wait loop") a hand-crafted loop was created, that nearly exactly replicate the iopoll's `read_poll_timeout` functionality. Use that instead. Signed-off-by: Olliver Schinagl --- .../drivers/net/dsa/rtl83xx/rtl838x.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c index 524594d725..f56901d707 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include +#include #include #include "rtl83xx.h" @@ -1805,20 +1806,14 @@ irqreturn_t rtl838x_switch_irq(int irq, void *dev_id) int rtl838x_smi_wait_op(int timeout) { - unsigned long end = jiffies + usecs_to_jiffies(timeout); + int ret = 0; + u32 val; - while (1) { - if (!(sw_r32(RTL838X_SMI_ACCESS_PHY_CTRL_1) & 0x1)) - return 0; + ret = readx_poll_timeout(sw_r32, RTL838X_SMI_ACCESS_PHY_CTRL_1, val, val & 0x1, 20, timeout); + if (ret) + pr_err("%s: timeout\n", __func__); - if (time_after(jiffies, end)) - break; - - usleep_range(10, 20); - } - - pr_err("rtl838x_smi_wait_op: timeout\n"); - return -1; + return ret; } /* From 2f50c53f1772f24e4687e960e21c5b392fb522f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Wed, 14 Sep 2022 14:20:38 +0200 Subject: [PATCH 102/114] bcm53xx: update NVMEM driver for NVRAM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Include support for NVMEM cells. Signed-off-by: Rafał Miłecki --- ...-parse-NVRAM-content-into-NVMEM-cell.patch | 146 ++++++++++++++++++ ...-find-Device-Tree-nodes-for-NVMEM-ce.patch | 38 +++++ ...-provide-NVMEM-content-to-the-NVRAM-.patch | 10 +- ...-parse-NVRAM-content-into-NVMEM-cell.patch | 146 ++++++++++++++++++ ...-find-Device-Tree-nodes-for-NVMEM-ce.patch | 38 +++++ ...-provide-NVMEM-content-to-the-NVRAM-.patch | 10 +- ...support-passing-DT-node-in-cell-info.patch | 41 +++++ ...support-passing-DT-node-in-cell-info.patch | 41 +++++ 8 files changed, 460 insertions(+), 10 deletions(-) create mode 100644 target/linux/bcm53xx/patches-5.10/081-v5.18-nvmem-brcm_nvram-parse-NVRAM-content-into-NVMEM-cell.patch create mode 100644 target/linux/bcm53xx/patches-5.10/082-v5.19-nvmem-brcm_nvram-find-Device-Tree-nodes-for-NVMEM-ce.patch create mode 100644 target/linux/bcm53xx/patches-5.15/080-v5.18-nvmem-brcm_nvram-parse-NVRAM-content-into-NVMEM-cell.patch create mode 100644 target/linux/bcm53xx/patches-5.15/081-v5.19-nvmem-brcm_nvram-find-Device-Tree-nodes-for-NVMEM-ce.patch create mode 100644 target/linux/generic/backport-5.10/802-v5.19-nvmem-core-support-passing-DT-node-in-cell-info.patch create mode 100644 target/linux/generic/backport-5.15/803-v5.19-nvmem-core-support-passing-DT-node-in-cell-info.patch diff --git a/target/linux/bcm53xx/patches-5.10/081-v5.18-nvmem-brcm_nvram-parse-NVRAM-content-into-NVMEM-cell.patch b/target/linux/bcm53xx/patches-5.10/081-v5.18-nvmem-brcm_nvram-parse-NVRAM-content-into-NVMEM-cell.patch new file mode 100644 index 0000000000..99781b3a7b --- /dev/null +++ b/target/linux/bcm53xx/patches-5.10/081-v5.18-nvmem-brcm_nvram-parse-NVRAM-content-into-NVMEM-cell.patch @@ -0,0 +1,146 @@ +From 6e977eaa8280e957b87904b536661550f2a6b3e8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 25 Feb 2022 17:58:20 +0000 +Subject: [PATCH] nvmem: brcm_nvram: parse NVRAM content into NVMEM cells +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +NVRAM consist of header and NUL separated key-value pairs. Parse it and +create NVMEM cell for every key-value entry. + +Signed-off-by: Rafał Miłecki +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20220225175822.8293-3-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/brcm_nvram.c | 90 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 90 insertions(+) + +--- a/drivers/nvmem/brcm_nvram.c ++++ b/drivers/nvmem/brcm_nvram.c +@@ -6,12 +6,26 @@ + #include + #include + #include ++#include + #include + #include ++#include ++ ++#define NVRAM_MAGIC "FLSH" + + struct brcm_nvram { + struct device *dev; + void __iomem *base; ++ struct nvmem_cell_info *cells; ++ int ncells; ++}; ++ ++struct brcm_nvram_header { ++ char magic[4]; ++ __le32 len; ++ __le32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */ ++ __le32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */ ++ __le32 config_ncdl; /* ncdl values for memc */ + }; + + static int brcm_nvram_read(void *context, unsigned int offset, void *val, +@@ -26,6 +40,75 @@ static int brcm_nvram_read(void *context + return 0; + } + ++static int brcm_nvram_add_cells(struct brcm_nvram *priv, uint8_t *data, ++ size_t len) ++{ ++ struct device *dev = priv->dev; ++ char *var, *value, *eq; ++ int idx; ++ ++ priv->ncells = 0; ++ for (var = data + sizeof(struct brcm_nvram_header); ++ var < (char *)data + len && *var; ++ var += strlen(var) + 1) { ++ priv->ncells++; ++ } ++ ++ priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL); ++ if (!priv->cells) ++ return -ENOMEM; ++ ++ for (var = data + sizeof(struct brcm_nvram_header), idx = 0; ++ var < (char *)data + len && *var; ++ var = value + strlen(value) + 1, idx++) { ++ eq = strchr(var, '='); ++ if (!eq) ++ break; ++ *eq = '\0'; ++ value = eq + 1; ++ ++ priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL); ++ if (!priv->cells[idx].name) ++ return -ENOMEM; ++ priv->cells[idx].offset = value - (char *)data; ++ priv->cells[idx].bytes = strlen(value); ++ } ++ ++ return 0; ++} ++ ++static int brcm_nvram_parse(struct brcm_nvram *priv) ++{ ++ struct device *dev = priv->dev; ++ struct brcm_nvram_header header; ++ uint8_t *data; ++ size_t len; ++ int err; ++ ++ memcpy_fromio(&header, priv->base, sizeof(header)); ++ ++ if (memcmp(header.magic, NVRAM_MAGIC, 4)) { ++ dev_err(dev, "Invalid NVRAM magic\n"); ++ return -EINVAL; ++ } ++ ++ len = le32_to_cpu(header.len); ++ ++ data = kcalloc(1, len, GFP_KERNEL); ++ memcpy_fromio(data, priv->base, len); ++ data[len - 1] = '\0'; ++ ++ err = brcm_nvram_add_cells(priv, data, len); ++ if (err) { ++ dev_err(dev, "Failed to add cells: %d\n", err); ++ return err; ++ } ++ ++ kfree(data); ++ ++ return 0; ++} ++ + static int brcm_nvram_probe(struct platform_device *pdev) + { + struct nvmem_config config = { +@@ -35,6 +118,7 @@ static int brcm_nvram_probe(struct platf + struct device *dev = &pdev->dev; + struct resource *res; + struct brcm_nvram *priv; ++ int err; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) +@@ -46,7 +130,13 @@ static int brcm_nvram_probe(struct platf + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + ++ err = brcm_nvram_parse(priv); ++ if (err) ++ return err; ++ + config.dev = dev; ++ config.cells = priv->cells; ++ config.ncells = priv->ncells; + config.priv = priv; + config.size = resource_size(res); + diff --git a/target/linux/bcm53xx/patches-5.10/082-v5.19-nvmem-brcm_nvram-find-Device-Tree-nodes-for-NVMEM-ce.patch b/target/linux/bcm53xx/patches-5.10/082-v5.19-nvmem-brcm_nvram-find-Device-Tree-nodes-for-NVMEM-ce.patch new file mode 100644 index 0000000000..a9eacd9419 --- /dev/null +++ b/target/linux/bcm53xx/patches-5.10/082-v5.19-nvmem-brcm_nvram-find-Device-Tree-nodes-for-NVMEM-ce.patch @@ -0,0 +1,38 @@ +From 207775f7e17b8fd0426a2ac4a5b81e4e1d71849e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 29 Apr 2022 17:26:47 +0100 +Subject: [PATCH] nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +DT binding for Broadcom's NVRAM supports specifying NVMEM cells as NVMEM +device (provider) subnodes. Look for such subnodes when collecing NVMEM +cells. This allows NVMEM consumers to use NVRAM variables. + +Signed-off-by: Rafał Miłecki +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20220429162701.2222-3-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/brcm_nvram.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/nvmem/brcm_nvram.c ++++ b/drivers/nvmem/brcm_nvram.c +@@ -8,6 +8,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -72,6 +73,7 @@ static int brcm_nvram_add_cells(struct b + return -ENOMEM; + priv->cells[idx].offset = value - (char *)data; + priv->cells[idx].bytes = strlen(value); ++ priv->cells[idx].np = of_get_child_by_name(dev->of_node, priv->cells[idx].name); + } + + return 0; diff --git a/target/linux/bcm53xx/patches-5.10/800-0002-nvmem-brcm_nvram-provide-NVMEM-content-to-the-NVRAM-.patch b/target/linux/bcm53xx/patches-5.10/800-0002-nvmem-brcm_nvram-provide-NVMEM-content-to-the-NVRAM-.patch index cf5952ad5f..ecc5f3974e 100644 --- a/target/linux/bcm53xx/patches-5.10/800-0002-nvmem-brcm_nvram-provide-NVMEM-content-to-the-NVRAM-.patch +++ b/target/linux/bcm53xx/patches-5.10/800-0002-nvmem-brcm_nvram-provide-NVMEM-content-to-the-NVRAM-.patch @@ -20,12 +20,12 @@ Signed-off-by: Rafał Miłecki #include #include #include -@@ -46,6 +47,8 @@ static int brcm_nvram_probe(struct platf - if (IS_ERR(priv->base)) - return PTR_ERR(priv->base); +@@ -136,6 +137,8 @@ static int brcm_nvram_probe(struct platf + if (err) + return err; + bcm47xx_nvram_init_from_iomem(priv->base, resource_size(res)); + config.dev = dev; - config.priv = priv; - config.size = resource_size(res); + config.cells = priv->cells; + config.ncells = priv->ncells; diff --git a/target/linux/bcm53xx/patches-5.15/080-v5.18-nvmem-brcm_nvram-parse-NVRAM-content-into-NVMEM-cell.patch b/target/linux/bcm53xx/patches-5.15/080-v5.18-nvmem-brcm_nvram-parse-NVRAM-content-into-NVMEM-cell.patch new file mode 100644 index 0000000000..99781b3a7b --- /dev/null +++ b/target/linux/bcm53xx/patches-5.15/080-v5.18-nvmem-brcm_nvram-parse-NVRAM-content-into-NVMEM-cell.patch @@ -0,0 +1,146 @@ +From 6e977eaa8280e957b87904b536661550f2a6b3e8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 25 Feb 2022 17:58:20 +0000 +Subject: [PATCH] nvmem: brcm_nvram: parse NVRAM content into NVMEM cells +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +NVRAM consist of header and NUL separated key-value pairs. Parse it and +create NVMEM cell for every key-value entry. + +Signed-off-by: Rafał Miłecki +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20220225175822.8293-3-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/brcm_nvram.c | 90 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 90 insertions(+) + +--- a/drivers/nvmem/brcm_nvram.c ++++ b/drivers/nvmem/brcm_nvram.c +@@ -6,12 +6,26 @@ + #include + #include + #include ++#include + #include + #include ++#include ++ ++#define NVRAM_MAGIC "FLSH" + + struct brcm_nvram { + struct device *dev; + void __iomem *base; ++ struct nvmem_cell_info *cells; ++ int ncells; ++}; ++ ++struct brcm_nvram_header { ++ char magic[4]; ++ __le32 len; ++ __le32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */ ++ __le32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */ ++ __le32 config_ncdl; /* ncdl values for memc */ + }; + + static int brcm_nvram_read(void *context, unsigned int offset, void *val, +@@ -26,6 +40,75 @@ static int brcm_nvram_read(void *context + return 0; + } + ++static int brcm_nvram_add_cells(struct brcm_nvram *priv, uint8_t *data, ++ size_t len) ++{ ++ struct device *dev = priv->dev; ++ char *var, *value, *eq; ++ int idx; ++ ++ priv->ncells = 0; ++ for (var = data + sizeof(struct brcm_nvram_header); ++ var < (char *)data + len && *var; ++ var += strlen(var) + 1) { ++ priv->ncells++; ++ } ++ ++ priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL); ++ if (!priv->cells) ++ return -ENOMEM; ++ ++ for (var = data + sizeof(struct brcm_nvram_header), idx = 0; ++ var < (char *)data + len && *var; ++ var = value + strlen(value) + 1, idx++) { ++ eq = strchr(var, '='); ++ if (!eq) ++ break; ++ *eq = '\0'; ++ value = eq + 1; ++ ++ priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL); ++ if (!priv->cells[idx].name) ++ return -ENOMEM; ++ priv->cells[idx].offset = value - (char *)data; ++ priv->cells[idx].bytes = strlen(value); ++ } ++ ++ return 0; ++} ++ ++static int brcm_nvram_parse(struct brcm_nvram *priv) ++{ ++ struct device *dev = priv->dev; ++ struct brcm_nvram_header header; ++ uint8_t *data; ++ size_t len; ++ int err; ++ ++ memcpy_fromio(&header, priv->base, sizeof(header)); ++ ++ if (memcmp(header.magic, NVRAM_MAGIC, 4)) { ++ dev_err(dev, "Invalid NVRAM magic\n"); ++ return -EINVAL; ++ } ++ ++ len = le32_to_cpu(header.len); ++ ++ data = kcalloc(1, len, GFP_KERNEL); ++ memcpy_fromio(data, priv->base, len); ++ data[len - 1] = '\0'; ++ ++ err = brcm_nvram_add_cells(priv, data, len); ++ if (err) { ++ dev_err(dev, "Failed to add cells: %d\n", err); ++ return err; ++ } ++ ++ kfree(data); ++ ++ return 0; ++} ++ + static int brcm_nvram_probe(struct platform_device *pdev) + { + struct nvmem_config config = { +@@ -35,6 +118,7 @@ static int brcm_nvram_probe(struct platf + struct device *dev = &pdev->dev; + struct resource *res; + struct brcm_nvram *priv; ++ int err; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) +@@ -46,7 +130,13 @@ static int brcm_nvram_probe(struct platf + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + ++ err = brcm_nvram_parse(priv); ++ if (err) ++ return err; ++ + config.dev = dev; ++ config.cells = priv->cells; ++ config.ncells = priv->ncells; + config.priv = priv; + config.size = resource_size(res); + diff --git a/target/linux/bcm53xx/patches-5.15/081-v5.19-nvmem-brcm_nvram-find-Device-Tree-nodes-for-NVMEM-ce.patch b/target/linux/bcm53xx/patches-5.15/081-v5.19-nvmem-brcm_nvram-find-Device-Tree-nodes-for-NVMEM-ce.patch new file mode 100644 index 0000000000..a9eacd9419 --- /dev/null +++ b/target/linux/bcm53xx/patches-5.15/081-v5.19-nvmem-brcm_nvram-find-Device-Tree-nodes-for-NVMEM-ce.patch @@ -0,0 +1,38 @@ +From 207775f7e17b8fd0426a2ac4a5b81e4e1d71849e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 29 Apr 2022 17:26:47 +0100 +Subject: [PATCH] nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +DT binding for Broadcom's NVRAM supports specifying NVMEM cells as NVMEM +device (provider) subnodes. Look for such subnodes when collecing NVMEM +cells. This allows NVMEM consumers to use NVRAM variables. + +Signed-off-by: Rafał Miłecki +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20220429162701.2222-3-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/brcm_nvram.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/nvmem/brcm_nvram.c ++++ b/drivers/nvmem/brcm_nvram.c +@@ -8,6 +8,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -72,6 +73,7 @@ static int brcm_nvram_add_cells(struct b + return -ENOMEM; + priv->cells[idx].offset = value - (char *)data; + priv->cells[idx].bytes = strlen(value); ++ priv->cells[idx].np = of_get_child_by_name(dev->of_node, priv->cells[idx].name); + } + + return 0; diff --git a/target/linux/bcm53xx/patches-5.15/800-0002-nvmem-brcm_nvram-provide-NVMEM-content-to-the-NVRAM-.patch b/target/linux/bcm53xx/patches-5.15/800-0002-nvmem-brcm_nvram-provide-NVMEM-content-to-the-NVRAM-.patch index cf5952ad5f..ecc5f3974e 100644 --- a/target/linux/bcm53xx/patches-5.15/800-0002-nvmem-brcm_nvram-provide-NVMEM-content-to-the-NVRAM-.patch +++ b/target/linux/bcm53xx/patches-5.15/800-0002-nvmem-brcm_nvram-provide-NVMEM-content-to-the-NVRAM-.patch @@ -20,12 +20,12 @@ Signed-off-by: Rafał Miłecki #include #include #include -@@ -46,6 +47,8 @@ static int brcm_nvram_probe(struct platf - if (IS_ERR(priv->base)) - return PTR_ERR(priv->base); +@@ -136,6 +137,8 @@ static int brcm_nvram_probe(struct platf + if (err) + return err; + bcm47xx_nvram_init_from_iomem(priv->base, resource_size(res)); + config.dev = dev; - config.priv = priv; - config.size = resource_size(res); + config.cells = priv->cells; + config.ncells = priv->ncells; diff --git a/target/linux/generic/backport-5.10/802-v5.19-nvmem-core-support-passing-DT-node-in-cell-info.patch b/target/linux/generic/backport-5.10/802-v5.19-nvmem-core-support-passing-DT-node-in-cell-info.patch new file mode 100644 index 0000000000..b7870eef4b --- /dev/null +++ b/target/linux/generic/backport-5.10/802-v5.19-nvmem-core-support-passing-DT-node-in-cell-info.patch @@ -0,0 +1,41 @@ +From dbc2f62061c6bfba0aee93161ee3194dcee84bd0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 29 Apr 2022 17:26:46 +0100 +Subject: [PATCH] nvmem: core: support passing DT node in cell info +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Some hardware may have NVMEM cells described in Device Tree using +individual nodes. Let drivers pass such nodes to the NVMEM subsystem so +they can be later used by NVMEM consumers. + +Signed-off-by: Rafał Miłecki +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20220429162701.2222-2-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/core.c | 1 + + include/linux/nvmem-consumer.h | 1 + + 2 files changed, 2 insertions(+) + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -374,6 +374,7 @@ static int nvmem_cell_info_to_nvmem_cell + + cell->bit_offset = info->bit_offset; + cell->nbits = info->nbits; ++ cell->np = info->np; + + if (cell->nbits) + cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset, +--- a/include/linux/nvmem-consumer.h ++++ b/include/linux/nvmem-consumer.h +@@ -25,6 +25,7 @@ struct nvmem_cell_info { + unsigned int bytes; + unsigned int bit_offset; + unsigned int nbits; ++ struct device_node *np; + }; + + /** diff --git a/target/linux/generic/backport-5.15/803-v5.19-nvmem-core-support-passing-DT-node-in-cell-info.patch b/target/linux/generic/backport-5.15/803-v5.19-nvmem-core-support-passing-DT-node-in-cell-info.patch new file mode 100644 index 0000000000..1acc6947fe --- /dev/null +++ b/target/linux/generic/backport-5.15/803-v5.19-nvmem-core-support-passing-DT-node-in-cell-info.patch @@ -0,0 +1,41 @@ +From dbc2f62061c6bfba0aee93161ee3194dcee84bd0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Fri, 29 Apr 2022 17:26:46 +0100 +Subject: [PATCH] nvmem: core: support passing DT node in cell info +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Some hardware may have NVMEM cells described in Device Tree using +individual nodes. Let drivers pass such nodes to the NVMEM subsystem so +they can be later used by NVMEM consumers. + +Signed-off-by: Rafał Miłecki +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20220429162701.2222-2-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/core.c | 1 + + include/linux/nvmem-consumer.h | 1 + + 2 files changed, 2 insertions(+) + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -462,6 +462,7 @@ static int nvmem_cell_info_to_nvmem_cell + + cell->bit_offset = info->bit_offset; + cell->nbits = info->nbits; ++ cell->np = info->np; + + if (cell->nbits) + cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset, +--- a/include/linux/nvmem-consumer.h ++++ b/include/linux/nvmem-consumer.h +@@ -25,6 +25,7 @@ struct nvmem_cell_info { + unsigned int bytes; + unsigned int bit_offset; + unsigned int nbits; ++ struct device_node *np; + }; + + /** From f8cd56def6480c0599984ba2a5d924f764398471 Mon Sep 17 00:00:00 2001 From: Tomasz Maciej Nowak Date: Tue, 13 Sep 2022 22:38:08 +0200 Subject: [PATCH 103/114] tegra: copy patches and config for kernel 5.15 Simple copy to better illustrate the forthcoming changes. Signed-off-by: Tomasz Maciej Nowak --- target/linux/tegra/config-5.15 | 484 ++++++++++++++++++ ...interrupts-due-to-tegra2-silicon-bug.patch | 77 +++ ...enable-front-panel-leds-in-TrimSlice.patch | 46 ++ 3 files changed, 607 insertions(+) create mode 100644 target/linux/tegra/config-5.15 create mode 100644 target/linux/tegra/patches-5.15/100-serial8250-on-tegra-hsuart-recover-from-spurious-interrupts-due-to-tegra2-silicon-bug.patch create mode 100644 target/linux/tegra/patches-5.15/101-ARM-dtc-tegra-enable-front-panel-leds-in-TrimSlice.patch diff --git a/target/linux/tegra/config-5.15 b/target/linux/tegra/config-5.15 new file mode 100644 index 0000000000..8d808595d9 --- /dev/null +++ b/target/linux/tegra/config-5.15 @@ -0,0 +1,484 @@ +CONFIG_AC97_BUS=y +# CONFIG_AHCI_TEGRA is not set +CONFIG_ALIGNMENT_TRAP=y +CONFIG_ARCH_32BIT_OFF_T=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_KEEP_MEMBLOCK=y +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +CONFIG_ARCH_MULTIPLATFORM=y +CONFIG_ARCH_MULTI_V6_V7=y +CONFIG_ARCH_MULTI_V7=y +CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED=y +CONFIG_ARCH_NR_GPIO=1024 +CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y +CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT=y +CONFIG_ARCH_SELECT_MEMORY_MODEL=y +CONFIG_ARCH_SPARSEMEM_ENABLE=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ARCH_TEGRA=y +# CONFIG_ARCH_TEGRA_114_SOC is not set +# CONFIG_ARCH_TEGRA_124_SOC is not set +CONFIG_ARCH_TEGRA_2x_SOC=y +# CONFIG_ARCH_TEGRA_3x_SOC is not set +CONFIG_ARM=y +CONFIG_ARM_AMBA=y +CONFIG_ARM_CPU_SUSPEND=y +CONFIG_ARM_CRYPTO=y +CONFIG_ARM_ERRATA_720789=y +CONFIG_ARM_ERRATA_754327=y +CONFIG_ARM_ERRATA_764369=y +CONFIG_ARM_GIC=y +CONFIG_ARM_HAS_SG_CHAIN=y +CONFIG_ARM_HEAVY_MB=y +CONFIG_ARM_L1_CACHE_SHIFT=6 +CONFIG_ARM_L1_CACHE_SHIFT_6=y +CONFIG_ARM_PATCH_IDIV=y +CONFIG_ARM_PATCH_PHYS_VIRT=y +# CONFIG_ARM_PL172_MPMC is not set +# CONFIG_ARM_SMMU is not set +CONFIG_ARM_TEGRA_CPUIDLE=y +CONFIG_ARM_THUMB=y +CONFIG_ARM_THUMBEE=y +CONFIG_ARM_UNWIND=y +CONFIG_ARM_VIRT_EXT=y +CONFIG_ASN1=y +CONFIG_ATA=y +CONFIG_ATAGS=y +CONFIG_AUTO_ZRELADDR=y +CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK=y +CONFIG_BLK_DEV_BSG=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_MQ_PCI=y +CONFIG_BLK_PM=y +CONFIG_BLK_SCSI_REQUEST=y +CONFIG_BOUNCE=y +CONFIG_CACHE_L2X0=y +CONFIG_CLKDEV_LOOKUP=y +CONFIG_CLKSRC_MMIO=y +CONFIG_CLONE_BACKWARDS=y +CONFIG_CLZ_TAB=y +CONFIG_CMA=y +CONFIG_CMA_ALIGNMENT=8 +CONFIG_CMA_AREAS=7 +# CONFIG_CMA_DEBUG is not set +# CONFIG_CMA_DEBUGFS is not set +CONFIG_CMA_SIZE_MBYTES=16 +# CONFIG_CMA_SIZE_SEL_MAX is not set +CONFIG_CMA_SIZE_SEL_MBYTES=y +# CONFIG_CMA_SIZE_SEL_MIN is not set +# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set +CONFIG_COMMON_CLK=y +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_CONTIG_ALLOC=y +# CONFIG_CPUFREQ_DT is not set +CONFIG_CPU_32v6K=y +CONFIG_CPU_32v7=y +CONFIG_CPU_ABRT_EV7=y +CONFIG_CPU_CACHE_V7=y +CONFIG_CPU_CACHE_VIPT=y +CONFIG_CPU_COPY_V6=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set +CONFIG_CPU_FREQ_GOV_ATTR_SET=y +CONFIG_CPU_FREQ_GOV_COMMON=y +CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y +CONFIG_CPU_FREQ_GOV_POWERSAVE=y +CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y +CONFIG_CPU_FREQ_GOV_USERSPACE=y +# CONFIG_CPU_FREQ_STAT is not set +CONFIG_CPU_HAS_ASID=y +CONFIG_CPU_IDLE=y +CONFIG_CPU_IDLE_GOV_LADDER=y +CONFIG_CPU_PABRT_V7=y +CONFIG_CPU_PM=y +CONFIG_CPU_RMAP=y +CONFIG_CPU_SPECTRE=y +CONFIG_CPU_THUMB_CAPABLE=y +CONFIG_CPU_TLB_V7=y +CONFIG_CPU_V7=y +CONFIG_CRC16=y +# CONFIG_CRC32_SARWATE is not set +CONFIG_CRC32_SLICEBY8=y +CONFIG_CROSS_MEMORY_ATTACH=y +CONFIG_CRYPTO_ACOMP2=y +CONFIG_CRYPTO_AES_ARM=y +CONFIG_CRYPTO_AKCIPHER=y +CONFIG_CRYPTO_AKCIPHER2=y +CONFIG_CRYPTO_BLAKE2S=y +CONFIG_CRYPTO_CRC32=y +CONFIG_CRYPTO_CRC32C=y +CONFIG_CRYPTO_CRYPTD=y +CONFIG_CRYPTO_DEFLATE=y +CONFIG_CRYPTO_DRBG=y +CONFIG_CRYPTO_DRBG_HMAC=y +CONFIG_CRYPTO_DRBG_MENU=y +CONFIG_CRYPTO_ECHAINIV=y +CONFIG_CRYPTO_HMAC=y +CONFIG_CRYPTO_JITTERENTROPY=y +CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y +CONFIG_CRYPTO_LIB_SHA256=y +CONFIG_CRYPTO_LZ4=y +CONFIG_CRYPTO_LZ4HC=y +CONFIG_CRYPTO_LZO=y +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_RNG_DEFAULT=y +CONFIG_CRYPTO_RSA=y +CONFIG_CRYPTO_SEQIV=y +CONFIG_CRYPTO_SHA1=y +CONFIG_CRYPTO_SHA1_ARM=y +CONFIG_CRYPTO_SHA256=y +CONFIG_CRYPTO_SHA256_ARM=y +CONFIG_CRYPTO_SHA512_ARM=y +CONFIG_CRYPTO_TWOFISH=y +CONFIG_CRYPTO_TWOFISH_COMMON=y +CONFIG_DCACHE_WORD_ACCESS=y +CONFIG_DEBUG_ALIGN_RODATA=y +CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S" +# CONFIG_DEVPORT is not set +CONFIG_DMADEVICES=y +CONFIG_DMA_CMA=y +CONFIG_DMA_ENGINE=y +CONFIG_DMA_OF=y +CONFIG_DMA_OPS=y +CONFIG_DMA_REMAP=y +CONFIG_DMA_SHARED_BUFFER=y +CONFIG_DNOTIFY=y +CONFIG_DRM=y +CONFIG_DRM_BRIDGE=y +CONFIG_DRM_FBDEV_EMULATION=y +CONFIG_DRM_FBDEV_OVERALLOC=100 +CONFIG_DRM_KMS_FB_HELPER=y +CONFIG_DRM_KMS_HELPER=y +CONFIG_DRM_MIPI_DSI=y +CONFIG_DRM_PANEL=y +CONFIG_DRM_PANEL_BRIDGE=y +CONFIG_DRM_PANEL_ORIENTATION_QUIRKS=y +CONFIG_DRM_TEGRA=y +# CONFIG_DRM_TEGRA_DEBUG is not set +# CONFIG_DRM_TEGRA_STAGING is not set +CONFIG_DTC=y +CONFIG_EDAC_ATOMIC_SCRUB=y +CONFIG_EDAC_SUPPORT=y +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_EXT4_FS=y +CONFIG_EXTCON=y +CONFIG_F2FS_FS=y +CONFIG_FB=y +CONFIG_FB_CFB_COPYAREA=y +CONFIG_FB_CFB_FILLRECT=y +CONFIG_FB_CFB_IMAGEBLIT=y +CONFIG_FB_CMDLINE=y +CONFIG_FB_DEFERRED_IO=y +CONFIG_FB_SYS_COPYAREA=y +CONFIG_FB_SYS_FILLRECT=y +CONFIG_FB_SYS_FOPS=y +CONFIG_FB_SYS_IMAGEBLIT=y +CONFIG_FIX_EARLYCON_MEM=y +CONFIG_FREEZER=y +CONFIG_FS_IOMAP=y +CONFIG_FS_MBCACHE=y +# CONFIG_FW_CACHE is not set +CONFIG_FW_LOADER_PAGED_BUF=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_GENERIC_ARCH_TOPOLOGY=y +CONFIG_GENERIC_BUG=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_EARLY_IOREMAP=y +CONFIG_GENERIC_GETTIMEOFDAY=y +CONFIG_GENERIC_IDLE_POLL_SETUP=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_IRQ_MIGRATION=y +CONFIG_GENERIC_IRQ_MULTI_HANDLER=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_IRQ_SHOW_LEVEL=y +CONFIG_GENERIC_MSI_IRQ=y +CONFIG_GENERIC_MSI_IRQ_DOMAIN=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_PHY=y +CONFIG_GENERIC_PINCONF=y +CONFIG_GENERIC_PINCTRL_GROUPS=y +CONFIG_GENERIC_PINMUX_FUNCTIONS=y +CONFIG_GENERIC_SCHED_CLOCK=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GENERIC_VDSO_32=y +CONFIG_GLOB=y +CONFIG_GPIO_TEGRA=y +CONFIG_HANDLE_DOMAIN_IRQ=y +CONFIG_HARDEN_BRANCH_PREDICTOR=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HAVE_SMP=y +CONFIG_HDMI=y +CONFIG_HID=y +CONFIG_HIDRAW=y +CONFIG_HID_GENERIC=y +CONFIG_HIGHMEM=y +CONFIG_HIGHPTE=y +CONFIG_HOTPLUG_CPU=y +CONFIG_HWMON=y +CONFIG_HZ_FIXED=0 +CONFIG_HZ_PERIODIC=y +CONFIG_I2C=y +CONFIG_I2C_ALGOBIT=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_COMPAT=y +CONFIG_I2C_TEGRA=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_INPUT=y +CONFIG_INPUT_KEYBOARD=y +CONFIG_IOMMU_API=y +# CONFIG_IOMMU_DEBUGFS is not set +# CONFIG_IOMMU_DEFAULT_PASSTHROUGH is not set +CONFIG_IOMMU_IOVA=y +# CONFIG_IOMMU_IO_PGTABLE_ARMV7S is not set +# CONFIG_IOMMU_IO_PGTABLE_LPAE is not set +CONFIG_IOMMU_SUPPORT=y +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_DOMAIN_HIERARCHY=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_WORK=y +CONFIG_JBD2=y +CONFIG_KCMP=y +CONFIG_KEYBOARD_ATKBD=y +CONFIG_LIBFDT=y +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_LOCK_SPIN_ON_OWNER=y +CONFIG_LZ4HC_COMPRESS=y +CONFIG_LZ4_COMPRESS=y +CONFIG_LZ4_DECOMPRESS=y +CONFIG_LZO_COMPRESS=y +CONFIG_LZO_DECOMPRESS=y +CONFIG_MEMFD_CREATE=y +CONFIG_MEMORY=y +CONFIG_MEMORY_ISOLATION=y +# CONFIG_MFD_NVEC is not set +CONFIG_MIGHT_HAVE_CACHE_L2X0=y +CONFIG_MIGRATION=y +CONFIG_MMC=y +CONFIG_MMC_BLOCK=y +CONFIG_MMC_CQHCI=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_IO_ACCESSORS=y +# CONFIG_MMC_SDHCI_PCI is not set +CONFIG_MMC_SDHCI_PLTFM=y +CONFIG_MMC_SDHCI_TEGRA=y +CONFIG_MODULES_USE_ELF_REL=y +CONFIG_MPILIB=y +CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y +CONFIG_MUTEX_SPIN_ON_OWNER=y +CONFIG_NEED_DMA_MAP_STATE=y +# CONFIG_NEON is not set +CONFIG_NET_FLOW_LIMIT=y +CONFIG_NLS=y +CONFIG_NR_CPUS=4 +CONFIG_NVMEM=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IOMMU=y +CONFIG_OF_IRQ=y +CONFIG_OF_KOBJ=y +CONFIG_OF_NET=y +CONFIG_OLD_SIGACTION=y +CONFIG_OLD_SIGSUSPEND3=y +CONFIG_OUTER_CACHE=y +CONFIG_OUTER_CACHE_SYNC=y +CONFIG_PADATA=y +CONFIG_PAGE_OFFSET=0xC0000000 +CONFIG_PCI=y +CONFIG_PCIEAER=y +CONFIG_PCIEASPM=y +CONFIG_PCIEASPM_DEFAULT=y +# CONFIG_PCIEASPM_PERFORMANCE is not set +# CONFIG_PCIEASPM_POWERSAVE is not set +# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set +CONFIG_PCIEPORTBUS=y +CONFIG_PCIE_PME=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCI_DOMAINS_GENERIC=y +CONFIG_PCI_MSI=y +CONFIG_PCI_MSI_ARCH_FALLBACKS=y +CONFIG_PCI_MSI_IRQ_DOMAIN=y +CONFIG_PCI_TEGRA=y +CONFIG_PERF_USE_VMALLOC=y +CONFIG_PGTABLE_LEVELS=2 +CONFIG_PHY_TEGRA_XUSB=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_TEGRA=y +CONFIG_PINCTRL_TEGRA20=y +CONFIG_PINCTRL_TEGRA_XUSB=y +CONFIG_PL310_ERRATA_727915=y +CONFIG_PL310_ERRATA_769419=y +CONFIG_PL353_SMC=y +CONFIG_PM=y +CONFIG_PM_CLK=y +CONFIG_PM_OPP=y +CONFIG_PM_SLEEP=y +CONFIG_PM_SLEEP_SMP=y +CONFIG_POWER_RESET=y +CONFIG_POWER_RESET_GPIO=y +CONFIG_POWER_SUPPLY=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_PWM=y +CONFIG_PWM_SYSFS=y +CONFIG_PWM_TEGRA=y +CONFIG_RAS=y +CONFIG_RATIONAL=y +CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y +CONFIG_REGMAP_MMIO=y +CONFIG_REGMAP_SPI=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_REGULATOR_GPIO=y +CONFIG_RESET_CONTROLLER=y +CONFIG_RFS_ACCEL=y +CONFIG_RPS=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_TEGRA=y +CONFIG_RTC_I2C_AND_SPI=y +CONFIG_RTC_MC146818_LIB=y +CONFIG_RTC_NVMEM=y +CONFIG_RWSEM_SPIN_ON_OWNER=y +CONFIG_SCSI=y +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_PROC_FS is not set +CONFIG_SERIAL_8250_FSL=y +CONFIG_SERIAL_8250_TEGRA=y +CONFIG_SERIAL_MCTRL_GPIO=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SERIAL_TEGRA=y +CONFIG_SERIO=y +CONFIG_SERIO_LIBPS2=y +CONFIG_SGL_ALLOC=y +CONFIG_SG_POOL=y +CONFIG_SMP=y +CONFIG_SMP_ON_UP=y +CONFIG_SND=y +# CONFIG_SND_COMPRESS_OFFLOAD is not set +CONFIG_SND_DMAENGINE_PCM=y +# CONFIG_SND_DRIVERS is not set +# CONFIG_SND_HDA_TEGRA is not set +CONFIG_SND_JACK=y +CONFIG_SND_JACK_INPUT_DEV=y +# CONFIG_SND_PCI is not set +CONFIG_SND_PCM=y +# CONFIG_SND_PROC_FS is not set +CONFIG_SND_SIMPLE_CARD=y +CONFIG_SND_SIMPLE_CARD_UTILS=y +CONFIG_SND_SOC=y +CONFIG_SND_SOC_AC97_BUS=y +CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM=y +CONFIG_SND_SOC_I2C_AND_SPI=y +CONFIG_SND_SOC_TEGRA=y +# CONFIG_SND_SOC_TEGRA186_DSPK is not set +CONFIG_SND_SOC_TEGRA20_AC97=y +CONFIG_SND_SOC_TEGRA20_DAS=y +CONFIG_SND_SOC_TEGRA20_I2S=y +CONFIG_SND_SOC_TEGRA20_SPDIF=y +# CONFIG_SND_SOC_TEGRA210_ADMAIF is not set +# CONFIG_SND_SOC_TEGRA210_AHUB is not set +# CONFIG_SND_SOC_TEGRA210_DMIC is not set +# CONFIG_SND_SOC_TEGRA210_I2S is not set +# CONFIG_SND_SOC_TEGRA30_AHUB is not set +# CONFIG_SND_SOC_TEGRA30_I2S is not set +# CONFIG_SND_SOC_TEGRA_ALC5632 is not set +# CONFIG_SND_SOC_TEGRA_MAX98090 is not set +# CONFIG_SND_SOC_TEGRA_RT5640 is not set +# CONFIG_SND_SOC_TEGRA_RT5677 is not set +# CONFIG_SND_SOC_TEGRA_SGTL5000 is not set +CONFIG_SND_SOC_TEGRA_TRIMSLICE=y +# CONFIG_SND_SOC_TEGRA_WM8753 is not set +# CONFIG_SND_SOC_TEGRA_WM8903 is not set +# CONFIG_SND_SOC_TEGRA_WM9712 is not set +CONFIG_SND_SOC_TLV320AIC23=y +CONFIG_SND_SOC_TLV320AIC23_I2C=y +# CONFIG_SND_USB is not set +CONFIG_SOC_BUS=y +CONFIG_SOC_TEGRA20_VOLTAGE_COUPLER=y +CONFIG_SOC_TEGRA_FLOWCTRL=y +CONFIG_SOC_TEGRA_FUSE=y +CONFIG_SOC_TEGRA_PMC=y +CONFIG_SOUND=y +CONFIG_SOUND_OSS_CORE=y +CONFIG_SOUND_OSS_CORE_PRECLAIM=y +CONFIG_SPARSE_IRQ=y +CONFIG_SPI=y +CONFIG_SPI_MASTER=y +CONFIG_SPI_MEM=y +# CONFIG_SPI_TEGRA114 is not set +CONFIG_SPI_TEGRA20_SFLASH=y +CONFIG_SPI_TEGRA20_SLINK=y +CONFIG_SRCU=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +CONFIG_SWP_EMULATE=y +CONFIG_SYNC_FILE=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_TEGRA20_APB_DMA=y +CONFIG_TEGRA20_EMC=y +CONFIG_TEGRA_AHB=y +CONFIG_TEGRA_GMI=y +CONFIG_TEGRA_HOST1X=y +CONFIG_TEGRA_HOST1X_FIREWALL=y +CONFIG_TEGRA_IOMMU_GART=y +# CONFIG_TEGRA_IOMMU_SMMU is not set +# CONFIG_TEGRA_IVC is not set +CONFIG_TEGRA_MC=y +# CONFIG_TEGRA_SOCTHERM is not set +CONFIG_TEGRA_TIMER=y +CONFIG_TEGRA_WATCHDOG=y +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TIMER_OF=y +CONFIG_TIMER_PROBE=y +CONFIG_TREE_RCU=y +CONFIG_TREE_SRCU=y +# CONFIG_UACCE is not set +# CONFIG_UCLAMP_TASK is not set +CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" +CONFIG_UNWINDER_ARM=y +CONFIG_USB=y +CONFIG_USB_COMMON=y +CONFIG_USB_CONN_GPIO=y +CONFIG_USB_EHCI_HCD=y +# CONFIG_USB_EHCI_HCD_PLATFORM is not set +CONFIG_USB_EHCI_TEGRA=y +CONFIG_USB_HID=y +CONFIG_USB_HIDDEV=y +CONFIG_USB_PHY=y +CONFIG_USB_ROLE_SWITCH=y +CONFIG_USB_SUPPORT=y +CONFIG_USB_TEGRA_PHY=y +CONFIG_USB_ULPI=y +CONFIG_USB_ULPI_VIEWPORT=y +CONFIG_USE_OF=y +CONFIG_VFP=y +CONFIG_VFPv3=y +CONFIG_WATCHDOG_CORE=y +# CONFIG_USB_XHCI_TEGRA is not set +CONFIG_XPS=y +CONFIG_XZ_DEC_ARM=y +CONFIG_XZ_DEC_ARMTHUMB=y +CONFIG_XZ_DEC_BCJ=y +CONFIG_ZBOOT_ROM_BSS=0 +CONFIG_ZBOOT_ROM_TEXT=0 +CONFIG_ZLIB_DEFLATE=y +CONFIG_ZLIB_INFLATE=y diff --git a/target/linux/tegra/patches-5.15/100-serial8250-on-tegra-hsuart-recover-from-spurious-interrupts-due-to-tegra2-silicon-bug.patch b/target/linux/tegra/patches-5.15/100-serial8250-on-tegra-hsuart-recover-from-spurious-interrupts-due-to-tegra2-silicon-bug.patch new file mode 100644 index 0000000000..8f01f73eb2 --- /dev/null +++ b/target/linux/tegra/patches-5.15/100-serial8250-on-tegra-hsuart-recover-from-spurious-interrupts-due-to-tegra2-silicon-bug.patch @@ -0,0 +1,77 @@ +From patchwork Fri Jul 13 11:32:42 2018 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: serial8250 on tegra hsuart: recover from spurious interrupts due to + tegra2 silicon bug +X-Patchwork-Submitter: "David R. Piegdon" +X-Patchwork-Id: 943440 +Message-Id: <4676ea34-69ce-5422-1ded-94218b89f7d9@p23q.org> +To: linux-tegra@vger.kernel.org +Date: Fri, 13 Jul 2018 11:32:42 +0000 +From: "David R. Piegdon" +List-Id: + +Hi, +a while back I sent a few mails regarding spurious interrupts in the +UARTA (hsuart) block of the Tegra2 SoC, when using the 8250 driver for +it instead of the hsuart driver. After going down a pretty deep +debugging/testing hole, I think I found a patch that fixes the issue. So +far testing in a reboot-cycle suggests that the error frequency dropped +from >3% of all reboots to at least <0.05% of all reboots. Tests +continue to run over the weekend. + +The patch below already is a second iteration; the first did not reset +the MCR or contain the lines below '// clear interrupts'. This resulted +in no more spurious interrupts, but in a few % of spurious interrupts +that were recovered the UART block did not receive any characters any +more. So further resetting was required to fully reacquire operational +state of the UART block. + +I'd love any comments/suggestions on this! + +Cheers, + +David + +--- a/drivers/tty/serial/8250/8250_core.c ++++ b/drivers/tty/serial/8250/8250_core.c +@@ -134,6 +134,38 @@ static irqreturn_t serial8250_interrupt( + + if (l == i->head && pass_counter++ > PASS_LIMIT) + break; ++ ++#ifdef CONFIG_ARCH_TEGRA_2x_SOC ++ if (!handled && (port->type == PORT_TEGRA)) { ++ /* ++ * Fix Tegra 2 CPU silicon bug where sometimes ++ * "TX holding register empty" interrupts result in a ++ * bad (metastable?) state in Tegras HSUART IP core. ++ * Only way to recover seems to be to reset all ++ * interrupts as well as the TX queue and the MCR. ++ * But we don't want to loose any outgoing characters, ++ * so only do it if the RX and TX queues are empty. ++ */ ++ unsigned char lsr = port->serial_in(port, UART_LSR); ++ const unsigned char fifo_empty_mask = ++ (UART_LSR_TEMT | UART_LSR_THRE); ++ if (((lsr & (UART_LSR_DR | fifo_empty_mask)) == ++ fifo_empty_mask)) { ++ port->serial_out(port, UART_IER, 0); ++ port->serial_out(port, UART_MCR, 0); ++ serial8250_clear_and_reinit_fifos(up); ++ port->serial_out(port, UART_MCR, up->mcr); ++ port->serial_out(port, UART_IER, up->ier); ++ // clear interrupts ++ serial_port_in(port, UART_LSR); ++ serial_port_in(port, UART_RX); ++ serial_port_in(port, UART_IIR); ++ serial_port_in(port, UART_MSR); ++ up->lsr_saved_flags = 0; ++ up->msr_saved_flags = 0; ++ } ++ } ++#endif + } while (l != end); + + spin_unlock(&i->lock); diff --git a/target/linux/tegra/patches-5.15/101-ARM-dtc-tegra-enable-front-panel-leds-in-TrimSlice.patch b/target/linux/tegra/patches-5.15/101-ARM-dtc-tegra-enable-front-panel-leds-in-TrimSlice.patch new file mode 100644 index 0000000000..b1e210b212 --- /dev/null +++ b/target/linux/tegra/patches-5.15/101-ARM-dtc-tegra-enable-front-panel-leds-in-TrimSlice.patch @@ -0,0 +1,46 @@ +--- a/arch/arm/boot/dts/tegra20-trimslice.dts ++++ b/arch/arm/boot/dts/tegra20-trimslice.dts +@@ -201,16 +201,17 @@ + conf_ata { + nvidia,pins = "ata", "atc", "atd", "ate", + "crtp", "dap2", "dap3", "dap4", "dta", +- "dtb", "dtc", "dtd", "dte", "gmb", +- "gme", "i2cp", "pta", "slxc", "slxd", +- "spdi", "spdo", "uda"; ++ "dtb", "dtc", "dtd", "gmb", "gme", ++ "i2cp", "pta", "slxc", "slxd", "spdi", ++ "spdo", "uda"; + nvidia,pull = ; + nvidia,tristate = ; + }; + conf_atb { + nvidia,pins = "atb", "cdev1", "cdev2", "dap1", +- "gma", "gmc", "gmd", "gpu", "gpu7", +- "gpv", "sdio1", "slxa", "slxk", "uac"; ++ "dte", "gma", "gmc", "gmd", "gpu", ++ "gpu7", "gpv", "sdio1", "slxa", "slxk", ++ "uac"; + nvidia,pull = ; + nvidia,tristate = ; + }; +@@ -396,6 +397,20 @@ + }; + }; + ++ gpio-leds { ++ compatible = "gpio-leds"; ++ ++ ds2 { ++ label = "trimslice:green:right"; ++ gpios = <&gpio TEGRA_GPIO(D, 2) GPIO_ACTIVE_LOW>; ++ }; ++ ++ ds3 { ++ label = "trimslice:green:left"; ++ gpios = <&gpio TEGRA_GPIO(BB, 5) GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ + poweroff { + compatible = "gpio-poweroff"; + gpios = <&gpio TEGRA_GPIO(X, 7) GPIO_ACTIVE_LOW>; From df59c07fe9e32bd5124871daa400a8c5e2e8d96f Mon Sep 17 00:00:00 2001 From: Tomasz Maciej Nowak Date: Tue, 13 Sep 2022 22:38:09 +0200 Subject: [PATCH 104/114] tegra: add kernel 5.15 support - refresh config - disable suspend as it's pointless in the sope of OpenWrt - enable CPU frequency scaling Signed-off-by: Tomasz Maciej Nowak --- target/linux/tegra/Makefile | 1 + target/linux/tegra/config-5.15 | 62 +++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/target/linux/tegra/Makefile b/target/linux/tegra/Makefile index 76dfeab402..51019607f2 100644 --- a/target/linux/tegra/Makefile +++ b/target/linux/tegra/Makefile @@ -12,6 +12,7 @@ CPU_TYPE := cortex-a9 CPU_SUBTYPE := vfpv3-d16 KERNEL_PATCHVER := 5.10 +KERNEL_TESTING_PATCHVER := 5.15 include $(INCLUDE_DIR)/target.mk diff --git a/target/linux/tegra/config-5.15 b/target/linux/tegra/config-5.15 index 8d808595d9..794fa8b714 100644 --- a/target/linux/tegra/config-5.15 +++ b/target/linux/tegra/config-5.15 @@ -36,6 +36,8 @@ CONFIG_ARM_PATCH_IDIV=y CONFIG_ARM_PATCH_PHYS_VIRT=y # CONFIG_ARM_PL172_MPMC is not set # CONFIG_ARM_SMMU is not set +# CONFIG_ARM_TEGRA124_CPUFREQ is not set +CONFIG_ARM_TEGRA20_CPUFREQ=y CONFIG_ARM_TEGRA_CPUIDLE=y CONFIG_ARM_THUMB=y CONFIG_ARM_THUMBEE=y @@ -47,13 +49,12 @@ CONFIG_ATAGS=y CONFIG_AUTO_ZRELADDR=y CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK=y CONFIG_BLK_DEV_BSG=y +CONFIG_BLK_DEV_BSG_COMMON=y CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_MQ_PCI=y CONFIG_BLK_PM=y -CONFIG_BLK_SCSI_REQUEST=y CONFIG_BOUNCE=y CONFIG_CACHE_L2X0=y -CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKSRC_MMIO=y CONFIG_CLONE_BACKWARDS=y CONFIG_CLZ_TAB=y @@ -67,10 +68,12 @@ CONFIG_CMA_SIZE_MBYTES=16 CONFIG_CMA_SIZE_SEL_MBYTES=y # CONFIG_CMA_SIZE_SEL_MIN is not set # CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set +# CONFIG_CMA_SYSFS is not set CONFIG_COMMON_CLK=y CONFIG_COMPAT_32BIT_TIME=y CONFIG_CONTIG_ALLOC=y -# CONFIG_CPUFREQ_DT is not set +CONFIG_CPUFREQ_DT=y +CONFIG_CPUFREQ_DT_PLATDEV=y CONFIG_CPU_32v6K=y CONFIG_CPU_32v7=y CONFIG_CPU_ABRT_EV7=y @@ -105,11 +108,7 @@ CONFIG_CRC16=y # CONFIG_CRC32_SARWATE is not set CONFIG_CRC32_SLICEBY8=y CONFIG_CROSS_MEMORY_ATTACH=y -CONFIG_CRYPTO_ACOMP2=y CONFIG_CRYPTO_AES_ARM=y -CONFIG_CRYPTO_AKCIPHER=y -CONFIG_CRYPTO_AKCIPHER2=y -CONFIG_CRYPTO_BLAKE2S=y CONFIG_CRYPTO_CRC32=y CONFIG_CRYPTO_CRC32C=y CONFIG_CRYPTO_CRYPTD=y @@ -125,7 +124,6 @@ CONFIG_CRYPTO_LIB_SHA256=y CONFIG_CRYPTO_LZ4=y CONFIG_CRYPTO_LZ4HC=y CONFIG_CRYPTO_LZO=y -CONFIG_CRYPTO_NULL=y CONFIG_CRYPTO_RNG=y CONFIG_CRYPTO_RNG2=y CONFIG_CRYPTO_RNG_DEFAULT=y @@ -135,12 +133,19 @@ CONFIG_CRYPTO_SHA1=y CONFIG_CRYPTO_SHA1_ARM=y CONFIG_CRYPTO_SHA256=y CONFIG_CRYPTO_SHA256_ARM=y +CONFIG_CRYPTO_SHA512=y CONFIG_CRYPTO_SHA512_ARM=y CONFIG_CRYPTO_TWOFISH=y CONFIG_CRYPTO_TWOFISH_COMMON=y CONFIG_DCACHE_WORD_ACCESS=y CONFIG_DEBUG_ALIGN_RODATA=y CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S" +# CONFIG_DEVFREQ_GOV_PASSIVE is not set +# CONFIG_DEVFREQ_GOV_PERFORMANCE is not set +# CONFIG_DEVFREQ_GOV_POWERSAVE is not set +CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y +# CONFIG_DEVFREQ_GOV_USERSPACE is not set +CONFIG_DEVFREQ_THERMAL=y # CONFIG_DEVPORT is not set CONFIG_DMADEVICES=y CONFIG_DMA_CMA=y @@ -154,7 +159,6 @@ CONFIG_DRM=y CONFIG_DRM_BRIDGE=y CONFIG_DRM_FBDEV_EMULATION=y CONFIG_DRM_FBDEV_OVERALLOC=100 -CONFIG_DRM_KMS_FB_HELPER=y CONFIG_DRM_KMS_HELPER=y CONFIG_DRM_MIPI_DSI=y CONFIG_DRM_PANEL=y @@ -166,7 +170,6 @@ CONFIG_DRM_TEGRA=y CONFIG_DTC=y CONFIG_EDAC_ATOMIC_SCRUB=y CONFIG_EDAC_SUPPORT=y -CONFIG_ENABLE_MUST_CHECK=y CONFIG_EXT4_FS=y CONFIG_EXTCON=y CONFIG_F2FS_FS=y @@ -181,10 +184,8 @@ CONFIG_FB_SYS_FILLRECT=y CONFIG_FB_SYS_FOPS=y CONFIG_FB_SYS_IMAGEBLIT=y CONFIG_FIX_EARLYCON_MEM=y -CONFIG_FREEZER=y CONFIG_FS_IOMAP=y CONFIG_FS_MBCACHE=y -# CONFIG_FW_CACHE is not set CONFIG_FW_LOADER_PAGED_BUF=y CONFIG_GENERIC_ALLOCATOR=y CONFIG_GENERIC_ARCH_TOPOLOGY=y @@ -192,6 +193,7 @@ CONFIG_GENERIC_BUG=y CONFIG_GENERIC_CLOCKEVENTS=y CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_CPU_VULNERABILITIES=y CONFIG_GENERIC_EARLY_IOREMAP=y CONFIG_GENERIC_GETTIMEOFDAY=y CONFIG_GENERIC_IDLE_POLL_SETUP=y @@ -200,6 +202,7 @@ CONFIG_GENERIC_IRQ_MIGRATION=y CONFIG_GENERIC_IRQ_MULTI_HANDLER=y CONFIG_GENERIC_IRQ_SHOW=y CONFIG_GENERIC_IRQ_SHOW_LEVEL=y +CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED=y CONFIG_GENERIC_MSI_IRQ=y CONFIG_GENERIC_MSI_IRQ_DOMAIN=y CONFIG_GENERIC_PCI_IOMAP=y @@ -214,6 +217,8 @@ CONFIG_GENERIC_STRNLEN_USER=y CONFIG_GENERIC_TIME_VSYSCALL=y CONFIG_GENERIC_VDSO_32=y CONFIG_GLOB=y +CONFIG_GPIOLIB_IRQCHIP=y +CONFIG_GPIO_CDEV=y CONFIG_GPIO_TEGRA=y CONFIG_HANDLE_DOMAIN_IRQ=y CONFIG_HARDEN_BRANCH_PREDICTOR=y @@ -240,8 +245,11 @@ CONFIG_I2C_TEGRA=y CONFIG_INITRAMFS_SOURCE="" CONFIG_INPUT=y CONFIG_INPUT_KEYBOARD=y +CONFIG_INTERCONNECT=y CONFIG_IOMMU_API=y # CONFIG_IOMMU_DEBUGFS is not set +# CONFIG_IOMMU_DEFAULT_DMA_LAZY is not set +CONFIG_IOMMU_DEFAULT_DMA_STRICT=y # CONFIG_IOMMU_DEFAULT_PASSTHROUGH is not set CONFIG_IOMMU_IOVA=y # CONFIG_IOMMU_IO_PGTABLE_ARMV7S is not set @@ -255,6 +263,8 @@ CONFIG_IRQ_WORK=y CONFIG_JBD2=y CONFIG_KCMP=y CONFIG_KEYBOARD_ATKBD=y +CONFIG_KMAP_LOCAL=y +CONFIG_KMAP_LOCAL_NON_LINEAR_PTE_ARRAY=y CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOCK_SPIN_ON_OWNER=y @@ -266,6 +276,7 @@ CONFIG_LZO_DECOMPRESS=y CONFIG_MEMFD_CREATE=y CONFIG_MEMORY=y CONFIG_MEMORY_ISOLATION=y +# CONFIG_MFD_ACER_A500_EC is not set # CONFIG_MFD_NVEC is not set CONFIG_MIGHT_HAVE_CACHE_L2X0=y CONFIG_MIGRATION=y @@ -296,7 +307,6 @@ CONFIG_OF_GPIO=y CONFIG_OF_IOMMU=y CONFIG_OF_IRQ=y CONFIG_OF_KOBJ=y -CONFIG_OF_NET=y CONFIG_OLD_SIGACTION=y CONFIG_OLD_SIGSUSPEND3=y CONFIG_OUTER_CACHE=y @@ -315,7 +325,6 @@ CONFIG_PCIE_PME=y CONFIG_PCI_DOMAINS=y CONFIG_PCI_DOMAINS_GENERIC=y CONFIG_PCI_MSI=y -CONFIG_PCI_MSI_ARCH_FALLBACKS=y CONFIG_PCI_MSI_IRQ_DOMAIN=y CONFIG_PCI_TEGRA=y CONFIG_PERF_USE_VMALLOC=y @@ -330,13 +339,16 @@ CONFIG_PL310_ERRATA_769419=y CONFIG_PL353_SMC=y CONFIG_PM=y CONFIG_PM_CLK=y +CONFIG_PM_DEVFREQ=y +# CONFIG_PM_DEVFREQ_EVENT is not set +CONFIG_PM_GENERIC_DOMAINS=y +CONFIG_PM_GENERIC_DOMAINS_OF=y CONFIG_PM_OPP=y -CONFIG_PM_SLEEP=y -CONFIG_PM_SLEEP_SMP=y CONFIG_POWER_RESET=y CONFIG_POWER_RESET_GPIO=y CONFIG_POWER_SUPPLY=y CONFIG_PROC_PAGE_MONITOR=y +CONFIG_PTP_1588_CLOCK_OPTIONAL=y CONFIG_PWM=y CONFIG_PWM_SYSFS=y CONFIG_PWM_TEGRA=y @@ -353,12 +365,13 @@ CONFIG_RESET_CONTROLLER=y CONFIG_RFS_ACCEL=y CONFIG_RPS=y CONFIG_RTC_CLASS=y +# CONFIG_RTC_DRV_CMOS is not set CONFIG_RTC_DRV_TEGRA=y CONFIG_RTC_I2C_AND_SPI=y -CONFIG_RTC_MC146818_LIB=y CONFIG_RTC_NVMEM=y CONFIG_RWSEM_SPIN_ON_OWNER=y CONFIG_SCSI=y +CONFIG_SCSI_COMMON=y # CONFIG_SCSI_LOWLEVEL is not set # CONFIG_SCSI_PROC_FS is not set CONFIG_SERIAL_8250_FSL=y @@ -401,6 +414,7 @@ CONFIG_SND_SOC_TEGRA20_SPDIF=y # CONFIG_SND_SOC_TEGRA30_AHUB is not set # CONFIG_SND_SOC_TEGRA30_I2S is not set # CONFIG_SND_SOC_TEGRA_ALC5632 is not set +CONFIG_SND_SOC_TEGRA_MACHINE_DRV=y # CONFIG_SND_SOC_TEGRA_MAX98090 is not set # CONFIG_SND_SOC_TEGRA_RT5640 is not set # CONFIG_SND_SOC_TEGRA_RT5677 is not set @@ -412,6 +426,7 @@ CONFIG_SND_SOC_TEGRA_TRIMSLICE=y CONFIG_SND_SOC_TLV320AIC23=y CONFIG_SND_SOC_TLV320AIC23_I2C=y # CONFIG_SND_USB is not set +CONFIG_SOCK_RX_QUEUE_MAPPING=y CONFIG_SOC_BUS=y CONFIG_SOC_TEGRA20_VOLTAGE_COUPLER=y CONFIG_SOC_TEGRA_FLOWCTRL=y @@ -427,9 +442,8 @@ CONFIG_SPI_MEM=y # CONFIG_SPI_TEGRA114 is not set CONFIG_SPI_TEGRA20_SFLASH=y CONFIG_SPI_TEGRA20_SLINK=y +# CONFIG_SPI_TEGRA210_QUAD is not set CONFIG_SRCU=y -CONFIG_SUSPEND=y -CONFIG_SUSPEND_FREEZER=y CONFIG_SWP_EMULATE=y CONFIG_SYNC_FILE=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y @@ -456,24 +470,32 @@ CONFIG_TREE_SRCU=y CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" CONFIG_UNWINDER_ARM=y CONFIG_USB=y +CONFIG_USB_CHIPIDEA=y +CONFIG_USB_CHIPIDEA_HOST=y +CONFIG_USB_CHIPIDEA_TEGRA=y +CONFIG_USB_CHIPIDEA_UDC=y CONFIG_USB_COMMON=y CONFIG_USB_CONN_GPIO=y CONFIG_USB_EHCI_HCD=y # CONFIG_USB_EHCI_HCD_PLATFORM is not set CONFIG_USB_EHCI_TEGRA=y +CONFIG_USB_GADGET=y CONFIG_USB_HID=y CONFIG_USB_HIDDEV=y CONFIG_USB_PHY=y CONFIG_USB_ROLE_SWITCH=y CONFIG_USB_SUPPORT=y CONFIG_USB_TEGRA_PHY=y +# CONFIG_USB_TEGRA_XUDC is not set CONFIG_USB_ULPI=y +CONFIG_USB_ULPI_BUS=y CONFIG_USB_ULPI_VIEWPORT=y +# CONFIG_USB_XHCI_TEGRA is not set CONFIG_USE_OF=y CONFIG_VFP=y CONFIG_VFPv3=y CONFIG_WATCHDOG_CORE=y -# CONFIG_USB_XHCI_TEGRA is not set +# CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set CONFIG_XPS=y CONFIG_XZ_DEC_ARM=y CONFIG_XZ_DEC_ARMTHUMB=y From 00643b4584e73949de05ca8c3276a05657ba0d45 Mon Sep 17 00:00:00 2001 From: Wojciech Dubowik Date: Wed, 14 Sep 2022 12:12:06 +0200 Subject: [PATCH 105/114] mpc85xx: Copy over kernel 5.10 patches and config to 5.15 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split patches for better change visibility. Signed-off-by: Wojciech Dubowik Signed-off-by: Petr Štetiar [un-dmarc, commit description] --- target/linux/mpc85xx/config-5.15 | 276 ++++++++++++++++++ ...85xx-add-gpio-keys-to-of-match-table.patch | 10 + ...0-powerpc-85xx-tl-wdr4900-v1-support.patch | 91 ++++++ .../101-powerpc-85xx-hiveap-330-support.patch | 30 ++ .../102-powerpc-add-cmdline-override.patch | 41 +++ .../103-powerpc-85xx-red-15w-rev1.patch | 33 +++ ...change-P2020RDB-dts-file-for-OpenWRT.patch | 170 +++++++++++ .../105-powerpc-85xx-panda-support.patch | 30 ++ .../106-powerpc-85xx-ws-ap3710i-support.patch | 30 ++ ...-powerpc-85xx-add-ws-ap3825i-support.patch | 37 +++ ...-support-for-IRQ_TYPE_LEVEL_LOW-flow.patch | 39 +++ ...ootwrapper-disable-uImage-generation.patch | 44 +++ 12 files changed, 831 insertions(+) create mode 100644 target/linux/mpc85xx/config-5.15 create mode 100644 target/linux/mpc85xx/patches-5.15/001-powerpc-85xx-add-gpio-keys-to-of-match-table.patch create mode 100644 target/linux/mpc85xx/patches-5.15/100-powerpc-85xx-tl-wdr4900-v1-support.patch create mode 100644 target/linux/mpc85xx/patches-5.15/101-powerpc-85xx-hiveap-330-support.patch create mode 100644 target/linux/mpc85xx/patches-5.15/102-powerpc-add-cmdline-override.patch create mode 100644 target/linux/mpc85xx/patches-5.15/103-powerpc-85xx-red-15w-rev1.patch create mode 100644 target/linux/mpc85xx/patches-5.15/104-powerpc-mpc85xx-change-P2020RDB-dts-file-for-OpenWRT.patch create mode 100644 target/linux/mpc85xx/patches-5.15/105-powerpc-85xx-panda-support.patch create mode 100644 target/linux/mpc85xx/patches-5.15/106-powerpc-85xx-ws-ap3710i-support.patch create mode 100644 target/linux/mpc85xx/patches-5.15/107-powerpc-85xx-add-ws-ap3825i-support.patch create mode 100644 target/linux/mpc85xx/patches-5.15/110-gpio-mpc8xxx-Fix-support-for-IRQ_TYPE_LEVEL_LOW-flow.patch create mode 100644 target/linux/mpc85xx/patches-5.15/900-powerpc-bootwrapper-disable-uImage-generation.patch diff --git a/target/linux/mpc85xx/config-5.15 b/target/linux/mpc85xx/config-5.15 new file mode 100644 index 0000000000..532d176c15 --- /dev/null +++ b/target/linux/mpc85xx/config-5.15 @@ -0,0 +1,276 @@ +# CONFIG_40x is not set +# CONFIG_44x is not set +# CONFIG_ADVANCED_OPTIONS is not set +CONFIG_AR8216_PHY=y +CONFIG_AR8216_PHY_LEDS=y +CONFIG_ARCH_32BIT_OFF_T=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_KEEP_MEMBLOCK=y +CONFIG_ARCH_MAY_HAVE_PC_FDC=y +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y +CONFIG_ARCH_MMAP_RND_BITS=11 +CONFIG_ARCH_MMAP_RND_BITS_MAX=17 +CONFIG_ARCH_MMAP_RND_BITS_MIN=11 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=17 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=11 +CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ARCH_WEAK_RELEASE_ACQUIRE=y +CONFIG_ASN1=y +CONFIG_AUDIT_ARCH=y +CONFIG_BLK_MQ_PCI=y +CONFIG_BOOKE=y +CONFIG_BOOKE_WDT=y +# CONFIG_BSC9131_RDB is not set +# CONFIG_BSC9132_QDS is not set +# CONFIG_C293_PCIE is not set +CONFIG_CLONE_BACKWARDS=y +CONFIG_CLZ_TAB=y +CONFIG_CMDLINE="console=ttyS0,115200" +CONFIG_CMDLINE_FROM_BOOTLOADER=y +# CONFIG_CMDLINE_OVERRIDE is not set +# CONFIG_COMMON_CLK is not set +CONFIG_COMPAT_32BIT_TIME=y +# CONFIG_CORENET_GENERIC is not set +# CONFIG_CPM2 is not set +CONFIG_CPU_BIG_ENDIAN=y +# CONFIG_CRYPTO_AES_PPC_SPE is not set +CONFIG_CRYPTO_AKCIPHER=y +CONFIG_CRYPTO_AKCIPHER2=y +CONFIG_CRYPTO_AUTHENC=y +CONFIG_CRYPTO_BLAKE2S=y +CONFIG_CRYPTO_HW=y +CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y +CONFIG_CRYPTO_LIB_POLY1305_RSIZE=1 +# CONFIG_CRYPTO_MD5_PPC is not set +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_RSA=y +# CONFIG_CRYPTO_SHA1_PPC is not set +# CONFIG_CRYPTO_SHA1_PPC_SPE is not set +# CONFIG_CRYPTO_SHA256_PPC_SPE is not set +CONFIG_DATA_SHIFT=12 +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DNOTIFY=y +CONFIG_DTC=y +# CONFIG_E200 is not set +CONFIG_E500=y +# CONFIG_E5500_CPU is not set +# CONFIG_E6500_CPU is not set +CONFIG_EARLY_PRINTK=y +CONFIG_EDAC=y +CONFIG_EDAC_ATOMIC_SCRUB=y +# CONFIG_EDAC_DEBUG is not set +CONFIG_EDAC_LEGACY_SYSFS=y +CONFIG_EDAC_MPC85XX=y +CONFIG_EDAC_SUPPORT=y +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_ETHERNET_PACKET_MANGLE=y +CONFIG_FIXED_PHY=y +CONFIG_FSL_BOOKE=y +CONFIG_FSL_EMB_PERFMON=y +# CONFIG_FSL_FMAN is not set +CONFIG_FSL_LBC=y +CONFIG_FSL_PCI=y +CONFIG_FSL_PQ_MDIO=y +CONFIG_FSL_SOC=y +CONFIG_FSL_SOC_BOOKE=y +CONFIG_FW_LOADER_PAGED_BUF=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_GENERIC_ATOMIC64=y +CONFIG_GENERIC_BUG=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CMOS_UPDATE=y +CONFIG_GENERIC_CPU=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_CPU_VULNERABILITIES=y +CONFIG_GENERIC_EARLY_IOREMAP=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_IRQ_SHOW_LEVEL=y +CONFIG_GENERIC_ISA_DMA=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GEN_RTC=y +# CONFIG_GE_IMP3A is not set +CONFIG_GIANFAR=y +CONFIG_GPIO_GENERIC=y +CONFIG_GPIO_MPC8XXX=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +# CONFIG_HIVEAP_330 is not set +CONFIG_HW_RANDOM=y +# CONFIG_HW_RANDOM_XIPHERA is not set +CONFIG_HZ_PERIODIC=y +CONFIG_I2C=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_MPC=y +CONFIG_ILLEGAL_POINTER_VALUE=0 +CONFIG_INITRAMFS_SOURCE="" +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_WORK=y +CONFIG_ISA_DMA_API=y +CONFIG_KERNEL_START=0xc0000000 +# CONFIG_KSI8560 is not set +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=256 +CONFIG_LIBFDT=y +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_LOWMEM_CAM_NUM=3 +CONFIG_LOWMEM_SIZE=0x30000000 +CONFIG_LXT_PHY=y +# CONFIG_MATH_EMULATION is not set +CONFIG_MDIO_BUS=y +CONFIG_MDIO_DEVICE=y +CONFIG_MEMFD_CREATE=y +# CONFIG_MFD_ROHM_BD71828 is not set +CONFIG_MIGRATION=y +CONFIG_MMU_GATHER_PAGE_SIZE=y +CONFIG_MODULES_USE_ELF_RELA=y +# CONFIG_MPC8536_DS is not set +# CONFIG_MPC8540_ADS is not set +# CONFIG_MPC8560_ADS is not set +# CONFIG_MPC85xx_CDS is not set +# CONFIG_MPC85xx_DS is not set +# CONFIG_MPC85xx_MDS is not set +# CONFIG_MPC85xx_RDB is not set +CONFIG_MPIC=y +# CONFIG_MPIC_MSGR is not set +CONFIG_MPIC_TIMER=y +CONFIG_MPILIB=y +# CONFIG_MTD_CFI is not set +CONFIG_MTD_NAND_CORE=y +CONFIG_MTD_NAND_ECC=y +CONFIG_MTD_NAND_ECC_SW_HAMMING=y +CONFIG_MTD_RAW_NAND=y +CONFIG_MTD_SPI_NOR=y +# CONFIG_MVME2500 is not set +CONFIG_NEED_PER_CPU_KM=y +CONFIG_NEED_SG_DMA_LENGTH=y +CONFIG_NLS=y +CONFIG_NR_IRQS=512 +CONFIG_NVMEM=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_DMA_DEFAULT_COHERENT=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IRQ=y +CONFIG_OF_KOBJ=y +CONFIG_OF_MDIO=y +CONFIG_OF_NET=y +CONFIG_OLD_SIGACTION=y +CONFIG_OLD_SIGSUSPEND=y +# CONFIG_P1010_RDB is not set +# CONFIG_P1022_DS is not set +# CONFIG_P1022_RDK is not set +# CONFIG_P1023_RDB is not set +CONFIG_PAGE_OFFSET=0xc0000000 +# CONFIG_PANDA is not set +CONFIG_PCI=y +CONFIG_PCIEAER=y +CONFIG_PCIEASPM=y +CONFIG_PCIEASPM_DEFAULT=y +# CONFIG_PCIEASPM_PERFORMANCE is not set +# CONFIG_PCIEASPM_POWERSAVE is not set +# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set +CONFIG_PCIEPORTBUS=y +CONFIG_PCI_DOMAINS=y +CONFIG_PGTABLE_LEVELS=2 +CONFIG_PHYLIB=y +CONFIG_PHYSICAL_ALIGN=0x04000000 +CONFIG_PHYSICAL_START=0x00000000 +# CONFIG_PHYS_64BIT is not set +# CONFIG_PMU_SYSFS is not set +# CONFIG_PPA8548 is not set +CONFIG_PPC=y +CONFIG_PPC32=y +# CONFIG_PPC64 is not set +CONFIG_PPC_85xx=y +# CONFIG_PPC_8xx is not set +CONFIG_PPC_ADV_DEBUG_DACS=2 +CONFIG_PPC_ADV_DEBUG_DVCS=0 +CONFIG_PPC_ADV_DEBUG_IACS=2 +CONFIG_PPC_ADV_DEBUG_REGS=y +CONFIG_PPC_BARRIER_NOSPEC=y +CONFIG_PPC_BOOK3E_MMU=y +# CONFIG_PPC_BOOK3S_6xx is not set +CONFIG_PPC_DOORBELL=y +# CONFIG_PPC_E500MC is not set +# CONFIG_PPC_EARLY_DEBUG is not set +CONFIG_PPC_FSL_BOOK3E=y +CONFIG_PPC_INDIRECT_PCI=y +# CONFIG_PPC_IRQ_SOFT_MASK_DEBUG is not set +CONFIG_PPC_MMU_NOHASH=y +CONFIG_PPC_MMU_NOHASH_32=y +CONFIG_PPC_PAGE_SHIFT=12 +# CONFIG_PPC_PTDUMP is not set +# CONFIG_PPC_QEMU_E500 is not set +CONFIG_PPC_SMP_MUXED_IPI=y +CONFIG_PPC_UDBG_16550=y +CONFIG_PPC_WERROR=y +CONFIG_QE_GPIO=y +CONFIG_QUICC_ENGINE=y +CONFIG_RAS=y +# CONFIG_RED_15W_REV1 is not set +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_GENERIC=y +# CONFIG_RTC_DRV_RV3032 is not set +CONFIG_RTC_I2C_AND_SPI=y +CONFIG_RTC_MC146818_LIB=y +# CONFIG_SBC8548 is not set +# CONFIG_SCOM_DEBUGFS is not set +CONFIG_SERIAL_8250_EXTENDED=y +CONFIG_SERIAL_8250_FSL=y +CONFIG_SERIAL_8250_SHARE_IRQ=y +CONFIG_SERIAL_MCTRL_GPIO=y +CONFIG_SERIAL_OF_PLATFORM=y +# CONFIG_SERIAL_QE is not set +# CONFIG_SOCRATES is not set +CONFIG_SPARSE_IRQ=y +CONFIG_SPE=y +CONFIG_SPE_POSSIBLE=y +CONFIG_SPI=y +CONFIG_SPI_FSL_ESPI=y +CONFIG_SPI_MASTER=y +CONFIG_SPI_MEM=y +CONFIG_SRCU=y +# CONFIG_STRIP_ASM_SYMS is not set +# CONFIG_STX_GP3 is not set +CONFIG_SWCONFIG=y +CONFIG_SWPHY=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_TASK_SIZE=0xc0000000 +CONFIG_THREAD_INFO_IN_TASK=y +CONFIG_THREAD_SHIFT=13 +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TINY_SRCU=y +# CONFIG_TL_WDR4900_V1 is not set +# CONFIG_TQM8540 is not set +# CONFIG_TQM8541 is not set +# CONFIG_TQM8548 is not set +# CONFIG_TQM8555 is not set +# CONFIG_TQM8560 is not set +# CONFIG_TWR_P102x is not set +CONFIG_UCC=y +CONFIG_UCC_FAST=y +CONFIG_UCC_GETH=y +# CONFIG_UGETH_TX_ON_DEMAND is not set +CONFIG_USB_SUPPORT=y +CONFIG_VDSO32=y +# CONFIG_VIRT_CPU_ACCOUNTING_NATIVE is not set +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_WATCHDOG_CORE=y +# CONFIG_WS_AP3710I is not set +# CONFIG_WS_AP3825I is not set +# CONFIG_XES_MPC85xx is not set +CONFIG_XZ_DEC_BCJ=y +CONFIG_XZ_DEC_POWERPC=y diff --git a/target/linux/mpc85xx/patches-5.15/001-powerpc-85xx-add-gpio-keys-to-of-match-table.patch b/target/linux/mpc85xx/patches-5.15/001-powerpc-85xx-add-gpio-keys-to-of-match-table.patch new file mode 100644 index 0000000000..5e5ab10daf --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/001-powerpc-85xx-add-gpio-keys-to-of-match-table.patch @@ -0,0 +1,10 @@ +--- a/arch/powerpc/platforms/85xx/common.c ++++ b/arch/powerpc/platforms/85xx/common.c +@@ -30,6 +30,7 @@ static const struct of_device_id mpc85xx + { .compatible = "fsl,mpc8548-guts", }, + /* Probably unnecessary? */ + { .compatible = "gpio-leds", }, ++ { .compatible = "gpio-keys", }, + /* For all PCI controllers */ + { .compatible = "fsl,mpc8540-pci", }, + { .compatible = "fsl,mpc8548-pcie", }, diff --git a/target/linux/mpc85xx/patches-5.15/100-powerpc-85xx-tl-wdr4900-v1-support.patch b/target/linux/mpc85xx/patches-5.15/100-powerpc-85xx-tl-wdr4900-v1-support.patch new file mode 100644 index 0000000000..76fd6af010 --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/100-powerpc-85xx-tl-wdr4900-v1-support.patch @@ -0,0 +1,91 @@ +From 1d9f596e572917772b87a2a37e1680902964782f Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Wed, 20 Feb 2013 08:40:33 +0100 +Subject: [PATCH] powerpc: 85xx: add support for the TP-Link TL-WDR4900 v1 + board + +This patch adds support for the TP-Link TL-WDR4900 v1 +concurrent dual-band wireless router. The devices uses +the Freescale P1014 SoC. + +Signed-off-by: Gabor Juhos +Signed-off-by: Pawel Dembicki +--- + arch/powerpc/boot/Makefile | 3 ++- + arch/powerpc/boot/wrapper | 5 +++++ + arch/powerpc/platforms/85xx/Kconfig | 12 ++++++++++++ + arch/powerpc/platforms/85xx/Makefile | 1 + + 4 files changed, 20 insertions(+), 1 deletion(-) + +Index: linux-5.15.67/arch/powerpc/boot/Makefile +=================================================================== +--- linux-5.15.67.orig/arch/powerpc/boot/Makefile ++++ linux-5.15.67/arch/powerpc/boot/Makefile +@@ -162,6 +162,7 @@ src-plat-$(CONFIG_PPC_PSERIES) += pserie + src-plat-$(CONFIG_PPC_POWERNV) += pseries-head.S + src-plat-$(CONFIG_PPC_IBM_CELL_BLADE) += pseries-head.S + src-plat-$(CONFIG_MVME7100) += motload-head.S mvme7100.c ++src-plat-$(CONFIG_TL_WDR4900_V1) += simpleboot.c fixed-head.S + + src-plat-$(CONFIG_PPC_MICROWATT) += fixed-head.S microwatt.c + +@@ -342,7 +343,7 @@ image-$(CONFIG_TQM8548) += cuImage.tqm + image-$(CONFIG_TQM8555) += cuImage.tqm8555 + image-$(CONFIG_TQM8560) += cuImage.tqm8560 + image-$(CONFIG_KSI8560) += cuImage.ksi8560 +- ++image-$(CONFIG_TL_WDR4900_V1) += simpleImage.tl-wdr4900-v1 + # Board ports in arch/powerpc/platform/86xx/Kconfig + image-$(CONFIG_MVME7100) += dtbImage.mvme7100 + +Index: linux-5.15.67/arch/powerpc/boot/wrapper +=================================================================== +--- linux-5.15.67.orig/arch/powerpc/boot/wrapper ++++ linux-5.15.67/arch/powerpc/boot/wrapper +@@ -326,6 +326,11 @@ adder875-redboot) + platformo="$object/fixed-head.o $object/redboot-8xx.o" + binary=y + ;; ++simpleboot-tl-wdr4900-v1) ++ platformo="$object/fixed-head.o $object/simpleboot.o" ++ link_address='0x1000000' ++ binary=y ++ ;; + simpleboot-*) + platformo="$object/fixed-head.o $object/simpleboot.o" + binary=y +Index: linux-5.15.67/arch/powerpc/platforms/85xx/Kconfig +=================================================================== +--- linux-5.15.67.orig/arch/powerpc/platforms/85xx/Kconfig ++++ linux-5.15.67/arch/powerpc/platforms/85xx/Kconfig +@@ -170,6 +170,18 @@ config STX_GP3 + select CPM2 + select DEFAULT_UIMAGE + ++config TL_WDR4900_V1 ++ bool "TP-Link TL-WDR4900 v1" ++ select DEFAULT_UIMAGE ++ select ARCH_REQUIRE_GPIOLIB ++ select GPIO_MPC8XXX ++ select SWIOTLB ++ help ++ This option enables support for the TP-Link TL-WDR4900 v1 board. ++ ++ This board is a Concurrent Dual-Band wireless router with a ++ Freescale P1014 SoC. ++ + config TQM8540 + bool "TQ Components TQM8540" + help +Index: linux-5.15.67/arch/powerpc/platforms/85xx/Makefile +=================================================================== +--- linux-5.15.67.orig/arch/powerpc/platforms/85xx/Makefile ++++ linux-5.15.67/arch/powerpc/platforms/85xx/Makefile +@@ -27,6 +27,7 @@ obj-$(CONFIG_TWR_P102x) += twr_p102x.o + obj-$(CONFIG_CORENET_GENERIC) += corenet_generic.o + obj-$(CONFIG_FB_FSL_DIU) += t1042rdb_diu.o + obj-$(CONFIG_STX_GP3) += stx_gp3.o ++obj-$(CONFIG_TL_WDR4900_V1) += tl_wdr4900_v1.o + obj-$(CONFIG_TQM85xx) += tqm85xx.o + obj-$(CONFIG_PPA8548) += ppa8548.o + obj-$(CONFIG_SOCRATES) += socrates.o socrates_fpga_pic.o diff --git a/target/linux/mpc85xx/patches-5.15/101-powerpc-85xx-hiveap-330-support.patch b/target/linux/mpc85xx/patches-5.15/101-powerpc-85xx-hiveap-330-support.patch new file mode 100644 index 0000000000..da95cd2716 --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/101-powerpc-85xx-hiveap-330-support.patch @@ -0,0 +1,30 @@ +--- a/arch/powerpc/platforms/85xx/Kconfig ++++ b/arch/powerpc/platforms/85xx/Kconfig +@@ -49,6 +49,17 @@ config BSC9132_QDS + and dual StarCore SC3850 DSP cores. + Manufacturer : Freescale Semiconductor, Inc + ++config HIVEAP_330 ++ bool "Aerohive HiveAP-330" ++ select DEFAULT_UIMAGE ++ select ARCH_REQUIRE_GPIOLIB ++ select GPIO_MPC8XXX ++ help ++ This option enables support for the Aerohive HiveAP-330 board. ++ ++ This board is a Concurrent Dual-Band wireless access point with a ++ Freescale P1020 SoC. ++ + config MPC8540_ADS + bool "Freescale MPC8540 ADS" + select DEFAULT_UIMAGE +--- a/arch/powerpc/platforms/85xx/Makefile ++++ b/arch/powerpc/platforms/85xx/Makefile +@@ -12,6 +12,7 @@ obj-y += common.o + obj-$(CONFIG_BSC9131_RDB) += bsc913x_rdb.o + obj-$(CONFIG_BSC9132_QDS) += bsc913x_qds.o + obj-$(CONFIG_C293_PCIE) += c293pcie.o ++obj-$(CONFIG_HIVEAP_330) += hiveap-330.o + obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o + obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o + obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o diff --git a/target/linux/mpc85xx/patches-5.15/102-powerpc-add-cmdline-override.patch b/target/linux/mpc85xx/patches-5.15/102-powerpc-add-cmdline-override.patch new file mode 100644 index 0000000000..c8803d8428 --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/102-powerpc-add-cmdline-override.patch @@ -0,0 +1,41 @@ +Index: linux-5.15.67/arch/powerpc/Kconfig +=================================================================== +--- linux-5.15.67.orig/arch/powerpc/Kconfig ++++ linux-5.15.67/arch/powerpc/Kconfig +@@ -915,6 +915,14 @@ config CMDLINE_FORCE + + endchoice + ++config CMDLINE_OVERRIDE ++ bool "Use alternative cmdline from device tree" ++ help ++ Some bootloaders may have uneditable bootargs. While CMDLINE_FORCE can ++ be used, this is not a good option for kernels that are shared across ++ devices. This setting enables using "chosen/cmdline-override" as the ++ cmdline if it exists in the device tree. ++ + config EXTRA_TARGETS + string "Additional default image types" + help +Index: linux-5.15.67/drivers/of/fdt.c +=================================================================== +--- linux-5.15.67.orig/drivers/of/fdt.c ++++ linux-5.15.67/drivers/of/fdt.c +@@ -1162,6 +1162,17 @@ int __init early_init_dt_scan_chosen(uns + if (p != NULL && l > 0) + strlcat(data, p, min_t(int, strlen(data) + (int)l, COMMAND_LINE_SIZE)); + ++ /* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different ++ * device tree option of chosen/bootargs-override. This is ++ * helpful on boards where u-boot sets bootargs, and is unable ++ * to be modified. ++ */ ++#ifdef CONFIG_CMDLINE_OVERRIDE ++ p = of_get_flat_dt_prop(node, "bootargs-override", &l); ++ if (p != NULL && l > 0) ++ strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE)); ++#endif ++ + /* + * CONFIG_CMDLINE is meant to be a default in case nothing else + * managed to set the command line, unless CONFIG_CMDLINE_FORCE diff --git a/target/linux/mpc85xx/patches-5.15/103-powerpc-85xx-red-15w-rev1.patch b/target/linux/mpc85xx/patches-5.15/103-powerpc-85xx-red-15w-rev1.patch new file mode 100644 index 0000000000..574d16d96c --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/103-powerpc-85xx-red-15w-rev1.patch @@ -0,0 +1,33 @@ +Index: linux-5.15.67/arch/powerpc/platforms/85xx/Kconfig +=================================================================== +--- linux-5.15.67.orig/arch/powerpc/platforms/85xx/Kconfig ++++ linux-5.15.67/arch/powerpc/platforms/85xx/Kconfig +@@ -173,6 +173,16 @@ config XES_MPC85xx + Manufacturer: Extreme Engineering Solutions, Inc. + URL: + ++config RED_15W_REV1 ++ bool "Sophos RED 15w Rev.1" ++ select DEFAULT_UIMAGE ++ select ARCH_REQUIRE_GPIOLIB ++ select GPIO_MPC8XXX ++ help ++ This option enables support for the Sophos RED 15w Rev.1 board. ++ ++ This board is a wireless VPN router with a Freescale P1010 SoC. ++ + config STX_GP3 + bool "Silicon Turnkey Express GP3" + help +Index: linux-5.15.67/arch/powerpc/platforms/85xx/Makefile +=================================================================== +--- linux-5.15.67.orig/arch/powerpc/platforms/85xx/Makefile ++++ linux-5.15.67/arch/powerpc/platforms/85xx/Makefile +@@ -27,6 +27,7 @@ obj-$(CONFIG_P1023_RDB) += p1023_rdb.o + obj-$(CONFIG_TWR_P102x) += twr_p102x.o + obj-$(CONFIG_CORENET_GENERIC) += corenet_generic.o + obj-$(CONFIG_FB_FSL_DIU) += t1042rdb_diu.o ++obj-$(CONFIG_RED_15W_REV1) += red15w_rev1.o + obj-$(CONFIG_STX_GP3) += stx_gp3.o + obj-$(CONFIG_TL_WDR4900_V1) += tl_wdr4900_v1.o + obj-$(CONFIG_TQM85xx) += tqm85xx.o diff --git a/target/linux/mpc85xx/patches-5.15/104-powerpc-mpc85xx-change-P2020RDB-dts-file-for-OpenWRT.patch b/target/linux/mpc85xx/patches-5.15/104-powerpc-mpc85xx-change-P2020RDB-dts-file-for-OpenWRT.patch new file mode 100644 index 0000000000..94ed26c3df --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/104-powerpc-mpc85xx-change-P2020RDB-dts-file-for-OpenWRT.patch @@ -0,0 +1,170 @@ +From 93514afd769c305182beeed1f9c4c46235879ef8 Mon Sep 17 00:00:00 2001 +From: Pawel Dembicki +Date: Sun, 30 Dec 2018 23:24:41 +0100 +Subject: [PATCH] powerpc: mpc85xx: change P2020RDB dts file for OpenWRT + +This patch apply chages for OpenWRT in P2020RDB +dts file. + +Signed-off-by: Pawel Dembicki +--- + arch/powerpc/boot/dts/fsl/p2020rdb.dts | 98 +++++++++++++++++--------- + 1 file changed, 63 insertions(+), 35 deletions(-) + +--- a/arch/powerpc/boot/dts/fsl/p2020rdb.dts ++++ b/arch/powerpc/boot/dts/fsl/p2020rdb.dts +@@ -5,10 +5,15 @@ + * Copyright 2009-2012 Freescale Semiconductor Inc. + */ + ++/dts-v1/; ++ + /include/ "p2020si-pre.dtsi" + ++#include ++#include ++ + / { +- model = "fsl,P2020RDB"; ++ model = "Freescale P2020RDB"; + compatible = "fsl,P2020RDB"; + + aliases { +@@ -34,48 +39,38 @@ + 0x2 0x0 0x0 0xffb00000 0x00020000>; + + nor@0,0 { +- #address-cells = <1>; +- #size-cells = <1>; + compatible = "cfi-flash"; + reg = <0x0 0x0 0x1000000>; + bank-width = <2>; + device-width = <1>; + +- partition@0 { +- /* This location must not be altered */ +- /* 256KB for Vitesse 7385 Switch firmware */ +- reg = <0x0 0x00040000>; +- label = "NOR (RO) Vitesse-7385 Firmware"; +- read-only; +- }; +- +- partition@40000 { +- /* 256KB for DTB Image */ +- reg = <0x00040000 0x00040000>; +- label = "NOR (RO) DTB Image"; +- read-only; +- }; ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; + +- partition@80000 { +- /* 3.5 MB for Linux Kernel Image */ +- reg = <0x00080000 0x00380000>; +- label = "NOR (RO) Linux Kernel Image"; +- read-only; +- }; ++ partition@0 { ++ /* This location must not be altered */ ++ /* 256KB for Vitesse 7385 Switch firmware */ ++ reg = <0x0 0x00040000>; ++ label = "NOR (RO) Vitesse-7385 Firmware"; ++ read-only; ++ }; + +- partition@400000 { +- /* 11MB for JFFS2 based Root file System */ +- reg = <0x00400000 0x00b00000>; +- label = "NOR (RW) JFFS2 Root File System"; +- }; ++ partition@40000 { ++ compatible = "denx,fit"; ++ reg = <0x00040000 0x00ec0000>; ++ label = "firmware"; ++ }; + +- partition@f00000 { +- /* This location must not be altered */ +- /* 512KB for u-boot Bootloader Image */ +- /* 512KB for u-boot Environment Variables */ +- reg = <0x00f00000 0x00100000>; +- label = "NOR (RO) U-Boot Image"; +- read-only; ++ partition@f00000 { ++ /* This location must not be altered */ ++ /* 512KB for u-boot Bootloader Image */ ++ /* 512KB for u-boot Environment Variables */ ++ reg = <0x00f00000 0x00100000>; ++ label = "u-boot"; ++ read-only; ++ }; + }; + }; + +@@ -85,6 +80,7 @@ + compatible = "fsl,p2020-fcm-nand", + "fsl,elbc-fcm-nand"; + reg = <0x1 0x0 0x40000>; ++ nand-ecc-mode = "none"; + + partition@0 { + /* This location must not be altered */ +@@ -140,13 +136,43 @@ + soc: soc@ffe00000 { + ranges = <0x0 0x0 0xffe00000 0x100000>; + ++ gpio0: gpio-controller@fc00 { ++ }; ++ + i2c@3000 { ++ temperature-sensor@4c { ++ compatible = "adi,adt7461"; ++ reg = <0x4c>; ++ }; ++ ++ eeprom@50 { ++ compatible = "atmel,24c256"; ++ reg = <0x50>; ++ }; ++ + rtc@68 { + compatible = "dallas,ds1339"; + reg = <0x68>; + }; + }; + ++ i2c@3100 { ++ pmic@11 { ++ compatible = "zl2006"; ++ reg = <0x11>; ++ }; ++ ++ gpio@18 { ++ compatible = "nxp,pca9557"; ++ reg = <0x18>; ++ }; ++ ++ eeprom@52 { ++ compatible = "atmel,24c01"; ++ reg = <0x52>; ++ }; ++ }; ++ + spi@7000 { + flash@0 { + #address-cells = <1>; +@@ -200,10 +226,12 @@ + phy0: ethernet-phy@0 { + interrupts = <3 1 0 0>; + reg = <0x0>; ++ reset-gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; + }; + phy1: ethernet-phy@1 { + interrupts = <3 1 0 0>; + reg = <0x1>; ++ reset-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; + }; + tbi-phy@2 { + device_type = "tbi-phy"; diff --git a/target/linux/mpc85xx/patches-5.15/105-powerpc-85xx-panda-support.patch b/target/linux/mpc85xx/patches-5.15/105-powerpc-85xx-panda-support.patch new file mode 100644 index 0000000000..4913c614a8 --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/105-powerpc-85xx-panda-support.patch @@ -0,0 +1,30 @@ +--- a/arch/powerpc/platforms/85xx/Kconfig ++++ b/arch/powerpc/platforms/85xx/Kconfig +@@ -60,6 +60,17 @@ config HIVEAP_330 + This board is a Concurrent Dual-Band wireless access point with a + Freescale P1020 SoC. + ++config PANDA ++ bool "OCEDO PANDA" ++ select DEFAULT_UIMAGE ++ select ARCH_REQUIRE_GPIOLIB ++ select GPIO_MPC8XXX ++ help ++ This option enables support for the OCEDO PANDA board. ++ ++ This board is a Concurrent Dual-Band wireless access point with a ++ Freescale P1020 SoC. ++ + config MPC8540_ADS + bool "Freescale MPC8540 ADS" + select DEFAULT_UIMAGE +--- a/arch/powerpc/platforms/85xx/Makefile ++++ b/arch/powerpc/platforms/85xx/Makefile +@@ -24,6 +24,7 @@ obj-$(CONFIG_P1010_RDB) += p1010rdb.o + obj-$(CONFIG_P1022_DS) += p1022_ds.o + obj-$(CONFIG_P1022_RDK) += p1022_rdk.o + obj-$(CONFIG_P1023_RDB) += p1023_rdb.o ++obj-$(CONFIG_PANDA) += panda.o + obj-$(CONFIG_TWR_P102x) += twr_p102x.o + obj-$(CONFIG_CORENET_GENERIC) += corenet_generic.o + obj-$(CONFIG_FB_FSL_DIU) += t1042rdb_diu.o diff --git a/target/linux/mpc85xx/patches-5.15/106-powerpc-85xx-ws-ap3710i-support.patch b/target/linux/mpc85xx/patches-5.15/106-powerpc-85xx-ws-ap3710i-support.patch new file mode 100644 index 0000000000..124376ffd9 --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/106-powerpc-85xx-ws-ap3710i-support.patch @@ -0,0 +1,30 @@ +--- a/arch/powerpc/platforms/85xx/Kconfig ++++ b/arch/powerpc/platforms/85xx/Kconfig +@@ -71,6 +71,17 @@ config PANDA + This board is a Concurrent Dual-Band wireless access point with a + Freescale P1020 SoC. + ++config WS_AP3710I ++ bool "Enterasys WS-AP3710i" ++ select DEFAULT_UIMAGE ++ select ARCH_REQUIRE_GPIOLIB ++ select GPIO_MPC8XXX ++ help ++ This option enables support for the Enterasys WS-AP3710i board. ++ ++ This board is a Concurrent Dual-Band wireless access point with a ++ Freescale P1020 SoC. ++ + config MPC8540_ADS + bool "Freescale MPC8540 ADS" + select DEFAULT_UIMAGE +--- a/arch/powerpc/platforms/85xx/Makefile ++++ b/arch/powerpc/platforms/85xx/Makefile +@@ -26,6 +26,7 @@ obj-$(CONFIG_P1022_RDK) += p1022_rdk.o + obj-$(CONFIG_P1023_RDB) += p1023_rdb.o + obj-$(CONFIG_PANDA) += panda.o + obj-$(CONFIG_TWR_P102x) += twr_p102x.o ++obj-$(CONFIG_WS_AP3710I) += ws-ap3710i.o + obj-$(CONFIG_CORENET_GENERIC) += corenet_generic.o + obj-$(CONFIG_FB_FSL_DIU) += t1042rdb_diu.o + obj-$(CONFIG_RED_15W_REV1) += red15w_rev1.o diff --git a/target/linux/mpc85xx/patches-5.15/107-powerpc-85xx-add-ws-ap3825i-support.patch b/target/linux/mpc85xx/patches-5.15/107-powerpc-85xx-add-ws-ap3825i-support.patch new file mode 100644 index 0000000000..1829a78ec4 --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/107-powerpc-85xx-add-ws-ap3825i-support.patch @@ -0,0 +1,37 @@ +From 2fa1a7983ef30f3c7486f9b07c001bee87d1f6d6 Mon Sep 17 00:00:00 2001 +From: Martin Kennedy +Date: Sat, 1 Jan 2022 11:01:37 -0500 +Subject: [PATCH] PowerPC 85xx: Add WS-AP3825i support + +This patch adds support for building Linux for the Extreme Networks +WS-AP3825i AP. + +--- a/arch/powerpc/platforms/85xx/Kconfig ++++ b/arch/powerpc/platforms/85xx/Kconfig +@@ -82,6 +82,16 @@ config WS_AP3710I + This board is a Concurrent Dual-Band wireless access point with a + Freescale P1020 SoC. + ++config WS_AP3825I ++ bool "Extreme Networks WS-AP3825i" ++ select DEFAULT_UIMAGE ++ select ARCH_REQUIRE_GPIOLIB ++ select GPIO_MPC8XXX ++ help ++ This option enables support for the Extreme Networks WS-AP3825i board. ++ This board is a Concurrent Dual-Band wireless access point with a ++ Freescale P1020 SoC. ++ + config MPC8540_ADS + bool "Freescale MPC8540 ADS" + select DEFAULT_UIMAGE +--- a/arch/powerpc/platforms/85xx/Makefile ++++ b/arch/powerpc/platforms/85xx/Makefile +@@ -27,6 +27,7 @@ obj-$(CONFIG_P1023_RDB) += p1023_rdb.o + obj-$(CONFIG_PANDA) += panda.o + obj-$(CONFIG_TWR_P102x) += twr_p102x.o + obj-$(CONFIG_WS_AP3710I) += ws-ap3710i.o ++obj-$(CONFIG_WS_AP3825I) += ws-ap3825i.o + obj-$(CONFIG_CORENET_GENERIC) += corenet_generic.o + obj-$(CONFIG_FB_FSL_DIU) += t1042rdb_diu.o + obj-$(CONFIG_RED_15W_REV1) += red15w_rev1.o diff --git a/target/linux/mpc85xx/patches-5.15/110-gpio-mpc8xxx-Fix-support-for-IRQ_TYPE_LEVEL_LOW-flow.patch b/target/linux/mpc85xx/patches-5.15/110-gpio-mpc8xxx-Fix-support-for-IRQ_TYPE_LEVEL_LOW-flow.patch new file mode 100644 index 0000000000..0592da1763 --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/110-gpio-mpc8xxx-Fix-support-for-IRQ_TYPE_LEVEL_LOW-flow.patch @@ -0,0 +1,39 @@ +From 29af30435022442ec4eccf3166956b8e0b8a2134 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pali=20Roh=C3=A1r?= +Date: Mon, 5 Sep 2022 23:13:47 +0200 +Subject: [PATCH] gpio: mpc8xxx: Fix support for IRQ_TYPE_LEVEL_LOW flow_type + in mpc85xx +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit e39d5ef67804 ("powerpc/5xxx: extend mpc8xxx_gpio driver to support +mpc512x gpios") implemented support for IRQ_TYPE_LEVEL_LOW flow type in +mpc512x via falling edge type. Do same for mpc85xx which support was added +in commit 345e5c8a1cc3 ("powerpc: Add interrupt support to mpc8xxx_gpio"). + +Fixes probing of lm90 hwmon driver on mpc85xx based board which use level +interrupt. Without it kernel prints error and refuse lm90 to work: + + [ 15.258370] genirq: Setting trigger mode 8 for irq 49 failed (mpc8xxx_irq_set_type+0x0/0xf8) + [ 15.267168] lm90 0-004c: cannot request IRQ 49 + [ 15.272708] lm90: probe of 0-004c failed with error -22 + +Fixes: 345e5c8a1cc3 ("powerpc: Add interrupt support to mpc8xxx_gpio") +Signed-off-by: Pali Rohár +--- + drivers/gpio/gpio-mpc8xxx.c | 1 + + 1 file changed, 1 insertion(+) + +Index: linux-5.15.67/drivers/gpio/gpio-mpc8xxx.c +=================================================================== +--- linux-5.15.67.orig/drivers/gpio/gpio-mpc8xxx.c ++++ linux-5.15.67/drivers/gpio/gpio-mpc8xxx.c +@@ -172,6 +172,7 @@ static int mpc8xxx_irq_set_type(struct i + + switch (flow_type) { + case IRQ_TYPE_EDGE_FALLING: ++ case IRQ_TYPE_LEVEL_LOW: + raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); + gc->write_reg(mpc8xxx_gc->regs + GPIO_ICR, + gc->read_reg(mpc8xxx_gc->regs + GPIO_ICR) diff --git a/target/linux/mpc85xx/patches-5.15/900-powerpc-bootwrapper-disable-uImage-generation.patch b/target/linux/mpc85xx/patches-5.15/900-powerpc-bootwrapper-disable-uImage-generation.patch new file mode 100644 index 0000000000..a021db000d --- /dev/null +++ b/target/linux/mpc85xx/patches-5.15/900-powerpc-bootwrapper-disable-uImage-generation.patch @@ -0,0 +1,44 @@ +From d43ab14605510d9d2bd257a8cd70f24ada4621b0 Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Sat, 29 Feb 2020 14:27:04 +0100 +Subject: [PATCH] powerpc: bootwrapper: disable uImage generation + +Due to CONFIG_KERNEL_XZ symbol, the bootwrapper code tries to +instruct the mkimage to use the xz compression, which isn't +supported. This disables the uImage generation, as OpenWrt +generates individual uImages for each board using it's own +toolchain. + +Signed-off-by: David Bauer +--- + arch/powerpc/boot/Makefile | 9 --------- + 1 file changed, 9 deletions(-) + +Index: linux-5.15.67/arch/powerpc/boot/Makefile +=================================================================== +--- linux-5.15.67.orig/arch/powerpc/boot/Makefile ++++ linux-5.15.67/arch/powerpc/boot/Makefile +@@ -271,7 +271,6 @@ image-$(CONFIG_PPC_CHRP) += zImage.chrp + image-$(CONFIG_PPC_EFIKA) += zImage.chrp + image-$(CONFIG_PPC_PMAC) += zImage.pmac + image-$(CONFIG_PPC_HOLLY) += dtbImage.holly +-image-$(CONFIG_DEFAULT_UIMAGE) += uImage + image-$(CONFIG_EPAPR_BOOT) += zImage.epapr + + # +@@ -403,15 +402,6 @@ $(obj)/dtbImage.%: vmlinux $(wrapperbits + $(obj)/vmlinux.strip: vmlinux + $(STRIP) -s -R .comment $< -o $@ + +-$(obj)/uImage: vmlinux $(wrapperbits) FORCE +- $(call if_changed,wrap,uboot) +- +-$(obj)/uImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE +- $(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) +- +-$(obj)/uImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE +- $(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb) +- + $(obj)/cuImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE + $(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) + From 016c9344824c06f54412f23fa5962156edfc0d39 Mon Sep 17 00:00:00 2001 From: Wojciech Dubowik Date: Wed, 14 Sep 2022 12:13:10 +0200 Subject: [PATCH 106/114] mpc85xx: Add 5.15 kernel as testing and fix configs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build system: x86_64 Build-tested: generic Run-tested: generic/TL-WDR4900 v1 board from TP-Link Signed-off-by: Wojciech Dubowik Signed-off-by: Petr Štetiar [un-dmarc] --- target/linux/mpc85xx/Makefile | 1 + target/linux/mpc85xx/config-5.15 | 3 +++ target/linux/mpc85xx/p1020/config-default | 1 + target/linux/mpc85xx/p2020/config-default | 1 + 4 files changed, 6 insertions(+) diff --git a/target/linux/mpc85xx/Makefile b/target/linux/mpc85xx/Makefile index 398e578882..f5f5a9c5c1 100644 --- a/target/linux/mpc85xx/Makefile +++ b/target/linux/mpc85xx/Makefile @@ -12,6 +12,7 @@ FEATURES:=squashfs ramdisk nand SUBTARGETS:=p1010 p1020 p2020 KERNEL_PATCHVER:=5.10 +KERNEL_TESTING_PATCHVER:=5.15 KERNELNAME:=zImage diff --git a/target/linux/mpc85xx/config-5.15 b/target/linux/mpc85xx/config-5.15 index 532d176c15..4f27d3bd70 100644 --- a/target/linux/mpc85xx/config-5.15 +++ b/target/linux/mpc85xx/config-5.15 @@ -57,6 +57,7 @@ CONFIG_DNOTIFY=y CONFIG_DTC=y # CONFIG_E200 is not set CONFIG_E500=y +CONFIG_E500_CPU=y # CONFIG_E5500_CPU is not set # CONFIG_E6500_CPU is not set CONFIG_EARLY_PRINTK=y @@ -194,6 +195,7 @@ CONFIG_PHYSICAL_START=0x00000000 CONFIG_PPC=y CONFIG_PPC32=y # CONFIG_PPC64 is not set +# CONFIG_PPC_BOOK3S_32 is not set CONFIG_PPC_85xx=y # CONFIG_PPC_8xx is not set CONFIG_PPC_ADV_DEBUG_DACS=2 @@ -254,6 +256,7 @@ CONFIG_THREAD_SHIFT=13 CONFIG_TICK_CPU_ACCOUNTING=y CONFIG_TINY_SRCU=y # CONFIG_TL_WDR4900_V1 is not set +# CONFIG_TOOLCHAIN_DEFAULT_CPU is not set # CONFIG_TQM8540 is not set # CONFIG_TQM8541 is not set # CONFIG_TQM8548 is not set diff --git a/target/linux/mpc85xx/p1020/config-default b/target/linux/mpc85xx/p1020/config-default index 6f2a9d2c3b..73176a87dc 100644 --- a/target/linux/mpc85xx/p1020/config-default +++ b/target/linux/mpc85xx/p1020/config-default @@ -34,6 +34,7 @@ CONFIG_MUTEX_SPIN_ON_OWNER=y CONFIG_NET_FLOW_LIMIT=y CONFIG_NR_CPUS=2 CONFIG_PADATA=y +# CONFIG_PPC_QUEUED_SPINLOCKS is not set CONFIG_REGMAP_IRQ=y CONFIG_REGULATOR=y CONFIG_RFS_ACCEL=y diff --git a/target/linux/mpc85xx/p2020/config-default b/target/linux/mpc85xx/p2020/config-default index e4ed758d95..1d9ef14276 100644 --- a/target/linux/mpc85xx/p2020/config-default +++ b/target/linux/mpc85xx/p2020/config-default @@ -19,6 +19,7 @@ CONFIG_NR_CPUS=2 CONFIG_PADATA=y CONFIG_PCI_MSI=y CONFIG_PPC_MSI_BITMAP=y +# CONFIG_PPC_QUEUED_SPINLOCKS is not set CONFIG_RFS_ACCEL=y CONFIG_RPS=y CONFIG_RTC_DRV_DS1307=y From 4ed850fcb18ae894b10caa979bcc249eb92f5fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Fri, 22 Apr 2022 08:17:13 +0200 Subject: [PATCH 107/114] malta: make 5.15 kernel default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to begin testing of upcoming kernel. Signed-off-by: Petr Štetiar --- target/linux/malta/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/linux/malta/Makefile b/target/linux/malta/Makefile index 7259cff4e9..fb24708991 100644 --- a/target/linux/malta/Makefile +++ b/target/linux/malta/Makefile @@ -10,8 +10,7 @@ SUBTARGETS:=le be le64 be64 INITRAMFS_EXTRA_FILES:= FEATURES:=cpiogz ext4 ramdisk squashfs targz -KERNEL_PATCHVER:=5.10 -KERNEL_TESTING_PATCHVER:=5.15 +KERNEL_PATCHVER:=5.15 include $(INCLUDE_DIR)/target.mk From 67144f38e7e2bf6e973ffee3043883192fb73764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Fri, 22 Apr 2022 08:17:13 +0200 Subject: [PATCH 108/114] armvirt: make 5.15 kernel default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to begin testing of upcoming kernel. Signed-off-by: Petr Štetiar --- target/linux/armvirt/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/linux/armvirt/Makefile b/target/linux/armvirt/Makefile index 6a2587fb38..73913f4a5b 100644 --- a/target/linux/armvirt/Makefile +++ b/target/linux/armvirt/Makefile @@ -9,8 +9,7 @@ BOARDNAME:=QEMU ARM Virtual Machine FEATURES:=fpu pci rtc usb FEATURES+=cpiogz ext4 ramdisk squashfs targz -KERNEL_PATCHVER:=5.10 -KERNEL_TESTING_PATCHVER:=5.15 +KERNEL_PATCHVER:=5.15 include $(INCLUDE_DIR)/target.mk From c4d030f24cff34737d7cf1f116022b8dbe45f5be Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Wed, 31 Aug 2022 17:20:52 +0200 Subject: [PATCH 109/114] realtek: rtl838x: Fix ethernet polling timeout on probe Due to an oversight we accidentally inverted the timeout check. This patch corrects this. Fixes: 9cec4a0ea45b ("realtek: Use built-in functionality for timeout loop") Signed-off-by: Olliver Schinagl [ wrap poll_timeout line to 80 char ] Signed-off-by: Christian Marangi --- .../linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c index f56901d707..76b6cde7be 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c @@ -1809,7 +1809,8 @@ int rtl838x_smi_wait_op(int timeout) int ret = 0; u32 val; - ret = readx_poll_timeout(sw_r32, RTL838X_SMI_ACCESS_PHY_CTRL_1, val, val & 0x1, 20, timeout); + ret = readx_poll_timeout(sw_r32, RTL838X_SMI_ACCESS_PHY_CTRL_1, + val, !(val & 0x1), 20, timeout); if (ret) pr_err("%s: timeout\n", __func__); From 8010d3da0376f68dd3724c30db0c4c9c513e5376 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 14 Sep 2022 20:23:17 +0100 Subject: [PATCH 110/114] mediatek: build USB XHCI support as module Instead of always including the XHCI driver in the kernel on all MediaTek boards, selectively include the kernel module only on boards which actually make use of USB functionality. Signed-off-by: Daniel Golle --- package/kernel/linux/modules/usb.mk | 1 + target/linux/mediatek/filogic/config-5.15 | 5 ----- target/linux/mediatek/mt7622/config-5.15 | 5 ----- target/linux/mediatek/mt7623/config-5.15 | 3 --- 4 files changed, 1 insertion(+), 13 deletions(-) diff --git a/package/kernel/linux/modules/usb.mk b/package/kernel/linux/modules/usb.mk index f3838b3981..4ee70d7eb9 100644 --- a/package/kernel/linux/modules/usb.mk +++ b/package/kernel/linux/modules/usb.mk @@ -1746,6 +1746,7 @@ define KernelPackage/usb3 +TARGET_bcm53xx:kmod-usb-bcma \ +TARGET_bcm53xx:kmod-phy-bcm-ns-usb3 \ +TARGET_ramips_mt7621:kmod-usb-xhci-mtk \ + +TARGET_mediatek:kmod-usb-xhci-mtk \ +TARGET_apm821xx_nand:kmod-usb-xhci-pci-renesas \ +TARGET_mvebu_cortexa9:kmod-usb-xhci-pci-renesas KCONFIG:= \ diff --git a/target/linux/mediatek/filogic/config-5.15 b/target/linux/mediatek/filogic/config-5.15 index 0c026e0e01..963815b264 100644 --- a/target/linux/mediatek/filogic/config-5.15 +++ b/target/linux/mediatek/filogic/config-5.15 @@ -412,12 +412,7 @@ CONFIG_TREE_SRCU=y CONFIG_UBIFS_FS=y # CONFIG_UCLAMP_TASK is not set # CONFIG_UNMAP_KERNEL_AT_EL0 is not set -CONFIG_USB=y -CONFIG_USB_COMMON=y CONFIG_USB_SUPPORT=y -CONFIG_USB_XHCI_HCD=y -CONFIG_USB_XHCI_MTK=y -# CONFIG_USB_XHCI_PLATFORM is not set CONFIG_VMAP_STACK=y CONFIG_WATCHDOG_CORE=y CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC=y diff --git a/target/linux/mediatek/mt7622/config-5.15 b/target/linux/mediatek/mt7622/config-5.15 index 8717e799ed..c21ec45e90 100644 --- a/target/linux/mediatek/mt7622/config-5.15 +++ b/target/linux/mediatek/mt7622/config-5.15 @@ -441,12 +441,7 @@ CONFIG_TREE_SRCU=y CONFIG_UBIFS_FS=y # CONFIG_UCLAMP_TASK is not set # CONFIG_UNMAP_KERNEL_AT_EL0 is not set -CONFIG_USB=y -CONFIG_USB_COMMON=y CONFIG_USB_SUPPORT=y -CONFIG_USB_XHCI_HCD=y -CONFIG_USB_XHCI_MTK=y -# CONFIG_USB_XHCI_PLATFORM is not set CONFIG_VMAP_STACK=y CONFIG_WATCHDOG_CORE=y CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC=y diff --git a/target/linux/mediatek/mt7623/config-5.15 b/target/linux/mediatek/mt7623/config-5.15 index d28b051c85..aa4c4cbad1 100644 --- a/target/linux/mediatek/mt7623/config-5.15 +++ b/target/linux/mediatek/mt7623/config-5.15 @@ -552,9 +552,6 @@ CONFIG_USB_ROLE_SWITCH=y CONFIG_USB_SUPPORT=y CONFIG_USB_U_ETHER=y CONFIG_USB_U_SERIAL=y -CONFIG_USB_XHCI_HCD=y -CONFIG_USB_XHCI_MTK=y -CONFIG_USB_XHCI_PLATFORM=y CONFIG_USE_OF=y CONFIG_VFP=y CONFIG_VFPv3=y From b36de68da6bc5a7f61e5ede16fd403085d24433c Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 15 Sep 2022 13:35:52 +0200 Subject: [PATCH 111/114] mt76: update to the latest version 94eb0bc1374d wifi: mt76: testmode: use random payload for tx packets f8ece810002b wifi: mt76: add rx_check callback for usb devices 67fbdb7bed90 wifi: mt76: mt7921e: fix race issue between reset and suspend/resume a9b09dd2715f wifi: mt76: mt7921s: fix race issue between reset and suspend/resume ee3eb0d6d52e wifi: mt76: mt7921u: fix race issue between reset and suspend/resume 9706ccef5447 wifi: mt76: mt7921u: remove unnecessary MT76_STATE_SUSPEND 74a29eb4f714 wifi: mt76: mt7921: move mt7921_rx_check and mt7921_queue_rx_skb in mac.c f49e06c4cfce wifi: mt76: sdio: fix the deadlock caused by sdio->stat_work 322656141fa4 wifi: mt76: sdio: poll sta stat when device transmits data dee0a3cbfb03 wifi: mt76: mt7915: fix an uninitialized variable bug 9dd7be2c5164 wifi: mt76: mt7921: fix use after free in mt7921_acpi_read() 0ad02c9a4512 wifi: mt76: sdio: add rx_check callback for sdio devices fe85e5ccbaca wifi: mt76: sdio: fix transmitting packet hangs 206c7ebd7464 wifi: mt76: mt7615: add mt7615_mutex_acquire/release in mt7615_sta_set_decap_offload bf79f5d73e4f wifi: mt76: mt7915: fix possible unaligned access in mt7915_mac_add_twt_setup c4132ab0bea2 wifi: mt76: connac: fix possible unaligned access in mt76_connac_mcu_add_nested_tlv 52eec74986cf wifi: mt76: mt7663s: add rx_check callback 019ef069e754 wifi: mt76: mt76_usb.mt76u_mcu.burst is always false remove related code 0a392ca03db8 wifi: mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap fbb3554b6236 wifi: mt76: mt7921: add mt7921_mutex_acquire at mt7921_sta_set_decap_offload b55a4eb2ee21 wifi: mt76: mt7921: fix the firmware version report 2d72c9a74011 wifi: mt76: move move mt76_sta_stats to mt76_wcid 873365b06c5c wifi: mt76: add PPDU based TxS support for WED device 0c64a80a61c2 wifi: mt76: connac: fix in comment d11f971a452e wifi: mt76: mt7921: get rid of the false positive reset 2ac22300c7ac wifi: mt76: mt7915: fix mcs value in ht mode 5e45533e4ba2 wifi: mt76: fix uninitialized pointer in mt7921_mac_fill_rx e06376af21dd wifi: mt76: mt7915: do not check state before configuring implicit beamform 0c0bda4aea05 wifi: mt76: mt7921: reset msta->airtime_ac while clearing up hw value cddc4b43ea93 wifi: mt76: mt7921e: fix rmmod crash in driver reload test ebbd68842ee0 wifi: mt76: mt7921: introduce Country Location Control support 763a1d90133b wifi: mt76: mt7921e: fix random fw download fail Signed-off-by: Felix Fietkau --- package/kernel/mt76/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile index 998320ac5c..c1c5f36535 100644 --- a/package/kernel/mt76/Makefile +++ b/package/kernel/mt76/Makefile @@ -8,9 +8,9 @@ PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/openwrt/mt76 PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2022-09-06 -PKG_SOURCE_VERSION:=d70546462b7b51ebc2bcdd5c534fdf3465be62a4 -PKG_MIRROR_HASH:=3d6b68d70a78c0072ed10ab2548344b6b3a70ad99e4edc258fafa16886f4abf9 +PKG_SOURCE_DATE:=2022-09-15 +PKG_SOURCE_VERSION:=763a1d90133bfd2efae1a533d6b571d9802bcaa3 +PKG_MIRROR_HASH:=8adeab19ef8c7df146fa9568bc8aba9418840e543b49e1e79dee85ca70725fa4 PKG_MAINTAINER:=Felix Fietkau PKG_USE_NINJA:=0 From 8b06e06832ebe757246582b65306ad2a2537741f Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 15 Sep 2022 16:38:18 +0200 Subject: [PATCH 112/114] mac80211: merge pending fixes for tx queueing issues Fixes a potential deadlock and a tx queue hang on STA assoc Signed-off-by: Felix Fietkau --- ...dlock-Don-t-start-TX-while-holding-f.patch | 40 ++++++++++++++++ ...vif-queues-are-operational-after-sta.patch | 47 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 package/kernel/mac80211/patches/subsys/341-mac80211-Fix-deadlock-Don-t-start-TX-while-holding-f.patch create mode 100644 package/kernel/mac80211/patches/subsys/342-mac80211-Ensure-vif-queues-are-operational-after-sta.patch diff --git a/package/kernel/mac80211/patches/subsys/341-mac80211-Fix-deadlock-Don-t-start-TX-while-holding-f.patch b/package/kernel/mac80211/patches/subsys/341-mac80211-Fix-deadlock-Don-t-start-TX-while-holding-f.patch new file mode 100644 index 0000000000..8c56acbf88 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/341-mac80211-Fix-deadlock-Don-t-start-TX-while-holding-f.patch @@ -0,0 +1,40 @@ +From: Alexander Wetzel +Date: Thu, 15 Sep 2022 14:41:20 +0200 +Subject: [PATCH] mac80211: Fix deadlock: Don't start TX while holding + fq->lock + +ieee80211_txq_purge() calls fq_tin_reset() and +ieee80211_purge_tx_queue(); Both are then calling +ieee80211_free_txskb(). Which can decide to TX the skb again. + +There are at least two ways to get a deadlock: + +1) When we have a TDLS teardown packet queued in either tin or frags + ieee80211_tdls_td_tx_handle() will call ieee80211_subif_start_xmit() + while we still hold fq->lock. ieee80211_txq_enqueue() will thus + deadlock. + +2) A variant of the above happens if aggregation is up and running: + In that case ieee80211_iface_work() will deadlock with the original + task: The original tasks already holds fq->lock and tries to get + sta->lock after kicking off ieee80211_iface_work(). But the worker + can get sta->lock prior to the original task and will then spin for + fq->lock. + +Avoid these deadlocks by not sending out any skbs when called via +ieee80211_free_txskb(). + +Signed-off-by: Alexander Wetzel +--- + +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -698,7 +698,7 @@ static void ieee80211_report_used_skb(st + + if (!sdata) { + skb->dev = NULL; +- } else { ++ } else if (!dropped) { + unsigned int hdr_size = + ieee80211_hdrlen(hdr->frame_control); + diff --git a/package/kernel/mac80211/patches/subsys/342-mac80211-Ensure-vif-queues-are-operational-after-sta.patch b/package/kernel/mac80211/patches/subsys/342-mac80211-Ensure-vif-queues-are-operational-after-sta.patch new file mode 100644 index 0000000000..4310329319 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/342-mac80211-Ensure-vif-queues-are-operational-after-sta.patch @@ -0,0 +1,47 @@ +From: Alexander Wetzel +Date: Thu, 15 Sep 2022 15:09:46 +0200 +Subject: [PATCH] mac80211: Ensure vif queues are operational after start + +Make sure local->queue_stop_reasons and vif.txqs_stopped stay in sync. + +When a new vif is created the queues may end up in an inconsistent state +and be inoperable: +Communication not using iTXQ will work, allowing to e.g. complete the +association. But the 4-way handshake will time out. The sta will not +send out any skbs queued in iTXQs. + +All normal attempts to start the queues will fail when reaching this +state. +local->queue_stop_reasons will have marked all queues as operational but +vif.txqs_stopped will still be set, creating an inconsistent internal +state. + +In reality this seems to be race between the mac80211 function +ieee80211_do_open() setting SDATA_STATE_RUNNING and the wake_txqs_tasklet: +Depending on the driver and the timing the queues may end up to be +operational or not. + +Cc: stable@vger.kernel.org +Fixes: f856373e2f31 ("wifi: mac80211: do not wake queues on a vif that is being stopped") +Signed-off-by: Alexander Wetzel +--- + +--- a/net/mac80211/util.c ++++ b/net/mac80211/util.c +@@ -301,14 +301,14 @@ static void __ieee80211_wake_txqs(struct + local_bh_disable(); + spin_lock(&fq->lock); + ++ sdata->vif.txqs_stopped[ac] = false; ++ + if (!test_bit(SDATA_STATE_RUNNING, &sdata->state)) + goto out; + + if (sdata->vif.type == NL80211_IFTYPE_AP) + ps = &sdata->bss->ps; + +- sdata->vif.txqs_stopped[ac] = false; +- + list_for_each_entry_rcu(sta, &local->sta_list, list) { + if (sdata != sta->sdata) + continue; From aa9be386d40f3a5e559c0f2183c772175a45cf0d Mon Sep 17 00:00:00 2001 From: Koen Vandeputte Date: Mon, 22 Aug 2022 11:18:35 +0200 Subject: [PATCH 113/114] mac80211: merge upstream fixes fetched from upstream kernel v5.15.67 Signed-off-by: Koen Vandeputte --- ...emory-leak-where-sta_info-is-not-fre.patch | 77 +++++++++++++++++++ ...n-t-finalize-CSA-in-IBSS-mode-if-sta.patch | 47 +++++++++++ ...ac80211-Fix-UAF-in-ieee80211_scan_rx.patch | 55 +++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 package/kernel/mac80211/patches/subsys/360-mac80211-fix-a-memory-leak-where-sta_info-is-not-fre.patch create mode 100644 package/kernel/mac80211/patches/subsys/361-wifi-mac80211-Don-t-finalize-CSA-in-IBSS-mode-if-sta.patch create mode 100644 package/kernel/mac80211/patches/subsys/362-wifi-mac80211-Fix-UAF-in-ieee80211_scan_rx.patch diff --git a/package/kernel/mac80211/patches/subsys/360-mac80211-fix-a-memory-leak-where-sta_info-is-not-fre.patch b/package/kernel/mac80211/patches/subsys/360-mac80211-fix-a-memory-leak-where-sta_info-is-not-fre.patch new file mode 100644 index 0000000000..ff3cb7be53 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/360-mac80211-fix-a-memory-leak-where-sta_info-is-not-fre.patch @@ -0,0 +1,77 @@ +From 4db561ae4a90c2d0e15996634567559e292dc9e5 Mon Sep 17 00:00:00 2001 +From: Ahmed Zaki +Date: Sat, 2 Oct 2021 08:53:29 -0600 +Subject: [PATCH] mac80211: fix a memory leak where sta_info is not freed + +commit 8f9dcc29566626f683843ccac6113a12208315ca upstream. + +The following is from a system that went OOM due to a memory leak: + +wlan0: Allocated STA 74:83:c2:64:0b:87 +wlan0: Allocated STA 74:83:c2:64:0b:87 +wlan0: IBSS finish 74:83:c2:64:0b:87 (---from ieee80211_ibss_add_sta) +wlan0: Adding new IBSS station 74:83:c2:64:0b:87 +wlan0: moving STA 74:83:c2:64:0b:87 to state 2 +wlan0: moving STA 74:83:c2:64:0b:87 to state 3 +wlan0: Inserted STA 74:83:c2:64:0b:87 +wlan0: IBSS finish 74:83:c2:64:0b:87 (---from ieee80211_ibss_work) +wlan0: Adding new IBSS station 74:83:c2:64:0b:87 +wlan0: moving STA 74:83:c2:64:0b:87 to state 2 +wlan0: moving STA 74:83:c2:64:0b:87 to state 3 +. +. +wlan0: expiring inactive not authorized STA 74:83:c2:64:0b:87 +wlan0: moving STA 74:83:c2:64:0b:87 to state 2 +wlan0: moving STA 74:83:c2:64:0b:87 to state 1 +wlan0: Removed STA 74:83:c2:64:0b:87 +wlan0: Destroyed STA 74:83:c2:64:0b:87 + +The ieee80211_ibss_finish_sta() is called twice on the same STA from 2 +different locations. On the second attempt, the allocated STA is not +destroyed creating a kernel memory leak. + +This is happening because sta_info_insert_finish() does not call +sta_info_free() the second time when the STA already exists (returns +-EEXIST). Note that the caller sta_info_insert_rcu() assumes STA is +destroyed upon errors. + +Same fix is applied to -ENOMEM. + +Signed-off-by: Ahmed Zaki +Link: https://lore.kernel.org/r/20211002145329.3125293-1-anzaki@gmail.com +[change the error path label to use the existing code] +Signed-off-by: Johannes Berg +Signed-off-by: Viacheslav Sablin +Signed-off-by: Greg Kroah-Hartman +--- + net/mac80211/sta_info.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/net/mac80211/sta_info.c ++++ b/net/mac80211/sta_info.c +@@ -646,13 +646,13 @@ static int sta_info_insert_finish(struct + /* check if STA exists already */ + if (sta_info_get_bss(sdata, sta->sta.addr)) { + err = -EEXIST; +- goto out_err; ++ goto out_cleanup; + } + + sinfo = kzalloc(sizeof(struct station_info), GFP_KERNEL); + if (!sinfo) { + err = -ENOMEM; +- goto out_err; ++ goto out_cleanup; + } + + local->num_sta++; +@@ -708,8 +708,8 @@ static int sta_info_insert_finish(struct + out_drop_sta: + local->num_sta--; + synchronize_net(); ++ out_cleanup: + cleanup_single_sta(sta); +- out_err: + mutex_unlock(&local->sta_mtx); + kfree(sinfo); + rcu_read_lock(); diff --git a/package/kernel/mac80211/patches/subsys/361-wifi-mac80211-Don-t-finalize-CSA-in-IBSS-mode-if-sta.patch b/package/kernel/mac80211/patches/subsys/361-wifi-mac80211-Don-t-finalize-CSA-in-IBSS-mode-if-sta.patch new file mode 100644 index 0000000000..dd3e934c00 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/361-wifi-mac80211-Don-t-finalize-CSA-in-IBSS-mode-if-sta.patch @@ -0,0 +1,47 @@ +From 552ba102a6898630a7d16887f29e606d6fabe508 Mon Sep 17 00:00:00 2001 +From: Siddh Raman Pant +Date: Sun, 14 Aug 2022 20:45:12 +0530 +Subject: [PATCH] wifi: mac80211: Don't finalize CSA in IBSS mode if state is + disconnected + +commit 15bc8966b6d3a5b9bfe4c9facfa02f2b69b1e5f0 upstream. + +When we are not connected to a channel, sending channel "switch" +announcement doesn't make any sense. + +The BSS list is empty in that case. This causes the for loop in +cfg80211_get_bss() to be bypassed, so the function returns NULL +(check line 1424 of net/wireless/scan.c), causing the WARN_ON() +in ieee80211_ibss_csa_beacon() to get triggered (check line 500 +of net/mac80211/ibss.c), which was consequently reported on the +syzkaller dashboard. + +Thus, check if we have an existing connection before generating +the CSA beacon in ieee80211_ibss_finish_csa(). + +Cc: stable@vger.kernel.org +Fixes: cd7760e62c2a ("mac80211: add support for CSA in IBSS mode") +Link: https://syzkaller.appspot.com/bug?id=05603ef4ae8926761b678d2939a3b2ad28ab9ca6 +Reported-by: syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com +Signed-off-by: Siddh Raman Pant +Tested-by: syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com +Link: https://lore.kernel.org/r/20220814151512.9985-1-code@siddh.me +Signed-off-by: Johannes Berg +Signed-off-by: Greg Kroah-Hartman +--- + net/mac80211/ibss.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/net/mac80211/ibss.c ++++ b/net/mac80211/ibss.c +@@ -534,6 +534,10 @@ int ieee80211_ibss_finish_csa(struct iee + + sdata_assert_lock(sdata); + ++ /* When not connected/joined, sending CSA doesn't make sense. */ ++ if (ifibss->state != IEEE80211_IBSS_MLME_JOINED) ++ return -ENOLINK; ++ + /* update cfg80211 bss information with the new channel */ + if (!is_zero_ether_addr(ifibss->bssid)) { + cbss = cfg80211_get_bss(sdata->local->hw.wiphy, diff --git a/package/kernel/mac80211/patches/subsys/362-wifi-mac80211-Fix-UAF-in-ieee80211_scan_rx.patch b/package/kernel/mac80211/patches/subsys/362-wifi-mac80211-Fix-UAF-in-ieee80211_scan_rx.patch new file mode 100644 index 0000000000..0e58b61602 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/362-wifi-mac80211-Fix-UAF-in-ieee80211_scan_rx.patch @@ -0,0 +1,55 @@ +From 5d20c6f932f2758078d0454729129c894fe353e7 Mon Sep 17 00:00:00 2001 +From: Siddh Raman Pant +Date: Sat, 20 Aug 2022 01:33:40 +0530 +Subject: [PATCH] wifi: mac80211: Fix UAF in ieee80211_scan_rx() + +commit 60deb9f10eec5c6a20252ed36238b55d8b614a2c upstream. + +ieee80211_scan_rx() tries to access scan_req->flags after a +null check, but a UAF is observed when the scan is completed +and __ieee80211_scan_completed() executes, which then calls +cfg80211_scan_done() leading to the freeing of scan_req. + +Since scan_req is rcu_dereference()'d, prevent the racing in +__ieee80211_scan_completed() by ensuring that from mac80211's +POV it is no longer accessed from an RCU read critical section +before we call cfg80211_scan_done(). + +Cc: stable@vger.kernel.org +Link: https://syzkaller.appspot.com/bug?extid=f9acff9bf08a845f225d +Reported-by: syzbot+f9acff9bf08a845f225d@syzkaller.appspotmail.com +Suggested-by: Johannes Berg +Signed-off-by: Siddh Raman Pant +Link: https://lore.kernel.org/r/20220819200340.34826-1-code@siddh.me +Signed-off-by: Johannes Berg +Signed-off-by: Greg Kroah-Hartman +--- + net/mac80211/scan.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +--- a/net/mac80211/scan.c ++++ b/net/mac80211/scan.c +@@ -461,16 +461,19 @@ static void __ieee80211_scan_completed(s + scan_req = rcu_dereference_protected(local->scan_req, + lockdep_is_held(&local->mtx)); + +- if (scan_req != local->int_scan_req) { +- local->scan_info.aborted = aborted; +- cfg80211_scan_done(scan_req, &local->scan_info); +- } + RCU_INIT_POINTER(local->scan_req, NULL); + RCU_INIT_POINTER(local->scan_sdata, NULL); + + local->scanning = 0; + local->scan_chandef.chan = NULL; + ++ synchronize_rcu(); ++ ++ if (scan_req != local->int_scan_req) { ++ local->scan_info.aborted = aborted; ++ cfg80211_scan_done(scan_req, &local->scan_info); ++ } ++ + /* Set power back to normal operating levels. */ + ieee80211_hw_config(local, 0); + From 731646e13ac66797fa8621cf29cdf30dc08ca9d5 Mon Sep 17 00:00:00 2001 From: Koen Vandeputte Date: Tue, 13 Sep 2022 13:44:17 +0200 Subject: [PATCH 114/114] kernel: mhi: backport upstream patch This patch will print the name of the modem in the bootlog during probing. This allows to verify that the exact model was loaded and not some generic type. The only other way to do this is by enabling dynamic debugging which is disabled by default in OpenWRT Signed-off-by: Koen Vandeputte --- ...ost-always-print-detected-modem-name.patch | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 target/linux/generic/backport-5.15/781-v6.1-bus-mhi-host-always-print-detected-modem-name.patch diff --git a/target/linux/generic/backport-5.15/781-v6.1-bus-mhi-host-always-print-detected-modem-name.patch b/target/linux/generic/backport-5.15/781-v6.1-bus-mhi-host-always-print-detected-modem-name.patch new file mode 100644 index 0000000000..e974c21cb7 --- /dev/null +++ b/target/linux/generic/backport-5.15/781-v6.1-bus-mhi-host-always-print-detected-modem-name.patch @@ -0,0 +1,37 @@ +From f369e9ad52ec9361827e21a631b7198c9fca438e Mon Sep 17 00:00:00 2001 +From: Koen Vandeputte +Date: Wed, 31 Aug 2022 12:03:49 +0200 +Subject: [PATCH] bus: mhi: host: always print detected modem name + +This harmless print provides a very easy way of knowing +if the modem is detected properly during probing. + +Promote it to an informational print so no hassle is required +enabling kernel debugging info to obtain it. + +The rationale here is that: +On a lot of low-storage embedded devices, extensive kernel +debugging info is not always present as this would +increase it's size to much causing partition size issues. + +Signed-off-by: Koen Vandeputte +Reviewed-by: Manivannan Sadhasivam +Reviewed-by: Loic Poulain +Link: https://lore.kernel.org/r/20220831100349.1488762-1-koen.vandeputte@citymesh.com +[mani: added missing review tags] +Signed-off-by: Manivannan Sadhasivam +--- + drivers/bus/mhi/pci_generic.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/bus/mhi/pci_generic.c ++++ b/drivers/bus/mhi/pci_generic.c +@@ -806,7 +806,7 @@ static int mhi_pci_probe(struct pci_dev + struct mhi_controller *mhi_cntrl; + int err; + +- dev_dbg(&pdev->dev, "MHI PCI device found: %s\n", info->name); ++ dev_info(&pdev->dev, "MHI PCI device found: %s\n", info->name); + + /* mhi_pdev.mhi_cntrl must be zero-initialized */ + mhi_pdev = devm_kzalloc(&pdev->dev, sizeof(*mhi_pdev), GFP_KERNEL);