net: stmmac: qcom-ethqos: add support for SCMI power domains
Subsystems (28)
v15 cover net: stmmac: qcom-ethqos: add support for SCMI power domains
This iteration addresses several issues raised by Sashiko. Some are not addressed as they were false positives (nothing in the PHY driver ever calls phy_runtime_get() on the parent device) or I decided they make no sense - like the suggestion to remove the power-domain-names property because there's only one power domain.
--
Add support for the firmware-managed variant of the DesignWare MAC on the sa8255p platform. This series contains new DT bindings and driver changes required to support the MAC in the STMMAC driver.
It also reorganizes the ethqos code quite a bit to make the introduction of power domains into the driver a bit easier on the eye.
The DTS changes will go in separately.
---
Changes in v15:
- Squash patches 6 and 7 to avoid a potential hang-on-resume regression
(Sashiko)
- Fix the AUTONEG_DISABLE early return path in forced mode (Sashiko)
- Fix Kconfig dependencies on generic power domains (Sashiko)
- Set the performance level back to 0 on unbind in the PHY driver
(Sashiko)
- Use devm_pm_runtime_enable() where applicable
- Link to v14: https://patch.msgid.link/[email protected]
Changes in v14:
- let genpd's own runtime suspend/resume callbacks own the perf state entirely
by calling dev_pm_genpd_set_performance_state() in set_mode()
unconditionally in the sgmii PHY driver
- drop usleep_range() from the PHY driver when setting the state as the level
setting is already synchronous
- add missing power-domains limits for ma35d1/k3-dwmac
- fix ordering of clearing the sgmii loopback
- configure the wrapper clocks synchronously in scmi setup
- Link to v13: https://patch.msgid.link/[email protected]
Changes in v13:
- Reapply OPP on speed change in the PHY driver
- Use linux/device-id/of.h instead of mod_devicetable.h
- Fix the "invalid PTP clock rate" warning on sa8255p
- Add commits necessary to allow correct link speed change with SCMI
- Link to v12: https://patch.msgid.link/[email protected]
Changes in v12:
- Drop the power-domain-names from the SGMII PHY DT bindings
- Add missing Kconfig dependency on PM for the new SGMII PHY driver
- Link to v11: https://patch.msgid.link/[email protected]
Changes in v11:
- Take a new approach: add a dedicated driver for the firmware-managed
SGMII PHY and simplify changes made to the MAC driver
- Link to v10: https://patch.msgid.link/[email protected]
Changes in v10:
- Fix unit address in DT example
- Link to v9: https://patch.msgid.link/[email protected]
Changes in v9:
- Rebase on top of current linux-next again
- Link to v8: https://patch.msgid.link/[email protected]
Changes in v8:
- Rebase on top of recent changes in linux-next which required an
extensive rework
- Drop partial R-b tags
- Link to v7: https://patch.msgid.link/[email protected]
Changes in v7:
- Restored the correct authorship after learning git uses .mailmap for
the --author switch
- Rebased on top of changes from Russell
- Fixed resource management issues in error paths
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- Fix $id value in the bindings
- Drop patch 3/8 from the series
- Update init/exit callback signatures
- Link to v5: https://lore.kernel.org/r/[email protected]
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Name the DT binding document after the new compatbile
- Add missing space
- Make the power-domains limits stricter
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Remove the phys property from the SCMI bindings
- Mark the power-domain-names property as required
- Set maxItems for power-domains to 1 for all existing bindings to
maintain the current requirements after modifying the value in the
top-level document
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Drop 'power' and 'perf' prefixes from power domain names
- Rebase on top of Russell's changes to dwmac
- Rebase on top of even more changes from Russell that are not yet
in next ([email protected])
- Link to v2: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Fix the power-domains property in DT bindings
- Rework the DT bindings example
- Drop the DTS patch, it will go upstream separately
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Bartosz Golaszewski (9):
net: phy: aquantia: fix system interface type not updated in forced mode
dt-bindings: phy: document the serdes PHY on sa8255p
phy: qcom: add the SGMII SerDes PHY driver for SCMI systems
dt-bindings: net: qcom: document the ethqos device for SCMI-based systems
net: stmmac: qcom-ethqos: set serdes mode before powerup
net: stmmac: qcom-ethqos: update phy_mode to the resolved interface in mac_finish()
net: stmmac: qcom-ethqos: reuse the address of ethqos_emac_driver_data
net: stmmac: qcom-ethqos: factor out linux-level setup into a separate function
net: stmmac: qcom-ethqos: add support for sa8255p
.../bindings/net/allwinner,sun7i-a20-gmac.yaml | 3 + .../bindings/net/altr,socfpga-stmmac.yaml | 3 + .../bindings/net/amlogic,meson-dwmac.yaml | 3 + .../devicetree/bindings/net/eswin,eic7700-eth.yaml | 3 + .../devicetree/bindings/net/intel,dwmac-plat.yaml | 3 + .../bindings/net/loongson,ls1b-gmac.yaml | 3 + .../bindings/net/loongson,ls1c-emac.yaml | 3 + .../bindings/net/nuvoton,ma35d1-dwmac.yaml | 3 + .../devicetree/bindings/net/nxp,dwmac-imx.yaml | 3 + .../devicetree/bindings/net/nxp,lpc1850-dwmac.yaml | 3 + .../devicetree/bindings/net/nxp,s32-dwmac.yaml | 3 + .../devicetree/bindings/net/qcom,ethqos.yaml | 3 + .../bindings/net/qcom,sa8255p-ethqos.yaml | 107 +++++++++ .../devicetree/bindings/net/renesas,rzn1-gmac.yaml | 3 + .../bindings/net/renesas,rzv2h-gbeth.yaml | 3 + .../devicetree/bindings/net/rockchip-dwmac.yaml | 3 + .../devicetree/bindings/net/snps,dwmac.yaml | 5 +- .../bindings/net/sophgo,cv1800b-dwmac.yaml | 3 + .../bindings/net/sophgo,sg2044-dwmac.yaml | 3 + .../devicetree/bindings/net/spacemit,k3-dwmac.yaml | 3 + .../bindings/net/starfive,jh7110-dwmac.yaml | 3 + .../devicetree/bindings/net/stm32-dwmac.yaml | 3 + .../devicetree/bindings/net/tesla,fsd-ethqos.yaml | 3 + .../devicetree/bindings/net/thead,th1520-gmac.yaml | 3 + .../bindings/net/toshiba,visconti-dwmac.yaml | 3 + .../bindings/phy/qcom,sa8255p-dwmac-sgmii-phy.yaml | 50 ++++ MAINTAINERS | 1 + .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 263 ++++++++++++++++----- drivers/net/phy/aquantia/aquantia_main.c | 5 +- drivers/phy/qualcomm/Kconfig | 10 + drivers/phy/qualcomm/Makefile | 1 + drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c | 117 +++++++++ 32 files changed, 570 insertions(+), 58 deletions(-)
---
base-commit: ab8dad6c8262729415164de729ba533466fc3649
change-id: 20250704-qcom-sa8255p-emac-8460235ac512
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
PATCH v15 1/9 net: phy: aquantia: fix system interface type not updated in forced mode
aqr_gen1_read_status() decodes the MDIO_PHYXS_VEND_IF_STATUS register to determine which SerDes interface the PHY is currently using on its system side and stores the result in phydev->interface. phylink relies on this value to configure the MAC.
The autoneg == AUTONEG_DISABLE check is not correct:MDIO_PHYXS_VEND_IF_STATUS is set by the PHY firmware based on the negotiated link speed, not based on whether autoneg was used to reach it. When the link comes up at 1G in forced mode, the register correctly reads SGMII, but the early return prevents phydev->interface from being updated. It stays at whatever value it held before (typically 2500BASE-X from the initial autoneg run), so phylink configures the MAC for the wrong interface and the link cannot come up.
Remove the autoneg guard so that the system interface type is always decoded when the link is up.
--- drivers/net/phy/aquantia/aquantia_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/phy/aquantia/aquantia_main.c +4 -1
@@ -544,7 +544,7 @@ static int aqr_gen1_read_status(struct phy_device *phydev)if (ret)return ret; -if (!phydev->link || phydev->autoneg ==AUTONEG_DISABLE ) +if (!phydev->link)return 0 ;/* The status register is not immediately correct on line side link up.
@@ -594,6 +594,9 @@ static int aqr_gen1_read_status(struct phy_device *phydev) phydev->interface =aqr_translate_interface (phydev, interface); +if (phydev->autoneg ==AUTONEG_DISABLE ) +return 0 ; +/* Read rate from vendor register */ return aqr_gen1_read_rate (phydev); }
Signature · 1 line
2.47.3
Jakub Kicinski
maintainerRe: [PATCH net-next v15 1/9] net: phy: aquantia: fix system interface type not updated in forced mode
Quoted 14 lines · On Wed, 23 Sep 2026 17:14:35 +0200 Bartosz Golaszewski wrote:
aqr_gen1_read_status()decodes theMDIO_PHYXS_VEND_IF_STATUSregister to determine which SerDes interface the PHY is currently using on its system side and stores the result inphydev->interface. phylink relies on this value to configure the MAC.The autoneg ==
AUTONEG_DISABLEcheck is not correct:MDIO_PHYXS_VEND_IF_STATUSis set by the PHY firmware based on the negotiated link speed, not based on whether autoneg was used to reach it. When the link comes up at 1G in forced mode, the register correctly reads SGMII, but the early return preventsphydev->interfacefrom being updated. It stays at whatever value it held before (typically 2500BASE-X from the initial autoneg run), so phylink configures the MAC for the wrong interface and the link cannot come up.
Quoted 6 lines
Remove the autoneg guard so that the system interface type is always decoded when the link is up.
Fixes 110a2432c520 ("net: phy: aquantia: add downshift support")Signed-off-by Bartosz Golaszewski <[email protected]>
Sounds like a real regression, is it? Should we ship it to Linus tomorrow so that it makes 7.3? stable + next does not compute for me
Re: [PATCH net-next v15 1/9] net: phy: aquantia: fix system interface type not updated in forced mode
Quoted 18 lines · Jakub Kicinski
Quoted 17 lines · On Wed, 23 Sep 2026 17:14:35 +0200 Bartosz Golaszewski wrote:
aqr_gen1_read_status()decodes theMDIO_PHYXS_VEND_IF_STATUSregister to determine which SerDes interface the PHY is currently using on its system side and stores the result inphydev->interface. phylink relies on this value to configure the MAC.The autoneg ==
AUTONEG_DISABLEcheck is not correct:MDIO_PHYXS_VEND_IF_STATUSis set by the PHY firmware based on the negotiated link speed, not based on whether autoneg was used to reach it. When the link comes up at 1G in forced mode, the register correctly reads SGMII, but the early return preventsphydev->interfacefrom being updated. It stays at whatever value it held before (typically 2500BASE-X from the initial autoneg run), so phylink configures the MAC for the wrong interface and the link cannot come up.Remove the autoneg guard so that the system interface type is always decoded when the link is up.
Quoted 7 lines
Quoted 3 lines
Fixes 110a2432c520 ("net: phy: aquantia: add downshift support")Signed-off-by Bartosz Golaszewski <[email protected]>Sounds like a real regression, is it? Should we ship it to Linus tomorrow so that it makes 7.3? stable + next does not compute for me
Yes, this is independent from the rest of the series and a small fix. It sounds good to send it upstream ASAP.
Bart
PATCH v15 2/9 dt-bindings: phy: document the serdes PHY on sa8255p
In reply to Bartosz GolaszewskiDescribe the SGMII/SerDes PHY present on the Qualcomm sa8255p platforms. This is essentially the same hardware as sa8775p rev3 but the PHY is managed by firmware over SCMI.
--- .../bindings/phy/qcom,sa8255p-dwmac-sgmii-phy.yaml | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+)
Documentation/devicetree/bindings/phy/qcom,sa8255p-dwmac-sgmii-phy.yaml new file +50 -0
@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/qcom,sa8255p-dwmac-sgmii-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm SerDes/SGMII ethernet PHY controller (firmware managed) + +maintainers: + - Bartosz Golaszewski <[email protected]> + +description: + The SerDes PHY sits between the MAC and the external PHY and provides + separate Rx Tx lines. + +properties: + compatible: + const: qcom,sa8255p-dwmac-sgmii-phy + + reg: + items: + - description: serdes + + power-domains: + maxItems: 1 + + power-domain-names: + maxItems: 1 + + "#phy-cells": + const: 0 + +required: + - compatible + - reg + - "#phy-cells" + - power-domains + - power-domain-names + +additionalProperties: false + +examples: + - | + phy@8901000 { + compatible = "qcom,sa8255p-dwmac-sgmii-phy"; + reg = <0x08901000 0xe10>; + #phy-cells = <0>; + power-domains = <&scmi7_dvfs 0>; + power-domain-names = "serdes"; + };
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH net-next v15 2/9] dt-bindings: phy: document the serdes PHY on sa8255p
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In the new binding Documentation/devicetree/bindings/phy/qcom,sa8255p-dwmac-sgmii-…
--
dt-bindings: phy: document the serdes PHY on sa8255p
This commit adds a new binding for the SGMII/SerDes PHY on Qualcomm sa8255p platforms. The hardware is the same as sa8775p rev3, but here firmware manages the PHY over SCMI.
Quoted 5 lines
Documentation/devicetree/bindings/phy/qcom,sa8255p-dwmac-sgmii-phy.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/phy/qcom,sa8255p-dwmac-sgmii-phy.yaml line 28
Quoted 5 lines
Documentation/devicetree/bindings/phy/qcom,sa8255p-dwmac-sgmii-phy.yaml new file +5
-0+ power-domains: + maxItems: 1 + + power-domain-names: + maxItems: 1
[Severity: Low]
This isn't a bug, but should power-domain-names pin its value here?
The property is listed under required, and the example uses "serdes". However, the only constraint is maxItems: 1. A node with power-domain-names = "foo" would still pass dt_binding_check, so the value of a required property is left undefined in the ABI.
The other firmware-managed sa8255p bindings fix their names with const entries. For example, qcom,sa8255p-geni-i2c.yaml has:
power-domain-names:
items:
- const: power
- const: perf
qcom,sa8255p-ethqos.yaml, added later in this series, does the same with core and mdio.
power-domains also has no description, so the binding doesn't say what the single domain represents.
Could this use items: - const: serdes for power-domain-names, and add an
items: - description: entry for power-domains? Another option is to drop power-domain-names, since there is only one entry.
The driver added later in the series (phy-qcom-sgmii-eth-scmi.c) doesn't look the domain up by name. The driver core attaches the single domain automatically, so an unexpected name causes no runtime failure. The concern is limited to the schema and the ABI definition.
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom,sa8255p-dwmac-sgmii-phy.yaml new file +10
-0+ + "#phy-cells": + const: 0 + +required: + - compatible + - reg + - "#phy-cells" + - power-domains + - power-domain-names
[ ... ]
Quoted 3 lines
Documentation/devicetree/bindings/phy/qcom,sa8255p-dwmac-sgmii-phy.yaml new file +3
-0+ power-domains = <&scmi7_dvfs 0>; + power-domain-names = "serdes"; + };
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260923-qcom-sa8255p-emac-v15-0-e82f33720737%40oss.qualcomm.com
PATCH v15 3/9 phy: qcom: add the SGMII SerDes PHY driver for SCMI systems
In reply to Bartosz GolaszewskiImplement support for the firmware-managed SGMII/SerDes PHY present on Qualcomm platforms. Do this as a separate driver from the HLOS-managed variant as they don't share almost any code.
--- drivers/phy/qualcomm/Kconfig | 10 +++ drivers/phy/qualcomm/Makefile | 1 + drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c | 117 +++++++++++++++++++++++++ 3 files changed, 128 insertions(+)
drivers/phy/qualcomm/Kconfig +10 -0
@@ -242,3 +242,13 @@ config PHY_QCOM_SGMII_ETH help Enable this to support the internal SerDes/SGMII PHY on various Qualcomm chipsets. + +config PHY_QCOM_SGMII_ETH_SCMI + tristate "Qualcomm DWMAC SGMII SerDes/PHY driver (firmware managed)" + depends on OF && (ARCH_QCOM || COMPILE_TEST) + depends on PM_GENERIC_DOMAINS + select GENERIC_PHY + help + Enable this to support the internal SerDes/SGMII PHY on Qualcomm + chipsets where the SerDes hardware (clocks and registers) is owned + by the firmware.
drivers/phy/qualcomm/Makefile +1 -0
@@ -26,3 +26,4 @@ obj-$(CONFIG_PHY_QCOM_USB_SS) += phy-qcom-usb-ss.o obj-$(CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2)+= phy-qcom-snps-femto-v2.o obj-$(CONFIG_PHY_QCOM_IPQ806X_USB) += phy-qcom-ipq806x-usb.o obj-$(CONFIG_PHY_QCOM_SGMII_ETH) += phy-qcom-sgmii-eth.o +obj-$(CONFIG_PHY_QCOM_SGMII_ETH_SCMI) += phy-qcom-sgmii-eth-scmi.o
drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c new file +117 -0
117 lines not on this page · raw message
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH net-next v15 3/9] phy: qcom: add the SGMII SerDes PHY driver for SCMI systems
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] Nothing in the new SCMI SerDes PHY driver ever tells firmware to power the SerDes down or release its rate vote.
--
phy: qcom: add the SGMII SerDes PHY driver for SCMI systems
This adds a separate PHY driver for the firmware-managed SGMII/SerDes PHY on Qualcomm sa8255p platforms. The driver never touches registers or clocks. It turns the requested interface mode into a genpd performance state (SPEED_1000 or SPEED_2500) and uses runtime PM on the provider device for power votes.
Quoted 5 lines
drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c new file +0
-0
[ ... ]
Quoted 32 lines
drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c new file +32
-0+static int qcom_dwmac_sgmii_phy_scmi_set_mode (struct phy *phy,enum phy_mode mode, +int submode) +{ +struct device *dev = phy->dev.parent; +unsigned int perf_state; +int ret; + + ret =qcom_dwmac_sgmii_phy_scmi_validate (phy, mode, submode,NULL ); +if (ret) +return ret; + + perf_state = (submode ==PHY_INTERFACE_MODE_2500BASEX ) ? +SPEED_2500 :SPEED_1000 ; + +return dev_pm_genpd_set_performance_state (dev, perf_state); +} + +static const struct phy_ops qcom_dwmac_sgmii_phy_scmi_ops = { + .set_mode = qcom_dwmac_sgmii_phy_scmi_set_mode, + .validate = qcom_dwmac_sgmii_phy_scmi_validate, + .owner =THIS_MODULE , +}; + +static void qcom_dwmac_sgmii_phy_scmi_reset_perf_state (void *data) +{ +struct device *dev = data; + +dev_pm_genpd_set_performance_state (dev,0 ); +} + +static int qcom_dwmac_sgmii_phy_scmi_probe (struct platform_device *pdev) +{
[ ... ]
drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c line 83
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c new file +8
-0+/* +* Enable runtime PM on the provider before creating the PHY so that the +* PHY core enables runtime PM on the PHY device too. The single SCMI +* power domain has already been attached to this device by the driver +* core, so runtime PM votes propagate to firmware through the genpd +* device link. No register or clock access is done here - firmware owns +* the SerDes. +*/
[Severity: Medium]
Is this comment accurate for the domain type the binding describes?
The binding allows only one power-domains entry, and its example uses <&scmi7_dvfs 0>. That is an SCMI perf domain, handled by drivers/pmdomain/arm/scmi_perf_domain.c. When there is only one domain, the driver core attaches it directly as dev->pm_domain, so no device link is created.
scmi_perf_domain_probe() registers that genpd with no power_on or power_off callbacks, and sets these flags:
scmi_pd->genpd.flags = GENPD_FLAG_ALWAYS_ON | GENPD_FLAG_OPP_TABLE_FW | GENPD_FLAG_DEV_NAME_FW;
In addition, scmi_pd_set_perf_state() returns before it reaches perf_ops->level_set() when the level is 0:
if (!state) return 0;
The MAC calls phy_power_off()/phy_exit() in qcom_ethqos_serdes_powerdown(). When this provider then runtime suspends, the path is:
genpd_runtime_suspend()
genpd_power_off() <- no-op, ALWAYS_ON
genpd_drop_performance_state()
scmi_pd_set_perf_state(genpd, 0) <- returns 0, no SCMI message
Does anything ever ask firmware to power down the SerDes or release its rate vote?
qcom_dwmac_sgmii_phy_scmi_reset_perf_state() has the same problem on unbind or probe failure. Its dev_pm_genpd_set_performance_state(dev, 0) call ends at the same early return.
Say qcom_dwmac_sgmii_phy_scmi_set_mode() has requested SPEED_1000 or SPEED_2500. Firmware then seems to keep that level through interface down, phy_power_off() and driver unbind. Meanwhile genpd records performance_state = 0. Can the kernel's view and the firmware's view get out of sync here?
Whether the SerDes stays physically powered may depend on firmware and on the MAC's own SCMI power domains. Even so, this driver never sends a power-off or release request.
The opposite problem shows up if the DT points at an SCMI power-protocol domain (scmi_pm_domain.c) instead. On/off would then work, but that genpd has no set_performance_state callback. _genpd_set_performance_state() would record the state and return 0. set_mode() would then report success for 2500BASE-X even though nothing reaches firmware.
Other sa8255p firmware-managed devices use separate domains for these two jobs. For example, qcom,sa8255p-geni-i2c.yaml has 'power' and 'perf' as <&scmi0_pd 0>, <&scmi0_dvfs 0>. Would this driver need the same power plus perf split, with the probe comment updated to match?
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c new file +3
-0+ ret =devm_pm_runtime_enable (dev); +if (ret) +return ret;
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260923-qcom-sa8255p-emac-v15-0-e82f33720737%40oss.qualcomm.com
Jakub Kicinski
maintainerRe: [PATCH net-next v15 3/9] phy: qcom: add the SGMII SerDes PHY driver for SCMI systems
In reply to Bartosz GolaszewskiQuoted 10 lines · On Wed, 23 Sep 2026 17:14:37 +0200 Bartosz Golaszewski wrote:
Implement support for the firmware-managed SGMII/SerDes PHY present on Qualcomm platforms. Do this as a separate driver from the HLOS-managed variant as they don't share almost any code.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/phy/qualcomm/Kconfig | 10 +++ drivers/phy/qualcomm/Makefile | 1 + drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c | 117 +++++++++++++++++++++++++ 3 files changed, 128 insertions(+)
Hmm, why is this here? is there a hard dependency? Otherwise it'd be better to send it separately out to Vinod, this is drivers/phy after all.
Re: [PATCH net-next v15 3/9] phy: qcom: add the SGMII SerDes PHY driver for SCMI systems
Quoted 12 lines · Jakub Kicinski
Quoted 10 lines · On Wed, 23 Sep 2026 17:14:37 +0200 Bartosz Golaszewski wrote:
Implement support for the firmware-managed SGMII/SerDes PHY present on Qualcomm platforms. Do this as a separate driver from the HLOS-managed variant as they don't share almost any code.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/phy/qualcomm/Kconfig | 10 +++ drivers/phy/qualcomm/Makefile | 1 + drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c | 117 +++++++++++++++++++++++++ 3 files changed, 128 insertions(+)
Quoted 4 lines
Hmm, why is this here? is there a hard dependency? Otherwise it'd be better to send it separately out to Vinod, this is
drivers/phyafter all.
Heh, it's always the same question of whether to split larger series into per-subsystem threads or keep them together in order to provide the full picture and let maintainers pick up subsets of patches. I've been yelled at for doing both in the past. :)
Ok, I'll split the next iteration into smaller chunks.
Bart
PATCH v15 4/9 dt-bindings: net: qcom: document the ethqos device for SCMI-based systems
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Describe the firmware-managed variant of the QCom DesignWare MAC. As the properties here differ a lot from the HLOS-managed variant, lets put it in a separate file. Since we need to update the maximum number of power domains, let's update existing bindings referencing the top-level snps,dwmac.yaml and limit their maxItems for power-domains to 1.
--- .../bindings/net/allwinner,sun7i-a20-gmac.yaml | 3 + .../bindings/net/altr,socfpga-stmmac.yaml | 3 + .../bindings/net/amlogic,meson-dwmac.yaml | 3 + .../devicetree/bindings/net/eswin,eic7700-eth.yaml | 3 + .../devicetree/bindings/net/intel,dwmac-plat.yaml | 3 + .../bindings/net/loongson,ls1b-gmac.yaml | 3 + .../bindings/net/loongson,ls1c-emac.yaml | 3 + .../bindings/net/nuvoton,ma35d1-dwmac.yaml | 3 + .../devicetree/bindings/net/nxp,dwmac-imx.yaml | 3 + .../devicetree/bindings/net/nxp,lpc1850-dwmac.yaml | 3 + .../devicetree/bindings/net/nxp,s32-dwmac.yaml | 3 + .../devicetree/bindings/net/qcom,ethqos.yaml | 3 + .../bindings/net/qcom,sa8255p-ethqos.yaml | 107 +++++++++++++++++++++ .../devicetree/bindings/net/renesas,rzn1-gmac.yaml | 3 + .../bindings/net/renesas,rzv2h-gbeth.yaml | 3 + .../devicetree/bindings/net/rockchip-dwmac.yaml | 3 + .../devicetree/bindings/net/snps,dwmac.yaml | 5 +- .../bindings/net/sophgo,cv1800b-dwmac.yaml | 3 + .../bindings/net/sophgo,sg2044-dwmac.yaml | 3 + .../devicetree/bindings/net/spacemit,k3-dwmac.yaml | 3 + .../bindings/net/starfive,jh7110-dwmac.yaml | 3 + .../devicetree/bindings/net/stm32-dwmac.yaml | 3 + .../devicetree/bindings/net/tesla,fsd-ethqos.yaml | 3 + .../devicetree/bindings/net/thead,th1520-gmac.yaml | 3 + .../bindings/net/toshiba,visconti-dwmac.yaml | 3 + MAINTAINERS | 1 + 26 files changed, 181 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/allwinner,sun7i-a20-gmac.yaml +3 -0
@@ -40,6 +40,9 @@ properties: description: PHY regulator + power-domains: + maxItems: 1 + required: - compatible - reg
Documentation/devicetree/bindings/net/altr,socfpga-stmmac.yaml +3 -0
@@ -156,6 +156,9 @@ properties: - description: offset of the control register - description: shift within the control register + power-domains: + maxItems: 1 + patternProperties: "^mdio[0-9]$": type: object
Documentation/devicetree/bindings/net/amlogic,meson-dwmac.yaml +3 -0
@@ -158,6 +158,9 @@ properties: interrupt-names: const: macirq + power-domains: + maxItems: 1 + required: - compatible - reg
Documentation/devicetree/bindings/net/eswin,eic7700-eth.yaml +3 -0
@@ -120,6 +120,9 @@ properties: - description: Optional offset of register controlling TXD delay - description: Optional offset of register controlling RXD delay + power-domains: + maxItems: 1 + required: - compatible - reg
Documentation/devicetree/bindings/net/intel,dwmac-plat.yaml +3 -0
@@ -47,6 +47,9 @@ properties: interrupt-names: const: macirq + power-domains: + maxItems: 1 + required: - compatible - clocks
Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml +3 -0
@@ -66,6 +66,9 @@ properties: - mii - rgmii-id + power-domains: + maxItems: 1 + required: - compatible - reg
Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml +3 -0
@@ -65,6 +65,9 @@ properties: - mii - rmii + power-domains: + maxItems: 1 + required: - compatible - reg
Documentation/devicetree/bindings/net/nuvoton,ma35d1-dwmac.yaml +3 -0
@@ -69,6 +69,9 @@ properties: items: - const: stmmaceth + power-domains: + maxItems: 1 + phy-mode: enum: - rmii
Documentation/devicetree/bindings/net/nxp,dwmac-imx.yaml +3 -0
@@ -83,6 +83,9 @@ properties: description: To select RMII reference clock from external. + power-domains: + maxItems: 1 + required: - compatible - clocks
Documentation/devicetree/bindings/net/nxp,lpc1850-dwmac.yaml +3 -0
@@ -51,6 +51,9 @@ properties: items: - const: stmmaceth + power-domains: + maxItems: 1 + required: - compatible - reg
Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml +3 -0
@@ -81,6 +81,9 @@ properties: - const: rx - const: ptp_ref + power-domains: + maxItems: 1 + required: - clocks - clock-names
Documentation/devicetree/bindings/net/qcom,ethqos.yaml +3 -0
@@ -86,6 +86,9 @@ properties: phy-names: const: serdes + power-domains: + maxItems: 1 + required: - compatible - clocks
Documentation/devicetree/bindings/net/qcom,sa8255p-ethqos.yaml new file +107 -0
107 lines not on this page · raw message
Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml +3 -0
@@ -44,6 +44,9 @@ properties: phandle pointing to a PCS sub-node compatible with renesas,rzn1-miic.yaml# + power-domains: + maxItems: 1 + required: - compatible
Documentation/devicetree/bindings/net/renesas,rzv2h-gbeth.yaml +3 -0
@@ -154,6 +154,9 @@ properties: Documentation/devicetree/bindings/net/pcs/renesas,rzn1-miic.yaml# (Refer RZ/T2H portion in the DT-binding file) + power-domains: + maxItems: 1 + required: - compatible - reg
Documentation/devicetree/bindings/net/rockchip-dwmac.yaml +3 -0
@@ -123,6 +123,9 @@ properties: phy-supply: description: PHY regulator + power-domains: + maxItems: 1 + required: - compatible - clocks
Documentation/devicetree/bindings/net/snps,dwmac.yaml +4 -1
@@ -72,6 +72,7 @@ properties: - nuvoton,ma35d1-dwmac - nxp,s32g2-dwmac - qcom,qcs404-ethqos + - qcom,sa8255p-ethqos - qcom,sa8775p-ethqos - qcom,sc8280xp-ethqos - qcom,sm8150-ethqos
@@ -186,7 +187,8 @@ properties: - enum: [ahb, stmmaceth-ocp] power-domains: - maxItems: 1 + minItems: 1 + maxItems: 2 mac-mode: $ref: ethernet-controller.yaml#/properties/phy-connection-type
@@ -631,6 +633,7 @@ allOf: - ingenic,x1830-mac - ingenic,x2000-mac - qcom,qcs404-ethqos + - qcom,sa8255p-ethqos - qcom,sa8775p-ethqos - qcom,sc8280xp-ethqos - qcom,sm8150-ethqos
Documentation/devicetree/bindings/net/sophgo,cv1800b-dwmac.yaml +3 -0
@@ -49,6 +49,9 @@ properties: reset-names: const: stmmaceth + power-domains: + maxItems: 1 + required: - compatible - reg
Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml +3 -0
@@ -52,6 +52,9 @@ properties: interrupt-names: maxItems: 1 + power-domains: + maxItems: 1 + resets: maxItems: 1
Documentation/devicetree/bindings/net/spacemit,k3-dwmac.yaml +3 -0
@@ -56,6 +56,9 @@ properties: reset-names: const: stmmaceth + power-domains: + maxItems: 1 + spacemit,apmu: $ref: /schemas/types.yaml#/definitions/phandle-array items:
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +3 -0
@@ -75,6 +75,9 @@ properties: The argument one is the offset of phy mode selection, the argument two is the shift of phy mode selection. + power-domains: + maxItems: 1 + required: - compatible - reg
Documentation/devicetree/bindings/net/stm32-dwmac.yaml +3 -0
@@ -121,6 +121,9 @@ properties: minItems: 1 maxItems: 2 + power-domains: + maxItems: 1 + required: - compatible - clocks
Documentation/devicetree/bindings/net/tesla,fsd-ethqos.yaml +3 -0
@@ -67,6 +67,9 @@ properties: - rgmii-rxid - rgmii-txid + power-domains: + maxItems: 1 + required: - compatible - reg
Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml +3 -0
@@ -78,6 +78,9 @@ properties: items: - const: macirq + power-domains: + maxItems: 1 + required: - clocks - clock-names
Documentation/devicetree/bindings/net/toshiba,visconti-dwmac.yaml +3 -0
@@ -48,6 +48,9 @@ properties: interrupt-names: const: macirq + power-domains: + maxItems: 1 + required: - compatible - reg
MAINTAINERS +1 -0
@@ -22676,6 +22676,7 @@ L: [email protected] L: [email protected] S: Maintained F: Documentation/devicetree/bindings/net/qcom,ethqos.yaml +F: Documentation/devicetree/bindings/net/qcom,sa8255p-ethqos.yaml F: drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c QUALCOMM FASTRPC DRIVER
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH net-next v15 4/9] dt-bindings: net: qcom: document the ethqos device for SCMI-based systems
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dt-bindings: ultrarisc,dp1000-gmac: missing power-domains maxItems constraint --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dt-bindings: ultrarisc,dp1000-gmac: missing power-domains maxItems constraint --
commit e30cc0626178117fbbeeed38ffe455db15d4973b
Author: Bartosz Golaszewski <[email protected]>
dt-bindings: net: qcom: document the ethqos device for SCMI-based systems
Describe the firmware-managed variant of the QCom DesignWare MAC. As the properties here differ a lot from the HLOS-managed variant, lets put it in a separate file. Since we need to update the maximum number of power domains, let's update existing bindings referencing the top-level snps,dwmac.yaml and limit their maxItems for power-domains to 1.
Quoted 4 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +0
-0
[ ... ]
Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 194
Quoted 10 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +2
-1@@ -186,7 +187,8 @@ properties: - enum: [ahb, stmmaceth-ocp] power-domains: - maxItems: 1 + minItems: 1 + maxItems: 2 mac-mode: $ref: ethernet-controller.yaml#/properties/phy-connection-type
[Severity: Low]
Does this unintentionally relax validation for the ultrarisc,dp1000-gmac compatible string?
The commit message mentions updating existing bindings that reference snps,dwmac.yaml to limit power-domains maxItems to 1. However, it appears Documentation/devicetree/bindings/net/ultrarisc,dp1000-gmac.yaml is missing a local override and will now inherit this new maxItems: 2 constraint.
Should ultrarisc,dp1000-gmac.yaml also be updated to limit maxItems to 1?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
AI reviewRe: [PATCH net-next v15 4/9] dt-bindings: net: qcom: document the ethqos device for SCMI-based systems
In reply to Bartosz GolaszewskiThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] This patch raises the shared power-domains limit in Documentation/devicetree/bindings/net/snps,dwmac.yaml from `maxItems:…
--
dt-bindings: net: qcom: document the ethqos device for SCMI-based systems
This commit adds a separate binding for the firmware-managed qcom,sa8255p-ethqos variant of the Qualcomm DesignWare MAC. It also adds that compatible to snps,dwmac.yaml and raises the shared power-domains limit there to two. To keep the old limit for other devices, it adds power-domains maxItems: 1 to the vendor bindings that reference snps,dwmac.yaml.
Quoted 4 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +0
-0
[ ... ]
Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 191
Quoted 7 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +2
-1@@ -186,7 +187,8 @@ properties: - enum: [ahb, stmmaceth-ocp] power-domains: - maxItems: 1 + minItems: 1 + maxItems: 2
[Severity: Medium]
Was ultrarisc,dp1000-gmac.yaml missed? The commit message says:
let's update existing bindings referencing the top-level snps,dwmac.yaml and limit their maxItems for power-domains to 1.
Documentation/devicetree/bindings/net/ultrarisc,dp1000-gmac.yaml already exists at the baseline and references this schema:
allOf:
- $ref: snps,dwmac.yaml#
unevaluatedProperties: false
Its properties block lists compatible, reg, clocks, clock-names, interrupts, interrupt-names and phy-mode. It has no power-domains entry, so it only gets the relaxed limit from snps,dwmac.yaml.
Before this patch, dt_binding_check and dtbs_check rejected a DP1000 node with power-domains = <&a>, <&b>. With this patch that node is accepted. This is still the case at the end of the series.
Nodes checked only through the select in snps,dwmac.yaml are affected too. That covers generic snps,dwmac* or snps,dwxgmac* compatibles with no vendor schema. These nodes now also accept two power domains, because no vendor schema restores the limit of 1.
One option is to add power-domains maxItems: 1 to ultrarisc,dp1000-gmac.yaml. Another is to keep maxItems: 1 here and allow two only for qcom,sa8255p-ethqos in an allOf if/then block. That would also cover bindings added later.
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260923-qcom-sa8255p-emac-v15-0-e82f33720737%40oss.qualcomm.com
PATCH v15 5/9 net: stmmac: qcom-ethqos: set serdes mode before powerup
In reply to Bartosz GolaszewskiCall phy_set_mode_ext() before phy_power_on() in qcom_ethqos_serdes_powerup(). This is harmless for existing users but on SCMI systems this is required for the PHY driver to select the right performance level - which translates to the link speed. This is done ahead of adding support for the firmware-managed EMAC on Qualcomm sa8255p.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +10 -1
@@ -601,10 +601,19 @@ static int qcom_ethqos_serdes_powerup(struct net_device *ndev, void *priv)if (ret)return ret; + ret =phy_set_mode_ext (ethqos->serdes_phy,PHY_MODE_ETHERNET , + ethqos->phy_mode); +if (ret) + goto err_out; + ret =phy_power_on (ethqos->serdes_phy);if (ret) -phy_exit (ethqos->serdes_phy); + goto err_out; +return 0 ; + +err_out: +phy_exit (ethqos->serdes_phy);return ret; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH net-next v15 5/9] net: stmmac: qcom-ethqos: set serdes mode before powerup
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] In qcom_ethqos_serdes_powerup() (drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c), the patch…
--
net: stmmac: qcom-ethqos: set serdes mode before powerup
This patch adds a call to phy_set_mode_ext() before phy_power_on() in qcom_ethqos_serdes_powerup(). On SCMI systems the PHY driver needs it to pick the right performance level, which sets the link speed. It prepares for adding support for the firmware-managed EMAC on Qualcomm sa8255p.
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int qcom_ethqos_serdes_powerup(struct net_device *ndev, void *priv) · line 607
Quoted 12 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +4
-0@@ -601,10 +601,19 @@ static int qcom_ethqos_serdes_powerup(struct net_device *ndev, void *priv)if (ret)return ret; + ret =phy_set_mode_ext (ethqos->serdes_phy,PHY_MODE_ETHERNET , + ethqos->phy_mode); +if (ret) + goto err_out;
[Severity: Medium]
What happens here if ethqos->phy_mode is one of the RGMII variants?
qcom_ethqos_probe() accepts RGMII, RGMII_ID, RGMII_RXID and RGMII_TXID. It installs serdes_powerup whenever a "serdes" PHY is found, whatever the phy_mode is:
qcom_ethqos_probe() {
...
if (ethqos->serdes_phy) {
plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup;
plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown;
}
...
}The qcom,ethqos binding allows this combination too. It has "phys: true" and "phy-names: const: serdes", with no condition on phy-mode.
Both SerDes PHY drivers reject any submode other than SGMII, 1000BASEX and 2500BASEX. In phy-qcom-sgmii-eth.c, qcom_dwmac_sgmii_phy_validate() is called from qcom_dwmac_sgmii_phy_set_mode():
if (submode == PHY_INTERFACE_MODE_SGMII || submode == PHY_INTERFACE_MODE_1000BASEX || submode == PHY_INTERFACE_MODE_2500BASEX) return 0; return -EINVAL;
The new qcom_dwmac_sgmii_phy_scmi_validate() inphy-qcom-sgmii-eth-scmi.c does the same.
Take a DT that sets phy-mode = "rgmii*" and also references an enabled serdes PHY. With this patch, powerup would fail like this:
stmmac_open()
stmmac_legacy_serdes_power_up()
qcom_ethqos_serdes_powerup()
phy_set_mode_ext()
qcom_dwmac_sgmii_phy_set_mode()
qcom_dwmac_sgmii_phy_validate() returns -EINVAL
goto err_out -> phy_exit()"SerDes powerup failed" is logged, and both stmmac_open() and stmmac_resume() fail. Before this patch the same DT powered the SerDes on without an error.
The other caller of this API in the same file already limits the call to SerDes modes:
ethqos_mac_finish_serdes() {
...
if (interface == PHY_INTERFACE_MODE_SGMII ||
interface == PHY_INTERFACE_MODE_2500BASEX)
ret = phy_set_mode_ext(ethqos->serdes_phy, PHY_MODE_ETHERNET,
interface);
...
}Later patches in the series don't change serdes_powerup. The patch that updates phy_mode to the resolved interface in mac_finish() only touches phy_mode inside mac_finish. mac_finish is only installed for SGMII and 2500BASEX, so an RGMII phy_mode would still reach this call at the end of the series.
I checked the in-tree DTs. The boards that reference a serdes PHY (lemans.dtsi and monaco.dtsi based) all use sgmii or 2500base-x. The RGMII boards have no serdes PHY. So "harmless for existing users" holds for in-tree users, and this only affects DTs the binding allows but that aren't in the tree.
Should the call be guarded the same way as in ethqos_mac_finish_serdes() (SGMII, 1000BASEX and 2500BASEX only)? Another option would be to install serdes_powerup only for SerDes phy-modes in qcom_ethqos_probe(), or to restrict the binding.
Quoted 12 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +6
-1+ ret =phy_power_on (ethqos->serdes_phy);if (ret) -phy_exit (ethqos->serdes_phy); + goto err_out; +return 0 ; + +err_out: +phy_exit (ethqos->serdes_phy);return ret; }
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260923-qcom-sa8255p-emac-v15-0-e82f33720737%40oss.qualcomm.com
PATCH v15 6/9 net: stmmac: qcom-ethqos: update phy_mode to the resolved interface in mac_finish()
In reply to Bartosz Golaszewskiethqos->phy_mode is read by serdes_powerup() and qcom_ethqos_set_sgmii_loopback() to configure the SerDes and its wrapper for the correct interface. It is set once at probe from the DT phy-mode property and never updated.
phylink resolves the actual runtime interface and passes it to the mac_finish() callback. On platforms that only ever operate at one speed these two values are always the same, but when the interface changes at runtime - for example switching between SGMII and 2500BASE-X - the stored value becomes stale. The next serdes_powerup() call, on a subsequent link cycle, then reinitializes the SerDes to the wrong mode.
Update ethqos->phy_mode from the interface argument in ethqos_mac_finish_serdes() so that it always reflects the last resolved interface.
With that, we now update the phy_mode to the runtime-resolved interface, so any subsequent resume with a 1G SGMII link skips the loopback setup and the DMA reset hangs. To remedy this, extend the guard to include PHY_INTERFACE_MODE_SGMII.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +8 -1
@@ -190,7 +190,8 @@ static void qcom_ethqos_set_sgmii_loopback(struct qcom_ethqos *ethqos, bool enable) {if (!ethqos->needs_sgmii_loopback || - ethqos->phy_mode !=PHY_INTERFACE_MODE_2500BASEX ) + (ethqos->phy_mode !=PHY_INTERFACE_MODE_2500BASEX && + ethqos->phy_mode !=PHY_INTERFACE_MODE_SGMII ))return ; rgmii_updatel(ethqos,
@@ -634,6 +635,12 @@ static int ethqos_mac_finish_serdes(struct net_device *ndev, void *priv,qcom_ethqos_set_sgmii_loopback (ethqos, false); +/* The interface mode is only known once phylink has resolved it and +* may change at runtime, so keep it in sync for later +* serdes_powerup()/serdes_powerdown() calls. +*/ + ethqos->phy_mode = interface; +if (interface ==PHY_INTERFACE_MODE_SGMII || interface ==PHY_INTERFACE_MODE_2500BASEX ) ret = phy_set_mode_ext(ethqos->serdes_phy, PHY_MODE_ETHERNET,
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH net-next v15 6/9] net: stmmac: qcom-ethqos: update phy_mode to the resolved interface in mac_finish()
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This patch fixes a regression added by the previous patch in the same series, "net: stmmac: qcom-ethqos: set serdes mode before…
- [Low] The new comment in ethqos_mac_finish_serdes() (dwmac-qcom- ethqos.c:638-641) says phy_mode is kept in sync "for later…
--
net: stmmac: qcom-ethqos: update phy_mode to the resolved interface in mac_finish()
This patch updates ethqos->phy_mode in ethqos_mac_finish_serdes() from the interface that phylink resolved, so later serdes_powerup() calls program the SerDes to the correct mode. It also widens the guard in qcom_ethqos_set_sgmii_loopback() to cover PHY_INTERFACE_MODE_SGMII. This keeps the loopback in place on resume with a 1G SGMII link.
Quoted 4 lines
ethqos->phy_modeis read byserdes_powerup()andqcom_ethqos_set_sgmii_loopback()to configure the SerDes and its wrapper for the correct interface. It is set once at probe from the DT phy-mode property and never updated.
[Severity: Low]
Is this a long-standing problem, or was it added earlier in this series?
As far as I can tell, serdes_powerup() only started reading phy_mode in the preceding patch, "net: stmmac: qcom-ethqos: set serdes mode before powerup". That patch added this to qcom_ethqos_serdes_powerup():
ret = phy_set_mode_ext(ethqos->serdes_phy, PHY_MODE_ETHERNET, ethqos->phy_mode);
Before that patch, power-up never used the stale probe-time value.
With only that patch applied, every open/resume replaces the resolved interface held by the SerDes PHY driver (data->interface in phy-qcom-sgmii-eth.c) with the DT mode. This stays in effect until phylink_mac_initial_config()->ethqos_mac_finish_serdes() programs the resolved mode again.
The commit message doesn't mention this dependency, so backporters won't know about it. Bisection can also stop on the intermediate commit.
Both patches are in the same unmerged series, so a Fixes: tag isn't the right fit here. Could this change be folded into "set serdes mode before powerup", or placed before it? Could the commit message then say so?
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +0
-0
[ ... ]
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int ethqos_mac_finish_serdes(struct net_device *ndev, void *priv, · line 641
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +4
-0@@ -634,6 +635,12 @@ static int ethqos_mac_finish_serdes(struct net_device *ndev, void *priv,qcom_ethqos_set_sgmii_loopback (ethqos, false); +/* The interface mode is only known once phylink has resolved it and +* may change at runtime, so keep it in sync for later +* serdes_powerup()/serdes_powerdown() calls. +*/
[Severity: Low]
This isn't a bug, but is the mention of serdes_powerdown() accurate? qcom_ethqos_serdes_powerdown() never reads ethqos->phy_mode:
static void qcom_ethqos_serdes_powerdown(struct net_device *ndev, void *priv)
{
struct qcom_ethqos *ethqos = priv;
phy_power_off(ethqos->serdes_phy);
phy_exit(ethqos->serdes_phy);
}The comment also leaves out qcom_ethqos_set_sgmii_loopback(). That function is called from ethqos_clks_config(true) on every open/resume:
qcom_ethqos_set_sgmii_loopback(ethqos, true); ethqos_set_func_clk_en(ethqos);
After this patch, its loopback decision depends on this assignment, which is why the guard had to be widened.
Would it be clearer to list serdes_powerup() andqcom_ethqos_set_sgmii_loopback() as the readers?
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +2
-0+ ethqos->phy_mode = interface; +if (interface ==PHY_INTERFACE_MODE_SGMII || interface ==PHY_INTERFACE_MODE_2500BASEX ) ret = phy_set_mode_ext(ethqos->serdes_phy, PHY_MODE_ETHERNET,
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260923-qcom-sa8255p-emac-v15-0-e82f33720737%40oss.qualcomm.com
PATCH v15 7/9 net: stmmac: qcom-ethqos: reuse the address of ethqos_emac_driver_data
In reply to Bartosz GolaszewskiInstead of needlessly copying the fields of ethqos_emac_driver_data into struct qcom_ethqos, just use the address of the former as a reference. It's .rodata after all. This is done in order to avoid having either two calls to of_device_get_match_data() or having to extend the latter with another field when adding support for SCMI.
--- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 37 ++++++++-------------- 1 file changed, 14 insertions(+), 23 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +14 -23
@@ -103,12 +103,7 @@ struct qcom_ethqos {struct clk *link_clk;struct phy *serdes_phy;phy_interface_t phy_mode; - -const struct ethqos_emac_por *rgmii_por; -unsigned int num_rgmii_por; -bool rgmii_config_loopback_en; -bool has_emac_ge_3; -bool needs_sgmii_loopback; +const struct ethqos_emac_driver_data *data; };static u32 rgmii_readl (struct qcom_ethqos *ethqos,unsigned int offset)
@@ -189,7 +184,7 @@ static int ethqos_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,static void qcom_ethqos_set_sgmii_loopback (struct qcom_ethqos *ethqos,bool enable) { -if (!ethqos->needs_sgmii_loopback || +if (!ethqos->data->needs_sgmii_loopback || (ethqos->phy_mode !=PHY_INTERFACE_MODE_2500BASEX && ethqos->phy_mode !=PHY_INTERFACE_MODE_SGMII ))return ;
@@ -323,7 +318,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)/* Set DLL_EN */ rgmii_setmask (ethqos,SDCC_DLL_CONFIG_DLL_EN ,SDCC_HC_REG_DLL_CONFIG ); -if (!ethqos->has_emac_ge_3) { +if (!ethqos->data->has_emac_ge_3) {rgmii_clrmask (ethqos,SDCC_DLL_MCLK_GATING_EN ,SDCC_HC_REG_DLL_CONFIG );
@@ -353,7 +348,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)rgmii_setmask (ethqos,SDCC_DLL_CONFIG2_DDR_CAL_EN ,SDCC_HC_REG_DLL_CONFIG2 ); -if (!ethqos->has_emac_ge_3) { +if (!ethqos->data->has_emac_ge_3) {rgmii_clrmask (ethqos,SDCC_DLL_CONFIG2_DLL_CLOCK_DIS ,SDCC_HC_REG_DLL_CONFIG2 );
@@ -433,7 +428,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos, int speed)rgmii_clrmask (ethqos,RGMII_CONFIG2_RSVD_CONFIG15 ,RGMII_IO_MACRO_CONFIG2 ); -if (speed ==SPEED_1000 || ethqos->has_emac_ge_3) +if (speed ==SPEED_1000 || ethqos->data->has_emac_ge_3)rgmii_setmask (ethqos,RGMII_CONFIG2_RX_PROG_SWAP ,RGMII_IO_MACRO_CONFIG2 );else
@@ -457,7 +452,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos, int speed)* in practice this becomes PRG_RCLK_DLY = 52 * 4 / * (2 * RX delay ns) */ -if (ethqos->has_emac_ge_3) { +if (ethqos->data->has_emac_ge_3) {/* 0.9 ns */ prg_rclk_dly =115 ; }else {
@@ -473,7 +468,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos, int speed) SDCC_HC_REG_DDR_CONFIG); } -if (ethqos->rgmii_config_loopback_en) +if (ethqos->data->rgmii_config_loopback_en) loopback =RGMII_CONFIG_LOOPBACK_EN ;else loopback =0 ;
@@ -496,9 +491,9 @@ static void ethqos_fix_mac_speed_rgmii(void *bsp_priv, dev = ðqos->pdev->dev;/* Reset to POR values and enable clk */ -for (i =0 ; i < ethqos->num_rgmii_por; i++) -rgmii_writel (ethqos, ethqos->rgmii_por[i].value, - ethqos->rgmii_por[i].offset); +for (i =0 ; i < ethqos->data->num_rgmii_por; i++) +rgmii_writel (ethqos, ethqos->data->rgmii_por[i].value, + ethqos->data->rgmii_por[i].offset);ethqos_set_func_clk_en (ethqos);
@@ -512,7 +507,7 @@ static void ethqos_fix_mac_speed_rgmii(void *bsp_priv,rgmii_setmask (ethqos,SDCC_DLL_CONFIG_PDN ,SDCC_HC_REG_DLL_CONFIG ); -if (ethqos->has_emac_ge_3) { +if (ethqos->data->has_emac_ge_3) {if (speed ==SPEED_1000 ) {rgmii_writel (ethqos,0x1800000 ,SDCC_TEST_CTL );rgmii_writel (ethqos,0x2C010800 ,SDCC_USR_CTL );
@@ -539,7 +534,7 @@ static void ethqos_fix_mac_speed_rgmii(void *bsp_priv, SDCC_HC_REG_DLL_CONFIG);/* Set USR_CTL bit 26 with mask of 3 bits */ -if (!ethqos->has_emac_ge_3) +if (!ethqos->data->has_emac_ge_3)rgmii_updatel (ethqos,GENMASK (26 ,24 ),BIT (26 ),SDCC_USR_CTL );
@@ -750,11 +745,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) "Failed to map rgmii resource\n"); data =of_device_get_match_data (dev); - ethqos->rgmii_por = data->rgmii_por; - ethqos->num_rgmii_por = data->num_rgmii_por; - ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en; - ethqos->has_emac_ge_3 = data->has_emac_ge_3; - ethqos->needs_sgmii_loopback = data->needs_sgmii_loopback; + ethqos->data = data; ethqos->link_clk =devm_clk_get (dev, data->link_clk_name ?:"rgmii" );if (IS_ERR (ethqos->link_clk))
@@ -791,7 +782,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) plat_dat->dump_debug_regs = rgmii_dump; plat_dat->ptp_clk_freq_config = ethqos_ptp_clk_freq_config; plat_dat->core_type =DWMAC_CORE_GMAC4 ; -if (ethqos->has_emac_ge_3) +if (data->has_emac_ge_3) plat_dat->dwmac4_addrs = &data->dwmac4_addrs; plat_dat->pmt = true;if (of_property_read_bool (np,"snps,tso" ))
Signature · 1 line
2.47.3
PATCH v15 8/9 net: stmmac: qcom-ethqos: factor out linux-level setup into a separate function
In reply to Bartosz GolaszewskiAhead of adding support for firmware-controlled EMAC variants, extend the ethqos_emac_driver_data structure with a setup() callback, implement it for the existing models and move all operations not required in SCMI mode into it.
--- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 99 +++++++++++++++------- 1 file changed, 68 insertions(+), 31 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +68 -31
@@ -5,6 +5,7 @@#include <linux/of.h> #include <linux/of_net.h> #include <linux/platform_device.h> +#include <linux/pm_domain.h> #include <linux/phy.h> #include <linux/phy/phy.h>
@@ -81,6 +82,8 @@#define SGMII_10M_RX_CLK_DVDR 0x31 +struct qcom_ethqos ; +struct ethqos_emac_por {unsigned int offset;unsigned int value;
@@ -95,6 +98,8 @@ struct ethqos_emac_driver_data {const char *link_clk_name;struct dwmac4_addrs dwmac4_addrs;bool needs_sgmii_loopback; +int (*setup)(struct qcom_ethqos *ethqos, +struct plat_stmmacenet_data *plat_dat); };struct qcom_ethqos {
@@ -200,6 +205,9 @@ static void ethqos_set_func_clk_en(struct qcom_ethqos *ethqos)rgmii_setmask (ethqos,RGMII_CONFIG_FUNC_CLK_EN ,RGMII_IO_MACRO_CONFIG ); } +static int ethqos_hlos_setup (struct qcom_ethqos *ethqos, +struct plat_stmmacenet_data *plat_dat); +static const struct ethqos_emac_por emac_v2_3_0_por[] = { { .offset =RGMII_IO_MACRO_CONFIG , .value =0x00C01343 }, { .offset =SDCC_HC_REG_DLL_CONFIG , .value =0x2004642C },
@@ -214,6 +222,7 @@ static const struct ethqos_emac_driver_data emac_v2_3_0_data = { .num_rgmii_por = ARRAY_SIZE(emac_v2_3_0_por), .rgmii_config_loopback_en = true, .has_emac_ge_3 = false, + .setup = ethqos_hlos_setup, };static const struct ethqos_emac_por emac_v2_1_0_por[] = {
@@ -230,6 +239,7 @@ static const struct ethqos_emac_driver_data emac_v2_1_0_data = { .num_rgmii_por = ARRAY_SIZE(emac_v2_1_0_por), .rgmii_config_loopback_en = false, .has_emac_ge_3 = false, + .setup = ethqos_hlos_setup, };static const struct ethqos_emac_por emac_v3_0_0_por[] = {
@@ -262,6 +272,7 @@ static const struct ethqos_emac_driver_data emac_v3_0_0_data = { .mtl_low_cred = 0x00008024, .mtl_low_cred_offset = 0x1000, }, + .setup = ethqos_hlos_setup, }; static const struct ethqos_emac_por emac_v4_0_0_por[] = {
@@ -297,6 +308,7 @@ static const struct ethqos_emac_driver_data emac_v4_0_0_data = { .mtl_low_cred = 0x00008024, .mtl_low_cred_offset = 0x1000, }, + .setup = ethqos_hlos_setup, };static int ethqos_dll_configure (struct qcom_ethqos *ethqos)
@@ -692,6 +704,58 @@ static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv)netdev_dbg (priv->dev,"PTP rate %lu\n" , plat_dat->clk_ptp_rate); } +static int ethqos_hlos_setup (struct qcom_ethqos *ethqos, +struct plat_stmmacenet_data *plat_dat) +{ +struct platform_device *pdev = ethqos->pdev; +struct device *dev = &pdev->dev; +int ret; + + ethqos->rgmii_base =devm_platform_ioremap_resource_byname (pdev,"rgmii" ); +if (IS_ERR (ethqos->rgmii_base)) +return dev_err_probe (dev,PTR_ERR (ethqos->rgmii_base), +"Failed to map rgmii resource\n" ); + + ethqos->link_clk =devm_clk_get (dev, ethqos->data->link_clk_name ?:"rgmii" ); +if (IS_ERR (ethqos->link_clk)) +return dev_err_probe (dev,PTR_ERR (ethqos->link_clk), +"Failed to get link_clk\n" ); + + plat_dat->clks_config = ethqos_clks_config; + + ret =ethqos_clks_config (ethqos, true); +if (ret) +return ret; + + ret =devm_add_action_or_reset (dev, ethqos_clks_disable, ethqos); +if (ret) +return ret; + +ethqos_set_clk_tx_rate (ethqos,NULL , plat_dat->phy_interface,SPEED_1000 ); +qcom_ethqos_set_sgmii_loopback (ethqos, true); +ethqos_set_func_clk_en (ethqos); + +switch (ethqos->phy_mode) { +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + plat_dat->fix_mac_speed = ethqos_fix_mac_speed_rgmii; +break ; +case PHY_INTERFACE_MODE_2500BASEX : +case PHY_INTERFACE_MODE_SGMII : + plat_dat->fix_mac_speed = ethqos_fix_mac_speed_sgmii; +break ; +default : +break ; + } + + plat_dat->set_clk_tx_rate = ethqos_set_clk_tx_rate; + plat_dat->dump_debug_regs = rgmii_dump; + +return 0 ; +} +static int qcom_ethqos_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node;
@@ -713,23 +777,20 @@ static int qcom_ethqos_probe(struct platform_device *pdev) "dt configuration failed\n"); } - plat_dat->clks_config = ethqos_clks_config; - ethqos =devm_kzalloc (dev,sizeof (*ethqos),GFP_KERNEL );if (!ethqos)return -ENOMEM ; ethqos->phy_mode = plat_dat->phy_interface; +switch (ethqos->phy_mode) {case PHY_INTERFACE_MODE_RGMII :case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_RXID :case PHY_INTERFACE_MODE_RGMII_TXID : - plat_dat->fix_mac_speed = ethqos_fix_mac_speed_rgmii;break ;case PHY_INTERFACE_MODE_2500BASEX :case PHY_INTERFACE_MODE_SGMII : - plat_dat->fix_mac_speed = ethqos_fix_mac_speed_sgmii; plat_dat->mac_finish = ethqos_mac_finish_serdes;break ;default :
@@ -739,24 +800,13 @@ static int qcom_ethqos_probe(struct platform_device *pdev) } ethqos->pdev = pdev; - ethqos->rgmii_base =devm_platform_ioremap_resource_byname (pdev,"rgmii" ); -if (IS_ERR (ethqos->rgmii_base)) -return dev_err_probe (dev,PTR_ERR (ethqos->rgmii_base), -"Failed to map rgmii resource\n" ); - data =of_device_get_match_data (dev); ethqos->data = data; - ethqos->link_clk =devm_clk_get (dev, data->link_clk_name ?:"rgmii" ); -if (IS_ERR (ethqos->link_clk)) -return dev_err_probe (dev,PTR_ERR (ethqos->link_clk), -"Failed to get link_clk\n" ); - - ret =ethqos_clks_config (ethqos, true); -if (ret) -return ret; +if (WARN_ON (!data->setup)) +return -EINVAL ; - ret =devm_add_action_or_reset (dev, ethqos_clks_disable, ethqos); + ret = data->setup (ethqos, plat_dat);if (ret)return ret;
@@ -765,21 +815,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (ethqos->serdes_phy),"Failed to get serdes phy\n" ); -ethqos_set_clk_tx_rate (ethqos,NULL , plat_dat->phy_interface, -SPEED_1000 ); - -qcom_ethqos_set_sgmii_loopback (ethqos, true); -ethqos_set_func_clk_en (ethqos); - -/* The clocks are controlled by firmware, so we don't know for certain -* what clock rate is being used. Hardware documentation mentions that -* the AHB slave clock will be in the range of 50 to 100MHz, which -* equates to a MDC between 1.19 and 2.38MHz. -*/ plat_dat->clk_csr =STMMAC_CSR_60_100M ; plat_dat->bsp_priv = ethqos; - plat_dat->set_clk_tx_rate = ethqos_set_clk_tx_rate; - plat_dat->dump_debug_regs = rgmii_dump; plat_dat->ptp_clk_freq_config = ethqos_ptp_clk_freq_config; plat_dat->core_type =DWMAC_CORE_GMAC4 ;if (data->has_emac_ge_3)
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH net-next v15 8/9] net: stmmac: qcom-ethqos: factor out linux-level setup into a separate function
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message does not describe the refactor boundary accurately.
- [Low] The patch deletes the comment that justified the hard-coded MDC divider ('The clocks are controlled by firmware, so we don't know for…
--
net: stmmac: qcom-ethqos: factor out linux-level setup into a separate function
This patch adds a setup() callback to struct ethqos_emac_driver_data. It implements the callback as ethqos_hlos_setup() for the existing EMAC variants. The rgmii mapping, link clock handling and several plat_dat callbacks move from qcom_ethqos_probe() into it, ahead of support for firmware-controlled (SCMI) EMAC variants.
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +0
-0
[ ... ]
Quoted 31 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +27
-0@@ -692,6 +704,58 @@ static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv)netdev_dbg (priv->dev,"PTP rate %lu\n" , plat_dat->clk_ptp_rate); } +static int ethqos_hlos_setup (struct qcom_ethqos *ethqos, +struct plat_stmmacenet_data *plat_dat) +{ +struct platform_device *pdev = ethqos->pdev; +struct device *dev = &pdev->dev; +int ret; + + ethqos->rgmii_base =devm_platform_ioremap_resource_byname (pdev,"rgmii" ); +if (IS_ERR (ethqos->rgmii_base)) +return dev_err_probe (dev,PTR_ERR (ethqos->rgmii_base), +"Failed to map rgmii resource\n" ); + + ethqos->link_clk =devm_clk_get (dev, ethqos->data->link_clk_name ?:"rgmii" ); +if (IS_ERR (ethqos->link_clk)) +return dev_err_probe (dev,PTR_ERR (ethqos->link_clk), +"Failed to get link_clk\n" ); + + plat_dat->clks_config = ethqos_clks_config; + + ret =ethqos_clks_config (ethqos, true); +if (ret) +return ret; + + ret =devm_add_action_or_reset (dev, ethqos_clks_disable, ethqos); +if (ret) +return ret; +
[ ... ]
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv) · line 751
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +7
-0+case PHY_INTERFACE_MODE_2500BASEX : +case PHY_INTERFACE_MODE_SGMII : + plat_dat->fix_mac_speed = ethqos_fix_mac_speed_sgmii; +break ; +default : +break ; + }
[Severity: Low]
This isn't a bug, but is the commit message accurate about what moves into the callback? It says the patch will:
"move all operations not required in SCMI mode into it."
SCMI mode also needs several of the steps moved into ethqos_hlos_setup():
- mapping the "rgmii" wrapper
- setting plat_dat->clks_config
- the first ethqos_clks_config(ethqos, true) call, along with its devm_add_action_or_reset(dev, ethqos_clks_disable, ethqos) cleanup
- selecting ethqos_fix_mac_speed_sgmii for SGMII/2500BASEX
Later in the series, the ethqos_scmi_setup() added by "net: stmmac:
qcom-ethqos: add support for sa8255p" repeats each of these steps. Its own comment says the wrapper loopback and functional clock bits are required. Without them, the DMA SW-reset in dwmac4_dma_reset() never completes.
As a result, the same setup code exists in two places instead of once in qcom_ethqos_probe().
Could the shared steps stay in qcom_ethqos_probe() or move to a common helper, leaving only the HLOS-only parts in ethqos_hlos_setup()? If not, could the commit message describe the split more precisely?
[ ... ]
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +0
-2@@ -765,21 +815,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (ethqos->serdes_phy),"Failed to get serdes phy\n" ); -ethqos_set_clk_tx_rate (ethqos,NULL , plat_dat->phy_interface, -SPEED_1000 );
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int qcom_ethqos_probe(struct platform_device *pdev) · line 818
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +0
-9- -qcom_ethqos_set_sgmii_loopback (ethqos, true); -ethqos_set_func_clk_en (ethqos); - -/* The clocks are controlled by firmware, so we don't know for certain -* what clock rate is being used. Hardware documentation mentions that -* the AHB slave clock will be in the range of 50 to 100MHz, which -* equates to a MDC between 1.19 and 2.38MHz. -*/ plat_dat->clk_csr =STMMAC_CSR_60_100M ;
[Severity: Low]
Was this comment meant to be removed?
qcom_ethqos_probe() still sets plat_dat->clk_csr = STMMAC_CSR_60_100M for every variant, but the comment explaining the hard-coded MDC divider is gone.
The commit message describes the change as code motion and does not mention removing the comment. No later patch in the series restores it.
Could the comment be kept above the clk_csr assignment?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260923-qcom-sa8255p-emac-v15-0-e82f33720737%40oss.qualcomm.com
PATCH v15 9/9 net: stmmac: qcom-ethqos: add support for sa8255p
In reply to Bartosz GolaszewskiExtend the driver to support a new model - sa8255p. Unlike the previously supported variants, this one's power management is done in the firmware over SCMI. This is modeled in linux using power domains so add a new emac data variant and a separate setup callback.
--- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +107 -0
@@ -98,6 +98,11 @@ struct ethqos_emac_driver_data {const char *link_clk_name;struct dwmac4_addrs dwmac4_addrs;bool needs_sgmii_loopback; +/* Fixed PTP reference clock rate, used on SCMI platforms where +* firmware does not implement the clock protocol allowing linux to +* query it. +*/ +unsigned long ptp_clk_rate;int (*setup)(struct qcom_ethqos *ethqos,struct plat_stmmacenet_data *plat_dat); };
@@ -108,6 +113,7 @@ struct qcom_ethqos {struct clk *link_clk;struct phy *serdes_phy;phy_interface_t phy_mode; +struct dev_pm_domain_list *pds;const struct ethqos_emac_driver_data *data; };
@@ -207,6 +213,8 @@ static void ethqos_set_func_clk_en(struct qcom_ethqos *ethqos)static int ethqos_hlos_setup (struct qcom_ethqos *ethqos,struct plat_stmmacenet_data *plat_dat); +static int ethqos_scmi_setup (struct qcom_ethqos *ethqos, +struct plat_stmmacenet_data *plat_dat);static const struct ethqos_emac_por emac_v2_3_0_por[] = { { .offset =RGMII_IO_MACRO_CONFIG , .value =0x00C01343 },
@@ -311,6 +319,30 @@ static const struct ethqos_emac_driver_data emac_v4_0_0_data = { .setup = ethqos_hlos_setup, }; +static const struct ethqos_emac_driver_data emac_v4_0_0_scmi_data = { + .has_emac_ge_3 = true, + .needs_sgmii_loopback = true, + .dma_addr_width =36 , + .ptp_clk_rate =230400000 , + .dwmac4_addrs = { + .dma_chan =0x00008100 , + .dma_chan_offset =0x1000 , + .mtl_chan =0x00008000 , + .mtl_chan_offset =0x1000 , + .mtl_ets_ctrl =0x00008010 , + .mtl_ets_ctrl_offset =0x1000 , + .mtl_txq_weight =0x00008018 , + .mtl_txq_weight_offset =0x1000 , + .mtl_send_slp_cred =0x0000801c , + .mtl_send_slp_cred_offset =0x1000 , + .mtl_high_cred =0x00008020 , + .mtl_high_cred_offset =0x1000 , + .mtl_low_cred =0x00008024 , + .mtl_low_cred_offset =0x1000 , + }, + .setup = ethqos_scmi_setup, +}; +static int ethqos_dll_configure (struct qcom_ethqos *ethqos) {struct device *dev = ðqos->pdev->dev;
@@ -756,6 +788,80 @@ static int ethqos_hlos_setup(struct qcom_ethqos *ethqos,return 0 ; } +static const char *const ethqos_scmi_pd_names[] = {"core" ,"mdio" }; + +static int ethqos_scmi_setup (struct qcom_ethqos *ethqos, +struct plat_stmmacenet_data *plat_dat) +{ +const struct dev_pm_domain_attach_data pd_data = { + .pd_names = ethqos_scmi_pd_names, + .num_pd_names =ARRAY_SIZE (ethqos_scmi_pd_names), + .pd_flags =PD_FLAG_DEV_LINK_ON , + }; + +struct platform_device *pdev = ethqos->pdev; +struct device *dev = &pdev->dev; +int ret; + + ret =devm_pm_domain_attach_list (dev, &pd_data, ðqos->pds); +if (ret <0 ) +return dev_err_probe (dev, ret, +"Failed to attach power domains\n" ); + +/* +* The SerDes lane, its clocks and the MAC AXI/AHB clocks are owned by +* firmware and brought up through the SCMI power domains above. The +* MAC wrapper itself, however is in the kernel's register space: the +* wrapper bit that loops the PHY TX clock into the MAC's clk_rx_i - +* needed because no recovered RX clock exists yet - is not +* configured by firmware. Without it, clk_rx_i never toggles and the +* DMA SW-reset polled in dwmac4_dma_reset() never completes. +* +* Map the wrapper and program the same loopback/functional clock bits +* the non-firmware platforms rely on (see ethqos_clks_config) so the +* RX clock is present by the time the DMA engine is reset. +*/ + ethqos->rgmii_base =devm_platform_ioremap_resource_byname (pdev,"rgmii" ); +if (IS_ERR (ethqos->rgmii_base)) +return dev_err_probe (dev,PTR_ERR (ethqos->rgmii_base), +"Failed to map rgmii resource\n" ); + +/* +* Register clks_config to run on every subsequent runtime resume, +* which stmmac performs after the power domains are on but before +* serdes_powerup() and the DMA reset. This alone isn't enough for +* the very first reset done from stmmac_open(), though: probe() +* fakes the device into RPM_ACTIVE without invoking the resume +* callback, so whether clks_config() has run by then depends on +* whether the device has already gone through one real suspend/resume +* cycle in the meantime. Call it here explicitly so the wrapper is +* always configured before the first DMA reset regardless of that +* timing. +*/ + plat_dat->clks_config = ethqos_clks_config; + + ret =ethqos_clks_config (ethqos, true); +if (ret) +return ret; + + ret =devm_add_action_or_reset (dev, ethqos_clks_disable, ethqos); +if (ret) +return ret; + + plat_dat->clk_ptp_rate = ethqos->data->ptp_clk_rate; + +switch (ethqos->phy_mode) { +case PHY_INTERFACE_MODE_2500BASEX : +case PHY_INTERFACE_MODE_SGMII : + plat_dat->fix_mac_speed = ethqos_fix_mac_speed_sgmii; +break ; +default : +break ; + } + +return 0 ; +} +static int qcom_ethqos_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node;
@@ -843,6 +949,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)static const struct of_device_id qcom_ethqos_match[] = { { .compatible ="qcom,qcs404-ethqos" , .data = &emac_v2_3_0_data}, + { .compatible ="qcom,sa8255p-ethqos" , .data = &emac_v4_0_0_scmi_data}, { .compatible ="qcom,sa8775p-ethqos" , .data = &emac_v4_0_0_data}, { .compatible ="qcom,sc8280xp-ethqos" , .data = &emac_v3_0_0_data}, { .compatible ="qcom,sm8150-ethqos" , .data = &emac_v2_1_0_data},
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH net-next v15 9/9] net: stmmac: qcom-ethqos: add support for sa8255p
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 2
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] With Wake-on-LAN armed, system suspend on sa8255p powers off the MAC's SCMI "core"/"mdio" domains, and on resume the EMAC wrapper…
- [Medium] The SCMI variant has no CSR/application clock, and nothing substitutes a rate for it.
- [Low] The new sa8255p (SCMI) variant accepts RGMII phy-modes but silently misconfigures them.
- [Low] The new comment in ethqos_scmi_setup() and the commit message misdescribe what the code does.
--
net: stmmac: qcom-ethqos: add support for sa8255p
This adds a new sa8255p variant to the qcom-ethqos glue driver. On this variant, firmware handles power management over SCMI, and Linux models it with power domains. It adds a new emac data variant with a fixed PTP clock rate, plus a separate ethqos_scmi_setup() callback.
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +0
-0
[ ... ]
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +9
-0@@ -756,6 +788,80 @@ static int ethqos_hlos_setup(struct qcom_ethqos *ethqos,return 0 ; } +static const char *const ethqos_scmi_pd_names[] = {"core" ,"mdio" }; + +static int ethqos_scmi_setup (struct qcom_ethqos *ethqos, +struct plat_stmmacenet_data *plat_dat) +{ +const struct dev_pm_domain_attach_data pd_data = { + .pd_names = ethqos_scmi_pd_names, + .num_pd_names =ARRAY_SIZE (ethqos_scmi_pd_names), + .pd_flags =PD_FLAG_DEV_LINK_ON ,
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int ethqos_hlos_setup(struct qcom_ethqos *ethqos, · line 809
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +10
-0+ }; + +struct platform_device *pdev = ethqos->pdev; +struct device *dev = &pdev->dev; +int ret; + + ret =devm_pm_domain_attach_list (dev, &pd_data, ðqos->pds); +if (ret <0 ) +return dev_err_probe (dev, ret, +"Failed to attach power domains\n" );
[Severity: Medium]
What happens to these two domains during system suspend when Wake-on-LAN is armed?
devm_pm_domain_attach_list() creates virtual genpd devices through genpd_dev_pm_attach_by_id(). Those devices have no parent:
drivers/pmdomain/core.c:genpd_dev_pm_attach_by_id() {
...
dev_set_name(virt_dev, "genpd:%u:%s", index, dev_name(dev));
virt_dev->bus = &genpd_bus_type;
virt_dev->release = genpd_release_dev;
virt_dev->of_node = of_node_get(dev->of_node);
...
}dpm_propagate_wakeup_to_parent() only passes wakeup_path to dev->parent. It does not reach device-link suppliers, so device_awake_path(virt_dev) stays false.
SCMI domains set GENPD_FLAG_ACTIVE_WAKEUP. Even so, genpd_finish_suspend() falls through to genpd_sync_power_off():
if (device_awake_path(dev) && genpd_is_active_wakeup(genpd) && !device_out_band_wakeup(dev)) return 0;
qcom_ethqos_probe() also sets plat_dat->pmt = true for this variant, so WoL can be enabled with ethtool. With priv->wolopts set, stmmac_pltfr_noirq_suspend() and stmmac_pltfr_noirq_resume() skip pm_runtime_force_suspend() and pm_runtime_force_resume():
if (!priv->wolopts) {
/* enable the clk previously disabled */
ret = pm_runtime_force_resume(dev);As a result, ethqos_clks_config(true) does not run on resume.
If firmware really power-cycles the MAC and wrapper when the "core" and "mdio" domains are turned off, can WoL fail to wake the system? Would the SGMII loopback and FUNC_CLK_EN bits at rgmii_base also be lost, so that stmmac_resume()->stmmac_hw_setup() hits the DMA SW-reset timeout that the comment below describes?
On the HLOS variants, the single GDSC is the MAC's own pm_domain, so the awake-path check applies to the MAC device itself. This looks specific to the multi-domain attach used here. The kernel tree can't show whether firmware actually removes power on that request.
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int ethqos_hlos_setup(struct qcom_ethqos *ethqos, · line 818
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +9
-0+ +/* +* The SerDes lane, its clocks and the MAC AXI/AHB clocks are owned by +* firmware and brought up through the SCMI power domains above. The +* MAC wrapper itself, however is in the kernel's register space: the +* wrapper bit that loops the PHY TX clock into the MAC's clk_rx_i - +* needed because no recovered RX clock exists yet - is not +* configured by firmware. Without it, clk_rx_i never toggles and the +* DMA SW-reset polled in dwmac4_dma_reset() never completes.
[Severity: Low]
Is this comment right about where the SerDes power comes from?
The sa8255p SerDes PHY binding (qcom,sa8255p-dwmac-sgmii-phy.yaml) requires a power-domain of its own. phy-qcom-sgmii-eth-scmi.c votes for it through the PHY device's runtime PM (devm_pm_runtime_enable() before devm_phy_create()), and set_mode() sets its performance state.
qcom_ethqos_probe() still gets the "serdes" phy and installs qcom_ethqos_serdes_powerup(). The PHY TX clock that is looped into clk_rx_i therefore comes from serdes_powerup() in stmmac_open(), before __stmmac_open()->stmmac_hw_setup(). It does not come from the "core" and "mdio" domains attached above.
The current ordering works. Could the comment name the SerDes PHY's own domain instead, so later changes to the SerDes or PM ordering are not misled?
The commit message also says only:
Unlike the previously supported variants, this one's power management is done in the firmware over SCMI. This is modeled in linux using power domains so add a new emac data variant and a separate setup callback.
Could it also mention the following?
- The kernel still maps and programs the "rgmii" wrapper registers (SGMII loopback and FUNC_CLK_EN) at probe and on every runtime resume.
- set_clk_tx_rate and dump_debug_regs are dropped for this variant.
- A fixed 230.4 MHz PTP reference rate is hardcoded in
emac_v4_0_0_scmi_data.
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +5
-0+* +* Map the wrapper and program the same loopback/functional clock bits +* the non-firmware platforms rely on (see ethqos_clks_config) so the +* RX clock is present by the time the DMA engine is reset. +*/
[ ... ]
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int ethqos_hlos_setup(struct qcom_ethqos *ethqos, · line 851
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +5
-0+ ret =devm_add_action_or_reset (dev, ethqos_clks_disable, ethqos); +if (ret) +return ret; + + plat_dat->clk_ptp_rate = ethqos->data->ptp_clk_rate;
[Severity: Medium]
The PTP rate gets a fixed value here, but what about the CSR clock?
The sa8255p binding has no clocks property. stmmac_probe_config_dt() therefore fails devm_clk_get("stmmaceth") and leaves plat->stmmac_clk NULL:
plat->stmmac_clk = devm_clk_get(&pdev->dev,
STMMAC_RESOURCE_NAME);
if (IS_ERR(plat->stmmac_clk)) {
dev_warn(&pdev->dev, "Cannot get CSR clock\n");
plat->stmmac_clk = NULL;dwmac4_core_init() then runs this on every stmmac_hw_setup():
clk_rate = clk_get_rate(priv->plat->stmmac_clk); writel((clk_rate / 1000000) - 1, ioaddr + GMAC4_MAC_ONEUS_TIC_COUNTER);
With clk_rate == 0, won't this write 0xFFFFFFFF into GMAC4_MAC_ONEUS_TIC_COUNTER? That would break the LPI/EEE timers, which count in microseconds.
plat_dat->clk_ref_rate is not set either, so stmmac_usec2riwt() and stmmac_riwt2usec() return 0:
unsigned long clk = clk_get_rate(priv->plat->stmmac_clk);
if (!clk) {
clk = priv->plat->clk_ref_rate;
if (!clk)
return 0;Would ethtool -C rx-usecs then fail the MIN_DMA_RIWT check, and would rx-usecs be reported as 0?
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c static int ethqos_hlos_setup(struct qcom_ethqos *ethqos, · line 860
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +9
-0+ +switch (ethqos->phy_mode) { +case PHY_INTERFACE_MODE_2500BASEX : +case PHY_INTERFACE_MODE_SGMII : + plat_dat->fix_mac_speed = ethqos_fix_mac_speed_sgmii; +break ; +default : +break ; + }
[Severity: Low]
What happens here if the device tree sets an RGMII phy-mode on a qcom,sa8255p-ethqos node?
qcom_ethqos_probe() accepts PHY_INTERFACE_MODE_RGMII, _ID, _RXID and _TXID for every compatible, and the sa8255p binding does not constrain phy-mode. For RGMII, this switch takes the default branch, so none of the following happens:
- no fix_mac_speed is installed
- no set_clk_tx_rate is installed
- no RGMII IO macro or DLL programming is done (emac_v4_0_0_scmi_data has no rgmii_por)
qcom_ethqos_set_sgmii_loopback() also returns early for non-SGMII modes.
The SCMI SerDes provider rejects RGMII as well:
drivers/phy/qualcomm/phy-qcom-sgmii-eth-scmi.c:qcom_dwmac_sgmii_phy_scmi_validate() {
switch (submode) {
case PHY_INTERFACE_MODE_SGMII:
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_2500BASEX:
return 0;
default:
return -EINVAL;
...
}With a phys property, qcom_ethqos_serdes_powerup()->phy_set_mode_ext() fails at open time. Without one, the MAC runs in RGMII mode with no wrapper configuration. In both cases probe succeeds, but the interface never works.
Would it be better for ethqos_scmi_setup() to return -EINVAL for modes that don't use the SerDes, or for the binding to limit phy-mode to an enum, or both?
Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +3
-0+ +return 0 ; +}
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260923-qcom-sa8255p-emac-v15-0-e82f33720737%40oss.qualcomm.com
This series was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 9 lines · On Wed, 23 Sep 2026 17:14:34 +0200 you wrote:
This iteration addresses several issues raised by Sashiko. Some are not addressed as they were false positives (nothing in the PHY driver ever calls
phy_runtime_get()on the parent device) or I decided they make no sense - like the suggestion to remove the power-domain-names property because there's only one power domain.--
[...]
Here is the summary with links:
- [net-next,v15,1/9] net: phy: aquantia: fix system interface type not updated in forced mode
https://git.kernel.org/netdev/net/c/6e0022b5ae3d
- [net-next,v15,2/9] dt-bindings: phy: document the serdes PHY on sa8255p
(no matching commit)
- [net-next,v15,3/9] phy: qcom: add the SGMII SerDes PHY driver for SCMI systems
(no matching commit)
- [net-next,v15,4/9] dt-bindings: net: qcom: document the ethqos device for SCMI-based systems (no matching commit)
- [net-next,v15,5/9] net: stmmac: qcom-ethqos: set serdes mode before powerup
(no matching commit)
- [net-next,v15,6/9] net: stmmac: qcom-ethqos: update phy_mode to the resolved interface in mac_finish() (no matching commit)
- [net-next,v15,7/9] net: stmmac: qcom-ethqos: reuse the address of ethqos_emac_driver_data (no matching commit)
- [net-next,v15,8/9] net: stmmac: qcom-ethqos: factor out linux-level setup into a separate function (no matching commit)
- [net-next,v15,9/9] net: stmmac: qcom-ethqos: add support for sa8255p
(no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html