Repository navigation
realtek: add Realtek PSE MCU driver - #23222
Conversation
76ffcde to
ed6f9a2
Compare
|
I would suggest you contact Bootlin engineer Köry Maincent to see if he would be interested in reviewing for you as he was responsible for the development and upstreaming of the original PoE support in 2023 and 2024. |
openwrt-ai
left a comment
There was a problem hiding this comment.
Reviewed both new commits. Inline comments cover three definite build/runtime bugs (pse->mutex in the UART probe, if (!r) in rtl_pse_port_get_pw_limit_ranges, req.payload[] reads in rtl_pse_mcu_get_ext_config), a config mismatch (the new symbols are =y while the commit message and the deferred-probe pending patch assume modules), plus framing / ranging / indentation observations.
Commit checks
f3ec28b"WIP generic: pse-pd: add pending patches for module-based PSE drivers" — body matches diff.ed6f9a2"WIP realtek: add PSE driver for Realtek PoE MCUs" — message says "enable the new symbols as modules in rtl930x/config-6.18", but the diff setsCONFIG_PSE_REALTEK{,_I2C,_UART}=y(built-in). Either flip to=mor correct the message.
Generated by Claude Code
openwrt-ai
left a comment
There was a problem hiding this comment.
Commit checks
ed6f9a25"WIP realtek: add PSE driver for Realtek PoE MCUs" — commit message says "enable the new symbols as modules in rtl930x/config-6.18", but the diff enables them built-in (CONFIG_PSE_REALTEK=y,CONFIG_PSE_REALTEK_I2C=y,CONFIG_PSE_REALTEK_UART=y). Either flip to=mor update the wording. (See inline comment on the config hunk.)
To address review feedback, force-push fixes to this branch. Don't close and open a new PR — that loses the review history and the bot starts from scratch.
Generated by Claude Code
2e4a548 to
98ee694
Compare
98ee694 to
711dd94
Compare
|
Changes compared to previous version:
(summarized by Claude) |
|
thx for the great work @jonasjelonek :-) For the hs104 Oleksij suggested to merge it as well ... I have a similar device and will give it a try soon! |
Sure, but later. This isn't mature enough and I do not have the patience going through 500 review rounds upstream possibly changing the driver architecture every 5th time. I'd rather develop that downstream until it's good enough for upstream.
great, I'd like to see this LED stuff too and am happy to implement it in this driver as well then. How about the other patch from you I included here, is that on it's way upstream already? |
Jeah the 500 review rounds I also faced:D LED piece - is that what you meant? https://lore.kernel.org/all/[email protected]/ For target/linux/generic/pending-6.18/897-net-pse-pd-fix-pairset-return-value-check.patch I don't recall from the top of my head... and the other piece defer is here |
|
The LED stuff yes, and that loading of PSE can be deferred. I needed that too to make my stuff work. The 897 patch is mine, I probably need to send that upstream. EDIT: Submitted at https://lore.kernel.org/netdev/[email protected]/T/#u |
openwrt-ai
left a comment
There was a problem hiding this comment.
Re-reviewed at 711dd949. The previous round's 22 findings are addressed (header guard, req/resp swap, indentation, undefined identifiers, =y/=m mismatch wording). Two new framework-integration issues are flagged inline: pse-pis is missing the mandatory #address-cells/#size-cells cells, and pcdev.pis_prio_max / pcdev.supp_budget_eval_strategies are unset so pi_set_prio is unreachable from ethtool.
Generated by Claude Code
711dd94 to
373a1c2
Compare
|
Changes in latest round:
(summarized by Claude) |
|
@bmork could you give this a test? Just note quite some stuff has changed since the state you did your PoC changes on top of. Most of the DTS change can be used + selecting |
Will do. There are a couple of minor issues you might want to figure out the best solution for while I'm building:
EDIT: I see that you've added |
openwrt-ai
left a comment
There was a problem hiding this comment.
Re-reviewed after the force-push — the branch was rebased and the series substantially restructured, so this is a fresh review of all 5 commits. The previous round's findings (header guard, req/resp swap, indentation, undefined identifiers, =y/=m, pis_prio_max/supp_budget_eval_strategies, missing #address-cells/#size-cells on XMG1915-10EP) are all addressed. Inline comments cover the same pse-pis cells bug reintroduced on the new XS1930-12HP DTS, a node-naming deviation from the binding, and the missing patch header on 898-....
Commit checks
49205d01d"realtek: use rtl-pse kernel driver for PoE on XMG1915-10EP" — message refers to the driver asrtl-pse, but it was renamed torealtek-pseand the diff selectskmod-pse-realtek-uart. Update the wording to match.373a1c298"realtek: add PoE support for XS1930-12HP" — body says "using the rtl-pse-i2c driver"; the module/kmod isrealtek-pse-i2c/kmod-pse-realtek-i2c(which the diff correctly selects). Stale name in the message.
Generated by Claude Code
|
Not entirely successful, I'm afraid: I believe I see the problem. Have to build to confirm. But I didn't configure any ignoring the -ENODEV. But pse->poe_supply is not NULL anymore.... And then you do Yup, confirmed. Works fine after adding |
|
ahh I see, thanks. Overlooked that, and didn't spotted because my device needs the regulator. |
|
Sorry about all the fragmented feedback. Force pushed all my modifications on top of your branch to Don't know if we can enable this for more of the rtl838x Zyxels without testing? I played it safe with only the GS1900-10HP for now. But then we have to move the poe gpio-hog into the other GS1900 dts files. And thanks a lot for doing all this! |
|
Valuable feedback anyway.
I think we can switch the devices step-by-step, testing if people have the devices and otherwise going "just change and see if someone complains". |
5146d58 to
679213f
Compare
Add a patch which modifies the Realtek PSE MCU driver backport to add a sysfs control to control detection mode per port. Some older, bad-designed devices aren't detected properly in standard mode on some switches, though vendor firmware powers them properly. Testing shows that enabling the detection of legacy PDs by allowing wider resistance, more input capacitance and using a wider detection window, solves this issue. The legacy detection can be activated by writing 1 to portN/detection_legacy in the device's sysfs, e.g. echo 1 > /sys/bus/i2c/devices/3-0020/port0/detection_legacy This patch is kept downstream for now, upstreaming will be attempted though it is likely that upstream prefers a generic pse-pd approach. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Instead of relying on the userspace implementation, make this device the first user of the new realtek-pse kernel driver (kmod-pse-realtek-mcu-uart) based on the PSE-PD framework to interface PoE functionality of that switch. Control of PoE functionality happens via ethtool / netifd now. Drop selecting realtek-poe for this device. This doesn't include any support for PoE-related LEDs. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Add support for PoE functionality using the realtek-pse-mcu driver (kmod-pse-realtek-mcu-i2c) interfacing the on-board PoE MCU and RTL8239 PSE chips. This doesn't include any support for PoE-related LEDs. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
242942a to
e9aa5be
Compare
|
For the record, the driver as-is is close to being upstreamed. |
Add a backport patch and pending patches needed by upcoming PSE drivers which are built as modules and probed after the MAC/PHY. The net effect for module-built PSE controllers: attachment to PHYs happens via the lifecycle notifier rather than via probe-time -EPROBE_DEFER coupling, so the MDIO/DSA probe no longer sees any PSE-originated -EPROBE_DEFER and the probe-retry storm is gone. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Add pending patches which add a PSE driver for the PSE setup found on most of Realtek-based switches. An MCU with a Realtek-defined firmware and protocol fronts one or more PSE chips (from Realtek or Broadcom) as a management controller. The driver provides both I2C/SMBus and UART communication, which varies among our supported switches. There is no need for complicated userspace handling anymore, the PSE setup is defined in the device tree and interfaced in userspace via ethtool, netlink and netifd support. Those patches have progressed far enough upstream, the bindings are reviewed. Thus, we can keep this intermediate version downstream to open it up earlier for usage. Only little changes are expected til the final version lands. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Add a patch which modifies the Realtek PSE MCU driver backport to add a sysfs control to control detection mode per port. Some older, bad-designed devices aren't detected properly in standard mode on some switches, though vendor firmware powers them properly. Testing shows that enabling the detection of legacy PDs by allowing wider resistance, more input capacitance and using a wider detection window, solves this issue. The legacy detection can be activated by writing 1 to portN/detection_legacy in the device's sysfs, e.g. echo 1 > /sys/bus/i2c/devices/3-0020/port0/detection_legacy This patch is kept downstream for now, upstreaming will be attempted though it is likely that upstream prefers a generic pse-pd approach. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Instead of relying on the userspace implementation, make this device the first user of the new realtek-pse kernel driver (kmod-pse-realtek-mcu-uart) based on the PSE-PD framework to interface PoE functionality of that switch. Control of PoE functionality happens via ethtool / netifd now. Drop selecting realtek-poe for this device. This doesn't include any support for PoE-related LEDs. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Add support for PoE functionality using the realtek-pse-mcu driver (kmod-pse-realtek-mcu-i2c) interfacing the on-board PoE MCU and RTL8239 PSE chips. This doesn't include any support for PoE-related LEDs. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
|
Sorry to bump this PR, but I was wondering how the pse-controller's For context, I am trying to add a fixed-regulator node on the Netgear GS110TPP that defines the external PSU's power limitation of 130W. Doing so results in the following kernel log:
The regulator tree then shows the PSE-PI regulators to be using the dummy regulator instead of "ext-psu", as I had intended/expected: Is this expected behaviour? Or should I instead be referring every Looking a bit deeper, AFAICT this driver doesn't support setting the system's power budget. So not sure if what I'm trying to achieve is possible at the moment. Then this just relies on a pre-set global power budget? A state configured by a driver operating the system before? What's preventing this from overdrawing the device's power budget (which can have physical consequences)? |
Formality Check: Suggestions AvailableWe completed the verification flow. Please review the formatting overview logs below.
|
The
Not sure, would each pse-pi then assume it has 130W as budget for itself?
It doesn't support this yet. However, I don't see a danger right now. All switches I've worked on so far had their advertised overall power somehow in the MCU configuration. The value that you can read with one of the commands there always matched the advertised PoE power budget. Nevertheless, this is still a gap that I'm aware of. I just don't know yet how to model that within the driver since I'm not that familiar with the regulator subsystem yet. Maybe have the overall regulator (supplied via Similarly, there is still a gap that a per-port cap as given by a switch vendor isn't modelled right now. For now, only the chip maximum is the limit but some vendors reduce it for several ports, for several reasons. |
If you pass that via the pse-pi node's vpwr-supply property, each individual node being enabled would request (and thus enable if needed) the power supply. No need to bind it to the parent device AFAICT. Setting vpwr-suppy to the ext-psu node gives me:
I didn't look into the pse-core details yet, so maybe that's not even in there.
For the device, you could loop over all child pse-pi nodes to collect the unique power supplies and then add up (if there's multiple) their power limits to obtain the device power limit. The question then is: what to do with that information? You could be cautious and just log a driver warning in case the device power has not been defined, or if it differs from the reported power limit. In case of no defined limits, the driver could default to the maximum power per port.
This is more something to take up with upstream, but since the pse-pi is modelled as a regulator, (some of) the regulator binding properties could apply. Thinking of |
|
Thanks for the hints. I'll have a look, maybe it was indeed the wrong way to solve this issue. Though it's IMO more intuitive to bind the supply to the PSE controller instead of the single PIs, given how most of our switches look like. Then doing some looping, adding up, etc. in the driver feels somewhat odd. EDIT: Looking at PSE-PD core it kinda makes sense though. |
|
I've sent a mail on the netdev list too, as I felt this was becoming a discussion on the driver and binding and belonged more upstream. I've only noticed your edits here now (no mail notifications for edits), so I think we are aligned? The pd692xx binding indeed models a very similar hardware structure, so that could be a good way to evolve going forward. If you don't want to update the binding right now, before being merged upstream, the driver should (in theory) always be able to deal with old "incomplete" devicetrees too. But I guess that more or less just means being able to deal with missing |
Seems like, yes.
I would like to get it right before being merged, dealing with that bad stuff later will just cause issues. |
|
@jonasjelonek FYI git bisect points to this PR as the cause of the hangs during boot on kernel 6.18 on lantiq/xway[1]. I still need to dig deeper to find the cause. Any ideas? :) |
|
@abajk I had a similar issue with an earlier version of the patches added to generic here, but only in a very specific case. Effect was that a RTNL deadlock occured, however this was fixed in the here-merged version. I had a look at your dmesg logs, it seems like the Qualcomm Atheros Ethernet driver is the one being probed right at that point where the hang occurs. Please check in this direction, maybe point an AI to your issue, the driver and the patches. |
Interestingly, this problem doesn't appear on the AVM 5490. The differences between the two platforms are the gswip DSA switch + AR8033 PHY instead of the ETOP MAC and AR8035 PHY. |
Add a backport patch and pending patches needed by upcoming PSE drivers which are built as modules and probed after the MAC/PHY. The net effect for module-built PSE controllers: attachment to PHYs happens via the lifecycle notifier rather than via probe-time -EPROBE_DEFER coupling, so the MDIO/DSA probe no longer sees any PSE-originated -EPROBE_DEFER and the probe-retry storm is gone. Link: openwrt/openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Add a backport patch and pending patches needed by upcoming PSE drivers which are built as modules and probed after the MAC/PHY. The net effect for module-built PSE controllers: attachment to PHYs happens via the lifecycle notifier rather than via probe-time -EPROBE_DEFER coupling, so the MDIO/DSA probe no longer sees any PSE-originated -EPROBE_DEFER and the probe-retry storm is gone. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Add pending patches which add a PSE driver for the PSE setup found on most of Realtek-based switches. An MCU with a Realtek-defined firmware and protocol fronts one or more PSE chips (from Realtek or Broadcom) as a management controller. The driver provides both I2C/SMBus and UART communication, which varies among our supported switches. There is no need for complicated userspace handling anymore, the PSE setup is defined in the device tree and interfaced in userspace via ethtool, netlink and netifd support. Those patches have progressed far enough upstream, the bindings are reviewed. Thus, we can keep this intermediate version downstream to open it up earlier for usage. Only little changes are expected til the final version lands. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Add a patch which modifies the Realtek PSE MCU driver backport to add a sysfs control to control detection mode per port. Some older, bad-designed devices aren't detected properly in standard mode on some switches, though vendor firmware powers them properly. Testing shows that enabling the detection of legacy PDs by allowing wider resistance, more input capacitance and using a wider detection window, solves this issue. The legacy detection can be activated by writing 1 to portN/detection_legacy in the device's sysfs, e.g. echo 1 > /sys/bus/i2c/devices/3-0020/port0/detection_legacy This patch is kept downstream for now, upstreaming will be attempted though it is likely that upstream prefers a generic pse-pd approach. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Instead of relying on the userspace implementation, make this device the first user of the new realtek-pse kernel driver (kmod-pse-realtek-mcu-uart) based on the PSE-PD framework to interface PoE functionality of that switch. Control of PoE functionality happens via ethtool / netifd now. Drop selecting realtek-poe for this device. This doesn't include any support for PoE-related LEDs. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
Add support for PoE functionality using the realtek-pse-mcu driver (kmod-pse-realtek-mcu-i2c) interfacing the on-board PoE MCU and RTL8239 PSE chips. This doesn't include any support for PoE-related LEDs. Link: openwrt#23222 Signed-off-by: Jonas Jelonek <[email protected]>
My WIP attempt for a driver that makes use of PSE-PD framework and may allow us to drop
realtek-poeandpoemgrfor Realtek switches, making PoE on those devices better available.FWIW, this works as-is on Zyxel XMG1915-10EP (PoE MCU attached via UART) and Zyxel XGS1930-28HP (PoE MCU attached via I2C). Ports can be enabled/disabled, power limit can be set, state is properly available in ethtool. Supports both Realtek dialect and Broadcom dialect.
Feedback is welcome, especially from driver architects and PSE/PoE experts