* [net-next v10 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver @ 2025-05-02 7:44 Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 1/7] dt-bindings: net: Add MTIP L2 switch description Lukasz Majewski ` (6 more replies) 0 siblings, 7 replies; 15+ messages in thread From: Lukasz Majewski @ 2025-05-02 7:44 UTC (permalink / raw) To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Lukasz Majewski This patch series adds support for More Than IP's L2 switch driver embedded in some NXP's SoCs. This one has been tested on imx287, but is also available in the vf610. In the past there has been performed some attempts to upstream this driver: 1. The 4.19-cip based one [1] 2. DSA based one for 5.12 [2] - i.e. the switch itself was treat as a DSA switch with NO tag appended. 3. The extension for FEC driver for 5.12 [3] - the trick here was to fully reuse FEC when the in-HW switching is disabled. When bridge offloading is enabled, the driver uses already configured MAC and PHY to also configure PHY. All three approaches were not accepted as eligible for upstreaming. The driver from this series has floowing features: 1. It is fully separated from fec_main - i.e. can be used interchangeable with it. To be more specific - one can build them as modules and if required switch between them when e.g. bridge offloading is required. To be more specific: - Use FEC_MAIN: When one needs support for two ETH ports with separate uDMAs used for both and bridging can be realized in SW. - Use MTIPL2SW: When it is enough to support two ports with only uDMA0 attached to switch and bridging shall be offloaded to HW. 2. This driver uses MTIP's L2 switch internal VLAN feature to provide port separation at boot time. Port separation is disabled when bridging is required. 3. Example usage: Configuration: ip link set lan0 up; sleep 1; ip link set lan1 up; sleep 1; ip link add name br0 type bridge; ip link set br0 up; sleep 1; ip link set lan0 master br0; ip link set lan1 master br0; bridge link; ip addr add 192.168.2.17/24 dev br0; ping -c 5 192.168.2.222 Removal: ip link set br0 down; ip link delete br0 type bridge; ip link set dev lan1 down ip link set dev lan0 down 4. Limitations: - Driver enables and disables switch operation with learning and ageing. - Missing is the advanced configuration (e.g. adding entries to FBD). This is on purpose, as up till now we didn't had consensus about how the driver shall be added to Linux. 5. Clang build: make LLVM_SUFFIX=-19 LLVM=1 mrproper cp ./arch/arm/configs/mxs_defconfig .config make ARCH=arm LLVM_SUFFIX=-19 LLVM=1 W=1 menuconfig make ARCH=arm LLVM_SUFFIX=-19 LLVM=1 W=1 -j8 LOADADDR=0x40008000 uImage dtbs Links: [1] - https://github.com/lmajewski/linux-imx28-l2switch/commits/master [2] - https://github.com/lmajewski/linux-imx28-l2switch/tree/imx28-v5.12-L2-upstream-RFC_v1 [3] - https://source.denx.de/linux/linux-imx28-l2switch/-/tree/imx28-v5.12-L2-upstream-switchdev-RFC_v1?ref_type=heads Lukasz Majewski (7): dt-bindings: net: Add MTIP L2 switch description ARM: dts: nxp: mxs: Adjust the imx28.dtsi L2 switch description ARM: dts: nxp: mxs: Adjust XEA board's DTS to support L2 switch net: mtip: The L2 switch driver for imx287 ARM: mxs_defconfig: Enable CONFIG_NFS_FSCACHE ARM: mxs_defconfig: Update mxs_defconfig to 6.15-rc1 ARM: mxs_defconfig: Enable CONFIG_FEC_MTIP_L2SW to support MTIP L2 switch .../bindings/net/nxp,imx28-mtip-switch.yaml | 149 ++ MAINTAINERS | 7 + arch/arm/boot/dts/nxp/mxs/imx28-xea.dts | 56 + arch/arm/boot/dts/nxp/mxs/imx28.dtsi | 9 +- arch/arm/configs/mxs_defconfig | 13 +- drivers/net/ethernet/freescale/Kconfig | 1 + drivers/net/ethernet/freescale/Makefile | 1 + drivers/net/ethernet/freescale/mtipsw/Kconfig | 13 + .../net/ethernet/freescale/mtipsw/Makefile | 4 + .../net/ethernet/freescale/mtipsw/mtipl2sw.c | 1978 +++++++++++++++++ .../net/ethernet/freescale/mtipsw/mtipl2sw.h | 771 +++++++ .../ethernet/freescale/mtipsw/mtipl2sw_br.c | 120 + .../ethernet/freescale/mtipsw/mtipl2sw_mgnt.c | 436 ++++ 13 files changed, 3547 insertions(+), 11 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml create mode 100644 drivers/net/ethernet/freescale/mtipsw/Kconfig create mode 100644 drivers/net/ethernet/freescale/mtipsw/Makefile create mode 100644 drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c create mode 100644 drivers/net/ethernet/freescale/mtipsw/mtipl2sw.h create mode 100644 drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.c create mode 100644 drivers/net/ethernet/freescale/mtipsw/mtipl2sw_mgnt.c -- 2.39.5 ^ permalink raw reply [flat|nested] 15+ messages in thread
* [net-next v10 1/7] dt-bindings: net: Add MTIP L2 switch description 2025-05-02 7:44 [net-next v10 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski @ 2025-05-02 7:44 ` Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 2/7] ARM: dts: nxp: mxs: Adjust the imx28.dtsi " Lukasz Majewski ` (5 subsequent siblings) 6 siblings, 0 replies; 15+ messages in thread From: Lukasz Majewski @ 2025-05-02 7:44 UTC (permalink / raw) To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Lukasz Majewski This patch provides description of the MTIP L2 switch available in some NXP's SOCs - e.g. imx287. Signed-off-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Stefan Wahren <wahrenst@gmx.net> --- Changes for v2: - Rename the file to match exactly the compatible (nxp,imx287-mtip-switch) Changes for v3: - Remove '-' from const:'nxp,imx287-mtip-switch' - Use '^port@[12]+$' for port patternProperties - Drop status = "okay"; - Provide proper indentation for 'example' binding (replace 8 spaces with 4 spaces) - Remove smsc,disable-energy-detect; property - Remove interrupt-parent and interrupts properties as not required - Remove #address-cells and #size-cells from required properties check - remove description from reg: - Add $ref: ethernet-switch.yaml# Changes for v4: - Use $ref: ethernet-switch.yaml#/$defs/ethernet-ports and remove already referenced properties - Rename file to nxp,imx28-mtip-switch.yaml Changes for v5: - Provide proper description for 'ethernet-port' node Changes for v6: - Proper usage of $ref: ethernet-switch.yaml#/$defs/ethernet-ports/patternProperties when specifying the 'ethernet-ports' property - Add description and check for interrupt-names property Changes for v7: - Change switch interrupt name from 'mtipl2sw' to 'enet_switch' Changes for v8: - None Changes for v9: - Add GPIO_ACTIVE_LOW to reset-gpios mdio phandle Changes for v10: - None --- .../bindings/net/nxp,imx28-mtip-switch.yaml | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml diff --git a/Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml b/Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file mode 100644 index 000000000000..35f1fe268de7 --- /dev/null +++ b/Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml @@ -0,0 +1,149 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/nxp,imx28-mtip-switch.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP SoC Ethernet Switch Controller (L2 MoreThanIP switch) + +maintainers: + - Lukasz Majewski <lukma@denx.de> + +description: + The 2-port switch ethernet subsystem provides ethernet packet (L2) + communication and can be configured as an ethernet switch. It provides the + reduced media independent interface (RMII), the management data input + output (MDIO) for physical layer device (PHY) management. + +properties: + compatible: + const: nxp,imx28-mtip-switch + + reg: + maxItems: 1 + + phy-supply: + description: + Regulator that powers Ethernet PHYs. + + clocks: + items: + - description: Register accessing clock + - description: Bus access clock + - description: Output clock for external device - e.g. PHY source clock + - description: IEEE1588 timer clock + + clock-names: + items: + - const: ipg + - const: ahb + - const: enet_out + - const: ptp + + interrupts: + items: + - description: Switch interrupt + - description: ENET0 interrupt + - description: ENET1 interrupt + + interrupt-names: + items: + - const: enet_switch + - const: enet0 + - const: enet1 + + pinctrl-names: true + + ethernet-ports: + type: object + $ref: ethernet-switch.yaml#/$defs/ethernet-ports/patternProperties + additionalProperties: true + + patternProperties: + '^ethernet-port@[12]$': + type: object + additionalProperties: true + properties: + reg: + items: + - enum: [1, 2] + description: MTIP L2 switch port number + + required: + - reg + - label + - phy-mode + - phy-handle + + mdio: + type: object + $ref: mdio.yaml# + unevaluatedProperties: false + description: + Specifies the mdio bus in the switch, used as a container for phy nodes. + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - interrupt-names + - mdio + - ethernet-ports + +unevaluatedProperties: false + +examples: + - | + #include<dt-bindings/interrupt-controller/irq.h> + #include<dt-bindings/gpio/gpio.h> + switch@800f0000 { + compatible = "nxp,imx28-mtip-switch"; + reg = <0x800f0000 0x20000>; + pinctrl-names = "default"; + pinctrl-0 = <&mac0_pins_a>, <&mac1_pins_a>; + phy-supply = <®_fec_3v3>; + interrupts = <100>, <101>, <102>; + interrupt-names = "enet_switch", "enet0", "enet1"; + clocks = <&clks 57>, <&clks 57>, <&clks 64>, <&clks 35>; + clock-names = "ipg", "ahb", "enet_out", "ptp"; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + mtip_port1: ethernet-port@1 { + reg = <1>; + label = "lan0"; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rmii"; + phy-handle = <ðphy0>; + }; + + mtip_port2: ethernet-port@2 { + reg = <2>; + label = "lan1"; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rmii"; + phy-handle = <ðphy1>; + }; + }; + + mdio_sw: mdio { + #address-cells = <1>; + #size-cells = <0>; + + reset-gpios = <&gpio2 13 GPIO_ACTIVE_LOW>; + reset-delay-us = <25000>; + reset-post-delay-us = <10000>; + + ethphy0: ethernet-phy@0 { + reg = <0>; + }; + + ethphy1: ethernet-phy@1 { + reg = <1>; + }; + }; + }; -- 2.39.5 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [net-next v10 2/7] ARM: dts: nxp: mxs: Adjust the imx28.dtsi L2 switch description 2025-05-02 7:44 [net-next v10 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 1/7] dt-bindings: net: Add MTIP L2 switch description Lukasz Majewski @ 2025-05-02 7:44 ` Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 3/7] ARM: dts: nxp: mxs: Adjust XEA board's DTS to support L2 switch Lukasz Majewski ` (4 subsequent siblings) 6 siblings, 0 replies; 15+ messages in thread From: Lukasz Majewski @ 2025-05-02 7:44 UTC (permalink / raw) To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Lukasz Majewski, Andrew Lunn The current range of 'reg' property is too small to allow full control of the L2 switch on imx287. As this IP block also uses ENET-MAC blocks for its operation, the address range for it must be included as well. Moreover, some SoC common properties (like compatible, clocks, interrupts numbers) have been moved to this node. Signed-off-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Stefan Wahren <wahrenst@gmx.net> --- Changes for v2: - adding extra properties (like compatible, clocks, interupts) Changes for v3: - None Changes for v4: - Rename imx287 with imx28 (as the former is not used in kernel anymore) Changes for v5: - None Changes for v6: - Add interrupt-names property Changes for v7: - Change switch interrupt name from 'mtipl2sw' to 'enet_switch' Changes for v8: - None Changes for v9: - None Changes for v10: - None --- arch/arm/boot/dts/nxp/mxs/imx28.dtsi | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/nxp/mxs/imx28.dtsi b/arch/arm/boot/dts/nxp/mxs/imx28.dtsi index bbea8b77386f..8aff2e87980e 100644 --- a/arch/arm/boot/dts/nxp/mxs/imx28.dtsi +++ b/arch/arm/boot/dts/nxp/mxs/imx28.dtsi @@ -1321,8 +1321,13 @@ mac1: ethernet@800f4000 { status = "disabled"; }; - eth_switch: switch@800f8000 { - reg = <0x800f8000 0x8000>; + eth_switch: switch@800f0000 { + compatible = "nxp,imx28-mtip-switch"; + reg = <0x800f0000 0x20000>; + interrupts = <100>, <101>, <102>; + interrupt-names = "enet_switch", "enet0", "enet1"; + clocks = <&clks 57>, <&clks 57>, <&clks 64>, <&clks 35>; + clock-names = "ipg", "ahb", "enet_out", "ptp"; status = "disabled"; }; }; -- 2.39.5 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [net-next v10 3/7] ARM: dts: nxp: mxs: Adjust XEA board's DTS to support L2 switch 2025-05-02 7:44 [net-next v10 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 1/7] dt-bindings: net: Add MTIP L2 switch description Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 2/7] ARM: dts: nxp: mxs: Adjust the imx28.dtsi " Lukasz Majewski @ 2025-05-02 7:44 ` Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 5/7] ARM: mxs_defconfig: Enable CONFIG_NFS_FSCACHE Lukasz Majewski ` (3 subsequent siblings) 6 siblings, 0 replies; 15+ messages in thread From: Lukasz Majewski @ 2025-05-02 7:44 UTC (permalink / raw) To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Lukasz Majewski, Andrew Lunn The description is similar to the one used with the new CPSW driver. Signed-off-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Stefan Wahren <wahrenst@gmx.net> --- Changes for v2: - Remove properties which are common for the imx28(7) SoC - Use mdio properties to perform L2 switch reset (avoid using deprecated properties) Changes for v3: - Replace IRQ_TYPE_EDGE_FALLING with IRQ_TYPE_LEVEL_LOW - Update comment regarding PHY interrupts s/AND/OR/g Changes for v4: - Use GPIO_ACTIVE_LOW instead of 0 in 'reset-gpios' - Replace port@[12] with ethernet-port@[12] Changes for v5: - Add proper multiline comment for IRQs description Changes for v6: - None Changes for v7: - None Changes for v8: - None Changes for v9: - None Changes for v10: - None --- arch/arm/boot/dts/nxp/mxs/imx28-xea.dts | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/arch/arm/boot/dts/nxp/mxs/imx28-xea.dts b/arch/arm/boot/dts/nxp/mxs/imx28-xea.dts index 6c5e6856648a..69032b29d767 100644 --- a/arch/arm/boot/dts/nxp/mxs/imx28-xea.dts +++ b/arch/arm/boot/dts/nxp/mxs/imx28-xea.dts @@ -5,6 +5,7 @@ */ /dts-v1/; +#include<dt-bindings/interrupt-controller/irq.h> #include "imx28-lwe.dtsi" / { @@ -90,6 +91,61 @@ ®_usb_5v { gpio = <&gpio0 2 0>; }; +ð_switch { + pinctrl-names = "default"; + pinctrl-0 = <&mac0_pins_a>, <&mac1_pins_a>; + phy-supply = <®_fec_3v3>; + status = "okay"; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + mtip_port1: ethernet-port@1 { + reg = <1>; + label = "lan0"; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rmii"; + phy-handle = <ðphy0>; + }; + + mtip_port2: ethernet-port@2 { + reg = <2>; + label = "lan1"; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rmii"; + phy-handle = <ðphy1>; + }; + }; + + mdio_sw: mdio { + #address-cells = <1>; + #size-cells = <0>; + + reset-gpios = <&gpio3 21 GPIO_ACTIVE_LOW>; + reset-delay-us = <25000>; + reset-post-delay-us = <10000>; + + ethphy0: ethernet-phy@0 { + reg = <0>; + smsc,disable-energy-detect; + /* + * Both PHYs (i.e. 0,1) have the same, single GPIO, + * line to handle both, their interrupts (OR'ed) + */ + interrupt-parent = <&gpio4>; + interrupts = <13 IRQ_TYPE_LEVEL_LOW>; + }; + + ethphy1: ethernet-phy@1 { + reg = <1>; + smsc,disable-energy-detect; + interrupt-parent = <&gpio4>; + interrupts = <13 IRQ_TYPE_LEVEL_LOW>; + }; + }; +}; + &spi2_pins_a { fsl,pinmux-ids = < MX28_PAD_SSP2_SCK__SSP2_SCK -- 2.39.5 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [net-next v10 5/7] ARM: mxs_defconfig: Enable CONFIG_NFS_FSCACHE 2025-05-02 7:44 [net-next v10 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski ` (2 preceding siblings ...) 2025-05-02 7:44 ` [net-next v10 3/7] ARM: dts: nxp: mxs: Adjust XEA board's DTS to support L2 switch Lukasz Majewski @ 2025-05-02 7:44 ` Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 6/7] ARM: mxs_defconfig: Update mxs_defconfig to 6.15-rc1 Lukasz Majewski ` (2 subsequent siblings) 6 siblings, 0 replies; 15+ messages in thread From: Lukasz Majewski @ 2025-05-02 7:44 UTC (permalink / raw) To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Lukasz Majewski It is not possible to enable by user the CONFIG_NETFS_SUPPORT anymore and hence it depends on CONFIG_NFS_FSCACHE being enabled. This patch fixes potential performance regression for NFS on the mxs devices. Signed-off-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Stefan Wahren <wahrenst@gmx.net> Suggested-by: Stefan Wahren <wahrenst@gmx.net> --- Changes for v6: - New patch Changes for v7: - None Changes for v8: - None Changes for v9: - None Changes for v10: - None --- arch/arm/configs/mxs_defconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/configs/mxs_defconfig b/arch/arm/configs/mxs_defconfig index c76d66135abb..22f7639f61fe 100644 --- a/arch/arm/configs/mxs_defconfig +++ b/arch/arm/configs/mxs_defconfig @@ -138,8 +138,6 @@ CONFIG_PWM_MXS=y CONFIG_NVMEM_MXS_OCOTP=y CONFIG_EXT4_FS=y # CONFIG_DNOTIFY is not set -CONFIG_NETFS_SUPPORT=m -CONFIG_FSCACHE=y CONFIG_FSCACHE_STATS=y CONFIG_CACHEFILES=m CONFIG_VFAT_FS=y @@ -155,6 +153,7 @@ CONFIG_NFS_FS=y CONFIG_NFS_V3_ACL=y CONFIG_NFS_V4=y CONFIG_ROOT_NFS=y +CONFIG_NFS_FSCACHE=y CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_CODEPAGE_850=y CONFIG_NLS_ISO8859_1=y -- 2.39.5 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [net-next v10 6/7] ARM: mxs_defconfig: Update mxs_defconfig to 6.15-rc1 2025-05-02 7:44 [net-next v10 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski ` (3 preceding siblings ...) 2025-05-02 7:44 ` [net-next v10 5/7] ARM: mxs_defconfig: Enable CONFIG_NFS_FSCACHE Lukasz Majewski @ 2025-05-02 7:44 ` Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 7/7] ARM: mxs_defconfig: Enable CONFIG_FEC_MTIP_L2SW to support MTIP L2 switch Lukasz Majewski [not found] ` <20250502074447.2153837-5-lukma@denx.de> 6 siblings, 0 replies; 15+ messages in thread From: Lukasz Majewski @ 2025-05-02 7:44 UTC (permalink / raw) To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Lukasz Majewski This file is the updated version of mxs_defconfig for the v6.15-rc1 linux-next. Detailed description of removed configuration entries: -CONFIG_MTD_M25P80=y -> it has been replaced MTD_SPI_NOR (which is enabled) -CONFIG_SMSC_PHY=y -> is enabled implicit by USB_NET_SMSC95XX -CONFIG_GPIO_SYSFS=y -> it has been deprecated by moving to EXPERT and its replacement GPIO_CDEV is enabled by default Signed-off-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Stefan Wahren <wahrenst@gmx.net> Suggested-by: Stefan Wahren <wahrenst@gmx.net> --- Changes for v5: - New patch Changes for v6: - Add detailed description on the removed configuration options after update Changes for v7: - None Changes for v8: - None Changes for v9: - None Changes for v10: - None --- arch/arm/configs/mxs_defconfig | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/arm/configs/mxs_defconfig b/arch/arm/configs/mxs_defconfig index 22f7639f61fe..b1a31cb914c8 100644 --- a/arch/arm/configs/mxs_defconfig +++ b/arch/arm/configs/mxs_defconfig @@ -32,9 +32,6 @@ CONFIG_INET=y CONFIG_IP_PNP=y CONFIG_IP_PNP_DHCP=y CONFIG_SYN_COOKIES=y -# CONFIG_INET_XFRM_MODE_TRANSPORT is not set -# CONFIG_INET_XFRM_MODE_TUNNEL is not set -# CONFIG_INET_XFRM_MODE_BEET is not set # CONFIG_INET_DIAG is not set # CONFIG_IPV6 is not set CONFIG_CAN=m @@ -45,7 +42,6 @@ CONFIG_MTD=y CONFIG_MTD_CMDLINE_PARTS=y CONFIG_MTD_BLOCK=y CONFIG_MTD_DATAFLASH=y -CONFIG_MTD_M25P80=y CONFIG_MTD_SST25L=y CONFIG_MTD_RAW_NAND=y CONFIG_MTD_NAND_GPMI_NAND=y @@ -60,7 +56,6 @@ CONFIG_ENC28J60=y CONFIG_ICPLUS_PHY=y CONFIG_MICREL_PHY=y CONFIG_REALTEK_PHY=y -CONFIG_SMSC_PHY=y CONFIG_CAN_FLEXCAN=m CONFIG_USB_USBNET=y CONFIG_USB_NET_SMSC95XX=y @@ -77,13 +72,11 @@ CONFIG_SERIAL_AMBA_PL011=y CONFIG_SERIAL_AMBA_PL011_CONSOLE=y CONFIG_SERIAL_MXS_AUART=y # CONFIG_HW_RANDOM is not set -# CONFIG_I2C_COMPAT is not set CONFIG_I2C_CHARDEV=y CONFIG_I2C_MXS=y CONFIG_SPI=y CONFIG_SPI_GPIO=m CONFIG_SPI_MXS=y -CONFIG_GPIO_SYSFS=y # CONFIG_HWMON is not set CONFIG_WATCHDOG=y CONFIG_STMP3XXX_RTC_WATCHDOG=y -- 2.39.5 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [net-next v10 7/7] ARM: mxs_defconfig: Enable CONFIG_FEC_MTIP_L2SW to support MTIP L2 switch 2025-05-02 7:44 [net-next v10 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski ` (4 preceding siblings ...) 2025-05-02 7:44 ` [net-next v10 6/7] ARM: mxs_defconfig: Update mxs_defconfig to 6.15-rc1 Lukasz Majewski @ 2025-05-02 7:44 ` Lukasz Majewski [not found] ` <20250502074447.2153837-5-lukma@denx.de> 6 siblings, 0 replies; 15+ messages in thread From: Lukasz Majewski @ 2025-05-02 7:44 UTC (permalink / raw) To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Lukasz Majewski This patch enables support for More Than IP L2 switch available on some imx28[7] devices. Moreover, it also enables CONFIG_SWITCHDEV and CONFIG_BRIDGE required by this driver for correct operation. Signed-off-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Stefan Wahren <wahrenst@gmx.net> --- Changes for v4: - New patch Changes for v5: - Apply this patch on top of patch, which updates mxs_defconfig to v6.15-rc1 - Add more verbose commit message with explanation why SWITCHDEV and BRIDGE must be enabled as well Changes for v6: - None Changes for v7: - None Changes for v8: - None Changes for v9: - None Changes for v10: - None --- arch/arm/configs/mxs_defconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/configs/mxs_defconfig b/arch/arm/configs/mxs_defconfig index b1a31cb914c8..ef4556222274 100644 --- a/arch/arm/configs/mxs_defconfig +++ b/arch/arm/configs/mxs_defconfig @@ -34,6 +34,8 @@ CONFIG_IP_PNP_DHCP=y CONFIG_SYN_COOKIES=y # CONFIG_INET_DIAG is not set # CONFIG_IPV6 is not set +CONFIG_BRIDGE=y +CONFIG_NET_SWITCHDEV=y CONFIG_CAN=m # CONFIG_WIRELESS is not set CONFIG_DEVTMPFS=y @@ -52,6 +54,7 @@ CONFIG_EEPROM_AT24=y CONFIG_SCSI=y CONFIG_BLK_DEV_SD=y CONFIG_NETDEVICES=y +CONFIG_FEC_MTIP_L2SW=y CONFIG_ENC28J60=y CONFIG_ICPLUS_PHY=y CONFIG_MICREL_PHY=y -- 2.39.5 ^ permalink raw reply related [flat|nested] 15+ messages in thread
[parent not found: <20250502074447.2153837-5-lukma@denx.de>]
* Re: [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 [not found] ` <20250502074447.2153837-5-lukma@denx.de> @ 2025-05-02 14:13 ` Jakub Kicinski 2025-05-04 6:28 ` Lukasz Majewski 2025-05-02 14:33 ` Krzysztof Kozlowski 2025-05-02 17:05 ` Simon Horman 2 siblings, 1 reply; 15+ messages in thread From: Jakub Kicinski @ 2025-05-02 14:13 UTC (permalink / raw) To: Lukasz Majewski Cc: Andrew Lunn, davem, Eric Dumazet, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Andrew Lunn On Fri, 2 May 2025 09:44:44 +0200 Lukasz Majewski wrote: > This patch series provides support for More Than IP L2 switch embedded > in the imx287 SoC. > > This is a two port switch (placed between uDMA[01] and MAC-NET[01]), > which can be used for offloading the network traffic. > > It can be used interchangeably with current FEC driver - to be more > specific: one can use either of it, depending on the requirements. > > The biggest difference is the usage of DMA - when FEC is used, separate > DMAs are available for each ENET-MAC block. > However, with switch enabled - only the DMA0 is used to send/receive data > to/form switch (and then switch sends them to respecitive ports). > > Signed-off-by: Lukasz Majewski <lukma@denx.de> > Reviewed-by: Stefan Wahren <wahrenst@gmx.net> > Reviewed-by: Andrew Lunn <andrew@lunn.ch> Now that basic build is green the series has advanced to full testing, where coccicheck says: drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1961:1-6: WARNING: invalid free of devm_ allocated data drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1237:16-19: ERROR: bus is NULL but dereferenced. -- pw-bot: cr ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 2025-05-02 14:13 ` [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 Jakub Kicinski @ 2025-05-04 6:28 ` Lukasz Majewski 2025-05-05 20:16 ` Jakub Kicinski 0 siblings, 1 reply; 15+ messages in thread From: Lukasz Majewski @ 2025-05-04 6:28 UTC (permalink / raw) To: Jakub Kicinski Cc: Andrew Lunn, davem, Eric Dumazet, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Andrew Lunn [-- Attachment #1: Type: text/plain, Size: 1623 bytes --] Hi Jakub, > On Fri, 2 May 2025 09:44:44 +0200 Lukasz Majewski wrote: > > This patch series provides support for More Than IP L2 switch > > embedded in the imx287 SoC. > > > > This is a two port switch (placed between uDMA[01] and MAC-NET[01]), > > which can be used for offloading the network traffic. > > > > It can be used interchangeably with current FEC driver - to be more > > specific: one can use either of it, depending on the requirements. > > > > The biggest difference is the usage of DMA - when FEC is used, > > separate DMAs are available for each ENET-MAC block. > > However, with switch enabled - only the DMA0 is used to > > send/receive data to/form switch (and then switch sends them to > > respecitive ports). > > > > Signed-off-by: Lukasz Majewski <lukma@denx.de> > > Reviewed-by: Stefan Wahren <wahrenst@gmx.net> > > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > > Now that basic build is green the series has advanced to full testing, > where coccicheck says: > > drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1961:1-6: WARNING: > invalid free of devm_ allocated data > drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1237:16-19: ERROR: > bus is NULL but dereferenced. I'm sorry for not checking the code with coccinelle. I do have already used sparse and checkpatch. I will fix those errors. Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 2025-05-04 6:28 ` Lukasz Majewski @ 2025-05-05 20:16 ` Jakub Kicinski 2025-05-06 11:30 ` Lukasz Majewski 0 siblings, 1 reply; 15+ messages in thread From: Jakub Kicinski @ 2025-05-05 20:16 UTC (permalink / raw) To: Lukasz Majewski Cc: Andrew Lunn, davem, Eric Dumazet, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Andrew Lunn On Sun, 4 May 2025 08:28:11 +0200 Lukasz Majewski wrote: > > Now that basic build is green the series has advanced to full testing, > > where coccicheck says: > > > > drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1961:1-6: WARNING: > > invalid free of devm_ allocated data > > drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1237:16-19: ERROR: > > bus is NULL but dereferenced. > > I'm sorry for not checking the code with coccinelle. > > I do have already used sparse and checkpatch. No worries. Not testing a build W=1 is a bit of a faux pas. But coccinelle is finicky and slow. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 2025-05-05 20:16 ` Jakub Kicinski @ 2025-05-06 11:30 ` Lukasz Majewski 0 siblings, 0 replies; 15+ messages in thread From: Lukasz Majewski @ 2025-05-06 11:30 UTC (permalink / raw) To: Jakub Kicinski Cc: Andrew Lunn, davem, Eric Dumazet, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Andrew Lunn [-- Attachment #1: Type: text/plain, Size: 1018 bytes --] Hi Jakub, > On Sun, 4 May 2025 08:28:11 +0200 Lukasz Majewski wrote: > > > Now that basic build is green the series has advanced to full > > > testing, where coccicheck says: > > > > > > drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1961:1-6: > > > WARNING: invalid free of devm_ allocated data > > > drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1237:16-19: > > > ERROR: bus is NULL but dereferenced. > > > > I'm sorry for not checking the code with coccinelle. > > > > I do have already used sparse and checkpatch. > > No worries. Not testing a build W=1 is a bit of a faux pas. Yes, I'm fully aware of them - mea culpa. (at least now by default I will have W=1 set :-) ) > But coccinelle is finicky and slow. Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 [not found] ` <20250502074447.2153837-5-lukma@denx.de> 2025-05-02 14:13 ` [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 Jakub Kicinski @ 2025-05-02 14:33 ` Krzysztof Kozlowski 2025-05-04 10:47 ` Lukasz Majewski 2025-05-02 17:05 ` Simon Horman 2 siblings, 1 reply; 15+ messages in thread From: Krzysztof Kozlowski @ 2025-05-02 14:33 UTC (permalink / raw) To: Lukasz Majewski, Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Andrew Lunn On 02/05/2025 09:44, Lukasz Majewski wrote: > + > +static int mtip_parse_of(struct switch_enet_private *fep, > + struct device_node *np) > +{ > + struct device_node *p; > + unsigned int port_num; > + int ret = 0; > + > + p = of_find_node_by_name(np, "ethernet-ports"); This should be looking for children, not any nodes. Otherwise you will take the ethernet ports from a next device as well. > + > + for_each_available_child_of_node_scoped(p, port) { > + if (of_property_read_u32(port, "reg", &port_num)) > + continue; > + > + if (port_num > SWITCH_EPORT_NUMBER) { > + dev_err(&fep->pdev->dev, > + "%s: The switch supports up to %d ports!\n", > + __func__, SWITCH_EPORT_NUMBER); > + goto of_get_err; > + } > + > + fep->n_ports = port_num; > + ret = of_get_mac_address(port, &fep->mac[port_num - 1][0]); > + if (ret) > + dev_dbg(&fep->pdev->dev, > + "of_get_mac_address(%pOF) failed (%d)!\n", > + port, ret); > + > + ret = of_property_read_string(port, "label", > + &fep->ndev_name[port_num - 1]); > + if (ret < 0) { > + dev_err(&fep->pdev->dev, > + "%s: Cannot get ethernet port name (%d)!\n", > + __func__, ret); > + goto of_get_err; > + } > + > + ret = of_get_phy_mode(port, &fep->phy_interface[port_num - 1]); > + if (ret < 0) { > + dev_err(&fep->pdev->dev, > + "%s: Cannot get PHY mode (%d)!\n", __func__, > + ret); > + goto of_get_err; > + } > + > + fep->phy_np[port_num - 1] = of_parse_phandle(port, > + "phy-handle", 0); > + } > + > + of_get_err: > + of_node_put(p); > + > + return ret; > +} > + > +static int mtip_sw_learning(void *arg) > +{ > + struct switch_enet_private *fep = arg; > + > + while (!kthread_should_stop()) { > + set_current_state(TASK_INTERRUPTIBLE); > + /* check learning record valid */ > + mtip_atable_dynamicms_learn_migration(fep, fep->curr_time, > + NULL, NULL); > + schedule_timeout(HZ / 100); > + } > + > + return 0; > +} > + > +static void mtip_mii_unregister(struct switch_enet_private *fep) > +{ > + mdiobus_unregister(fep->mii_bus); > + mdiobus_free(fep->mii_bus); > +} > + > +static const struct mtip_devinfo mtip_imx28_l2switch_info = { > + .quirks = FEC_QUIRK_BUG_CAPTURE | FEC_QUIRK_SINGLE_MDIO | > + FEC_QUIRK_SWAP_FRAME, > +}; > + > +static const struct of_device_id mtipl2_of_match[] = { > + { .compatible = "nxp,imx28-mtip-switch", > + .data = &mtip_imx28_l2switch_info}, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(of, mtipl2_of_match); > + > +static int mtip_sw_probe(struct platform_device *pdev) > +{ > + struct device_node *np = pdev->dev.of_node; > + const struct of_device_id *of_id; > + struct switch_enet_private *fep; > + struct mtip_devinfo *dev_info; > + int ret; > + > + fep = devm_kzalloc(&pdev->dev, sizeof(*fep), GFP_KERNEL); > + if (!fep) > + return -ENOMEM; > + > + of_id = of_match_node(mtipl2_of_match, pdev->dev.of_node); > + if (of_id) { > + dev_info = (struct mtip_devinfo *)of_id->data; Do not open-code of_device_get_match_data(). > + if (dev_info) > + fep->quirks = dev_info->quirks; > + } > + > + fep->pdev = pdev; > + platform_set_drvdata(pdev, fep); > + > + fep->enet_addr = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(fep->enet_addr)) > + return PTR_ERR(fep->enet_addr); > + > + fep->irq = platform_get_irq_byname(pdev, "enet_switch"); > + if (fep->irq < 0) > + return fep->irq; > + > + ret = mtip_parse_of(fep, np); > + if (ret < 0) { > + dev_err(&pdev->dev, "%s: OF parse error (%d)!\n", __func__, > + ret); Syntax is: return dev_err_probe just like you have in other places > + return ret; > + } > + > + /* Create an Ethernet device instance. > + * The switch lookup address memory starts at 0x800FC000 > + */ > + fep->hwp_enet = fep->enet_addr; > + fep->hwp = fep->enet_addr + ENET_SWI_PHYS_ADDR_OFFSET; > + fep->hwentry = (struct mtip_addr_table __iomem *) > + (fep->hwp + MCF_ESW_LOOKUP_MEM_OFFSET); > + > + ret = devm_regulator_get_enable_optional(&pdev->dev, "phy"); > + if (ret) > + return dev_err_probe(&pdev->dev, ret, > + "Unable to get and enable 'phy'\n"); > + > + fep->clk_ipg = devm_clk_get_enabled(&pdev->dev, "ipg"); > + if (IS_ERR(fep->clk_ipg)) > + return dev_err_probe(&pdev->dev, PTR_ERR(fep->clk_ipg), > + "Unable to acquire 'ipg' clock\n"); > + > + fep->clk_ahb = devm_clk_get_enabled(&pdev->dev, "ahb"); > + if (IS_ERR(fep->clk_ahb)) > + return dev_err_probe(&pdev->dev, PTR_ERR(fep->clk_ahb), > + "Unable to acquire 'ahb' clock\n"); > + > + fep->clk_enet_out = devm_clk_get_optional_enabled(&pdev->dev, > + "enet_out"); > + if (IS_ERR(fep->clk_enet_out)) > + return dev_err_probe(&pdev->dev, PTR_ERR(fep->clk_enet_out), > + "Unable to acquire 'enet_out' clock\n"); > + > + /* setup MII interface for external switch ports */ > + mtip_enet_init(fep, 1); > + mtip_enet_init(fep, 2); > + > + spin_lock_init(&fep->learn_lock); > + spin_lock_init(&fep->hw_lock); > + spin_lock_init(&fep->mii_lock); > + > + ret = devm_request_irq(&pdev->dev, fep->irq, mtip_interrupt, 0, > + dev_name(&pdev->dev), fep); > + if (ret) > + return dev_err_probe(&pdev->dev, fep->irq, > + "Could not alloc IRQ\n"); > + > + ret = mtip_register_notifiers(fep); > + if (ret) > + return ret; > + > + ret = mtip_ndev_init(fep, pdev); > + if (ret) { > + dev_err(&pdev->dev, "%s: Failed to create virtual ndev (%d)\n", > + __func__, ret); > + goto ndev_init_err; > + } > + > + ret = mtip_switch_dma_init(fep); > + if (ret) { > + dev_err(&pdev->dev, "%s: ethernet switch init fail (%d)!\n", > + __func__, ret); > + goto dma_init_err; > + } > + > + ret = mtip_mii_init(fep, pdev); > + if (ret) { > + dev_err(&pdev->dev, "%s: Cannot init phy bus (%d)!\n", __func__, > + ret); > + goto mii_init_err; > + } > + /* setup timer for learning aging function */ > + timer_setup(&fep->timer_aging, mtip_aging_timer, 0); > + mod_timer(&fep->timer_aging, > + jiffies + msecs_to_jiffies(LEARNING_AGING_INTERVAL)); > + > + fep->task = kthread_run(mtip_sw_learning, fep, "mtip_l2sw_learning"); > + if (IS_ERR(fep->task)) { > + ret = PTR_ERR(fep->task); > + dev_err(&pdev->dev, "%s: learning kthread_run error (%d)!\n", > + __func__, ret); ret = dev_err_probe > + goto task_learning_err; > + } > + > + return 0; > + > + task_learning_err: > + timer_delete_sync(&fep->timer_aging); > + mtip_mii_unregister(fep); > + mii_init_err: > + dma_init_err: > + mtip_ndev_cleanup(fep); > + ndev_init_err: > + mtip_unregister_notifiers(fep); > + > + return ret; > +} > + > +static void mtip_sw_remove(struct platform_device *pdev) > +{ > + struct switch_enet_private *fep = platform_get_drvdata(pdev); > + > + mtip_unregister_notifiers(fep); > + mtip_ndev_cleanup(fep); > + > + mtip_mii_remove(fep); > + > + kthread_stop(fep->task); > + timer_delete_sync(&fep->timer_aging); > + platform_set_drvdata(pdev, NULL); > + > + kfree(fep); Jakub already pointed out that tools would find this bug but also testing. This was not ever tested. If it was, you would see nice clear double free. All last three versions had trivial issues which are pointed out by tooling, compilers, static analyzers. Before you post next version. please run standard kernel tools for static analysis, like coccinelle, smatch and sparse, and fix reported warnings. Also please check for warnings when building with W=1 with clang. Most of these commands (checks or W=1 build) can build specific targets, like some directory, to narrow the scope to only your code. The code here looks like it needs a fix. Feel free to get in touch if the warning is not clear. You do not nede the the top-level, one of the most busy maintainers to point out the issues which compilers find as well. Using reviewers instead of automated tools is the easiest way to get grumpy responses. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 2025-05-02 14:33 ` Krzysztof Kozlowski @ 2025-05-04 10:47 ` Lukasz Majewski 0 siblings, 0 replies; 15+ messages in thread From: Lukasz Majewski @ 2025-05-04 10:47 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Andrew Lunn [-- Attachment #1: Type: text/plain, Size: 9490 bytes --] Hi Krzysztof, > On 02/05/2025 09:44, Lukasz Majewski wrote: > > + > > +static int mtip_parse_of(struct switch_enet_private *fep, > > + struct device_node *np) > > +{ > > + struct device_node *p; > > + unsigned int port_num; > > + int ret = 0; > > + > > + p = of_find_node_by_name(np, "ethernet-ports"); > > This should be looking for children, not any nodes. Otherwise you will > take the ethernet ports from a next device as well. Yes, you are right - I will replace of_find_node_by_name() with of_get_child_by_name() > > > + > > + for_each_available_child_of_node_scoped(p, port) { > > + if (of_property_read_u32(port, "reg", &port_num)) > > + continue; > > + > > + if (port_num > SWITCH_EPORT_NUMBER) { > > + dev_err(&fep->pdev->dev, > > + "%s: The switch supports up to %d > > ports!\n", > > + __func__, SWITCH_EPORT_NUMBER); > > + goto of_get_err; > > + } > > + > > + fep->n_ports = port_num; > > + ret = of_get_mac_address(port, &fep->mac[port_num > > - 1][0]); > > + if (ret) > > + dev_dbg(&fep->pdev->dev, > > + "of_get_mac_address(%pOF) failed > > (%d)!\n", > > + port, ret); > > + > > + ret = of_property_read_string(port, "label", > > + > > &fep->ndev_name[port_num - 1]); > > + if (ret < 0) { > > + dev_err(&fep->pdev->dev, > > + "%s: Cannot get ethernet port name > > (%d)!\n", > > + __func__, ret); > > + goto of_get_err; > > + } > > + > > + ret = of_get_phy_mode(port, > > &fep->phy_interface[port_num - 1]); > > + if (ret < 0) { > > + dev_err(&fep->pdev->dev, > > + "%s: Cannot get PHY mode (%d)!\n", > > __func__, > > + ret); > > + goto of_get_err; > > + } > > + > > + fep->phy_np[port_num - 1] = of_parse_phandle(port, > > + > > "phy-handle", 0); > > + } > > + > > + of_get_err: > > + of_node_put(p); > > + > > + return ret; > > +} > > + > > +static int mtip_sw_learning(void *arg) > > +{ > > + struct switch_enet_private *fep = arg; > > + > > + while (!kthread_should_stop()) { > > + set_current_state(TASK_INTERRUPTIBLE); > > + /* check learning record valid */ > > + mtip_atable_dynamicms_learn_migration(fep, > > fep->curr_time, > > + NULL, NULL); > > + schedule_timeout(HZ / 100); > > + } > > + > > + return 0; > > +} > > + > > +static void mtip_mii_unregister(struct switch_enet_private *fep) > > +{ > > + mdiobus_unregister(fep->mii_bus); > > + mdiobus_free(fep->mii_bus); > > +} > > + > > +static const struct mtip_devinfo mtip_imx28_l2switch_info = { > > + .quirks = FEC_QUIRK_BUG_CAPTURE | FEC_QUIRK_SINGLE_MDIO | > > + FEC_QUIRK_SWAP_FRAME, > > +}; > > + > > +static const struct of_device_id mtipl2_of_match[] = { > > + { .compatible = "nxp,imx28-mtip-switch", > > + .data = &mtip_imx28_l2switch_info}, > > + { /* sentinel */ } > > +}; > > +MODULE_DEVICE_TABLE(of, mtipl2_of_match); > > + > > +static int mtip_sw_probe(struct platform_device *pdev) > > +{ > > + struct device_node *np = pdev->dev.of_node; > > + const struct of_device_id *of_id; > > + struct switch_enet_private *fep; > > + struct mtip_devinfo *dev_info; > > + int ret; > > + > > + fep = devm_kzalloc(&pdev->dev, sizeof(*fep), GFP_KERNEL); > > + if (!fep) > > + return -ENOMEM; > > + > > + of_id = of_match_node(mtipl2_of_match, pdev->dev.of_node); > > + if (of_id) { > > + dev_info = (struct mtip_devinfo *)of_id->data; > > Do not open-code of_device_get_match_data(). +1 > > > + if (dev_info) > > + fep->quirks = dev_info->quirks; > > + } > > + > > + fep->pdev = pdev; > > + platform_set_drvdata(pdev, fep); > > + > > + fep->enet_addr = devm_platform_ioremap_resource(pdev, 0); > > + if (IS_ERR(fep->enet_addr)) > > + return PTR_ERR(fep->enet_addr); > > + > > + fep->irq = platform_get_irq_byname(pdev, "enet_switch"); > > + if (fep->irq < 0) > > + return fep->irq; > > + > > + ret = mtip_parse_of(fep, np); > > + if (ret < 0) { > > + dev_err(&pdev->dev, "%s: OF parse error (%d)!\n", > > __func__, > > + ret); > > Syntax is: > return dev_err_probe > just like you have in other places Ok. > > > + return ret; > > + } > > + > > + /* Create an Ethernet device instance. > > + * The switch lookup address memory starts at 0x800FC000 > > + */ > > + fep->hwp_enet = fep->enet_addr; > > + fep->hwp = fep->enet_addr + ENET_SWI_PHYS_ADDR_OFFSET; > > + fep->hwentry = (struct mtip_addr_table __iomem *) > > + (fep->hwp + MCF_ESW_LOOKUP_MEM_OFFSET); > > + > > + ret = devm_regulator_get_enable_optional(&pdev->dev, > > "phy"); > > + if (ret) > > + return dev_err_probe(&pdev->dev, ret, > > + "Unable to get and enable > > 'phy'\n"); + > > + fep->clk_ipg = devm_clk_get_enabled(&pdev->dev, "ipg"); > > + if (IS_ERR(fep->clk_ipg)) > > + return dev_err_probe(&pdev->dev, > > PTR_ERR(fep->clk_ipg), > > + "Unable to acquire 'ipg' > > clock\n"); + > > + fep->clk_ahb = devm_clk_get_enabled(&pdev->dev, "ahb"); > > + if (IS_ERR(fep->clk_ahb)) > > + return dev_err_probe(&pdev->dev, > > PTR_ERR(fep->clk_ahb), > > + "Unable to acquire 'ahb' > > clock\n"); + > > + fep->clk_enet_out = > > devm_clk_get_optional_enabled(&pdev->dev, > > + > > "enet_out"); > > + if (IS_ERR(fep->clk_enet_out)) > > + return dev_err_probe(&pdev->dev, > > PTR_ERR(fep->clk_enet_out), > > + "Unable to acquire 'enet_out' > > clock\n"); + > > + /* setup MII interface for external switch ports */ > > + mtip_enet_init(fep, 1); > > + mtip_enet_init(fep, 2); > > + > > + spin_lock_init(&fep->learn_lock); > > + spin_lock_init(&fep->hw_lock); > > + spin_lock_init(&fep->mii_lock); > > + > > + ret = devm_request_irq(&pdev->dev, fep->irq, > > mtip_interrupt, 0, > > + dev_name(&pdev->dev), fep); > > + if (ret) > > + return dev_err_probe(&pdev->dev, fep->irq, > > + "Could not alloc IRQ\n"); > > + > > + ret = mtip_register_notifiers(fep); > > + if (ret) > > + return ret; > > + > > + ret = mtip_ndev_init(fep, pdev); > > + if (ret) { > > + dev_err(&pdev->dev, "%s: Failed to create virtual > > ndev (%d)\n", > > + __func__, ret); > > + goto ndev_init_err; > > + } > > + > > + ret = mtip_switch_dma_init(fep); > > + if (ret) { > > + dev_err(&pdev->dev, "%s: ethernet switch init fail > > (%d)!\n", > > + __func__, ret); > > + goto dma_init_err; > > + } > > + > > + ret = mtip_mii_init(fep, pdev); > > + if (ret) { > > + dev_err(&pdev->dev, "%s: Cannot init phy bus > > (%d)!\n", __func__, > > + ret); > > + goto mii_init_err; > > + } > > + /* setup timer for learning aging function */ > > + timer_setup(&fep->timer_aging, mtip_aging_timer, 0); > > + mod_timer(&fep->timer_aging, > > + jiffies + > > msecs_to_jiffies(LEARNING_AGING_INTERVAL)); + > > + fep->task = kthread_run(mtip_sw_learning, fep, > > "mtip_l2sw_learning"); > > + if (IS_ERR(fep->task)) { > > + ret = PTR_ERR(fep->task); > > + dev_err(&pdev->dev, "%s: learning kthread_run > > error (%d)!\n", > > + __func__, ret); > > ret = dev_err_probe I will replace two above lines with: ret = dev_err_probe(&pdev->dev, PTR_ERR(fep->task), "learning kthread_run error\n"); > > > + goto task_learning_err; > > + } > > + > > + return 0; > > + > > + task_learning_err: > > + timer_delete_sync(&fep->timer_aging); > > + mtip_mii_unregister(fep); > > + mii_init_err: > > + dma_init_err: > > + mtip_ndev_cleanup(fep); > > + ndev_init_err: > > + mtip_unregister_notifiers(fep); > > + > > + return ret; > > +} > > + > > +static void mtip_sw_remove(struct platform_device *pdev) > > +{ > > + struct switch_enet_private *fep = > > platform_get_drvdata(pdev); + > > + mtip_unregister_notifiers(fep); > > + mtip_ndev_cleanup(fep); > > + > > + mtip_mii_remove(fep); > > + > > + kthread_stop(fep->task); > > + timer_delete_sync(&fep->timer_aging); > > + platform_set_drvdata(pdev, NULL); > > + > > + kfree(fep); > > Jakub already pointed out that tools would find this bug but also > testing. This was not ever tested. If it was, you would see nice clear > double free. > > All last three versions had trivial issues which are pointed out by > tooling, compilers, static analyzers. Before you post next version. > please run standard kernel tools for static analysis, like coccinelle, > smatch and sparse, and fix reported warnings. Also please check for > warnings when building with W=1 with clang. Most of these commands > (checks or W=1 build) can build specific targets, like some directory, > to narrow the scope to only your code. The code here looks like it > needs a fix. Feel free to get in touch if the warning is not clear. > Ok. > You do not nede the the top-level, one of the most busy maintainers to > point out the issues which compilers find as well. Using reviewers > instead of automated tools is the easiest way to get grumpy responses. > Maybe I've striven to upstream the code too much recently as it takes already 6 years (with 3 major rewrites of the code)... Nonetheless, the code shall pass all required checks, so it is my responsibility to fix it. > > Best regards, > Krzysztof Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 [not found] ` <20250502074447.2153837-5-lukma@denx.de> 2025-05-02 14:13 ` [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 Jakub Kicinski 2025-05-02 14:33 ` Krzysztof Kozlowski @ 2025-05-02 17:05 ` Simon Horman 2025-05-04 10:48 ` Lukasz Majewski 2 siblings, 1 reply; 15+ messages in thread From: Simon Horman @ 2025-05-02 17:05 UTC (permalink / raw) To: Lukasz Majewski Cc: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Andrew Lunn On Fri, May 02, 2025 at 09:44:44AM +0200, Lukasz Majewski wrote: > +static int mtip_sw_probe(struct platform_device *pdev) ... > + ret = devm_request_irq(&pdev->dev, fep->irq, mtip_interrupt, 0, > + dev_name(&pdev->dev), fep); > + if (ret) > + return dev_err_probe(&pdev->dev, fep->irq, It looks like the 2nd argument to dev_err_probe() should be ret rather than fep->irq. Flagged by Smatch. > + "Could not alloc IRQ\n"); ... ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 2025-05-02 17:05 ` Simon Horman @ 2025-05-04 10:48 ` Lukasz Majewski 0 siblings, 0 replies; 15+ messages in thread From: Lukasz Majewski @ 2025-05-04 10:48 UTC (permalink / raw) To: Simon Horman Cc: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Andrew Lunn [-- Attachment #1: Type: text/plain, Size: 868 bytes --] On Fri, 2 May 2025 18:05:03 +0100 Simon Horman <horms@kernel.org> wrote: > On Fri, May 02, 2025 at 09:44:44AM +0200, Lukasz Majewski wrote: > > > +static int mtip_sw_probe(struct platform_device *pdev) > > ... > > > + ret = devm_request_irq(&pdev->dev, fep->irq, > > mtip_interrupt, 0, > > + dev_name(&pdev->dev), fep); > > + if (ret) > > + return dev_err_probe(&pdev->dev, fep->irq, > > It looks like the 2nd argument to dev_err_probe() should be ret > rather than fep->irq. > +1 > Flagged by Smatch. > > > + "Could not alloc IRQ\n"); > > ... Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2025-05-06 14:01 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-05-02 7:44 [net-next v10 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 1/7] dt-bindings: net: Add MTIP L2 switch description Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 2/7] ARM: dts: nxp: mxs: Adjust the imx28.dtsi " Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 3/7] ARM: dts: nxp: mxs: Adjust XEA board's DTS to support L2 switch Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 5/7] ARM: mxs_defconfig: Enable CONFIG_NFS_FSCACHE Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 6/7] ARM: mxs_defconfig: Update mxs_defconfig to 6.15-rc1 Lukasz Majewski 2025-05-02 7:44 ` [net-next v10 7/7] ARM: mxs_defconfig: Enable CONFIG_FEC_MTIP_L2SW to support MTIP L2 switch Lukasz Majewski [not found] ` <20250502074447.2153837-5-lukma@denx.de> 2025-05-02 14:13 ` [net-next v10 4/7] net: mtip: The L2 switch driver for imx287 Jakub Kicinski 2025-05-04 6:28 ` Lukasz Majewski 2025-05-05 20:16 ` Jakub Kicinski 2025-05-06 11:30 ` Lukasz Majewski 2025-05-02 14:33 ` Krzysztof Kozlowski 2025-05-04 10:47 ` Lukasz Majewski 2025-05-02 17:05 ` Simon Horman 2025-05-04 10:48 ` Lukasz Majewski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).