]> git.ipfire.org Git - thirdparty/openwrt.git/commit
realtek: pcs: derive SerDes link count from DT at probe time 23484/head
authorJonas Jelonek <jelonek.jonas@gmail.com>
Fri, 22 May 2026 20:14:20 +0000 (20:14 +0000)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Sat, 23 May 2026 09:02:15 +0000 (11:02 +0200)
commit15593de3768242d3c459811159e1c9a7339c8ceb
tree76f4f7f70fac21525034946adebe911271782ae7
parenta7bd3b147e1b295bc87dc4f7b3f425e9461f7e5b
realtek: pcs: derive SerDes link count from DT at probe time

Previously, sds->num_of_links was incremented from rtpcs_create() as
each DSA port bound its phylink_pcs. The count therefore relied on a
temporal contract (DSA must finish enumerating before pcs_config runs)
and on rtpcs_create() being the single chokepoint for all consumers.

Replace this with a probe-time scan of pcs-handle references in the
live OF tree: for every available consumer node carrying a pcs-handle
property pointing at one of our SerDes subnodes, bump that SerDes'
num_of_links. After the scan, the count is final regardless of when
or whether DSA later calls in.

To allow of_parse_phandle_with_args() to walk the property correctly,
add #pcs-cells = <0> to every serdes@N node in the 838x/839x/930x/931x
.dtsi files. A future cell-bearing form remains possible without
touching the scan.

Over-references (DT pointing more consumers at one SerDes than the
hardware can carry) are clamped at RTPCS_MAX_LINKS_PER_SDS and warned
about, but do not fail probe — the correctly-wired ports on that
SerDes still come up, and only the surplus reference is dropped.

The bounds check and the bare ++ in rtpcs_create() become redundant
under the scan-driven count and are removed.

This decouples num_of_links from DSA call ordering and is a prereq
for migrating to fwnode_pcs providers, where rtpcs_create() goes away
as the centralised counter.

Link: https://github.com/openwrt/openwrt/pull/23484
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
target/linux/realtek/dts/rtl838x.dtsi
target/linux/realtek/dts/rtl839x.dtsi
target/linux/realtek/dts/rtl930x.dtsi
target/linux/realtek/dts/rtl931x.dtsi
target/linux/realtek/files-6.18/drivers/net/pcs/pcs-rtl-otto.c