net: dsa: yt921x: Add support for Motorcomm YT921x
Subsystems (5)
David Yang
maintainerv7 cover net: dsa: yt921x: Add support for Motorcomm YT921x
Motorcomm YT921x is a series of ethernet switches developed by Shanghai Motorcomm Electronic Technology, including:
- YT9215S / YT9215RB / YT9215SC: 5 GbE phys
- YT9213NB / YT9214NB: 2 GbE phys
- YT9218N / YT9218MB: 8 GbE phys
and up to 2 serdes interfaces.
This patch adds basic support for a working DSA switch.
v6: https://lore.kernel.org/r/[email protected]
- handle unforwarded packets in tag driver
- move register and struct definitions to header file
- rework register abstraction and implement a driver lock
- implement *_stats and use a periodic work to fetch MIB
- remove EEPROM dump
- remove sysfs attr and other debug leftovers
- remove ds->user_mii_bus assignment
- run selftests and fix any errors found
v5: https://lore.kernel.org/r/[email protected]
- use enum for reg in dt binding
- fix phylink_mac_ops in the driver
- fix coding style
v4: https://lore.kernel.org/r/[email protected]
- remove switchid from dt binding
- remove hsr from tag driver
- use ratelimited log in tag driver
v3: https://lore.kernel.org/r/[email protected]
- fix words and warnings in dt binding
- remove unnecessary dev_warn_ratelimited and u64_from_u32
- remove lag and mst
- check for mdio results and fix a unlocked write in conduit_state_change
v2: https://lore.kernel.org/r/[email protected]
- fix words in dt binding
- add support for lag and mst
v1: https://lore.kernel.org/r/[email protected]
- fix coding style
- add dt binding
- add support for fdb, vlan and bridge
David Yang (3):
dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
net: dsa: tag_yt921x: add support for Motorcomm YT921x tags
net: dsa: yt921x: Add support for Motorcomm YT921x
.../bindings/net/dsa/motorcomm,yt921x.yaml | 169 + drivers/net/dsa/Kconfig | 7 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/yt921x.c | 3004 +++++++++++++++++ drivers/net/dsa/yt921x.h | 593 ++++ include/net/dsa.h | 2 + include/uapi/linux/if_ether.h | 1 + net/dsa/Kconfig | 6 + net/dsa/Makefile | 1 + net/dsa/tag_yt921x.c | 138 + 10 files changed, 3922 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml create mode 100644 drivers/net/dsa/yt921x.c create mode 100644 drivers/net/dsa/yt921x.h create mode 100644 net/dsa/tag_yt921x.c
Signature · 1 line
2.50.1
David Yang
maintainerPATCH v7 1/3 dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
The Motorcomm YT921x series is a family of Ethernet switches with up to 8 internal GbE PHYs and up to 2 GMACs.
--- .../bindings/net/dsa/motorcomm,yt921x.yaml | 169 ++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +169 -0
@@ -0,0 +1,169 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/motorcomm,yt921x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Motorcomm YT921x Ethernet switch family + +maintainers: + - David Yang <[email protected]> + +description: | + The Motorcomm YT921x series is a family of Ethernet switches with up to 8 + internal GbE PHYs and up to 2 GMACs, including: + + - YT9215S / YT9215RB / YT9215SC: 5 GbE PHYs (Port 0-4) + 2 GMACs (Port 8-9) + - YT9213NB: 2 GbE PHYs (Port 1/3) + 1 GMAC (Port 9) + - YT9214NB: 2 GbE PHYs (Port 1/3) + 2 GMACs (Port 8-9) + - YT9218N: 8 GbE PHYs (Port 0-7) + - YT9218MB: 8 GbE PHYs (Port 0-7) + 2 GMACs (Port 8-9) + + Any port can be used as the CPU port. + +properties: + compatible: + const: motorcomm,yt9215 + + reg: + enum: [0x0, 0x1d] + + reset-gpios: + maxItems: 1 + + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: | + Internal MDIO bus for the internal GbE PHYs. PHYs 0-7 are used for Port + 0-7 respectively. + + mdio-external: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: | + External MDIO bus to access external components. External PHYs for GMACs + (Port 8-9) are expected to be connected to the external MDIO bus in + vendor's reference design, but that is not a hard limitation from the + chip. + +required: + - compatible + - reg + +allOf: + - $ref: dsa.yaml#/$defs/ethernet-ports + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + switch@1d { + compatible = "motorcomm,yt9215"; + /* default 0x1d, alternate 0x0 */ + reg = <0x1d>; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + sw_phy0: phy@0 { + reg = <0x0>; + }; + + sw_phy1: phy@1 { + reg = <0x1>; + }; + + sw_phy2: phy@2 { + reg = <0x2>; + }; + + sw_phy3: phy@3 { + reg = <0x3>; + }; + + sw_phy4: phy@4 { + reg = <0x4>; + }; + }; + + mdio-external { + #address-cells = <1>; + #size-cells = <0>; + + phy1: phy@b { + reg = <0xb>; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan1"; + phy-mode = "internal"; + phy-handle = <&sw_phy0>; + }; + + port@1 { + reg = <1>; + label = "lan2"; + phy-mode = "internal"; + phy-handle = <&sw_phy1>; + }; + + port@2 { + reg = <2>; + label = "lan3"; + phy-mode = "internal"; + phy-handle = <&sw_phy2>; + }; + + port@3 { + reg = <3>; + label = "lan4"; + phy-mode = "internal"; + phy-handle = <&sw_phy3>; + }; + + port@4 { + reg = <4>; + label = "lan5"; + phy-mode = "internal"; + phy-handle = <&sw_phy4>; + }; + + /* CPU port */ + port@8 { + reg = <8>; + phy-mode = "sgmii"; + ethernet = <ð0>; + + fixed-link { + speed = <1000>; + full-duplex; + pause; + asym-pause; + }; + }; + + /* if external phy is connected to a MAC */ + port@9 { + reg = <9>; + label = "wan"; + phy-mode = "rgmii"; + phy-handle = <&phy1>; + }; + }; + }; + };
Signature · 1 line
2.50.1
Rob Herring
maintainerRe: [PATCH net-next v7 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
Quoted 2 lines · David Yang
The Motorcomm YT921x series is a family of Ethernet switches with up to 8 internal GbE PHYs and up to 2 GMACs.
A couple of nits below if you spin another version.
Quoted 41 lines
Signed-off-by David Yang <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>--- .../bindings/net/dsa/motorcomm,yt921x.yaml | 169 ++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yamlDocumentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +27
-0@@ -0,0 +1,169 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/motorcomm,yt921x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Motorcomm YT921x Ethernet switch family + +maintainers: + - David Yang <[email protected]> + +description: | + The Motorcomm YT921x series is a family of Ethernet switches with up to 8 + internal GbE PHYs and up to 2 GMACs, including: + + - YT9215S / YT9215RB / YT9215SC: 5 GbE PHYs (Port 0-4) + 2 GMACs (Port 8-9) + - YT9213NB: 2 GbE PHYs (Port 1/3) + 1 GMAC (Port 9) + - YT9214NB: 2 GbE PHYs (Port 1/3) + 2 GMACs (Port 8-9) + - YT9218N: 8 GbE PHYs (Port 0-7) + - YT9218MB: 8 GbE PHYs (Port 0-7) + 2 GMACs (Port 8-9) + + Any port can be used as the CPU port. + +properties: + compatible: + const: motorcomm,yt9215 +
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 37
Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +10
-0+ reg: + enum: [0x0, 0x1d] + + reset-gpios: + maxItems: 1 + + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: |
Don't need '|'.
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 44
Quoted 7 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +7
-0+ Internal MDIO bus for the internal GbE PHYs. PHYs 0-7 are used for Port + 0-7 respectively. + + mdio-external: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: |
Don't need '|'.
Quoted 53 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +53
-0+ External MDIO bus to access external components. External PHYs for GMACs + (Port 8-9) are expected to be connected to the external MDIO bus in + vendor's reference design, but that is not a hard limitation from the + chip. + +required: + - compatible + - reg + +allOf: + - $ref: dsa.yaml#/$defs/ethernet-ports + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + switch@1d { + compatible = "motorcomm,yt9215"; + /* default 0x1d, alternate 0x0 */ + reg = <0x1d>; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + sw_phy0: phy@0 { + reg = <0x0>; + }; + + sw_phy1: phy@1 { + reg = <0x1>; + }; + + sw_phy2: phy@2 { + reg = <0x2>; + }; + + sw_phy3: phy@3 { + reg = <0x3>; + }; + + sw_phy4: phy@4 { + reg = <0x4>; + }; + }; +
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 107
Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +10
-0+ mdio-external { + #address-cells = <1>; + #size-cells = <0>; + + phy1: phy@b { + reg = <0xb>; + }; + }; + + ports {
ethernet-ports
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 111
Quoted 4 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +4
-0+ #address-cells = <1>; + #size-cells = <0>; + + port@0 {
ethernet-port
Quoted 61 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +58
-0+ reg = <0>; + label = "lan1"; + phy-mode = "internal"; + phy-handle = <&sw_phy0>; + }; + + port@1 { + reg = <1>; + label = "lan2"; + phy-mode = "internal"; + phy-handle = <&sw_phy1>; + }; + + port@2 { + reg = <2>; + label = "lan3"; + phy-mode = "internal"; + phy-handle = <&sw_phy2>; + }; + + port@3 { + reg = <3>; + label = "lan4"; + phy-mode = "internal"; + phy-handle = <&sw_phy3>; + }; + + port@4 { + reg = <4>; + label = "lan5"; + phy-mode = "internal"; + phy-handle = <&sw_phy4>; + }; + + /* CPU port */ + port@8 { + reg = <8>; + phy-mode = "sgmii"; + ethernet = <ð0>; + + fixed-link { + speed = <1000>; + full-duplex; + pause; + asym-pause; + }; + }; + + /* if external phy is connected to a MAC */ + port@9 { + reg = <9>; + label = "wan"; + phy-mode = "rgmii"; + phy-handle = <&phy1>; + }; + }; + }; + };Signature · 1 line
2.50.1
Andrew Lunn
maintainerRe: [PATCH net-next v7 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
In reply to David YangDocumentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 164
Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +5
-0+ /* if external phy is connected to a MAC */ + port@9 { + reg = <9>; + label = "wan"; + phy-mode = "rgmii";
"rgmii" is likely wrong. It should probably be "rgmii-id"
Otherwise, this looks good.
Andrew
David Yang
maintainerPATCH v7 2/3 net: dsa: tag_yt921x: add support for Motorcomm YT921x tags
In reply to David YangAdd support for Motorcomm YT921x tags, which includes a proper configurable ethertype field (default to 0x9988).
--- include/net/dsa.h | 2 + include/uapi/linux/if_ether.h | 1 + net/dsa/Kconfig | 6 ++ net/dsa/Makefile | 1 + net/dsa/tag_yt921x.c | 138 ++++++++++++++++++++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 net/dsa/tag_yt921x.c
include/net/dsa.h +2 -0
@@ -55,6 +55,7 @@ struct tc_action;#define DSA_TAG_PROTO_LAN937X_VALUE 27#define DSA_TAG_PROTO_VSC73XX_8021Q_VALUE 28#define DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE 29 +#define DSA_TAG_PROTO_YT921X_VALUE 30enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,
@@ -87,6 +88,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_RZN1_A5PSW =DSA_TAG_PROTO_RZN1_A5PSW_VALUE ,DSA_TAG_PROTO_LAN937X =DSA_TAG_PROTO_LAN937X_VALUE ,DSA_TAG_PROTO_VSC73XX_8021Q =DSA_TAG_PROTO_VSC73XX_8021Q_VALUE , + DSA_TAG_PROTO_YT921X = DSA_TAG_PROTO_YT921X_VALUE, };struct dsa_switch ;
include/uapi/linux/if_ether.h +1 -0
@@ -114,6 +114,7 @@#define ETH_P_QINQ1 0x9100/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */ #define ETH_P_QINQ2 0x9200/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */ #define ETH_P_QINQ3 0x9300/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_YT921X 0x9988/* Motorcomm YT921x DSA [ NOT AN OFFICIALLY REGISTERED ID ] */ #define ETH_P_EDSA 0xDADA/* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */ #define ETH_P_DSA_8021Q 0xDADB/* Fake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ] */ #define ETH_P_DSA_A5PSW 0xE001/* A5PSW Tag Value [ NOT AN OFFICIALLY REGISTERED ID ] */
net/dsa/Kconfig +6 -0
@@ -190,4 +190,10 @@ config NET_DSA_TAG_XRS700X Say Y or M if you want to enable support for tagging frames for Arrow SpeedChips XRS700x switches that use a single byte tag trailer. +config NET_DSA_TAG_YT921X + tristate "Tag driver for Motorcomm YT921x switches" + help + Say Y or M if you want to enable support for tagging frames for + Motorcomm YT921x switches. + endif
net/dsa/Makefile +1 -0
@@ -39,6 +39,7 @@ obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o obj-$(CONFIG_NET_DSA_TAG_VSC73XX_8021Q) += tag_vsc73xx_8021q.o obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o +obj-$(CONFIG_NET_DSA_TAG_YT921X) += tag_yt921x.o # for tracing framework to find trace.h CFLAGS_trace.o := -I$(src)
net/dsa/tag_yt921x.c new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
2.50.1
David Yang
maintainerPATCH v7 3/3 net: dsa: yt921x: Add support for Motorcomm YT921x
In reply to David YangMotorcomm YT921x is a series of ethernet switches developed by Shanghai Motorcomm Electronic Technology, including:
- YT9215S / YT9215RB / YT9215SC: 5 GbE PHYs
- YT9213NB / YT9214NB: 2 GbE PHYs
- YT9218N / YT9218MB: 8 GbE PHYs
and up to 2 GMACs.
Driver verified on a stock wireless router with IPQ5018 + YT9215S.
--- drivers/net/dsa/Kconfig | 7 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/yt921x.c | 3004 ++++++++++++++++++++++++++++++++++++++ drivers/net/dsa/yt921x.h | 593 ++++++++ 4 files changed, 3605 insertions(+) create mode 100644 drivers/net/dsa/yt921x.c create mode 100644 drivers/net/dsa/yt921x.h
drivers/net/dsa/Kconfig +7 -0
@@ -152,4 +152,11 @@ config NET_DSA_VITESSE_VSC73XX_PLATFORM This enables support for the Vitesse VSC7385, VSC7388, VSC7395 and VSC7398 SparX integrated ethernet switches, connected over a CPU-attached address bus and work in memory-mapped I/O mode. + +config NET_DSA_YT921X + tristate "Motorcomm YT9215 ethernet switch chip support" + select NET_DSA_TAG_YT921X + help + This enables support for the Motorcomm YT9215 ethernet switch + chip. endmenu
drivers/net/dsa/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_NET_DSA_SMSC_LAN9303_MDIO) += lan9303_mdio.o obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx-core.o obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_PLATFORM) += vitesse-vsc73xx-platform.o obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_SPI) += vitesse-vsc73xx-spi.o +obj-$(CONFIG_NET_DSA_YT921X) += yt921x.o obj-y += b53/ obj-y += hirschmann/ obj-y += microchip/
drivers/net/dsa/yt921x.c new file +3004 -0
2,982 lines not on this page · raw message
drivers/net/dsa/yt921x.h new file +593 -0
593 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.50.1
Part of the diff is not shown here. View the raw message.
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi David,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net/main]
[also build test WARNING on linus/master v6.17-rc4 next-20250905] [cannot apply to net-next/main horms-ipvs/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/David-Yang/dt-bindings-net-dsa-yt921x-Add-Motorcomm-YT921x-switch-support/20250906-021942 base: net/main patch link: https://lore.kernel.org/r/20250905181728.3169479-4-mmyangfl%40gmail.com patch subject: [PATCH net-next v7 3/3] net: dsa: yt921x: Add support for Motorcomm YT921x config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20250906/[email protected]/config) compiler: sh4-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250906/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/net/dsa/yt921x.c: In function 'yt921x_set_eee':
>> drivers/net/dsa/yt921x.c:1045:24: warning: unused variable 'dev' [-Wunused-variable]
1045 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_change_mtu':
drivers/net/dsa/yt921x.c:1110:24: warning: unused variable 'dev' [-Wunused-variable]
1110 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_mirror_add':
drivers/net/dsa/yt921x.c:1161:24: warning: unused variable 'dev' [-Wunused-variable]
1161 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_fdb_dump':
drivers/net/dsa/yt921x.c:1579:24: warning: unused variable 'dev' [-Wunused-variable]
1579 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_set_ageing_time':
drivers/net/dsa/yt921x.c:1611:24: warning: unused variable 'dev' [-Wunused-variable]
1611 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_fdb_del':
drivers/net/dsa/yt921x.c:1636:24: warning: unused variable 'dev' [-Wunused-variable]
1636 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_fdb_add':
drivers/net/dsa/yt921x.c:1651:24: warning: unused variable 'dev' [-Wunused-variable]
1651 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_mdb_del':
drivers/net/dsa/yt921x.c:1668:24: warning: unused variable 'dev' [-Wunused-variable]
1668 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_mdb_add':
drivers/net/dsa/yt921x.c:1686:24: warning: unused variable 'dev' [-Wunused-variable]
1686 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_vlan_filtering':
drivers/net/dsa/yt921x.c:1849:24: warning: unused variable 'dev' [-Wunused-variable]
1849 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_vlan_del':
drivers/net/dsa/yt921x.c:1867:24: warning: unused variable 'dev' [-Wunused-variable]
1867 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_vlan_add':
drivers/net/dsa/yt921x.c:1900:24: warning: unused variable 'dev' [-Wunused-variable]
1900 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_bridge_flags':
drivers/net/dsa/yt921x.c:2148:24: warning: unused variable 'dev' [-Wunused-variable]
2148 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_bridge_join':
drivers/net/dsa/yt921x.c:2187:24: warning: unused variable 'dev' [-Wunused-variable]
2187 | struct device *dev = to_device(priv);
| ^~~
drivers/net/dsa/yt921x.c: In function 'yt921x_dsa_port_setup':
drivers/net/dsa/yt921x.c:2557:24: warning: unused variable 'dev' [-Wunused-variable]
2557 | struct device *dev = to_device(priv);
| ^~~vim +/dev +1045 drivers/net/dsa/yt921x.c
1041
1042 static int
1043 yt921x_set_eee(struct yt921x_priv *priv, int port, struct ethtool_keee *e)
1044 {
> 1045 struct device *dev = to_device(priv);
1046 bool enable = e->eee_enabled;
1047 u16 new_mask;
1048 int res;
1049
1050 /* Enable / disable global EEE */
1051 new_mask = priv->eee_ports_mask;
1052 new_mask &= ~BIT(port);
1053 new_mask |= !enable ? 0 : BIT(port);
1054
1055 if (!!new_mask != !!priv->eee_ports_mask) {
1056 res = yt921x_reg_toggle_bits(priv, YT921X_PON_STRAP_FUNC,
1057 YT921X_PON_STRAP_EEE, !!new_mask);
1058 if (res)
1059 return res;
1060 res = yt921x_reg_toggle_bits(priv, YT921X_PON_STRAP_VAL,
1061 YT921X_PON_STRAP_EEE, !!new_mask);
1062 if (res)
1063 return res;
1064 }
1065
1066 priv->eee_ports_mask = new_mask;
1067
1068 /* Enable / disable port EEE */
1069 res = yt921x_reg_toggle_bits(priv, YT921X_EEE_CTRL,
1070 YT921X_EEE_CTRL_ENn(port), enable);
1071 if (res)
1072 return res;
1073 res = yt921x_reg_toggle_bits(priv, YT921X_EEEn_VAL(port),
1074 YT921X_EEE_VAL_DATA, enable);
1075 if (res)
1076 return res;
1077
1078 return 0;
1079 }
1080
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Andrew Lunn
maintainerQuoted 3 lines
+/* Prepare for read/write operations. Not a lock primitive despite underlying
+ * implementations may perform a lock (could be a no-op if the bus supports
+ * native atomic operations on internal ASIC registers).
It is more than atomic operations. Look at how long you hold the lock. It is not a simple read/modify/write, you hold it over multiple reads and writes. If the ASIC provided some sort of locking, it would be available for MDIO, I2C, and SPI, and probably mean additional bus transactions.
drivers/net/dsa/yt921x.c line 179
Quoted 8 lines
+ *
+ * To serialize register operations, useyt921x_lock()instead.
+ */drivers/net/dsa/yt921x.c new file +5
-0+static void yt921x_reg_acquire (struct yt921x_priv *priv) +{ +if (priv->smi_ops->acquire) + priv->smi_ops->acquire (priv->smi_ctx); +}
So, as i said in my review to previous versions, skip the if and just take the mutex. KISS. I would not even call mutex_lock(priv->lock); Don't over engineer the solution, this will probably work for I2C and SPI as well.
Quoted 4 lines
drivers/net/dsa/yt921x.c new file +4
-0+/* You should manage the bus ownership yourself and use yt921x_reg_read() +* directly, except for register polling with read_poll_timeout(); see examples +* below. +*/
drivers/net/dsa/yt921x.c line 208
Quoted 10 lines
drivers/net/dsa/yt921x.c new file +10
-0+static int yt921x_reg_read_managed (struct yt921x_priv *priv,u32 reg,u32 *valp) +{ +int res; + +yt921x_reg_acquire (priv); + res =yt921x_reg_read (priv, reg, valp); +yt921x_reg_release (priv); + +return res; +}
Sorry, i missed your reply to my comment to the previous version. You
Quoted 2 lines · said:
The driver itself does not need an explicit lock (so long as dsa framework does not call two conflicting methods on the same port),
The DSA framework makes no such guarantees. The DSA framework is also not the only entry point into the driver, phylink will directly call into the driver, and if you implement things like LEDs, they will have direct access to the driver.
So i suggest only having a high level lock, acquired on entry, released on exit, e.g. as mv88e6xxx does. KISS.
Andrew
---
pw-bot: cr
Yangfl
maintainerQuoted 51 lines · Andrew Lunn
Quoted 4 lines
+/* Prepare for read/write operations. Not a lock primitive despite underlying
+ * implementations may perform a lock (could be a no-op if the bus supports
+ * native atomic operations on internal ASIC registers).It is more than atomic operations. Look at how long you hold the lock. It is not a simple read/modify/write, you hold it over multiple reads and writes. If the ASIC provided some sort of locking, it would be available for MDIO, I2C, and SPI, and probably mean additional bus transactions.
drivers/net/dsa/yt921x.c line 179
Quoted 8 lines
+ *
+ * To serialize register operations, useyt921x_lock()instead.
+ */drivers/net/dsa/yt921x.c new file +5
-0+static void yt921x_reg_acquire (struct yt921x_priv *priv) +{ +if (priv->smi_ops->acquire) + priv->smi_ops->acquire (priv->smi_ctx); +}So, as i said in my review to previous versions, skip the if and just take the mutex. KISS. I would not even call
mutex_lock(priv->lock); Don't over engineer the solution, this will probably work for I2C and SPI as well.Quoted 4 lines
drivers/net/dsa/yt921x.c new file +4
-0+/* You should manage the bus ownership yourself and use yt921x_reg_read() +* directly, except for register polling with read_poll_timeout(); see examples +* below. +*/ drivers/net/dsa/yt921x.c line 208
Quoted 10 lines
drivers/net/dsa/yt921x.c new file +10
-0+static int yt921x_reg_read_managed (struct yt921x_priv *priv,u32 reg,u32 *valp) +{ +int res; + +yt921x_reg_acquire (priv); + res =yt921x_reg_read (priv, reg, valp); +yt921x_reg_release (priv); + +return res; +}Sorry, i missed your reply to my comment to the previous version. You
Quoted 2 lines · said:
The driver itself does not need an explicit lock (so long as dsa framework does not call two conflicting methods on the same port),
The DSA framework makes no such guarantees. The DSA framework is also not the only entry point into the driver, phylink will directly call into the driver, and if you implement things like LEDs, they will have direct access to the driver.
Quoted 7 lines
So i suggest only having a high level lock, acquired on entry, released on exit, e.g. as mv88e6xxx does. KISS.
Andrew
---
pw-bot: cr
So you mean holding bus->mdio_lock during any operations instead of implementing driver's own lock? Wouldn't other bus participants starve if I want to poll a register for like 100ms?
Andrew Lunn
maintainerQuoted 11 lines
Quoted 7 lines
The DSA framework makes no such guarantees. The DSA framework is also not the only entry point into the driver, phylink will directly call into the driver, and if you implement things like LEDs, they will have direct access to the driver.
So i suggest only having a high level lock, acquired on entry, released on exit, e.g. as mv88e6xxx does. KISS.
So you mean holding
bus->mdio_lockduring any operations instead of implementing driver's own lock? Wouldn't other bus participants starve if I want to poll a register for like 100ms?
No, leave the mdio lock alone.
The mv88e6xxx driver has a lock in the 'priv' structure:
https://elixir.bootlin.com/linux/v6.16.5/source/drivers/net/dsa/mv88e6xxx/chip.h#L354
Function which are exposed in dsa_switch_ops take the lock at the beginning, and release it at the end:
static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_mdb *mdb, struct dsa_db db)
{
struct mv88e6xxx_chip *chip = ds->priv;
int err;
mv88e6xxx_reg_lock(chip);
err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC);
if (err)
goto out;
if (!mv88e6xxx_port_db_find(chip, mdb->addr, mdb->vid))
err = -ENOSPC;out:
mv88e6xxx_reg_unlock(chip); return err; }
There are functions which wait for the device, polling:
https://elixir.bootlin.com/linux/v6.16.5/source/drivers/net/dsa/mv88e6xxx/chip.c#L87
and we do this while holding the lock. We have a timeout of 50ms, but it never takes that long, on average it is just a couple of MDIO bus transactions.
Andrew