Re: [OpenWrt-Devel] [PATCH v2] gemini: Bring up DSA switches
On Sun, Jul 14, 2019 at 5:15 PM Pawel Dembicki wrote: > > +storlink,gemini324) > > + # These are all connected to eth1 thru VSC7385 > > + ucidef_set_interface "eth" ifname "eth1" protocol "none" > > + ucidef_set_interfaces_lan_wan "eth1 lan1 lan2 lan3 lan4" "eth0" > > + ;; Ooops I say I shall fix it then I don't. eth1 is still there. OK I fix a v3. The switch is working fine on the VSC7385 like this. > I can't reproduce working state on P2020RDB with this two methods. > In my device work this sequence: > > ip link set eth0 up > ip link set lan1 up > ip link set lan2 up > ip link set lan3 up > ip link set lan4 up > ip link add name br-lan type bridge > ip link set dev lan1 master br-lan > ip link set dev lan2 master br-lan > ip link set dev lan3 master br-lan > ip link set dev lan4 master br-lan > ip addr add 192.168.1.1/24 dev br-lan > ip link set dev br-lan up > ip link set dev eth0 master br-lan > > I think, vsc73xx without vlan filtering is very tricky now. I think you should have it like this: ucidef_set_interface "eth" ifname "eth0" protocol "none" ucidef_set_interfaces_lan "lan1 lan2 lan3 lan4" If you don't have any WAN interface (uplink) on the device. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH v2] gemini: Bring up DSA switches
First group the interfaces on the DSA switch into the right LAN/WAN groups. Tested successfully on the Itian Square One SQ201 and the SL93512 reference design with the Vitesse DSA switches. As discussed on the mailing list, these switches are untagged (DSA_TAG_PROTO_NONE) so the DSA slave devices are only slave devices with not datapath control. This means each of the CPU-facing interfaces need to be brought up with the "none" protocol before any slave devices are brought up. (The sequence matters here.) Tested on each of the three affected devices. Cc: Pawel Dembicki Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Remove the eth1 from the LAN bridge in both the Vitesse switch devices, instead bring up each ethernet master interface independently with "none" protocol. --- .../gemini/base-files/etc/board.d/02_network | 27 +++ 1 file changed, 27 insertions(+) create mode 100755 target/linux/gemini/base-files/etc/board.d/02_network diff --git a/target/linux/gemini/base-files/etc/board.d/02_network b/target/linux/gemini/base-files/etc/board.d/02_network new file mode 100755 index ..b5c48c82 --- /dev/null +++ b/target/linux/gemini/base-files/etc/board.d/02_network @@ -0,0 +1,27 @@ +#!/bin/sh + +. /lib/functions/uci-defaults.sh + +board_config_update + +case "$(board_name)" in +storlink,gemini324) + # These are all connected to eth1 thru VSC7385 + ucidef_set_interface "eth" ifname "eth1" protocol "none" + ucidef_set_interfaces_lan_wan "eth1 lan1 lan2 lan3 lan4" "eth0" + ;; +itian,sq201) + # These are all connected to eth1 thru VSC7395 + ucidef_set_interface "eth" ifname "eth1" protocol "none" + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "eth0" + ;; +dlink,dir-685) + # These are all connected to eth0 thru RTL8366RB + ucidef_set_interface "eth" ifname "eth0" protocol "none" + ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" "wan" + ;; +esac + +board_config_flush + +exit 0 -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] gemini: Bring up DSA switches
On Sat, Jul 13, 2019 at 10:38 PM Florian Fainelli wrote: > drivers/net/dsa/vitesse-vsc73xx.c returns DSA_TAG_PROTO_NONE for the > tagging protocol, which means that the DSA slave devices are only > control devices they are not used by the data-path (which requires an > appropriate tagging protocol to allow differentiating the Ethernet > frames on a per-port basis). If you supported a different tagging > protocol, then you would not be able to enslave the DSA master device > (eth1) into the bridge, because that would conflict with the bridge's > rx_handler, see 8db0a2ee2c6302a1dcbcdb93cb731dfc6c0cdb5e ("net: bridge: > reject DSA-enabled master netdevices as bridge members") Ah it's because of this! I try to figure it out. Thanks Florian! I really tried to figure out a way to get both the Vitesse and Realtek switches to do internal tagging but they just don't. The Vitesse switches can do VLAN but I just haven't implemented it yet, but now that Adrian is using it on a Freescale board as well I might get to it as we have some more users. There are some patches to the kernel do do port separation using only VLAN (by Vladimir Oltean) but of course I have to implement VLAN first if I want to try to use that. > Your second sequence is more in line with what you should do, see the > recent documentation examples from Benedikt: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/dsa/configuration.rst Oh that is really good documentation. I linked it in the Ethernet switch page in the OpenWrt wiki. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] gemini: Bring up DSA switches
On Fri, Jul 12, 2019 at 8:57 AM Hauke Mehrtens wrote: > On 7/12/19 8:07 AM, Linus Walleij wrote: > > + # These are all connected to eth1 thru VSC7385 > > + ucidef_set_interfaces_lan_wan "eth1 lan1 lan2 lan3 lan4" "eth0" > > This will create a bridge over eth1, lan1, lan2, lan3 and lan4, but I > think you do not have to put eth1 into this bridge, it should be > sufficient to have all the lanX in it. It is really puzzling to me too :( What I notice is that if I do this everything works fine and if eth1 is not included it doesn't. This sequence also works fine: ifconfig eth1 169.254.1.2 netmask 255.255.255.0 up ifconfig lan1 up ifconfig lan2 up ifconfig lan3 up ifconfig lan4 up I think the reason is that the IP address is not assigned to eth1 (the CPU port towards the switch/DSA). Maybe other DSA switches are better with this? My dmesg looks like this with eth1 included in the lan-facing interfaces: [ 52.704396] gemini-ethernet-port 6000c000.ethernet-port eth1: link flow control: both [ 53.046012] br-lan: port 1(eth1) entered blocking state [ 53.170160] br-lan: port 1(eth1) entered disabled state [ 53.253455] device eth1 entered promiscuous mode [ 53.299150] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready [ 53.388545] vsc73xx spi0.0: enable port 0 [ 53.446029] vsc73xx spi0.0 lan1: configuring for phy/gmii link mode [ 53.526483] br-lan: port 2(lan1) entered blocking state [ 53.594789] br-lan: port 2(lan1) entered disabled state [ 53.665816] device lan1 entered promiscuous mode [ 53.728728] br-lan: port 1(eth1) entered blocking state [ 53.760176] br-lan: port 1(eth1) entered forwarding state [ 53.874449] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready [ 54.000353] vsc73xx spi0.0: enable port 1 [ 54.056099] vsc73xx spi0.0 lan2: configuring for phy/gmii link mode [ 54.142223] br-lan: port 3(lan2) entered blocking state [ 54.214679] br-lan: port 3(lan2) entered disabled state [ 54.266496] device lan2 entered promiscuous mode [ 54.308593] vsc73xx spi0.0: enable port 2 [ 54.335298] vsc73xx spi0.0 lan3: configuring for phy/gmii link mode [ 54.377279] br-lan: port 4(lan3) entered blocking state [ 54.97] br-lan: port 4(lan3) entered disabled state [ 54.515791] device lan3 entered promiscuous mode [ 54.588687] vsc73xx spi0.0: enable port 3 [ 54.646048] vsc73xx spi0.0 lan4: configuring for phy/gmii link mode [ 54.726991] br-lan: port 5(lan4) entered blocking state [ 54.785910] vsc73xx spi0.0 lan1: Link is Up - 1Gbps/Full - flow control rx/tx [ 54.844478] br-lan: port 5(lan4) entered disabled state [ 54.915911] device lan4 entered promiscuous mode [ 54.976533] br-lan: port 2(lan1) entered blocking state [ 55.007954] br-lan: port 2(lan1) entered forwarding state After this I can ping the host: # ping 169.254.1.1 PING 169.254.1.1 (169.254.1.1): 56 data bytes 64 bytes from 169.254.1.1: seq=0 ttl=64 time=2.049 ms 64 bytes from 169.254.1.1: seq=6 ttl=64 time=0.913 ms 64 bytes from 169.254.1.1: seq=25 ttl=64 time=1.268 ms And the host can ping the device: $ ping 169.254.1.2 PING 169.254.1.2 (169.254.1.2) 56(84) bytes of data. 64 bytes from 169.254.1.2: icmp_seq=1 ttl=64 time=1.12 ms 64 bytes from 169.254.1.2: icmp_seq=2 ttl=64 time=0.582 ms 64 bytes from 169.254.1.2: icmp_seq=3 ttl=64 time=0.576 ms 64 bytes from 169.254.1.2: icmp_seq=4 ttl=64 time=0.654 ms But if I remove eth1 from the LAN facing interfaces it looks like this: [ 52.433253] gemini-ethernet-port 6000c000.ethernet-port eth1: link flow control: both [ 52.769503] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready [ 52.925178] device eth1 entered promiscuous mode [ 52.987672] vsc73xx spi0.0: enable port 0 [ 53.014460] vsc73xx spi0.0 lan1: configuring for phy/gmii link mode [ 53.054754] br-lan: port 1(lan1) entered blocking state [ 53.086323] br-lan: port 1(lan1) entered disabled state [ 53.119857] device lan1 entered promiscuous mode [ 53.160541] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready [ 53.250938] vsc73xx spi0.0: enable port 1 [ 53.309220] vsc73xx spi0.0 lan2: configuring for phy/gmii link mode [ 53.394269] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready [ 53.476271] br-lan: port 2(lan2) entered blocking state [ 53.543459] br-lan: port 2(lan2) entered disabled state [ 53.604655] device lan2 entered promiscuous mode [ 53.686932] vsc73xx spi0.0: enable port 2 [ 53.744974] vsc73xx spi0.0 lan3: configuring for phy/gmii link mode [ 53.820229] br-lan: port 3(lan3) entered blocking state [ 53.893505] br-lan: port 3(lan3) entered disabled state [ 53.964682] device lan3 entered promiscuous mode [ 54.047383] vsc73xx spi0.0: enable port 3 [ 54.087228] vsc73xx spi0.0 lan4: configuring for phy/gmii link mode [ 54.128009] br-lan: port 4(lan4) entered blocking state [ 54.160537] br-lan: port 4(lan4) entered disabled state [ 54.194726] device lan4 entered promiscuou
[OpenWrt-Devel] [PATCH] gemini: Bring up DSA switches
First group the interfaces on the DSA switch into the right LAN/WAN groups. Tested successfully on the Itian Square One SQ201 and the SL93512 reference design with the Vitesse DSA switches. The RTL8366RB on the DIR-685 is still under development but this setup is a starting point but since the WAN and the LAN ports share the same ethernet CPU port the ethernet port should not be part of either WAN or LAN. Signed-off-by: Linus Walleij --- .../gemini/base-files/etc/board.d/02_network | 25 +++ 1 file changed, 25 insertions(+) create mode 100755 target/linux/gemini/base-files/etc/board.d/02_network diff --git a/target/linux/gemini/base-files/etc/board.d/02_network b/target/linux/gemini/base-files/etc/board.d/02_network new file mode 100755 index ..87f888e92c28 --- /dev/null +++ b/target/linux/gemini/base-files/etc/board.d/02_network @@ -0,0 +1,25 @@ +#!/bin/sh + +. /lib/functions/uci-defaults.sh + +board_config_update + +case "$(board_name)" in +storlink,gemini324) + # These are all connected to eth1 thru VSC7385 + ucidef_set_interfaces_lan_wan "eth1 lan1 lan2 lan3 lan4" "eth0" + ;; +itian,sq201) + # These are all connected to eth1 thru VSC7395 + ucidef_set_interfaces_lan_wan "eth1 lan1 lan2 lan3 lan4" "eth0" + ;; +dlink,dir-685) + # These are all connected to eth0 thru RTL8366RB + ucidef_set_interface "eth" ifname "eth0" protocol "none" + ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" "wan" + ;; +esac + +board_config_flush + +exit 0 -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] gemini: Stop enforcing command line
The command line enforced by the kernel is harmful, we want to use the command line passed from the device tree. This is especially important for the SQ201, Teltonika RUT and WBD111 which has a console set to 115200n8 and not 19200n8 like all the others, so their consoles will be confusingly changing baudrate between boot loader and kernel. The setting in the device tree corresponds to what the boot loader is using. Signed-off-by: Linus Walleij --- target/linux/gemini/config-4.14 | 2 -- target/linux/gemini/config-4.19 | 2 -- 2 files changed, 4 deletions(-) diff --git a/target/linux/gemini/config-4.14 b/target/linux/gemini/config-4.14 index 3d11de6a40c9..fb96aa78c73a 100644 --- a/target/linux/gemini/config-4.14 +++ b/target/linux/gemini/config-4.14 @@ -55,8 +55,6 @@ CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKSRC_MMIO=y CONFIG_CLONE_BACKWARDS=y -CONFIG_CMDLINE="console=ttyS0,19200n8" -CONFIG_CMDLINE_FROM_BOOTLOADER=y CONFIG_COMMON_CLK=y CONFIG_COMMON_CLK_GEMINI=y CONFIG_CONSOLE_TRANSLATIONS=y diff --git a/target/linux/gemini/config-4.19 b/target/linux/gemini/config-4.19 index 288c8e0a3ae0..a817303ec8a0 100644 --- a/target/linux/gemini/config-4.19 +++ b/target/linux/gemini/config-4.19 @@ -62,8 +62,6 @@ 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_CMDLINE="console=ttyS0,19200n8" -CONFIG_CMDLINE_FROM_BOOTLOADER=y CONFIG_COMMON_CLK=y CONFIG_COMMON_CLK_GEMINI=y CONFIG_CONSOLE_TRANSLATIONS=y -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] gemini: Add missing image file
Somehow I missed to add the magical image cooking file for the SL93512r. Fix it. Reported-by: Christian Lamparter Signed-off-by: Linus Walleij --- .../gemini/image/ImageInfo-storlink_sl93512r | 18 ++ 1 file changed, 18 insertions(+) create mode 100644 target/linux/gemini/image/ImageInfo-storlink_sl93512r diff --git a/target/linux/gemini/image/ImageInfo-storlink_sl93512r b/target/linux/gemini/image/ImageInfo-storlink_sl93512r new file mode 100644 index ..722e9b407e29 --- /dev/null +++ b/target/linux/gemini/image/ImageInfo-storlink_sl93512r @@ -0,0 +1,18 @@ +UpgradeImages="zImage rd.gz hddapp.tgz" +Procduction="SL3516" +BOOT_VER="1.0.5" +FIRMWARE_VER="firmware-openwrt-DATESTR" +INTERNAL_FIRMWARE_VER="firmware-openwrt-DATESTR" +CONFIGURATION_VER="firmware-openwrt" +DESCRIPTION="Storlink SL93512r Reference Design" +TSS="enabled" +DIRECT_MODE="disabled" +DEFAULT_LAN_IPADDR="192.168.1.1" +DEFAULT_LAN_NETMASK="255.255.255.0" +DEFAULT_LAN_BOOTPROTO="none" +DEFAULT_WAN_BOOTPROTO="dhcp" +DEFAULT_WAN_ENABLED="yes" +DEFAULT_WLAN_DEVICENAME="eth0" +VER_zImage="DATESTR" +VER_Ramdisk="DATESTR" +VER_hddapp="DATESTR" -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] gemini: Add StorLink SL93512r images
On Sat, Jul 6, 2019 at 5:45 PM Christian Lamparter wrote: > The buildbots are currently in a bit of a pickle: > <http://phase1.builds.lede-project.org/builders/gemini%2Fgeneric> > > The gemini-target is failing for some time now. > > This is due to this error (see patch): > https://patchwork.ozlabs.org/patch/1128185/ Thanks to Adrian for fixing this part. > but also: > > cp ./ImageInfo-storlink_sl93512r > /home/luser/owrt/test-chunkeey-20190705-170344/gemini-generic/build_dir/target-arm_fa526_musl_eabi/linux-gemini/tmp/openwrt-gemini-storlink_sl93512r-squashfs-factory.bin.tmp/ImageInfo > cp: cannot stat './ImageInfo-storlink_sl93512r': No such file or directory > > This is because the script "Build/storlink-default-images" expects to have > a "target/linux/gemini/image/ImageInfo-storlink_sl93512r". > > @Linus: Can you please make a patch that adds the missing file? Yep I made a patch, testing it as we speak. Sorry for stupid mistakes, I guess I forgot some git add and then rebased and lost the file. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] gemini: Add StorLink SL93512r images
This adds image generation for the StorLink reference design SL93512r. This board is now supported upstream in kernel v4.19. As this image structure is identical to SQ201 and Raidsonic, we simply refer to this as "storlink-reference" from now on. Signed-off-by: Linus Walleij --- target/linux/gemini/image/Makefile | 24 +--- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index 5901bbf0c9b2..7b5faa04fd0e 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -74,14 +74,15 @@ define Build/wiligear-image mv $@.new $@ endef -# Create the special NAS4220B and Itian Square One SQ201 image -# format with the squashfs and overlay inside the "rd.gz" file. +# Create the default image format used by the StorLink reference design +# SL93512r, Raidsonic NAS4220B and Itian Square One SQ201 +# with the squashfs and overlay inside the "rd.gz" file. # We pad it out to 6144K which is the size of the initramfs partition. # # The "application" partition is just blank. You can put anything # there when using OpenWRT. We just use that to create the # "sysupgrade" firmware image. -define Build/nas4220b-sq201-images +define Build/storlink-default-images mkdir -p $@.tmp mv $@ $@.tmp/rd.gz @@ -162,15 +163,16 @@ define Device/dlink_dns-313 endef TARGET_DEVICES += dlink_dns-313 -define Device/itian-raidsonic +# Default images setup used by the StorLink reference designs +define Device/storlink-reference IMAGES := factory.bin IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 6144k | \ - nas4220b-sq201-images $(1) + storlink-default-images $(1) DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) endef define Device/itian_sq201 - $(Device/itian-raidsonic) + $(Device/storlink-reference) DEVICE_TITLE := ITian Square One SQ201 DEVICE_DTS := gemini-sq201 DEVICE_PACKAGES += kmod-rt61-pci kmod-usb2-pci @@ -178,13 +180,21 @@ endef TARGET_DEVICES += itian_sq201 define Device/raidsonic_ib-4220-b - $(Device/itian-raidsonic) + $(Device/storlink-reference) DEVICE_TITLE := Raidsonic NAS IB-4220-B DEVICE_DTS := gemini-nas4220b DEVICE_TYPE := nas endef TARGET_DEVICES += raidsonic_ib-4220-b +define Device/storlink-sl93512r + $(Device/storlink-reference) + DEVICE_TITLE := StorLink SL93512r + DEVICE_DTS := gemini-sl93512r +endef +TARGET_DEVICES += storlink_sl93512r + + # The wiliboard images need some changes to be functional and buildable. # # The dts would need to use the ecoscentric,redboot-fis-partitions partition -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] gemini: Drop switch kmod and swconfig
The DIR-685 needs this module compiled in for safety (it is facing the LAN ports) and it is now (as of kernel v4.19) using the DSA switch architecture so swconfig is not needed. Signed-off-by: Linus Walleij --- target/linux/gemini/image/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index ddc2fb9a138c..5901bbf0c9b2 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -142,7 +142,6 @@ define Device/dlink_dir-685 DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router DEVICE_DTS := gemini-dlink-dir-685 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \ - kmod-switch-rtl8366rb swconfig \ kmod-rt2800-pci IMAGES := factory.bin sysupgrade.bin # Pad to 128k erase blocks with 160 bytes WRGG header -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] gpio-button-hotplug: gpio-keys: read initial state
On Tue, Jun 18, 2019 at 12:53 PM David Bauer wrote: > On 17.06.19 22:26, Linus Walleij wrote: > > I think it makes a lot of sense on mechanical pushbuttons to > > implement generic debounce. > > This is, however, not the job of the GPIO driver or is it? If the GPIO block supports it, GPIO provides an API to use a hardware debounce timer. I'e had exotic ideas like pulling the debounce support from the input subsystem into the GPIO subsystem, so whenever a consumer asks for debounce they will get it, sometimes with a software timer sometimes from hardware. But it never became any more than a pipe dream. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] gpio-button-hotplug: gpio-keys: read initial state
On Mon, Jun 17, 2019 at 7:56 PM David Bauer wrote: > Thanks for your suggestion. However, with your suggestion i still see the > ghost press on bootup :( > Just to clarify - I do not see multiple ghost presses, just one. The button > is active low. > > After configuring the GPIO direction to input, the value of the GPIO reads 0 > (pressed). > After ~10ms, this changes to 1 (not pressed). I suppose your proposed > solution does not work > as interrupts are only registered after configuring the GPIO line as input > and the GPIO line > changes after registering the interrupt. So we are reading the interrupt > state too early. Hm this sounds like something that would be solved by debouncing. It might even be a bounce effect of sorts, it can be a capacitance or something in the mechanics causing this. If you look in: drivers/input/keyboard/gpio_keys.c you will see that GPIO keys in the input subsystem has debouncing support. I guess something like this needs to be copied over to the OpenWrt netlink thingie. If the GPIO driver supports debounce (some do, it doesn't look like the ath79 does) that can be utilized. If someone can double-check the ath79 datasheet to check if it can do debounce that'd be great because it would solve this in hardware. > If delays are allowed there, we could add a 20ms delay when configuring the > GPIO line > direction as input. This way we could also assure the line is stable for > "normal" value > reads. We would need to override the direction_input method provided by > gpio-mmio for this. That's like an initial debounce. > Second: > We could store the kernel uptime together with the GPIO line and for how long > interrupts > should be ignored within the driver. This could be checked when an interrupt > is fired. The third alternative is common software debounce. I.e. wait for any value to stabilize before reporting keys. Some extra interrupts more or less doesn't matter, we just frame it with some timer. > I do not really like the second idea as dropping interrupts without feedback > is probably not > what we want. I think it makes a lot of sense on mechanical pushbuttons to implement generic debounce. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] gpio-button-hotplug: gpio-keys: read initial state
On Sun, Jun 16, 2019 at 4:31 PM David Bauer wrote: > It seems the input is indeed not stable after setting the GPIO > direction. With the following patch applied, i get zero ghost presses > and the buttons work as expected. However I'm not sure if this approach > is the right one to fix the underlying issue. It shows what the problem is for sure. delays are forbidden in irqchip callback functions since they are all called from IRQ context with IRQs disabled though. > @@ -96,6 +97,12 @@ static void ath79_gpio_irq_enable(struct irq_data *data) > u32 mask = BIT(irqd_to_hwirq(data)); > unsigned long flags; > > + /* > +* The input can be unstable after configuring GPIO direction. > +* Wait a bit to assert the input is stable. > +*/ > + msleep(25); > + > raw_spin_lock_irqsave(>lock, flags); > ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, mask); > ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask); After this and before the raw_spin_unlock() try to read the status register until it eads zero for the requested IRQ: while (ath79_gpio_read(ctrl, AR71XX_GPIO_REG_INT_PENDING) & mask) {} This way we wait for the status to go low before we allow any IRQs to fire after enableing. Maybe not so good since we may want to turn on IRQs that are asserted at some point, but worth a try. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] ARM: dts: gemini Fix up DNS-313 compatible string
It's a simple typo in the DNS file, which was pretty serious. No scripts were working properly. Fix it up. Signed-off-by: Linus Walleij --- arch/arm/boot/dts/gemini-dlink-dns-313.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/gemini-dlink-dns-313.dts b/arch/arm/boot/dts/gemini-dlink-dns-313.dts index b12504e10f0b..360642a02a48 100644 --- a/arch/arm/boot/dts/gemini-dlink-dns-313.dts +++ b/arch/arm/boot/dts/gemini-dlink-dns-313.dts @@ -11,7 +11,7 @@ / { model = "D-Link DNS-313 1-Bay Network Storage Enclosure"; - compatible = "dlink,dir-313", "cortina,gemini"; + compatible = "dlink,dns-313", "cortina,gemini"; #address-cells = <1>; #size-cells = <1>; -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] gpio-button-hotplug: gpio-keys: read initial state
On Fri, Jun 14, 2019 at 9:28 PM Christian Lamparter wrote: > Maybe he can point to a specifc reason why the interrupt gets triggered > when the module is loaded and how to handle it. Because this behavior > seems to be common between different platforms now and the upstream > gpio-keys (which does work differently!) seems to handle it just fine. > > @Linus: Do you have any inside knowledge about the issue? That when > gpio-keys is loaded (in OpenWrt it's a module due to kernel size > constraint on various routers) the associated interrupt fires and > this results in a ghost key event. Without any detailed knowledge I'd say the most common cause is the underlying GPIO chip implementation. There are often transient line events when the system is powered up and initialized and it is often necessary for the gpio_chip driver to clear any interrupt flags in hardware before setting up the gpio chip, especially the irqchip portions of it. I tried to half-guess what gpio chip this is using and since it is WiFi pro 1200e I guess ths gpio driver is drivers/gpio-ath79.c which does indeed initialize an irqchip without clearing the interrupts first. Can you try this patch, if this solves the problem I will commit it upstream as well: >From ce4b6db51658e0954f97837095393c5fd1416db2 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sat, 15 Jun 2019 10:18:48 +0200 Subject: [PATCH] gpio: ath79: Clear pending IRQs The ath79 gpio driver may emit "ghost interrupts" because pending IRQs are sitting in the latches when we probe the driver. It appears this GPIO block clears interrupts by reading the status register, so read that and toss the result before adding the gpio irqchip. Reported-by: David Bauer Reported-by: Christian Lamparter Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ath79.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c index 0a553d676042..39ccb48c03d5 100644 --- a/drivers/gpio/gpio-ath79.c +++ b/drivers/gpio/gpio-ath79.c @@ -290,6 +290,8 @@ static int ath79_gpio_probe(struct platform_device *pdev) if (np && !of_property_read_bool(np, "interrupt-controller")) return 0; +/* Clear any pending IRQs so we have a clean slate */ +ath79_gpio_read(ctrl, AR71XX_GPIO_REG_INT_PENDING); err = gpiochip_irqchip_add(>gc, _gpio_irqchip, 0, handle_simple_irq, IRQ_TYPE_NONE); if (err) { -- 2.21.0 > I have to add that OpenWrt's > gpio-button-hotplug.c (which registers the gpio-keys and > gpio-keys-polled) is a special, out-of-tree module that sends broadcast > events (netlink) rather than using the input-subsystem (again due > to space issues). This seems like a valid usecase. I guess it may be hard to drive that solution home upstream but at some point it should at least be discussed with Dmitry (the input maintainer) so he can give his view on how resource constrained systems should handle this. I suspect the root cause is the "footprint problem" that hits IOT devices like OpenWrt and I know Nicolas Pitre tried to drive a few approaches upstream to get footprint down, but the experience was somewhat discouraging. I think it's a worthy cause though! Small memory systems should be able to run Linux proper IMO, we just lack the manpower to make it happen. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] gemini: Make a per-board case for ethernet MAC
On Fri, Jun 14, 2019 at 7:24 PM Christian Lamparter wrote: > I put together a patchset in my staging tree starting from > > https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=620462e09afc40602110b82caeb2858903709567 > https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=bbde89504fb6124da5a3f0014025753db4d6ec67 > https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=6096e5208373822d123b8fe4f848b8612f3d04c8 > https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=1d8ddcfc7a00701ab73d7dd06cf5fa420c1a5882 > https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=b106a522001e970378c38279fe598acbc867d0f4 > > Let me know if this works now with the ip tool. Yes! I applied this series and all comes up nicely, right MAC address and writeable root filesystem. Feel free to push this and thanks so much for the help! Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] gemini: Fix up patch format
On Tue, Jun 11, 2019 at 11:28 PM Linus Walleij wrote: > One of the patches were not properly refreshed. Fix it up. > > Signed-off-by: Linus Walleij Bah, drop this patch. I was fixing my own out-of-tree patches :P Sorry for the buzz Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] gemini: Fix up patch format
One of the patches were not properly refreshed. Fix it up. Signed-off-by: Linus Walleij --- .../0008-ARM-dts-Enable-Gemini-flash-access.patch | 7 --- 1 file changed, 7 deletions(-) diff --git a/target/linux/gemini/patches-4.19/0008-ARM-dts-Enable-Gemini-flash-access.patch b/target/linux/gemini/patches-4.19/0008-ARM-dts-Enable-Gemini-flash-access.patch index 26198ece78f9..4a33c43f08c9 100644 --- a/target/linux/gemini/patches-4.19/0008-ARM-dts-Enable-Gemini-flash-access.patch +++ b/target/linux/gemini/patches-4.19/0008-ARM-dts-Enable-Gemini-flash-access.patch @@ -20,8 +20,6 @@ Signed-off-by: Linus Walleij arch/arm/boot/dts/gemini-sq201.dts | 31 +++- 2 files changed, 40 insertions(+), 24 deletions(-) -diff --git a/arch/arm/boot/dts/gemini-dlink-dir-685.dts b/arch/arm/boot/dts/gemini-dlink-dir-685.dts -index 502a361d1fe9..c77fb83986ca 100644 --- a/arch/arm/boot/dts/gemini-dlink-dir-685.dts +++ b/arch/arm/boot/dts/gemini-dlink-dir-685.dts @@ -64,7 +64,6 @@ @@ -86,8 +84,6 @@ index 502a361d1fe9..c77fb83986ca 100644 pinctrl-gmii { mux { function = "gmii"; -diff --git a/arch/arm/boot/dts/gemini-sq201.dts b/arch/arm/boot/dts/gemini-sq201.dts -index 66e2845a3edb..79df6ce5bc6a 100644 --- a/arch/arm/boot/dts/gemini-sq201.dts +++ b/arch/arm/boot/dts/gemini-sq201.dts @@ -41,14 +41,12 @@ @@ -155,6 +151,3 @@ index 66e2845a3edb..79df6ce5bc6a 100644 pinctrl-gmii { mux { function = "gmii"; --- -2.20.1 - -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH v2] gemini: Make root filesystem writeable
The squashfs+jffs2 root filesystem only came up as read-only and the config would not take: [ 25.600237] mount_root: Could not open mtd device: /dev/mtd4 [ 25.634674] mount_root: reading rootfs_data failed [ 25.665346] mount_root: Could not open mtd device: /dev/mtd3 [ 25.699802] mount_root: reading rootfs failed [ 25.726426] mount_root: mounting /dev/root Well that is not very strange since the whole firmware partition is made read-only in the device tree. Let's fix that by augmenting the OpenWrt patch. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Refresh the patch so that it has the right patch format. --- ...gment-DIR-685-partition-table-for-OpenWrt.patch | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/target/linux/gemini/patches-4.19/0020-ARM-dts-Augment-DIR-685-partition-table-for-OpenWrt.patch b/target/linux/gemini/patches-4.19/0020-ARM-dts-Augment-DIR-685-partition-table-for-OpenWrt.patch index bb4076558df4..6ef931c16c00 100644 --- a/target/linux/gemini/patches-4.19/0020-ARM-dts-Augment-DIR-685-partition-table-for-OpenWrt.patch +++ b/target/linux/gemini/patches-4.19/0020-ARM-dts-Augment-DIR-685-partition-table-for-OpenWrt.patch @@ -1,7 +1,7 @@ -From 854934b0ce8e758ce581f5ddbc30e618ab46fbdb Mon Sep 17 00:00:00 2001 +From ea99e7570882df53478f9b5fa5886a6e92fc2c7f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 11 Mar 2019 15:44:29 +0100 -Subject: [PATCH 2/2] ARM: dts: Augment DIR-685 partition table for OpenWrt +Subject: [PATCH] ARM: dts: Augment DIR-685 partition table for OpenWrt Rename the firmware partition so that the firmware MTD splitter will do its job, drop the rootfs arguments as @@ -9,8 +9,8 @@ the MTD splitter will set this up automatically. Signed-off-by: Linus Walleij --- - arch/arm/boot/dts/gemini-dlink-dir-685.dts | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) + arch/arm/boot/dts/gemini-dlink-dir-685.dts | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) --- a/arch/arm/boot/dts/gemini-dlink-dir-685.dts +++ b/arch/arm/boot/dts/gemini-dlink-dir-685.dts @@ -23,7 +23,7 @@ Signed-off-by: Linus Walleij stdout-path = "uart0:19200n8"; }; -@@ -286,7 +286,8 @@ +@@ -286,9 +286,9 @@ * this is called "upgrade" on the vendor system. */ partition@4 { @@ -31,5 +31,7 @@ Signed-off-by: Linus Walleij + compatible = "wrg"; + label = "firmware"; reg = <0x0004 0x01f4>; - read-only; +- read-only; }; + /* RGDB, Residental Gateway Database? */ + partition@1f8 { -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/3 v2] gemini: Make a per-board case for ethernet MAC
The DNS-313 isn't the only special board so let's bite the bullet and create a case ladder in preparation for DIR-685. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase on the new patch using library functions --- .../lib/preinit/05_set_ether_mac_gemini | 28 +++ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini index a79ee5057ffc..a51c223d85c9 100644 --- a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini +++ b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini @@ -4,6 +4,22 @@ . /lib/functions/system.sh set_ether_mac() { + case $(board_name) in + dlink,dns-313) + # The DNS-313 has a special field in its RedBoot + # binary that we need to check + part=$(find_mtd_part RedBoot) + if [ ! -z $part ] ; then + DEVID="$(dd if=$part bs=1 skip=119508 count=7 2>/dev/null)" + if [ "x$DEVID" = "xdns-313" ] ; then + MAC1=$(mtd_get_mac_binary RedBoot 119540) + ifconfig eth0 hw ether $MAC1 2>/dev/null + return 0 + fi + fi + ;; + esac + # Most devices have a standard "VCTL" partition part=$(find_mtd_part VCTL) if [ ! -z $part ] ; then @@ -14,18 +30,6 @@ set_ether_mac() { ifconfig eth1 hw ether $MAC2 2>/dev/null return 0 fi - - # The DNS-313 has a special field in its RedBoot - # binary that we need to check - part=$(find_mtd_part RedBoot) - if [ ! -z $part ] ; then - DEVID="$(dd if=$part bs=1 skip=119508 count=7 2>/dev/null)" - if [ "x$DEVID" = "xdns-313" ] ; then - MAC1=$(mtd_get_mac_binary RedBoot 119540) - ifconfig eth0 hw ether $MAC1 2>/dev/null - return 0 - fi - fi } boot_hook_add preinit_main set_ether_mac -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 3/3 v2] gemini: Fix MAC address assignment for DIR-685
The DIR-685 has the MAC addresses in the RedBoot code just like DNS-313. Check some magic numbers to determine that the MAC address is where we want it and extract it from RedBoot. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase on the other patches - Use library functions to get partition and hex MAC address - Use ip to set up mac address --- .../lib/preinit/05_set_ether_mac_gemini | 15 +++ 1 file changed, 15 insertions(+) diff --git a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini index a51c223d85c9..f702e0458c2e 100644 --- a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini +++ b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini @@ -18,6 +18,21 @@ set_ether_mac() { fi fi ;; + dlink,dir-685) + # The DIR-685 has a special field in its RedBoot + # binary that we need to check + part=$(find_mtd_part RedBoot) + if [ ! -z $part ] ; then + DEVID="$(dd if=$part bs=1 skip=81516 count=7 2>/dev/null)" + if [ "x$DEVID" = "xILI9322" ] ; then + MAC1=$(mtd_get_mac_binary RedBoot 95040) + MAC2=$(mtd_get_mac_binary RedBoot 95046) + ifconfig eth0 hw ether $MAC1 2>/dev/null + ifconfig eth1 hw ether $MAC2 2>/dev/null + return 0 + fi + fi + ;; esac # Most devices have a standard "VCTL" partition -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/3 v2] gemini: Use library functions to assign MAC address
This simplifies the ethernet address extraction script by using standard library functions to locate the MTD partitions and extract ethernet address from a binary offset location in the flash. Suggested-by: Christian Lamparter Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - New patch prepended to the series - Hold back switchover to use "ip" rather than "ifconfig". ip link set eth0 address 00:50:c2:11:11:11 returns ip: socket(AF_PACKET,2,0): Address family not supported by protocol We can fix up the use of "ip" when we know why it's not working. --- .../lib/preinit/05_set_ether_mac_gemini | 19 +++ 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini index 1ce5c8067ef0..a79ee5057ffc 100644 --- a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini +++ b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini @@ -1,11 +1,14 @@ #!/bin/sh +. /lib/functions.sh +. /lib/functions/system.sh + set_ether_mac() { # Most devices have a standard "VCTL" partition - CONFIG_PARTITION="$(grep "VCTL" /proc/mtd | cut -d: -f1)" - if [ ! -z $CONFIG_PARTITION ] ; then - MAC1="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f2|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')" - MAC2="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f8|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')" + part=$(find_mtd_part VCTL) + if [ ! -z $part ] ; then + MAC1="$(strings $part |grep MAC|cut -d: -f2|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')" + MAC2="$(strings $part |grep MAC|cut -d: -f8|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')" ifconfig eth0 hw ether $MAC1 2>/dev/null ifconfig eth1 hw ether $MAC2 2>/dev/null @@ -14,11 +17,11 @@ set_ether_mac() { # The DNS-313 has a special field in its RedBoot # binary that we need to check - CONFIG_PARTITION="$(grep "RedBoot" /proc/mtd | cut -d: -f1)" - if [ ! -z $CONFIG_PARTITION ] ; then - DEVID="$(dd if=/dev/mtdblock0 bs=1 skip=119508 count=7 2>/dev/null)" + part=$(find_mtd_part RedBoot) + if [ ! -z $part ] ; then + DEVID="$(dd if=$part bs=1 skip=119508 count=7 2>/dev/null)" if [ "x$DEVID" = "xdns-313" ] ; then - MAC1="$(dd if=/dev/mtdblock0 bs=1 skip=119540 count=6 2>/dev/null | hexdump -n6 -e '/1 ":%02X"' | sed s/^://g)" + MAC1=$(mtd_get_mac_binary RedBoot 119540) ifconfig eth0 hw ether $MAC1 2>/dev/null return 0 fi -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] gemini: Make a per-board case for ethernet MAC
Hi Christian, I worked in all the changes you requested until I got to this: On Thu, May 30, 2019 at 12:46 AM Christian Lamparter wrote: > > + ifconfig eth0 hw ether $MAC1 2>/dev/null > > I guess while we are at it, why not change it to > "ip link set dev eth0 address $MAC1" Testing this: ip link set eth0 address 00:50:c2:11:11:11 ip: socket(AF_PACKET,2,0): Address family not supported by protocol Any hints? According to the help it should work ... Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] kernel: Move some DSA config options to generic config
On Sun, May 26, 2019 at 11:46 PM Hauke Mehrtens wrote: > On 5/24/19 11:09 PM, Linus Walleij wrote: > > Hi Hauke, > > > > this patch regresses my Gemini systems because I really need these switches > > to come up and this patch: > > Sorry Linus, > > I didn't know that they are needed, I assumed that they were > accidentally added for the gemini target, on the ath79 target these > options were not defined by the build system for kernel 4.19 at all. Don't worry I find all the bugs :) For ath79 CONFIG_NET_DSA_VITESSE_VSC73XX it is however pretty relevant I think! The AR71xx v4.14 kernel at ar71xx/files/drivers/spi/spi-vsc7385.c there is some OpenWrt custom driver for the VSC7385 that is used by the PB44 board and added in patch: patches-4.14/606-MIPS-ath79-pb44-fixes.patch this should be covered by the new upstream driver in v4.19, but I don't have this router so I cannot really enable it. I think it will be possible to just enable the driver for use without any of the special firmware that is provided for PB44 in the OpenWrt tree. The best would be if PB44 would be converted to device tree to use it, but I suppose it is also possible to patch drivers/net/dsa/vitesse-vsc73xx.c to use the boardfile. > Are both switches found on some of the gemini board? I will add them again. Yep the RTL8366RB is on the DIR-685 and the Vitesse variants are on the SQ201. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 3/3] gemini: Fix MAC address assignment for DIR-685
The DIR-685 has the MAC addresses in the RedBoot code just like DNS-313. Check some magic numbers to determine that the MAC address is where we want it and extract it from RedBoot. Signed-off-by: Linus Walleij --- .../lib/preinit/05_set_ether_mac_gemini | 15 +++ 1 file changed, 15 insertions(+) diff --git a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini index 6072e828c678..ecf4a8238143 100644 --- a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini +++ b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini @@ -18,6 +18,21 @@ set_ether_mac() { fi fi ;; + dlink,dir-685) + # The DIR-685 has a special field in its RedBoot + # binary that we need to check + CONFIG_PARTITION="$(grep "RedBoot" /proc/mtd | cut -d: -f1)" + if [ ! -z $CONFIG_PARTITION ] ; then + DEVID="$(dd if=/dev/mtdblock0 bs=1 skip=81516 count=7 2>/dev/null)" + if [ "x$DEVID" = "xILI9322" ] ; then + MAC1="$(dd if=/dev/mtdblock0 bs=1 skip=95040 count=6 2>/dev/null | hexdump -n6 -v -e '/1 ":%02X"' | sed s/^://g)" + MAC2="$(dd if=/dev/mtdblock0 bs=1 skip=95046 count=6 2>/dev/null | hexdump -n6 -v -e '/1 ":%02X"' | sed s/^://g)" + ifconfig eth0 hw ether $MAC1 2>/dev/null + ifconfig eth1 hw ether $MAC2 2>/dev/null + return 0 + fi + fi + ;; esac # Most devices have a standard "VCTL" partition -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/3] gemini: Fix possible hexdump error on MAC assignment
If a MAC address is for example 00:50:c2:11:11:11 using hexdump to extract this from raw bytes in the flash will yield "00:50:c2:11*" with the asterisk indicating "more of the same". This will inhibit the MAC address from being assigned correctly, so fix it by passing -v to hexdump. Signed-off-by: Linus Walleij --- .../linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini index ebd3ae0f55c5..6072e828c678 100644 --- a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini +++ b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini @@ -12,7 +12,7 @@ set_ether_mac() { if [ ! -z $CONFIG_PARTITION ] ; then DEVID="$(dd if=/dev/mtdblock0 bs=1 skip=119508 count=7 2>/dev/null)" if [ "x$DEVID" = "xdns-313" ] ; then - MAC1="$(dd if=/dev/mtdblock0 bs=1 skip=119540 count=6 2>/dev/null | hexdump -n6 -e '/1 ":%02X"' | sed s/^://g)" + MAC1="$(dd if=/dev/mtdblock0 bs=1 skip=119540 count=6 2>/dev/null | hexdump -n6 -v -e '/1 ":%02X"' | sed s/^://g)" ifconfig eth0 hw ether $MAC1 2>/dev/null return 0 fi -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/3] gemini: Make a per-board case for ethernet MAC
The DNS-313 isn't the only special board so let's bite the bullet and create a case ladder in preparation for DIR-685. Signed-off-by: Linus Walleij --- .../lib/preinit/05_set_ether_mac_gemini | 30 --- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini index 1ce5c8067ef0..ebd3ae0f55c5 100644 --- a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini +++ b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini @@ -1,6 +1,25 @@ #!/bin/sh set_ether_mac() { + + . /lib/functions.sh + + case $(board_name) in + dlink,dns-313) + # The DNS-313 has a special field in its RedBoot + # binary that we need to check + CONFIG_PARTITION="$(grep "RedBoot" /proc/mtd | cut -d: -f1)" + if [ ! -z $CONFIG_PARTITION ] ; then + DEVID="$(dd if=/dev/mtdblock0 bs=1 skip=119508 count=7 2>/dev/null)" + if [ "x$DEVID" = "xdns-313" ] ; then + MAC1="$(dd if=/dev/mtdblock0 bs=1 skip=119540 count=6 2>/dev/null | hexdump -n6 -e '/1 ":%02X"' | sed s/^://g)" + ifconfig eth0 hw ether $MAC1 2>/dev/null + return 0 + fi + fi + ;; + esac + # Most devices have a standard "VCTL" partition CONFIG_PARTITION="$(grep "VCTL" /proc/mtd | cut -d: -f1)" if [ ! -z $CONFIG_PARTITION ] ; then @@ -12,17 +31,6 @@ set_ether_mac() { return 0 fi - # The DNS-313 has a special field in its RedBoot - # binary that we need to check - CONFIG_PARTITION="$(grep "RedBoot" /proc/mtd | cut -d: -f1)" - if [ ! -z $CONFIG_PARTITION ] ; then - DEVID="$(dd if=/dev/mtdblock0 bs=1 skip=119508 count=7 2>/dev/null)" - if [ "x$DEVID" = "xdns-313" ] ; then - MAC1="$(dd if=/dev/mtdblock0 bs=1 skip=119540 count=6 2>/dev/null | hexdump -n6 -e '/1 ":%02X"' | sed s/^://g)" - ifconfig eth0 hw ether $MAC1 2>/dev/null - return 0 - fi - fi } boot_hook_add preinit_main set_ether_mac -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] kernel: Move some DSA config options to generic config
Hi Hauke, this patch regresses my Gemini systems because I really need these switches to come up and this patch: On Sun, May 12, 2019 at 7:32 PM Hauke Mehrtens wrote: > diff --git a/target/linux/gemini/config-4.19 b/target/linux/gemini/config-4.19 > CONFIG_NET_DSA=y > -# CONFIG_NET_DSA_LEGACY is not set > -CONFIG_NET_DSA_REALTEK_SMI=y > -CONFIG_NET_DSA_VITESSE_VSC73XX=y Deletes my selected DSA switches and: > +# CONFIG_NET_DSA_REALTEK_SMI is not set > # CONFIG_NET_DSA_SMSC_LAN9303_I2C is not set > # CONFIG_NET_DSA_SMSC_LAN9303_MDIO is not set > # CONFIG_NET_DSA_TAG_DSA is not set > # CONFIG_NET_DSA_TAG_EDSA is not set > +# CONFIG_NET_DSA_VITESSE_VSC73XX is not set Adds them to the generic config as "not set" (disabled). It seems this needs to be partially reverted for Gemini to work, but not completely. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] gemini: Make root filesystem writeable
The squashfs+jffs2 root filesystem only came up as read-only and the config would not take: [ 25.600237] mount_root: Could not open mtd device: /dev/mtd4 [ 25.634674] mount_root: reading rootfs_data failed [ 25.665346] mount_root: Could not open mtd device: /dev/mtd3 [ 25.699802] mount_root: reading rootfs failed [ 25.726426] mount_root: mounting /dev/root Well that is not very strange since the whole firmware partition is made read-only in the device tree. Let's fix that by augmenting the OpenWrt patch. Signed-off-by: Linus Walleij --- ...-DIR-685-partition-table-for-OpenWrt.patch | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/target/linux/gemini/patches-4.19/0020-ARM-dts-Augment-DIR-685-partition-table-for-OpenWrt.patch b/target/linux/gemini/patches-4.19/0020-ARM-dts-Augment-DIR-685-partition-table-for-OpenWrt.patch index bb4076558df4..4be6545186c0 100644 --- a/target/linux/gemini/patches-4.19/0020-ARM-dts-Augment-DIR-685-partition-table-for-OpenWrt.patch +++ b/target/linux/gemini/patches-4.19/0020-ARM-dts-Augment-DIR-685-partition-table-for-OpenWrt.patch @@ -1,7 +1,7 @@ -From 854934b0ce8e758ce581f5ddbc30e618ab46fbdb Mon Sep 17 00:00:00 2001 +From ea99e7570882df53478f9b5fa5886a6e92fc2c7f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 11 Mar 2019 15:44:29 +0100 -Subject: [PATCH 2/2] ARM: dts: Augment DIR-685 partition table for OpenWrt +Subject: [PATCH] ARM: dts: Augment DIR-685 partition table for OpenWrt Rename the firmware partition so that the firmware MTD splitter will do its job, drop the rootfs arguments as @@ -9,9 +9,11 @@ the MTD splitter will set this up automatically. Signed-off-by: Linus Walleij --- - arch/arm/boot/dts/gemini-dlink-dir-685.dts | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) + arch/arm/boot/dts/gemini-dlink-dir-685.dts | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) +diff --git a/arch/arm/boot/dts/gemini-dlink-dir-685.dts b/arch/arm/boot/dts/gemini-dlink-dir-685.dts +index 50ff65d95f26..4ae0bb95be20 100644 --- a/arch/arm/boot/dts/gemini-dlink-dir-685.dts +++ b/arch/arm/boot/dts/gemini-dlink-dir-685.dts @@ -20,7 +20,7 @@ @@ -23,7 +25,7 @@ Signed-off-by: Linus Walleij stdout-path = "uart0:19200n8"; }; -@@ -286,7 +286,8 @@ +@@ -286,9 +286,9 @@ * this is called "upgrade" on the vendor system. */ partition@4 { @@ -31,5 +33,10 @@ Signed-off-by: Linus Walleij + compatible = "wrg"; + label = "firmware"; reg = <0x0004 0x01f4>; - read-only; +- read-only; }; + /* RGDB, Residental Gateway Database? */ + partition@1f8 { +-- +2.20.1 + -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH v3] gemini: Support sysupgrade on DIR-685
On Mon, May 20, 2019 at 10:56 PM Petr Štetiar wrote: > And merged[1] it into my staging tree, so please check it and let me know if > it's ok with you or if you prefer to go with v4, thanks. Thanks man, sorry if I'm a bit confused around how you want the sysupgrade to work. Maybe we could open a documentation page for new devices, like here is how we want you to implement sysupgrade, I had a hard time to figure out that all was circuling around the platform.sh script and how that was called from the core sysupgrade. I can start while I still have it in fresh memory and you can chime in on how you want people to do generic checksum etc. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH v3] gemini: Support sysupgrade on DIR-685
This makes sysupgrade work on the D-Link DIR-685 after initial factory install. We create the platform.sh script to support sysupgrade on more targets as we move on with sysupgrade support. Cc: Petr Štetiar Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Drop the WRGG magic check: after thinking about it this check only MD5-sums the kernel on the sysupgrade images so it is not helpful for checking the stuff we actually write to flash, including the rootfs. So skip it on sysupgrade. ChangeLog v1->v2: - Append metadata to sysupgrade image - Require metadata in platform.sh - Strip comments --- .../gemini/base-files/lib/upgrade/platform.sh | 40 +++ target/linux/gemini/image/Makefile| 5 ++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 target/linux/gemini/base-files/lib/upgrade/platform.sh diff --git a/target/linux/gemini/base-files/lib/upgrade/platform.sh b/target/linux/gemini/base-files/lib/upgrade/platform.sh new file mode 100644 index ..eaaf9d734e13 --- /dev/null +++ b/target/linux/gemini/base-files/lib/upgrade/platform.sh @@ -0,0 +1,40 @@ +REQUIRE_IMAGE_METADATA=1 + +platform_find_part_size() { + local first dev size erasesize name + while read dev size erasesize name; do + name=${name#'"'}; name=${name%'"'} + [ "$name" = "$1" ] && { + echo "$size" + break + } + done < /proc/mtd +} + +platform_check_image() { + local board=$(board_name) + + case "$board" in + dlink,dir-685 ) + return 0 + ;; + esac + + echo "Sysupgrade is not yet supported on $board." + return 1 +} + +platform_do_upgrade() { + local board=$(board_name) + + v "board=$board" + case "$board" in + dlink,dir-685 ) + PART_NAME=firmware + default_do_upgrade "$ARGV" + ;; + *) + + ;; + esac +} diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index 8fec250f186a..3339cd2467a9 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -115,6 +115,7 @@ define Device/Default KERNEL_NAME := zImage KERNEL := kernel-bin | append-dtb BLOCKSIZE := 128k + SUPPORTED_DEVICES := $(subst _,$(comma),$(1)) endef # A reasonable set of default packages handling the NAS type @@ -143,9 +144,11 @@ define Device/dlink_dir-685 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \ kmod-switch-rtl8366rb swconfig \ kmod-rt2800-pci - IMAGES := factory.bin + IMAGES := factory.bin sysupgrade.bin # Pad to 128k erase blocks with 160 bytes WRGG header IMAGE/factory.bin := append-kernel | pad-offset 128k 160 | append-rootfs | dir685-pad-rootfs | dir685-image + IMAGE/sysupgrade.bin := append-kernel | pad-offset 128k 160 | dir685-image | append-rootfs | dir685-pad-rootfs | append-metadata + SUPPORTED_DEVICES += dlink,dir-685 endef TARGET_DEVICES += dlink_dir-685 -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/2] mtd: Make fixwrgg command work on DIR-685
The D-Link DIR-685 has the same problem as the D-Link DAP-2695: when flashing the factory image, the checksum includes the whole flashed image, even the rootfs_data part with the end of filesystem mark. Also the whole flashed image is stored in the flash, so on the first boot, the whole rootfs image is loaded into memory with the kernel. This is fixed using the fixwrgg command to mtd, but for this to work we need to make fixwrgg work with the Little-Endian ARM DIR-685. The code tries to be endian agnostic but this fails because the WRGG image loader doesn't. On ARM, the file size is stored in little endian format, and on big-endian systems it is stored in big endian format, so we can just drop all the friendly htonl() that will make the shdr->size big endian: this will actually break the little endian systems, and on the big endian systems the native endianness will still be correct. The magic number is always stored in little endian format however, so make sure this is always read in LE32 format. I chose to create a straight-forward le32_to_cpu() static inline that IMO is simple and easy to read. Cc: Stijn Tintel Signed-off-by: Linus Walleij --- It'd be great if someone could verify that this works with DAP-2695 as well. The code is inspired by the kernel mtdsplit code in target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c --- package/system/mtd/src/wrgg.c | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/package/system/mtd/src/wrgg.c b/package/system/mtd/src/wrgg.c index e0b5ca172d12..c62f9f550736 100644 --- a/package/system/mtd/src/wrgg.c +++ b/package/system/mtd/src/wrgg.c @@ -39,13 +39,10 @@ #include "wrgg.h" #include "md5.h" -#if __BYTE_ORDER == __BIG_ENDIAN -#define STORE32_LE(X) X) & 0x00FF) << 24) | (((X) & 0xFF00) << 8) | (((X) & 0x00FF) >> 8) | (((X) & 0xFF00) >> 24)) -#elif __BYTE_ORDER == __LITTLE_ENDIAN -#define STORE32_LE(X) (X) -#else -#error unknown endianness! -#endif +static inline uint32_t le32_to_cpu(uint8_t *buf) +{ + return buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24; +} ssize_t pread(int fd, void *buf, size_t count, off_t offset); ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); @@ -94,7 +91,7 @@ wrgg_fix_md5(struct wrgg03_header *shdr, int fd, size_t data_offset, size_t data } /* update the size in the image */ - shdr->size = htonl(data_size); + shdr->size = data_size; /* update the checksum in the image */ memcpy(shdr->digest, digest, sizeof(digest)); @@ -147,12 +144,14 @@ mtd_fixwrgg(const char *mtd, size_t offset, size_t data_size) } shdr = (struct wrgg03_header *)(first_block + offset); - if (shdr->magic1 != htonl(STORE32_LE(WRGG03_MAGIC))) { - fprintf(stderr, "magic1 %x\n", shdr->magic1); - fprintf(stderr, "htonl(WRGG03_MAGIC) %x\n", WRGG03_MAGIC); + + /* The magic is always stored in little-endian byte order */ + if (le32_to_cpu((uint8_t *)>magic1) != WRGG03_MAGIC) { + fprintf(stderr, "magic1 = %x\n", shdr->magic1); + fprintf(stderr, "WRGG03_MAGIC = %x\n", WRGG03_MAGIC); fprintf(stderr, "No WRGG header found\n"); exit(1); - } else if (!ntohl(shdr->size)) { + } else if (!shdr->size) { fprintf(stderr, "WRGG entity with empty image\n"); exit(1); } @@ -160,8 +159,8 @@ mtd_fixwrgg(const char *mtd, size_t offset, size_t data_size) data_offset = offset + sizeof(struct wrgg03_header); if (!data_size) data_size = mtdsize - data_offset; - if (data_size > ntohl(shdr->size)) - data_size = ntohl(shdr->size); + if (data_size > shdr->size) + data_size = shdr->size; if (wrgg_fix_md5(shdr, fd, data_offset, data_size)) goto out; -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/2] gemini: Fix up firmware checksum on DIR-685
Using the same method as the D-Link DAP-2695 A1 we use the "mtd" tool to augment the firmware checkum in flash on first boot of a new firmware on the D-Link DIR-685. We need to augment the Makefile for "mtd" to build in the special WRGG fixup support for Gemini as well. This works around the problem of the machine not booting after factory install unless the sysupgrade is applied immediately. Based on commit e3875350f3e4185020b64e0588bba521cd1d6e64 "ar71xx: add support for D-Link DAP-2695 rev. A1" Cc: Stijn Tintel Signed-off-by: Linus Walleij --- package/system/mtd/src/Makefile | 1 + .../etc/uci-defaults/09_fix-checksum | 20 +++ 2 files changed, 21 insertions(+) create mode 100644 target/linux/gemini/base-files/etc/uci-defaults/09_fix-checksum diff --git a/package/system/mtd/src/Makefile b/package/system/mtd/src/Makefile index 08a9fb295dac..e3265fe9f1b9 100644 --- a/package/system/mtd/src/Makefile +++ b/package/system/mtd/src/Makefile @@ -8,6 +8,7 @@ obj.wrg = wrg.o md5.o obj.wrgg = wrgg.o md5.o obj.tpl = tpl_ramips_recoveryflag.o obj.ar71xx = trx.o $(obj.seama) $(obj.wrgg) +obj.gemini = $(obj.wrgg) obj.brcm = trx.o obj.brcm47xx = $(obj.brcm) obj.bcm53xx = $(obj.brcm) $(obj.seama) diff --git a/target/linux/gemini/base-files/etc/uci-defaults/09_fix-checksum b/target/linux/gemini/base-files/etc/uci-defaults/09_fix-checksum new file mode 100644 index ..5f79d1a65caa --- /dev/null +++ b/target/linux/gemini/base-files/etc/uci-defaults/09_fix-checksum @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Copyright (C) 2019 OpenWrt.org +# + +. /lib/functions.sh + +board=$(board_name) + +fixwrgg() { + local kernel_size=$(sed -n 's/mtd[0-9]*: \([0-9a-f]*\).*"kernel".*/\1/p' /proc/mtd) + + [ "$kernel_size" ] && mtd -c 0x$kernel_size fixwrgg firmware +} + +case "$board" in +dlink,dir-685) + fixwrgg + ;; +esac -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH v2] gemini: Support sysupgrade on DIR-685
[Adding Stijn Tintel as DAP-2695 A1 maintainer, I think he want to know how we solve this.] On Tue, May 14, 2019 at 2:07 PM Petr Štetiar wrote: > Linus Walleij [2019-05-14 13:16:50]: > > On Tue, May 14, 2019 at 10:30 AM Petr Štetiar wrote: > > > > > Linus Walleij [2019-05-12 21:13:17]: > > > > > > +REQUIRE_IMAGE_METADATA=1 > > > > > > once you set this, you don't need to check for the image magic, do you? > > > If so, > > > please provide the reason for that. > > > > The image magic is necessary for the boot loader to recognize > > and boot the image. Since flashing an image without this magic > > will brick the device, > > bricking the device is a strong wording, as brick means, that you can't use > any recovery method and you probably need soldering iron at least. It seems to > me, that you can just render the device unbootable, right? Yeah, you need a soldering iron if it goes that far. A proper UART gives a console that can recover the machine. > > I feel it should be check as a "better safe than sorry" measure, so we > > cannot under any circumstances flash something that the router cannot boot. > > I think, that metadata and JSON parsing is tad more complex and thus more > advanced validity checking then your proposed first 4-byte header check. > Really, how could you be sure, that any of the following bytes past this > header are valid, thus still won't render flashed device unbootable. Yeah the 4 bytes are just an indication that the header is intact and we're not flashing rubbish. There is some additional checksums etc in the header as well, see below. > > Do you want me to add this to the commit message? > > I see no point, really. > > > In theory yes but in so many practical situations I have muttered the words > > "that should not happen" and that is why I feel it is better to have double > > safety checks. > > It makes no sense to pretend any safety here, both solutions (4-byte header > check, unsigned metadata) are just poor man's workarounds. Should you need any > safety, then enforce only signed images (or add some functionality to metadata > handling which could check hash of complete image, not just 4-byte header). Actually there is some safety since the DIR-685 has all that. Just checking the 4 bytes in the header is a quick sanity check. The check comes from target/linux/ar71xx/base-files/lib/upgrade/platform.sh by the way, as the same is used in D-Link DAP-2695 A1. The full header format can be seen in tools/firmware-utils/src/mkwrggimg.c and includes a MD5 digest. This MD5 digest is checked by the ROM of the machine every time it boots. So what happens in this case is that when we add another checksum around this checksummed image. I guess I could insist on writing a utility in C to check that custom MD5 sum before we flash, it has a nice "being close to what the target wants" feeling about it. But on the other hand it could be nice that it is done according to the OpenWrt standard, and what really matters is that some checksum is checked, so I guess I will go with your suggestion unless the DAP-2695 A1 people have some other opinion? Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH v2] gemini: Support sysupgrade on DIR-685
On Tue, May 14, 2019 at 10:30 AM Petr Štetiar wrote: > Linus Walleij [2019-05-12 21:13:17]: > > +REQUIRE_IMAGE_METADATA=1 > > once you set this, you don't need to check for the image magic, do you? If so, > please provide the reason for that. The image magic is necessary for the boot loader to recognize and boot the image. Since flashing an image without this magic will brick the device, I feel it should be check as a "better safe than sorry" measure, so we cannot under any circumstances flash something that the router cannot boot. Do you want me to add this to the commit message? > Generated image is simply going to contain > list of compatible boards in it's metadata JSON (comming from > SUPPORTED_DEVICES variable) so I think, that this generic check should be > enough. In theory yes but in so many practical situations I have muttered the words "that should not happen" and that is why I feel it is better to have double safety checks. > > +platform_find_part_size() { > > + local first dev size erasesize name > > + while read dev size erasesize name; do > > + name=${name#'"'}; name=${name%'"'} > > + [ "$name" = "$1" ] && { > > + echo "$size" > > + break > > + } > > + done < /proc/mtd > > +} > > Why is this needed? I don't see it being used anywhere. I'll drop it. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH v2] gemini: Support sysupgrade on DIR-685
This makes sysupgrade work on the D-Link DIR-685 after initial factory install. We create the platform.sh script to support sysupgrade on more targets as we move on with sysupgrade support. Cc: Petr Štetiar Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Append metadata to sysupgrade image - Require metadata in platform.sh - Strip comments --- .../gemini/base-files/lib/upgrade/platform.sh | 50 +++ target/linux/gemini/image/Makefile| 5 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 target/linux/gemini/base-files/lib/upgrade/platform.sh diff --git a/target/linux/gemini/base-files/lib/upgrade/platform.sh b/target/linux/gemini/base-files/lib/upgrade/platform.sh new file mode 100644 index ..5f7a2117cb3b --- /dev/null +++ b/target/linux/gemini/base-files/lib/upgrade/platform.sh @@ -0,0 +1,50 @@ +REQUIRE_IMAGE_METADATA=1 + +wrgg_get_image_magic() { + get_image "$@" | dd bs=4 count=1 skip=8 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' +} + +platform_find_part_size() { + local first dev size erasesize name + while read dev size erasesize name; do + name=${name#'"'}; name=${name%'"'} + [ "$name" = "$1" ] && { + echo "$size" + break + } + done < /proc/mtd +} + +platform_check_image() { + local board=$(board_name) + + case "$board" in + dlink,dir-685 ) + local magic=$(wrgg_get_image_magic "$1") + [ "$magic" != "21030820" ] && { + echo "Invalid image. Bad magic for DIR-685." + return 1 + } + echo "Image looks OK" + return 0 + ;; + esac + + echo "Sysupgrade is not yet supported on $board." + return 1 +} + +platform_do_upgrade() { + local board=$(board_name) + + v "board=$board" + case "$board" in + dlink,dir-685 ) + PART_NAME=firmware + default_do_upgrade "$ARGV" + ;; + *) + + ;; + esac +} diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index 8fec250f186a..3339cd2467a9 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -115,6 +115,7 @@ define Device/Default KERNEL_NAME := zImage KERNEL := kernel-bin | append-dtb BLOCKSIZE := 128k + SUPPORTED_DEVICES := $(subst _,$(comma),$(1)) endef # A reasonable set of default packages handling the NAS type @@ -143,9 +144,11 @@ define Device/dlink_dir-685 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \ kmod-switch-rtl8366rb swconfig \ kmod-rt2800-pci - IMAGES := factory.bin + IMAGES := factory.bin sysupgrade.bin # Pad to 128k erase blocks with 160 bytes WRGG header IMAGE/factory.bin := append-kernel | pad-offset 128k 160 | append-rootfs | dir685-pad-rootfs | dir685-image + IMAGE/sysupgrade.bin := append-kernel | pad-offset 128k 160 | dir685-image | append-rootfs | dir685-pad-rootfs | append-metadata + SUPPORTED_DEVICES += dlink,dir-685 endef TARGET_DEVICES += dlink_dir-685 -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] gemini: Support sysupgrade on DIR-685
This makes sysupgrade work on the D-Link DIR-685 after initial factory install. We create the platform.sh script to support sysupgrade on more targets as we move on with sysupgrade support. Signed-off-by: Linus Walleij --- .../gemini/base-files/lib/upgrade/platform.sh | 54 +++ target/linux/gemini/image/Makefile| 3 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 target/linux/gemini/base-files/lib/upgrade/platform.sh diff --git a/target/linux/gemini/base-files/lib/upgrade/platform.sh b/target/linux/gemini/base-files/lib/upgrade/platform.sh new file mode 100644 index ..0c6fc44ee725 --- /dev/null +++ b/target/linux/gemini/base-files/lib/upgrade/platform.sh @@ -0,0 +1,54 @@ +wrgg_get_image_magic() { + get_image "$@" | dd bs=4 count=1 skip=8 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' +} + +platform_find_part_size() { + local first dev size erasesize name + while read dev size erasesize name; do + name=${name#'"'}; name=${name%'"'} + [ "$name" = "$1" ] && { + echo "$size" + break + } + done < /proc/mtd +} + +platform_check_image() { + local board=$(board_name) + # TODO: check size of sysupgrade image + + case "$board" in + dlink,dir-685 ) + local magic=$(wrgg_get_image_magic "$1") + [ "$magic" != "21030820" ] && { + echo "Invalid image. Bad magic for DIR-685." + return 1 + } + echo "Image looks OK" + return 0 + ;; + esac + + echo "Sysupgrade is not yet supported on $board." + return 1 +} + +platform_do_upgrade() { + local board=$(board_name) + + v "board=$board" + case "$board" in + dlink,dir-685 ) + # This will overwrite "firmware" which means that the + # partitions "kernel", "rootfs" and "rootfs_data" get + # overwritten in the flash. The "kernel" image has the + # necessary boot loader magic attached to it, and after + # the "rootfs" there is an empty space marker for "rootfs_data" + PART_NAME=firmware + default_do_upgrade "$ARGV" + ;; + *) + + ;; + esac +} diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index 8fec250f186a..a7001eb0068a 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -143,9 +143,10 @@ define Device/dlink_dir-685 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \ kmod-switch-rtl8366rb swconfig \ kmod-rt2800-pci - IMAGES := factory.bin + IMAGES := factory.bin sysupgrade.bin # Pad to 128k erase blocks with 160 bytes WRGG header IMAGE/factory.bin := append-kernel | pad-offset 128k 160 | append-rootfs | dir685-pad-rootfs | dir685-image + IMAGE/sysupgrade.bin := append-kernel | pad-offset 128k 160 | dir685-image | append-rootfs | dir685-pad-rootfs endef TARGET_DEVICES += dlink_dir-685 -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Commit 8dcc1087602e breaks FA526 (Gemini) compile
On Thu, May 2, 2019 at 12:30 AM Boris Krasnovskiy wrote: > Crash during init that you can see, is pretty far along in the boot process, > so toolchain likely correct. I found the problem, actually the toolchain was incorrect, but that was a sideffect of the build system. After applying this patch a mere make menuconfig && make clean && make will not do it, you have to rm -rf build_dir. After I did this and rebuilt the whole universe overnight it works again, so I am happy now! :D Thanks for your help anyway! Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] Commit 8dcc1087602e breaks FA526 (Gemini) compile
Hi Boris & friends, commit 8dcc1087602e2dd606e4f6e81a06aee62cfd4f4c "toolchain: ARM: Fix toolchain compilation for gcc 8.x" regresses the Gemini (FA526-based). I cannot quite see how. I noticed init crashed with the latest OpenWrt codebase and bisected it down to this commit. Before the commit include/target.mk has: ifneq ($(findstring arm,$(ARCH)),) CPU_CFLAGS_fa526 = -mcpu=fa526 ifeq ($(CONFIG_SOFT_FLOAT),) After in toolchain/gcc/common.mk we have: ifeq ($(CONFIG_arm),y) CC_CONFIGURE+= \ --with-cpu=$(word 1, $(subst +," ,$(CONFIG_CPU_TYPE))) ifneq ($(CONFIG_SOFT_FLOAT),y) GCC_CONFIGURE+= \ --with-fpu=$(word 2, $(subst +, ",$(CONFIG_CPU_TYPE))) --with-float=hard It's a bit terse so I cannot really make this out :/ Relevant stuff from my .config is: CONFIG_CPU_TYPE="fa526" CONFIG_arm=y CONFIG_ARCH="arm" CONFIG_SOFT_FLOAT=y Any hints? Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/2] gemini: Generate padded kernel+rootfs images for DIR-685
We currently generate a kernel that boots from the harddrive in the DIR-685. That's not how we usually do things, so let's augment it to boot from flash and mount the rootfs using squashfs and JFFS2 like everyone else. Partition splitting only work when the partitions are inside of a "partitions" node which is why we have a patch like this (submitted upstream). Another patch drops the rootfs arguments and renames the firmware partition while adding the compatible "wrg" to it so the WRGG parser will kick in. Factory image was tested by bravely reflashing the DIR-685 from stock firmware using the web UI and the serial console boot loader. Signed-off-by: Linus Walleij --- target/linux/gemini/config-4.14 | 2 + target/linux/gemini/config-4.19 | 2 + target/linux/gemini/image/Makefile| 23 +++- ...emini-Indent-DIR-685-partition-table.patch | 110 ++ ...-DIR-685-partition-table-for-OpenWrt.patch | 40 +++ 5 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 target/linux/gemini/patches-4.19/0019-ARM-dts-gemini-Indent-DIR-685-partition-table.patch create mode 100644 target/linux/gemini/patches-4.19/0020-ARM-dts-Augment-DIR-685-partition-table-for-OpenWrt.patch diff --git a/target/linux/gemini/config-4.14 b/target/linux/gemini/config-4.14 index 326b05c089a2..ef5900771e4b 100644 --- a/target/linux/gemini/config-4.14 +++ b/target/linux/gemini/config-4.14 @@ -277,6 +277,8 @@ CONFIG_MTD_CFI_STAA=y # CONFIG_MTD_COMPLEX_MAPPINGS is not set CONFIG_MTD_PHYSMAP=y CONFIG_MTD_PHYSMAP_OF_GEMINI=y +CONFIG_MTD_SPLIT_FIRMWARE=y +CONFIG_MTD_SPLIT_WRGG_FW=y CONFIG_MULTI_IRQ_HANDLER=y CONFIG_NAMESPACES=y CONFIG_NEED_DMA_MAP_STATE=y diff --git a/target/linux/gemini/config-4.19 b/target/linux/gemini/config-4.19 index 7025ec149cf4..014175ea13e5 100644 --- a/target/linux/gemini/config-4.19 +++ b/target/linux/gemini/config-4.19 @@ -330,6 +330,8 @@ CONFIG_MTD_JEDECPROBE=y CONFIG_MTD_PHYSMAP=y CONFIG_MTD_PHYSMAP_OF_GEMINI=y CONFIG_MTD_REDBOOT_PARTS=y +CONFIG_MTD_SPLIT_FIRMWARE=y +CONFIG_MTD_SPLIT_WRGG_FW=y CONFIG_NAMESPACES=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NEED_KUSER_HELPERS=y diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index 7fcac8051f66..9dd37ab70292 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -10,8 +10,8 @@ include $(INCLUDE_DIR)/image.mk # Cook a "WRGG" image, this board is apparently one in the D-Link # WRGG family and uses the exact same firmware format as other # D-Link devices. -define Build/dir685-images - mkwrggimg -i $(IMAGE_KERNEL) \ +define Build/dir685-image + mkwrggimg -i $@ \ -o $@.new \ -d /dev/mtdblock/1 \ -s wrgns01_dlwbr_dir685RBWW \ @@ -22,6 +22,12 @@ define Build/dir685-images mv $@.new $@ endef +# Padding added after the rootfs to an even 128k boundary +# as this is 128k eraseblocks flash. +define Build/dir685-pad-rootfs + $(STAGING_DIR_HOST)/bin/padjffs2 $(IMAGE_ROOTFS) -c 128 >>$@ +endef + # Build D-Link DNS-313 images using the special header tool. # rootfs.tgz and rd.tgz contains nothing, we only need them # to satisfy the boot loader on the device. The zImage is @@ -121,6 +127,16 @@ GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \ samba36-server mdadm cfdisk fdisk e2fsprogs badblocks \ partx-utils +# The DIR-685 flash layout is kernel in WRGG format, padded and followed +# by the appended rootfs followed by some reasonable JFFS padding, the +# remainder will be used by JFFS2 through overlayfs. +# +# - For the factory image, the WRGG image includes the rootfs so that the +# default firmware will flash it properly as all it knows is WRGG format. +# - For the sysupgrade, we do not include the rootfs in the kernel image +# so it is not needelessly tossed into the RAM by the boot loader. +# This will be flashed from OpenWrt userland anyways so we only need +# the minimum to make the boot loader happy. define Device/dlink_dir-685 DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router DEVICE_DTS := gemini-dlink-dir-685 @@ -128,7 +144,8 @@ define Device/dlink_dir-685 kmod-switch-rtl8366rb swconfig \ kmod-rt2800-pci IMAGES := factory.bin - IMAGE/factory.bin := dir685-images + # Pad to 128k erase blocks with 160 bytes WRGG header + IMAGE/factory.bin := append-kernel | pad-offset 128k 160 | append-rootfs | dir685-pad-rootfs | dir685-image endef TARGET_DEVICES += dlink_dir-685 diff --git a/target/linux/gemini/patches-4.19/0019-ARM-dts-gemini-Indent-DIR-685-partition-table.patch b/target/linux/gemini/patches-4.19/0019-ARM-dts-gemini-Indent-DIR-685-partition-table.patch new file mode 100644 index ..b121ca174e6a --- /dev/null +++ b/target/linux/gemini/patches-4.1
[OpenWrt-Devel] [PATCH 1/2] kernel: mtdsplit: wrgg: Support big and little endian
The WRGG images exist in both big and little endian variants, as can be seen from the image generator in tools/firmware-utils/src/mkwrggimg.c, you either pass the "-b" flag or not. The D-Link DIR-685 is using little endian images so we need to support splitting these. Detect endianness like this: if the kernel entity size gets silly big (bigger than the flash memory) we are probably using the wrong endianness. Example: my kernel of 0x0067ff64 was switched around by wrong endianness and detected as 0x64ff67a0 (the actual size in swapped endianness + header 0xa0). Signed-off-by: Linus Walleij --- .../generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c index 5ce7625731d6..dd98bee04f7b 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c @@ -72,6 +72,12 @@ static int mtdsplit_parse_wrgg(struct mtd_info *master, /* sanity checks */ if (le32_to_cpu(hdr.magic1) == WRGG03_MAGIC) { kernel_ent_size = hdr_len + be32_to_cpu(hdr.size); + /* +* If this becomes silly big is is probably because the +* WRGG image is little-endian. +*/ + if (kernel_ent_size > master->size) + kernel_ent_size = hdr_len + le32_to_cpu(hdr.size); } else if (le32_to_cpu(hdr.magic1) == WRG_MAGIC) { kernel_ent_size = sizeof(struct wrg_header) + le32_to_cpu( ((struct wrg_header*))->size); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH v2] net: Allow class-e address assignment via ifconfig ioctl
On Sun, Feb 17, 2019 at 7:22 PM Sasha Levin wrote: > On Thu, Feb 14, 2019 at 02:16:04PM +0100, Linus Walleij wrote: > >From: Dave Taht > > > >commit 65cab850f0eeaa9180bd2e10a231964f33743edf upstream. > > > >While most distributions long ago switched to the iproute2 suite > >of utilities, which allow class-e (240.0.0.0/4) address assignment, > >distributions relying on busybox, toybox and other forms of > >ifconfig cannot assign class-e addresses without this kernel patch. > > > >While CIDR has been obsolete for 2 decades, and a survey of all the > >open source code in the world shows the IN_whatever macros are also > >obsolete... rather than obsolete CIDR from this ioctl entirely, this > >patch merely enables class-e assignment, sanely. > > > >Signed-off-by: Dave Taht > >Signed-off-by: David S. Miller > >Signed-off-by: Linus Walleij > > Is this really a fix? This isn't something that ever worked. I guess it fits the bill of "a real bug that bothers people", what OpenWrt wants is to use their simple userspace to set up class-e addresses and without this patch, this doesn't work for them, and IIUC it could be expected to work. I guess it is an ontological question whether OpenWrt are "fixning" or "stabilizing" or "adding features" by making class-e networks work with good old ifconfig. The maintainer(s) will decide. > Either way, David Miller will need to sign off on this since he manages > net/ -stable patches. I was unaware of different route points for stable patches, but it makes sense. Maybe we should add some kind of tagging entries to MAINTAINERS so it is clear where to route stable material? Right now I guess it is another one of these undocumented rules that one is supposed to pick up by first annoying everyone :D Are there other subsystems that have a second-level maintainer for stable, so I know before annoying someone else? Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/8 v3] bridge: multicast to unicast
On Sun, Feb 17, 2019 at 7:16 PM Sasha Levin wrote: > On Thu, Feb 14, 2019 at 02:23:56PM +0100, Linus Walleij wrote: > >From: Felix Fietkau > > > >commit 6db6f0eae6052b70885562e1733896647ec1d807 upstream. > > > >Implements an optional, per bridge port flag and feature to deliver > >multicast packets to any host on the according port via unicast > >individually. This is done by copying the packet per host and > >changing the multicast destination MAC to a unicast one accordingly. > > > >multicast-to-unicast works on top of the multicast snooping feature of > >the bridge. Which means unicast copies are only delivered to hosts which > >are interested in it and signalized this via IGMP/MLD reports > >previously. > > > >This feature is intended for interface types which have a more reliable > >and/or efficient way to deliver unicast packets than broadcast ones > >(e.g. wifi). (...) > This looks like a new feature rather than a fix, why does it need to go > to -stable? Yeah :/ I'm not very good with networking stuff and it shows. I percieved it as something else when I picked it out, now I see that it requires a flag set on the bridge which is not gonna be done without some other changes setting it. Let's drop it. Thanks, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 5/8 v3] ubifs: Drop softlimit and delta fields from struct ubifs_wbuf
On Sun, Feb 17, 2019 at 7:16 PM Sasha Levin wrote: > On Thu, Feb 14, 2019 at 02:24:00PM +0100, Linus Walleij wrote: > >From: Rafał Miłecki > > > >commit 854826c9d526fd81077742c3b000e3f7fcaef3ce upstream. > > > >Values of these fields are set during init and never modified. They are > >used (read) in a single function only. There isn't really any reason to > >keep them in a struct. It only makes struct just a bit bigger without > >any visible gain. > > > >Signed-off-by: Rafał Miłecki > >Reviewed-by: Boris Brezillon > >Signed-off-by: Richard Weinberger > >Signed-off-by: Linus Walleij > > This one is a cleanup, why is it needed in -stable? I suppose just a prerequisite for 6/8 which was a feature, so let's drop this one too. Thanks! Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 6/8 v3] ubifs: Use dirty_writeback_interval value for wbuf timer
On Sun, Feb 17, 2019 at 7:18 PM Sasha Levin wrote: > On Thu, Feb 14, 2019 at 02:24:01PM +0100, Linus Walleij wrote: > >From: Rafał Miłecki > > > >commit 1b7fc2c0069f3864a3dda15430b7aded31c0bfcc upstream. > > > >Right now wbuf timer has hardcoded timeouts and there is no place for > >manual adjustments. Some projects / cases many need that though. Few > >file systems allow doing that by respecting dirty_writeback_interval > >that can be set using sysctl (dirty_writeback_centisecs). > > > >Lowering dirty_writeback_interval could be some way of dealing with user > >space apps lacking proper fsyncs. This is definitely *not* a perfect > >solution but we don't have ideal (user space) world. There were already > >advanced discussions on this matter, mostly when ext4 was introduced and > >it wasn't behaving as ext3. Anyway, the final decision was to add some > >hacks to the ext4, as trying to fix whole user space or adding new API > >was pointless. > > > >We can't (and shouldn't?) just follow ext4. We can't e.g. sync on close > >as this would cause too many commits and flash wearing. On the other > >hand we still should allow some trade-off between -o sync and default > >wbuf timeout. Respecting dirty_writeback_interval should allow some sane > >cutomizations if used warily. > > > >Signed-off-by: Rafał Miłecki > >Reviewed-by: Boris Brezillon > >Signed-off-by: Richard Weinberger > >Signed-off-by: Linus Walleij > > This one looks like a new feature that will also require changes to > userspace. Is there actual breakage this fixes? No let's drop it then, the problem I am investigating in OpenWrt and other distributions (and code dumps) are backported patches: sometimes they are obviously backported for features, sometimes obviously for fixing something that was broken, sometimes it is just unclear to me why it has been backported. So I guess this was backported for features, so it can be dropped. Thanks for helping out! Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 2/2] gemini: Generate harddisk image for DNS-313
On Sun, Feb 17, 2019 at 5:22 PM Christian Lamparter wrote: > > + FILESYSTEMS := ext4 squashfs > > squashfs images would be nice. They are prefered because they support features > like better/safer Failsafe Mode and Factory Reset, which are not available for > the ext4 images as they need the "read-only" property that squashfs provides. > > Though, the squashfs images on block-like devices (hdd/ssd/mmc) are trickier, > because they need f2fs (kernel + userspace) + loopdev support in order to > work properly. (Without these, the squashfs image will boot, but it will > always lose the configuration on reboot because all the volatile files are > just stored on a emergency ramdisk fallback). So I figure if I just put a file in /etc/config/foo.txt or so and it remains after a reboot it is fine. > That's why I added the changes to the config-4.14 and config-4.19 and added > the f2fs tools. I put them into this separate patch on my staging area: > > https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=1626b5ca1d963e70a979fc4e6262149208608d46 > > if these work out, please let me know. I'll git it a spin, now that I understand what you want to achieve! Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/2] firmware-tools/ptgen: Allow generation 0 size partitions
The firmware on the D-Link DNS-313 NAS require two blank partitions before the boot partition. Support this if explicitly requested with a "-n" flag. Tested on the D-Link DNS-313. Signed-off-by: Christian Lamparter [Broken out from original patch] Signed-off-by: Linus Walleij --- tools/firmware-utils/src/ptgen.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index 13e0eda6222a..0192bb65e514 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,7 @@ int active = 1; int heads = -1; int sectors = -1; int kb_align = 0; +bool ignore_null_sized_partition = false; struct partinfo parts[4]; char *filename = NULL; @@ -140,6 +142,8 @@ static int gen_ptable(uint32_t signature, int nr) memset(pte, 0, sizeof(struct pte) * 4); for (i = 0; i < nr; i++) { if (!parts[i].size) { + if (ignore_null_sized_partition) + continue; fprintf(stderr, "Invalid size in partition %d!\n", i); return -1; } @@ -196,7 +200,7 @@ fail: static void usage(char *prog) { - fprintf(stderr, "Usage: %s [-v] -h -s -o [-a 0..4] [-l ] [[-t ] -p ...] \n", prog); + fprintf(stderr, "Usage: %s [-v] [-n] -h -s -o [-a 0..4] [-l ] [[-t ] -p ...] \n", prog); exit(EXIT_FAILURE); } @@ -207,7 +211,7 @@ int main (int argc, char **argv) int part = 0; uint32_t signature = 0x5452574F; /* 'OWRT' */ - while ((ch = getopt(argc, argv, "h:s:p:a:t:o:vl:S:")) != -1) { + while ((ch = getopt(argc, argv, "h:s:p:a:t:o:vnl:S:")) != -1) { switch (ch) { case 'o': filename = optarg; @@ -215,6 +219,9 @@ int main (int argc, char **argv) case 'v': verbose++; break; + case 'n': + ignore_null_sized_partition = true; + break; case 'h': heads = (int)strtoul(optarg, NULL, 0); break; -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/2] gemini: Generate harddisk image for DNS-313
This makes OpenWrt build an Ext2+Ext4 partitioned image for the D-Link DNS-313 with two blank partitions, a boot partition on /dev/sda3 and a rootfs partition on /dev/sda4. This uses the methods already used in apm821xx including the tricks to convert the generated Ext2 filesystem partition to version 1 so that the firmware bootloader will properly recognize it. We patch a bit around the build files to make sure we get the rootfs size set and that genext2fs is properly built. Tested on the D-Link DNS-313. Signed-off-by: Christian Lamparter [Fixing and tricksing] Signed-off-by: Linus Walleij --- config/Config-images.in | 2 +- target/linux/gemini/Makefile | 2 +- target/linux/gemini/image/Makefile| 27 ++ .../linux/gemini/image/dns313_gen_hdd_img.sh | 28 +++ tools/Makefile| 2 +- 5 files changed, 52 insertions(+), 9 deletions(-) create mode 100755 target/linux/gemini/image/dns313_gen_hdd_img.sh diff --git a/config/Config-images.in b/config/Config-images.in index bdd24ef6178c..b9cc929f0f95 100644 --- a/config/Config-images.in +++ b/config/Config-images.in @@ -275,7 +275,7 @@ menu "Target Images" config TARGET_ROOTFS_PARTSIZE int "Root filesystem partition size (in MB)" - depends on GRUB_IMAGES || USES_ROOTFS_PART || TARGET_ROOTFS_EXT4FS || TARGET_mvebu || TARGET_omap || TARGET_rb532 || TARGET_sunxi || TARGET_uml + depends on GRUB_IMAGES || USES_ROOTFS_PART || TARGET_ROOTFS_EXT4FS || TARGET_mvebu || TARGET_omap || TARGET_rb532 || TARGET_sunxi || TARGET_uml || TARGET_gemini default 256 help Select the root filesystem partition size. diff --git a/target/linux/gemini/Makefile b/target/linux/gemini/Makefile index 7c573c7c6d09..e232937bb9eb 100644 --- a/target/linux/gemini/Makefile +++ b/target/linux/gemini/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk ARCH:=arm BOARD:=gemini BOARDNAME:=Cortina Systems CS351x -FEATURES:=squashfs pci rtc usb dt gpio display +FEATURES:=squashfs pci rtc usb dt gpio display ext4 root-part boot-part CPU_TYPE:=fa526 MAINTAINER:=Roman Yeryomin diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index a612cf706d63..493f14cbf416 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -28,6 +28,7 @@ endef # the only real content. define Build/dns313-images mkdir -p $@.tmp/.boot + chmod 755 $@.tmp/.boot echo "dummy" > $@.tmp/dummyfile @@ -38,9 +39,20 @@ define Build/dns313-images dns313-header $(IMAGE_KERNEL) \ $@.tmp/.boot/zImage - tar --sort=name --owner=0 --group=0 --numeric-owner -czf $@ \ - -C $@.tmp .boot \ - $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") + rm $@.tmp/dummyfile + + genext2fs --block-size $(BLOCKSIZE:%k=%Ki) \ + --size-in-blocks $$((1024 * $(CONFIG_TARGET_KERNEL_PARTSIZE))) \ + --squash-uids \ + --root $@.tmp $@.tmp-boot + + # The device firmware needs revision 1 of EXT2 + $(STAGING_DIR_HOST)/bin/tune2fs -O filetype $@.tmp-boot + $(STAGING_DIR_HOST)/bin/e2fsck -pDf $@.tmp-boot > /dev/null + + ./dns313_gen_hdd_img.sh $@ $@.tmp-boot $(IMAGE_ROOTFS) \ + $(CONFIG_TARGET_KERNEL_PARTSIZE) \ + $(CONFIG_TARGET_ROOTFS_PARTSIZE) rm -rf $@.tmp endef @@ -106,7 +118,8 @@ GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \ kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \ kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \ kmod-nls-utf8 kmod-usb-storage-extras \ - samba36-server mdadm cfdisk fdisk e2fsprogs badblocks + samba36-server mdadm cfdisk fdisk e2fsprogs badblocks \ + partx-utils define Device/dlink_dir-685 DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router @@ -123,8 +136,10 @@ define Device/dlink_dns-313 DEVICE_TITLE := D-Link DNS-313 1-Bay Network Storage Enclosure DEVICE_DTS := gemini-dlink-dns-313 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) - IMAGES := bootpart.tar.gz - IMAGE/bootpart.tar.gz := dns313-images + BLOCKSIZE := 1k + FILESYSTEMS := ext4 squashfs + IMAGES := factory.bin.gz + IMAGE/factory.bin.gz := dns313-images | gzip endef TARGET_DEVICES += dlink_dns-313 diff --git a/target/linux/gemini/image/dns313_gen_hdd_img.sh b/target/linux/gemini/image/dns313_gen_hdd_img.sh new file mode 100755 index ..1eb2c7c57599 --- /dev/null +++ b/target/linux/gemini/image/dns313_gen_hdd_img.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -x +[ $# -eq 5 ] || { + echo "SYNTAX: $0 " + exit 1 +}
[OpenWrt-Devel] [PATCH 8/8 v3] netfilter: nf_tables: fix mismatch in big-endian system
From: Liping Zhang commit 10596608c4d62cb8c1c2b806debcbd32fe657e71 upstream. Currently, there are two different methods to store an u16 integer to the u32 data register. For example: u32 *dest = >data[priv->dreg]; 1. *dest = 0; *(u16 *) dest = val_u16; 2. *dest = val_u16; For method 1, the u16 value will be stored like this, either in big-endian or little-endian system: 0 15 31 +-+-+-+-+-+-+-+-+-+-+-+-+ | Value | 0 | +-+-+-+-+-+-+-+-+-+-+-+-+ For method 2, in little-endian system, the u16 value will be the same as listed above. But in big-endian system, the u16 value will be stored like this: 0 15 31 +-+-+-+-+-+-+-+-+-+-+-+-+ | 0 | Value | +-+-+-+-+-+-+-+-+-+-+-+-+ So later we use "memcmp(>data[priv->sreg], data, 2);" to do compare in nft_cmp, nft_lookup expr ..., method 2 will get the wrong result in big-endian system, as 0~15 bits will always be zero. For the similar reason, when loading an u16 value from the u32 data register, we should use "*(u16 *) sreg;" instead of "(u16)*sreg;", the 2nd method will get the wrong value in the big-endian system. So introduce some wrapper functions to store/load an u8 or u16 integer to/from the u32 data register, and use them in the right place. Signed-off-by: Liping Zhang Signed-off-by: Pablo Neira Ayuso Signed-off-by: Linus Walleij --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- include/net/netfilter/nf_tables.h | 29 net/ipv4/netfilter/nft_masq_ipv4.c | 8 +++--- net/ipv4/netfilter/nft_redir_ipv4.c | 8 +++--- net/ipv6/netfilter/nft_masq_ipv6.c | 8 +++--- net/ipv6/netfilter/nft_redir_ipv6.c | 8 +++--- net/netfilter/nft_ct.c | 10 +++ net/netfilter/nft_meta.c| 42 +++-- net/netfilter/nft_nat.c | 8 +++--- 8 files changed, 76 insertions(+), 45 deletions(-) diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h index b02af0bf5777..66f6b84df287 100644 --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h @@ -87,6 +87,35 @@ struct nft_regs { }; }; +/* Store/load an u16 or u8 integer to/from the u32 data register. + * + * Note, when using concatenations, register allocation happens at 32-bit + * level. So for store instruction, pad the rest part with zero to avoid + * garbage values. + */ + +static inline void nft_reg_store16(u32 *dreg, u16 val) +{ + *dreg = 0; + *(u16 *)dreg = val; +} + +static inline void nft_reg_store8(u32 *dreg, u8 val) +{ + *dreg = 0; + *(u8 *)dreg = val; +} + +static inline u16 nft_reg_load16(u32 *sreg) +{ + return *(u16 *)sreg; +} + +static inline u8 nft_reg_load8(u32 *sreg) +{ + return *(u8 *)sreg; +} + static inline void nft_data_copy(u32 *dst, const struct nft_data *src, unsigned int len) { diff --git a/net/ipv4/netfilter/nft_masq_ipv4.c b/net/ipv4/netfilter/nft_masq_ipv4.c index 51ced81b616c..dc3628a396ec 100644 --- a/net/ipv4/netfilter/nft_masq_ipv4.c +++ b/net/ipv4/netfilter/nft_masq_ipv4.c @@ -26,10 +26,10 @@ static void nft_masq_ipv4_eval(const struct nft_expr *expr, memset(, 0, sizeof(range)); range.flags = priv->flags; if (priv->sreg_proto_min) { - range.min_proto.all = - *(__be16 *)>data[priv->sreg_proto_min]; - range.max_proto.all = - *(__be16 *)>data[priv->sreg_proto_max]; + range.min_proto.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_min]); + range.max_proto.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_max]); } regs->verdict.code = nf_nat_masquerade_ipv4(pkt->skb, pkt->hook, , pkt->out); diff --git a/net/ipv4/netfilter/nft_redir_ipv4.c b/net/ipv4/netfilter/nft_redir_ipv4.c index c09d4381427e..f760524e1353 100644 --- a/net/ipv4/netfilter/nft_redir_ipv4.c +++ b/net/ipv4/netfilter/nft_redir_ipv4.c @@ -26,10 +26,10 @@ static void nft_redir_ipv4_eval(const struct nft_expr *expr, memset(, 0, sizeof(mr)); if (priv->sreg_proto_min) { - mr.range[0].min.all = - *(__be16 *)>data[priv->sreg_proto_min]; - mr.range[0].max.all = - *(__be16 *)>data[priv->sreg_proto_max]; + mr.range[0].min.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_min]); + mr.range[0].max.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_max]); mr.range[0].flags |= NF_NAT_RANGE_PROTO_SPECIFIED; } diff --git a/net/ipv6/netfilt
[OpenWrt-Devel] [PATCH 7/8 v3] usb: dwc2: Remove unnecessary kfree
From: John Youn commit cd4b1e34655d46950c065d9284b596cd8d7b28cd upstream. This shouldn't be freed by the HCD as it is owned by the core and allocated with devm_kzalloc. Signed-off-by: John Youn Signed-off-by: Felipe Balbi Signed-off-by: Linus Walleij --- - This was applied upstream in v4.10 - Should be applied to stable v4.9.y --- drivers/usb/dwc2/hcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 984d6aae7529..0e5435330c07 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -5202,7 +5202,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) error2: usb_put_hcd(hcd); error1: - kfree(hsotg->core_params); #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS kfree(hsotg->last_frame_num_array); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 6/8 v3] ubifs: Use dirty_writeback_interval value for wbuf timer
From: Rafał Miłecki commit 1b7fc2c0069f3864a3dda15430b7aded31c0bfcc upstream. Right now wbuf timer has hardcoded timeouts and there is no place for manual adjustments. Some projects / cases many need that though. Few file systems allow doing that by respecting dirty_writeback_interval that can be set using sysctl (dirty_writeback_centisecs). Lowering dirty_writeback_interval could be some way of dealing with user space apps lacking proper fsyncs. This is definitely *not* a perfect solution but we don't have ideal (user space) world. There were already advanced discussions on this matter, mostly when ext4 was introduced and it wasn't behaving as ext3. Anyway, the final decision was to add some hacks to the ext4, as trying to fix whole user space or adding new API was pointless. We can't (and shouldn't?) just follow ext4. We can't e.g. sync on close as this would cause too many commits and flash wearing. On the other hand we still should allow some trade-off between -o sync and default wbuf timeout. Respecting dirty_writeback_interval should allow some sane cutomizations if used warily. Signed-off-by: Rafał Miłecki Reviewed-by: Boris Brezillon Signed-off-by: Richard Weinberger Signed-off-by: Linus Walleij --- - This was applied upstream in v4.10 - Should be applied to stable v4.9.y --- fs/ubifs/io.c| 8 fs/ubifs/ubifs.h | 4 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 4d6ce4a2a4b6..3be28900bf37 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c @@ -452,11 +452,11 @@ static enum hrtimer_restart wbuf_timer_callback_nolock(struct hrtimer *timer) */ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) { - ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0); - unsigned long long delta; + ktime_t softlimit = ms_to_ktime(dirty_writeback_interval * 10); + unsigned long long delta = dirty_writeback_interval; - delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT; - delta *= 10ULL; + /* centi to milli, milli to nano, then 10% */ + delta *= 10ULL * NSEC_PER_MSEC / 10ULL; ubifs_assert(!hrtimer_active(>timer)); ubifs_assert(delta <= ULONG_MAX); diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index ade4b3137a1d..b8b18d446a49 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -83,10 +83,6 @@ */ #define BGT_NAME_PATTERN "ubifs_bgt%d_%d" -/* Write-buffer synchronization timeout interval in seconds */ -#define WBUF_TIMEOUT_SOFTLIMIT 3 -#define WBUF_TIMEOUT_HARDLIMIT 5 - /* Maximum possible inode number (only 32-bit inodes are supported now) */ #define MAX_INUM 0x -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 5/8 v3] ubifs: Drop softlimit and delta fields from struct ubifs_wbuf
From: Rafał Miłecki commit 854826c9d526fd81077742c3b000e3f7fcaef3ce upstream. Values of these fields are set during init and never modified. They are used (read) in a single function only. There isn't really any reason to keep them in a struct. It only makes struct just a bit bigger without any visible gain. Signed-off-by: Rafał Miłecki Reviewed-by: Boris Brezillon Signed-off-by: Richard Weinberger Signed-off-by: Linus Walleij --- - This was applied upstream in v4.10 - Should be applied to stable v4.9.y --- fs/ubifs/io.c| 18 ++ fs/ubifs/ubifs.h | 5 - 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 97be41215332..4d6ce4a2a4b6 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c @@ -452,16 +452,22 @@ static enum hrtimer_restart wbuf_timer_callback_nolock(struct hrtimer *timer) */ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) { + ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0); + unsigned long long delta; + + delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT; + delta *= 10ULL; + ubifs_assert(!hrtimer_active(>timer)); + ubifs_assert(delta <= ULONG_MAX); if (wbuf->no_timer) return; dbg_io("set timer for jhead %s, %llu-%llu millisecs", dbg_jhead(wbuf->jhead), - div_u64(ktime_to_ns(wbuf->softlimit), USEC_PER_SEC), - div_u64(ktime_to_ns(wbuf->softlimit) + wbuf->delta, - USEC_PER_SEC)); - hrtimer_start_range_ns(>timer, wbuf->softlimit, wbuf->delta, + div_u64(ktime_to_ns(softlimit), USEC_PER_SEC), + div_u64(ktime_to_ns(softlimit) + delta, USEC_PER_SEC)); + hrtimer_start_range_ns(>timer, softlimit, delta, HRTIMER_MODE_REL); } @@ -1059,10 +1065,6 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf) hrtimer_init(>timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); wbuf->timer.function = wbuf_timer_callback_nolock; - wbuf->softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0); - wbuf->delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT; - wbuf->delta *= 10ULL; - ubifs_assert(wbuf->delta <= ULONG_MAX); return 0; } diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 096035eb29d0..ade4b3137a1d 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -645,9 +645,6 @@ typedef int (*ubifs_lpt_scan_callback)(struct ubifs_info *c, * @io_mutex: serializes write-buffer I/O * @lock: serializes @buf, @lnum, @offs, @avail, @used, @next_ino and @inodes *fields - * @softlimit: soft write-buffer timeout interval - * @delta: hard and soft timeouts delta (the timer expire interval is @softlimit - * and @softlimit + @delta) * @timer: write-buffer timer * @no_timer: non-zero if this write-buffer does not have a timer * @need_sync: non-zero if the timer expired and the wbuf needs sync'ing @@ -676,8 +673,6 @@ struct ubifs_wbuf { int (*sync_callback)(struct ubifs_info *c, int lnum, int free, int pad); struct mutex io_mutex; spinlock_t lock; - ktime_t softlimit; - unsigned long long delta; struct hrtimer timer; unsigned int no_timer:1; unsigned int need_sync:1; -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 4/8 v3] kaweth: use skb_cow_head() to deal with cloned skbs
From: Eric Dumazet commit 39fba7835aacda65284a86e611774cbba71dac20 upstream. We can use skb_cow_head() to properly deal with clones, especially the ones coming from TCP stack that allow their head being modified. This avoids a copy. Signed-off-by: Eric Dumazet Cc: James Hughes Signed-off-by: David S. Miller Signed-off-by: Linus Walleij --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- drivers/net/usb/kaweth.c | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 66b34ddbe216..72d9e7954b0a 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -803,18 +803,12 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb, } /* We now decide whether we can put our special header into the sk_buff */ - if (skb_cloned(skb) || skb_headroom(skb) < 2) { - /* no such luck - we make our own */ - struct sk_buff *copied_skb; - copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC); - dev_kfree_skb_irq(skb); - skb = copied_skb; - if (!copied_skb) { - kaweth->stats.tx_errors++; - netif_start_queue(net); - spin_unlock_irq(>device_lock); - return NETDEV_TX_OK; - } + if (skb_cow_head(skb, 2)) { + kaweth->stats.tx_errors++; + netif_start_queue(net); + spin_unlock_irq(>device_lock); + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; } private_header = (__le16 *)__skb_push(skb, 2); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 3/8 v3] ch9200: use skb_cow_head() to deal with cloned skbs
From: Eric Dumazet commit 6bc6895bdd6744e0136eaa4a11fbdb20a7db4e40 upstream. We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers. skb_cow_head() is the proper helper to deal with this. Fixes: 4a476bd6d1d9 ("usbnet: New driver for QinHeng CH9200 devices") Signed-off-by: Eric Dumazet Cc: James Hughes Cc: Matthew Garrett Signed-off-by: David S. Miller Signed-off-by: Linus Walleij --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- drivers/net/usb/ch9200.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/net/usb/ch9200.c b/drivers/net/usb/ch9200.c index 8a40202c0a17..c4f1c363e24b 100644 --- a/drivers/net/usb/ch9200.c +++ b/drivers/net/usb/ch9200.c @@ -254,14 +254,9 @@ static struct sk_buff *ch9200_tx_fixup(struct usbnet *dev, struct sk_buff *skb, tx_overhead = 0x40; len = skb->len; - if (skb_headroom(skb) < tx_overhead) { - struct sk_buff *skb2; - - skb2 = skb_copy_expand(skb, tx_overhead, 0, flags); + if (skb_cow_head(skb, tx_overhead)) { dev_kfree_skb_any(skb); - skb = skb2; - if (!skb) - return NULL; + return NULL; } __skb_push(skb, tx_overhead); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 0/8 v3] Stable material from OpenWrt for v4.9.y
This is a series of patches used in OpenWrt's v4.9 backports that seem to be of generic interest to v4.9.y For the remaining patches I cherry-picked the upstream commits except for (8/8) "netfilter: nf_tables: fix mismatch in big-endian system" where I used OpenWrt's backport. ChangeLog v2->v3: - Add Signed-off-by to all patches to reflect delivery path. ChangeLog v1->v2: - I have dropped two patches from the series: one was to be applied also to v4.14.y and one was to be applied also to v4.14.y and v4.19.y. The rest are for v4.9.y as they have been merged upstream between v4.9 and v4.14. - The two dropped patches have been sent out separately. - I have added the "commit n upstream." message on the first line of each commit message to fit stable standards. Upstream commits: The list of upstream commits in patch order: 6db6f0eae6052b70885562e1733896647ec1d807 ("bridge: multicast to unicast") e9156cd26a495a18706e796f02a81fee41ec14f4 ("smsc95xx: Use skb_cow_head to deal with cloned skbs") 6bc6895bdd6744e0136eaa4a11fbdb20a7db4e40 ("ch9200: use skb_cow_head() to deal with cloned skbs") 39fba7835aacda65284a86e611774cbba71dac20 ("kaweth: use skb_cow_head() to deal with cloned skbs") 854826c9d526fd81077742c3b000e3f7fcaef3ce ("ubifs: Drop softlimit and delta fields from struct ubifs_wbuf") 1b7fc2c0069f3864a3dda15430b7aded31c0bfcc ("ubifs: Use dirty_writeback_interval value for wbuf timer") cd4b1e34655d46950c065d9284b596cd8d7b28cd ("usb: dwc2: Remove unnecessary kfree") 10596608c4d62cb8c1c2b806debcbd32fe657e71 ("netfilter: nf_tables: fix mismatch in big-endian system") Eric Dumazet (2): ch9200: use skb_cow_head() to deal with cloned skbs kaweth: use skb_cow_head() to deal with cloned skbs Felix Fietkau (1): bridge: multicast to unicast James Hughes (1): smsc95xx: Use skb_cow_head to deal with cloned skbs John Youn (1): usb: dwc2: Remove unnecessary kfree Liping Zhang (1): netfilter: nf_tables: fix mismatch in big-endian system Rafał Miłecki (2): ubifs: Drop softlimit and delta fields from struct ubifs_wbuf ubifs: Use dirty_writeback_interval value for wbuf timer drivers/net/usb/ch9200.c| 9 +-- drivers/net/usb/kaweth.c| 18 ++ drivers/net/usb/smsc95xx.c | 12 ++-- drivers/usb/dwc2/hcd.c | 1 - fs/ubifs/io.c | 18 +++--- fs/ubifs/ubifs.h| 9 --- include/linux/if_bridge.h | 1 + include/net/netfilter/nf_tables.h | 29 ++ include/uapi/linux/if_link.h| 1 + net/bridge/br_forward.c | 39 - net/bridge/br_mdb.c | 2 +- net/bridge/br_multicast.c | 90 + net/bridge/br_netlink.c | 5 ++ net/bridge/br_private.h | 3 +- net/bridge/br_sysfs_if.c| 2 + net/ipv4/netfilter/nft_masq_ipv4.c | 8 +-- net/ipv4/netfilter/nft_redir_ipv4.c | 8 +-- net/ipv6/netfilter/nft_masq_ipv6.c | 8 +-- net/ipv6/netfilter/nft_redir_ipv6.c | 8 +-- net/netfilter/nft_ct.c | 10 ++-- net/netfilter/nft_meta.c| 42 +++--- net/netfilter/nft_nat.c | 8 +-- 22 files changed, 214 insertions(+), 117 deletions(-) -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/8 v3] smsc95xx: Use skb_cow_head to deal with cloned skbs
From: James Hughes commit e9156cd26a495a18706e796f02a81fee41ec14f4 upstream. The driver was failing to check that the SKB wasn't cloned before adding checksum data. Replace existing handling to extend/copy the header buffer with skb_cow_head. Signed-off-by: James Hughes Acked-by: Eric Dumazet Acked-by: Woojung Huh Signed-off-by: David S. Miller Signed-off-by: Linus Walleij --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- drivers/net/usb/smsc95xx.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index e29f4c0767eb..e719ecd69d01 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -2011,13 +2011,13 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, /* We do not advertise SG, so skbs should be already linearized */ BUG_ON(skb_shinfo(skb)->nr_frags); - if (skb_headroom(skb) < overhead) { - struct sk_buff *skb2 = skb_copy_expand(skb, - overhead, 0, flags); + /* Make writable and expand header space by overhead if required */ + if (skb_cow_head(skb, overhead)) { + /* Must deallocate here as returning NULL to indicate error +* means the skb won't be deallocated in the caller. +*/ dev_kfree_skb_any(skb); - skb = skb2; - if (!skb) - return NULL; + return NULL; } if (csum) { -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/8 v3] bridge: multicast to unicast
From: Felix Fietkau commit 6db6f0eae6052b70885562e1733896647ec1d807 upstream. Implements an optional, per bridge port flag and feature to deliver multicast packets to any host on the according port via unicast individually. This is done by copying the packet per host and changing the multicast destination MAC to a unicast one accordingly. multicast-to-unicast works on top of the multicast snooping feature of the bridge. Which means unicast copies are only delivered to hosts which are interested in it and signalized this via IGMP/MLD reports previously. This feature is intended for interface types which have a more reliable and/or efficient way to deliver unicast packets than broadcast ones (e.g. wifi). However, it should only be enabled on interfaces where no IGMPv2/MLDv1 report suppression takes place. This feature is disabled by default. The initial patch and idea is from Felix Fietkau. Signed-off-by: Felix Fietkau [linus.luess...@c0d3.blue: various bug + style fixes, commit message] Signed-off-by: Linus Lüssing Reviewed-by: Nikolay Aleksandrov Signed-off-by: David S. Miller Signed-off-by: Linus Walleij --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- include/linux/if_bridge.h| 1 + include/uapi/linux/if_link.h | 1 + net/bridge/br_forward.c | 39 +++- net/bridge/br_mdb.c | 2 +- net/bridge/br_multicast.c| 90 ++-- net/bridge/br_netlink.c | 5 ++ net/bridge/br_private.h | 3 +- net/bridge/br_sysfs_if.c | 2 + 8 files changed, 114 insertions(+), 29 deletions(-) diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h index c6587c01d951..debc9d5904e5 100644 --- a/include/linux/if_bridge.h +++ b/include/linux/if_bridge.h @@ -46,6 +46,7 @@ struct br_ip_list { #define BR_LEARNING_SYNC BIT(9) #define BR_PROXYARP_WIFI BIT(10) #define BR_MCAST_FLOOD BIT(11) +#define BR_MULTICAST_TO_UNICASTBIT(12) #define BR_DEFAULT_AGEING_TIME (300 * HZ) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index b4fba662cd32..ee4d632d089d 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -319,6 +319,7 @@ enum { IFLA_BRPORT_MULTICAST_ROUTER, IFLA_BRPORT_PAD, IFLA_BRPORT_MCAST_FLOOD, + IFLA_BRPORT_MCAST_TO_UCAST, __IFLA_BRPORT_MAX }; #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index 5b675695c661..30afa130287e 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c @@ -173,6 +173,31 @@ static struct net_bridge_port *maybe_deliver( return p; } +static void maybe_deliver_addr(struct net_bridge_port *p, struct sk_buff *skb, + const unsigned char *addr, bool local_orig) +{ + struct net_device *dev = BR_INPUT_SKB_CB(skb)->brdev; + const unsigned char *src = eth_hdr(skb)->h_source; + + if (!should_deliver(p, skb)) + return; + + /* Even with hairpin, no soliloquies - prevent breaking IPv6 DAD */ + if (skb->dev == p->dev && ether_addr_equal(src, addr)) + return; + + skb = skb_copy(skb, GFP_ATOMIC); + if (!skb) { + dev->stats.tx_dropped++; + return; + } + + if (!is_broadcast_ether_addr(addr)) + memcpy(eth_hdr(skb)->h_dest, addr, ETH_ALEN); + + __br_forward(p, skb, local_orig); +} + /* called under rcu_read_lock */ void br_flood(struct net_bridge *br, struct sk_buff *skb, enum br_pkt_type pkt_type, bool local_rcv, bool local_orig) @@ -241,10 +266,20 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst, rport = rp ? hlist_entry(rp, struct net_bridge_port, rlist) : NULL; - port = (unsigned long)lport > (unsigned long)rport ? - lport : rport; + if ((unsigned long)lport > (unsigned long)rport) { + port = lport; + + if (port->flags & BR_MULTICAST_TO_UNICAST) { + maybe_deliver_addr(lport, skb, p->eth_addr, + local_orig); + goto delivered; + } + } else { + port = rport; + } prev = maybe_deliver(prev, port, skb, local_orig); +delivered: if (IS_ERR(prev)) goto out; if (prev == port) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 6406010e155b..57e94a1b57e1 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -532,7 +532,7 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, break; } - p = br
[OpenWrt-Devel] [PATCH v2] uapi/if_ether.h: prevent redefinition of struct ethhdr
From: Hauke Mehrtens commit 6926e041a8920c8ec27e4e155efa760aa01551fd upstream. Musl provides its own ethhdr struct definition. Add a guard to prevent its definition of the appropriate musl header has already been included. glibc does not implement this header, but when glibc will implement this they can just define __UAPI_DEF_ETHHDR 0 to make it work with the kernel. Signed-off-by: Hauke Mehrtens Signed-off-by: David S. Miller Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Add SoB line - This is upstream in v4.15 - This should be applied for stable v4.14.y and v4.9.y --- include/uapi/linux/if_ether.h| 3 +++ include/uapi/linux/libc-compat.h | 6 ++ 2 files changed, 9 insertions(+) diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h index 244e3213ecb0..60ec9114e28f 100644 --- a/include/uapi/linux/if_ether.h +++ b/include/uapi/linux/if_ether.h @@ -23,6 +23,7 @@ #define _UAPI_LINUX_IF_ETHER_H #include +#include /* * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble @@ -150,11 +151,13 @@ * This is an Ethernet frame header. */ +#if __UAPI_DEF_ETHHDR struct ethhdr { unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ unsigned char h_source[ETH_ALEN]; /* source ether addr*/ __be16 h_proto;/* packet type ID field */ } __attribute__((packed)); +#endif #endif /* _UAPI_LINUX_IF_ETHER_H */ diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h index 8254c937c9f4..fc29efaa918c 100644 --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h @@ -264,4 +264,10 @@ #endif /* __GLIBC__ */ +/* Definitions for if_ether.h */ +/* allow libcs like musl to deactivate this, glibc does not implement this. */ +#ifndef __UAPI_DEF_ETHHDR +#define __UAPI_DEF_ETHHDR 1 +#endif + #endif /* _UAPI_LIBC_COMPAT_H */ -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH v2] net: Allow class-e address assignment via ifconfig ioctl
From: Dave Taht commit 65cab850f0eeaa9180bd2e10a231964f33743edf upstream. While most distributions long ago switched to the iproute2 suite of utilities, which allow class-e (240.0.0.0/4) address assignment, distributions relying on busybox, toybox and other forms of ifconfig cannot assign class-e addresses without this kernel patch. While CIDR has been obsolete for 2 decades, and a survey of all the open source code in the world shows the IN_whatever macros are also obsolete... rather than obsolete CIDR from this ioctl entirely, this patch merely enables class-e assignment, sanely. Signed-off-by: Dave Taht Signed-off-by: David S. Miller Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Add SoB-line - This commit is upstream in v4.20 - This should ve applied for stable v4.19.y, v4.14.y and v4.9.y --- include/uapi/linux/in.h | 10 +++--- net/ipv4/devinet.c | 5 +++-- net/ipv4/ipconfig.c | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h index 48e8a225b985..f6052e70bf40 100644 --- a/include/uapi/linux/in.h +++ b/include/uapi/linux/in.h @@ -266,10 +266,14 @@ struct sockaddr_in { #defineIN_CLASSD(a)long int) (a)) & 0xf000) == 0xe000) #defineIN_MULTICAST(a) IN_CLASSD(a) -#define IN_MULTICAST_NET 0xF000 +#defineIN_MULTICAST_NET0xe000 -#defineIN_EXPERIMENTAL(a) long int) (a)) & 0xf000) == 0xf000) -#defineIN_BADCLASS(a) IN_EXPERIMENTAL((a)) +#defineIN_BADCLASS(a) long int) (a) ) == 0x) +#defineIN_EXPERIMENTAL(a) IN_BADCLASS((a)) + +#defineIN_CLASSE(a)long int) (a)) & 0xf000) == 0xf000) +#defineIN_CLASSE_NET 0x +#defineIN_CLASSE_NSHIFT0 /* Address to accept any incoming messages. */ #defineINADDR_ANY ((unsigned long int) 0x) diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index ea4bd8a52422..e38042933a27 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -941,17 +941,18 @@ static int inet_abc_len(__be32 addr) { int rc = -1;/* Something else, probably a multicast. */ - if (ipv4_is_zeronet(addr)) + if (ipv4_is_zeronet(addr) || ipv4_is_lbcast(addr)) rc = 0; else { __u32 haddr = ntohl(addr); - if (IN_CLASSA(haddr)) rc = 8; else if (IN_CLASSB(haddr)) rc = 16; else if (IN_CLASSC(haddr)) rc = 24; + else if (IN_CLASSE(haddr)) + rc = 32; } return rc; diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 88212615bf4c..2393e5c106bf 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -429,6 +429,8 @@ static int __init ic_defaults(void) ic_netmask = htonl(IN_CLASSB_NET); else if (IN_CLASSC(ntohl(ic_myaddr))) ic_netmask = htonl(IN_CLASSC_NET); + else if (IN_CLASSE(ntohl(ic_myaddr))) + ic_netmask = htonl(IN_CLASSE_NET); else { pr_err("IP-Config: Unable to guess netmask for address %pI4\n", _myaddr); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] uapi/if_ether.h: prevent redefinition of struct ethhdr
On Thu, Feb 14, 2019 at 1:45 PM Greg Kroah-Hartman wrote: > On Thu, Feb 14, 2019 at 01:27:20PM +0100, Linus Walleij wrote: > > From: Hauke Mehrtens > > > > commit 6926e041a8920c8ec27e4e155efa760aa01551fd upstream. > > > > Musl provides its own ethhdr struct definition. Add a guard to prevent > > its definition of the appropriate musl header has already been included. > > > > glibc does not implement this header, but when glibc will implement this > > they can just define __UAPI_DEF_ETHHDR 0 to make it work with the > > kernel. > > > > Signed-off-by: Hauke Mehrtens > > Signed-off-by: David S. Miller > > --- > > - This is upstream in v4.15 > > - This should be applied for stable v4.14.y and v4.9.y > > Sounds good, but do you also want to sign off on it? :) Oh deliver path, yeah, so many details :D OK I respin the whole lot with signed-off-by's. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 7/8 v2] usb: dwc2: Remove unnecessary kfree
From: John Youn commit cd4b1e34655d46950c065d9284b596cd8d7b28cd upstream. This shouldn't be freed by the HCD as it is owned by the core and allocated with devm_kzalloc. Signed-off-by: John Youn Signed-off-by: Felipe Balbi --- - This was applied upstream in v4.10 - Should be applied to stable v4.9.y --- drivers/usb/dwc2/hcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 984d6aae7529..0e5435330c07 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -5202,7 +5202,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) error2: usb_put_hcd(hcd); error1: - kfree(hsotg->core_params); #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS kfree(hsotg->last_frame_num_array); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 6/8 v2] ubifs: Use dirty_writeback_interval value for wbuf timer
From: Rafał Miłecki commit 1b7fc2c0069f3864a3dda15430b7aded31c0bfcc upstream. Right now wbuf timer has hardcoded timeouts and there is no place for manual adjustments. Some projects / cases many need that though. Few file systems allow doing that by respecting dirty_writeback_interval that can be set using sysctl (dirty_writeback_centisecs). Lowering dirty_writeback_interval could be some way of dealing with user space apps lacking proper fsyncs. This is definitely *not* a perfect solution but we don't have ideal (user space) world. There were already advanced discussions on this matter, mostly when ext4 was introduced and it wasn't behaving as ext3. Anyway, the final decision was to add some hacks to the ext4, as trying to fix whole user space or adding new API was pointless. We can't (and shouldn't?) just follow ext4. We can't e.g. sync on close as this would cause too many commits and flash wearing. On the other hand we still should allow some trade-off between -o sync and default wbuf timeout. Respecting dirty_writeback_interval should allow some sane cutomizations if used warily. Signed-off-by: Rafał Miłecki Reviewed-by: Boris Brezillon Signed-off-by: Richard Weinberger --- - This was applied upstream in v4.10 - Should be applied to stable v4.9.y --- fs/ubifs/io.c| 8 fs/ubifs/ubifs.h | 4 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 4d6ce4a2a4b6..3be28900bf37 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c @@ -452,11 +452,11 @@ static enum hrtimer_restart wbuf_timer_callback_nolock(struct hrtimer *timer) */ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) { - ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0); - unsigned long long delta; + ktime_t softlimit = ms_to_ktime(dirty_writeback_interval * 10); + unsigned long long delta = dirty_writeback_interval; - delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT; - delta *= 10ULL; + /* centi to milli, milli to nano, then 10% */ + delta *= 10ULL * NSEC_PER_MSEC / 10ULL; ubifs_assert(!hrtimer_active(>timer)); ubifs_assert(delta <= ULONG_MAX); diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index ade4b3137a1d..b8b18d446a49 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -83,10 +83,6 @@ */ #define BGT_NAME_PATTERN "ubifs_bgt%d_%d" -/* Write-buffer synchronization timeout interval in seconds */ -#define WBUF_TIMEOUT_SOFTLIMIT 3 -#define WBUF_TIMEOUT_HARDLIMIT 5 - /* Maximum possible inode number (only 32-bit inodes are supported now) */ #define MAX_INUM 0x -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 8/8 v2] netfilter: nf_tables: fix mismatch in big-endian system
From: Liping Zhang commit 10596608c4d62cb8c1c2b806debcbd32fe657e71 upstream. Currently, there are two different methods to store an u16 integer to the u32 data register. For example: u32 *dest = >data[priv->dreg]; 1. *dest = 0; *(u16 *) dest = val_u16; 2. *dest = val_u16; For method 1, the u16 value will be stored like this, either in big-endian or little-endian system: 0 15 31 +-+-+-+-+-+-+-+-+-+-+-+-+ | Value | 0 | +-+-+-+-+-+-+-+-+-+-+-+-+ For method 2, in little-endian system, the u16 value will be the same as listed above. But in big-endian system, the u16 value will be stored like this: 0 15 31 +-+-+-+-+-+-+-+-+-+-+-+-+ | 0 | Value | +-+-+-+-+-+-+-+-+-+-+-+-+ So later we use "memcmp(>data[priv->sreg], data, 2);" to do compare in nft_cmp, nft_lookup expr ..., method 2 will get the wrong result in big-endian system, as 0~15 bits will always be zero. For the similar reason, when loading an u16 value from the u32 data register, we should use "*(u16 *) sreg;" instead of "(u16)*sreg;", the 2nd method will get the wrong value in the big-endian system. So introduce some wrapper functions to store/load an u8 or u16 integer to/from the u32 data register, and use them in the right place. Signed-off-by: Liping Zhang Signed-off-by: Pablo Neira Ayuso --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- include/net/netfilter/nf_tables.h | 29 net/ipv4/netfilter/nft_masq_ipv4.c | 8 +++--- net/ipv4/netfilter/nft_redir_ipv4.c | 8 +++--- net/ipv6/netfilter/nft_masq_ipv6.c | 8 +++--- net/ipv6/netfilter/nft_redir_ipv6.c | 8 +++--- net/netfilter/nft_ct.c | 10 +++ net/netfilter/nft_meta.c| 42 +++-- net/netfilter/nft_nat.c | 8 +++--- 8 files changed, 76 insertions(+), 45 deletions(-) diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h index b02af0bf5777..66f6b84df287 100644 --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h @@ -87,6 +87,35 @@ struct nft_regs { }; }; +/* Store/load an u16 or u8 integer to/from the u32 data register. + * + * Note, when using concatenations, register allocation happens at 32-bit + * level. So for store instruction, pad the rest part with zero to avoid + * garbage values. + */ + +static inline void nft_reg_store16(u32 *dreg, u16 val) +{ + *dreg = 0; + *(u16 *)dreg = val; +} + +static inline void nft_reg_store8(u32 *dreg, u8 val) +{ + *dreg = 0; + *(u8 *)dreg = val; +} + +static inline u16 nft_reg_load16(u32 *sreg) +{ + return *(u16 *)sreg; +} + +static inline u8 nft_reg_load8(u32 *sreg) +{ + return *(u8 *)sreg; +} + static inline void nft_data_copy(u32 *dst, const struct nft_data *src, unsigned int len) { diff --git a/net/ipv4/netfilter/nft_masq_ipv4.c b/net/ipv4/netfilter/nft_masq_ipv4.c index 51ced81b616c..dc3628a396ec 100644 --- a/net/ipv4/netfilter/nft_masq_ipv4.c +++ b/net/ipv4/netfilter/nft_masq_ipv4.c @@ -26,10 +26,10 @@ static void nft_masq_ipv4_eval(const struct nft_expr *expr, memset(, 0, sizeof(range)); range.flags = priv->flags; if (priv->sreg_proto_min) { - range.min_proto.all = - *(__be16 *)>data[priv->sreg_proto_min]; - range.max_proto.all = - *(__be16 *)>data[priv->sreg_proto_max]; + range.min_proto.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_min]); + range.max_proto.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_max]); } regs->verdict.code = nf_nat_masquerade_ipv4(pkt->skb, pkt->hook, , pkt->out); diff --git a/net/ipv4/netfilter/nft_redir_ipv4.c b/net/ipv4/netfilter/nft_redir_ipv4.c index c09d4381427e..f760524e1353 100644 --- a/net/ipv4/netfilter/nft_redir_ipv4.c +++ b/net/ipv4/netfilter/nft_redir_ipv4.c @@ -26,10 +26,10 @@ static void nft_redir_ipv4_eval(const struct nft_expr *expr, memset(, 0, sizeof(mr)); if (priv->sreg_proto_min) { - mr.range[0].min.all = - *(__be16 *)>data[priv->sreg_proto_min]; - mr.range[0].max.all = - *(__be16 *)>data[priv->sreg_proto_max]; + mr.range[0].min.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_min]); + mr.range[0].max.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_max]); mr.range[0].flags |= NF_NAT_RANGE_PROTO_SPECIFIED; } diff --git a/net/ipv6/netfilter/nft_masq_ipv6.c b/net/ipv6/netfilter/nft_masq_ipv6.c index 9597ffb74077..b74a420050c4 100644 --- a/net/ipv6/netfilter/nft_masq_ipv6.c +++
[OpenWrt-Devel] [PATCH 5/8 v2] ubifs: Drop softlimit and delta fields from struct ubifs_wbuf
From: Rafał Miłecki commit 854826c9d526fd81077742c3b000e3f7fcaef3ce upstream. Values of these fields are set during init and never modified. They are used (read) in a single function only. There isn't really any reason to keep them in a struct. It only makes struct just a bit bigger without any visible gain. Signed-off-by: Rafał Miłecki Reviewed-by: Boris Brezillon Signed-off-by: Richard Weinberger --- - This was applied upstream in v4.10 - Should be applied to stable v4.9.y --- fs/ubifs/io.c| 18 ++ fs/ubifs/ubifs.h | 5 - 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 97be41215332..4d6ce4a2a4b6 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c @@ -452,16 +452,22 @@ static enum hrtimer_restart wbuf_timer_callback_nolock(struct hrtimer *timer) */ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) { + ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0); + unsigned long long delta; + + delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT; + delta *= 10ULL; + ubifs_assert(!hrtimer_active(>timer)); + ubifs_assert(delta <= ULONG_MAX); if (wbuf->no_timer) return; dbg_io("set timer for jhead %s, %llu-%llu millisecs", dbg_jhead(wbuf->jhead), - div_u64(ktime_to_ns(wbuf->softlimit), USEC_PER_SEC), - div_u64(ktime_to_ns(wbuf->softlimit) + wbuf->delta, - USEC_PER_SEC)); - hrtimer_start_range_ns(>timer, wbuf->softlimit, wbuf->delta, + div_u64(ktime_to_ns(softlimit), USEC_PER_SEC), + div_u64(ktime_to_ns(softlimit) + delta, USEC_PER_SEC)); + hrtimer_start_range_ns(>timer, softlimit, delta, HRTIMER_MODE_REL); } @@ -1059,10 +1065,6 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf) hrtimer_init(>timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); wbuf->timer.function = wbuf_timer_callback_nolock; - wbuf->softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0); - wbuf->delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT; - wbuf->delta *= 10ULL; - ubifs_assert(wbuf->delta <= ULONG_MAX); return 0; } diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 096035eb29d0..ade4b3137a1d 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -645,9 +645,6 @@ typedef int (*ubifs_lpt_scan_callback)(struct ubifs_info *c, * @io_mutex: serializes write-buffer I/O * @lock: serializes @buf, @lnum, @offs, @avail, @used, @next_ino and @inodes *fields - * @softlimit: soft write-buffer timeout interval - * @delta: hard and soft timeouts delta (the timer expire interval is @softlimit - * and @softlimit + @delta) * @timer: write-buffer timer * @no_timer: non-zero if this write-buffer does not have a timer * @need_sync: non-zero if the timer expired and the wbuf needs sync'ing @@ -676,8 +673,6 @@ struct ubifs_wbuf { int (*sync_callback)(struct ubifs_info *c, int lnum, int free, int pad); struct mutex io_mutex; spinlock_t lock; - ktime_t softlimit; - unsigned long long delta; struct hrtimer timer; unsigned int no_timer:1; unsigned int need_sync:1; -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 4/8 v2] kaweth: use skb_cow_head() to deal with cloned skbs
From: Eric Dumazet commit 39fba7835aacda65284a86e611774cbba71dac20 upstream. We can use skb_cow_head() to properly deal with clones, especially the ones coming from TCP stack that allow their head being modified. This avoids a copy. Signed-off-by: Eric Dumazet Cc: James Hughes Signed-off-by: David S. Miller --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- drivers/net/usb/kaweth.c | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 66b34ddbe216..72d9e7954b0a 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -803,18 +803,12 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb, } /* We now decide whether we can put our special header into the sk_buff */ - if (skb_cloned(skb) || skb_headroom(skb) < 2) { - /* no such luck - we make our own */ - struct sk_buff *copied_skb; - copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC); - dev_kfree_skb_irq(skb); - skb = copied_skb; - if (!copied_skb) { - kaweth->stats.tx_errors++; - netif_start_queue(net); - spin_unlock_irq(>device_lock); - return NETDEV_TX_OK; - } + if (skb_cow_head(skb, 2)) { + kaweth->stats.tx_errors++; + netif_start_queue(net); + spin_unlock_irq(>device_lock); + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; } private_header = (__le16 *)__skb_push(skb, 2); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 3/8 v2] ch9200: use skb_cow_head() to deal with cloned skbs
From: Eric Dumazet commit 6bc6895bdd6744e0136eaa4a11fbdb20a7db4e40 upstream. We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers. skb_cow_head() is the proper helper to deal with this. Fixes: 4a476bd6d1d9 ("usbnet: New driver for QinHeng CH9200 devices") Signed-off-by: Eric Dumazet Cc: James Hughes Cc: Matthew Garrett Signed-off-by: David S. Miller --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- drivers/net/usb/ch9200.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/net/usb/ch9200.c b/drivers/net/usb/ch9200.c index 8a40202c0a17..c4f1c363e24b 100644 --- a/drivers/net/usb/ch9200.c +++ b/drivers/net/usb/ch9200.c @@ -254,14 +254,9 @@ static struct sk_buff *ch9200_tx_fixup(struct usbnet *dev, struct sk_buff *skb, tx_overhead = 0x40; len = skb->len; - if (skb_headroom(skb) < tx_overhead) { - struct sk_buff *skb2; - - skb2 = skb_copy_expand(skb, tx_overhead, 0, flags); + if (skb_cow_head(skb, tx_overhead)) { dev_kfree_skb_any(skb); - skb = skb2; - if (!skb) - return NULL; + return NULL; } __skb_push(skb, tx_overhead); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/8 v2] smsc95xx: Use skb_cow_head to deal with cloned skbs
From: James Hughes commit e9156cd26a495a18706e796f02a81fee41ec14f4 upstream. The driver was failing to check that the SKB wasn't cloned before adding checksum data. Replace existing handling to extend/copy the header buffer with skb_cow_head. Signed-off-by: James Hughes Acked-by: Eric Dumazet Acked-by: Woojung Huh Signed-off-by: David S. Miller --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- drivers/net/usb/smsc95xx.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index e29f4c0767eb..e719ecd69d01 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -2011,13 +2011,13 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, /* We do not advertise SG, so skbs should be already linearized */ BUG_ON(skb_shinfo(skb)->nr_frags); - if (skb_headroom(skb) < overhead) { - struct sk_buff *skb2 = skb_copy_expand(skb, - overhead, 0, flags); + /* Make writable and expand header space by overhead if required */ + if (skb_cow_head(skb, overhead)) { + /* Must deallocate here as returning NULL to indicate error +* means the skb won't be deallocated in the caller. +*/ dev_kfree_skb_any(skb); - skb = skb2; - if (!skb) - return NULL; + return NULL; } if (csum) { -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/8 v2] bridge: multicast to unicast
From: Felix Fietkau commit 6db6f0eae6052b70885562e1733896647ec1d807 upstream. Implements an optional, per bridge port flag and feature to deliver multicast packets to any host on the according port via unicast individually. This is done by copying the packet per host and changing the multicast destination MAC to a unicast one accordingly. multicast-to-unicast works on top of the multicast snooping feature of the bridge. Which means unicast copies are only delivered to hosts which are interested in it and signalized this via IGMP/MLD reports previously. This feature is intended for interface types which have a more reliable and/or efficient way to deliver unicast packets than broadcast ones (e.g. wifi). However, it should only be enabled on interfaces where no IGMPv2/MLDv1 report suppression takes place. This feature is disabled by default. The initial patch and idea is from Felix Fietkau. Signed-off-by: Felix Fietkau [linus.luess...@c0d3.blue: various bug + style fixes, commit message] Signed-off-by: Linus Lüssing Reviewed-by: Nikolay Aleksandrov Signed-off-by: David S. Miller --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- include/linux/if_bridge.h| 1 + include/uapi/linux/if_link.h | 1 + net/bridge/br_forward.c | 39 +++- net/bridge/br_mdb.c | 2 +- net/bridge/br_multicast.c| 90 ++-- net/bridge/br_netlink.c | 5 ++ net/bridge/br_private.h | 3 +- net/bridge/br_sysfs_if.c | 2 + 8 files changed, 114 insertions(+), 29 deletions(-) diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h index c6587c01d951..debc9d5904e5 100644 --- a/include/linux/if_bridge.h +++ b/include/linux/if_bridge.h @@ -46,6 +46,7 @@ struct br_ip_list { #define BR_LEARNING_SYNC BIT(9) #define BR_PROXYARP_WIFI BIT(10) #define BR_MCAST_FLOOD BIT(11) +#define BR_MULTICAST_TO_UNICASTBIT(12) #define BR_DEFAULT_AGEING_TIME (300 * HZ) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index b4fba662cd32..ee4d632d089d 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -319,6 +319,7 @@ enum { IFLA_BRPORT_MULTICAST_ROUTER, IFLA_BRPORT_PAD, IFLA_BRPORT_MCAST_FLOOD, + IFLA_BRPORT_MCAST_TO_UCAST, __IFLA_BRPORT_MAX }; #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index 5b675695c661..30afa130287e 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c @@ -173,6 +173,31 @@ static struct net_bridge_port *maybe_deliver( return p; } +static void maybe_deliver_addr(struct net_bridge_port *p, struct sk_buff *skb, + const unsigned char *addr, bool local_orig) +{ + struct net_device *dev = BR_INPUT_SKB_CB(skb)->brdev; + const unsigned char *src = eth_hdr(skb)->h_source; + + if (!should_deliver(p, skb)) + return; + + /* Even with hairpin, no soliloquies - prevent breaking IPv6 DAD */ + if (skb->dev == p->dev && ether_addr_equal(src, addr)) + return; + + skb = skb_copy(skb, GFP_ATOMIC); + if (!skb) { + dev->stats.tx_dropped++; + return; + } + + if (!is_broadcast_ether_addr(addr)) + memcpy(eth_hdr(skb)->h_dest, addr, ETH_ALEN); + + __br_forward(p, skb, local_orig); +} + /* called under rcu_read_lock */ void br_flood(struct net_bridge *br, struct sk_buff *skb, enum br_pkt_type pkt_type, bool local_rcv, bool local_orig) @@ -241,10 +266,20 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst, rport = rp ? hlist_entry(rp, struct net_bridge_port, rlist) : NULL; - port = (unsigned long)lport > (unsigned long)rport ? - lport : rport; + if ((unsigned long)lport > (unsigned long)rport) { + port = lport; + + if (port->flags & BR_MULTICAST_TO_UNICAST) { + maybe_deliver_addr(lport, skb, p->eth_addr, + local_orig); + goto delivered; + } + } else { + port = rport; + } prev = maybe_deliver(prev, port, skb, local_orig); +delivered: if (IS_ERR(prev)) goto out; if (prev == port) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 6406010e155b..57e94a1b57e1 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -532,7 +532,7 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, break; } - p = br_multicast_new_port_group(port, group, *pp, state); + p =
[OpenWrt-Devel] [PATCH 0/8 v2] Stable material from OpenWrt for v4.9.y
This is a series of patches used in OpenWrt's v4.9 backports that seem to be of generic interest to v4.9.y For the remaining patches I cherry-picked the upstream commits except for (8/8) "netfilter: nf_tables: fix mismatch in big-endian system" where I used OpenWrt's backport. ChangeLog v1->v2: - I have dropped two patches from the series: one was to be applied also to v4.14.y and one was to be applied also to v4.14.y and v4.19.y. The rest are for v4.9.y as they have been merged upstream between v4.9 and v4.14. - The two dropped patches have been sent out separately. - I have added the "commit n upstream." message on the first line of each commit message to fit stable standards. Upstream commits: The list of upstream commits in patch order: 6db6f0eae6052b70885562e1733896647ec1d807 ("bridge: multicast to unicast") e9156cd26a495a18706e796f02a81fee41ec14f4 ("smsc95xx: Use skb_cow_head to deal with cloned skbs") 6bc6895bdd6744e0136eaa4a11fbdb20a7db4e40 ("ch9200: use skb_cow_head() to deal with cloned skbs") 39fba7835aacda65284a86e611774cbba71dac20 ("kaweth: use skb_cow_head() to deal with cloned skbs") 854826c9d526fd81077742c3b000e3f7fcaef3ce ("ubifs: Drop softlimit and delta fields from struct ubifs_wbuf") 1b7fc2c0069f3864a3dda15430b7aded31c0bfcc ("ubifs: Use dirty_writeback_interval value for wbuf timer") cd4b1e34655d46950c065d9284b596cd8d7b28cd ("usb: dwc2: Remove unnecessary kfree") 10596608c4d62cb8c1c2b806debcbd32fe657e71 ("netfilter: nf_tables: fix mismatch in big-endian system") Eric Dumazet (2): ch9200: use skb_cow_head() to deal with cloned skbs kaweth: use skb_cow_head() to deal with cloned skbs Felix Fietkau (1): bridge: multicast to unicast James Hughes (1): smsc95xx: Use skb_cow_head to deal with cloned skbs John Youn (1): usb: dwc2: Remove unnecessary kfree Liping Zhang (1): netfilter: nf_tables: fix mismatch in big-endian system Rafał Miłecki (2): ubifs: Drop softlimit and delta fields from struct ubifs_wbuf ubifs: Use dirty_writeback_interval value for wbuf timer drivers/net/usb/ch9200.c| 9 +-- drivers/net/usb/kaweth.c| 18 ++ drivers/net/usb/smsc95xx.c | 12 ++-- drivers/usb/dwc2/hcd.c | 1 - fs/ubifs/io.c | 18 +++--- fs/ubifs/ubifs.h| 9 --- include/linux/if_bridge.h | 1 + include/net/netfilter/nf_tables.h | 29 ++ include/uapi/linux/if_link.h| 1 + net/bridge/br_forward.c | 39 - net/bridge/br_mdb.c | 2 +- net/bridge/br_multicast.c | 90 + net/bridge/br_netlink.c | 5 ++ net/bridge/br_private.h | 3 +- net/bridge/br_sysfs_if.c| 2 + net/ipv4/netfilter/nft_masq_ipv4.c | 8 +-- net/ipv4/netfilter/nft_redir_ipv4.c | 8 +-- net/ipv6/netfilter/nft_masq_ipv6.c | 8 +-- net/ipv6/netfilter/nft_redir_ipv6.c | 8 +-- net/netfilter/nft_ct.c | 10 ++-- net/netfilter/nft_meta.c| 42 +++--- net/netfilter/nft_nat.c | 8 +-- 22 files changed, 214 insertions(+), 117 deletions(-) -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] uapi/if_ether.h: prevent redefinition of struct ethhdr
From: Hauke Mehrtens commit 6926e041a8920c8ec27e4e155efa760aa01551fd upstream. Musl provides its own ethhdr struct definition. Add a guard to prevent its definition of the appropriate musl header has already been included. glibc does not implement this header, but when glibc will implement this they can just define __UAPI_DEF_ETHHDR 0 to make it work with the kernel. Signed-off-by: Hauke Mehrtens Signed-off-by: David S. Miller --- - This is upstream in v4.15 - This should be applied for stable v4.14.y and v4.9.y --- include/uapi/linux/if_ether.h| 3 +++ include/uapi/linux/libc-compat.h | 6 ++ 2 files changed, 9 insertions(+) diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h index 244e3213ecb0..60ec9114e28f 100644 --- a/include/uapi/linux/if_ether.h +++ b/include/uapi/linux/if_ether.h @@ -23,6 +23,7 @@ #define _UAPI_LINUX_IF_ETHER_H #include +#include /* * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble @@ -150,11 +151,13 @@ * This is an Ethernet frame header. */ +#if __UAPI_DEF_ETHHDR struct ethhdr { unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ unsigned char h_source[ETH_ALEN]; /* source ether addr*/ __be16 h_proto;/* packet type ID field */ } __attribute__((packed)); +#endif #endif /* _UAPI_LINUX_IF_ETHER_H */ diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h index 8254c937c9f4..fc29efaa918c 100644 --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h @@ -264,4 +264,10 @@ #endif /* __GLIBC__ */ +/* Definitions for if_ether.h */ +/* allow libcs like musl to deactivate this, glibc does not implement this. */ +#ifndef __UAPI_DEF_ETHHDR +#define __UAPI_DEF_ETHHDR 1 +#endif + #endif /* _UAPI_LIBC_COMPAT_H */ -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] net: Allow class-e address assignment via ifconfig ioctl
From: Dave Taht commit 65cab850f0eeaa9180bd2e10a231964f33743edf upstream. While most distributions long ago switched to the iproute2 suite of utilities, which allow class-e (240.0.0.0/4) address assignment, distributions relying on busybox, toybox and other forms of ifconfig cannot assign class-e addresses without this kernel patch. While CIDR has been obsolete for 2 decades, and a survey of all the open source code in the world shows the IN_whatever macros are also obsolete... rather than obsolete CIDR from this ioctl entirely, this patch merely enables class-e assignment, sanely. Signed-off-by: Dave Taht Signed-off-by: David S. Miller --- - This commit is upstream in v4.20 - This should ve applied for stable v4.19.y, v4.14.y and v4.9.y --- include/uapi/linux/in.h | 10 +++--- net/ipv4/devinet.c | 5 +++-- net/ipv4/ipconfig.c | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h index 48e8a225b985..f6052e70bf40 100644 --- a/include/uapi/linux/in.h +++ b/include/uapi/linux/in.h @@ -266,10 +266,14 @@ struct sockaddr_in { #defineIN_CLASSD(a)long int) (a)) & 0xf000) == 0xe000) #defineIN_MULTICAST(a) IN_CLASSD(a) -#define IN_MULTICAST_NET 0xF000 +#defineIN_MULTICAST_NET0xe000 -#defineIN_EXPERIMENTAL(a) long int) (a)) & 0xf000) == 0xf000) -#defineIN_BADCLASS(a) IN_EXPERIMENTAL((a)) +#defineIN_BADCLASS(a) long int) (a) ) == 0x) +#defineIN_EXPERIMENTAL(a) IN_BADCLASS((a)) + +#defineIN_CLASSE(a)long int) (a)) & 0xf000) == 0xf000) +#defineIN_CLASSE_NET 0x +#defineIN_CLASSE_NSHIFT0 /* Address to accept any incoming messages. */ #defineINADDR_ANY ((unsigned long int) 0x) diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index ea4bd8a52422..e38042933a27 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -941,17 +941,18 @@ static int inet_abc_len(__be32 addr) { int rc = -1;/* Something else, probably a multicast. */ - if (ipv4_is_zeronet(addr)) + if (ipv4_is_zeronet(addr) || ipv4_is_lbcast(addr)) rc = 0; else { __u32 haddr = ntohl(addr); - if (IN_CLASSA(haddr)) rc = 8; else if (IN_CLASSB(haddr)) rc = 16; else if (IN_CLASSC(haddr)) rc = 24; + else if (IN_CLASSE(haddr)) + rc = 32; } return rc; diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 88212615bf4c..2393e5c106bf 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -429,6 +429,8 @@ static int __init ic_defaults(void) ic_netmask = htonl(IN_CLASSB_NET); else if (IN_CLASSC(ntohl(ic_myaddr))) ic_netmask = htonl(IN_CLASSC_NET); + else if (IN_CLASSE(ntohl(ic_myaddr))) + ic_netmask = htonl(IN_CLASSE_NET); else { pr_err("IP-Config: Unable to guess netmask for address %pI4\n", _myaddr); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 00/10] Stable material from OpenWrt
On Thu, Feb 14, 2019 at 11:42 AM Greg Kroah-Hartman wrote: > Also, some of these are in kernels newer than 4.14, so if I were to > apply them to 4.9 only, someone moving to a newer kernel would have a > regression, which isn't ok. > > 65cab850f0ee ("net: Allow class-e address assignment via ifconfig > ioctl") is one such example of that type of patch. > > So I can't take these as-is, sorry. OK I will look closer for each of them and try to mention which stable each of them should go to, I thought they would all be for v4.9 but I was wrong. I'll update and respin, NP. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 10/10] uapi/if_ether.h: prevent redefinition of struct ethhdr
From: Hauke Mehrtens Musl provides its own ethhdr struct definition. Add a guard to prevent its definition of the appropriate musl header has already been included. glibc does not implement this header, but when glibc will implement this they can just define __UAPI_DEF_ETHHDR 0 to make it work with the kernel. Signed-off-by: Hauke Mehrtens Signed-off-by: David S. Miller --- include/uapi/linux/if_ether.h| 3 +++ include/uapi/linux/libc-compat.h | 6 ++ 2 files changed, 9 insertions(+) diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h index 659b1634de61..b31e2f836317 100644 --- a/include/uapi/linux/if_ether.h +++ b/include/uapi/linux/if_ether.h @@ -22,6 +22,7 @@ #define _UAPI_LINUX_IF_ETHER_H #include +#include /* * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble @@ -139,11 +140,13 @@ * This is an Ethernet frame header. */ +#if __UAPI_DEF_ETHHDR struct ethhdr { unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ unsigned char h_source[ETH_ALEN]; /* source ether addr*/ __be16 h_proto;/* packet type ID field */ } __attribute__((packed)); +#endif #endif /* _UAPI_LINUX_IF_ETHER_H */ diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h index 774cb2db1b89..7c098d68d5e5 100644 --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h @@ -263,4 +263,10 @@ #endif /* __GLIBC__ */ +/* Definitions for if_ether.h */ +/* allow libcs like musl to deactivate this, glibc does not implement this. */ +#ifndef __UAPI_DEF_ETHHDR +#define __UAPI_DEF_ETHHDR 1 +#endif + #endif /* _UAPI_LIBC_COMPAT_H */ -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 09/10] net: Allow class-e address assignment via ifconfig ioctl
From: Dave Taht While most distributions long ago switched to the iproute2 suite of utilities, which allow class-e (240.0.0.0/4) address assignment, distributions relying on busybox, toybox and other forms of ifconfig cannot assign class-e addresses without this kernel patch. While CIDR has been obsolete for 2 decades, and a survey of all the open source code in the world shows the IN_whatever macros are also obsolete... rather than obsolete CIDR from this ioctl entirely, this patch merely enables class-e assignment, sanely. Signed-off-by: Dave Taht Signed-off-by: David S. Miller --- include/uapi/linux/in.h | 10 +++--- net/ipv4/devinet.c | 5 +++-- net/ipv4/ipconfig.c | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h index eaf94919291a..550b234be4a1 100644 --- a/include/uapi/linux/in.h +++ b/include/uapi/linux/in.h @@ -264,10 +264,14 @@ struct sockaddr_in { #defineIN_CLASSD(a)long int) (a)) & 0xf000) == 0xe000) #defineIN_MULTICAST(a) IN_CLASSD(a) -#define IN_MULTICAST_NET 0xF000 +#defineIN_MULTICAST_NET0xe000 -#defineIN_EXPERIMENTAL(a) long int) (a)) & 0xf000) == 0xf000) -#defineIN_BADCLASS(a) IN_EXPERIMENTAL((a)) +#defineIN_BADCLASS(a) long int) (a) ) == 0x) +#defineIN_EXPERIMENTAL(a) IN_BADCLASS((a)) + +#defineIN_CLASSE(a)long int) (a)) & 0xf000) == 0xf000) +#defineIN_CLASSE_NET 0x +#defineIN_CLASSE_NSHIFT0 /* Address to accept any incoming messages. */ #defineINADDR_ANY ((unsigned long int) 0x) diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index f08f984ebc56..32335ed0e9fe 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -898,17 +898,18 @@ static int inet_abc_len(__be32 addr) { int rc = -1;/* Something else, probably a multicast. */ - if (ipv4_is_zeronet(addr)) + if (ipv4_is_zeronet(addr) || ipv4_is_lbcast(addr)) rc = 0; else { __u32 haddr = ntohl(addr); - if (IN_CLASSA(haddr)) rc = 8; else if (IN_CLASSB(haddr)) rc = 16; else if (IN_CLASSC(haddr)) rc = 24; + else if (IN_CLASSE(haddr)) + rc = 32; } return rc; diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index d278b06459ac..ecf19f7ab5fd 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -455,6 +455,8 @@ static int __init ic_defaults(void) ic_netmask = htonl(IN_CLASSB_NET); else if (IN_CLASSC(ntohl(ic_myaddr))) ic_netmask = htonl(IN_CLASSC_NET); + else if (IN_CLASSE(ntohl(ic_myaddr))) + ic_netmask = htonl(IN_CLASSE_NET); else { pr_err("IP-Config: Unable to guess netmask for address %pI4\n", _myaddr); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 08/10] netfilter: nf_tables: fix mismatch in big-endian system
From: Liping Zhang Currently, there are two different methods to store an u16 integer to the u32 data register. For example: u32 *dest = >data[priv->dreg]; 1. *dest = 0; *(u16 *) dest = val_u16; 2. *dest = val_u16; For method 1, the u16 value will be stored like this, either in big-endian or little-endian system: 0 15 31 +-+-+-+-+-+-+-+-+-+-+-+-+ | Value | 0 | +-+-+-+-+-+-+-+-+-+-+-+-+ For method 2, in little-endian system, the u16 value will be the same as listed above. But in big-endian system, the u16 value will be stored like this: 0 15 31 +-+-+-+-+-+-+-+-+-+-+-+-+ | 0 | Value | +-+-+-+-+-+-+-+-+-+-+-+-+ So later we use "memcmp(>data[priv->sreg], data, 2);" to do compare in nft_cmp, nft_lookup expr ..., method 2 will get the wrong result in big-endian system, as 0~15 bits will always be zero. For the similar reason, when loading an u16 value from the u32 data register, we should use "*(u16 *) sreg;" instead of "(u16)*sreg;", the 2nd method will get the wrong value in the big-endian system. So introduce some wrapper functions to store/load an u8 or u16 integer to/from the u32 data register, and use them in the right place. This is OpenWrts backport of upstream commit 10596608c4d62cb8c1c2b806debcbd32fe657e71 "netfilter: nf_tables: fix mismatch in big-endian system", the upstream commit does not work right off. Signed-off-by: Liping Zhang Signed-off-by: Pablo Neira Ayuso --- include/net/netfilter/nf_tables.h | 29 net/ipv4/netfilter/nft_masq_ipv4.c | 8 +++--- net/ipv4/netfilter/nft_redir_ipv4.c | 8 +++--- net/ipv6/netfilter/nft_masq_ipv6.c | 8 +++--- net/ipv6/netfilter/nft_redir_ipv6.c | 8 +++--- net/netfilter/nft_ct.c | 10 +++ net/netfilter/nft_meta.c| 42 +++-- net/netfilter/nft_nat.c | 8 +++--- 8 files changed, 76 insertions(+), 45 deletions(-) diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h index b02af0bf5777..66f6b84df287 100644 --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h @@ -87,6 +87,35 @@ struct nft_regs { }; }; +/* Store/load an u16 or u8 integer to/from the u32 data register. + * + * Note, when using concatenations, register allocation happens at 32-bit + * level. So for store instruction, pad the rest part with zero to avoid + * garbage values. + */ + +static inline void nft_reg_store16(u32 *dreg, u16 val) +{ + *dreg = 0; + *(u16 *)dreg = val; +} + +static inline void nft_reg_store8(u32 *dreg, u8 val) +{ + *dreg = 0; + *(u8 *)dreg = val; +} + +static inline u16 nft_reg_load16(u32 *sreg) +{ + return *(u16 *)sreg; +} + +static inline u8 nft_reg_load8(u32 *sreg) +{ + return *(u8 *)sreg; +} + static inline void nft_data_copy(u32 *dst, const struct nft_data *src, unsigned int len) { diff --git a/net/ipv4/netfilter/nft_masq_ipv4.c b/net/ipv4/netfilter/nft_masq_ipv4.c index 51ced81b616c..dc3628a396ec 100644 --- a/net/ipv4/netfilter/nft_masq_ipv4.c +++ b/net/ipv4/netfilter/nft_masq_ipv4.c @@ -26,10 +26,10 @@ static void nft_masq_ipv4_eval(const struct nft_expr *expr, memset(, 0, sizeof(range)); range.flags = priv->flags; if (priv->sreg_proto_min) { - range.min_proto.all = - *(__be16 *)>data[priv->sreg_proto_min]; - range.max_proto.all = - *(__be16 *)>data[priv->sreg_proto_max]; + range.min_proto.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_min]); + range.max_proto.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_max]); } regs->verdict.code = nf_nat_masquerade_ipv4(pkt->skb, pkt->hook, , pkt->out); diff --git a/net/ipv4/netfilter/nft_redir_ipv4.c b/net/ipv4/netfilter/nft_redir_ipv4.c index c09d4381427e..f760524e1353 100644 --- a/net/ipv4/netfilter/nft_redir_ipv4.c +++ b/net/ipv4/netfilter/nft_redir_ipv4.c @@ -26,10 +26,10 @@ static void nft_redir_ipv4_eval(const struct nft_expr *expr, memset(, 0, sizeof(mr)); if (priv->sreg_proto_min) { - mr.range[0].min.all = - *(__be16 *)>data[priv->sreg_proto_min]; - mr.range[0].max.all = - *(__be16 *)>data[priv->sreg_proto_max]; + mr.range[0].min.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_min]); + mr.range[0].max.all = (__force __be16)nft_reg_load16( + >data[priv->sreg_proto_max]); mr.range[0].flags |= NF_NAT_RANGE_PROTO_SPECIFIED; } diff --git a/net/ipv6/netfilter/nft_masq_ipv6.c b/net/ipv6/netfilter/nft_masq_ipv6.c index 9597ffb74077..b74a420050c4
[OpenWrt-Devel] [PATCH 05/10] ubifs: Drop softlimit and delta fields from struct ubifs_wbuf
From: Rafał Miłecki Values of these fields are set during init and never modified. They are used (read) in a single function only. There isn't really any reason to keep them in a struct. It only makes struct just a bit bigger without any visible gain. Signed-off-by: Rafał Miłecki Reviewed-by: Boris Brezillon Signed-off-by: Richard Weinberger --- fs/ubifs/io.c| 18 ++ fs/ubifs/ubifs.h | 5 - 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 97be41215332..4d6ce4a2a4b6 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c @@ -452,16 +452,22 @@ static enum hrtimer_restart wbuf_timer_callback_nolock(struct hrtimer *timer) */ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) { + ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0); + unsigned long long delta; + + delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT; + delta *= 10ULL; + ubifs_assert(!hrtimer_active(>timer)); + ubifs_assert(delta <= ULONG_MAX); if (wbuf->no_timer) return; dbg_io("set timer for jhead %s, %llu-%llu millisecs", dbg_jhead(wbuf->jhead), - div_u64(ktime_to_ns(wbuf->softlimit), USEC_PER_SEC), - div_u64(ktime_to_ns(wbuf->softlimit) + wbuf->delta, - USEC_PER_SEC)); - hrtimer_start_range_ns(>timer, wbuf->softlimit, wbuf->delta, + div_u64(ktime_to_ns(softlimit), USEC_PER_SEC), + div_u64(ktime_to_ns(softlimit) + delta, USEC_PER_SEC)); + hrtimer_start_range_ns(>timer, softlimit, delta, HRTIMER_MODE_REL); } @@ -1059,10 +1065,6 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf) hrtimer_init(>timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); wbuf->timer.function = wbuf_timer_callback_nolock; - wbuf->softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0); - wbuf->delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT; - wbuf->delta *= 10ULL; - ubifs_assert(wbuf->delta <= ULONG_MAX); return 0; } diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 096035eb29d0..ade4b3137a1d 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -645,9 +645,6 @@ typedef int (*ubifs_lpt_scan_callback)(struct ubifs_info *c, * @io_mutex: serializes write-buffer I/O * @lock: serializes @buf, @lnum, @offs, @avail, @used, @next_ino and @inodes *fields - * @softlimit: soft write-buffer timeout interval - * @delta: hard and soft timeouts delta (the timer expire interval is @softlimit - * and @softlimit + @delta) * @timer: write-buffer timer * @no_timer: non-zero if this write-buffer does not have a timer * @need_sync: non-zero if the timer expired and the wbuf needs sync'ing @@ -676,8 +673,6 @@ struct ubifs_wbuf { int (*sync_callback)(struct ubifs_info *c, int lnum, int free, int pad); struct mutex io_mutex; spinlock_t lock; - ktime_t softlimit; - unsigned long long delta; struct hrtimer timer; unsigned int no_timer:1; unsigned int need_sync:1; -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 07/10] usb: dwc2: Remove unnecessary kfree
From: John Youn This shouldn't be freed by the HCD as it is owned by the core and allocated with devm_kzalloc. Signed-off-by: John Youn Signed-off-by: Felipe Balbi --- drivers/usb/dwc2/hcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 984d6aae7529..0e5435330c07 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -5202,7 +5202,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) error2: usb_put_hcd(hcd); error1: - kfree(hsotg->core_params); #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS kfree(hsotg->last_frame_num_array); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 06/10] ubifs: Use dirty_writeback_interval value for wbuf timer
From: Rafał Miłecki Right now wbuf timer has hardcoded timeouts and there is no place for manual adjustments. Some projects / cases many need that though. Few file systems allow doing that by respecting dirty_writeback_interval that can be set using sysctl (dirty_writeback_centisecs). Lowering dirty_writeback_interval could be some way of dealing with user space apps lacking proper fsyncs. This is definitely *not* a perfect solution but we don't have ideal (user space) world. There were already advanced discussions on this matter, mostly when ext4 was introduced and it wasn't behaving as ext3. Anyway, the final decision was to add some hacks to the ext4, as trying to fix whole user space or adding new API was pointless. We can't (and shouldn't?) just follow ext4. We can't e.g. sync on close as this would cause too many commits and flash wearing. On the other hand we still should allow some trade-off between -o sync and default wbuf timeout. Respecting dirty_writeback_interval should allow some sane cutomizations if used warily. Signed-off-by: Rafał Miłecki Reviewed-by: Boris Brezillon Signed-off-by: Richard Weinberger --- fs/ubifs/io.c| 8 fs/ubifs/ubifs.h | 4 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 4d6ce4a2a4b6..3be28900bf37 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c @@ -452,11 +452,11 @@ static enum hrtimer_restart wbuf_timer_callback_nolock(struct hrtimer *timer) */ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) { - ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0); - unsigned long long delta; + ktime_t softlimit = ms_to_ktime(dirty_writeback_interval * 10); + unsigned long long delta = dirty_writeback_interval; - delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT; - delta *= 10ULL; + /* centi to milli, milli to nano, then 10% */ + delta *= 10ULL * NSEC_PER_MSEC / 10ULL; ubifs_assert(!hrtimer_active(>timer)); ubifs_assert(delta <= ULONG_MAX); diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index ade4b3137a1d..b8b18d446a49 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -83,10 +83,6 @@ */ #define BGT_NAME_PATTERN "ubifs_bgt%d_%d" -/* Write-buffer synchronization timeout interval in seconds */ -#define WBUF_TIMEOUT_SOFTLIMIT 3 -#define WBUF_TIMEOUT_HARDLIMIT 5 - /* Maximum possible inode number (only 32-bit inodes are supported now) */ #define MAX_INUM 0x -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 01/10] bridge: multicast to unicast
From: Felix Fietkau Implements an optional, per bridge port flag and feature to deliver multicast packets to any host on the according port via unicast individually. This is done by copying the packet per host and changing the multicast destination MAC to a unicast one accordingly. multicast-to-unicast works on top of the multicast snooping feature of the bridge. Which means unicast copies are only delivered to hosts which are interested in it and signalized this via IGMP/MLD reports previously. This feature is intended for interface types which have a more reliable and/or efficient way to deliver unicast packets than broadcast ones (e.g. wifi). However, it should only be enabled on interfaces where no IGMPv2/MLDv1 report suppression takes place. This feature is disabled by default. The initial patch and idea is from Felix Fietkau. Signed-off-by: Felix Fietkau [linus.luess...@c0d3.blue: various bug + style fixes, commit message] Signed-off-by: Linus Lüssing Reviewed-by: Nikolay Aleksandrov Signed-off-by: David S. Miller --- include/linux/if_bridge.h| 1 + include/uapi/linux/if_link.h | 1 + net/bridge/br_forward.c | 39 +++- net/bridge/br_mdb.c | 2 +- net/bridge/br_multicast.c| 90 ++-- net/bridge/br_netlink.c | 5 ++ net/bridge/br_private.h | 3 +- net/bridge/br_sysfs_if.c | 2 + 8 files changed, 114 insertions(+), 29 deletions(-) diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h index c6587c01d951..debc9d5904e5 100644 --- a/include/linux/if_bridge.h +++ b/include/linux/if_bridge.h @@ -46,6 +46,7 @@ struct br_ip_list { #define BR_LEARNING_SYNC BIT(9) #define BR_PROXYARP_WIFI BIT(10) #define BR_MCAST_FLOOD BIT(11) +#define BR_MULTICAST_TO_UNICASTBIT(12) #define BR_DEFAULT_AGEING_TIME (300 * HZ) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index b4fba662cd32..ee4d632d089d 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -319,6 +319,7 @@ enum { IFLA_BRPORT_MULTICAST_ROUTER, IFLA_BRPORT_PAD, IFLA_BRPORT_MCAST_FLOOD, + IFLA_BRPORT_MCAST_TO_UCAST, __IFLA_BRPORT_MAX }; #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index 5b675695c661..30afa130287e 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c @@ -173,6 +173,31 @@ static struct net_bridge_port *maybe_deliver( return p; } +static void maybe_deliver_addr(struct net_bridge_port *p, struct sk_buff *skb, + const unsigned char *addr, bool local_orig) +{ + struct net_device *dev = BR_INPUT_SKB_CB(skb)->brdev; + const unsigned char *src = eth_hdr(skb)->h_source; + + if (!should_deliver(p, skb)) + return; + + /* Even with hairpin, no soliloquies - prevent breaking IPv6 DAD */ + if (skb->dev == p->dev && ether_addr_equal(src, addr)) + return; + + skb = skb_copy(skb, GFP_ATOMIC); + if (!skb) { + dev->stats.tx_dropped++; + return; + } + + if (!is_broadcast_ether_addr(addr)) + memcpy(eth_hdr(skb)->h_dest, addr, ETH_ALEN); + + __br_forward(p, skb, local_orig); +} + /* called under rcu_read_lock */ void br_flood(struct net_bridge *br, struct sk_buff *skb, enum br_pkt_type pkt_type, bool local_rcv, bool local_orig) @@ -241,10 +266,20 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst, rport = rp ? hlist_entry(rp, struct net_bridge_port, rlist) : NULL; - port = (unsigned long)lport > (unsigned long)rport ? - lport : rport; + if ((unsigned long)lport > (unsigned long)rport) { + port = lport; + + if (port->flags & BR_MULTICAST_TO_UNICAST) { + maybe_deliver_addr(lport, skb, p->eth_addr, + local_orig); + goto delivered; + } + } else { + port = rport; + } prev = maybe_deliver(prev, port, skb, local_orig); +delivered: if (IS_ERR(prev)) goto out; if (prev == port) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 6406010e155b..57e94a1b57e1 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -532,7 +532,7 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, break; } - p = br_multicast_new_port_group(port, group, *pp, state); + p = br_multicast_new_port_group(port, group, *pp, state, NULL); if (unlikely(!p)) return -ENOMEM; rcu_assign_pointer(*pp,
[OpenWrt-Devel] [PATCH 04/10] kaweth: use skb_cow_head() to deal with cloned skbs
From: Eric Dumazet We can use skb_cow_head() to properly deal with clones, especially the ones coming from TCP stack that allow their head being modified. This avoids a copy. Signed-off-by: Eric Dumazet Cc: James Hughes Signed-off-by: David S. Miller --- drivers/net/usb/kaweth.c | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 66b34ddbe216..72d9e7954b0a 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -803,18 +803,12 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb, } /* We now decide whether we can put our special header into the sk_buff */ - if (skb_cloned(skb) || skb_headroom(skb) < 2) { - /* no such luck - we make our own */ - struct sk_buff *copied_skb; - copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC); - dev_kfree_skb_irq(skb); - skb = copied_skb; - if (!copied_skb) { - kaweth->stats.tx_errors++; - netif_start_queue(net); - spin_unlock_irq(>device_lock); - return NETDEV_TX_OK; - } + if (skb_cow_head(skb, 2)) { + kaweth->stats.tx_errors++; + netif_start_queue(net); + spin_unlock_irq(>device_lock); + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; } private_header = (__le16 *)__skb_push(skb, 2); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 03/10] ch9200: use skb_cow_head() to deal with cloned skbs
From: Eric Dumazet We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers. skb_cow_head() is the proper helper to deal with this. Fixes: 4a476bd6d1d9 ("usbnet: New driver for QinHeng CH9200 devices") Signed-off-by: Eric Dumazet Cc: James Hughes Cc: Matthew Garrett Signed-off-by: David S. Miller --- drivers/net/usb/ch9200.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/net/usb/ch9200.c b/drivers/net/usb/ch9200.c index 8a40202c0a17..c4f1c363e24b 100644 --- a/drivers/net/usb/ch9200.c +++ b/drivers/net/usb/ch9200.c @@ -254,14 +254,9 @@ static struct sk_buff *ch9200_tx_fixup(struct usbnet *dev, struct sk_buff *skb, tx_overhead = 0x40; len = skb->len; - if (skb_headroom(skb) < tx_overhead) { - struct sk_buff *skb2; - - skb2 = skb_copy_expand(skb, tx_overhead, 0, flags); + if (skb_cow_head(skb, tx_overhead)) { dev_kfree_skb_any(skb); - skb = skb2; - if (!skb) - return NULL; + return NULL; } __skb_push(skb, tx_overhead); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 02/10] smsc95xx: Use skb_cow_head to deal with cloned skbs
From: James Hughes The driver was failing to check that the SKB wasn't cloned before adding checksum data. Replace existing handling to extend/copy the header buffer with skb_cow_head. Signed-off-by: James Hughes Acked-by: Eric Dumazet Acked-by: Woojung Huh Signed-off-by: David S. Miller --- drivers/net/usb/smsc95xx.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index e29f4c0767eb..e719ecd69d01 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -2011,13 +2011,13 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, /* We do not advertise SG, so skbs should be already linearized */ BUG_ON(skb_shinfo(skb)->nr_frags); - if (skb_headroom(skb) < overhead) { - struct sk_buff *skb2 = skb_copy_expand(skb, - overhead, 0, flags); + /* Make writable and expand header space by overhead if required */ + if (skb_cow_head(skb, overhead)) { + /* Must deallocate here as returning NULL to indicate error +* means the skb won't be deallocated in the caller. +*/ dev_kfree_skb_any(skb); - skb = skb2; - if (!skb) - return NULL; + return NULL; } if (csum) { -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 00/10] Stable material from OpenWrt
This is a series of patches used in OpenWrt's v4.9 backports that seem to be of generic interest to v4.9.y As a bunch of commits hit networking I CC DaveM and here so the can nod/object to these, I think the want a bit of control over what goes into networking stable. I avoided two patch sets dealing with IPv6 tunneling and netfilter that seem to still be fixed and I feel generally incompetent about. For the remaining patches I cherry-picked the upstream commits except for (8/10) "netfilter: nf_tables: fix mismatch in big-endian system" where I used OpenWrt's backport. The list of upstream commits in patch order: 6db6f0eae6052b70885562e1733896647ec1d807 "bridge: multicast to unicast" e9156cd26a495a18706e796f02a81fee41ec14f4 "smsc95xx: Use skb_cow_head to deal with cloned skbs" 6bc6895bdd6744e0136eaa4a11fbdb20a7db4e40 "ch9200: use skb_cow_head() to deal with cloned skbs" 39fba7835aacda65284a86e611774cbba71dac20 "kaweth: use skb_cow_head() to deal with cloned skbs" 854826c9d526fd81077742c3b000e3f7fcaef3ce "ubifs: Drop softlimit and delta fields from struct ubifs_wbuf" 1b7fc2c0069f3864a3dda15430b7aded31c0bfcc "ubifs: Use dirty_writeback_interval value for wbuf timer" cd4b1e34655d46950c065d9284b596cd8d7b28cd "usb: dwc2: Remove unnecessary kfree" 10596608c4d62cb8c1c2b806debcbd32fe657e7 "netfilter: nf_tables: fix mismatch in big-endian system" 65cab850f0eeaa9180bd2e10a231964f33743edf "net: Allow class-e address assignment via ifconfig ioctl" 6926e041a8920c8ec27e4e155efa760aa01551fd "uapi/if_ether.h: prevent redefinition of struct ethhdr" Dave Taht (1): net: Allow class-e address assignment via ifconfig ioctl Eric Dumazet (2): ch9200: use skb_cow_head() to deal with cloned skbs kaweth: use skb_cow_head() to deal with cloned skbs Felix Fietkau (1): bridge: multicast to unicast Hauke Mehrtens (1): uapi/if_ether.h: prevent redefinition of struct ethhdr James Hughes (1): smsc95xx: Use skb_cow_head to deal with cloned skbs John Youn (1): usb: dwc2: Remove unnecessary kfree Liping Zhang (1): netfilter: nf_tables: fix mismatch in big-endian system Rafał Miłecki (2): ubifs: Drop softlimit and delta fields from struct ubifs_wbuf ubifs: Use dirty_writeback_interval value for wbuf timer drivers/net/usb/ch9200.c| 9 +-- drivers/net/usb/kaweth.c| 18 ++ drivers/net/usb/smsc95xx.c | 12 ++-- drivers/usb/dwc2/hcd.c | 1 - fs/ubifs/io.c | 18 +++--- fs/ubifs/ubifs.h| 9 --- include/linux/if_bridge.h | 1 + include/net/netfilter/nf_tables.h | 29 ++ include/uapi/linux/if_ether.h | 3 + include/uapi/linux/if_link.h| 1 + include/uapi/linux/in.h | 10 +++- include/uapi/linux/libc-compat.h| 6 ++ net/bridge/br_forward.c | 39 - net/bridge/br_mdb.c | 2 +- net/bridge/br_multicast.c | 90 + net/bridge/br_netlink.c | 5 ++ net/bridge/br_private.h | 3 +- net/bridge/br_sysfs_if.c| 2 + net/ipv4/devinet.c | 5 +- net/ipv4/ipconfig.c | 2 + net/ipv4/netfilter/nft_masq_ipv4.c | 8 +-- net/ipv4/netfilter/nft_redir_ipv4.c | 8 +-- net/ipv6/netfilter/nft_masq_ipv6.c | 8 +-- net/ipv6/netfilter/nft_redir_ipv6.c | 8 +-- net/netfilter/nft_ct.c | 10 ++-- net/netfilter/nft_meta.c| 42 +++--- net/netfilter/nft_nat.c | 8 +-- 27 files changed, 235 insertions(+), 122 deletions(-) -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/2] gemini: Name binary "bootpart.tar.gz"
This factory binary i supposed to actually be unzipped and untarred by the user as part of the installation process (this NAS boots from harddisk), so name it "bootpart.tar.gz" and not "factory.bin" so it is helpful for users. Signed-off-by: Linus Walleij --- target/linux/gemini/image/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index 21a375d75307..1ec1b095023c 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -123,8 +123,8 @@ define Device/dlink_dns-313 DEVICE_TITLE := D-Link DNS-313 1-Bay Network Storage Enclosure DEVICE_DTS := gemini-dlink-dns-313 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) - IMAGES := factory.bin - IMAGE/factory.bin := dns313-images + IMAGES := bootpart.tar.gz + IMAGE/bootpart.tar.gz := dns313-images endef TARGET_DEVICES += dlink_dns-313 -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/2] gemini: Fix typo
It's kmod-ledtrig-* not kmod-led-trig-*. Signed-off-by: Linus Walleij --- target/linux/gemini/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/gemini/Makefile b/target/linux/gemini/Makefile index 03f0fdbb1d6c..38a4f254de4a 100644 --- a/target/linux/gemini/Makefile +++ b/target/linux/gemini/Makefile @@ -26,7 +26,7 @@ include $(INCLUDE_DIR)/target.mk DEFAULT_PACKAGES += \ kmod-usb-core kmod-usb-fotg210 \ kmod-usb-ledtrig-usbport \ - kmod-leds-gpio kmod-led-trig-heartbeat \ + kmod-leds-gpio kmod-ledtrig-heartbeat \ kmod-gpio-button-hotplug $(eval $(call BuildTarget)) -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/2 v3] gemini: Add v4.19 kernel patches
This is the remainder of kernel patches for the v4.19 kernel. A whole slew of the previous patch stack is now upstream, so this mainly contains the stuff that was added upstream between v4.19 and v5.0-rc1, and then the USB FOTG201 patches from Hans. Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Resend. ChangeLog v1->v2: - Resend. --- ...pinctrl-gemini-Mask-and-set-properly.patch | 36 +++ ...inctrl-gemini-Fix-up-TVC-clock-group.patch | 146 ...nctrl-gemini-Drop-noisy-debug-prints.patch | 87 .../0004-boot-sq201-from-sda1.patch | 25 +++ ...hysmap_of-Move-custom-initialization.patch | 52 + ...physmap_of_gemini-Handle-pin-control.patch | 194 ...he-D-Link-DIR-685-MTD-partition-info.patch | 71 ++ ...8-ARM-dts-Enable-Gemini-flash-access.patch | 169 ++ ...rtitions-Add-RedBoot-FIS-DT-bindings.patch | 51 + ...ns-Add-second-compatible-for-redboot.patch | 77 +++ ...11-ARM-dts-Fix-up-SQ201-flash-access.patch | 73 ++ ...ARM-dts-Blank-D-Link-DIR-685-console.patch | 30 +++ ...ost-fotg2-add-silicon-clock-handling.patch | 123 ++ ...st-add-DT-bindings-for-faraday-fotg2.patch | 69 ++ ...b-host-fotg2-add-device-tree-probing.patch | 48 ...t-fotg2-add-Gemini-specific-handling.patch | 138 ...t-fotg2-restart-hcd-after-port-reset.patch | 32 +++ ...he-FOTG210-USB-host-to-Gemini-boards.patch | 210 ++ 18 files changed, 1631 insertions(+) create mode 100644 target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch create mode 100644 target/linux/gemini/patches-4.19/0002-pinctrl-gemini-Fix-up-TVC-clock-group.patch create mode 100644 target/linux/gemini/patches-4.19/0003-pinctrl-gemini-Drop-noisy-debug-prints.patch create mode 100644 target/linux/gemini/patches-4.19/0004-boot-sq201-from-sda1.patch create mode 100644 target/linux/gemini/patches-4.19/0005-mtd-physmap_of-Move-custom-initialization.patch create mode 100644 target/linux/gemini/patches-4.19/0006-mtd-physmap_of_gemini-Handle-pin-control.patch create mode 100644 target/linux/gemini/patches-4.19/0007-ARM-dts-Fix-up-the-D-Link-DIR-685-MTD-partition-info.patch create mode 100644 target/linux/gemini/patches-4.19/0008-ARM-dts-Enable-Gemini-flash-access.patch create mode 100644 target/linux/gemini/patches-4.19/0009-mtd-partitions-Add-RedBoot-FIS-DT-bindings.patch create mode 100644 target/linux/gemini/patches-4.19/0010-mtd-partitions-Add-second-compatible-for-redboot.patch create mode 100644 target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch create mode 100644 target/linux/gemini/patches-4.19/0012-ARM-dts-Blank-D-Link-DIR-685-console.patch create mode 100644 target/linux/gemini/patches-4.19/0013-usb-host-fotg2-add-silicon-clock-handling.patch create mode 100644 target/linux/gemini/patches-4.19/0014-usb-host-add-DT-bindings-for-faraday-fotg2.patch create mode 100644 target/linux/gemini/patches-4.19/0015-usb-host-fotg2-add-device-tree-probing.patch create mode 100644 target/linux/gemini/patches-4.19/0016-usb-host-fotg2-add-Gemini-specific-handling.patch create mode 100644 target/linux/gemini/patches-4.19/0017-usb-host-fotg2-restart-hcd-after-port-reset.patch create mode 100644 target/linux/gemini/patches-4.19/0018-ARM-dts-Add-the-FOTG210-USB-host-to-Gemini-boards.patch diff --git a/target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch b/target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch new file mode 100644 index ..3cc7bad8b84c --- /dev/null +++ b/target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch @@ -0,0 +1,36 @@ +From f8ac3d3472a8dc99c8647a637611d146d88be8cb Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Tue, 9 Oct 2018 10:09:14 +0200 +Subject: [PATCH 01/18] pinctrl: gemini: Mask and set properly + +The code was written under the assumption that the +regmap_update_bits() would mask the bits in the mask and +set the bits in the value. + +It missed the points that it will not set bits in the value +unless these are also masked in the mask. Set value bits +that are not in the mask will simply be ignored. + +Fixes: 06351d133dea ("pinctrl: add a Gemini SoC pin controller") +Signed-off-by: Linus Walleij +--- + drivers/pinctrl/pinctrl-gemini.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/pinctrl/pinctrl-gemini.c b/drivers/pinctrl/pinctrl-gemini.c +index fa7d998e1d5a..1e484a36ff07 100644 +--- a/drivers/pinctrl/pinctrl-gemini.c b/drivers/pinctrl/pinctrl-gemini.c +@@ -2184,7 +2184,8 @@ static int gemini_pmx_set_mux(struct pinctrl_dev *pctldev, +func->name, grp->name); + + regmap_read(pmx->map, GLOBAL_MISC_CTRL, ); +- regmap_update_bits(pmx->map, GLOBAL_MISC_CTRL, grp->mask, ++ regmap_update_bits(pmx->map, GLOBAL_MISC_CTRL, ++
[OpenWrt-Devel] [PATCH 2/2 v3] gemini: Add a config for kernel v4.19
This adds a config for kernel v4.19 to the Gemini target. Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Just add the new config, don't switch kernel yet. - Add missing CONFIG_USB_ROLE_SWITCH as disabled. ChangeLog v1->v2: - Run the config through OpenWrt make kernel_oldconfig and inspect the result. Looks good now. --- target/linux/gemini/config-4.19 | 495 1 file changed, 495 insertions(+) create mode 100644 target/linux/gemini/config-4.19 diff --git a/target/linux/gemini/config-4.19 b/target/linux/gemini/config-4.19 new file mode 100644 index ..7025ec149cf4 --- /dev/null +++ b/target/linux/gemini/config-4.19 @@ -0,0 +1,495 @@ +CONFIG_ALIGNMENT_TRAP=y +CONFIG_AMBA_PL08X=y +CONFIG_ARCH_CLOCKSOURCE_DATA=y +CONFIG_ARCH_GEMINI=y +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y +CONFIG_ARCH_HAS_ELF_RANDOMIZE=y +CONFIG_ARCH_HAS_FORTIFY_SOURCE=y +CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y +CONFIG_ARCH_HAS_KCOV=y +CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE=y +CONFIG_ARCH_HAS_PHYS_TO_DMA=y +CONFIG_ARCH_HAS_RESET_CONTROLLER=y +CONFIG_ARCH_HAS_SET_MEMORY=y +CONFIG_ARCH_HAS_SG_CHAIN=y +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y +CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +# CONFIG_ARCH_MOXART is not set +CONFIG_ARCH_MULTIPLATFORM=y +CONFIG_ARCH_MULTI_V4=y +# CONFIG_ARCH_MULTI_V4T is not set +CONFIG_ARCH_MULTI_V4_V5=y +# CONFIG_ARCH_MULTI_V5 is not set +CONFIG_ARCH_NR_GPIO=0 +CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y +CONFIG_ARCH_SUPPORTS_UPROBES=y +CONFIG_ARCH_USE_BUILTIN_BSWAP=y +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y +CONFIG_ARCH_WANT_GENERAL_HUGETLB=y +CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y +CONFIG_ARM=y +CONFIG_ARM_AMBA=y +CONFIG_ARM_APPENDED_DTB=y +# CONFIG_ARM_ATAG_DTB_COMPAT is not set +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_SP805_WATCHDOG is not set +CONFIG_ARM_UNWIND=y +CONFIG_ATA=y +CONFIG_ATAGS=y +CONFIG_ATA_VERBOSE_ERROR=y +CONFIG_AUTO_ZRELADDR=y +CONFIG_BINFMT_MISC=y +CONFIG_BLK_DEV_SD=y +CONFIG_BLK_MQ_PCI=y +CONFIG_BLK_SCSI_REQUEST=y +CONFIG_BOUNCE=y +# CONFIG_BPF_SYSCALL is not set +CONFIG_CLKDEV_LOOKUP=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=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_CMDLINE="console=ttyS0,19200n8" +CONFIG_CMDLINE_FROM_BOOTLOADER=y +CONFIG_COMMON_CLK=y +CONFIG_COMMON_CLK_GEMINI=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_COREDUMP=y +CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y +CONFIG_CPU_32v4=y +CONFIG_CPU_ABRT_EV4=y +# CONFIG_CPU_BPREDICT_DISABLE is not set +CONFIG_CPU_CACHE_FA=y +CONFIG_CPU_CACHE_VIVT=y +CONFIG_CPU_COPY_FA=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y +# CONFIG_CPU_DCACHE_WRITETHROUGH is not set +CONFIG_CPU_FA526=y +# CONFIG_CPU_ICACHE_DISABLE is not set +CONFIG_CPU_NO_EFFICIENT_FFS=y +CONFIG_CPU_PABRT_LEGACY=y +CONFIG_CPU_TLB_FA=y +CONFIG_CPU_USE_DOMAINS=y +CONFIG_CRASH_CORE=y +CONFIG_CRC16=y +# CONFIG_CRC32_SARWATE is not set +CONFIG_CRC32_SLICEBY8=y +CONFIG_CRC_CCITT=y +CONFIG_CRC_ITU_T=y +CONFIG_CROSS_MEMORY_ATTACH=y +CONFIG_CRYPTO_AEAD=y +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_CCM=y +CONFIG_CRYPTO_CMAC=y +CONFIG_CRYPTO_CRC32C=y +CONFIG_CRYPTO_CTR=y +CONFIG_CRYPTO_DES=y +CONFIG_CRYPTO_DRBG=y +CONFIG_CRYPTO_DRBG_HMAC=y +CONFIG_CRYPTO_DRBG_MENU=y +CONFIG_CRYPTO_ECB=y +CONFIG_CRYPTO_ECHAINIV=y +CONFIG_CRYPTO_GCM=y +CONFIG_CRYPTO_GF128MUL=y +CONFIG_CRYPTO_GHASH=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_HMAC=y +CONFIG_CRYPTO_HW=y +CONFIG_CRYPTO_JITTERENTROPY=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +CONFIG_CRYPTO_MD4=y +CONFIG_CRYPTO_MD5=y +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_NULL2=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_RNG_DEFAULT=y +CONFIG_CRYPTO_SEQIV=y +CONFIG_CRYPTO_SHA256=y +CONFIG_CRYPTO_WORKQUEUE=y +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S" +CONFIG_DEBUG_MEMORY_INIT=y +# CONFIG_DEBUG_USER is not set +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_DEFAULT_CFQ=y +# CONFIG_DEFAULT_DEADLINE is not set +CONFIG_DEFAULT_IOSCHED="cfq" +CONFIG_DMADEVICES=y +CONFIG_DMATEST=y +CONFIG_DMA_CMA=y +CONFIG_DMA_ENGINE=y +CONFIG_DMA_ENGINE_RAID=y +CONFIG_DMA_OF=y +CONFIG_DMA_SHARED_BUFFER=y +CONFIG_DMA_VIRTUAL_CHANNELS=y +CONFIG_DRM=y +CONFIG_DRM_BRIDGE=y +# CONFIG_DRM_CDNS_DSI is not set +# CONFIG_DRM_DEBUG_SELFTEST is not set +CONFIG_DRM_GEM_CMA_HELPER=y +# CONFIG_DRM_I2C_NXP_TDA9950 is not set +CONFIG_DRM_KMS_CMA_HELPER=y +CONFIG_DRM_KMS_FB_HELPER=y +CONFIG_DRM_KMS_HELPER=y +CONFIG_DRM_PANEL
[OpenWrt-Devel] [PATCH 0/2 v3] Add Gemini kernel v4.19 files
This add the Gemini platform files to use kernel v4.19. We do not switch to kernel v4.19 yet, let's do that later. Since many of the in-flight patches are upstream in v4.19 we cut down a bit on the patch burden with this, and we also invented and patched some new stuff. The patches are also available here: https://dflund.se/~triad/krad/gemini/openwrt/ On popular request also pushed to github: https://github.com/linusw/openwrt Branch "gemini-v4.19" The patches on that branch include full v4.19 enablement (which should not be applied to OpenWrt) Linus Walleij (2): gemini: Add v4.19 kernel patches gemini: Add a config for kernel v4.19 target/linux/gemini/config-4.19 | 495 ++ ...pinctrl-gemini-Mask-and-set-properly.patch | 36 ++ ...inctrl-gemini-Fix-up-TVC-clock-group.patch | 146 ++ ...nctrl-gemini-Drop-noisy-debug-prints.patch | 87 +++ .../0004-boot-sq201-from-sda1.patch | 25 + ...hysmap_of-Move-custom-initialization.patch | 52 ++ ...physmap_of_gemini-Handle-pin-control.patch | 194 +++ ...he-D-Link-DIR-685-MTD-partition-info.patch | 71 +++ ...8-ARM-dts-Enable-Gemini-flash-access.patch | 169 ++ ...rtitions-Add-RedBoot-FIS-DT-bindings.patch | 51 ++ ...ns-Add-second-compatible-for-redboot.patch | 77 +++ ...11-ARM-dts-Fix-up-SQ201-flash-access.patch | 73 +++ ...ARM-dts-Blank-D-Link-DIR-685-console.patch | 30 ++ ...ost-fotg2-add-silicon-clock-handling.patch | 123 + ...st-add-DT-bindings-for-faraday-fotg2.patch | 69 +++ ...b-host-fotg2-add-device-tree-probing.patch | 48 ++ ...t-fotg2-add-Gemini-specific-handling.patch | 138 + ...t-fotg2-restart-hcd-after-port-reset.patch | 32 ++ ...he-FOTG210-USB-host-to-Gemini-boards.patch | 210 19 files changed, 2126 insertions(+) create mode 100644 target/linux/gemini/config-4.19 create mode 100644 target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch create mode 100644 target/linux/gemini/patches-4.19/0002-pinctrl-gemini-Fix-up-TVC-clock-group.patch create mode 100644 target/linux/gemini/patches-4.19/0003-pinctrl-gemini-Drop-noisy-debug-prints.patch create mode 100644 target/linux/gemini/patches-4.19/0004-boot-sq201-from-sda1.patch create mode 100644 target/linux/gemini/patches-4.19/0005-mtd-physmap_of-Move-custom-initialization.patch create mode 100644 target/linux/gemini/patches-4.19/0006-mtd-physmap_of_gemini-Handle-pin-control.patch create mode 100644 target/linux/gemini/patches-4.19/0007-ARM-dts-Fix-up-the-D-Link-DIR-685-MTD-partition-info.patch create mode 100644 target/linux/gemini/patches-4.19/0008-ARM-dts-Enable-Gemini-flash-access.patch create mode 100644 target/linux/gemini/patches-4.19/0009-mtd-partitions-Add-RedBoot-FIS-DT-bindings.patch create mode 100644 target/linux/gemini/patches-4.19/0010-mtd-partitions-Add-second-compatible-for-redboot.patch create mode 100644 target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch create mode 100644 target/linux/gemini/patches-4.19/0012-ARM-dts-Blank-D-Link-DIR-685-console.patch create mode 100644 target/linux/gemini/patches-4.19/0013-usb-host-fotg2-add-silicon-clock-handling.patch create mode 100644 target/linux/gemini/patches-4.19/0014-usb-host-add-DT-bindings-for-faraday-fotg2.patch create mode 100644 target/linux/gemini/patches-4.19/0015-usb-host-fotg2-add-device-tree-probing.patch create mode 100644 target/linux/gemini/patches-4.19/0016-usb-host-fotg2-add-Gemini-specific-handling.patch create mode 100644 target/linux/gemini/patches-4.19/0017-usb-host-fotg2-restart-hcd-after-port-reset.patch create mode 100644 target/linux/gemini/patches-4.19/0018-ARM-dts-Add-the-FOTG210-USB-host-to-Gemini-boards.patch -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 2/4 v2] gemini: Switch to kernel v4.19
On Sat, Jan 26, 2019 at 12:29 PM Linus Walleij wrote: > On Sat, Jan 26, 2019 at 9:29 AM Petr Štetiar wrote: > > then I had to add missing generic symbol CONFIG_USB_ROLE_SWITCH[1] and > > CONFIG_DRM_PANEL_SEIKO_43WVF1G[2] in order to get past kernel config step > > while running build in verbose mode `make V=s` (you otherwise don't see the > > missing kernel config symbols I guess). > > > > 1. > > https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=cf0d9418bc54ef4200b83cf33aafc6a759eb8d18 > > 2. > > https://github.com/openwrt/openwrt/pull/1714/commits/596e83d397d97aa63a0330e0b8a71a599ac37669 > > I didn't need any of this. No I was wrong. :( I definately needed to disable CONFIG_USB_ROLE_SWITCH. But not the panel. Thanks, it is building smoothly now. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 4/4 v2] gemini: Add SL93512R Support
Hi Christian! thanks for tidying up Gemini! On Thu, Jan 24, 2019 at 4:21 PM Christian Lamparter wrote: > > + cp $(IMAGE_KERNEL) $(BIN_DIR)/zImage > > + mv $(BIN_DIR)/rd.gz $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-rd.gz > > + mv $(BIN_DIR)/hddapp.bz2 $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-hddapp.bz2 > > + mv $(BIN_DIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-zImage > > +endef > > I did rework the image creation process for the NAS4220B and sq201 > because it was very racy (and probably caused some of the build > failures in this target? [0]) and I think it should be possible to > improve the sl93512r as well. Yup I rebased my SL93512r on top of your changes, it works like a charm. > > +define Device/sl93512r > > + DEVICE_TITLE := StorLink SL93512R Reference Design > > > + IMAGES += sl93512r-image > > + IMAGE/sl93512r-image := sl93512r-images > Can you please check if something like this: > > ARTIFACTS := zImage > ARTIFACT/zImage := append-kernel > IMAGES := rd.gz hddapp.bz2 > IMAGE/rd.gz := append-rootfs | pad-to 6144k > IMAGE/hddapp.bz2 := pad-extra 6144k | append-rootfs > > Produces similar/compatible files? > (This would make the extra Build/sl93512r-images obsolete). It does, I have a new patch for this. I will not submit it again until we switch to v4.19 though, just sending the kernel patches and config-v4.19 for next iteration. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 2/4 v2] gemini: Switch to kernel v4.19
Hi Petr, thanks a lot for testing! On Sat, Jan 26, 2019 at 9:29 AM Petr Štetiar wrote: > FYI I can't merge your branch on top of current master. > > git reset --hard origin/master > HEAD is now at 0465e41 mt76: update to the latest version > > git merge --no-edit gemini-4.19/gemini-v4.19 > Auto-merging target/linux/gemini/image/Makefile > CONFLICT (content): Merge conflict in target/linux/gemini/image/Makefile > Automatic merge failed; fix conflicts and then commit the result. Ah Christian was tidying up the scripts, I rebased it. Looks much better now anyways. We won't be able to merge that until we switch to kernel v4.19 anyways. > > - Run the config through OpenWrt make kernel_oldconfig > > and inspect the result. Looks good now. > > then I had to add missing generic symbol CONFIG_USB_ROLE_SWITCH[1] and > CONFIG_DRM_PANEL_SEIKO_43WVF1G[2] in order to get past kernel config step > while running build in verbose mode `make V=s` (you otherwise don't see the > missing kernel config symbols I guess). > > 1. > https://git.openwrt.org/?p=openwrt/staging/chunkeey.git;a=commit;h=cf0d9418bc54ef4200b83cf33aafc6a759eb8d18 > 2. > https://github.com/openwrt/openwrt/pull/1714/commits/596e83d397d97aa63a0330e0b8a71a599ac37669 I didn't need any of this. That panel is definately not used on any Gemini so I think it's a pecularity of the i.MX DRM driver requireing it for some platforms (should be handled by Kconfig itself, I think upstream needs patching). I'm not good with USB, it's one of those things I need to learn better, but I didn't need that config symbol at least, make V=s looks fine for me. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 2/4 v2] gemini: Switch to kernel v4.19
On Thu, Jan 24, 2019 at 7:19 PM Stijn Tintel wrote: > On 23/01/19 19:59, Linus Walleij wrote: > > This adds a config and augments the gemini makefile to > > use kernel v4.19. > > > > These devices work so much better with v4.19 so let's > > immediately make it the default. > > NAK. All targets need to be on 4.14 until 19.01 is branched. Ah OK so I can add the patches and the config but not switch over to 4.19 in the Makefile? I can fix that. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/4 v2] gemini: Add v4.19 kernel patches
This is the remainder of kernel patches for the v4.19 kernel. A whole slew of the previous patch stack is now upstream, so this mainly contains the stuff that was added upstream between v4.19 and v5.0-rc1, and then the USB FOTG201 patches from Hans. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Resend. --- ...pinctrl-gemini-Mask-and-set-properly.patch | 36 +++ ...inctrl-gemini-Fix-up-TVC-clock-group.patch | 146 ...nctrl-gemini-Drop-noisy-debug-prints.patch | 87 .../0004-boot-sq201-from-sda1.patch | 25 +++ ...hysmap_of-Move-custom-initialization.patch | 52 + ...physmap_of_gemini-Handle-pin-control.patch | 194 ...he-D-Link-DIR-685-MTD-partition-info.patch | 71 ++ ...8-ARM-dts-Enable-Gemini-flash-access.patch | 169 ++ ...rtitions-Add-RedBoot-FIS-DT-bindings.patch | 51 + ...ns-Add-second-compatible-for-redboot.patch | 77 +++ ...11-ARM-dts-Fix-up-SQ201-flash-access.patch | 73 ++ ...ARM-dts-Blank-D-Link-DIR-685-console.patch | 30 +++ ...ost-fotg2-add-silicon-clock-handling.patch | 123 ++ ...st-add-DT-bindings-for-faraday-fotg2.patch | 69 ++ ...b-host-fotg2-add-device-tree-probing.patch | 48 ...t-fotg2-add-Gemini-specific-handling.patch | 138 ...t-fotg2-restart-hcd-after-port-reset.patch | 32 +++ ...he-FOTG210-USB-host-to-Gemini-boards.patch | 210 ++ 18 files changed, 1631 insertions(+) create mode 100644 target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch create mode 100644 target/linux/gemini/patches-4.19/0002-pinctrl-gemini-Fix-up-TVC-clock-group.patch create mode 100644 target/linux/gemini/patches-4.19/0003-pinctrl-gemini-Drop-noisy-debug-prints.patch create mode 100644 target/linux/gemini/patches-4.19/0004-boot-sq201-from-sda1.patch create mode 100644 target/linux/gemini/patches-4.19/0005-mtd-physmap_of-Move-custom-initialization.patch create mode 100644 target/linux/gemini/patches-4.19/0006-mtd-physmap_of_gemini-Handle-pin-control.patch create mode 100644 target/linux/gemini/patches-4.19/0007-ARM-dts-Fix-up-the-D-Link-DIR-685-MTD-partition-info.patch create mode 100644 target/linux/gemini/patches-4.19/0008-ARM-dts-Enable-Gemini-flash-access.patch create mode 100644 target/linux/gemini/patches-4.19/0009-mtd-partitions-Add-RedBoot-FIS-DT-bindings.patch create mode 100644 target/linux/gemini/patches-4.19/0010-mtd-partitions-Add-second-compatible-for-redboot.patch create mode 100644 target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch create mode 100644 target/linux/gemini/patches-4.19/0012-ARM-dts-Blank-D-Link-DIR-685-console.patch create mode 100644 target/linux/gemini/patches-4.19/0013-usb-host-fotg2-add-silicon-clock-handling.patch create mode 100644 target/linux/gemini/patches-4.19/0014-usb-host-add-DT-bindings-for-faraday-fotg2.patch create mode 100644 target/linux/gemini/patches-4.19/0015-usb-host-fotg2-add-device-tree-probing.patch create mode 100644 target/linux/gemini/patches-4.19/0016-usb-host-fotg2-add-Gemini-specific-handling.patch create mode 100644 target/linux/gemini/patches-4.19/0017-usb-host-fotg2-restart-hcd-after-port-reset.patch create mode 100644 target/linux/gemini/patches-4.19/0018-ARM-dts-Add-the-FOTG210-USB-host-to-Gemini-boards.patch diff --git a/target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch b/target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch new file mode 100644 index ..3cc7bad8b84c --- /dev/null +++ b/target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch @@ -0,0 +1,36 @@ +From f8ac3d3472a8dc99c8647a637611d146d88be8cb Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Tue, 9 Oct 2018 10:09:14 +0200 +Subject: [PATCH 01/18] pinctrl: gemini: Mask and set properly + +The code was written under the assumption that the +regmap_update_bits() would mask the bits in the mask and +set the bits in the value. + +It missed the points that it will not set bits in the value +unless these are also masked in the mask. Set value bits +that are not in the mask will simply be ignored. + +Fixes: 06351d133dea ("pinctrl: add a Gemini SoC pin controller") +Signed-off-by: Linus Walleij +--- + drivers/pinctrl/pinctrl-gemini.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/pinctrl/pinctrl-gemini.c b/drivers/pinctrl/pinctrl-gemini.c +index fa7d998e1d5a..1e484a36ff07 100644 +--- a/drivers/pinctrl/pinctrl-gemini.c b/drivers/pinctrl/pinctrl-gemini.c +@@ -2184,7 +2184,8 @@ static int gemini_pmx_set_mux(struct pinctrl_dev *pctldev, +func->name, grp->name); + + regmap_read(pmx->map, GLOBAL_MISC_CTRL, ); +- regmap_update_bits(pmx->map, GLOBAL_MISC_CTRL, grp->mask, ++ regmap_update_bits(pmx->map, GLOBAL_MISC_CTRL, ++
[OpenWrt-Devel] [PATCH 4/4 v2] gemini: Add SL93512R Support
This generates images for the StorLink SL93512R reference design which is supported in kernel v4.19. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Resend. --- target/linux/gemini/image/Makefile | 21 + 1 file changed, 21 insertions(+) diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index 59041a72a785..722df1c82b00 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -39,6 +39,19 @@ define Build/dns313-images if [ -d $(BIN_DIR)/.boot ] ; then rm -rf $(BIN_DIR)/.boot ; fi endef +# Create the special SL93512R image format with the squashfs +# split across two "partitions" named rd.gz and hddapp.tgz but +# essentially just being used by OpenWRT as one big squashfs +# partition +define Build/sl93512r-images + dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/rd.gz bs=6144k conv=sync + dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/hddapp.bz2 bs=6144k count=1 seek=1 + cp $(IMAGE_KERNEL) $(BIN_DIR)/zImage + mv $(BIN_DIR)/rd.gz $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-rd.gz + mv $(BIN_DIR)/hddapp.bz2 $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-hddapp.bz2 + mv $(BIN_DIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-zImage +endef + # Create the special NAS4220B image format with the squashfs # and overlay inside the "rd.gz" file. We pad it out to 6144K # which is the size of the initramfs partition. @@ -122,6 +135,14 @@ define Device/dlink-dns-313 endef TARGET_DEVICES += dlink-dns-313 +define Device/sl93512r + DEVICE_TITLE := StorLink SL93512R Reference Design + IMAGES += sl93512r-image + IMAGE/sl93512r-image := sl93512r-images + DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) +endef +TARGET_DEVICES += sl93512r + define Device/nas4220b DEVICE_TITLE := Raidsonic NAS IB-4220-B IMAGES += nas4220b-image -- 2.19.2 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/4 v2] gemini: Switch to kernel v4.19
This adds a config and augments the gemini makefile to use kernel v4.19. These devices work so much better with v4.19 so let's immediately make it the default. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Run the config through OpenWrt make kernel_oldconfig and inspect the result. Looks good now. --- target/linux/gemini/Makefile| 2 +- target/linux/gemini/config-4.19 | 494 2 files changed, 495 insertions(+), 1 deletion(-) create mode 100644 target/linux/gemini/config-4.19 diff --git a/target/linux/gemini/Makefile b/target/linux/gemini/Makefile index 3204b3f5d81e..03f0fdbb1d6c 100644 --- a/target/linux/gemini/Makefile +++ b/target/linux/gemini/Makefile @@ -13,7 +13,7 @@ FEATURES:=squashfs pci rtc usb dt gpio display CPU_TYPE:=fa526 MAINTAINER:=Roman Yeryomin -KERNEL_PATCHVER:=4.14 +KERNEL_PATCHVER:=4.19 define Target/Description Build firmware images for the StorLink/Cortina Gemini CS351x ARM FA526 CPU diff --git a/target/linux/gemini/config-4.19 b/target/linux/gemini/config-4.19 new file mode 100644 index ..2bca204a91c8 --- /dev/null +++ b/target/linux/gemini/config-4.19 @@ -0,0 +1,494 @@ +CONFIG_ALIGNMENT_TRAP=y +CONFIG_AMBA_PL08X=y +CONFIG_ARCH_CLOCKSOURCE_DATA=y +CONFIG_ARCH_GEMINI=y +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y +CONFIG_ARCH_HAS_ELF_RANDOMIZE=y +CONFIG_ARCH_HAS_FORTIFY_SOURCE=y +CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y +CONFIG_ARCH_HAS_KCOV=y +CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE=y +CONFIG_ARCH_HAS_PHYS_TO_DMA=y +CONFIG_ARCH_HAS_RESET_CONTROLLER=y +CONFIG_ARCH_HAS_SET_MEMORY=y +CONFIG_ARCH_HAS_SG_CHAIN=y +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y +CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +# CONFIG_ARCH_MOXART is not set +CONFIG_ARCH_MULTIPLATFORM=y +CONFIG_ARCH_MULTI_V4=y +# CONFIG_ARCH_MULTI_V4T is not set +CONFIG_ARCH_MULTI_V4_V5=y +# CONFIG_ARCH_MULTI_V5 is not set +CONFIG_ARCH_NR_GPIO=0 +CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y +CONFIG_ARCH_SUPPORTS_UPROBES=y +CONFIG_ARCH_USE_BUILTIN_BSWAP=y +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y +CONFIG_ARCH_WANT_GENERAL_HUGETLB=y +CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y +CONFIG_ARM=y +CONFIG_ARM_AMBA=y +CONFIG_ARM_APPENDED_DTB=y +# CONFIG_ARM_ATAG_DTB_COMPAT is not set +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_SP805_WATCHDOG is not set +CONFIG_ARM_UNWIND=y +CONFIG_ATA=y +CONFIG_ATAGS=y +CONFIG_ATA_VERBOSE_ERROR=y +CONFIG_AUTO_ZRELADDR=y +CONFIG_BINFMT_MISC=y +CONFIG_BLK_DEV_SD=y +CONFIG_BLK_MQ_PCI=y +CONFIG_BLK_SCSI_REQUEST=y +CONFIG_BOUNCE=y +# CONFIG_BPF_SYSCALL is not set +CONFIG_CLKDEV_LOOKUP=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=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_CMDLINE="console=ttyS0,19200n8" +CONFIG_CMDLINE_FROM_BOOTLOADER=y +CONFIG_COMMON_CLK=y +CONFIG_COMMON_CLK_GEMINI=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_COREDUMP=y +CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y +CONFIG_CPU_32v4=y +CONFIG_CPU_ABRT_EV4=y +# CONFIG_CPU_BPREDICT_DISABLE is not set +CONFIG_CPU_CACHE_FA=y +CONFIG_CPU_CACHE_VIVT=y +CONFIG_CPU_COPY_FA=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y +# CONFIG_CPU_DCACHE_WRITETHROUGH is not set +CONFIG_CPU_FA526=y +# CONFIG_CPU_ICACHE_DISABLE is not set +CONFIG_CPU_NO_EFFICIENT_FFS=y +CONFIG_CPU_PABRT_LEGACY=y +CONFIG_CPU_TLB_FA=y +CONFIG_CPU_USE_DOMAINS=y +CONFIG_CRASH_CORE=y +CONFIG_CRC16=y +# CONFIG_CRC32_SARWATE is not set +CONFIG_CRC32_SLICEBY8=y +CONFIG_CRC_CCITT=y +CONFIG_CRC_ITU_T=y +CONFIG_CROSS_MEMORY_ATTACH=y +CONFIG_CRYPTO_AEAD=y +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_CCM=y +CONFIG_CRYPTO_CMAC=y +CONFIG_CRYPTO_CRC32C=y +CONFIG_CRYPTO_CTR=y +CONFIG_CRYPTO_DES=y +CONFIG_CRYPTO_DRBG=y +CONFIG_CRYPTO_DRBG_HMAC=y +CONFIG_CRYPTO_DRBG_MENU=y +CONFIG_CRYPTO_ECB=y +CONFIG_CRYPTO_ECHAINIV=y +CONFIG_CRYPTO_GCM=y +CONFIG_CRYPTO_GF128MUL=y +CONFIG_CRYPTO_GHASH=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_HMAC=y +CONFIG_CRYPTO_HW=y +CONFIG_CRYPTO_JITTERENTROPY=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +CONFIG_CRYPTO_MD4=y +CONFIG_CRYPTO_MD5=y +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_NULL2=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_RNG_DEFAULT=y +CONFIG_CRYPTO_SEQIV=y +CONFIG_CRYPTO_SHA256=y +CONFIG_CRYPTO_WORKQUEUE=y +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S" +CONFIG_DEBUG_MEMORY_INIT=y +# CONFIG_DEBUG_USER is not set +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_DEFAULT_CFQ=y +# CONFIG_DEFAULT_DEADLINE is not set +CONF
[OpenWrt-Devel] [PATCH 3/4 v2] gemini: Drop switch kmod and swconfig
The DIR-685 needs this module compiled in for safety (it is facing the LAN ports) and it is now using the DSA switch architecture so swconfig is not needed. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Resend. --- target/linux/gemini/image/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index c1d7792bf8ff..59041a72a785 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -108,7 +108,6 @@ GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \ define Device/dlink-dir-685 DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \ - kmod-switch-rtl8366rb swconfig \ rt2800-pci IMAGES += dir685-image IMAGE/dir685-image := dir685-images -- 2.19.2 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 0/4 v2] Update Gemini to kernel v4.19
This updates the Gemini platform to use kernel v4.19. Since many of the in-flight patches are upstream in v4.19 we cut down a bit on the patch burden with this, and we also invented and patched some new stuff. As the Gemini platforms use DSA switches as of v4.19 we don't need the switch kmod or swconfig anymore. A new reference design named SL93512R is available so support it. If the first patch is too big, the patches are also available here: https://dflund.se/~triad/krad/gemini/openwrt/ On popular request also pushed to github: https://github.com/linusw/openwrt Branch "gemini-v4.19" Linus Walleij (4): gemini: Add v4.19 kernel patches gemini: Switch to kernel v4.19 gemini: Drop switch kmod and swconfig gemini: Add SL93512R Support target/linux/gemini/Makefile | 2 +- target/linux/gemini/config-4.19 | 494 ++ target/linux/gemini/image/Makefile| 22 +- ...pinctrl-gemini-Mask-and-set-properly.patch | 36 ++ ...inctrl-gemini-Fix-up-TVC-clock-group.patch | 146 ++ ...nctrl-gemini-Drop-noisy-debug-prints.patch | 87 +++ .../0004-boot-sq201-from-sda1.patch | 25 + ...hysmap_of-Move-custom-initialization.patch | 52 ++ ...physmap_of_gemini-Handle-pin-control.patch | 194 +++ ...he-D-Link-DIR-685-MTD-partition-info.patch | 71 +++ ...8-ARM-dts-Enable-Gemini-flash-access.patch | 169 ++ ...rtitions-Add-RedBoot-FIS-DT-bindings.patch | 51 ++ ...ns-Add-second-compatible-for-redboot.patch | 77 +++ ...11-ARM-dts-Fix-up-SQ201-flash-access.patch | 73 +++ ...ARM-dts-Blank-D-Link-DIR-685-console.patch | 30 ++ ...ost-fotg2-add-silicon-clock-handling.patch | 123 + ...st-add-DT-bindings-for-faraday-fotg2.patch | 69 +++ ...b-host-fotg2-add-device-tree-probing.patch | 48 ++ ...t-fotg2-add-Gemini-specific-handling.patch | 138 + ...t-fotg2-restart-hcd-after-port-reset.patch | 32 ++ ...he-FOTG210-USB-host-to-Gemini-boards.patch | 210 21 files changed, 2147 insertions(+), 2 deletions(-) create mode 100644 target/linux/gemini/config-4.19 create mode 100644 target/linux/gemini/patches-4.19/0001-pinctrl-gemini-Mask-and-set-properly.patch create mode 100644 target/linux/gemini/patches-4.19/0002-pinctrl-gemini-Fix-up-TVC-clock-group.patch create mode 100644 target/linux/gemini/patches-4.19/0003-pinctrl-gemini-Drop-noisy-debug-prints.patch create mode 100644 target/linux/gemini/patches-4.19/0004-boot-sq201-from-sda1.patch create mode 100644 target/linux/gemini/patches-4.19/0005-mtd-physmap_of-Move-custom-initialization.patch create mode 100644 target/linux/gemini/patches-4.19/0006-mtd-physmap_of_gemini-Handle-pin-control.patch create mode 100644 target/linux/gemini/patches-4.19/0007-ARM-dts-Fix-up-the-D-Link-DIR-685-MTD-partition-info.patch create mode 100644 target/linux/gemini/patches-4.19/0008-ARM-dts-Enable-Gemini-flash-access.patch create mode 100644 target/linux/gemini/patches-4.19/0009-mtd-partitions-Add-RedBoot-FIS-DT-bindings.patch create mode 100644 target/linux/gemini/patches-4.19/0010-mtd-partitions-Add-second-compatible-for-redboot.patch create mode 100644 target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch create mode 100644 target/linux/gemini/patches-4.19/0012-ARM-dts-Blank-D-Link-DIR-685-console.patch create mode 100644 target/linux/gemini/patches-4.19/0013-usb-host-fotg2-add-silicon-clock-handling.patch create mode 100644 target/linux/gemini/patches-4.19/0014-usb-host-add-DT-bindings-for-faraday-fotg2.patch create mode 100644 target/linux/gemini/patches-4.19/0015-usb-host-fotg2-add-device-tree-probing.patch create mode 100644 target/linux/gemini/patches-4.19/0016-usb-host-fotg2-add-Gemini-specific-handling.patch create mode 100644 target/linux/gemini/patches-4.19/0017-usb-host-fotg2-restart-hcd-after-port-reset.patch create mode 100644 target/linux/gemini/patches-4.19/0018-ARM-dts-Add-the-FOTG210-USB-host-to-Gemini-boards.patch -- 2.19.2 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 0/4] Update Gemini to kernel v4.19
On Tue, Jan 22, 2019 at 12:15 PM Petr Štetiar wrote: > Ends with following: > > make[5]: Entering directory > '/openwrt/build_dir/target-arm_fa526_musl_eabi/linux-gemini/linux-4.19.16' > Makefile:600: include/config/auto.conf: No such file or directory >YACCscripts/kconfig/zconf.tab.c >HOSTCC scripts/kconfig/conf.o >LEX scripts/kconfig/zconf.lex.c >HOSTCC scripts/kconfig/zconf.tab.o >HOSTLD scripts/kconfig/conf > scripts/kconfig/conf --syncconfig Kconfig > net/sched/Kconfig:44: warning: menuconfig statement without prompt > .config:3930:warning: symbol value 'm' invalid for NF_NAT_REDIRECT > * > * Restart config... () > So I'm guessing, that you're probably missing some kernel config symbols > (either in generic or in gemini config) when CONFIG_ALL_KMODS=y is enabled. Yeah interesting, hm there is that make target for OpenWrt that cleans up the defconfig now that I remember it, I'll try running that. Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 0/4] Update Gemini to kernel v4.19
On Mon, Jan 21, 2019 at 9:39 AM Petr Štetiar wrote: > Linus Walleij [2019-01-19 21:28:58]: > > If the first patch is too big, the patches are also available here: > > https://dflund.se/~triad/krad/gemini/openwrt/ > > is it possible to fetch it somewhere directly in Git? I would like to build > test it. Thanks. I pushed it to the branch "gemini-v4.19" (with some more patches, but shouldn't make a difference) here: https://github.com/linusw/openwrt Yours, Linus Walleij ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 4/4] gemini: Add SL93512R Support
This generates images for the StorLink SL93512R reference design which is supported in kernel v4.19. Signed-off-by: Linus Walleij --- target/linux/gemini/image/Makefile | 21 + 1 file changed, 21 insertions(+) diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index 59041a72a785..722df1c82b00 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -39,6 +39,19 @@ define Build/dns313-images if [ -d $(BIN_DIR)/.boot ] ; then rm -rf $(BIN_DIR)/.boot ; fi endef +# Create the special SL93512R image format with the squashfs +# split across two "partitions" named rd.gz and hddapp.tgz but +# essentially just being used by OpenWRT as one big squashfs +# partition +define Build/sl93512r-images + dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/rd.gz bs=6144k conv=sync + dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/hddapp.bz2 bs=6144k count=1 seek=1 + cp $(IMAGE_KERNEL) $(BIN_DIR)/zImage + mv $(BIN_DIR)/rd.gz $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-rd.gz + mv $(BIN_DIR)/hddapp.bz2 $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-hddapp.bz2 + mv $(BIN_DIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-sl93512r-zImage +endef + # Create the special NAS4220B image format with the squashfs # and overlay inside the "rd.gz" file. We pad it out to 6144K # which is the size of the initramfs partition. @@ -122,6 +135,14 @@ define Device/dlink-dns-313 endef TARGET_DEVICES += dlink-dns-313 +define Device/sl93512r + DEVICE_TITLE := StorLink SL93512R Reference Design + IMAGES += sl93512r-image + IMAGE/sl93512r-image := sl93512r-images + DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) +endef +TARGET_DEVICES += sl93512r + define Device/nas4220b DEVICE_TITLE := Raidsonic NAS IB-4220-B IMAGES += nas4220b-image -- 2.19.2 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel