| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/08 23:48 | flow | patch-triage |
22mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "The patch series introduces a Rockchip RK3568 Ethernet XPCS (Physical Coding Sublayer) platform driver and updates the Synopsys DW XPCS SGMII auto-negotiation logic for Rockchip integration. The modified code resides in Rockchip SoC-specific platform drivers and the Synopsys DW XPCS driver, which requires physical SoC/ASIC hardware (Rockchip, Wangxun, Intel MGBE, Meta fbnic, or DSA switches) not emulated in standard virtualized QEMU environments on amd64. Consequently, the modified code is structurally unreachable.",
"WorthFuzzing": false
} |
| 1/1 | 2026/10/08 23:48 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit a938dab07a487e21fa7cd36f388875908179ea5b\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Thu Oct 8 23:48:46 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/Documentation/devicetree/bindings/net/pcs/rockchip,rk3568-xpcs.yaml b/Documentation/devicetree/bindings/net/pcs/rockchip,rk3568-xpcs.yaml\nnew file mode 100644\nindex 0000000000000..a331880eb11c1\n--- /dev/null\n+++ b/Documentation/devicetree/bindings/net/pcs/rockchip,rk3568-xpcs.yaml\n@@ -0,0 +1,69 @@\n+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)\n+%YAML 1.2\n+---\n+$id: http://devicetree.org/schemas/net/pcs/rockchip,rk3568-xpcs.yaml#\n+$schema: http://devicetree.org/meta-schemas/core.yaml#\n+\n+title: Rockchip RK3568 Synopsys DesignWare Ethernet PCS\n+\n+maintainers:\n+ - Coia Prant \u003ccoiaprant@gmail.com\u003e\n+\n+description: |\n+ Rockchip RK3568 SoC integrates a Synopsys DesignWare Ethernet Physical\n+ Coding Sublayer (XPCS).\n+ The PCS provides an interface between the Media Access Control (MAC)\n+ and the Physical Medium Attachment (PMA) sublayer through a Media\n+ Independent Interface (GMII).\n+\n+ The XPCS is accessed over the APB3 bus and internally connected to a\n+ Naneng Combo SerDes PHY.\n+ It supports 1000BASE-X, SGMII and QSGMII modes.\n+\n+properties:\n+ compatible:\n+ const: rockchip,rk3568-xpcs\n+\n+ reg:\n+ maxItems: 1\n+\n+ clocks:\n+ items:\n+ - description: APB3 bus interface clock (clk_csr_i), required for register access\n+ - description: EEE clock (clk_eee_i), required for Energy Efficient Ethernet operation\n+\n+ clock-names:\n+ items:\n+ - const: csr\n+ - const: eee\n+\n+ phys:\n+ maxItems: 1\n+\n+ power-domains:\n+ maxItems: 1\n+\n+required:\n+ - compatible\n+ - reg\n+ - clocks\n+ - clock-names\n+ - phys\n+ - power-domains\n+\n+additionalProperties: false\n+\n+examples:\n+ - |\n+ #include \u003cdt-bindings/clock/rk3568-cru.h\u003e\n+ #include \u003cdt-bindings/power/rk3568-power.h\u003e\n+ #include \u003cdt-bindings/phy/phy.h\u003e\n+\n+ ethernet-pcs@fda00000 {\n+ compatible = \"rockchip,rk3568-xpcs\";\n+ reg = \u003c0xfda00000 0x200000\u003e;\n+ clocks = \u003c\u0026cru PCLK_XPCS\u003e, \u003c\u0026cru CLK_XPCS_EEE\u003e;\n+ clock-names = \"csr\", \"eee\";\n+ phys = \u003c\u0026combphy2 PHY_TYPE_SGMII\u003e;\n+ power-domains = \u003c\u0026power RK3568_PD_PIPE\u003e;\n+ };\ndiff --git a/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml b/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml\nindex 80c252845349c..c434450fd07ff 100644\n--- a/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml\n+++ b/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml\n@@ -120,6 +120,12 @@ properties:\n maximum: 0x7F\n default: 0x10\n \n+ pcs-handle:\n+ description:\n+ Specifies a reference to a node representing the PCS device\n+ connected to this GMAC. Required when phy-mode is \"sgmii\".\n+ maxItems: 1\n+\n phy-supply:\n description: PHY regulator\n \n@@ -159,6 +165,27 @@ allOf:\n clocks:\n minItems: 5\n \n+ - if:\n+ properties:\n+ compatible:\n+ contains:\n+ const: rockchip,rk3568-gmac\n+ then:\n+ required:\n+ - phy-mode\n+\n+ - if:\n+ properties:\n+ compatible:\n+ contains:\n+ const: rockchip,rk3568-gmac\n+ phy-mode:\n+ contains:\n+ const: sgmii\n+ then:\n+ required:\n+ - pcs-handle\n+\n unevaluatedProperties: false\n \n examples:\ndiff --git a/MAINTAINERS b/MAINTAINERS\nindex 65e8a4b5c90b1..2f0f46eabcf54 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -23757,6 +23757,15 @@ S:\tMaintained\n F:\tDocumentation/devicetree/bindings/sound/rockchip,rk3576-sai.yaml\n F:\tsound/soc/rockchip/rockchip_sai.*\n \n+ROCKCHIP XPCS DRIVER\n+M:\tCoia Prant \u003ccoiaprant@gmail.com\u003e\n+L:\tnetdev@vger.kernel.org\n+L:\tlinux-rockchip@lists.infradead.org\n+S:\tMaintained\n+F:\tDocumentation/devicetree/bindings/net/pcs/rockchip,rk3568-xpcs.yaml\n+F:\tdrivers/net/pcs/pcs-xpcs-rk.c\n+F:\tinclude/linux/pcs/pcs-xpcs-rk.h\n+\n ROCKER DRIVER\n M:\tJiri Pirko \u003cjiri@resnulli.us\u003e\n L:\tnetdev@vger.kernel.org\ndiff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig\nindex e3dd5adda5aca..5088acc06982e 100644\n--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig\n+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig\n@@ -170,6 +170,7 @@ config DWMAC_ROCKCHIP\n \tdefault ARCH_ROCKCHIP\n \tdepends on OF \u0026\u0026 (ARCH_ROCKCHIP || COMPILE_TEST)\n \tselect MFD_SYSCON\n+\tselect PCS_XPCS_ROCKCHIP\n \thelp\n \t Support for Ethernet controller on Rockchip RK3288 SoC.\n \ndiff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c\nindex 72bdbcb5e863a..c4db919ec1640 100644\n--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c\n+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c\n@@ -20,6 +20,7 @@\n #include \u003clinux/delay.h\u003e\n #include \u003clinux/mfd/syscon.h\u003e\n #include \u003clinux/regmap.h\u003e\n+#include \u003clinux/pcs/pcs-xpcs-rk.h\u003e\n #include \u003clinux/pm_runtime.h\u003e\n \n #include \"stmmac_platform.h\"\n@@ -47,6 +48,7 @@ struct rk_gmac_ops {\n \tvoid (*set_to_rgmii)(struct rk_priv_data *bsp_priv,\n \t\t\t int tx_delay, int rx_delay);\n \tvoid (*set_to_rmii)(struct rk_priv_data *bsp_priv);\n+\tvoid (*set_to_sgmii)(struct rk_priv_data *bsp_priv);\n \tint (*set_speed)(struct rk_priv_data *bsp_priv,\n \t\t\t phy_interface_t interface, int speed);\n \tvoid (*integrated_phy_powerup)(struct rk_priv_data *bsp_priv);\n@@ -63,6 +65,7 @@ struct rk_gmac_ops {\n \tbool clock_grf_reg_in_php;\n \tbool supports_rgmii;\n \tbool supports_rmii;\n+\tbool supports_sgmii;\n \tbool php_grf_required;\n \tbool regs_valid;\n \tu32 regs[];\n@@ -98,6 +101,7 @@ struct rk_priv_data {\n \tbool integrated_phy;\n \tbool supports_rgmii;\n \tbool supports_rmii;\n+\tbool supports_sgmii;\n \n \tstruct clk_bulk_data *clks;\n \tint num_clks;\n@@ -809,6 +813,8 @@ static const struct rk_gmac_ops rk3528_ops = {\n #define RK3568_GRF_GMAC1_CON1\t\t0x038c\n \n /* RK3568_GRF_GMAC0_CON1 \u0026\u0026 RK3568_GRF_GMAC1_CON1 */\n+#define RK3568_GMAC_MODE_RMII_RGMII\t\tGRF_CLR_BIT(7)\n+#define RK3568_GMAC_MODE_SGMII_QSGMII\t\tGRF_BIT(7)\n #define RK3568_GMAC_FLOW_CTRL\t\t\tGRF_BIT(3)\n #define RK3568_GMAC_FLOW_CTRL_CLR\t\tGRF_CLR_BIT(3)\n #define RK3568_GMAC_RXCLK_DLY_ENABLE\t\tGRF_BIT(1)\n@@ -836,6 +842,16 @@ static int rk3568_init(struct rk_priv_data *bsp_priv)\n \t}\n }\n \n+static void rk3568_set_to_rmii(struct rk_priv_data *bsp_priv)\n+{\n+\tu32 con1;\n+\n+\tcon1 = (bsp_priv-\u003eid == 1) ? RK3568_GRF_GMAC1_CON1 :\n+\t\t\t\t RK3568_GRF_GMAC0_CON1;\n+\n+\tregmap_write(bsp_priv-\u003egrf, con1, RK3568_GMAC_MODE_RMII_RGMII);\n+}\n+\n static void rk3568_set_to_rgmii(struct rk_priv_data *bsp_priv,\n \t\t\t\tint tx_delay, int rx_delay)\n {\n@@ -851,19 +867,31 @@ static void rk3568_set_to_rgmii(struct rk_priv_data *bsp_priv,\n \t\t RK3568_GMAC_CLK_TX_DL_CFG(tx_delay));\n \n \tregmap_write(bsp_priv-\u003egrf, con1,\n+\t\t RK3568_GMAC_MODE_RMII_RGMII |\n \t\t RK3568_GMAC_RXCLK_DLY_ENABLE |\n \t\t RK3568_GMAC_TXCLK_DLY_ENABLE);\n }\n \n+static void rk3568_set_to_sgmii(struct rk_priv_data *bsp_priv)\n+{\n+\tu32 con1;\n+\n+\tcon1 = (bsp_priv-\u003eid == 1) ? RK3568_GRF_GMAC1_CON1 :\n+\t\t\t\t RK3568_GRF_GMAC0_CON1;\n+\n+\tregmap_write(bsp_priv-\u003egrf, con1, RK3568_GMAC_MODE_SGMII_QSGMII);\n+}\n+\n static const struct rk_gmac_ops rk3568_ops = {\n \t.init = rk3568_init,\n+\t.set_to_rmii = rk3568_set_to_rmii,\n \t.set_to_rgmii = rk3568_set_to_rgmii,\n+\t.set_to_sgmii = rk3568_set_to_sgmii,\n+\n \t.set_speed = rk_set_clk_mac_speed,\n \n \t.gmac_phy_intf_sel_mask = GENMASK_U16(6, 4),\n \n-\t.supports_rmii = true,\n-\n \t.regs_valid = true,\n \t.regs = {\n \t\t0xfe2a0000, /* gmac0 */\n@@ -1211,6 +1239,44 @@ static void rk_phy_powerdown(struct rk_priv_data *bsp_priv)\n \t\tdev_err(bsp_priv-\u003edev, \"fail to disable phy-supply\\n\");\n }\n \n+static int rk_pcs_init(struct stmmac_priv *priv)\n+{\n+\tstruct rk_priv_data *bsp_priv = priv-\u003eplat-\u003ebsp_priv;\n+\tstruct device_node *node = priv-\u003edevice-\u003eof_node;\n+\tstruct device_node *pcs_node;\n+\tstruct dw_xpcs *xpcs;\n+\n+\tpcs_node = of_parse_phandle(node, \"pcs-handle\", 0);\n+\tif (!pcs_node)\n+\t\treturn -ENODEV;\n+\n+\txpcs = xpcs_rk_create(priv-\u003edevice, pcs_node, bsp_priv-\u003eid);\n+\tof_node_put(pcs_node);\n+\tif (IS_ERR(xpcs))\n+\t\treturn PTR_ERR(xpcs);\n+\n+\tpriv-\u003ehw-\u003expcs = xpcs;\n+\treturn 0;\n+}\n+\n+static void rk_pcs_exit(struct stmmac_priv *priv)\n+{\n+\tif (!priv-\u003ehw-\u003expcs)\n+\t\treturn;\n+\n+\txpcs_destroy(priv-\u003ehw-\u003expcs);\n+\tpriv-\u003ehw-\u003expcs = NULL;\n+}\n+\n+static struct phylink_pcs *rk_select_pcs(struct stmmac_priv *priv,\n+\t\t\t\t\t phy_interface_t interface)\n+{\n+\tif (!priv-\u003ehw-\u003expcs)\n+\t\treturn NULL;\n+\n+\treturn xpcs_to_phylink_pcs(priv-\u003ehw-\u003expcs);\n+}\n+\n static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,\n \t\t\t\t\t struct plat_stmmacenet_data *plat,\n \t\t\t\t\t const struct rk_gmac_ops *ops)\n@@ -1333,6 +1399,7 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,\n \n \tbsp_priv-\u003esupports_rgmii = ops-\u003esupports_rgmii || !!ops-\u003eset_to_rgmii;\n \tbsp_priv-\u003esupports_rmii = ops-\u003esupports_rmii || !!ops-\u003eset_to_rmii;\n+\tbsp_priv-\u003esupports_sgmii = ops-\u003esupports_sgmii || !!ops-\u003eset_to_sgmii;\n \n \tif (ops-\u003einit) {\n \t\tret = ops-\u003einit(bsp_priv);\n@@ -1364,6 +1431,10 @@ static int rk_gmac_check_ops(struct rk_priv_data *bsp_priv)\n \t\tif (!bsp_priv-\u003esupports_rmii)\n \t\t\treturn -EINVAL;\n \t\tbreak;\n+\tcase PHY_INTERFACE_MODE_SGMII:\n+\t\tif (!bsp_priv-\u003esupports_sgmii)\n+\t\t\treturn -EINVAL;\n+\t\tbreak;\n \tdefault:\n \t\tdev_err(bsp_priv-\u003edev,\n \t\t\t\"unsupported interface %d\", bsp_priv-\u003ephy_iface);\n@@ -1382,16 +1453,19 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)\n \tif (ret)\n \t\treturn ret;\n \n+\tret = gmac_clk_enable(bsp_priv, true);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (bsp_priv-\u003ephy_iface == PHY_INTERFACE_MODE_SGMII)\n+\t\tgoto set_mode;\n+\n \tret = rk_get_phy_intf_sel(bsp_priv-\u003ephy_iface);\n \tif (ret \u003c 0)\n-\t\treturn ret;\n+\t\tgoto clk_disable;\n \n \tintf = ret;\n \n-\tret = gmac_clk_enable(bsp_priv, true);\n-\tif (ret)\n-\t\treturn ret;\n-\n \tif (bsp_priv-\u003egmac_phy_intf_sel_mask ||\n \t bsp_priv-\u003egmac_rmii_mode_mask) {\n \t\t/* If defined, encode the phy_intf_sel value */\n@@ -1402,10 +1476,8 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)\n \t\t\t\t bsp_priv-\u003egmac_rmii_mode_mask);\n \n \t\tret = rk_write_gmac_grf_reg(bsp_priv, val);\n-\t\tif (ret \u003c 0) {\n-\t\t\tgmac_clk_enable(bsp_priv, false);\n-\t\t\treturn ret;\n-\t\t}\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto clk_disable;\n \t}\n \n \tif (bsp_priv-\u003eclock.rmii_mode_mask) {\n@@ -1413,13 +1485,12 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)\n \t\t\t\t bsp_priv-\u003eclock.rmii_mode_mask);\n \n \t\tret = rk_write_clock_grf_reg(bsp_priv, val);\n-\t\tif (ret \u003c 0) {\n-\t\t\tgmac_clk_enable(bsp_priv, false);\n-\t\t\treturn ret;\n-\t\t}\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto clk_disable;\n \t}\n \n-\t/*rmii or rgmii*/\n+set_mode:\n+\t/* rmii, rgmii, sgmii */\n \tswitch (bsp_priv-\u003ephy_iface) {\n \tcase PHY_INTERFACE_MODE_RGMII:\n \t\tdev_info(dev, \"init for RGMII\\n\");\n@@ -1450,15 +1521,20 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)\n \t\tif (bsp_priv-\u003eops-\u003eset_to_rmii)\n \t\t\tbsp_priv-\u003eops-\u003eset_to_rmii(bsp_priv);\n \t\tbreak;\n+\tcase PHY_INTERFACE_MODE_SGMII:\n+\t\tdev_info(dev, \"init for SGMII\\n\");\n+\t\tif (bsp_priv-\u003eops-\u003eset_to_sgmii)\n+\t\t\tbsp_priv-\u003eops-\u003eset_to_sgmii(bsp_priv);\n+\t\tbreak;\n \tdefault:\n \t\tdev_err(dev, \"NO interface defined!\\n\");\n+\t\tret = -EINVAL;\n+\t\tgoto clk_disable;\n \t}\n \n \tret = rk_phy_powerup(bsp_priv);\n-\tif (ret) {\n-\t\tgmac_clk_enable(bsp_priv, false);\n-\t\treturn ret;\n-\t}\n+\tif (ret)\n+\t\tgoto clk_disable;\n \n \tpm_runtime_get_sync(dev);\n \n@@ -1466,6 +1542,10 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)\n \t\tbsp_priv-\u003eops-\u003eintegrated_phy_powerup(bsp_priv);\n \n \treturn 0;\n+\n+clk_disable:\n+\tgmac_clk_enable(bsp_priv, false);\n+\treturn ret;\n }\n \n static void rk_gmac_powerdown(struct rk_priv_data *gmac)\n@@ -1605,6 +1685,17 @@ static int rk_gmac_probe(struct platform_device *pdev)\n \tplat_dat-\u003esuspend = rk_gmac_suspend;\n \tplat_dat-\u003eresume = rk_gmac_resume;\n \n+\tif (plat_dat-\u003ephy_interface == PHY_INTERFACE_MODE_SGMII) {\n+\t\t/* SGMII clock always runs at 125 MHz */\n+\t\tplat_dat-\u003eset_clk_tx_rate = NULL;\n+\n+\t\t/* SGMII requires a PCS */\n+\t\tplat_dat-\u003edefault_an_inband = true;\n+\t\tplat_dat-\u003epcs_init = rk_pcs_init;\n+\t\tplat_dat-\u003epcs_exit = rk_pcs_exit;\n+\t\tplat_dat-\u003eselect_pcs = rk_select_pcs;\n+\t}\n+\n \tplat_dat-\u003ebsp_priv = rk_gmac_setup(pdev, plat_dat, data);\n \tif (IS_ERR(plat_dat-\u003ebsp_priv))\n \t\treturn PTR_ERR(plat_dat-\u003ebsp_priv);\ndiff --git a/drivers/net/pcs/Kconfig b/drivers/net/pcs/Kconfig\nindex e417fd66f660a..5382afcf95748 100644\n--- a/drivers/net/pcs/Kconfig\n+++ b/drivers/net/pcs/Kconfig\n@@ -12,6 +12,31 @@ config PCS_XPCS\n \t This module provides a driver and helper functions for Synopsys\n \t DesignWare XPCS controllers.\n \n+if PCS_XPCS\n+\n+config PCS_XPCS_PLATFORM\n+\ttristate \"Generic XPCS controller support\"\n+\tdefault PCS_XPCS\n+\thelp\n+\t Generic DWXPCS driver for platforms that don't require any\n+\t platform specific code to function or is using platform\n+\t data for setup.\n+\n+\t If you have a controller with this interface, say Y or M here.\n+\n+config PCS_XPCS_ROCKCHIP\n+\ttristate \"Rockchip XPCS controller support\"\n+\tdefault ARCH_ROCKCHIP\n+\tdepends on OF \u0026\u0026 (ARCH_ROCKCHIP || COMPILE_TEST)\n+\tselect GENERIC_PHY\n+\tselect PM_GENERIC_DOMAINS if PM\n+\thelp\n+\t Support for XPCS controller on Rockchip RK356x SoC.\n+\n+\t If you have a Rockchip SoC with this interface, say Y or M here.\n+\n+endif # PCS_XPCS\n+\n config PCS_LYNX\n \ttristate\n \thelp\ndiff --git a/drivers/net/pcs/Makefile b/drivers/net/pcs/Makefile\nindex 4f7920618b900..f9f6cf2578d72 100644\n--- a/drivers/net/pcs/Makefile\n+++ b/drivers/net/pcs/Makefile\n@@ -1,10 +1,11 @@\n # SPDX-License-Identifier: GPL-2.0\n # Makefile for Linux PCS drivers\n \n-pcs_xpcs-$(CONFIG_PCS_XPCS)\t:= pcs-xpcs.o pcs-xpcs-plat.o \\\n-\t\t\t\t pcs-xpcs-nxp.o pcs-xpcs-wx.o\n+pcs_xpcs-$(CONFIG_PCS_XPCS)\t:= pcs-xpcs.o pcs-xpcs-nxp.o pcs-xpcs-wx.o\n \n obj-$(CONFIG_PCS_XPCS)\t\t+= pcs_xpcs.o\n+obj-$(CONFIG_PCS_XPCS_PLATFORM) += pcs-xpcs-plat.o\n+obj-$(CONFIG_PCS_XPCS_ROCKCHIP) += pcs-xpcs-rk.o\n obj-$(CONFIG_PCS_LYNX)\t\t+= pcs-lynx.o\n obj-$(CONFIG_PCS_MTK_LYNXI)\t+= pcs-mtk-lynxi.o\n obj-$(CONFIG_PCS_RZN1_MIIC)\t+= pcs-rzn1-miic.o\ndiff --git a/drivers/net/pcs/pcs-xpcs-rk.c b/drivers/net/pcs/pcs-xpcs-rk.c\nnew file mode 100644\nindex 0000000000000..698a43b753341\n--- /dev/null\n+++ b/drivers/net/pcs/pcs-xpcs-rk.c\n@@ -0,0 +1,598 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/*\n+ * Rockchip XPCS platform device driver\n+ *\n+ * Based on the Synopsys DesignWare XPCS platform driver.\n+ * Copyright (C) 2024 Serge Semin\n+ *\n+ * Adapted for Rockchip SoCs, with reference to the Rockchip OEM driver.\n+ * Copyright (C) 2026 Coia Prant\n+ */\n+\n+#include \u003clinux/atomic.h\u003e\n+#include \u003clinux/bitfield.h\u003e\n+#include \u003clinux/clk.h\u003e\n+#include \u003clinux/device.h\u003e\n+#include \u003clinux/io.h\u003e\n+#include \u003clinux/iopoll.h\u003e\n+#include \u003clinux/math.h\u003e\n+#include \u003clinux/mdio.h\u003e\n+#include \u003clinux/module.h\u003e\n+#include \u003clinux/of.h\u003e\n+#include \u003clinux/of_platform.h\u003e\n+#include \u003clinux/pcs/pcs-xpcs-rk.h\u003e\n+#include \u003clinux/phy.h\u003e\n+#include \u003clinux/phy/phy.h\u003e\n+#include \u003clinux/platform_device.h\u003e\n+#include \u003clinux/pm_domain.h\u003e\n+#include \u003clinux/pm_runtime.h\u003e\n+#include \u003clinux/property.h\u003e\n+#include \u003clinux/sizes.h\u003e\n+#include \u003clinux/time.h\u003e\n+\n+#include \"pcs-xpcs.h\"\n+\n+struct dw_xpcs_rk {\n+\tstruct platform_device *pdev;\n+\tstruct mii_bus *bus;\n+\tvoid __iomem *reg_base;\n+\tstruct phy *serdes_phy;\n+\tstruct clk *csr_clk;\n+\tstruct clk *eee_clk;\n+\tu8 eee_mult_fact;\n+};\n+\n+static ptrdiff_t xpcs_rk_addr_format(int dev, int reg)\n+{\n+\treturn FIELD_PREP(0x70000, dev) | FIELD_PREP(0xffff, reg);\n+}\n+\n+static int xpcs_rk_read_reg(struct dw_xpcs_rk *pxpcs, int dev, int reg)\n+{\n+\tptrdiff_t csr;\n+\tint ret;\n+\n+\tcsr = xpcs_rk_addr_format(dev, reg);\n+\n+\tret = pm_runtime_resume_and_get(\u0026pxpcs-\u003epdev-\u003edev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = readl(pxpcs-\u003ereg_base + (csr \u003c\u003c 2)) \u0026 0xffff;\n+\n+\tpm_runtime_put(\u0026pxpcs-\u003epdev-\u003edev);\n+\treturn ret;\n+}\n+\n+static int xpcs_rk_write_reg(struct dw_xpcs_rk *pxpcs, int dev, int reg, u16 val)\n+{\n+\tptrdiff_t csr;\n+\tint ret;\n+\n+\tcsr = xpcs_rk_addr_format(dev, reg);\n+\n+\tret = pm_runtime_resume_and_get(\u0026pxpcs-\u003epdev-\u003edev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\twritel(val, pxpcs-\u003ereg_base + (csr \u003c\u003c 2));\n+\n+\tpm_runtime_put(\u0026pxpcs-\u003epdev-\u003edev);\n+\treturn 0;\n+}\n+\n+#define ROCKCHIP_MMD_MII1\t2\n+#define ROCKCHIP_MMD_MII2\t3\n+#define ROCKCHIP_MMD_MII3\t4\n+#define ROCKCHIP_MMD_PMAPMD\t6\n+#define ROCKCHIP_MMD_MII\t7\n+\n+static bool xpcs_rk_mdio_addr_validate(int addr)\n+{\n+\treturn !(addr \u003c 0 || addr \u003e 3);\n+}\n+\n+static int xpcs_rk_mdio_read_remapping(int addr, int dev)\n+{\n+\tswitch (dev) {\n+\tcase MDIO_MMD_PMAPMD:\n+\t\treturn ROCKCHIP_MMD_PMAPMD;\n+\tcase MDIO_MMD_VEND2:\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -ENXIO;\n+\t}\n+\n+\t/*\n+\t * Reads are redirected by hardware to the port's read-only mirror;\n+\t * only writes have to be targeted at MII (see the write path).\n+\t */\n+\tswitch (addr) {\n+\tcase 0:\n+\t\treturn ROCKCHIP_MMD_MII;\n+\tcase 1:\n+\t\treturn ROCKCHIP_MMD_MII1;\n+\tcase 2:\n+\t\treturn ROCKCHIP_MMD_MII2;\n+\tcase 3:\n+\t\treturn ROCKCHIP_MMD_MII3;\n+\tdefault:\n+\t\treturn -ENODEV;\n+\t}\n+}\n+\n+static int xpcs_rk_mdio_write_remapping(int addr, int dev, int reg)\n+{\n+\tswitch (dev) {\n+\tcase MDIO_MMD_PMAPMD:\n+\t\treturn ROCKCHIP_MMD_PMAPMD;\n+\tcase MDIO_MMD_VEND2:\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -ENXIO;\n+\t}\n+\n+\t/*\n+\t * These registers physically live only in MII (the management port).\n+\t * Ports 1-3 expose read-only mirrors of these bits, so writes must\n+\t * always target MII; the read path remaps per address and the\n+\t * hardware redirects to the port's mirror.\n+\t */\n+\tswitch (reg) {\n+\tcase DW_VR_MII_AN_CTRL:\n+\tcase DW_VR_MII_AN_INTR_STS:\n+\tcase DW_VR_MII_EEE_MCTRL0:\n+\tcase DW_VR_MII_EEE_MCTRL1:\n+\tcase DW_VR_MII_DIG_CTRL2:\n+\t\treturn ROCKCHIP_MMD_MII;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\n+\tswitch (addr) {\n+\tcase 0:\n+\t\treturn ROCKCHIP_MMD_MII;\n+\tcase 1:\n+\t\treturn ROCKCHIP_MMD_MII1;\n+\tcase 2:\n+\t\treturn ROCKCHIP_MMD_MII2;\n+\tcase 3:\n+\t\treturn ROCKCHIP_MMD_MII3;\n+\tdefault:\n+\t\treturn -ENODEV;\n+\t}\n+}\n+\n+static int xpcs_rk_read_c22(struct mii_bus *bus, int addr, int reg)\n+{\n+\tstruct dw_xpcs_rk *pxpcs = bus-\u003epriv;\n+\tint dev;\n+\n+\tif (!xpcs_rk_mdio_addr_validate(addr))\n+\t\treturn -ENODEV;\n+\n+\tdev = xpcs_rk_mdio_read_remapping(addr, MDIO_MMD_VEND2);\n+\tif (dev \u003c 0)\n+\t\treturn 0xffff;\n+\n+\treturn xpcs_rk_read_reg(pxpcs, dev, reg);\n+}\n+\n+static int xpcs_rk_write_c22(struct mii_bus *bus, int addr, int reg, u16 val)\n+{\n+\tstruct dw_xpcs_rk *pxpcs = bus-\u003epriv;\n+\tint dev;\n+\n+\tif (!xpcs_rk_mdio_addr_validate(addr))\n+\t\treturn -ENODEV;\n+\n+\tdev = xpcs_rk_mdio_write_remapping(addr, MDIO_MMD_VEND2, reg);\n+\tif (dev \u003c 0)\n+\t\treturn 0;\n+\n+\treturn xpcs_rk_write_reg(pxpcs, dev, reg, val);\n+}\n+\n+static int xpcs_rk_read_c45(struct mii_bus *bus, int addr, int dev, int reg)\n+{\n+\tstruct dw_xpcs_rk *pxpcs = bus-\u003epriv;\n+\n+\tif (!xpcs_rk_mdio_addr_validate(addr))\n+\t\treturn -ENODEV;\n+\n+\tdev = xpcs_rk_mdio_read_remapping(addr, dev);\n+\tif (dev \u003c 0)\n+\t\treturn 0xffff;\n+\n+\treturn xpcs_rk_read_reg(pxpcs, dev, reg);\n+}\n+\n+static int xpcs_rk_write_c45(struct mii_bus *bus, int addr, int dev, int reg, u16 val)\n+{\n+\tstruct dw_xpcs_rk *pxpcs = bus-\u003epriv;\n+\n+\tif (!xpcs_rk_mdio_addr_validate(addr))\n+\t\treturn -ENODEV;\n+\n+\tdev = xpcs_rk_mdio_write_remapping(addr, dev, reg);\n+\tif (dev \u003c 0)\n+\t\treturn 0;\n+\n+\treturn xpcs_rk_write_reg(pxpcs, dev, reg, val);\n+}\n+\n+static struct dw_xpcs_rk *xpcs_rk_create_data(struct platform_device *pdev)\n+{\n+\tstruct dw_xpcs_rk *pxpcs;\n+\n+\tpxpcs = devm_kzalloc(\u0026pdev-\u003edev, sizeof(*pxpcs), GFP_KERNEL);\n+\tif (!pxpcs)\n+\t\treturn ERR_PTR(-ENOMEM);\n+\n+\tpxpcs-\u003epdev = pdev;\n+\n+\tdev_set_drvdata(\u0026pdev-\u003edev, pxpcs);\n+\n+\treturn pxpcs;\n+}\n+\n+static int xpcs_rk_serdes_phy_init(struct dw_xpcs_rk *pxpcs)\n+{\n+\tstruct device *dev = \u0026pxpcs-\u003epdev-\u003edev;\n+\n+\tpxpcs-\u003eserdes_phy = devm_phy_get(dev, NULL);\n+\tif (IS_ERR(pxpcs-\u003eserdes_phy))\n+\t\treturn dev_err_probe(dev, PTR_ERR(pxpcs-\u003eserdes_phy),\n+\t\t\t\t\t\"Failed to get SerDes PHY\\n\");\n+\n+\treturn 0;\n+}\n+\n+static void xpcs_rk_serdes_phy_poweroff(void *data)\n+{\n+\tstruct dw_xpcs_rk *pxpcs = data;\n+\tstruct device *dev = \u0026pxpcs-\u003epdev-\u003edev;\n+\n+\tphy_power_off(pxpcs-\u003eserdes_phy);\n+\tphy_exit(pxpcs-\u003eserdes_phy);\n+\n+\tdev_pm_genpd_rpm_always_on(dev, false);\n+}\n+\n+static int xpcs_rk_serdes_phy_poweron(struct dw_xpcs_rk *pxpcs)\n+{\n+\tstruct device *dev = \u0026pxpcs-\u003epdev-\u003edev;\n+\tint ret;\n+\n+\t/*\n+\t * The power domain is required and must be enabled, which allows us to\n+\t * dynamically turn the CSR clock on/off using PM while keeping the PCS\n+\t * powered on.\n+\t */\n+\tret = dev_pm_genpd_rpm_always_on(dev, true);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to power on power-domains\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tret = phy_init(pxpcs-\u003eserdes_phy);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to init SerDes PHY\\n\");\n+\t\tgoto pm_domain;\n+\t}\n+\n+\tret = phy_power_on(pxpcs-\u003eserdes_phy);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to power on SerDes PHY\\n\");\n+\t\tgoto serdes_phy;\n+\t}\n+\n+\tret = devm_add_action_or_reset(dev, xpcs_rk_serdes_phy_poweroff, pxpcs);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to register devm for SerDes PHY: %d\\n\", ret);\n+\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+\n+serdes_phy:\n+\tphy_exit(pxpcs-\u003eserdes_phy);\n+pm_domain:\n+\tdev_pm_genpd_rpm_always_on(dev, false);\n+\treturn ret;\n+}\n+\n+static int xpcs_rk_init_res(struct dw_xpcs_rk *pxpcs)\n+{\n+\tstruct platform_device *pdev = pxpcs-\u003epdev;\n+\tstruct device *dev = \u0026pdev-\u003edev;\n+\tstruct resource *res;\n+\n+\tres = platform_get_resource(pdev, IORESOURCE_MEM, 0);\n+\tif (!res) {\n+\t\tdev_err(dev, \"No reg-space found\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (resource_size(res) \u003c SZ_2M) {\n+\t\tdev_err(dev, \"Invalid reg-space size\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tpxpcs-\u003ereg_base = devm_ioremap_resource(dev, res);\n+\tif (IS_ERR(pxpcs-\u003ereg_base)) {\n+\t\tdev_err(dev, \"Failed to map reg-space\\n\");\n+\t\treturn PTR_ERR(pxpcs-\u003ereg_base);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void xpcs_rk_exit_clk(void *data)\n+{\n+\tstruct dw_xpcs_rk *pxpcs = data;\n+\tstruct device *dev = \u0026pxpcs-\u003epdev-\u003edev;\n+\n+\tpm_runtime_force_suspend(dev);\n+\tclk_disable_unprepare(pxpcs-\u003eeee_clk);\n+}\n+\n+static int xpcs_rk_init_clk(struct dw_xpcs_rk *pxpcs)\n+{\n+\tstruct device *dev = \u0026pxpcs-\u003epdev-\u003edev;\n+\tunsigned long rate;\n+\tu64 mult;\n+\tint ret;\n+\n+\tpxpcs-\u003ecsr_clk = devm_clk_get(dev, \"csr\");\n+\tif (IS_ERR(pxpcs-\u003ecsr_clk))\n+\t\treturn dev_err_probe(dev, PTR_ERR(pxpcs-\u003ecsr_clk),\n+\t\t\t\t\t \"Failed to get CSR clock\\n\");\n+\n+\tpxpcs-\u003eeee_clk = devm_clk_get(dev, \"eee\");\n+\tif (IS_ERR(pxpcs-\u003eeee_clk))\n+\t\treturn dev_err_probe(dev, PTR_ERR(pxpcs-\u003eeee_clk),\n+\t\t\t\t\t \"Failed to get EEE clock\\n\");\n+\n+\tret = clk_prepare_enable(pxpcs-\u003eeee_clk);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to enable EEE clock\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tpm_runtime_set_suspended(dev);\n+\tpm_runtime_enable(dev);\n+\n+\tret = devm_add_action_or_reset(dev, xpcs_rk_exit_clk, pxpcs);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to register devm for EEE clock: %d\\n\", ret);\n+\t\treturn ret;\n+\t}\n+\n+\t/*\n+\t * Compute the multiplier for the EEE clock so that\n+\t * clk_eee_period * (mult_fact + 1) falls within 80..120 ns.\n+\t *\n+\t * On RK3568, clk_xpcs_eee is muxed between gpll200 (200 MHz, 5 ns)\n+\t * and cpll125 (125 MHz, 8 ns), selected by CRU_CLKSEL_CON29 bit 13.\n+\t * The reset value is 0 (200 MHz), but derive the value at runtime to\n+\t * stay correct if the mux is changed by a board.\n+\t *\n+\t * Use a 64-bit intermediate: on 32-bit builds, 100 * 200000000\n+\t * does not fit in unsigned long. Clamp to the 4-bit\n+\t * DW_VR_MII_EEE_MULT_FACT_100NS field. The mux only provides\n+\t * 125 MHz or 200 MHz, so the rate cannot drop below the 5 MHz\n+\t * threshold where DIV_ROUND_CLOSEST_ULL() would return 0 and the\n+\t * subtraction below would underflow.\n+\t */\n+\trate = clk_get_rate(pxpcs-\u003eeee_clk);\n+\tif (!rate)\n+\t\treturn dev_err_probe(dev, -EINVAL, \"Invalid EEE clock rate\\n\");\n+\n+\tmult = DIV_ROUND_CLOSEST_ULL(100ULL * rate, NSEC_PER_SEC) - 1;\n+\tpxpcs-\u003eeee_mult_fact = min_t(u64, mult, 15);\n+\treturn 0;\n+}\n+\n+static int xpcs_rk_init_bus(struct dw_xpcs_rk *pxpcs)\n+{\n+\tstruct device *dev = \u0026pxpcs-\u003epdev-\u003edev;\n+\tstatic atomic_t id = ATOMIC_INIT(-1);\n+\tstruct mii_bus *bus;\n+\tint ret;\n+\n+\tbus = devm_mdiobus_alloc_size(dev, 0);\n+\tif (!bus)\n+\t\treturn -ENOMEM;\n+\n+\tbus-\u003ename = \"Rockchip DW XPCS MCI/APB3\";\n+\tbus-\u003eread = xpcs_rk_read_c22;\n+\tbus-\u003ewrite = xpcs_rk_write_c22;\n+\tbus-\u003eread_c45 = xpcs_rk_read_c45;\n+\tbus-\u003ewrite_c45 = xpcs_rk_write_c45;\n+\tbus-\u003ephy_mask = ~0;\n+\tbus-\u003eparent = dev;\n+\tbus-\u003epriv = pxpcs;\n+\n+\tsnprintf(bus-\u003eid, MII_BUS_ID_SIZE,\n+\t\t \"rockchip_dwxpcs-%x\", atomic_inc_return(\u0026id));\n+\n+\t/*\n+\t * MDIO-bus here serves as just a back-end engine abstracting out\n+\t * the MDIO and MCI/APB3 IO interfaces utilized for the Rockchip DWXPCS CSRs\n+\t * access.\n+\t */\n+\tret = devm_mdiobus_register(dev, bus);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to create MDIO bus\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tpxpcs-\u003ebus = bus;\n+\treturn 0;\n+}\n+\n+static int xpcs_rk_probe(struct platform_device *pdev)\n+{\n+\tstruct dw_xpcs_rk *pxpcs;\n+\tint ret;\n+\n+\tpxpcs = xpcs_rk_create_data(pdev);\n+\tif (IS_ERR(pxpcs))\n+\t\treturn PTR_ERR(pxpcs);\n+\n+\t/*\n+\t * The XPCS lives in the PD_PIPE power domain. The domain must be\n+\t * powered on before any register access, otherwise the SoC will\n+\t * trigger a synchronous external abort (SError).\n+\t *\n+\t * Accessing the XPCS registers also requires a TX clock from the\n+\t * SerDes, which is needed for the soft reset.\n+\t */\n+\tret = xpcs_rk_serdes_phy_init(pxpcs);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = xpcs_rk_serdes_phy_poweron(pxpcs);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = xpcs_rk_init_res(pxpcs);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = xpcs_rk_init_clk(pxpcs);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = xpcs_rk_init_bus(pxpcs);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n+static const struct of_device_id xpcs_rk_of_ids[] = {\n+\t{ .compatible = \"rockchip,rk3568-xpcs\" },\n+\t{ /* sentinel */ },\n+};\n+MODULE_DEVICE_TABLE(of, xpcs_rk_of_ids);\n+\n+struct dw_xpcs *xpcs_rk_create(struct device *dev, struct device_node *pcs, int port)\n+{\n+\tstruct platform_device *pdev;\n+\tstruct dw_xpcs_rk *pxpcs;\n+\tstruct dw_xpcs *xpcs;\n+\n+\tif (!of_device_is_available(pcs))\n+\t\treturn ERR_PTR(-ENODEV);\n+\n+\tif (!of_match_node(xpcs_rk_of_ids, pcs))\n+\t\treturn ERR_PTR(-EINVAL);\n+\n+\tif (!xpcs_rk_mdio_addr_validate(port))\n+\t\treturn ERR_PTR(-EINVAL);\n+\n+\tpdev = of_find_device_by_node(pcs);\n+\tif (!pdev)\n+\t\treturn ERR_PTR(-EPROBE_DEFER);\n+\n+\t/*\n+\t * Establish the device link before reading the supplier's drvdata.\n+\t * device_link_add() does not fail on a supplier that is unbinding;\n+\t * it creates the link in DL_STATE_SUPPLIER_UNBIND.\n+\t *\n+\t * The check below only confirms that the supplier is bound at this\n+\t * point. It does not fully protect against a concurrent unbind\n+\t * between here and xpcs_create_mdiodev(); closing that window would\n+\t * require reading a managed link's status or device_lock(), neither\n+\t * of which is acceptable on this path. The window is small and\n+\t * requires an explicit unbind from userspace. Discussed on\n+\t * driver-core.\n+\t *\n+\t * The link is released automatically when the consumer device is\n+\t * destroyed (DL_FLAG_AUTOREMOVE_CONSUMER), so no explicit\n+\t * device_link_remove() is needed on the failure paths.\n+\t */\n+\tif (!device_link_add(dev, \u0026pdev-\u003edev, DL_FLAG_AUTOREMOVE_CONSUMER)) {\n+\t\tput_device(\u0026pdev-\u003edev);\n+\t\treturn ERR_PTR(-EPROBE_DEFER);\n+\t}\n+\n+\tif (READ_ONCE(pdev-\u003edev.links.status) != DL_DEV_DRIVER_BOUND) {\n+\t\tput_device(\u0026pdev-\u003edev);\n+\t\treturn ERR_PTR(-EPROBE_DEFER);\n+\t}\n+\n+\tpxpcs = platform_get_drvdata(pdev);\n+\tif (!pxpcs || !pxpcs-\u003ebus) {\n+\t\tput_device(\u0026pdev-\u003edev);\n+\t\treturn ERR_PTR(-EPROBE_DEFER);\n+\t}\n+\n+\txpcs = xpcs_create_mdiodev(pxpcs-\u003ebus, port);\n+\tif (IS_ERR(xpcs)) {\n+\t\tput_device(\u0026pdev-\u003edev);\n+\t\treturn xpcs;\n+\t}\n+\n+\txpcs_config_eee_mult_fact(xpcs, pxpcs-\u003eeee_mult_fact);\n+\tput_device(\u0026pdev-\u003edev);\n+\treturn xpcs;\n+}\n+EXPORT_SYMBOL_GPL(xpcs_rk_create);\n+\n+static int xpcs_rk_pm_runtime_suspend(struct device *dev)\n+{\n+\tstruct dw_xpcs_rk *pxpcs = dev_get_drvdata(dev);\n+\n+\tclk_disable_unprepare(pxpcs-\u003ecsr_clk);\n+\n+\treturn 0;\n+}\n+\n+static int xpcs_rk_pm_runtime_resume(struct device *dev)\n+{\n+\tstruct dw_xpcs_rk *pxpcs = dev_get_drvdata(dev);\n+\n+\treturn clk_prepare_enable(pxpcs-\u003ecsr_clk);\n+}\n+\n+static int xpcs_rk_system_suspend(struct device *dev)\n+{\n+\t/*\n+\t * Keep the PD_PIPE power domain on during system suspend.\n+\t *\n+\t * PD_PIPE is shared with SATA/PCIe and would be powered down by\n+\t * genpd once all its consumers are suspended, killing the SerDes\n+\t * and breaking MAC WoL. Mark the XPCS as part of the wakeup path\n+\t * so genpd keeps the domain on. Unconditional because the XPCS\n+\t * core has no callback to convey the MAC WoL state.\n+\t */\n+\tdevice_set_wakeup_path(dev);\n+\treturn 0;\n+}\n+\n+static int xpcs_rk_system_resume(struct device *dev)\n+{\n+\treturn 0;\n+}\n+\n+static _DEFINE_DEV_PM_OPS(xpcs_rk_pm_ops,\n+\t\t\t xpcs_rk_system_suspend, xpcs_rk_system_resume,\n+\t\t\t xpcs_rk_pm_runtime_suspend, xpcs_rk_pm_runtime_resume,\n+\t\t\t NULL);\n+\n+static struct platform_driver xpcs_rk_driver = {\n+\t.probe = xpcs_rk_probe,\n+\t.driver = {\n+\t\t.name = \"rk_xpcs-dwxpcs\",\n+\t\t.pm = pm_ptr(\u0026xpcs_rk_pm_ops),\n+\t\t.of_match_table = xpcs_rk_of_ids,\n+\t},\n+};\n+module_platform_driver(xpcs_rk_driver);\n+\n+MODULE_DESCRIPTION(\"Rockchip XPCS platform device driver\");\n+MODULE_AUTHOR(\"Coia Prant \u003ccoiaprant@gmail.com\u003e\");\n+MODULE_LICENSE(\"GPL\");\ndiff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c\nindex b415b93d77c15..6466e0ff2a98b 100644\n--- a/drivers/net/pcs/pcs-xpcs.c\n+++ b/drivers/net/pcs/pcs-xpcs.c\n@@ -761,7 +761,9 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs,\n \t * DW xPCS used with DW EQoS MAC is always MAC side SGMII.\n \t * 4) VR_MII_DIG_CTRL1 Bit(9) [MAC_AUTO_SW] = 1b (Automatic\n \t * speed/duplex mode change by HW after SGMII AN complete)\n-\t * 5) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 1b (Enable SGMII AN)\n+\t * 5) VR_MII_AN_INTR_STS = 0x0 (Clear CL37 AN complete status)\n+\t * 6) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 1b (Enable SGMII AN)\n+\t * VR_MII_MMD_CTRL Bit(9) [AN_RESTART] = 1b (Restart SGMII AN)\n \t *\n \t * Note that VR_MII_MMD_CTRL is MII_BMCR.\n \t *\n@@ -769,7 +771,14 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs,\n \t *\t SR_MII_AN_ADV. MAC side SGMII receives AN Tx Config from\n \t *\t PHY about the link state change after C28 AN is completed\n \t *\t between PHY and Link Partner. There is also no need to\n-\t *\t trigger AN restart for MAC-side SGMII.\n+\t *\t trigger AN restart for MAC-side SGMII on most devices.\n+\t *\n+\t * Note: While the DesignWare databook states that AN restart is\n+\t *\t not needed for MAC side SGMII, some implementations (e.g.\n+\t *\t Rockchip RK3568) exhibit a timing quirk when integrated with\n+\t *\t phylink and do not restart AN automatically when the link\n+\t *\t comes back up. An explicit AN restart is required on those\n+\t *\t parts to recover the link after a disconnect.\n \t */\n \tmdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMCR);\n \tif (mdio_ctrl \u003c 0)\n@@ -816,9 +825,14 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs,\n \tif (ret \u003c 0)\n \t\treturn ret;\n \n+\t/* Clear CL37 AN complete status */\n+\tret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n \tif (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED)\n \t\tret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR,\n-\t\t\t\t mdio_ctrl | BMCR_ANENABLE);\n+\t\t\t\t mdio_ctrl | BMCR_ANENABLE | BMCR_ANRESTART);\n \n \treturn ret;\n }\n@@ -1093,9 +1107,18 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs,\n \t\treturn 0;\n \t}\n \n-\t/* Clear AN complete status or interrupt */\n-\tif (state-\u003ean_complete)\n-\t\txpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0);\n+\tif (state-\u003ean_complete) {\n+\t\t/* Clear AN complete status or interrupt */\n+\t\tret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\n+\t\t/* Initiate the next round of AN */\n+\t\tret = xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, BMCR_ANRESTART,\n+\t\t\t\t BMCR_ANRESTART);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t}\n \n \treturn 0;\n }\ndiff --git a/include/linux/pcs/pcs-xpcs-rk.h b/include/linux/pcs/pcs-xpcs-rk.h\nnew file mode 100644\nindex 0000000000000..e3ca3d51f7c7e\n--- /dev/null\n+++ b/include/linux/pcs/pcs-xpcs-rk.h\n@@ -0,0 +1,11 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+#ifndef __LINUX_PCS_XPCS_ROCKCHIP_H\n+#define __LINUX_PCS_XPCS_ROCKCHIP_H\n+\n+#include \u003clinux/device.h\u003e\n+#include \u003clinux/of.h\u003e\n+#include \u003clinux/pcs/pcs-xpcs.h\u003e\n+\n+struct dw_xpcs *xpcs_rk_create(struct device *dev, struct device_node *pcs, int port);\n+\n+#endif /* __LINUX_PCS_XPCS_ROCKCHIP_H */\n"
} |
| 2/1 | 2026/10/08 23:48 | agent | patch-evaluator |
22mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch series introduces a Rockchip RK3568 Ethernet XPCS (Physical Coding Sublayer) platform driver and updates the Synopsys DW XPCS SGMII auto-negotiation logic for Rockchip integration. The modified code resides in Rockchip SoC-specific platform drivers and the Synopsys DW XPCS driver, which requires physical SoC/ASIC hardware (Rockchip, Wangxun, Intel MGBE, Meta fbnic, or DSA switches) not emulated in standard virtualized QEMU environments on amd64. Consequently, the modified code is structurally unreachable.",
"WorthFuzzing": false
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit a938dab07a487e21fa7cd36f388875908179ea5b
Author: syz-cluster <triage@syzkaller.com>
Date: Thu Oct 8 23:48:46 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/devicetree/bindings/net/pcs/rockchip,rk3568-xpcs.yaml b/Documentation/devicetree/bindings/net/pcs/rockchip,rk3568-xpcs.yaml
new file mode 100644
index 0000000000000..a331880eb11c1
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/pcs/rockchip,rk3568-xpcs.yaml
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/pcs/rockchip,rk3568-xpcs.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Rockchip RK3568 Synopsys DesignWare Ethernet PCS
+
+maintainers:
+ - Coia Prant <coiaprant@gmail.com>
+
+description: |
+ Rockchip RK3568 SoC integrates a Synopsys DesignWare Ethernet Physical
+ Coding Sublayer (XPCS).
+ The PCS provides an interface between the Media Access Control (MAC)
+ and the Physical Medium Attachment (PMA) sublayer through a Media
+ Independent Interface (GMII).
+
+ The XPCS is accessed over the APB3 bus and internally connected to a
+ Naneng Combo SerDes PHY.
+ It supports 1000BASE-X, SGMII and QSGMII modes.
+
+properties:
+ compatible:
+ const: rockchip,rk3568-xpcs
+
+ reg:
+ maxItems: 1
+
+ clocks:
+ items:
+ - description: APB3 bus interface clock (clk_csr_i), required for register access
+ - description: EEE clock (clk_eee_i), required for Energy Efficient Ethernet operation
+
+ clock-names:
+ items:
+ - const: csr
+ - const: eee
+
+ phys:
+ maxItems: 1
+
+ power-domains:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - phys
+ - power-domains
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/rk3568-cru.h>
+ #include <dt-bindings/power/rk3568-power.h>
+ #include <dt-bindings/phy/phy.h>
+
+ ethernet-pcs@fda00000 {
+ compatible = "rockchip,rk3568-xpcs";
+ reg = <0xfda00000 0x200000>;
+ clocks = <&cru PCLK_XPCS>, <&cru CLK_XPCS_EEE>;
+ clock-names = "csr", "eee";
+ phys = <&combphy2 PHY_TYPE_SGMII>;
+ power-domains = <&power RK3568_PD_PIPE>;
+ };
diff --git a/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml b/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml
index 80c252845349c..c434450fd07ff 100644
--- a/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml
@@ -120,6 +120,12 @@ properties:
maximum: 0x7F
default: 0x10
+ pcs-handle:
+ description:
+ Specifies a reference to a node representing the PCS device
+ connected to this GMAC. Required when phy-mode is "sgmii".
+ maxItems: 1
+
phy-supply:
description: PHY regulator
@@ -159,6 +165,27 @@ allOf:
clocks:
minItems: 5
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: rockchip,rk3568-gmac
+ then:
+ required:
+ - phy-mode
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: rockchip,rk3568-gmac
+ phy-mode:
+ contains:
+ const: sgmii
+ then:
+ required:
+ - pcs-handle
+
unevaluatedProperties: false
examples:
diff --git a/MAINTAINERS b/MAINTAINERS
index 65e8a4b5c90b1..2f0f46eabcf54 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -23757,6 +23757,15 @@ S: Maintained
F: Documentation/devicetree/bindings/sound/rockchip,rk3576-sai.yaml
F: sound/soc/rockchip/rockchip_sai.*
+ROCKCHIP XPCS DRIVER
+M: Coia Prant <coiaprant@gmail.com>
+L: netdev@vger.kernel.org
+L: linux-rockchip@lists.infradead.org
+S: Maintained
+F: Documentation/devicetree/bindings/net/pcs/rockchip,rk3568-xpcs.yaml
+F: drivers/net/pcs/pcs-xpcs-rk.c
+F: include/linux/pcs/pcs-xpcs-rk.h
+
ROCKER DRIVER
M: Jiri Pirko <jiri@resnulli.us>
L: netdev@vger.kernel.org
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index e3dd5adda5aca..5088acc06982e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -170,6 +170,7 @@ config DWMAC_ROCKCHIP
default ARCH_ROCKCHIP
depends on OF && (ARCH_ROCKCHIP || COMPILE_TEST)
select MFD_SYSCON
+ select PCS_XPCS_ROCKCHIP
help
Support for Ethernet controller on Rockchip RK3288 SoC.
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 72bdbcb5e863a..c4db919ec1640 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -20,6 +20,7 @@
#include <linux/delay.h>
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
+#include <linux/pcs/pcs-xpcs-rk.h>
#include <linux/pm_runtime.h>
#include "stmmac_platform.h"
@@ -47,6 +48,7 @@ struct rk_gmac_ops {
void (*set_to_rgmii)(struct rk_priv_data *bsp_priv,
int tx_delay, int rx_delay);
void (*set_to_rmii)(struct rk_priv_data *bsp_priv);
+ void (*set_to_sgmii)(struct rk_priv_data *bsp_priv);
int (*set_speed)(struct rk_priv_data *bsp_priv,
phy_interface_t interface, int speed);
void (*integrated_phy_powerup)(struct rk_priv_data *bsp_priv);
@@ -63,6 +65,7 @@ struct rk_gmac_ops {
bool clock_grf_reg_in_php;
bool supports_rgmii;
bool supports_rmii;
+ bool supports_sgmii;
bool php_grf_required;
bool regs_valid;
u32 regs[];
@@ -98,6 +101,7 @@ struct rk_priv_data {
bool integrated_phy;
bool supports_rgmii;
bool supports_rmii;
+ bool supports_sgmii;
struct clk_bulk_data *clks;
int num_clks;
@@ -809,6 +813,8 @@ static const struct rk_gmac_ops rk3528_ops = {
#define RK3568_GRF_GMAC1_CON1 0x038c
/* RK3568_GRF_GMAC0_CON1 && RK3568_GRF_GMAC1_CON1 */
+#define RK3568_GMAC_MODE_RMII_RGMII GRF_CLR_BIT(7)
+#define RK3568_GMAC_MODE_SGMII_QSGMII GRF_BIT(7)
#define RK3568_GMAC_FLOW_CTRL GRF_BIT(3)
#define RK3568_GMAC_FLOW_CTRL_CLR GRF_CLR_BIT(3)
#define RK3568_GMAC_RXCLK_DLY_ENABLE GRF_BIT(1)
@@ -836,6 +842,16 @@ static int rk3568_init(struct rk_priv_data *bsp_priv)
}
}
+static void rk3568_set_to_rmii(struct rk_priv_data *bsp_priv)
+{
+ u32 con1;
+
+ con1 = (bsp_priv->id == 1) ? RK3568_GRF_GMAC1_CON1 :
+ RK3568_GRF_GMAC0_CON1;
+
+ regmap_write(bsp_priv->grf, con1, RK3568_GMAC_MODE_RMII_RGMII);
+}
+
static void rk3568_set_to_rgmii(struct rk_priv_data *bsp_priv,
int tx_delay, int rx_delay)
{
@@ -851,19 +867,31 @@ static void rk3568_set_to_rgmii(struct rk_priv_data *bsp_priv,
RK3568_GMAC_CLK_TX_DL_CFG(tx_delay));
regmap_write(bsp_priv->grf, con1,
+ RK3568_GMAC_MODE_RMII_RGMII |
RK3568_GMAC_RXCLK_DLY_ENABLE |
RK3568_GMAC_TXCLK_DLY_ENABLE);
}
+static void rk3568_set_to_sgmii(struct rk_priv_data *bsp_priv)
+{
+ u32 con1;
+
+ con1 = (bsp_priv->id == 1) ? RK3568_GRF_GMAC1_CON1 :
+ RK3568_GRF_GMAC0_CON1;
+
+ regmap_write(bsp_priv->grf, con1, RK3568_GMAC_MODE_SGMII_QSGMII);
+}
+
static const struct rk_gmac_ops rk3568_ops = {
.init = rk3568_init,
+ .set_to_rmii = rk3568_set_to_rmii,
.set_to_rgmii = rk3568_set_to_rgmii,
+ .set_to_sgmii = rk3568_set_to_sgmii,
+
.set_speed = rk_set_clk_mac_speed,
.gmac_phy_intf_sel_mask = GENMASK_U16(6, 4),
- .supports_rmii = true,
-
.regs_valid = true,
.regs = {
0xfe2a0000, /* gmac0 */
@@ -1211,6 +1239,44 @@ static void rk_phy_powerdown(struct rk_priv_data *bsp_priv)
dev_err(bsp_priv->dev, "fail to disable phy-supply\n");
}
+static int rk_pcs_init(struct stmmac_priv *priv)
+{
+ struct rk_priv_data *bsp_priv = priv->plat->bsp_priv;
+ struct device_node *node = priv->device->of_node;
+ struct device_node *pcs_node;
+ struct dw_xpcs *xpcs;
+
+ pcs_node = of_parse_phandle(node, "pcs-handle", 0);
+ if (!pcs_node)
+ return -ENODEV;
+
+ xpcs = xpcs_rk_create(priv->device, pcs_node, bsp_priv->id);
+ of_node_put(pcs_node);
+ if (IS_ERR(xpcs))
+ return PTR_ERR(xpcs);
+
+ priv->hw->xpcs = xpcs;
+ return 0;
+}
+
+static void rk_pcs_exit(struct stmmac_priv *priv)
+{
+ if (!priv->hw->xpcs)
+ return;
+
+ xpcs_destroy(priv->hw->xpcs);
+ priv->hw->xpcs = NULL;
+}
+
+static struct phylink_pcs *rk_select_pcs(struct stmmac_priv *priv,
+ phy_interface_t interface)
+{
+ if (!priv->hw->xpcs)
+ return NULL;
+
+ return xpcs_to_phylink_pcs(priv->hw->xpcs);
+}
+
static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
struct plat_stmmacenet_data *plat,
const struct rk_gmac_ops *ops)
@@ -1333,6 +1399,7 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
bsp_priv->supports_rgmii = ops->supports_rgmii || !!ops->set_to_rgmii;
bsp_priv->supports_rmii = ops->supports_rmii || !!ops->set_to_rmii;
+ bsp_priv->supports_sgmii = ops->supports_sgmii || !!ops->set_to_sgmii;
if (ops->init) {
ret = ops->init(bsp_priv);
@@ -1364,6 +1431,10 @@ static int rk_gmac_check_ops(struct rk_priv_data *bsp_priv)
if (!bsp_priv->supports_rmii)
return -EINVAL;
break;
+ case PHY_INTERFACE_MODE_SGMII:
+ if (!bsp_priv->supports_sgmii)
+ return -EINVAL;
+ break;
default:
dev_err(bsp_priv->dev,
"unsupported interface %d", bsp_priv->phy_iface);
@@ -1382,16 +1453,19 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
if (ret)
return ret;
+ ret = gmac_clk_enable(bsp_priv, true);
+ if (ret)
+ return ret;
+
+ if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_SGMII)
+ goto set_mode;
+
ret = rk_get_phy_intf_sel(bsp_priv->phy_iface);
if (ret < 0)
- return ret;
+ goto clk_disable;
intf = ret;
- ret = gmac_clk_enable(bsp_priv, true);
- if (ret)
- return ret;
-
if (bsp_priv->gmac_phy_intf_sel_mask ||
bsp_priv->gmac_rmii_mode_mask) {
/* If defined, encode the phy_intf_sel value */
@@ -1402,10 +1476,8 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
bsp_priv->gmac_rmii_mode_mask);
ret = rk_write_gmac_grf_reg(bsp_priv, val);
- if (ret < 0) {
- gmac_clk_enable(bsp_priv, false);
- return ret;
- }
+ if (ret < 0)
+ goto clk_disable;
}
if (bsp_priv->clock.rmii_mode_mask) {
@@ -1413,13 +1485,12 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
bsp_priv->clock.rmii_mode_mask);
ret = rk_write_clock_grf_reg(bsp_priv, val);
- if (ret < 0) {
- gmac_clk_enable(bsp_priv, false);
- return ret;
- }
+ if (ret < 0)
+ goto clk_disable;
}
- /*rmii or rgmii*/
+set_mode:
+ /* rmii, rgmii, sgmii */
switch (bsp_priv->phy_iface) {
case PHY_INTERFACE_MODE_RGMII:
dev_info(dev, "init for RGMII\n");
@@ -1450,15 +1521,20 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
if (bsp_priv->ops->set_to_rmii)
bsp_priv->ops->set_to_rmii(bsp_priv);
break;
+ case PHY_INTERFACE_MODE_SGMII:
+ dev_info(dev, "init for SGMII\n");
+ if (bsp_priv->ops->set_to_sgmii)
+ bsp_priv->ops->set_to_sgmii(bsp_priv);
+ break;
default:
dev_err(dev, "NO interface defined!\n");
+ ret = -EINVAL;
+ goto clk_disable;
}
ret = rk_phy_powerup(bsp_priv);
- if (ret) {
- gmac_clk_enable(bsp_priv, false);
- return ret;
- }
+ if (ret)
+ goto clk_disable;
pm_runtime_get_sync(dev);
@@ -1466,6 +1542,10 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
bsp_priv->ops->integrated_phy_powerup(bsp_priv);
return 0;
+
+clk_disable:
+ gmac_clk_enable(bsp_priv, false);
+ return ret;
}
static void rk_gmac_powerdown(struct rk_priv_data *gmac)
@@ -1605,6 +1685,17 @@ static int rk_gmac_probe(struct platform_device *pdev)
plat_dat->suspend = rk_gmac_suspend;
plat_dat->resume = rk_gmac_resume;
+ if (plat_dat->phy_interface == PHY_INTERFACE_MODE_SGMII) {
+ /* SGMII clock always runs at 125 MHz */
+ plat_dat->set_clk_tx_rate = NULL;
+
+ /* SGMII requires a PCS */
+ plat_dat->default_an_inband = true;
+ plat_dat->pcs_init = rk_pcs_init;
+ plat_dat->pcs_exit = rk_pcs_exit;
+ plat_dat->select_pcs = rk_select_pcs;
+ }
+
plat_dat->bsp_priv = rk_gmac_setup(pdev, plat_dat, data);
if (IS_ERR(plat_dat->bsp_priv))
return PTR_ERR(plat_dat->bsp_priv);
diff --git a/drivers/net/pcs/Kconfig b/drivers/net/pcs/Kconfig
index e417fd66f660a..5382afcf95748 100644
--- a/drivers/net/pcs/Kconfig
+++ b/drivers/net/pcs/Kconfig
@@ -12,6 +12,31 @@ config PCS_XPCS
This module provides a driver and helper functions for Synopsys
DesignWare XPCS controllers.
+if PCS_XPCS
+
+config PCS_XPCS_PLATFORM
+ tristate "Generic XPCS controller support"
+ default PCS_XPCS
+ help
+ Generic DWXPCS driver for platforms that don't require any
+ platform specific code to function or is using platform
+ data for setup.
+
+ If you have a controller with this interface, say Y or M here.
+
+config PCS_XPCS_ROCKCHIP
+ tristate "Rockchip XPCS controller support"
+ default ARCH_ROCKCHIP
+ depends on OF && (ARCH_ROCKCHIP || COMPILE_TEST)
+ select GENERIC_PHY
+ select PM_GENERIC_DOMAINS if PM
+ help
+ Support for XPCS controller on Rockchip RK356x SoC.
+
+ If you have a Rockchip SoC with this interface, say Y or M here.
+
+endif # PCS_XPCS
+
config PCS_LYNX
tristate
help
diff --git a/drivers/net/pcs/Makefile b/drivers/net/pcs/Makefile
index 4f7920618b900..f9f6cf2578d72 100644
--- a/drivers/net/pcs/Makefile
+++ b/drivers/net/pcs/Makefile
@@ -1,10 +1,11 @@
# SPDX-License-Identifier: GPL-2.0
# Makefile for Linux PCS drivers
-pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-plat.o \
- pcs-xpcs-nxp.o pcs-xpcs-wx.o
+pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-nxp.o pcs-xpcs-wx.o
obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o
+obj-$(CONFIG_PCS_XPCS_PLATFORM) += pcs-xpcs-plat.o
+obj-$(CONFIG_PCS_XPCS_ROCKCHIP) += pcs-xpcs-rk.o
obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o
obj-$(CONFIG_PCS_MTK_LYNXI) += pcs-mtk-lynxi.o
obj-$(CONFIG_PCS_RZN1_MIIC) += pcs-rzn1-miic.o
diff --git a/drivers/net/pcs/pcs-xpcs-rk.c b/drivers/net/pcs/pcs-xpcs-rk.c
new file mode 100644
index 0000000000000..698a43b753341
--- /dev/null
+++ b/drivers/net/pcs/pcs-xpcs-rk.c
@@ -0,0 +1,598 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Rockchip XPCS platform device driver
+ *
+ * Based on the Synopsys DesignWare XPCS platform driver.
+ * Copyright (C) 2024 Serge Semin
+ *
+ * Adapted for Rockchip SoCs, with reference to the Rockchip OEM driver.
+ * Copyright (C) 2026 Coia Prant
+ */
+
+#include <linux/atomic.h>
+#include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/math.h>
+#include <linux/mdio.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/pcs/pcs-xpcs-rk.h>
+#include <linux/phy.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+#include <linux/pm_domain.h>
+#include <linux/pm_runtime.h>
+#include <linux/property.h>
+#include <linux/sizes.h>
+#include <linux/time.h>
+
+#include "pcs-xpcs.h"
+
+struct dw_xpcs_rk {
+ struct platform_device *pdev;
+ struct mii_bus *bus;
+ void __iomem *reg_base;
+ struct phy *serdes_phy;
+ struct clk *csr_clk;
+ struct clk *eee_clk;
+ u8 eee_mult_fact;
+};
+
+static ptrdiff_t xpcs_rk_addr_format(int dev, int reg)
+{
+ return FIELD_PREP(0x70000, dev) | FIELD_PREP(0xffff, reg);
+}
+
+static int xpcs_rk_read_reg(struct dw_xpcs_rk *pxpcs, int dev, int reg)
+{
+ ptrdiff_t csr;
+ int ret;
+
+ csr = xpcs_rk_addr_format(dev, reg);
+
+ ret = pm_runtime_resume_and_get(&pxpcs->pdev->dev);
+ if (ret)
+ return ret;
+
+ ret = readl(pxpcs->reg_base + (csr << 2)) & 0xffff;
+
+ pm_runtime_put(&pxpcs->pdev->dev);
+ return ret;
+}
+
+static int xpcs_rk_write_reg(struct dw_xpcs_rk *pxpcs, int dev, int reg, u16 val)
+{
+ ptrdiff_t csr;
+ int ret;
+
+ csr = xpcs_rk_addr_format(dev, reg);
+
+ ret = pm_runtime_resume_and_get(&pxpcs->pdev->dev);
+ if (ret)
+ return ret;
+
+ writel(val, pxpcs->reg_base + (csr << 2));
+
+ pm_runtime_put(&pxpcs->pdev->dev);
+ return 0;
+}
+
+#define ROCKCHIP_MMD_MII1 2
+#define ROCKCHIP_MMD_MII2 3
+#define ROCKCHIP_MMD_MII3 4
+#define ROCKCHIP_MMD_PMAPMD 6
+#define ROCKCHIP_MMD_MII 7
+
+static bool xpcs_rk_mdio_addr_validate(int addr)
+{
+ return !(addr < 0 || addr > 3);
+}
+
+static int xpcs_rk_mdio_read_remapping(int addr, int dev)
+{
+ switch (dev) {
+ case MDIO_MMD_PMAPMD:
+ return ROCKCHIP_MMD_PMAPMD;
+ case MDIO_MMD_VEND2:
+ break;
+ default:
+ return -ENXIO;
+ }
+
+ /*
+ * Reads are redirected by hardware to the port's read-only mirror;
+ * only writes have to be targeted at MII (see the write path).
+ */
+ switch (addr) {
+ case 0:
+ return ROCKCHIP_MMD_MII;
+ case 1:
+ return ROCKCHIP_MMD_MII1;
+ case 2:
+ return ROCKCHIP_MMD_MII2;
+ case 3:
+ return ROCKCHIP_MMD_MII3;
+ default:
+ return -ENODEV;
+ }
+}
+
+static int xpcs_rk_mdio_write_remapping(int addr, int dev, int reg)
+{
+ switch (dev) {
+ case MDIO_MMD_PMAPMD:
+ return ROCKCHIP_MMD_PMAPMD;
+ case MDIO_MMD_VEND2:
+ break;
+ default:
+ return -ENXIO;
+ }
+
+ /*
+ * These registers physically live only in MII (the management port).
+ * Ports 1-3 expose read-only mirrors of these bits, so writes must
+ * always target MII; the read path remaps per address and the
+ * hardware redirects to the port's mirror.
+ */
+ switch (reg) {
+ case DW_VR_MII_AN_CTRL:
+ case DW_VR_MII_AN_INTR_STS:
+ case DW_VR_MII_EEE_MCTRL0:
+ case DW_VR_MII_EEE_MCTRL1:
+ case DW_VR_MII_DIG_CTRL2:
+ return ROCKCHIP_MMD_MII;
+ default:
+ break;
+ }
+
+ switch (addr) {
+ case 0:
+ return ROCKCHIP_MMD_MII;
+ case 1:
+ return ROCKCHIP_MMD_MII1;
+ case 2:
+ return ROCKCHIP_MMD_MII2;
+ case 3:
+ return ROCKCHIP_MMD_MII3;
+ default:
+ return -ENODEV;
+ }
+}
+
+static int xpcs_rk_read_c22(struct mii_bus *bus, int addr, int reg)
+{
+ struct dw_xpcs_rk *pxpcs = bus->priv;
+ int dev;
+
+ if (!xpcs_rk_mdio_addr_validate(addr))
+ return -ENODEV;
+
+ dev = xpcs_rk_mdio_read_remapping(addr, MDIO_MMD_VEND2);
+ if (dev < 0)
+ return 0xffff;
+
+ return xpcs_rk_read_reg(pxpcs, dev, reg);
+}
+
+static int xpcs_rk_write_c22(struct mii_bus *bus, int addr, int reg, u16 val)
+{
+ struct dw_xpcs_rk *pxpcs = bus->priv;
+ int dev;
+
+ if (!xpcs_rk_mdio_addr_validate(addr))
+ return -ENODEV;
+
+ dev = xpcs_rk_mdio_write_remapping(addr, MDIO_MMD_VEND2, reg);
+ if (dev < 0)
+ return 0;
+
+ return xpcs_rk_write_reg(pxpcs, dev, reg, val);
+}
+
+static int xpcs_rk_read_c45(struct mii_bus *bus, int addr, int dev, int reg)
+{
+ struct dw_xpcs_rk *pxpcs = bus->priv;
+
+ if (!xpcs_rk_mdio_addr_validate(addr))
+ return -ENODEV;
+
+ dev = xpcs_rk_mdio_read_remapping(addr, dev);
+ if (dev < 0)
+ return 0xffff;
+
+ return xpcs_rk_read_reg(pxpcs, dev, reg);
+}
+
+static int xpcs_rk_write_c45(struct mii_bus *bus, int addr, int dev, int reg, u16 val)
+{
+ struct dw_xpcs_rk *pxpcs = bus->priv;
+
+ if (!xpcs_rk_mdio_addr_validate(addr))
+ return -ENODEV;
+
+ dev = xpcs_rk_mdio_write_remapping(addr, dev, reg);
+ if (dev < 0)
+ return 0;
+
+ return xpcs_rk_write_reg(pxpcs, dev, reg, val);
+}
+
+static struct dw_xpcs_rk *xpcs_rk_create_data(struct platform_device *pdev)
+{
+ struct dw_xpcs_rk *pxpcs;
+
+ pxpcs = devm_kzalloc(&pdev->dev, sizeof(*pxpcs), GFP_KERNEL);
+ if (!pxpcs)
+ return ERR_PTR(-ENOMEM);
+
+ pxpcs->pdev = pdev;
+
+ dev_set_drvdata(&pdev->dev, pxpcs);
+
+ return pxpcs;
+}
+
+static int xpcs_rk_serdes_phy_init(struct dw_xpcs_rk *pxpcs)
+{
+ struct device *dev = &pxpcs->pdev->dev;
+
+ pxpcs->serdes_phy = devm_phy_get(dev, NULL);
+ if (IS_ERR(pxpcs->serdes_phy))
+ return dev_err_probe(dev, PTR_ERR(pxpcs->serdes_phy),
+ "Failed to get SerDes PHY\n");
+
+ return 0;
+}
+
+static void xpcs_rk_serdes_phy_poweroff(void *data)
+{
+ struct dw_xpcs_rk *pxpcs = data;
+ struct device *dev = &pxpcs->pdev->dev;
+
+ phy_power_off(pxpcs->serdes_phy);
+ phy_exit(pxpcs->serdes_phy);
+
+ dev_pm_genpd_rpm_always_on(dev, false);
+}
+
+static int xpcs_rk_serdes_phy_poweron(struct dw_xpcs_rk *pxpcs)
+{
+ struct device *dev = &pxpcs->pdev->dev;
+ int ret;
+
+ /*
+ * The power domain is required and must be enabled, which allows us to
+ * dynamically turn the CSR clock on/off using PM while keeping the PCS
+ * powered on.
+ */
+ ret = dev_pm_genpd_rpm_always_on(dev, true);
+ if (ret) {
+ dev_err(dev, "Failed to power on power-domains\n");
+ return ret;
+ }
+
+ ret = phy_init(pxpcs->serdes_phy);
+ if (ret) {
+ dev_err(dev, "Failed to init SerDes PHY\n");
+ goto pm_domain;
+ }
+
+ ret = phy_power_on(pxpcs->serdes_phy);
+ if (ret) {
+ dev_err(dev, "Failed to power on SerDes PHY\n");
+ goto serdes_phy;
+ }
+
+ ret = devm_add_action_or_reset(dev, xpcs_rk_serdes_phy_poweroff, pxpcs);
+ if (ret) {
+ dev_err(dev, "Failed to register devm for SerDes PHY: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+
+serdes_phy:
+ phy_exit(pxpcs->serdes_phy);
+pm_domain:
+ dev_pm_genpd_rpm_always_on(dev, false);
+ return ret;
+}
+
+static int xpcs_rk_init_res(struct dw_xpcs_rk *pxpcs)
+{
+ struct platform_device *pdev = pxpcs->pdev;
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(dev, "No reg-space found\n");
+ return -EINVAL;
+ }
+
+ if (resource_size(res) < SZ_2M) {
+ dev_err(dev, "Invalid reg-space size\n");
+ return -EINVAL;
+ }
+
+ pxpcs->reg_base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(pxpcs->reg_base)) {
+ dev_err(dev, "Failed to map reg-space\n");
+ return PTR_ERR(pxpcs->reg_base);
+ }
+
+ return 0;
+}
+
+static void xpcs_rk_exit_clk(void *data)
+{
+ struct dw_xpcs_rk *pxpcs = data;
+ struct device *dev = &pxpcs->pdev->dev;
+
+ pm_runtime_force_suspend(dev);
+ clk_disable_unprepare(pxpcs->eee_clk);
+}
+
+static int xpcs_rk_init_clk(struct dw_xpcs_rk *pxpcs)
+{
+ struct device *dev = &pxpcs->pdev->dev;
+ unsigned long rate;
+ u64 mult;
+ int ret;
+
+ pxpcs->csr_clk = devm_clk_get(dev, "csr");
+ if (IS_ERR(pxpcs->csr_clk))
+ return dev_err_probe(dev, PTR_ERR(pxpcs->csr_clk),
+ "Failed to get CSR clock\n");
+
+ pxpcs->eee_clk = devm_clk_get(dev, "eee");
+ if (IS_ERR(pxpcs->eee_clk))
+ return dev_err_probe(dev, PTR_ERR(pxpcs->eee_clk),
+ "Failed to get EEE clock\n");
+
+ ret = clk_prepare_enable(pxpcs->eee_clk);
+ if (ret) {
+ dev_err(dev, "Failed to enable EEE clock\n");
+ return ret;
+ }
+
+ pm_runtime_set_suspended(dev);
+ pm_runtime_enable(dev);
+
+ ret = devm_add_action_or_reset(dev, xpcs_rk_exit_clk, pxpcs);
+ if (ret) {
+ dev_err(dev, "Failed to register devm for EEE clock: %d\n", ret);
+ return ret;
+ }
+
+ /*
+ * Compute the multiplier for the EEE clock so that
+ * clk_eee_period * (mult_fact + 1) falls within 80..120 ns.
+ *
+ * On RK3568, clk_xpcs_eee is muxed between gpll200 (200 MHz, 5 ns)
+ * and cpll125 (125 MHz, 8 ns), selected by CRU_CLKSEL_CON29 bit 13.
+ * The reset value is 0 (200 MHz), but derive the value at runtime to
+ * stay correct if the mux is changed by a board.
+ *
+ * Use a 64-bit intermediate: on 32-bit builds, 100 * 200000000
+ * does not fit in unsigned long. Clamp to the 4-bit
+ * DW_VR_MII_EEE_MULT_FACT_100NS field. The mux only provides
+ * 125 MHz or 200 MHz, so the rate cannot drop below the 5 MHz
+ * threshold where DIV_ROUND_CLOSEST_ULL() would return 0 and the
+ * subtraction below would underflow.
+ */
+ rate = clk_get_rate(pxpcs->eee_clk);
+ if (!rate)
+ return dev_err_probe(dev, -EINVAL, "Invalid EEE clock rate\n");
+
+ mult = DIV_ROUND_CLOSEST_ULL(100ULL * rate, NSEC_PER_SEC) - 1;
+ pxpcs->eee_mult_fact = min_t(u64, mult, 15);
+ return 0;
+}
+
+static int xpcs_rk_init_bus(struct dw_xpcs_rk *pxpcs)
+{
+ struct device *dev = &pxpcs->pdev->dev;
+ static atomic_t id = ATOMIC_INIT(-1);
+ struct mii_bus *bus;
+ int ret;
+
+ bus = devm_mdiobus_alloc_size(dev, 0);
+ if (!bus)
+ return -ENOMEM;
+
+ bus->name = "Rockchip DW XPCS MCI/APB3";
+ bus->read = xpcs_rk_read_c22;
+ bus->write = xpcs_rk_write_c22;
+ bus->read_c45 = xpcs_rk_read_c45;
+ bus->write_c45 = xpcs_rk_write_c45;
+ bus->phy_mask = ~0;
+ bus->parent = dev;
+ bus->priv = pxpcs;
+
+ snprintf(bus->id, MII_BUS_ID_SIZE,
+ "rockchip_dwxpcs-%x", atomic_inc_return(&id));
+
+ /*
+ * MDIO-bus here serves as just a back-end engine abstracting out
+ * the MDIO and MCI/APB3 IO interfaces utilized for the Rockchip DWXPCS CSRs
+ * access.
+ */
+ ret = devm_mdiobus_register(dev, bus);
+ if (ret) {
+ dev_err(dev, "Failed to create MDIO bus\n");
+ return ret;
+ }
+
+ pxpcs->bus = bus;
+ return 0;
+}
+
+static int xpcs_rk_probe(struct platform_device *pdev)
+{
+ struct dw_xpcs_rk *pxpcs;
+ int ret;
+
+ pxpcs = xpcs_rk_create_data(pdev);
+ if (IS_ERR(pxpcs))
+ return PTR_ERR(pxpcs);
+
+ /*
+ * The XPCS lives in the PD_PIPE power domain. The domain must be
+ * powered on before any register access, otherwise the SoC will
+ * trigger a synchronous external abort (SError).
+ *
+ * Accessing the XPCS registers also requires a TX clock from the
+ * SerDes, which is needed for the soft reset.
+ */
+ ret = xpcs_rk_serdes_phy_init(pxpcs);
+ if (ret)
+ return ret;
+
+ ret = xpcs_rk_serdes_phy_poweron(pxpcs);
+ if (ret)
+ return ret;
+
+ ret = xpcs_rk_init_res(pxpcs);
+ if (ret)
+ return ret;
+
+ ret = xpcs_rk_init_clk(pxpcs);
+ if (ret)
+ return ret;
+
+ ret = xpcs_rk_init_bus(pxpcs);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static const struct of_device_id xpcs_rk_of_ids[] = {
+ { .compatible = "rockchip,rk3568-xpcs" },
+ { /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, xpcs_rk_of_ids);
+
+struct dw_xpcs *xpcs_rk_create(struct device *dev, struct device_node *pcs, int port)
+{
+ struct platform_device *pdev;
+ struct dw_xpcs_rk *pxpcs;
+ struct dw_xpcs *xpcs;
+
+ if (!of_device_is_available(pcs))
+ return ERR_PTR(-ENODEV);
+
+ if (!of_match_node(xpcs_rk_of_ids, pcs))
+ return ERR_PTR(-EINVAL);
+
+ if (!xpcs_rk_mdio_addr_validate(port))
+ return ERR_PTR(-EINVAL);
+
+ pdev = of_find_device_by_node(pcs);
+ if (!pdev)
+ return ERR_PTR(-EPROBE_DEFER);
+
+ /*
+ * Establish the device link before reading the supplier's drvdata.
+ * device_link_add() does not fail on a supplier that is unbinding;
+ * it creates the link in DL_STATE_SUPPLIER_UNBIND.
+ *
+ * The check below only confirms that the supplier is bound at this
+ * point. It does not fully protect against a concurrent unbind
+ * between here and xpcs_create_mdiodev(); closing that window would
+ * require reading a managed link's status or device_lock(), neither
+ * of which is acceptable on this path. The window is small and
+ * requires an explicit unbind from userspace. Discussed on
+ * driver-core.
+ *
+ * The link is released automatically when the consumer device is
+ * destroyed (DL_FLAG_AUTOREMOVE_CONSUMER), so no explicit
+ * device_link_remove() is needed on the failure paths.
+ */
+ if (!device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER)) {
+ put_device(&pdev->dev);
+ return ERR_PTR(-EPROBE_DEFER);
+ }
+
+ if (READ_ONCE(pdev->dev.links.status) != DL_DEV_DRIVER_BOUND) {
+ put_device(&pdev->dev);
+ return ERR_PTR(-EPROBE_DEFER);
+ }
+
+ pxpcs = platform_get_drvdata(pdev);
+ if (!pxpcs || !pxpcs->bus) {
+ put_device(&pdev->dev);
+ return ERR_PTR(-EPROBE_DEFER);
+ }
+
+ xpcs = xpcs_create_mdiodev(pxpcs->bus, port);
+ if (IS_ERR(xpcs)) {
+ put_device(&pdev->dev);
+ return xpcs;
+ }
+
+ xpcs_config_eee_mult_fact(xpcs, pxpcs->eee_mult_fact);
+ put_device(&pdev->dev);
+ return xpcs;
+}
+EXPORT_SYMBOL_GPL(xpcs_rk_create);
+
+static int xpcs_rk_pm_runtime_suspend(struct device *dev)
+{
+ struct dw_xpcs_rk *pxpcs = dev_get_drvdata(dev);
+
+ clk_disable_unprepare(pxpcs->csr_clk);
+
+ return 0;
+}
+
+static int xpcs_rk_pm_runtime_resume(struct device *dev)
+{
+ struct dw_xpcs_rk *pxpcs = dev_get_drvdata(dev);
+
+ return clk_prepare_enable(pxpcs->csr_clk);
+}
+
+static int xpcs_rk_system_suspend(struct device *dev)
+{
+ /*
+ * Keep the PD_PIPE power domain on during system suspend.
+ *
+ * PD_PIPE is shared with SATA/PCIe and would be powered down by
+ * genpd once all its consumers are suspended, killing the SerDes
+ * and breaking MAC WoL. Mark the XPCS as part of the wakeup path
+ * so genpd keeps the domain on. Unconditional because the XPCS
+ * core has no callback to convey the MAC WoL state.
+ */
+ device_set_wakeup_path(dev);
+ return 0;
+}
+
+static int xpcs_rk_system_resume(struct device *dev)
+{
+ return 0;
+}
+
+static _DEFINE_DEV_PM_OPS(xpcs_rk_pm_ops,
+ xpcs_rk_system_suspend, xpcs_rk_system_resume,
+ xpcs_rk_pm_runtime_suspend, xpcs_rk_pm_runtime_resume,
+ NULL);
+
+static struct platform_driver xpcs_rk_driver = {
+ .probe = xpcs_rk_probe,
+ .driver = {
+ .name = "rk_xpcs-dwxpcs",
+ .pm = pm_ptr(&xpcs_rk_pm_ops),
+ .of_match_table = xpcs_rk_of_ids,
+ },
+};
+module_platform_driver(xpcs_rk_driver);
+
+MODULE_DESCRIPTION("Rockchip XPCS platform device driver");
+MODULE_AUTHOR("Coia Prant <coiaprant@gmail.com>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index b415b93d77c15..6466e0ff2a98b 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -761,7 +761,9 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs,
* DW xPCS used with DW EQoS MAC is always MAC side SGMII.
* 4) VR_MII_DIG_CTRL1 Bit(9) [MAC_AUTO_SW] = 1b (Automatic
* speed/duplex mode change by HW after SGMII AN complete)
- * 5) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 1b (Enable SGMII AN)
+ * 5) VR_MII_AN_INTR_STS = 0x0 (Clear CL37 AN complete status)
+ * 6) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 1b (Enable SGMII AN)
+ * VR_MII_MMD_CTRL Bit(9) [AN_RESTART] = 1b (Restart SGMII AN)
*
* Note that VR_MII_MMD_CTRL is MII_BMCR.
*
@@ -769,7 +771,14 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs,
* SR_MII_AN_ADV. MAC side SGMII receives AN Tx Config from
* PHY about the link state change after C28 AN is completed
* between PHY and Link Partner. There is also no need to
- * trigger AN restart for MAC-side SGMII.
+ * trigger AN restart for MAC-side SGMII on most devices.
+ *
+ * Note: While the DesignWare databook states that AN restart is
+ * not needed for MAC side SGMII, some implementations (e.g.
+ * Rockchip RK3568) exhibit a timing quirk when integrated with
+ * phylink and do not restart AN automatically when the link
+ * comes back up. An explicit AN restart is required on those
+ * parts to recover the link after a disconnect.
*/
mdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMCR);
if (mdio_ctrl < 0)
@@ -816,9 +825,14 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs,
if (ret < 0)
return ret;
+ /* Clear CL37 AN complete status */
+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0);
+ if (ret < 0)
+ return ret;
+
if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED)
ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR,
- mdio_ctrl | BMCR_ANENABLE);
+ mdio_ctrl | BMCR_ANENABLE | BMCR_ANRESTART);
return ret;
}
@@ -1093,9 +1107,18 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs,
return 0;
}
- /* Clear AN complete status or interrupt */
- if (state->an_complete)
- xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0);
+ if (state->an_complete) {
+ /* Clear AN complete status or interrupt */
+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0);
+ if (ret < 0)
+ return ret;
+
+ /* Initiate the next round of AN */
+ ret = xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, BMCR_ANRESTART,
+ BMCR_ANRESTART);
+ if (ret < 0)
+ return ret;
+ }
return 0;
}
diff --git a/include/linux/pcs/pcs-xpcs-rk.h b/include/linux/pcs/pcs-xpcs-rk.h
new file mode 100644
index 0000000000000..e3ca3d51f7c7e
--- /dev/null
+++ b/include/linux/pcs/pcs-xpcs-rk.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_PCS_XPCS_ROCKCHIP_H
+#define __LINUX_PCS_XPCS_ROCKCHIP_H
+
+#include <linux/device.h>
+#include <linux/of.h>
+#include <linux/pcs/pcs-xpcs.h>
+
+struct dw_xpcs *xpcs_rk_create(struct device *dev, struct device_node *pcs, int port);
+
+#endif /* __LINUX_PCS_XPCS_ROCKCHIP_H */
|
| 3/2 | 2026/10/08 23:48 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17041 output: 18 thoughts: 383 Thoughts: **Fuzzing Feasibility Assessment** Okay, let's break down this patch series and determine if it's a good candidate for syzkaller fuzzing, keeping in mind my deep knowledge of the intricacies here. I see the target architecture is amd64, which is a good starting point. That's usually the easiest to get set up with. First, let's look at the changes. We have documentation updates, metadata, some Kconfig changes, a new Rockchip XPCS driver (`pcs-xpcs-rk.c`), modifications to the existing Synopsys XPCS driver (`pcs-xpcs.c`), and some supporting files. The Rockchip DWmac driver is modified as well. Looks like a lot of work in the networking stack. Wait a second...I see that `drivers/net/pcs/pcs-xpcs.c` was also modified. That's interesting, and potentially critical for fuzzing. We have to make sure that's even *reachable* on amd64 in QEMU. If it's not, we're wasting our time. I need to figure out who calls this, or how it's used. Let's do a quick check with `grepper` and see who uses `xpcs_` or `CONFIG_PCS_XPCS`. That will reveal if it can be reached on amd64. If `pcs-xpcs.c` is not reachable, fuzzing may not be worth it. |
| 4/2 | 2026/10/08 23:49 | tool | grepper |
0mArgs:{
"Expression": "PCS_XPCS"
}Results: {
"Output": "drivers/net/dsa/microchip/Kconfig=2=menuconfig NET_DSA_MICROCHIP_KSZ_COMMON\n--\ndrivers/net/dsa/microchip/Kconfig-8-\tselect DCB\ndrivers/net/dsa/microchip/Kconfig:9:\tselect PCS_XPCS\ndrivers/net/dsa/microchip/Kconfig-10-\thelp\n--\ndrivers/net/dsa/sja1105/Kconfig=3=tristate \"NXP SJA1105 Ethernet switch family support\"\n--\ndrivers/net/dsa/sja1105/Kconfig-6-\tselect NET_DSA_TAG_SJA1105\ndrivers/net/dsa/sja1105/Kconfig:7:\tselect PCS_XPCS\ndrivers/net/dsa/sja1105/Kconfig-8-\tselect PACKING\n--\ndrivers/net/ethernet/meta/Kconfig=20=config FBNIC\n--\ndrivers/net/ethernet/meta/Kconfig-28-\tselect PAGE_POOL\ndrivers/net/ethernet/meta/Kconfig:29:\tselect PCS_XPCS\ndrivers/net/ethernet/meta/Kconfig-30-\tselect PHYLINK\n--\ndrivers/net/ethernet/stmicro/stmmac/Kconfig=2=config STMMAC_ETH\n--\ndrivers/net/ethernet/stmicro/stmmac/Kconfig-7-\tselect MII\ndrivers/net/ethernet/stmicro/stmmac/Kconfig:8:\tselect PCS_XPCS\ndrivers/net/ethernet/stmicro/stmmac/Kconfig-9-\tselect PAGE_POOL\n--\ndrivers/net/ethernet/stmicro/stmmac/Kconfig=168=config DWMAC_ROCKCHIP\n--\ndrivers/net/ethernet/stmicro/stmmac/Kconfig-172-\tselect MFD_SYSCON\ndrivers/net/ethernet/stmicro/stmmac/Kconfig:173:\tselect PCS_XPCS_ROCKCHIP\ndrivers/net/ethernet/stmicro/stmmac/Kconfig-174-\thelp\n--\ndrivers/net/ethernet/wangxun/Kconfig=43=config TXGBE\n--\ndrivers/net/ethernet/wangxun/Kconfig-54-\tselect GPIOLIB_IRQCHIP\ndrivers/net/ethernet/wangxun/Kconfig:55:\tselect PCS_XPCS\ndrivers/net/ethernet/wangxun/Kconfig-56-\tselect LIBWX\n--\ndrivers/net/pcs/Kconfig=6=menu \"PCS device drivers\"\ndrivers/net/pcs/Kconfig-7-\ndrivers/net/pcs/Kconfig:8:config PCS_XPCS\ndrivers/net/pcs/Kconfig-9-\ttristate \"Synopsys DesignWare Ethernet XPCS\"\n--\ndrivers/net/pcs/Kconfig-14-\ndrivers/net/pcs/Kconfig:15:if PCS_XPCS\ndrivers/net/pcs/Kconfig-16-\ndrivers/net/pcs/Kconfig:17:config PCS_XPCS_PLATFORM\ndrivers/net/pcs/Kconfig-18-\ttristate \"Generic XPCS controller support\"\ndrivers/net/pcs/Kconfig:19:\tdefault PCS_XPCS\ndrivers/net/pcs/Kconfig-20-\thelp\n--\ndrivers/net/pcs/Kconfig-26-\ndrivers/net/pcs/Kconfig:27:config PCS_XPCS_ROCKCHIP\ndrivers/net/pcs/Kconfig-28-\ttristate \"Rockchip XPCS controller support\"\n--\ndrivers/net/pcs/Kconfig-37-\ndrivers/net/pcs/Kconfig:38:endif # PCS_XPCS\ndrivers/net/pcs/Kconfig-39-\n--\ndrivers/net/pcs/Makefile-3-\ndrivers/net/pcs/Makefile:4:pcs_xpcs-$(CONFIG_PCS_XPCS)\t:= pcs-xpcs.o pcs-xpcs-nxp.o pcs-xpcs-wx.o\ndrivers/net/pcs/Makefile-5-\ndrivers/net/pcs/Makefile:6:obj-$(CONFIG_PCS_XPCS)\t\t+= pcs_xpcs.o\ndrivers/net/pcs/Makefile:7:obj-$(CONFIG_PCS_XPCS_PLATFORM) += pcs-xpcs-plat.o\ndrivers/net/pcs/Makefile:8:obj-$(CONFIG_PCS_XPCS_ROCKCHIP) += pcs-xpcs-rk.o\ndrivers/net/pcs/Makefile-9-obj-$(CONFIG_PCS_LYNX)\t\t+= pcs-lynx.o\n--\ninclude/linux/pcs/pcs-xpcs-rk.h-1-/* SPDX-License-Identifier: GPL-2.0 */\ninclude/linux/pcs/pcs-xpcs-rk.h:2:#ifndef __LINUX_PCS_XPCS_ROCKCHIP_H\ninclude/linux/pcs/pcs-xpcs-rk.h:3:#define __LINUX_PCS_XPCS_ROCKCHIP_H\ninclude/linux/pcs/pcs-xpcs-rk.h-4-\n--\ninclude/linux/pcs/pcs-xpcs-rk.h=9=struct dw_xpcs *xpcs_rk_create(struct device *dev, struct device_node *pcs, int port);\ninclude/linux/pcs/pcs-xpcs-rk.h-10-\ninclude/linux/pcs/pcs-xpcs-rk.h:11:#endif /* __LINUX_PCS_XPCS_ROCKCHIP_H */\n--\ninclude/linux/pcs/pcs-xpcs.h-6-\ninclude/linux/pcs/pcs-xpcs.h:7:#ifndef __LINUX_PCS_XPCS_H\ninclude/linux/pcs/pcs-xpcs.h:8:#define __LINUX_PCS_XPCS_H\ninclude/linux/pcs/pcs-xpcs.h-9-\n--\ninclude/linux/pcs/pcs-xpcs.h=61=void xpcs_destroy_pcs(struct phylink_pcs *pcs);\ninclude/linux/pcs/pcs-xpcs.h-62-\ninclude/linux/pcs/pcs-xpcs.h:63:#endif /* __LINUX_PCS_XPCS_H */\n"
} |
| 5/2 | 2026/10/08 23:49 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 19294 output: 18 thoughts: 280 Thoughts: **My Initial Assessment of PCS-XPCS Driver Usage** Okay, let's take a look at where this `pcs-xpcs.c` driver is actually used. It looks like `CONFIG_PCS_XPCS` is selected by `NET_DSA_MICROCHIP_KSZ_COMMON`, `NET_DSA_TAG_SJA1105`, `FBNIC`, `STMMAC_ETH`, and `TXGBE`. Hmmm. Now, my immediate concern is whether any of these actually operate in a standard QEMU or virtualized environment. Can I easily instantiate and test a device using this `PCS_XPCS` driver within a typical QEMU instance? What exactly does QEMU emulate? Does it have any specific support for those drivers? I need to know if I can even *reach* any of these devices for testing on an AMD64 QEMU. Can I use this for fuzzing? I should really focus on the drivers themselves and see if they can be supported in a QEMU instance. So, I need to check `stmmac`, `dwmac-rk`, `pcs-xpcs-rk`, or directly in `pcs-xpcs.c`. I keep coming back to this question of reachability. Can I test any of this in QEMU? Wait a minute, what about PCI devices? Maybe there's a PCI device that leverages `stmmac` or `PCS_XPCS`. That might open up some interesting possibilities. Let's see if there is any `xpcs_create` usage in the codebase. |
| 6/2 | 2026/10/08 23:50 | tool | grepper |
0mArgs:{
"Expression": "xpcs_create"
}Results: {
"Output": "drivers/net/dsa/microchip/ksz9477.c=321=static int ksz9477_pcs_create(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz9477.c-345-\ndrivers/net/dsa/microchip/ksz9477.c:346:\tpcs = xpcs_create_pcs_mdiodev(bus, 0);\ndrivers/net/dsa/microchip/ksz9477.c-347-\tif (IS_ERR(pcs))\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c=368=static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv)\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c-411-\ndrivers/net/dsa/sja1105/sja1105_mdio.c:412:\t\tpcs = xpcs_create_pcs_mdiodev(bus, port);\ndrivers/net/dsa/sja1105/sja1105_mdio.c-413-\t\tif (IS_ERR(pcs)) {\n--\ndrivers/net/ethernet/meta/fbnic/fbnic_phylink.c=197=int fbnic_phylink_create(struct net_device *netdev)\n--\ndrivers/net/ethernet/meta/fbnic/fbnic_phylink.c-204-\ndrivers/net/ethernet/meta/fbnic/fbnic_phylink.c:205:\tpcs = xpcs_create_pcs_mdiodev(fbd-\u003emdio_bus, 0);\ndrivers/net/ethernet/meta/fbnic/fbnic_phylink.c-206-\tif (IS_ERR(pcs)) {\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c=426=int stmmac_pcs_setup(struct net_device *ndev)\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c-438-\t\tpcsnode = fwnode_find_reference(devnode, \"pcs-handle\", 0);\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c:439:\t\txpcs = xpcs_create_fwnode(pcsnode);\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c-440-\t\tfwnode_handle_put(pcsnode);\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c-444-\t\taddr = ffs(priv-\u003eplat-\u003emdio_bus_data-\u003epcs_mask) - 1;\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c:445:\t\txpcs = xpcs_create_mdiodev(priv-\u003emii, addr);\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c-446-\t\tret = PTR_ERR_OR_ZERO(xpcs);\n--\ndrivers/net/ethernet/wangxun/txgbe/txgbe_phy.c=126=static int txgbe_mdio_pcs_init(struct txgbe *txgbe)\n--\ndrivers/net/ethernet/wangxun/txgbe/txgbe_phy.c-153-\ndrivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:154:\tpcs = xpcs_create_pcs_mdiodev(mii_bus, 0);\ndrivers/net/ethernet/wangxun/txgbe/txgbe_phy.c-155-\tif (IS_ERR(pcs))\n--\ndrivers/net/pcs/pcs-xpcs-rk.c=481=struct dw_xpcs *xpcs_rk_create(struct device *dev, struct device_node *pcs, int port)\n--\ndrivers/net/pcs/pcs-xpcs-rk.c-506-\t * point. It does not fully protect against a concurrent unbind\ndrivers/net/pcs/pcs-xpcs-rk.c:507:\t * between here and xpcs_create_mdiodev(); closing that window would\ndrivers/net/pcs/pcs-xpcs-rk.c-508-\t * require reading a managed link's status or device_lock(), neither\n--\ndrivers/net/pcs/pcs-xpcs-rk.c-532-\ndrivers/net/pcs/pcs-xpcs-rk.c:533:\txpcs = xpcs_create_mdiodev(pxpcs-\u003ebus, port);\ndrivers/net/pcs/pcs-xpcs-rk.c-534-\tif (IS_ERR(xpcs)) {\n--\ndrivers/net/pcs/pcs-xpcs.c=1512=static int xpcs_identify(struct dw_xpcs *xpcs)\n--\ndrivers/net/pcs/pcs-xpcs.c-1531-\ndrivers/net/pcs/pcs-xpcs.c:1532:static struct dw_xpcs *xpcs_create_data(struct mdio_device *mdiodev)\ndrivers/net/pcs/pcs-xpcs.c-1533-{\n--\ndrivers/net/pcs/pcs-xpcs.c=1586=static int xpcs_init_id(struct dw_xpcs *xpcs)\n--\ndrivers/net/pcs/pcs-xpcs.c-1600-\ndrivers/net/pcs/pcs-xpcs.c:1601:static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev)\ndrivers/net/pcs/pcs-xpcs.c-1602-{\n--\ndrivers/net/pcs/pcs-xpcs.c-1605-\ndrivers/net/pcs/pcs-xpcs.c:1606:\txpcs = xpcs_create_data(mdiodev);\ndrivers/net/pcs/pcs-xpcs.c-1607-\tif (IS_ERR(xpcs))\n--\ndrivers/net/pcs/pcs-xpcs.c-1637-/**\ndrivers/net/pcs/pcs-xpcs.c:1638: * xpcs_create_mdiodev() - create a DW xPCS instance with the MDIO @addr\ndrivers/net/pcs/pcs-xpcs.c-1639- * @bus: pointer to the MDIO-bus descriptor for the device to be looked at\n--\ndrivers/net/pcs/pcs-xpcs.c-1645- */\ndrivers/net/pcs/pcs-xpcs.c:1646:struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr)\ndrivers/net/pcs/pcs-xpcs.c-1647-{\n--\ndrivers/net/pcs/pcs-xpcs.c-1654-\ndrivers/net/pcs/pcs-xpcs.c:1655:\txpcs = xpcs_create(mdiodev);\ndrivers/net/pcs/pcs-xpcs.c-1656-\ndrivers/net/pcs/pcs-xpcs.c:1657:\t/* xpcs_create() has taken a refcount on the mdiodev if it was\ndrivers/net/pcs/pcs-xpcs.c:1658:\t * successful. If xpcs_create() fails, this will free the mdio\ndrivers/net/pcs/pcs-xpcs.c-1659-\t * device here. In any case, we don't need to hold our reference\n--\ndrivers/net/pcs/pcs-xpcs.c-1666-}\ndrivers/net/pcs/pcs-xpcs.c:1667:EXPORT_SYMBOL_GPL(xpcs_create_mdiodev);\ndrivers/net/pcs/pcs-xpcs.c-1668-\ndrivers/net/pcs/pcs-xpcs.c:1669:struct phylink_pcs *xpcs_create_pcs_mdiodev(struct mii_bus *bus, int addr)\ndrivers/net/pcs/pcs-xpcs.c-1670-{\n--\ndrivers/net/pcs/pcs-xpcs.c-1672-\ndrivers/net/pcs/pcs-xpcs.c:1673:\txpcs = xpcs_create_mdiodev(bus, addr);\ndrivers/net/pcs/pcs-xpcs.c-1674-\tif (IS_ERR(xpcs))\n--\ndrivers/net/pcs/pcs-xpcs.c-1678-}\ndrivers/net/pcs/pcs-xpcs.c:1679:EXPORT_SYMBOL_GPL(xpcs_create_pcs_mdiodev);\ndrivers/net/pcs/pcs-xpcs.c-1680-\ndrivers/net/pcs/pcs-xpcs.c-1681-/**\ndrivers/net/pcs/pcs-xpcs.c:1682: * xpcs_create_fwnode() - Create a DW xPCS instance from @fwnode\ndrivers/net/pcs/pcs-xpcs.c-1683- * @fwnode: fwnode handle poining to the DW XPCS device\n--\ndrivers/net/pcs/pcs-xpcs.c-1690- */\ndrivers/net/pcs/pcs-xpcs.c:1691:struct dw_xpcs *xpcs_create_fwnode(struct fwnode_handle *fwnode)\ndrivers/net/pcs/pcs-xpcs.c-1692-{\n--\ndrivers/net/pcs/pcs-xpcs.c-1702-\ndrivers/net/pcs/pcs-xpcs.c:1703:\txpcs = xpcs_create(mdiodev);\ndrivers/net/pcs/pcs-xpcs.c-1704-\ndrivers/net/pcs/pcs-xpcs.c:1705:\t/* xpcs_create() has taken a refcount on the mdiodev if it was\ndrivers/net/pcs/pcs-xpcs.c:1706:\t * successful. If xpcs_create() fails, this will free the mdio\ndrivers/net/pcs/pcs-xpcs.c-1707-\t * device here. In any case, we don't need to hold our reference\n--\ndrivers/net/pcs/pcs-xpcs.c-1714-}\ndrivers/net/pcs/pcs-xpcs.c:1715:EXPORT_SYMBOL_GPL(xpcs_create_fwnode);\ndrivers/net/pcs/pcs-xpcs.c-1716-\n--\ninclude/linux/pcs/pcs-xpcs.h=55=void xpcs_config_eee_mult_fact(struct dw_xpcs *xpcs, u8 mult_fact);\ninclude/linux/pcs/pcs-xpcs.h:56:struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr);\ninclude/linux/pcs/pcs-xpcs.h:57:struct dw_xpcs *xpcs_create_fwnode(struct fwnode_handle *fwnode);\ninclude/linux/pcs/pcs-xpcs.h-58-void xpcs_destroy(struct dw_xpcs *xpcs);\ninclude/linux/pcs/pcs-xpcs.h-59-\ninclude/linux/pcs/pcs-xpcs.h:60:struct phylink_pcs *xpcs_create_pcs_mdiodev(struct mii_bus *bus, int addr);\ninclude/linux/pcs/pcs-xpcs.h-61-void xpcs_destroy_pcs(struct phylink_pcs *pcs);\n"
} |
| 7/2 | 2026/10/08 23:50 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 22886 output: 40 thoughts: 90 Thoughts: Okay, let's see what I'm looking at today. **Analyzing Recent Changes in `pcs-xpcs.c`** Alright, it looks like I need to understand some recent changes in `pcs-xpcs.c`. Specifically, I'm interested in the functions `xpcs_config_aneg_c37_sgmii` and `xpcs_get_state_c37_sgmii`. Given my experience, I'll go straight to the code. I'll focus my attention on the sections around lines 760-840 and 1090-1120 in that file. That should give me a good overview of the context around those function calls and the recent modifications. I'll likely be able to piece together the implications of any changes from there. Time to dig in! |
| 8/2 | 2026/10/08 23:51 | tool | read-file |
0mArgs:{
"File": "drivers/net/pcs/pcs-xpcs.c",
"FirstLine": 755,
"LineCount": 80
}Results: {
"Contents": " 755:\t\n 756:\t\t/* For AN for C37 SGMII mode, the settings are :-\n 757:\t\t * 1) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 0b (Disable SGMII AN in case\n 758:\t\t it is already enabled)\n 759:\t\t * 2) VR_MII_AN_CTRL Bit(2:1)[PCS_MODE] = 10b (SGMII AN)\n 760:\t\t * 3) VR_MII_AN_CTRL Bit(3) [TX_CONFIG] = 0b (MAC side SGMII)\n 761:\t\t * DW xPCS used with DW EQoS MAC is always MAC side SGMII.\n 762:\t\t * 4) VR_MII_DIG_CTRL1 Bit(9) [MAC_AUTO_SW] = 1b (Automatic\n 763:\t\t * speed/duplex mode change by HW after SGMII AN complete)\n 764:\t\t * 5) VR_MII_AN_INTR_STS = 0x0 (Clear CL37 AN complete status)\n 765:\t\t * 6) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 1b (Enable SGMII AN)\n 766:\t\t * VR_MII_MMD_CTRL Bit(9) [AN_RESTART] = 1b (Restart SGMII AN)\n 767:\t\t *\n 768:\t\t * Note that VR_MII_MMD_CTRL is MII_BMCR.\n 769:\t\t *\n 770:\t\t * Note: Since it is MAC side SGMII, there is no need to set\n 771:\t\t *\t SR_MII_AN_ADV. MAC side SGMII receives AN Tx Config from\n 772:\t\t *\t PHY about the link state change after C28 AN is completed\n 773:\t\t *\t between PHY and Link Partner. There is also no need to\n 774:\t\t *\t trigger AN restart for MAC-side SGMII on most devices.\n 775:\t\t *\n 776:\t\t * Note: While the DesignWare databook states that AN restart is\n 777:\t\t *\t not needed for MAC side SGMII, some implementations (e.g.\n 778:\t\t *\t Rockchip RK3568) exhibit a timing quirk when integrated with\n 779:\t\t *\t phylink and do not restart AN automatically when the link\n 780:\t\t *\t comes back up. An explicit AN restart is required on those\n 781:\t\t *\t parts to recover the link after a disconnect.\n 782:\t\t */\n 783:\t\tmdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMCR);\n 784:\t\tif (mdio_ctrl \u003c 0)\n 785:\t\t\treturn mdio_ctrl;\n 786:\t\n 787:\t\tif (mdio_ctrl \u0026 BMCR_ANENABLE) {\n 788:\t\t\tret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR,\n 789:\t\t\t\t\t mdio_ctrl \u0026 ~BMCR_ANENABLE);\n 790:\t\t\tif (ret \u003c 0)\n 791:\t\t\t\treturn ret;\n 792:\t\t}\n 793:\t\n 794:\t\tmask = DW_VR_MII_PCS_MODE_MASK | DW_VR_MII_TX_CONFIG_MASK;\n 795:\t\tval = FIELD_PREP(DW_VR_MII_PCS_MODE_MASK,\n 796:\t\t\t\t DW_VR_MII_PCS_MODE_C37_SGMII);\n 797:\t\n 798:\t\tif (xpcs-\u003einfo.pma == WX_TXGBE_XPCS_PMA_10G_ID) {\n 799:\t\t\tmask |= DW_VR_MII_AN_CTRL_8BIT;\n 800:\t\t\tval |= DW_VR_MII_AN_CTRL_8BIT;\n 801:\t\t\t/* Hardware requires it to be PHY side SGMII */\n 802:\t\t\ttx_conf = DW_VR_MII_TX_CONFIG_PHY_SIDE_SGMII;\n 803:\t\t} else {\n 804:\t\t\ttx_conf = DW_VR_MII_TX_CONFIG_MAC_SIDE_SGMII;\n 805:\t\t}\n 806:\t\n 807:\t\tval |= FIELD_PREP(DW_VR_MII_TX_CONFIG_MASK, tx_conf);\n 808:\t\n 809:\t\tret = xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL, mask, val);\n 810:\t\tif (ret \u003c 0)\n 811:\t\t\treturn ret;\n 812:\t\n 813:\t\tval = 0;\n 814:\t\tmask = DW_VR_MII_DIG_CTRL1_2G5_EN | DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW;\n 815:\t\n 816:\t\tif (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED)\n 817:\t\t\tval = DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW;\n 818:\t\n 819:\t\tif (xpcs-\u003einfo.pma == WX_TXGBE_XPCS_PMA_10G_ID) {\n 820:\t\t\tmask |= DW_VR_MII_DIG_CTRL1_PHY_MODE_CTRL;\n 821:\t\t\tval |= DW_VR_MII_DIG_CTRL1_PHY_MODE_CTRL;\n 822:\t\t}\n 823:\t\n 824:\t\tret = xpcs_modify(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, mask, val);\n 825:\t\tif (ret \u003c 0)\n 826:\t\t\treturn ret;\n 827:\t\n 828:\t\t/* Clear CL37 AN complete status */\n 829:\t\tret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0);\n 830:\t\tif (ret \u003c 0)\n 831:\t\t\treturn ret;\n 832:\t\n 833:\t\tif (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED)\n 834:\t\t\tret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_BMCR,\n"
} |
| 9/2 | 2026/10/08 23:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24915 output: 41 thoughts: 21 Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own: **Analyzing `xpcs_get_state_c37_sgmii`** Alright, I'm going to shift gears and turn my attention to `xpcs_get_state_c37_sgmii`. I need to understand this function, its purpose, and its role within the larger system. I'm already visualizing how it likely interfaces with the SGMII (Serial Gigabit Media Independent Interface) aspect. Given the context, I'm inferring it probably retrieves or reports the state of some critical component or module related to the C37 specification and SGMII communications. I'll need to see if the state refers to the link status, error counters, operational mode, or any other pertinent parameters. The name itself suggests a level of specificity that's intriguing. Time to dig in and break it down. |
| 10/2 | 2026/10/08 23:52 | tool | read-file |
0mArgs:{
"File": "drivers/net/pcs/pcs-xpcs.c",
"FirstLine": 1080,
"LineCount": 40
}Results: {
"Contents": "1080:\t\t/* For C37 SGMII mode, we check DW_VR_MII_AN_INTR_STS for link\n1081:\t\t * status, speed and duplex.\n1082:\t\t */\n1083:\t\tret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS);\n1084:\t\tif (ret \u003c 0)\n1085:\t\t\treturn ret;\n1086:\t\n1087:\t\tstate-\u003ean_complete = ret \u0026 DW_VR_MII_AN_STS_C37_ANCMPLT_INTR;\n1088:\t\n1089:\t\tif (ret \u0026 DW_VR_MII_C37_ANSGM_SP_LNKSTS) {\n1090:\t\t\tint speed_value;\n1091:\t\n1092:\t\t\tstate-\u003elink = true;\n1093:\t\n1094:\t\t\tspeed_value = FIELD_GET(DW_VR_MII_AN_STS_C37_ANSGM_SP, ret);\n1095:\t\t\tif (speed_value == DW_VR_MII_C37_ANSGM_SP_1000)\n1096:\t\t\t\tstate-\u003espeed = SPEED_1000;\n1097:\t\t\telse if (speed_value == DW_VR_MII_C37_ANSGM_SP_100)\n1098:\t\t\t\tstate-\u003espeed = SPEED_100;\n1099:\t\t\telse\n1100:\t\t\t\tstate-\u003espeed = SPEED_10;\n1101:\t\n1102:\t\t\tif (ret \u0026 DW_VR_MII_AN_STS_C37_ANSGM_FD)\n1103:\t\t\t\tstate-\u003eduplex = DUPLEX_FULL;\n1104:\t\t\telse\n1105:\t\t\t\tstate-\u003eduplex = DUPLEX_HALF;\n1106:\t\n1107:\t\t\treturn 0;\n1108:\t\t}\n1109:\t\n1110:\t\tif (state-\u003ean_complete) {\n1111:\t\t\t/* Clear AN complete status or interrupt */\n1112:\t\t\tret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0);\n1113:\t\t\tif (ret \u003c 0)\n1114:\t\t\t\treturn ret;\n1115:\t\n1116:\t\t\t/* Initiate the next round of AN */\n1117:\t\t\tret = xpcs_modify(xpcs, MDIO_MMD_VEND2, MII_BMCR, BMCR_ANRESTART,\n1118:\t\t\t\t\t BMCR_ANRESTART);\n1119:\t\t\tif (ret \u003c 0)\n"
} |
| 11/2 | 2026/10/08 23:52 | llm | patch-evaluator |
3mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25903 output: 51 thoughts: 59 Thoughts: Okay, let's dive into this. Here's how I'd approach this task, walking through my thought process: **Investigating the Usage of Specific Functions** Right, let's get down to brass tacks. I need to understand how these `xpcs_config_aneg_c37_sgmii` and `xpcs_get_state_c37_sgmii` functions are being used. Specifically, I need to trace their lifecycle. My first instinct, given what I'm dealing with, is to see where these functions are *called* or *registered*. I'm zeroing in on `pcs-xpcs.c` because that sounds like the most relevant source file, based on the function names. That naming convention suggests something to do with PCS (Physical Coding Sublayer) configurations and perhaps an XGXS or similar interface. So, I need to determine the contexts in which those functions are used. Knowing this will give me a better understanding of the overall system behavior and where to focus any debugging or modification efforts. |
| 12/2 | 2026/10/08 23:55 | tool | grepper |
0mArgs:{
"Expression": "xpcs_(config_aneg|get_state)_c37_sgmii",
"PathPrefixes": [
"drivers/net/pcs/pcs-xpcs.c"
]
}Results: {
"Output": "drivers/net/pcs/pcs-xpcs.c=721=static void xpcs_pre_config(struct phylink_pcs *pcs, phy_interface_t interface)\n--\ndrivers/net/pcs/pcs-xpcs.c-749-\ndrivers/net/pcs/pcs-xpcs.c:750:static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs,\ndrivers/net/pcs/pcs-xpcs.c-751-\t\t\t\t unsigned int neg_mode)\n--\ndrivers/net/pcs/pcs-xpcs.c=925=static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,\n--\ndrivers/net/pcs/pcs-xpcs.c-956-\tcase DW_AN_C37_SGMII:\ndrivers/net/pcs/pcs-xpcs.c:957:\t\tret = xpcs_config_aneg_c37_sgmii(xpcs, neg_mode);\ndrivers/net/pcs/pcs-xpcs.c-958-\t\tif (ret)\n--\ndrivers/net/pcs/pcs-xpcs.c=995=static int xpcs_get_state_c73(struct dw_xpcs *xpcs,\n--\ndrivers/net/pcs/pcs-xpcs.c-1067-\ndrivers/net/pcs/pcs-xpcs.c:1068:static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs,\ndrivers/net/pcs/pcs-xpcs.c-1069-\t\t\t\t struct phylink_link_state *state)\n--\ndrivers/net/pcs/pcs-xpcs.c=1184=static void xpcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,\n--\ndrivers/net/pcs/pcs-xpcs.c-1205-\tcase DW_AN_C37_SGMII:\ndrivers/net/pcs/pcs-xpcs.c:1206:\t\tret = xpcs_get_state_c37_sgmii(xpcs, state);\ndrivers/net/pcs/pcs-xpcs.c-1207-\t\tif (ret)\ndrivers/net/pcs/pcs-xpcs.c-1208-\t\t\tdev_err(\u0026xpcs-\u003emdiodev-\u003edev, \"%s returned %pe\\n\",\ndrivers/net/pcs/pcs-xpcs.c:1209:\t\t\t\t\"xpcs_get_state_c37_sgmii\", ERR_PTR(ret));\ndrivers/net/pcs/pcs-xpcs.c-1210-\t\tbreak;\n"
} |
| 13/2 | 2026/10/08 23:55 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26911 output: 40 thoughts: 109 Thoughts: Okay, let's break this down. **Analyzing the xpcs Driver Calls** Alright, so I see `xpcs_do_config` directly calls `xpcs_config_aneg_c37_sgmii`, and similarly, `xpcs_get_state` calls `xpcs_get_state_c37_sgmii`. These are clearly PCS (Physical Coding Sublayer) operations within the context of Phylink, which makes perfect sense. My initial impression is that these are well-defined function calls within the xpcs driver itself, and the next obvious thing to check is the driver code itself. Now, it looks like these operations are hooked up through `xpcs_phylink_ops` which is defined as a `static const struct phylink_pcs_ops`. I need to confirm this understanding, and the best way to do that is to go look at the definition of `xpcs_phylink_ops`. I'll head over to `drivers/net/pcs/pcs-xpcs.c` and dig into that struct. This should quickly confirm the expected connections and provide insight into how the PCS functions are registered with the Phylink framework. |
| 14/2 | 2026/10/08 23:56 | tool | grepper |
0mArgs:{
"Expression": "xpcs_phylink_ops",
"PathPrefixes": [
"drivers/net/pcs/pcs-xpcs.c"
]
}Results: {
"Output": "drivers/net/pcs/pcs-xpcs.c=1484=static const struct dw_xpcs_desc xpcs_desc_list[] = {\n--\ndrivers/net/pcs/pcs-xpcs.c-1499-\ndrivers/net/pcs/pcs-xpcs.c:1500:static const struct phylink_pcs_ops xpcs_phylink_ops = {\ndrivers/net/pcs/pcs-xpcs.c-1501-\t.pcs_validate = xpcs_validate,\n--\ndrivers/net/pcs/pcs-xpcs.c=1532=static struct dw_xpcs *xpcs_create_data(struct mdio_device *mdiodev)\n--\ndrivers/net/pcs/pcs-xpcs.c-1541-\txpcs-\u003emdiodev = mdiodev;\ndrivers/net/pcs/pcs-xpcs.c:1542:\txpcs-\u003epcs.ops = \u0026xpcs_phylink_ops;\ndrivers/net/pcs/pcs-xpcs.c-1543-\txpcs-\u003epcs.poll = true;\n"
} |
| 15/2 | 2026/10/08 23:56 | llm | patch-evaluator |
2mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27591 output: 42 thoughts: 464 Thoughts: **Investigating the Instantiation of `dw_xpcs` in QEMU** Okay, let's break this down. My goal is to determine if a device utilizing `dw_xpcs` can be successfully instantiated within QEMU. First, I need to understand where `dw_xpcs` is actually being instantiated. I'll need to trace the usage, specifically looking for calls to `dw_xpcs` or related functions like `xpcs_create*`. Here's what I've found, a quick rundown of the users: 1. **Microchip KSZ9477:** This is an Ethernet switch, and the driver interacts with the hardware over SPI/I2C/MDIO. No QEMU potential here. 2. **NXP SJA1105:** Another automotive Ethernet switch, connected via SPI. Again, not a candidate for a QEMU instance. 3. **Meta fbnic:** This is a PCIe NIC, a custom Meta ASIC. Potentially interesting, depending on how the PCIe side is handled. 4. **STMMAC:** Ah, this is where it's getting interesting. `stmmac_pcs_setup` is mentioned, and STMMAC has PCI glue! This is definitely worth a closer look. I need to dive into the `drivers/net/ethernet/stmicro/stmmac/` directory and see how this is instantiated, looking for instances of `stmmac_pcs_setup` or related. 5. **Wangxun TXGBE:** Another 10GbE PCI NIC, a physical PCIe card. Similar to the Meta fbnic, this might be relevant. 6. **Rockchip RK3568:** This is an ARM64 SoC platform device. Could potentially work in QEMU. Given the architecture of my own product, the STMMAC seems to be the most promising path, because of its PCI glue. I'll focus on `stmmac` now, focusing specifically on how `stmmac_pcs_setup` is utilized, along with other related symbols. I need to understand how the PHY interface is handled within the context of the STMMAC PCI instantiation. |
| 16/2 | 2026/10/08 23:58 | tool | grepper |
0mArgs:{
"Expression": "stmmac_pcs_setup",
"PathPrefixes": [
"drivers/net/ethernet/stmicro/stmmac/"
]
}Results: {
"Output": "drivers/net/ethernet/stmicro/stmmac/stmmac.h=399=void stmmac_mdio_unlock(struct stmmac_priv *priv);\ndrivers/net/ethernet/stmicro/stmmac/stmmac.h:400:int stmmac_pcs_setup(struct net_device *ndev);\ndrivers/net/ethernet/stmicro/stmmac/stmmac.h-401-void stmmac_pcs_clean(struct net_device *ndev);\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c=7834=static int __stmmac_dvr_probe(struct device *device,\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c-8083-\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c:8084:\tret = stmmac_pcs_setup(ndev);\ndrivers/net/ethernet/stmicro/stmmac/stmmac_main.c-8085-\tif (ret)\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c=381=int stmmac_mdio_reset(struct mii_bus *bus)\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c-425-\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c:426:int stmmac_pcs_setup(struct net_device *ndev)\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c-427-{\n"
} |
| 17/2 | 2026/10/08 23:58 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29016 output: 50 thoughts: 40 Thoughts: Okay, let's dive into this. I'm going to take a look at the `stmmac_pcs_setup` function within `drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c`. I'm especially interested in this function because it relates to the physical layer configuration for the STMicroelectronics Ethernet MAC driver. It is likely that this function handles the PCS (Physical Coding Sublayer) setup, which is a critical part of ensuring proper Ethernet link operation. I expect this function to interact heavily with the MDIO interface, given the file's name (`stmmac_mdio.c`). I'll be looking for how the function configures the PCS registers, what PHY types are supported, and how it handles different speed and duplex settings. Specifically, I need to understand what it does at the PCS layer, as the MAC only deals with the Medium Access Control layer. My expertise means I will be trying to determine whether this setup adheres to standards. |
| 18/2 | 2026/10/08 23:59 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c",
"FirstLine": 425,
"LineCount": 40
}Results: {
"Contents": " 425:\t\n 426:\tint stmmac_pcs_setup(struct net_device *ndev)\n 427:\t{\n 428:\t\tstruct stmmac_priv *priv = netdev_priv(ndev);\n 429:\t\tstruct fwnode_handle *devnode, *pcsnode;\n 430:\t\tstruct dw_xpcs *xpcs = NULL;\n 431:\t\tint addr, ret;\n 432:\t\n 433:\t\tdevnode = dev_fwnode(priv-\u003edevice);\n 434:\t\n 435:\t\tif (priv-\u003eplat-\u003epcs_init) {\n 436:\t\t\tret = priv-\u003eplat-\u003epcs_init(priv);\n 437:\t\t} else if (fwnode_property_present(devnode, \"pcs-handle\")) {\n 438:\t\t\tpcsnode = fwnode_find_reference(devnode, \"pcs-handle\", 0);\n 439:\t\t\txpcs = xpcs_create_fwnode(pcsnode);\n 440:\t\t\tfwnode_handle_put(pcsnode);\n 441:\t\t\tret = PTR_ERR_OR_ZERO(xpcs);\n 442:\t\t} else if (priv-\u003eplat-\u003emdio_bus_data \u0026\u0026\n 443:\t\t\t priv-\u003eplat-\u003emdio_bus_data-\u003epcs_mask) {\n 444:\t\t\taddr = ffs(priv-\u003eplat-\u003emdio_bus_data-\u003epcs_mask) - 1;\n 445:\t\t\txpcs = xpcs_create_mdiodev(priv-\u003emii, addr);\n 446:\t\t\tret = PTR_ERR_OR_ZERO(xpcs);\n 447:\t\t} else {\n 448:\t\t\treturn 0;\n 449:\t\t}\n 450:\t\n 451:\t\tif (ret)\n 452:\t\t\treturn dev_err_probe(priv-\u003edevice, ret, \"No xPCS found\\n\");\n 453:\t\n 454:\t\tif (xpcs)\n 455:\t\t\txpcs_config_eee_mult_fact(xpcs, priv-\u003eplat-\u003emult_fact_100ns);\n 456:\t\n 457:\t\tpriv-\u003ehw-\u003expcs = xpcs;\n 458:\t\n 459:\t\treturn 0;\n 460:\t}\n 461:\t\n 462:\tvoid stmmac_pcs_clean(struct net_device *ndev)\n 463:\t{\n 464:\t\tstruct stmmac_priv *priv = netdev_priv(ndev);\n"
} |
| 19/2 | 2026/10/08 23:59 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29994 output: 38 thoughts: 56 Thoughts: Here's my thought process, as if I were considering this myself: **Investigating STMMAC PCS Configuration** Okay, hold on a second. I need to clarify something about the `stmmac` driver. I'm trying to recall the exact conditions under which it uses `pcs_mask`, `pcs_init`, or `pcs-handle`. Are these used universally, or are they only associated with certain configurations or specific hardware? It's crucial for understanding how the Physical Layer (PCS) interface is managed within the driver. The best way to figure this out quickly is to get a general overview. My next step is to use `grep` within the `drivers/net/ethernet/stmicro/stmmac/` directory. I'll search for every instance of `pcs_mask`. This should allow me to see all references, which should give me the context I need to infer when `pcs_init` or `pcs-handle` are used too. Hopefully, this quick search will give me the answer I need. |
| 20/2 | 2026/10/09 00:00 | tool | grepper |
0mArgs:{
"Expression": "pcs_mask",
"PathPrefixes": [
"drivers/net/ethernet/stmicro/stmmac/"
]
}Results: {
"Output": "drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=616=static int intel_mgbe_common_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-733-\t plat-\u003ephy_interface == PHY_INTERFACE_MODE_1000BASEX) {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:734:\t\tplat-\u003emdio_bus_data-\u003epcs_mask = BIT_U32(INTEL_MGBE_XPCS_ADDR);\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-735-\t\tplat-\u003edefault_an_inband = true;\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c=426=int stmmac_pcs_setup(struct net_device *ndev)\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c-442-\t} else if (priv-\u003eplat-\u003emdio_bus_data \u0026\u0026\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c:443:\t\t priv-\u003eplat-\u003emdio_bus_data-\u003epcs_mask) {\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c:444:\t\taddr = ffs(priv-\u003eplat-\u003emdio_bus_data-\u003epcs_mask) - 1;\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c-445-\t\txpcs = xpcs_create_mdiodev(priv-\u003emii, addr);\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c=595=int stmmac_mdio_register(struct net_device *ndev)\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c-651-\tnew_bus-\u003epriv = ndev;\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c:652:\tnew_bus-\u003ephy_mask = mdio_bus_data-\u003ephy_mask | mdio_bus_data-\u003epcs_mask;\ndrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c-653-\tnew_bus-\u003eparent = priv-\u003edevice;\n"
} |
| 21/2 | 2026/10/09 00:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30937 output: 38 thoughts: 2677 Thoughts: **Analyzing the Intel Ethernet Controller and QEMU Emulation** Okay, so I've stumbled upon some code in `dwmac-intel.c` that piqued my interest. Specifically, the line setting `pcs_mask` for `intel_mgbe_common_data`. My initial thought was, what is this `dwmac-intel.c`? It's an Intel PCI Ethernet controller. Let me check if QEMU emulates it, because that would be relevant to what I'm working on. The answer is no, QEMU does *not* emulate Intel MGBE (e.g., Elkhart Lake or Tiger Lake multi-gigabit Ethernet), or rockchip or Wangxun devices. It's a key point. QEMU's emulation scope is limited to certain standard Ethernet devices, like e1000, virtio-net, etc. Now, I shifted focus, wondering if other related drivers, like `pcs-xpcs.c`, `pcs-xpcs-rk.c`, or `dwmac-rk.c`, were candidates for QEMU execution. My first clue was that `dwmac-rk.c` and `pcs-xpcs-rk.c` are platform drivers, specifically linked to Rockchip SoCs, and that they use the device tree for configuration. I checked their source code. They rely on specific Rockchip hardware features, like GRF registers and the associated clock and power management functions. Given that my target architecture is amd64, I had to pause and consider: Can these Device Tree platform devices function on amd64 in QEMU? The answer is no, because on amd64, ARCH_ROCKCHIP isn't defined, the standard kernel boot uses ACPI (unless special configurations, like DT overlays, are applied). My key thought here is that syzkaller, which I'm familiar with, does not run Device Tree devices for Rockchip. Even if I could somehow get these drivers to probe, they'd fail because of the underlying Rockchip SoC hardware dependencies. The code relies on vendor-specific registers and physical resources that aren't available in a generic QEMU environment. Then, I turned my attention to the core `pcs-xpcs.c` driver, specifically examining the recent changes. I looked closely at the additions related to Auto-Negotiation (AN) for SGMII. The key takeaway from the code changes is that some implementations, specifically Rockchip RK3568, exhibit timing quirks, requiring an explicit AN restart to re-establish the link after a disconnect. This nuance is crucial for understanding how the driver handles link recovery. My next step was to assess how `pcs-xpcs.c` could be reached in a simulated or emulated setup. To check this, I did a code search and found all the places where `xpcs_create` is called. The calls were from various drivers dealing with different network interfaces or PHYs (like Microchip, NXP, Meta, STM, Wangxun), and a few `pcs-xpcs*` drivers. This means there's a wider scope of integration for `xpcs` than just the initial Intel device. It is clear that the DesignWare xPCS is used in various setups with a few key examples. The discovery of `pcs-xpcs-plat.c` was particularly interesting, because that's a platform driver that is an abstraction for xPCS devices, and it's a lead worth investigating further! |
| 22/2 | 2026/10/09 00:01 | tool | grepper |
0mArgs:{
"Expression": "xpcs_",
"PathPrefixes": [
"drivers/net/pcs/pcs-xpcs-plat.c"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 202 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (1 files in total):\ndrivers/net/pcs/pcs-xpcs-plat.c:79\n\ndrivers/net/pcs/pcs-xpcs-plat.c-26-\ndrivers/net/pcs/pcs-xpcs-plat.c:27:struct dw_xpcs_plat {\ndrivers/net/pcs/pcs-xpcs-plat.c-28-\tstruct platform_device *pdev;\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-35-\ndrivers/net/pcs/pcs-xpcs-plat.c:36:static ptrdiff_t xpcs_mmio_addr_format(int dev, int reg)\ndrivers/net/pcs/pcs-xpcs-plat.c-37-{\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-40-\ndrivers/net/pcs/pcs-xpcs-plat.c:41:static u16 xpcs_mmio_addr_page(ptrdiff_t csr)\ndrivers/net/pcs/pcs-xpcs-plat.c-42-{\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-45-\ndrivers/net/pcs/pcs-xpcs-plat.c:46:static ptrdiff_t xpcs_mmio_addr_offset(ptrdiff_t csr)\ndrivers/net/pcs/pcs-xpcs-plat.c-47-{\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-50-\ndrivers/net/pcs/pcs-xpcs-plat.c:51:static int xpcs_mmio_read_reg_indirect(struct dw_xpcs_plat *pxpcs,\ndrivers/net/pcs/pcs-xpcs-plat.c-52-\t\t\t\t int dev, int reg)\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-57-\ndrivers/net/pcs/pcs-xpcs-plat.c:58:\tcsr = xpcs_mmio_addr_format(dev, reg);\ndrivers/net/pcs/pcs-xpcs-plat.c:59:\tpage = xpcs_mmio_addr_page(csr);\ndrivers/net/pcs/pcs-xpcs-plat.c:60:\tofs = xpcs_mmio_addr_offset(csr);\ndrivers/net/pcs/pcs-xpcs-plat.c-61-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-81-\ndrivers/net/pcs/pcs-xpcs-plat.c:82:static int xpcs_mmio_write_reg_indirect(struct dw_xpcs_plat *pxpcs,\ndrivers/net/pcs/pcs-xpcs-plat.c-83-\t\t\t\t\tint dev, int reg, u16 val)\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-88-\ndrivers/net/pcs/pcs-xpcs-plat.c:89:\tcsr = xpcs_mmio_addr_format(dev, reg);\ndrivers/net/pcs/pcs-xpcs-plat.c:90:\tpage = xpcs_mmio_addr_page(csr);\ndrivers/net/pcs/pcs-xpcs-plat.c:91:\tofs = xpcs_mmio_addr_offset(csr);\ndrivers/net/pcs/pcs-xpcs-plat.c-92-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-112-\ndrivers/net/pcs/pcs-xpcs-plat.c:113:static int xpcs_mmio_read_reg_direct(struct dw_xpcs_plat *pxpcs,\ndrivers/net/pcs/pcs-xpcs-plat.c-114-\t\t\t\t int dev, int reg)\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-118-\ndrivers/net/pcs/pcs-xpcs-plat.c:119:\tcsr = xpcs_mmio_addr_format(dev, reg);\ndrivers/net/pcs/pcs-xpcs-plat.c-120-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-138-\ndrivers/net/pcs/pcs-xpcs-plat.c:139:static int xpcs_mmio_write_reg_direct(struct dw_xpcs_plat *pxpcs,\ndrivers/net/pcs/pcs-xpcs-plat.c-140-\t\t\t\t int dev, int reg, u16 val)\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-144-\ndrivers/net/pcs/pcs-xpcs-plat.c:145:\tcsr = xpcs_mmio_addr_format(dev, reg);\ndrivers/net/pcs/pcs-xpcs-plat.c-146-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-164-\ndrivers/net/pcs/pcs-xpcs-plat.c:165:static int xpcs_mmio_read_c22(struct mii_bus *bus, int addr, int reg)\ndrivers/net/pcs/pcs-xpcs-plat.c-166-{\ndrivers/net/pcs/pcs-xpcs-plat.c:167:\tstruct dw_xpcs_plat *pxpcs = bus-\u003epriv;\ndrivers/net/pcs/pcs-xpcs-plat.c-168-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-172-\tif (pxpcs-\u003ereg_indir)\ndrivers/net/pcs/pcs-xpcs-plat.c:173:\t\treturn xpcs_mmio_read_reg_indirect(pxpcs, MDIO_MMD_VEND2, reg);\ndrivers/net/pcs/pcs-xpcs-plat.c-174-\telse\ndrivers/net/pcs/pcs-xpcs-plat.c:175:\t\treturn xpcs_mmio_read_reg_direct(pxpcs, MDIO_MMD_VEND2, reg);\ndrivers/net/pcs/pcs-xpcs-plat.c-176-}\ndrivers/net/pcs/pcs-xpcs-plat.c-177-\ndrivers/net/pcs/pcs-xpcs-plat.c:178:static int xpcs_mmio_write_c22(struct mii_bus *bus, int addr, int reg, u16 val)\ndrivers/net/pcs/pcs-xpcs-plat.c-179-{\ndrivers/net/pcs/pcs-xpcs-plat.c:180:\tstruct dw_xpcs_plat *pxpcs = bus-\u003epriv;\ndrivers/net/pcs/pcs-xpcs-plat.c-181-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-185-\tif (pxpcs-\u003ereg_indir)\ndrivers/net/pcs/pcs-xpcs-plat.c:186:\t\treturn xpcs_mmio_write_reg_indirect(pxpcs, MDIO_MMD_VEND2, reg, val);\ndrivers/net/pcs/pcs-xpcs-plat.c-187-\telse\ndrivers/net/pcs/pcs-xpcs-plat.c:188:\t\treturn xpcs_mmio_write_reg_direct(pxpcs, MDIO_MMD_VEND2, reg, val);\ndrivers/net/pcs/pcs-xpcs-plat.c-189-}\ndrivers/net/pcs/pcs-xpcs-plat.c-190-\ndrivers/net/pcs/pcs-xpcs-plat.c:191:static int xpcs_mmio_read_c45(struct mii_bus *bus, int addr, int dev, int reg)\ndrivers/net/pcs/pcs-xpcs-plat.c-192-{\ndrivers/net/pcs/pcs-xpcs-plat.c:193:\tstruct dw_xpcs_plat *pxpcs = bus-\u003epriv;\ndrivers/net/pcs/pcs-xpcs-plat.c-194-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-198-\tif (pxpcs-\u003ereg_indir)\ndrivers/net/pcs/pcs-xpcs-plat.c:199:\t\treturn xpcs_mmio_read_reg_indirect(pxpcs, dev, reg);\ndrivers/net/pcs/pcs-xpcs-plat.c-200-\telse\ndrivers/net/pcs/pcs-xpcs-plat.c:201:\t\treturn xpcs_mmio_read_reg_direct(pxpcs, dev, reg);\ndrivers/net/pcs/pcs-xpcs-plat.c-202-}\ndrivers/net/pcs/pcs-xpcs-plat.c-203-\ndrivers/net/pcs/pcs-xpcs-plat.c:204:static int xpcs_mmio_write_c45(struct mii_bus *bus, int addr, int dev,\ndrivers/net/pcs/pcs-xpcs-plat.c-205-\t\t\t int reg, u16 val)\ndrivers/net/pcs/pcs-xpcs-plat.c-206-{\ndrivers/net/pcs/pcs-xpcs-plat.c:207:\tstruct dw_xpcs_plat *pxpcs = bus-\u003epriv;\ndrivers/net/pcs/pcs-xpcs-plat.c-208-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-212-\tif (pxpcs-\u003ereg_indir)\ndrivers/net/pcs/pcs-xpcs-plat.c:213:\t\treturn xpcs_mmio_write_reg_indirect(pxpcs, dev, reg, val);\ndrivers/net/pcs/pcs-xpcs-plat.c-214-\telse\ndrivers/net/pcs/pcs-xpcs-plat.c:215:\t\treturn xpcs_mmio_write_reg_direct(pxpcs, dev, reg, val);\ndrivers/net/pcs/pcs-xpcs-plat.c-216-}\ndrivers/net/pcs/pcs-xpcs-plat.c-217-\ndrivers/net/pcs/pcs-xpcs-plat.c:218:static struct dw_xpcs_plat *xpcs_plat_create_data(struct platform_device *pdev)\ndrivers/net/pcs/pcs-xpcs-plat.c-219-{\ndrivers/net/pcs/pcs-xpcs-plat.c:220:\tstruct dw_xpcs_plat *pxpcs;\ndrivers/net/pcs/pcs-xpcs-plat.c-221-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-232-\ndrivers/net/pcs/pcs-xpcs-plat.c:233:static int xpcs_plat_init_res(struct dw_xpcs_plat *pxpcs)\ndrivers/net/pcs/pcs-xpcs-plat.c-234-{\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-277-\ndrivers/net/pcs/pcs-xpcs-plat.c:278:static int xpcs_plat_init_clk(struct dw_xpcs_plat *pxpcs)\ndrivers/net/pcs/pcs-xpcs-plat.c-279-{\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-297-\ndrivers/net/pcs/pcs-xpcs-plat.c:298:static int xpcs_plat_init_bus(struct dw_xpcs_plat *pxpcs)\ndrivers/net/pcs/pcs-xpcs-plat.c-299-{\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-308-\tpxpcs-\u003ebus-\u003ename = \"DW XPCS MCI/APB3\";\ndrivers/net/pcs/pcs-xpcs-plat.c:309:\tpxpcs-\u003ebus-\u003eread = xpcs_mmio_read_c22;\ndrivers/net/pcs/pcs-xpcs-plat.c:310:\tpxpcs-\u003ebus-\u003ewrite = xpcs_mmio_write_c22;\ndrivers/net/pcs/pcs-xpcs-plat.c:311:\tpxpcs-\u003ebus-\u003eread_c45 = xpcs_mmio_read_c45;\ndrivers/net/pcs/pcs-xpcs-plat.c:312:\tpxpcs-\u003ebus-\u003ewrite_c45 = xpcs_mmio_write_c45;\ndrivers/net/pcs/pcs-xpcs-plat.c-313-\tpxpcs-\u003ebus-\u003ephy_mask = ~0;\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-336- */\ndrivers/net/pcs/pcs-xpcs-plat.c:337:static int xpcs_plat_init_dev(struct dw_xpcs_plat *pxpcs)\ndrivers/net/pcs/pcs-xpcs-plat.c-338-{\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-372-\ndrivers/net/pcs/pcs-xpcs-plat.c:373:static int xpcs_plat_probe(struct platform_device *pdev)\ndrivers/net/pcs/pcs-xpcs-plat.c-374-{\ndrivers/net/pcs/pcs-xpcs-plat.c:375:\tstruct dw_xpcs_plat *pxpcs;\ndrivers/net/pcs/pcs-xpcs-plat.c-376-\tint ret;\ndrivers/net/pcs/pcs-xpcs-plat.c-377-\ndrivers/net/pcs/pcs-xpcs-plat.c:378:\tpxpcs = xpcs_plat_create_data(pdev);\ndrivers/net/pcs/pcs-xpcs-plat.c-379-\tif (IS_ERR(pxpcs))\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-381-\ndrivers/net/pcs/pcs-xpcs-plat.c:382:\tret = xpcs_plat_init_res(pxpcs);\ndrivers/net/pcs/pcs-xpcs-plat.c-383-\tif (ret)\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-385-\ndrivers/net/pcs/pcs-xpcs-plat.c:386:\tret = xpcs_plat_init_clk(pxpcs);\ndrivers/net/pcs/pcs-xpcs-plat.c-387-\tif (ret)\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-389-\ndrivers/net/pcs/pcs-xpcs-plat.c:390:\tret = xpcs_plat_init_bus(pxpcs);\ndrivers/net/pcs/pcs-xpcs-plat.c-391-\tif (ret)\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-393-\ndrivers/net/pcs/pcs-xpcs-plat.c:394:\tret = xpcs_plat_init_dev(pxpcs);\ndrivers/net/pcs/pcs-xpcs-plat.c-395-\tif (ret)\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-400-\ndrivers/net/pcs/pcs-xpcs-plat.c:401:static int __maybe_unused xpcs_plat_pm_runtime_suspend(struct device *dev)\ndrivers/net/pcs/pcs-xpcs-plat.c-402-{\ndrivers/net/pcs/pcs-xpcs-plat.c:403:\tstruct dw_xpcs_plat *pxpcs = dev_get_drvdata(dev);\ndrivers/net/pcs/pcs-xpcs-plat.c-404-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-409-\ndrivers/net/pcs/pcs-xpcs-plat.c:410:static int __maybe_unused xpcs_plat_pm_runtime_resume(struct device *dev)\ndrivers/net/pcs/pcs-xpcs-plat.c-411-{\ndrivers/net/pcs/pcs-xpcs-plat.c:412:\tstruct dw_xpcs_plat *pxpcs = dev_get_drvdata(dev);\ndrivers/net/pcs/pcs-xpcs-plat.c-413-\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-416-\ndrivers/net/pcs/pcs-xpcs-plat.c:417:static const struct dev_pm_ops xpcs_plat_pm_ops = {\ndrivers/net/pcs/pcs-xpcs-plat.c:418:\tSET_RUNTIME_PM_OPS(xpcs_plat_pm_runtime_suspend,\ndrivers/net/pcs/pcs-xpcs-plat.c:419:\t\t\t xpcs_plat_pm_runtime_resume,\ndrivers/net/pcs/pcs-xpcs-plat.c-420-\t\t\t NULL)\n--\ndrivers/net/pcs/pcs-xpcs-plat.c-422-\ndrivers/net/pcs/pcs-xpcs-plat.c:423:DW_XPCS_INFO_DECLARE(xpcs_generic, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_ID_NATIVE);\ndrivers/net/pcs/pcs-xpcs-plat.c:424:DW_XPCS_INFO_DECLARE(xpcs_pma_gen1_3g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN1_3G_ID);\ndrivers/net/pcs/pcs-xpcs-plat.c:425:DW_XPCS_INFO_DECLARE(xpcs_pma_gen2_3g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN2_3G_ID);\ndrivers/net/pcs/pcs-xpcs-plat.c:426:DW_XPCS_INFO_DECLARE(xpcs_pma_gen2_6g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN2_6G_ID);\ndrivers/net/pcs/pcs-xpcs-plat.c:427:DW_XPCS_INFO_DECLARE(xpcs_pma_gen4_3g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN4_3G_ID);\ndrivers/net/pcs/pcs-xpcs-plat.c:428:DW_XPCS_INFO_DECLARE(xpcs_pma_gen4_6g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN4_6G_ID);\ndrivers/net/pcs/pcs-xpcs-plat.c:429:DW_XPCS_INFO_DECLARE(xpcs_pma_gen5_10g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN5_10G_ID);\ndrivers/net/pcs/pcs-xpcs-plat.c:430:DW_XPCS_INFO_DECLARE(xpcs_pma_gen5_12g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN5_12G_ID);\ndrivers/net/pcs/pcs-xpcs-plat.c-431-\ndrivers/net/pcs/pcs-xpcs-plat.c:432:static const struct of_device_id xpcs_of_ids[] = {\ndrivers/net/pcs/pcs-xpcs-plat.c:433:\t{ .compatible = \"snps,dw-xpcs\", .data = \u0026xpcs_generic },\ndrivers/net/pcs/pcs-xpcs-plat.c:434:\t{ .compatible = \"snps,dw-xpcs-gen1-3g\", .data = \u0026xpcs_pma_gen1_3g },\ndrivers/net/pcs/pcs-xpcs-plat.c:435:\t{ .compatible = \"snps,dw-xpcs-gen2-3g\", .data = \u0026xpcs_pma_gen2_3g },\ndrivers/net/pcs/pcs-xpcs-plat.c:436:\t{ .compatible = \"snps,dw-xpcs-gen2-6g\", .data = \u0026xpcs_pma_gen2_6g },\ndrivers/net/pcs/pcs-xpcs-plat.c:437:\t{ .compatible = \"snps,dw-xpcs-gen4-3g\", .data = \u0026xpcs_pma_gen4_3g },\ndrivers/net/pcs/pcs-xpcs-plat.c:438:\t{ .compatible = \"snps,dw-xpcs-gen4-6g\", .data = \u0026xpcs_pma_gen4_6g },\ndrivers/net/pcs/pcs-xpcs-plat.c:439:\t{ .compatible = \"snps,dw-xpcs-gen5-10g\", .data = \u0026xpcs_pma_gen5_10g },\ndrivers/net/pcs/pcs-xpcs-plat.c:440:\t{ .compatible = \"snps,dw-xpcs-gen5-12g\", .data = \u0026xpcs_pma_gen5_12g },\ndrivers/net/pcs/pcs-xpcs-plat.c-441-\t{ /* sentinel */ },\ndrivers/net/pcs/pcs-xpcs-plat.c-442-};\ndrivers/net/pcs/pcs-xpcs-plat.c:443:MODULE_DEVICE_TABLE(of, xpcs_of_ids);\ndrivers/net/pcs/pcs-xpcs-plat.c-444-\ndrivers/net/pcs/pcs-xpcs-plat.c:445:static struct platform_driver xpcs_plat_driver = {\ndrivers/net/pcs/pcs-xpcs-plat.c:446:\t.probe = xpcs_plat_probe,\ndrivers/net/pcs/pcs-xpcs-plat.c-447-\t.driver = {\ndrivers/net/pcs/pcs-xpcs-plat.c-448-\t\t.name = \"dwxpcs\",\ndrivers/net/pcs/pcs-xpcs-plat.c:449:\t\t.pm = \u0026xpcs_plat_pm_ops,\ndrivers/net/pcs/pcs-xpcs-plat.c:450:\t\t.of_match_table = xpcs_of_ids,\ndrivers/net/pcs/pcs-xpcs-plat.c-451-\t},\ndrivers/net/pcs/pcs-xpcs-plat.c-452-};\n\n"
} |
| 23/2 | 2026/10/09 00:01 | llm | patch-evaluator |
2mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39985 output: 46 thoughts: 35 Thoughts: Okay, let's dive into this. Here's my thought process regarding `dwmac-intel.c`: **Initial Assessment of `dwmac-intel.c`** Alright, I'm taking a look at `dwmac-intel.c`. My immediate question is whether this driver is actually handling any PCI IDs. That's always my starting point when looking at a driver, especially for something like a network interface. I need to understand what hardware this module is designed to support. The PCI ID is the most fundamental indicator, right? So, first, I need to confirm whether probing the PCI ID is part of the code's functionality. Let me quickly scan this file. |
| 24/2 | 2026/10/09 00:03 | tool | grepper |
0mArgs:{
"Expression": "INTEL_MGBE_XPCS_ADDR",
"PathPrefixes": [
"drivers/net/ethernet/stmicro/stmmac/"
]
}Results: {
"Output": "drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=616=static int intel_mgbe_common_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-733-\t plat-\u003ephy_interface == PHY_INTERFACE_MODE_1000BASEX) {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:734:\t\tplat-\u003emdio_bus_data-\u003epcs_mask = BIT_U32(INTEL_MGBE_XPCS_ADDR);\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-735-\t\tplat-\u003edefault_an_inband = true;\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-740-\tplat-\u003emdio_bus_data-\u003ephy_mask = 1 \u003c\u003c INTEL_MGBE_ADHOC_ADDR;\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:741:\tplat-\u003emdio_bus_data-\u003ephy_mask |= 1 \u003c\u003c INTEL_MGBE_XPCS_ADDR;\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-742-\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.h-36-#define INTEL_MGBE_ADHOC_ADDR\t0x15\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.h:37:#define INTEL_MGBE_XPCS_ADDR\t0x16\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.h-38-\n"
} |
| 25/2 | 2026/10/09 00:03 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40664 output: 41 thoughts: 1381 Thoughts: **WorthFuzzing Decision for PCS/XPCS Driver Changes** Okay, so I'm looking at these changes and the primary concern is whether or not they're actually *reachable* in a standard fuzzing setup using QEMU. First, let's establish: Does QEMU even *have* a MGBE PCI device or emulate anything using DW XPCS? My immediate thought is, no, it doesn't. Now, referring to the "REACHABILITY IS THE PRIMARY GATE" section of instructions. The critical negative criteria are: structurally unreachable hardware. This specifically calls out vendor-specific PCIe switches and NICs that require physical cards or ASICs not emulated in standard QEMU. That's where I need to focus. Looking at the code modifications, the changes are to `drivers/net/pcs/pcs-xpcs.c`. This file appears to be related to `dwmac-rk` or `pcs-xpcs-rk`. Checking those: `dwmac-rk` is a Rockchip Ethernet controller, an OF platform driver for Rockchip SoCs. `pcs-xpcs-rk` is also a Rockchip OF platform driver, this time for XPCS controllers. Both are ARM/ARM64 and require internal Rockchip registers that are not available on AMD64. They won't run in x86_64 or amd64 QEMU. The real question is whether the changes to `pcs-xpcs.c` itself are executed in amd64/QEMU, regardless of the Rockchip SoCs. The change is to the functions `xpcs_config_aneg_c37_sgmii` and `xpcs_get_state_c37_sgmii`. These functions involve writing to and reading from MDIO registers, specifically related to auto-negotiation (AN) for SGMII. I've got to look at which *other* drivers use `pcs-xpcs.c` to see if there is any chance of AMD64 execution in QEMU. I quickly go through the list: 1. `microchip/ksz9477.c`: DSA switch on SPI/I2C. Nope, not relevant for QEMU. 2. `sja1105/sja1105_mdio.c`: DSA switch on SPI. Also not relevant. 3. `meta/fbnic/fbnic_phylink.c`: Facebook NIC ASIC (PCI ID 0x1d9b). Definitely not in QEMU. 4. `wangxun/txgbe/txgbe_phy.c`: Wangxun 10G NIC ASIC (PCI ID 0x80886). Again, not QEMU-able. 5. `stmicro/stmmac/`: This needs investigation. I need to check every platform and PCI ID supported by STMMAC to see if any are relevant. Given what I've seen so far, it *looks* like these changes are *unlikely* to be reachable in a standard QEMU setup, but I can't yet definitively rule out STMMAC. I need to confirm the configuration of STMMAC before making a final judgment. |
| 26/2 | 2026/10/09 00:05 | tool | grepper |
0mError:no matches Args: {
"Expression": "pci_register_driver",
"PathPrefixes": [
"drivers/net/ethernet/stmicro/stmmac/"
]
}Results: {
"error": "no matches"
} |
| 27/2 | 2026/10/09 00:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42821 output: 40 thoughts: 15 Thoughts: Okay, here's my summarization of those thoughts, tailored for an expert audience, in the first person: **Navigating the STMMAC Driver for PCI Integration** Alright, so the initial thought process here is pretty straightforward. I'm diving into the STMMAC driver, presumably for some debugging, modification, or just general investigation. The specific focus is the integration with the PCI bus. Therefore, my immediate goal is to locate the `pci_driver` structure within the stmmac codebase. This is usually the entry point for understanding how the driver interacts with the PCI subsystem, handles device discovery, resource allocation, and initialization. Finding this will be crucial for the next steps, whether I'm trying to trace the device probe sequence, understand interrupt handling within the PCI context, or potentially adapt the driver for a new PCI-based Ethernet controller. Knowing where this structure lives is foundational to any deeper analysis of the PCI-specific aspects of this driver. |
| 28/2 | 2026/10/09 00:06 | tool | grepper |
0mArgs:{
"Expression": "struct pci_driver",
"PathPrefixes": [
"drivers/net/ethernet/stmicro/stmmac/"
]
}Results: {
"Output": "drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=1415=MODULE_DEVICE_TABLE(pci, intel_eth_pci_id_table);\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-1416-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:1417:static struct pci_driver intel_eth_pci_driver = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-1418-\t.name = \"intel-eth-pci\",\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c=602=MODULE_DEVICE_TABLE(pci, loongson_dwmac_id_table);\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-603-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c:604:static struct pci_driver loongson_dwmac_driver = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-605-\t.name = DRIVER_NAME,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c=371=MODULE_DEVICE_TABLE(pci, dwmac_motorcomm_pci_id_table);\ndrivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c-372-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c:373:static struct pci_driver dwmac_motorcomm_pci_driver = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c-374-\t.name = DRIVER_NAME,\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c=210=MODULE_DEVICE_TABLE(pci, stmmac_id_table);\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-211-\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:212:static struct pci_driver stmmac_pci_driver = {\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-213-\t.name = STMMAC_RESOURCE_NAME,\n"
} |
| 29/2 | 2026/10/09 00:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 43720 output: 50 thoughts: 22 Thoughts: Okay, let's dive into this. Here's my take on understanding `stmmac_pci.c`: **Dissecting `stmmac_pci.c`** Alright, time to crack open `stmmac_pci.c`. My immediate goal is to understand its role. I need to figure out what functionality this particular module provides within the broader STMMAC (STMicroelectronics Media Access Controller) driver framework. Specifically, I want to determine the types of hardware this file is responsible for supporting. I'm assuming, given the filename, that it handles the PCI (Peripheral Component Interconnect) variants of STMMAC-based network controllers. So, I need to get a clear picture of what specific devices this handles. Are we talking about a certain generation of STMMAC chips? Or perhaps a subset based on configuration or vendor ID? I'll probably be looking for device ID tables, probing functions, and any device-specific initialization code to confirm my initial hypothesis and gain a comprehensive view. The aim here is to see the exact devices that the driver supports and the mechanism used to do so. |
| 30/2 | 2026/10/09 00:06 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c",
"FirstLine": 145,
"LineCount": 70
}Results: {
"Contents": " 145:\t\tif (ret) {\n 146:\t\t\tdev_err(\u0026pdev-\u003edev, \"%s: ERROR: failed to enable device\\n\",\n 147:\t\t\t\t__func__);\n 148:\t\t\treturn ret;\n 149:\t\t}\n 150:\t\n 151:\t\t/* Get the base address of device */\n 152:\t\tfor (i = 0; i \u003c PCI_STD_NUM_BARS; i++) {\n 153:\t\t\tif (pci_resource_len(pdev, i) == 0)\n 154:\t\t\t\tcontinue;\n 155:\t\t\tres.addr = pcim_iomap_region(pdev, i, STMMAC_RESOURCE_NAME);\n 156:\t\t\tif (IS_ERR(res.addr))\n 157:\t\t\t\treturn PTR_ERR(res.addr);\n 158:\t\t\tbreak;\n 159:\t\t}\n 160:\t\n 161:\t\tpci_set_master(pdev);\n 162:\t\n 163:\t\tret = info-\u003esetup(pdev, plat);\n 164:\t\tif (ret)\n 165:\t\t\treturn ret;\n 166:\t\n 167:\t\tres.wol_irq = pdev-\u003eirq;\n 168:\t\tres.irq = pdev-\u003eirq;\n 169:\t\n 170:\t\tplat-\u003esafety_feat_cfg-\u003etsoee = 1;\n 171:\t\tplat-\u003esafety_feat_cfg-\u003emrxpee = 1;\n 172:\t\tplat-\u003esafety_feat_cfg-\u003emestee = 1;\n 173:\t\tplat-\u003esafety_feat_cfg-\u003emrxee = 1;\n 174:\t\tplat-\u003esafety_feat_cfg-\u003emtxee = 1;\n 175:\t\tplat-\u003esafety_feat_cfg-\u003eepsi = 1;\n 176:\t\tplat-\u003esafety_feat_cfg-\u003eedpp = 1;\n 177:\t\tplat-\u003esafety_feat_cfg-\u003eprtyen = 1;\n 178:\t\tplat-\u003esafety_feat_cfg-\u003etmouten = 1;\n 179:\t\n 180:\t\tplat-\u003esuspend = stmmac_pci_plat_suspend;\n 181:\t\tplat-\u003eresume = stmmac_pci_plat_resume;\n 182:\t\n 183:\t\treturn stmmac_dvr_probe(\u0026pdev-\u003edev, plat, \u0026res);\n 184:\t}\n 185:\t\n 186:\t/**\n 187:\t * stmmac_pci_remove\n 188:\t *\n 189:\t * @pdev: platform device pointer\n 190:\t * Description: this function calls the main to free the net resources.\n 191:\t */\n 192:\tstatic void stmmac_pci_remove(struct pci_dev *pdev)\n 193:\t{\n 194:\t\tstmmac_dvr_remove(\u0026pdev-\u003edev);\n 195:\t}\n 196:\t\n 197:\t/* synthetic ID, no official vendor */\n 198:\t#define PCI_VENDOR_ID_STMMAC\t\t0x0700\n 199:\t\n 200:\t#define PCI_DEVICE_ID_STMMAC_STMMAC\t\t0x1108\n 201:\t#define PCI_DEVICE_ID_SYNOPSYS_GMAC5_ID\t\t0x7102\n 202:\t\n 203:\tstatic const struct pci_device_id stmmac_id_table[] = {\n 204:\t\t{ PCI_DEVICE_DATA(STMMAC, STMMAC, \u0026stmmac_pci_info) },\n 205:\t\t{ PCI_DEVICE_DATA(STMICRO, MAC, \u0026stmmac_pci_info) },\n 206:\t\t{ PCI_DEVICE_DATA(SYNOPSYS, GMAC5_ID, \u0026snps_gmac5_pci_info) },\n 207:\t\t{}\n 208:\t};\n 209:\t\n 210:\tMODULE_DEVICE_TABLE(pci, stmmac_id_table);\n 211:\t\n 212:\tstatic struct pci_driver stmmac_pci_driver = {\n 213:\t\t.name = STMMAC_RESOURCE_NAME,\n 214:\t\t.id_table = stmmac_id_table,\n"
} |
| 31/2 | 2026/10/09 00:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 45200 output: 55 thoughts: 31 Thoughts: Here's my analysis of the provided text, rendered as a first-person expert summary: **Digging into PCI Ethernet Driver Initialization** Okay, so I'm looking at these two functions, `stmmac_pci_info` and `snps_gmac5_pci_info`. The implication is pretty clear: they're related to initializing PCI-based Ethernet controllers, specifically those built around either a STMicroelectronics MAC core or a Synopsys GMAC5 core. My immediate thought is, I need to understand what these functions *do*, and what data structures they interact with. I'll need to see how they're used in the driver's probe sequence, how they handle resource allocation from the PCI bus, and how they configure the underlying hardware. Are they just providing platform-specific data, or do they perform some of the low-level register writes? Are there any differences in initialization between the STMMAC and GMAC5 implementations that are addressed here? My suspicion is that they likely encapsulate the specific PCI device IDs, vendor IDs, and perhaps some initial configuration parameters relevant to each hardware block. I'll be interested to see how they handle potential quirks or silicon revisions, and whether they account for any specific performance optimizations that these cores may support when interfaced over the PCI bus. Time to dig into the code and see. |
| 32/2 | 2026/10/09 00:07 | tool | grepper |
0mArgs:{
"Expression": "stmmac_pci_info|snps_gmac5_pci_info",
"PathPrefixes": [
"drivers/net/ethernet/stmicro/stmmac/"
]
}Results: {
"Output": "drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=45=struct stmmac_pci_dmi_data {\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-49-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:50:struct stmmac_pci_info {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-51-\tint (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=786=static int ehl_sgmii_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-805-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:806:static struct stmmac_pci_info ehl_sgmii1g_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-807-\t.setup = ehl_sgmii_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=810=static int ehl_rgmii_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-820-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:821:static struct stmmac_pci_info ehl_rgmii1g_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-822-\t.setup = ehl_rgmii_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=841=static int ehl_pse0_rgmii1g_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-847-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:848:static struct stmmac_pci_info ehl_pse0_rgmii1g_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-849-\t.setup = ehl_pse0_rgmii1g_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=852=static int ehl_pse0_sgmii1g_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-869-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:870:static struct stmmac_pci_info ehl_pse0_sgmii1g_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-871-\t.setup = ehl_pse0_sgmii1g_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=890=static int ehl_pse1_rgmii1g_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-896-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:897:static struct stmmac_pci_info ehl_pse1_rgmii1g_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-898-\t.setup = ehl_pse1_rgmii1g_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=901=static int ehl_pse1_sgmii1g_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-918-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:919:static struct stmmac_pci_info ehl_pse1_sgmii1g_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-920-\t.setup = ehl_pse1_sgmii1g_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=944=static int tgl_sgmii_phy0_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-952-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:953:static struct stmmac_pci_info tgl_sgmii1g_phy0_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-954-\t.setup = tgl_sgmii_phy0_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=957=static int tgl_sgmii_phy1_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-965-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:966:static struct stmmac_pci_info tgl_sgmii1g_phy1_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-967-\t.setup = tgl_sgmii_phy1_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=970=static int adls_sgmii_phy0_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-979-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:980:static struct stmmac_pci_info adls_sgmii1g_phy0_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-981-\t.setup = adls_sgmii_phy0_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=984=static int adls_sgmii_phy1_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-993-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:994:static struct stmmac_pci_info adls_sgmii1g_phy1_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-995-\t.setup = adls_sgmii_phy1_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=1023=static int adln_sgmii_phy0_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-1041-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:1042:static struct stmmac_pci_info adln_sgmii1g_phy0_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-1043-\t.setup = adln_sgmii_phy0_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=1109=static int quark_default_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-1144-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:1145:static const struct stmmac_pci_info quark_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-1146-\t.setup = quark_default_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c=1263=static int intel_eth_pci_probe(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-1265-{\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:1266:\tstruct stmmac_pci_info *info = (struct stmmac_pci_info *)id-\u003edriver_data;\ndrivers/net/ethernet/stmicro/stmmac/dwmac-intel.c-1267-\tstruct intel_priv_data *intel_priv;\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c=76=struct loongson_data {\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-81-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c:82:struct stmmac_pci_info {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-83-\tint (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c=132=static int loongson_gmac_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-141-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c:142:static struct stmmac_pci_info loongson_gmac_pci_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-143-\t.setup = loongson_gmac_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c=165=static int loongson_gnet_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-176-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c:177:static struct stmmac_pci_info loongson_gnet_pci_info = {\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-178-\t.setup = loongson_gnet_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c=498=static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id *id)\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-501-\tstruct stmmac_resources res = {};\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c:502:\tstruct stmmac_pci_info *info;\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-503-\tstruct loongson_data *ld;\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-542-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c:543:\tinfo = (struct stmmac_pci_info *)id-\u003edriver_data;\ndrivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c-544-\tret = info-\u003esetup(pdev, plat);\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-18-\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:19:struct stmmac_pci_info {\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-20-\tint (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c=33=static int stmmac_default_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-49-\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:50:static const struct stmmac_pci_info stmmac_pci_info = {\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-51-\t.setup = stmmac_default_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c=54=static int snps_gmac5_default_data(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-101-\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:102:static const struct stmmac_pci_info snps_gmac5_pci_info = {\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-103-\t.setup = snps_gmac5_default_data,\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c=118=static int stmmac_pci_probe(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-120-{\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:121:\tstruct stmmac_pci_info *info = (struct stmmac_pci_info *)id-\u003edriver_data;\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-122-\tstruct plat_stmmacenet_data *plat;\n--\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c=203=static const struct pci_device_id stmmac_id_table[] = {\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:204:\t{ PCI_DEVICE_DATA(STMMAC, STMMAC, \u0026stmmac_pci_info) },\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:205:\t{ PCI_DEVICE_DATA(STMICRO, MAC, \u0026stmmac_pci_info) },\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:206:\t{ PCI_DEVICE_DATA(SYNOPSYS, GMAC5_ID, \u0026snps_gmac5_pci_info) },\ndrivers/net/ethernet/stmicro/stmmac/stmmac_pci.c-207-\t{}\n"
} |
| 33/2 | 2026/10/09 00:07 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49602 output: 49 thoughts: 39 Thoughts: Okay, let's dive into this. Here's how I'd approach understanding the code, thinking out loud as if I were exploring it myself: **Investigating `snps_gmac5_default_data` and `stmmac_default_data`** Alright, I need to get a clear picture of how this `stmmac_pci.c` file works. My primary focus right now is to understand the role of `snps_gmac5_default_data` and `stmmac_default_data` within it. So, I'll start by looking for their definitions and where they're being *used*. Are these structures? Constants? Configuration options? My experience tells me that these types of named variables often represent default configurations or data structures specific to different hardware implementations within the `stmmac` family. I'll need to see how they interact with the PCI setup – are they being passed to initialization functions? Are they used in resource allocation or register mapping? Knowing the context of their use is key to understanding their purpose. Once I understand the definitions, I will look at where they are used within the code. Then, I need to get a picture of the relationship between them and how the PCI interface impacts their use. |
| 34/2 | 2026/10/09 00:07 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c",
"FirstLine": 33,
"LineCount": 70
}Results: {
"Contents": " 33:\tstatic int stmmac_default_data(struct pci_dev *pdev,\n 34:\t\t\t\t struct plat_stmmacenet_data *plat)\n 35:\t{\n 36:\t\t/* Set common default data first */\n 37:\t\tcommon_default_data(plat);\n 38:\t\n 39:\t\tplat-\u003ebus_id = 1;\n 40:\t\tplat-\u003ephy_addr = 0;\n 41:\t\tplat-\u003ephy_interface = PHY_INTERFACE_MODE_GMII;\n 42:\t\n 43:\t\tplat-\u003edma_cfg-\u003epbl = 32;\n 44:\t\tplat-\u003edma_cfg-\u003epblx8 = true;\n 45:\t\t/* TODO: AXI */\n 46:\t\n 47:\t\treturn 0;\n 48:\t}\n 49:\t\n 50:\tstatic const struct stmmac_pci_info stmmac_pci_info = {\n 51:\t\t.setup = stmmac_default_data,\n 52:\t};\n 53:\t\n 54:\tstatic int snps_gmac5_default_data(struct pci_dev *pdev,\n 55:\t\t\t\t\t struct plat_stmmacenet_data *plat)\n 56:\t{\n 57:\t\tint i;\n 58:\t\n 59:\t\tplat-\u003eclk_csr = STMMAC_CSR_250_300M;\n 60:\t\tplat-\u003ecore_type = DWMAC_CORE_GMAC4;\n 61:\t\tplat-\u003eforce_sf_dma_mode = true;\n 62:\t\tplat-\u003eflags |= STMMAC_FLAG_TSO_EN;\n 63:\t\tplat-\u003epmt = true;\n 64:\t\n 65:\t\t/* Set default number of RX and TX queues to use */\n 66:\t\tplat-\u003etx_queues_to_use = 4;\n 67:\t\tplat-\u003erx_queues_to_use = 4;\n 68:\t\n 69:\t\tplat-\u003etx_sched_algorithm = MTL_TX_ALGORITHM_WRR;\n 70:\t\tfor (i = 0; i \u003c plat-\u003etx_queues_to_use; i++) {\n 71:\t\t\tplat-\u003etx_queues_cfg[i].mode_to_use = MTL_QUEUE_DCB;\n 72:\t\t\tplat-\u003etx_queues_cfg[i].weight = 25;\n 73:\t\t\tif (i \u003e 0)\n 74:\t\t\t\tplat-\u003etx_queues_cfg[i].tbs_en = 1;\n 75:\t\t}\n 76:\t\n 77:\t\tplat-\u003erx_sched_algorithm = MTL_RX_ALGORITHM_SP;\n 78:\t\tfor (i = 0; i \u003c plat-\u003erx_queues_to_use; i++)\n 79:\t\t\tplat-\u003erx_queues_cfg[i].mode_to_use = MTL_QUEUE_DCB;\n 80:\t\n 81:\t\tplat-\u003ebus_id = 1;\n 82:\t\tplat-\u003ephy_interface = PHY_INTERFACE_MODE_GMII;\n 83:\t\n 84:\t\tplat-\u003edma_cfg-\u003epbl = 32;\n 85:\t\tplat-\u003edma_cfg-\u003epblx8 = true;\n 86:\t\n 87:\t\t/* Axi Configuration */\n 88:\t\tplat-\u003eaxi = devm_kzalloc(\u0026pdev-\u003edev, sizeof(*plat-\u003eaxi), GFP_KERNEL);\n 89:\t\tif (!plat-\u003eaxi)\n 90:\t\t\treturn -ENOMEM;\n 91:\t\n 92:\t\tplat-\u003eaxi-\u003eaxi_wr_osr_lmt = 31;\n 93:\t\tplat-\u003eaxi-\u003eaxi_rd_osr_lmt = 31;\n 94:\t\n 95:\t\tplat-\u003eaxi-\u003eaxi_fb = false;\n 96:\t\tplat-\u003eaxi-\u003eaxi_blen_regval = DMA_AXI_BLEN4 | DMA_AXI_BLEN8 |\n 97:\t\t\t\t\t DMA_AXI_BLEN16 | DMA_AXI_BLEN32;\n 98:\t\n 99:\t\treturn 0;\n 100:\t}\n 101:\t\n 102:\tstatic const struct stmmac_pci_info snps_gmac5_pci_info = {\n"
} |
| 35/2 | 2026/10/09 00:07 | llm | patch-evaluator |
3mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 51088 output: 152 thoughts: 1819 Thoughts: **Unreachable Code Analysis** Okay, so here's the deal. I've gone through this patch series with a fine-toothed comb, and based on my understanding, this is structurally unreachable code when running QEMU on an amd64 system. Here’s the breakdown of my thought process: First, I noted that the default configurations for `stmmac` and `snps_gmac5` don't seem to configure XPCS, opting for GMII instead. Also, that Synopsys GMAC5 on a PCI prototype board isn't emulated in QEMU. Then, I took a look at what devices *are* emulated. Nothing I could find – USB netdev, virtual devices like virtio-net, or even the standard QEMU PCI network cards – utilizes `dw_xpcs` or any `phylink` dependencies. Then, I meticulously went through the modified files in the patch: DT bindings, MAINTAINERS file, Kconfig files, and the driver code itself (`dwmac-rk.c`, `pcs-xpcs-rk.c`, and `pcs-xpcs.c`). The `dwmac-rk.c` and `pcs-xpcs-rk.c` files are, from what I've seen, specifically tied to Rockchip RK3568 hardware. They depend on Rockchip-specific registers, clocks, and power domains, none of which exist or are accessible in a standard QEMU amd64 environment. The `pcs-xpcs.c` changes are related to Synopsys DW XPCS, but, as I pointed out earlier, this is only used with very specific hardware -- like that RK3568, Intel MGBE, or various other ASICs/switches (Wangxun, Meta fbnic, Microchip/NXP). None of these are present or emulated in the environment. Finally, I checked against Section 2. The changes are all tied to vendor-specific hardware, and unreachable execution paths, like driver teardown which is triggered in a physical hot-unplug event, or platform-specific ARM code. The target architecture is amd64. Therefore, since the modified code either requires Rockchip RK3568 hardware or the DW XPCS on specific ASICs, and neither are emulated or accessible on amd64 QEMU or in a syzkaller context, this code path is unreachable. That means `WorthFuzzing` should be false. The focus symbols are non-existent, and the enable configurations are also non-existent. In summary: * `WorthFuzzing`: false * `FocusSymbols`: \[ ] * `EnableConfigs`: \[ ] I'll call `set-results` with this information now. |
| 36/2 | 2026/10/09 00:10 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The patch series introduces a Rockchip RK3568 Ethernet XPCS (Physical Coding Sublayer) platform driver and updates the Synopsys DW XPCS SGMII auto-negotiation logic for Rockchip integration. The modified code resides in Rockchip SoC-specific platform drivers and the Synopsys DW XPCS driver, which requires physical SoC/ASIC hardware (Rockchip, Wangxun, Intel MGBE, Meta fbnic, or DSA switches) not emulated in standard virtualized QEMU environments on amd64. Consequently, the modified code is structurally unreachable.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch series introduces a Rockchip RK3568 Ethernet XPCS (Physical Coding Sublayer) platform driver and updates the Synopsys DW XPCS SGMII auto-negotiation logic for Rockchip integration. The modified code resides in Rockchip SoC-specific platform drivers and the Synopsys DW XPCS driver, which requires physical SoC/ASIC hardware (Rockchip, Wangxun, Intel MGBE, Meta fbnic, or DSA switches) not emulated in standard virtualized QEMU environments on amd64. Consequently, the modified code is structurally unreachable.",
"WorthFuzzing": false
} |
| 37/1 | 2026/10/09 00:10 | action | If |
0mArgs:{
"WorthFuzzing": false
}Results: null |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|