| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/18 02:49 | flow | patch-triage |
3mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "The patch adds driver support for the Motorcomm YT8824 quad-port Ethernet PHY in drivers/net/phy/motorcomm.c and adds a C45 template testmode helper function in drivers/net/phy/phy-c45.c (which is only referenced by the YT8824 driver). The YT8824 driver requires physical Motorcomm hardware and Device Tree configuration (via devm_of_phy_package_join), neither of which exists or is emulated in standard QEMU/GCE virtualized environments on amd64. The change in ytphy_set_wol is a control-flow no-op jumping to the immediately adjacent label in the same unreachable driver. Therefore, the modified code is structurally unreachable and not worth fuzzing.",
"WorthFuzzing": false
} |
| 1/1 | 2026/10/18 02:49 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 2a4ea54257fb6c756ddc73b32d66516c4451c828\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sun Oct 18 02:49:44 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml b/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml\nnew file mode 100644\nindex 0000000000000..4c67f8afcf27a\n--- /dev/null\n+++ b/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml\n@@ -0,0 +1,78 @@\n+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)\n+%YAML 1.2\n+---\n+$id: http://devicetree.org/schemas/net/motorcomm,yt8824.yaml#\n+$schema: http://devicetree.org/meta-schemas/core.yaml#\n+\n+title: MotorComm YT8824 Ethernet PHY\n+\n+maintainers:\n+ - Kyle Switch \u003ckyle.switch@motor-comm.com\u003e\n+\n+description:\n+ Motorcomm YT8824 Ethernet PHY is a PHY package of 4 PHYs.\n+\n+$ref: ethernet-phy-package.yaml#\n+\n+properties:\n+ compatible:\n+ enum:\n+ - motorcomm,yt8824-package\n+\n+ motorcomm,package-mode:\n+ description: |\n+ PHY package can be configured in 2 modes:\n+ - internal: YT8824 is embedded in the switch, using\n+ an internal interface to the MAC.\n+ - 10g-qxgmii: YT8824 is a standalone external PHY,\n+ connected via 10G QXGMII.\n+ $ref: /schemas/types.yaml#/definitions/string\n+ enum: [ internal, 10g-qxgmii ]\n+\n+ reg:\n+ description:\n+ The absolute MDIO address of the YT8824 shared top extend\n+ register block.\n+ For internal mode, this is fixed at 9;\n+ For external mode, it is the base MDIO address of the four\n+ member PHYs plus 4, where base is typically 0x0.\n+ Note that this is NOT the reg of the first member PHY.\n+\n+required:\n+ - compatible\n+ - motorcomm,package-mode\n+ - reg\n+\n+unevaluatedProperties: false\n+\n+examples:\n+ - |\n+ mdio {\n+ #address-cells = \u003c1\u003e;\n+ #size-cells = \u003c0\u003e;\n+\n+ ethernet-phy-package@9 {\n+ #address-cells = \u003c1\u003e;\n+ #size-cells = \u003c0\u003e;\n+ compatible = \"motorcomm,yt8824-package\";\n+ reg = \u003c9\u003e;\n+\n+ motorcomm,package-mode = \"internal\";\n+\n+ ethernet-phy@4 {\n+ reg = \u003c4\u003e;\n+ };\n+\n+ ethernet-phy@5 {\n+ reg = \u003c5\u003e;\n+ };\n+\n+ ethernet-phy@6 {\n+ reg = \u003c6\u003e;\n+ };\n+\n+ ethernet-phy@7 {\n+ reg = \u003c7\u003e;\n+ };\n+ };\n+ };\ndiff --git a/MAINTAINERS b/MAINTAINERS\nindex 23e9194483d9b..ac8e12e7b8392 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -18424,8 +18424,10 @@ F:\tdrivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c\n \n MOTORCOMM PHY DRIVER\n M:\tFrank \u003cFrank.Sae@motor-comm.com\u003e\n+M:\tKyle Switch \u003ckyle.switch@motor-comm.com\u003e\n L:\tnetdev@vger.kernel.org\n S:\tMaintained\n+F:\tDocumentation/devicetree/bindings/net/motorcomm,yt8824.yaml\n F:\tDocumentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml\n F:\tdrivers/net/phy/motorcomm.c\n \ndiff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig\nindex 30e9d22c8d1a3..04593a770e433 100644\n--- a/drivers/net/phy/Kconfig\n+++ b/drivers/net/phy/Kconfig\n@@ -361,10 +361,12 @@ config MICROSEMI_PHY\n \n config MOTORCOMM_PHY\n \ttristate \"Motorcomm PHYs\"\n+\tselect PHY_PACKAGE\n \thelp\n \t Enables support for Motorcomm network PHYs.\n \t Currently supports YT85xx Gigabit Ethernet PHYs, YT861x PHYs\n-\t integrated in YT921x switches, and YT8821 2.5Gbps PHYs.\n+\t integrated in YT921x switches, YT8821 2.5Gbps PHYs and YT8824 4 * 2.5G\n+\t PHYs.\n \n config NATIONAL_PHY\n \ttristate \"National Semiconductor PHYs\"\ndiff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c\nindex 463e1ea3efc93..6628ebcca0819 100644\n--- a/drivers/net/phy/motorcomm.c\n+++ b/drivers/net/phy/motorcomm.c\n@@ -1,19 +1,25 @@\n // SPDX-License-Identifier: GPL-2.0+\n /*\n- * Motorcomm 8511/8521/8522/8531/8531S/861x/8821 PHY driver.\n+ * Motorcomm 8511/8521/8522/8531/8531S/861x/8821/8824 PHY driver.\n *\n * Author: Peter Geis \u003cpgwipeout@gmail.com\u003e\n * Author: Frank \u003cFrank.Sae@motor-comm.com\u003e\n+ * Author: Kyle \u003ckyle.switch@motor-comm.com\u003e\n */\n \n #include \u003clinux/clk.h\u003e\n #include \u003clinux/etherdevice.h\u003e\n #include \u003clinux/ethtool_netlink.h\u003e\n #include \u003clinux/kernel.h\u003e\n+#include \u003clinux/mdio.h\u003e\n #include \u003clinux/module.h\u003e\n+#include \u003clinux/of.h\u003e\n+#include \u003clinux/of_net.h\u003e\n #include \u003clinux/phy.h\u003e\n #include \u003clinux/property.h\u003e\n \n+#include \"phylib.h\"\n+\n #define PHY_ID_YT8511\t\t0x0000010a\n #define PHY_ID_YT8521\t\t0x0000011a\n #define PHY_ID_YT8522\t\t0x4f51e928\n@@ -22,6 +28,7 @@\n /* Live captured from YT921x switch internal MDIO bus */\n #define PHY_ID_INT861X\t\t0x01e04281\n #define PHY_ID_YT8821\t\t0x4f51ea19\n+#define PHY_ID_YT8824\t\t0x4f51e8b8\n /* YT8521/YT8531S/YT8821 Register Overview\n *\tUTP Register space\t|\tFIBER Register space\n * ------------------------------------------------------------\n@@ -33,6 +40,18 @@\n * ------------------------------------------------------------\n */\n \n+/* YT8824 Register Overview\n+ * UTP Register space\t| SERDES Register space\n+ * ------------------------------------------------------------\n+ * | UTP MII\t\t| SERDES MII\t\t|\n+ * | UTP MMD\t\t|\t\t\t|\n+ * | UTP Extended\t| SERDES Extended\t|\n+ * | UTP Top Extended\t| SERDES Top Extended\t|\n+ * ------------------------------------------------------------\n+ * | Common Top Extended\t\t\t|\n+ * ------------------------------------------------------------\n+ */\n+\n /* 0x10 ~ 0x15 , 0x1E and 0x1F are common MII registers of yt phy */\n \n /* Specific Function Control Register */\n@@ -397,6 +416,226 @@\n #define YT8821_CHIP_MODE_AUTO_BX2500_SGMII\t0\n #define YT8821_CHIP_MODE_FORCE_BX2500\t\t1\n \n+#define YT8824_RSSR_SPACE_MASK\t\t\tBIT(0)\n+#define YT8824_RSSR_SERDES_SPACE\t\t(0x1)\n+#define YT8824_RSSR_UTP_SPACE\t\t\t(0x0)\n+#define YT8824_SDS_CFG_MIN_PRE_MASK\t\tGENMASK(3, 0)\n+#define YT8824_SDS_EN_FILL_PRE\t\t\tBIT(13)\n+#define YT8824_SDS_TX_PRE_PADDING\t\t(0x7)\n+\n+/* PHY8824 UTP init registers */\n+#define YT8824_WRITE_PROTECT_CAL_REG\t\t0x1\n+#define YT8824_WRITE_PROTECT\t\t\tBIT(0)\n+#define YT8824_PLL_VCO_ATEMP_REG\t\t0xa20e\n+#define YT8824_PLL_VCO_SEL_CURRENT\t\tGENMASK(7, 4)\n+#define YT8824_PLL_VCO_SEL_CURRENT_B\t\t0xb\n+#define YT8824_PLL_PFD_CTRL_REG\t\t\t0xa20a\n+#define YT8824_PLL_VCO_ICOSTANT\t\t\tGENMASK(9, 4)\n+#define YT8824_PLL_VCO_ATEMP_1_REG\t\t0xa20c\n+#define YT8824_PLL_VCO_IPTAT\t\t\tGENMASK(5, 0)\n+#define YT8824_PLL_DAC_0_REG\t\t\t0xa2b6\n+#define YT8824_PLL_DAC_RST\t\t\tBIT(10)\n+#define YT8824_IF_CTRL_REG\t\t\t0xa003\n+#define YT8824_U0_U1_ENABLE_ODD_PREAMBLE\tGENMASK(1, 0)\n+#define YT8824_IDLE_CTRL_REG\t\t\t0x3d0\n+#define YT8824_IDLE_DETECT\t\t\tBIT(9)\n+#define YT8824_TRACE_GAIN_THR_REG\t\t0x372\n+#define YT8824_TRACE_LNG_GAIN_THR_2500\t\tGENMASK(14, 8)\n+#define YT8824_TRACE_MED_GAIN_THR_2500\t\tGENMASK(6, 0)\n+#define YT8824_PRM_LONG_REG\t\t\t0x37C\n+#define YT8824_PRM_LARGE_SLAVE_2500\t\tGENMASK(10, 0)\n+#define YT8824_PRM_SMALL_REG\t\t\t0x388\n+#define YT8824_PRM_SMALL_LNG_2500\t\tGENMASK(10, 0)\n+#define YT8824_FAST_RETRAIN_REG\t\t\t0x359\n+#define YT8824_LINK_FAIL_SIG\t\t\tGENMASK(13, 8)\n+#define YT8824_EN_GATE_CTRL_REG\t\t\t0xc\n+#define YT8824_EN_GATE_GMII_CLK\t\t\tBIT(0)\n+#define YT8824_DAC_CFG_REG\t\t\t0xa2fa\n+#define YT8824_POWER_SAVE\t\t\tGENMASK(15, 0)\n+#define YT8824_DAC_BIAS_CFG_REG\t\t\t0x4e2\n+#define YT8824_DAC_BIAS_CFG_2500\t\tGENMASK(9, 5)\n+#define YT8824_DAC_IMID_CFG_REG\t\t\t0x47e\n+#define YT8824_DAC_IMID_CH2\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMID_CH3\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMID_CFG1_REG\t\t0x47f\n+#define YT8824_DAC_IMID_CH0\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMID_CH1\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CFG_REG\t\t\t0x480\n+#define YT8824_DAC_IMSB_CH2\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CH3\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CFG1_REG\t\t0x481\n+#define YT8824_DAC_IMSB_CH0\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CH1\t\t\tGENMASK(14, 8)\n+#define YT8824_TRACE_LNG_GAIN_REG\t\t0x336\n+#define YT8824_TRACE_LNG_GAIN_THR\t\tGENMASK(14, 8)\n+#define YT8824_TRACE_MED_GAIN_REG\t\t0x340\n+#define YT8824_TRACE_MED_GAIN_THR\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMID_CH2_CH3_CFG_ORG_REG\t0x46e\n+#define YT8824_DAC_IMID_CH3_ORG\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMID_CH2_ORG\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMID_CH0_CH1_CFG_ORG_REG\t0x46f\n+#define YT8824_DAC_IMID_CH1_ORG\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMID_CH0_ORG\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CH2_CH3_CFG_ORG_REG\t0x470\n+#define YT8824_DAC_IMSB_CH3_ORG\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CH2_ORG\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CH0_CH1_CFG_ORG_REG\t0x471\n+#define YT8824_DAC_IMSB_CH1_ORG\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CH0_ORG\t\t\tGENMASK(6, 0)\n+#define YT8824_TRACE_LNG_GAIN_100_REG\t\t0x030b\n+#define YT8824_TRACE_LNG_GAIN_THR_100\t\tGENMASK(14, 8)\n+#define YT8824_TRACE_MED_GAIN_THR_100\t\tGENMASK(6, 0)\n+#define YT8824_CABLE_VSHT_REG\t\t\t0x071f\n+#define YT8824_CABLE_VSHT_THR_S\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_LPFIL_CH2_CH3_ADJ_REG\t0x046b\n+#define YT8824_DAC_LPFIL_ADJ_CH3_10\t\tGENMASK(12, 8)\n+#define YT8824_DAC_LPFIL_ADJ_CH2_10\t\tGENMASK(4, 0)\n+#define YT8824_DAC_LPFIL_CH0_CH1_ADJ_REG\t0x046c\n+#define YT8824_DAC_LPFIL_ADJ_CH1_10\t\tGENMASK(12, 8)\n+#define YT8824_DAC_LPFIL_ADJ_CH0_10\t\tGENMASK(4, 0)\n+#define YT8824_DAC_IMID_CFG_CH2_CH3_10_ORG\t0x0466\n+#define YT8824_DAC_IMID_CFG_CH3_10_ORG\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMID_CFG_CH2_10_ORG\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMID_CFG_CH0_CH1_10_ORG\t0x0467\n+#define YT8824_DAC_IMID_CFG_CH1_10_ORG\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMID_CFG_CH0_10_ORG\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CFG_CH2_CH3_10_ORG\t0x0468\n+#define YT8824_DAC_IMSB_CFG_CH3_10_ORG\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CFG_CH2_10_ORG\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CFG_CH0_CH1_10_ORG\t0x0469\n+#define YT8824_DAC_IMSB_CFG_CH1_10_ORG\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CFG_CH0_10_ORG\t\tGENMASK(6, 0)\n+#define YT8824_FFE_REG\t\t\t\t0x034a\n+#define YT8824_WAIT_TO_1000\t\t\tGENMASK(15, 8)\n+#define YT8824_FFE_SUM_THRES\t\t\tGENMASK(2, 0)\n+#define YT8824_EN_GATE_REG\t\t\t0x00f8\n+#define YT8824_EN_GATE_PHYDBG\t\t\tBIT(10)\n+#define YT8824_EN_GATE_BT1000\t\t\tBIT(9)\n+#define YT8824_CNT_REG\t\t\t\t0x0059\n+#define YT8824_CNT_ERR_AUTO\t\t\tBIT(14)\n+#define YT8824_PRM_LARGE_MASTER_REG\t\t0x032c\n+#define YT8824_PRM_LARGE_MASTER_1000\t\tGENMASK(10, 0)\n+#define YT8824_PRM_LARGE_SLAVE_REG\t\t0x032d\n+#define YT8824_PRM_LARGE_SLAVE_1000\t\tGENMASK(10, 0)\n+#define YT8824_SIG_GONE_REG\t\t\t0x032e\n+#define YT8824_SIG_GONE_THR_1000\t\tGENMASK(7, 0)\n+#define YT8824_EC_NX_TRAIN_COARSE_REG\t\t0x0322\n+#define YT8824_EC_NX_TRAIN_COARSE_TO_1000\tGENMASK(7, 0)\n+#define YT8824_VGA_IN_LPF2_CAP_REG\t\t0x04d3\n+#define YT8824_VGA_IN_LPF2_CAP_OTHER\t\tGENMASK(7, 4)\n+#define YT8824_VGA_IN_LPF1_CAP_REG\t\t0x04d2\n+#define YT8824_VGA_IN_LPF1_CAP_OTHER\t\tGENMASK(7, 4)\n+#define YT8824_LDPC_LFER_FAIL_REG\t\t0x00c8\n+#define YT8824_LDPC_FAIL_THR\t\t\tGENMASK(15, 8)\n+#define YT8824_LFER_FAIL_THR\t\t\tGENMASK(7, 0)\n+#define YT8824_FR_REQ_REG\t\t\t0x00be\n+#define YT8824_FR_REQ_THR\t\t\tGENMASK(4, 0)\n+#define YT8824_GN_MU_COARSE_REG\t\t\t0x037a\n+#define YT8824_PRM_SMALL_SHT_2500\t\tGENMASK(10, 0)\n+#define YT8824_DAC_AMP_ADJ_REG\t\t\t0x0482\n+#define YT8824_DAC_AMP_ADJ_CH3_PBO0_2500\tGENMASK(15, 12)\n+#define YT8824_DAC_AMP_ADJ_CH2_PBO0_2500\tGENMASK(11, 8)\n+#define YT8824_DAC_AMP_ADJ_CH1_PBO0_2500\tGENMASK(7, 4)\n+#define YT8824_DAC_AMP_ADJ_CH0_PBO0_2500\tGENMASK(3, 0)\n+#define YT8824_P0_DAC_BIAS_CAS_CH3_CH2_REG\t0xa2d5\n+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH3\t\tGENMASK(12, 8)\n+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH2\t\tGENMASK(4, 0)\n+#define YT8824_P0_DAC_BIAS_CAS_CH1_CH0_REG\t0xa2d6\n+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH1\t\tGENMASK(12, 8)\n+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH0\t\tGENMASK(4, 0)\n+#define YT8824_P1_DAC_BIAS_CAS_CH3_CH2_REG\t0xa2d7\n+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH3\t\tGENMASK(12, 8)\n+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH2\t\tGENMASK(4, 0)\n+#define YT8824_P1_DAC_BIAS_CAS_CH1_CH0_REG\t0xa2d8\n+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH1\t\tGENMASK(12, 8)\n+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH0\t\tGENMASK(4, 0)\n+#define YT8824_P01_PLL_EN_REG\t\t\t0xa218\n+#define YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET\tBIT(6)\n+#define YT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET\t\tBIT(5)\n+#define YT8824_U0_CSR_RESET_REG\t\t\t0xa01d\n+#define YT8824_U0_CSR_RESETB_TX_CH0\t\tBIT(3)\n+#define YT8824_U0_CSR_RESETB_TX_CH1\t\tBIT(2)\n+#define YT8824_U0_CSR_RESETB_TX_CH2\t\tBIT(1)\n+#define YT8824_U0_CSR_RESETB_TX_CH3\t\tBIT(0)\n+#define YT8824_U1_CSR_RESET_REG\t\t\t0xa01e\n+#define YT8824_U1_CSR_RESETB_TX_CH0\t\tBIT(3)\n+#define YT8824_U1_CSR_RESETB_TX_CH1\t\tBIT(2)\n+#define YT8824_U1_CSR_RESETB_TX_CH2\t\tBIT(1)\n+#define YT8824_U1_CSR_RESETB_TX_CH3\t\tBIT(0)\n+/* External PHY8824 serdes init registers */\n+#define YT8824_SERDES_PLL_CTRL1_REG\t\t0xa13e\n+#define YT8824_SERDES_PLL_CTRL2_REG\t\t0xa13f\n+#define YT8824_SERDES_PLL_CTRL3_REG\t\t0xa140\n+#define YT8824_WRITE_PROTECT_REG\t\t0x4be\n+#define YT8824_SERDES_REG_WR_PRT\t\tBIT(2)\n+#define YT8824_CSR_CTRL_REG\t\t\t0x49f\n+#define YT8824_CSR_PCS_GLB_RST_BYPASS\t\tBIT(10)\n+#define YT8824_CSR_SG_MODE_RST_BYPASS\t\tBIT(9)\n+#define YT8824_CSR_US_GLB_RESET_N\t\tBIT(7)\n+#define YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS\tBIT(2)\n+#define YT8824_CSR_PMA_CTRL_REG\t\t\t0x4a9\n+#define YT8824_CSR_WATCH_DOG_ALL_BYPASS\t\tBIT(7)\n+#define YT8824_CDR_CTRL_REG\t\t\t0x406\n+#define YT8824_CDR_MODE\t\t\t\tBIT(11)\n+#define YT8824_CSR_PLL_VCO_CTRL_REG\t\t0x438\n+#define YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT\tGENMASK(15, 12)\n+#define YT8824_CSR_PLL_VCO_ATEMP_R\t\tGENMASK(2, 0)\n+#define YT8824_CSR_PLL_DIVLDO_CTRL_REG\t\t0x439\n+#define YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R\tGENMASK(1, 0)\n+#define YT8824_CSR_PLL_FBDIV_REG\t\t0x043a\n+#define YT8824_CSR_PLL_FBDIV_SYNC_SELB\t\tBIT(1)\n+#define YT8824_CSR_PLL_SPARE_CTRL_REG\t\t0x042a\n+#define YT8824_CSR_PLL_SPARE\t\t\tGENMASK(15, 0)\n+#define YT8824_CDR_MANUAL_REG\t\t\t0x0491\n+#define YT8824_VDAC_AMP_THR_LNG\t\t\tGENMASK(6, 0)\n+#define YT8824_TRAINING_CTRL_REG\t\t0x0492\n+#define YT8824_VDAC_AMP_THR_MED\t\t\tGENMASK(14, 8)\n+#define YT8824_VDAC_AMP_THR_SHT\t\t\tGENMASK(7, 0)\n+#define YT8824_EOM_CTRL_REG\t\t\t0x0454\n+#define YT8824_EOD_DURATION_SEL\t\t\tGENMASK(11, 8)\n+#define YT8824_EOD_VTH\t\t\t\tGENMASK(6, 0)\n+#define YT8824_PGA_GAIN_CTRL_REG\t\t0x0497\n+#define YT8824_CDR_OFFSET_ERR_WTH\t\tGENMASK(14, 8)\n+#define YT8824_PGA_GAIN_MAX\t\t\tGENMASK(6, 4)\n+#define YT8824_PGA_GAIN_INIT\t\t\tGENMASK(2, 0)\n+#define YT8824_EOD_CTRL_REG\t\t\t0x04cd\n+#define YT8824_EOD_ERR_CNT_THR\t\t\tGENMASK(15, 0)\n+#define YT8824_CSR_AFE_CTRL_REG\t\t\t0x04af\n+#define YT8824_CSR_AFE_VCM_CFG\t\t\tGENMASK(10, 8)\n+#define YT8824_CSR_AFE_MANUAL_CTRL_1P25G\tBIT(4)\n+#define YT8824_CSR_AFE_MANUAL_CTRL_3P125G\tBIT(3)\n+#define YT8824_CSR_AFE_MANUAL_CTRL_10P3125G\tBIT(2)\n+#define YT8824_DFE_CTRL_REG\t\t\t0x048a\n+#define YT8824_DFE_TAP_POLARITY\t\t\tBIT(12)\n+#define YT8824_DFE_IDAC_TUNE\t\t\tGENMASK(11, 10)\n+#define YT8824_CSR_CDR_CTRL_REG\t\t\t0x0408\n+#define YT8824_CSR_CDR_OFFSET_DATA\t\tGENMASK(14, 8)\n+#define YT8824_DFE_VDAC_CODE_REG\t\t0x04d6\n+#define YT8824_DFE_VDAC_CODE_THR\t\t\tGENMASK(6, 0)\n+#define YT8824_RX_SPARE_CTRL_REG\t\t0x044f\n+#define YT8824_RX_SPARE_REG\t\t\tGENMASK(15, 0)\n+#define YT8824_DFE_VDAC_CTRL_REG\t\t0x048e\n+#define YT8824_DFE_VDAC_TUNE\t\t\tGENMASK(11, 10)\n+#define YT8824_DFE_VDAC_SEL\t\t\tGENMASK(9, 8)\n+#define YT8824_CSR_TX_PRE_REG\t\t\t0x000d\n+#define YT8824_CSR_TX_PRE_SEL\t\t\tGENMASK(4, 0)\n+#define YT8824_CSR_AFE_CTRL1_REG\t\t0x04b0\n+#define YT8824_CSR_AFE_CTLE_BW\t\t\tGENMASK(6, 4)\n+#define YT8824_CSR_AFE_CTRL2_REG\t\t0x04b1\n+#define YT8824_CSR_AFE_PGA_BW\t\t\tGENMASK(14, 12)\n+#define YT8824_CSR_AFE_BUF_BW\t\t\tGENMASK(6, 4)\n+#define YT8824_CSR_DCC_CAL_CTRL_REG\t\t0x0003\n+#define YT8824_CUR_TX_SEQ\t\t\tGENMASK(15, 12)\n+#define YT8824_CUR_RX_SEQ\t\t\tGENMASK(11, 8)\n+#define YT8824_CALIB_SEQ_FINISH\t\t\tBIT(1)\n+#define YT8824_CALIB_SEQ_SW_RST\t\t\tBIT(0)\n+#define YT8824_RESTART_CAL_CTRL_REG\t\t0x2000\n+#define YT8824_DAC_TRIM_MAIN_CFG_REG\t\t0x429\n+#define YT8824_PLL_VCO_CFG_REG\t\t\t0x441\n+#define YT8824_TX_MUX_CH3_CH2_REG\t\t0x42b\n+#define YT8824_C1_COARSE_CFG_REG\t\t0x4b4\n+#define YT8824_FFE_CTRL_REG\t\t\t0x4b5\n+\n struct yt8521_priv {\n \t/* combo_advertising is used for case of YT8521 in combo mode,\n \t * this means that yt8521 may work in utp or fiber mode which depends\n@@ -415,6 +654,14 @@ struct yt8521_priv {\n \tu8 reg_page;\n };\n \n+struct yt8824_shared_priv {\n+\tphy_interface_t package_mode;\n+\t/* shared_lock used to UTPs operation isolation during swap reg space */\n+\tstruct mutex shared_lock;\n+\t/* true once the package-wide SERDES init has been done */\n+\tbool sds_initialized;\n+};\n+\n /**\n * ytphy_read_ext() - read a PHY's extended register\n * @phydev: a pointer to a \u0026struct phy_device\n@@ -453,6 +700,70 @@ static int ytphy_read_ext_with_lock(struct phy_device *phydev, u16 regnum)\n \treturn ret;\n }\n \n+/**\n+ * ytphy_read_top_ext() - read a PHY's top extended register for YT8824\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @regnum: register number to read\n+ *\n+ * Returns: the value of regnum reg or negative error code\n+ */\n+static int ytphy_read_top_ext(struct phy_device *phydev, u16 regnum)\n+{\n+\tint ret;\n+\n+\tlockdep_assert_held(\u0026phydev-\u003emdio.bus-\u003emdio_lock);\n+\tret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn __phy_package_read(phydev, 0, YTPHY_PAGE_DATA);\n+}\n+\n+/**\n+ * ytphy_write_top_ext() - write a PHY's top extended register for YT8824\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @regnum: register number to write\n+ * @val: register val to write\n+ *\n+ * Returns: 0 or negative error code\n+ */\n+static int ytphy_write_top_ext(struct phy_device *phydev, u16 regnum,\n+\t\t\t u16 val)\n+{\n+\tint ret;\n+\n+\tlockdep_assert_held(\u0026phydev-\u003emdio.bus-\u003emdio_lock);\n+\tret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn __phy_package_write(phydev, 0, YTPHY_PAGE_DATA, val);\n+}\n+\n+/**\n+ * phy8824_page_write_with_lock() - write page for YT8824\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @page: reg page(YT8824_RSSR_SERDES_SPACE/YT8824_RSSR_UTP_SPACE).\n+ *\n+ * Returns: 0 or negative error code\n+ */\n+static int phy8824_page_write_with_lock(struct phy_device *phydev, int page)\n+{\n+\tint ret;\n+\n+\tphy_lock_mdio_bus(phydev);\n+\tret = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\tret \u0026= ~YT8824_RSSR_SPACE_MASK;\n+\tret |= (page \u0026 YT8824_RSSR_SPACE_MASK);\n+\tret = ytphy_write_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG, ret);\n+\n+err:\n+\tphy_unlock_mdio_bus(phydev);\n+\treturn ret;\n+}\n+\n /**\n * ytphy_write_ext() - write a PHY's extended register\n * @phydev: a pointer to a \u0026struct phy_device\n@@ -638,15 +949,1165 @@ static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)\n \t\tmask = YTPHY_WCR_ENABLE | YTPHY_WCR_INTR_SEL;\n \t\tret = ytphy_modify_ext(phydev, YTPHY_WOL_CONFIG_REG, mask, 0);\n \n-\t\t/* Disable WOL interrupt */\n-\t\tret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,\n-\t\t\t\t YTPHY_IER_WOL, 0);\n+\t\t/* Disable WOL interrupt */\n+\t\tret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,\n+\t\t\t\t YTPHY_IER_WOL, 0);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\t}\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_read_page() - read PHY8824 reg page\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: current reg space of yt8824 (YT8824_RSSR_SERDES_SPACE/\n+ * YT8824_RSSR_UTP_SPACE) or negative errno code\n+ */\n+static int yt8824_read_page(struct phy_device *phydev)\n+{\n+\tint old_page;\n+\n+\told_page = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);\n+\tif (old_page \u003c 0)\n+\t\treturn old_page;\n+\n+\treturn old_page \u0026 YT8824_RSSR_SPACE_MASK;\n+};\n+\n+/**\n+ * yt8824_write_page() - write reg page\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @page: Reg page(YT8824_RSSR_SERDES_SPACE/YT8824_RSSR_UTP_SPACE) to write.\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_write_page(struct phy_device *phydev, int page)\n+{\n+\tint old_page;\n+\tu16 data;\n+\n+\told_page = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);\n+\tif (old_page \u003c 0)\n+\t\treturn old_page;\n+\tdata = old_page \u0026 (~YT8824_RSSR_SPACE_MASK);\n+\tdata |= page;\n+\n+\treturn ytphy_write_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG, data);\n+};\n+\n+/**\n+ * yt8824_utp_set_template_test_mode() - config YT8824 UTP test mode.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @test_mode: template test mode from normal, testmode1 to testmode7\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_utp_set_template_test_mode(struct phy_device *phydev,\n+\t\t\t\t\t u16 test_mode)\n+{\n+\tint ret;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn genphy_c45_template_testmode(phydev, test_mode);\n+}\n+\n+/**\n+ * yt8824_sds_isolate_paged() - enable YT8824 serdes isolate.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_sds_isolate_paged(struct phy_device *phydev)\n+{\n+\tint old_page = YT8824_RSSR_UTP_SPACE;\n+\tint ret = 0;\n+\n+\told_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);\n+\tif (old_page \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* enable sds isolate */\n+\tret = __phy_modify(phydev, MII_BMCR, BMCR_ISOLATE, BMCR_ISOLATE);\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_utp_softreset_paged() - config YT8824 UTP softreset.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_utp_softreset_paged(struct phy_device *phydev)\n+{\n+\tint ret = 0;\n+\tint val;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = phy_modify(phydev, MII_BMCR, BMCR_RESET, BMCR_RESET);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* wait until softreset done. */\n+\treturn phy_read_poll_timeout(phydev, MII_BMCR, val, !(val \u0026 BMCR_RESET),\n+\t\t\t\t 50000, 600000, true);\n+}\n+\n+/**\n+ * yt8824_sds_isolate_and_softreset_paged() - disable YT8824 serdes isolate\n+ * and sds softreset.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_sds_isolate_and_softreset_paged(struct phy_device *phydev)\n+{\n+\tint old_page = YT8824_RSSR_UTP_SPACE;\n+\tint val = 0;\n+\tint ret = -1;\n+\n+\told_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);\n+\tif (old_page \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* sds softreset and disable isolate */\n+\tret = __phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ISOLATE,\n+\t\t\t BMCR_RESET \u0026 ~BMCR_ISOLATE);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* poll while still holding the lock */\n+\tret = read_poll_timeout(__phy_read, val,\n+\t\t\t\t(val \u003c 0) || !(val \u0026 BMCR_RESET), 50000, 600000,\n+\t\t\t\ttrue, phydev, MII_BMCR);\n+\tif (val \u003c 0)\n+\t\tret = val;\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_restore_working_status() - called to do store working status\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @ret: operation's return code\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_restore_working_status(struct phy_device *phydev, int ret)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint r;\n+\n+\tr = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\tif (priv-\u003epackage_mode != PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tr = yt8824_sds_isolate_and_softreset_paged(phydev);\n+\t\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\t\tret = r;\n+\t}\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_soft_reset() - called to do PHY software reset\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_soft_reset(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tif (priv-\u003epackage_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t} else {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_and_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t}\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\treturn ret;\n+retry:\n+\tret = yt8824_restore_working_status(phydev, ret);\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_config_utp_init_paged() - config external phy8824 utp init\n+ * @phydev: target phy_device struct\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_config_utp_init_paged(struct phy_device *phydev)\n+{\n+\tint ctrl = 0;\n+\tint mask = 0;\n+\tint ret = 0;\n+\tint val = 0;\n+\tint r;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* write protecting */\n+\tmask = YT8824_WRITE_PROTECT;\n+\tctrl = YT8824_WRITE_PROTECT;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_WRITE_PROTECT_CAL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* PLL calibration */\n+\tctrl = FIELD_PREP(YT8824_PLL_VCO_SEL_CURRENT, 0xb);\n+\tmask = YT8824_PLL_VCO_SEL_CURRENT;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PLL_VCO_ATEMP_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PLL_VCO_ICOSTANT, 0xf);\n+\tmask = YT8824_PLL_VCO_ICOSTANT;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PLL_PFD_CTRL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PLL_VCO_IPTAT, 0xf);\n+\tmask = YT8824_PLL_VCO_IPTAT;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PLL_VCO_ATEMP_1_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PLL_DAC_RST, 0);\n+\tmask = YT8824_PLL_DAC_RST;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PLL_DAC_0_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PLL_DAC_RST, 1);\n+\tmask = YT8824_PLL_DAC_RST;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PLL_DAC_0_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* enable nibble */\n+\tctrl = FIELD_PREP(YT8824_U0_U1_ENABLE_ODD_PREAMBLE, 3);\n+\tmask = YT8824_U0_U1_ENABLE_ODD_PREAMBLE;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_IF_CTRL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* idle err detect enable */\n+\tctrl = YT8824_IDLE_DETECT;\n+\tmask = YT8824_IDLE_DETECT;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_IDLE_CTRL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 2.5G long cable performance */\n+\tctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR_2500, 0x50);\n+\tctrl |= FIELD_PREP(YT8824_TRACE_MED_GAIN_THR_2500, 0x38);\n+\tmask = YT8824_TRACE_LNG_GAIN_THR_2500 |\n+\t YT8824_TRACE_MED_GAIN_THR_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_TRACE_GAIN_THR_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PRM_LARGE_SLAVE_2500, 0x68);\n+\tmask = YT8824_PRM_LARGE_SLAVE_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PRM_LONG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PRM_SMALL_LNG_2500, 0xa0);\n+\tmask = YT8824_PRM_SMALL_LNG_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PRM_SMALL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized fast retrain */\n+\tctrl = FIELD_PREP(YT8824_LINK_FAIL_SIG, 0x21);\n+\tmask = YT8824_LINK_FAIL_SIG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_FAST_RETRAIN_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_EN_GATE_GMII_CLK, 0);\n+\tmask = YT8824_EN_GATE_GMII_CLK;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_EN_GATE_CTRL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* 2.5G template tone */\n+\tctrl = FIELD_PREP(YT8824_POWER_SAVE, 0x83);\n+\tmask = YT8824_POWER_SAVE;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_CFG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_BIAS_CFG_2500, 0xa);\n+\tmask = YT8824_DAC_BIAS_CFG_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_BIAS_CFG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 2.5G template */\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CH2, 0x39);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CH3, 0x39);\n+\tmask = YT8824_DAC_IMID_CH2 | YT8824_DAC_IMID_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CFG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CH0, 0x39);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CH1, 0x39);\n+\tmask = YT8824_DAC_IMID_CH0 | YT8824_DAC_IMID_CH1;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CFG1_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CH2, 0x39);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH3, 0x39);\n+\tmask = YT8824_DAC_IMSB_CH2 | YT8824_DAC_IMSB_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CFG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CH0, 0x39);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH1, 0x39);\n+\tmask = YT8824_DAC_IMSB_CH0 | YT8824_DAC_IMSB_CH1;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CFG1_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 1000M cable length threshold */\n+\tctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR, 0x2b);\n+\tmask = YT8824_TRACE_LNG_GAIN_THR;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_TRACE_LNG_GAIN_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_TRACE_MED_GAIN_THR, 0x1d);\n+\tmask = YT8824_TRACE_MED_GAIN_THR;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_TRACE_MED_GAIN_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* 100M template amplitude */\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CH3_ORG, 0x45);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CH2_ORG, 0x45);\n+\tmask = YT8824_DAC_IMID_CH3_ORG | YT8824_DAC_IMID_CH2_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CH2_CH3_CFG_ORG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CH1_ORG, 0x45);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CH0_ORG, 0x45);\n+\tmask = YT8824_DAC_IMID_CH1_ORG | YT8824_DAC_IMID_CH0_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CH0_CH1_CFG_ORG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CH3_ORG, 0x45);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH2_ORG, 0x45);\n+\tmask = YT8824_DAC_IMSB_CH2_ORG | YT8824_DAC_IMSB_CH3_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CH2_CH3_CFG_ORG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CH1_ORG, 0x45);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH0_ORG, 0x45);\n+\tmask = YT8824_DAC_IMSB_CH1_ORG | YT8824_DAC_IMSB_CH0_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CH0_CH1_CFG_ORG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 100M cable length threshold */\n+\tctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR_100, 0x2A);\n+\tctrl |= FIELD_PREP(YT8824_TRACE_MED_GAIN_THR_100, 0x1D);\n+\tmask = YT8824_TRACE_LNG_GAIN_THR_100 | YT8824_TRACE_MED_GAIN_THR_100;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_TRACE_LNG_GAIN_100_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_CABLE_VSHT_THR_S, 0x36);\n+\tmask = YT8824_CABLE_VSHT_THR_S;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_CABLE_VSHT_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* 10M template amplitude */\n+\tctrl = FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH3_10, 0x18);\n+\tctrl |= FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH2_10, 0x18);\n+\tmask = YT8824_DAC_LPFIL_ADJ_CH3_10 | YT8824_DAC_LPFIL_ADJ_CH2_10;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_LPFIL_CH2_CH3_ADJ_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH1_10, 0x18);\n+\tctrl |= FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH0_10, 0x18);\n+\tmask = YT8824_DAC_LPFIL_ADJ_CH1_10 | YT8824_DAC_LPFIL_ADJ_CH0_10;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_LPFIL_CH0_CH1_ADJ_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 10M cable length threshold */\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CFG_CH3_10_ORG, 0x6C);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CFG_CH2_10_ORG, 0x6C);\n+\tmask = YT8824_DAC_IMID_CFG_CH3_10_ORG | YT8824_DAC_IMID_CFG_CH2_10_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CFG_CH2_CH3_10_ORG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CFG_CH1_10_ORG, 0x6C);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CFG_CH0_10_ORG, 0x6C);\n+\tmask = YT8824_DAC_IMID_CFG_CH1_10_ORG | YT8824_DAC_IMID_CFG_CH0_10_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CFG_CH0_CH1_10_ORG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized DAC IMSB config for CH2/CH3 */\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CFG_CH3_10_ORG, 0x6C);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CFG_CH2_10_ORG, 0x6C);\n+\tmask = YT8824_DAC_IMSB_CFG_CH3_10_ORG | YT8824_DAC_IMSB_CFG_CH2_10_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CFG_CH2_CH3_10_ORG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized DAC IMSB config for CH0/CH1 */\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CFG_CH1_10_ORG, 0x6C);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CFG_CH0_10_ORG, 0x6C);\n+\tmask = YT8824_DAC_IMSB_CFG_CH1_10_ORG | YT8824_DAC_IMSB_CFG_CH0_10_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CFG_CH0_CH1_10_ORG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimize utp 1000M performance */\n+\tctrl = FIELD_PREP(YT8824_WAIT_TO_1000, 0xFF);\n+\tmask = YT8824_WAIT_TO_1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_FFE_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_EN_GATE_PHYDBG, 0);\n+\tctrl |= FIELD_PREP(YT8824_EN_GATE_BT1000, 0);\n+\tmask = YT8824_EN_GATE_PHYDBG | YT8824_EN_GATE_BT1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_EN_GATE_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_CNT_ERR_AUTO, 1);\n+\tmask = YT8824_CNT_ERR_AUTO;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_CNT_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PRM_LARGE_MASTER_1000, 0x94);\n+\tmask = YT8824_PRM_LARGE_MASTER_1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_PRM_LARGE_MASTER_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PRM_LARGE_SLAVE_1000, 0x094);\n+\tmask = YT8824_PRM_LARGE_SLAVE_1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_PRM_LARGE_SLAVE_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_SIG_GONE_THR_1000, 0x08);\n+\tmask = YT8824_SIG_GONE_THR_1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_SIG_GONE_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_EC_NX_TRAIN_COARSE_TO_1000, 0x40);\n+\tmask = YT8824_EC_NX_TRAIN_COARSE_TO_1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_EC_NX_TRAIN_COARSE_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_VGA_IN_LPF2_CAP_OTHER, 0x2);\n+\tmask = YT8824_VGA_IN_LPF2_CAP_OTHER;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_VGA_IN_LPF2_CAP_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_VGA_IN_LPF1_CAP_OTHER, 0x2);\n+\tmask = YT8824_VGA_IN_LPF1_CAP_OTHER;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_VGA_IN_LPF1_CAP_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized EMC CS */\n+\tctrl = FIELD_PREP(YT8824_LDPC_FAIL_THR, 0xFF);\n+\tctrl |= FIELD_PREP(YT8824_LFER_FAIL_THR, 0xFF);\n+\tmask = YT8824_LDPC_FAIL_THR | YT8824_LFER_FAIL_THR;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_LDPC_LFER_FAIL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_FR_REQ_THR, 0x06);\n+\tmask = YT8824_FR_REQ_THR;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_FR_REQ_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PRM_SMALL_SHT_2500, 0x0FF);\n+\tmask = YT8824_PRM_SMALL_SHT_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_GN_MU_COARSE_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized EMC RE */\n+\tctrl = FIELD_PREP(YT8824_DAC_AMP_ADJ_CH3_PBO0_2500, 0xF);\n+\tctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH2_PBO0_2500, 0xF);\n+\tctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH1_PBO0_2500, 0xF);\n+\tctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH0_PBO0_2500, 0xF);\n+\tmask = YT8824_DAC_AMP_ADJ_CH3_PBO0_2500 |\n+\t YT8824_DAC_AMP_ADJ_CH2_PBO0_2500 |\n+\t YT8824_DAC_AMP_ADJ_CH1_PBO0_2500 |\n+\t YT8824_DAC_AMP_ADJ_CH0_PBO0_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_AMP_ADJ_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH3, 0x1F);\n+\tctrl |= FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH2, 0x1F);\n+\tmask = YT8824_P0_DAC_BIAS_CAS_CFG_CH3 | YT8824_P0_DAC_BIAS_CAS_CFG_CH2;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_P0_DAC_BIAS_CAS_CH3_CH2_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH1, 0x1F);\n+\tctrl |= FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH0, 0x1F);\n+\tmask = YT8824_P0_DAC_BIAS_CAS_CFG_CH1 | YT8824_P0_DAC_BIAS_CAS_CFG_CH0;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_P0_DAC_BIAS_CAS_CH1_CH0_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH3, 0x1F);\n+\tctrl |= FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH2, 0x1F);\n+\tmask = YT8824_P1_DAC_BIAS_CAS_CFG_CH3 | YT8824_P1_DAC_BIAS_CAS_CFG_CH2;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_P1_DAC_BIAS_CAS_CH3_CH2_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH1, 0x1F);\n+\tctrl |= FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH0, 0x1F);\n+\tmask = YT8824_P1_DAC_BIAS_CAS_CFG_CH1 | YT8824_P1_DAC_BIAS_CAS_CFG_CH0;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_P1_DAC_BIAS_CAS_CH1_CH0_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET, 1);\n+\tctrl |= FIELD_PREP(YT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET, 1);\n+\tmask = YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET |\n+\t\tYT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_P01_PLL_EN_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH0, 0);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH1, 0);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH2, 0);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH3, 0);\n+\tmask = YT8824_U0_CSR_RESETB_TX_CH0 | YT8824_U0_CSR_RESETB_TX_CH1 |\n+\t\tYT8824_U0_CSR_RESETB_TX_CH2 | YT8824_U0_CSR_RESETB_TX_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_U0_CSR_RESET_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH0, 0);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH1, 0);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH2, 0);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH3, 0);\n+\tmask = YT8824_U1_CSR_RESETB_TX_CH0 | YT8824_U1_CSR_RESETB_TX_CH1 |\n+\t YT8824_U1_CSR_RESETB_TX_CH2 | YT8824_U1_CSR_RESETB_TX_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_U1_CSR_RESET_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH0, 1);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH1, 1);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH2, 1);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH3, 1);\n+\tmask = YT8824_U0_CSR_RESETB_TX_CH0 | YT8824_U0_CSR_RESETB_TX_CH1 |\n+\t YT8824_U0_CSR_RESETB_TX_CH2 | YT8824_U0_CSR_RESETB_TX_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_U0_CSR_RESET_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH0, 1);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH1, 1);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH2, 1);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH3, 1);\n+\tmask = YT8824_U1_CSR_RESETB_TX_CH0 | YT8824_U1_CSR_RESETB_TX_CH1 |\n+\t YT8824_U1_CSR_RESETB_TX_CH2 | YT8824_U1_CSR_RESETB_TX_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_U1_CSR_RESET_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* reset */\n+\tret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_normal;\n+\n+\tret = phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE,\n+\t\t\t BMCR_RESET | BMCR_ANENABLE);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_normal;\n+\tret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val \u0026 BMCR_RESET),\n+\t\t\t\t 50000, 600000, true);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_normal;\n+\n+\tret = genphy_c45_template_testmode(phydev,\n+\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_normal;\n+\treturn 0;\n+\n+err_restore:\n+\tr = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, 0);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\treturn ret;\n+\n+err_restore_normal:\n+\tr = genphy_c45_template_testmode(phydev,\n+\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\tr = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, 0);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_extern_sds_softreset() - config external phy8824 sds softrest\n+ * @phydev: target phy_device struct\n+ *\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_extern_sds_softreset(struct phy_device *phydev)\n+{\n+\tint old_page = YT8824_RSSR_UTP_SPACE;\n+\tint ret = -1;\n+\tint val = 0;\n+\n+\told_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);\n+\tif (old_page \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* TX preamble padded to 8; RX IPG always \u003e 8 */\n+\tret = __phy_read(phydev, MII_RESV1);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\tret \u0026= ~YT8824_SDS_CFG_MIN_PRE_MASK;\n+\tret |= YT8824_SDS_TX_PRE_PADDING;\n+\tret |= YT8824_SDS_EN_FILL_PRE;\n+\tret = __phy_write(phydev, MII_RESV1, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = __phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE,\n+\t\t\t BMCR_RESET | BMCR_ANENABLE);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\t/* poll while still holding the lock; __phy_read takes no lock */\n+\tret = read_poll_timeout(__phy_read, val,\n+\t\t\t\t(val \u003c 0) || !(val \u0026 BMCR_RESET), 50000, 600000,\n+\t\t\t\ttrue, phydev, MII_BMCR);\n+\tif (val \u003c 0)\n+\t\tret = val;\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_extern_config_sds_init_paged() - config external phy8824 sds init\n+ * @phydev: target phy_device struct\n+ *\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_extern_config_sds_init_paged(struct phy_device *phydev)\n+{\n+\tint old_page = YT8824_RSSR_UTP_SPACE;\n+\tint val_1, val_2, val_3, tmp;\n+\tint ctrl = 0;\n+\tint mask = 0;\n+\tint ret = -1;\n+\n+\told_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);\n+\tif (old_page \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* read efuse */\n+\tret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL1_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\telse\n+\t\tval_1 = ret;\n+\n+\tret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL2_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\telse\n+\t\tval_2 = ret;\n+\n+\tret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL3_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\telse\n+\t\tval_3 = ret;\n+\n+\t/* Serdes optimization */\n+\tctrl = FIELD_PREP(YT8824_SERDES_REG_WR_PRT, 1);\n+\tmask = YT8824_SERDES_REG_WR_PRT;\n+\tret = ytphy_modify_ext(phydev, YT8824_WRITE_PROTECT_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_PCS_GLB_RST_BYPASS, 1);\n+\tctrl |= FIELD_PREP(YT8824_CSR_SG_MODE_RST_BYPASS, 1);\n+\tctrl |= FIELD_PREP(YT8824_CSR_US_GLB_RESET_N, 0);\n+\tctrl |= FIELD_PREP(YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS, 1);\n+\tmask = YT8824_CSR_PCS_GLB_RST_BYPASS | YT8824_CSR_SG_MODE_RST_BYPASS |\n+\t YT8824_CSR_US_GLB_RESET_N |\n+\t YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_WATCH_DOG_ALL_BYPASS, 1);\n+\tmask = YT8824_CSR_WATCH_DOG_ALL_BYPASS;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_PMA_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* analog CDR */\n+\tctrl = FIELD_PREP(YT8824_CDR_MODE, 1);\n+\tmask = YT8824_CDR_MODE;\n+\tret = ytphy_modify_ext(phydev, YT8824_CDR_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized VCO */\n+\tctrl = FIELD_PREP(YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT, 0x9);\n+\tctrl |= FIELD_PREP(YT8824_CSR_PLL_VCO_ATEMP_R, 0x4);\n+\tmask = YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT | YT8824_CSR_PLL_VCO_ATEMP_R;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_VCO_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R, 0x0);\n+\tmask = YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_DIVLDO_CTRL_REG,\n+\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized PLL lock */\n+\tret = ytphy_read_ext(phydev, YT8824_DAC_TRIM_MAIN_CFG_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret \u0026= ~(BIT(13) | BIT(12));\n+\ttmp = (val_1 \u0026 (BIT(7) | BIT(6))) \u003e\u003e 6;\n+\tret |= (tmp \u003c\u003c 12);\n+\tret = ytphy_write_ext(phydev, YT8824_DAC_TRIM_MAIN_CFG_REG, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_read_ext(phydev, YT8824_PLL_VCO_CFG_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret \u0026= ~(BIT(1) | BIT(0));\n+\ttmp = (val_1 \u0026 (BIT(5) | BIT(4))) \u003e\u003e 4;\n+\tret |= tmp;\n+\tret = ytphy_write_ext(phydev, YT8824_PLL_VCO_CFG_REG, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_read_ext(phydev, YT8824_TX_MUX_CH3_CH2_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret \u0026= ~(BIT(13) | BIT(12));\n+\ttmp = (val_3 \u0026 (BIT(1) | BIT(0)));\n+\tret |= (tmp \u003c\u003c 12);\n+\tret = ytphy_write_ext(phydev, YT8824_TX_MUX_CH3_CH2_REG, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_PLL_FBDIV_SYNC_SELB, 1);\n+\tmask = YT8824_CSR_PLL_FBDIV_SYNC_SELB;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_FBDIV_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_PLL_SPARE, 0xf070);\n+\tmask = YT8824_CSR_PLL_SPARE;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_SPARE_CTRL_REG,\n+\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* cable length threshold */\n+\tctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_LNG, 0x7F);\n+\tmask = YT8824_VDAC_AMP_THR_LNG;\n+\tret = ytphy_modify_ext(phydev, YT8824_CDR_MANUAL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);\n+\tctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0x7F);\n+\tmask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;\n+\tret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* Serdes training threshold */\n+\tctrl = FIELD_PREP(YT8824_EOD_DURATION_SEL, 0xF);\n+\tctrl |= FIELD_PREP(YT8824_EOD_VTH, 0x14);\n+\tmask = YT8824_EOD_DURATION_SEL | YT8824_EOD_VTH;\n+\tret = ytphy_modify_ext(phydev, YT8824_EOM_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CDR_OFFSET_ERR_WTH, 0x0A);\n+\tctrl |= FIELD_PREP(YT8824_PGA_GAIN_MAX, 0x4);\n+\tctrl |= FIELD_PREP(YT8824_PGA_GAIN_INIT, 0x4);\n+\tmask = YT8824_CDR_OFFSET_ERR_WTH | YT8824_PGA_GAIN_MAX |\n+\t YT8824_PGA_GAIN_INIT;\n+\tret = ytphy_modify_ext(phydev, YT8824_PGA_GAIN_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* digital eye diagram of SerDes */\n+\tctrl = FIELD_PREP(YT8824_EOD_ERR_CNT_THR, 0x0000);\n+\tmask = YT8824_EOD_ERR_CNT_THR;\n+\tret = ytphy_modify_ext(phydev, YT8824_EOD_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* Serdes LDO */\n+\tret = ytphy_read_ext(phydev, YT8824_FFE_CTRL_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret \u0026= ~(BIT(6) | BIT(5) | BIT(4));\n+\ttmp = (val_2 \u0026 (BIT(4) | BIT(3) | BIT(2))) \u003e\u003e 2;\n+\tret |= (tmp \u003c\u003c 4);\n+\tret = ytphy_write_ext(phydev, YT8824_FFE_CTRL_REG, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_read_ext(phydev, YT8824_C1_COARSE_CFG_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret \u0026= ~(BIT(10) | BIT(9) | BIT(8));\n+\ttmp = (val_2 \u0026 (BIT(7) | BIT(6) | BIT(5))) \u003e\u003e 5;\n+\tret |= (tmp \u003c\u003c 8);\n+\tret = ytphy_write_ext(phydev, YT8824_C1_COARSE_CFG_REG, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized Serdes RX */\n+\tctrl = FIELD_PREP(YT8824_CSR_AFE_VCM_CFG, 0x5);\n+\tctrl |= FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_1P25G, 0);\n+\tctrl |= FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_3P125G, 0);\n+\tmask = YT8824_CSR_AFE_VCM_CFG | YT8824_CSR_AFE_MANUAL_CTRL_1P25G |\n+\t YT8824_CSR_AFE_MANUAL_CTRL_3P125G;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_DFE_TAP_POLARITY, 1);\n+\tctrl |= FIELD_PREP(YT8824_DFE_IDAC_TUNE, 0x3);\n+\tmask = YT8824_DFE_TAP_POLARITY | YT8824_DFE_IDAC_TUNE;\n+\tret = ytphy_modify_ext(phydev, YT8824_DFE_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_CDR_OFFSET_DATA, 0x7C);\n+\tmask = YT8824_CSR_CDR_OFFSET_DATA;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_CDR_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_DFE_VDAC_CODE_THR, 0x7F);\n+\tmask = YT8824_DFE_VDAC_CODE_THR;\n+\tret = ytphy_modify_ext(phydev, YT8824_DFE_VDAC_CODE_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_RX_SPARE_REG, 0xff08);\n+\tmask = YT8824_RX_SPARE_REG;\n+\tret = ytphy_modify_ext(phydev, YT8824_RX_SPARE_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized Serdes TX */\n+\tctrl = FIELD_PREP(YT8824_DFE_VDAC_TUNE, 0x1);\n+\tctrl |= FIELD_PREP(YT8824_DFE_VDAC_SEL, 0x0);\n+\tmask = YT8824_DFE_VDAC_TUNE | YT8824_DFE_VDAC_SEL;\n+\tret = ytphy_modify_ext(phydev, YT8824_DFE_VDAC_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_TX_PRE_SEL, 0x6);\n+\tmask = YT8824_CSR_TX_PRE_SEL;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_TX_PRE_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* Serdes manual config */\n+\tctrl = FIELD_PREP(YT8824_CSR_AFE_CTLE_BW, 0x0);\n+\tmask = YT8824_CSR_AFE_CTLE_BW;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL1_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_AFE_PGA_BW, 0x7);\n+\tctrl |= FIELD_PREP(YT8824_CSR_AFE_BUF_BW, 0x7);\n+\tmask = YT8824_CSR_AFE_PGA_BW | YT8824_CSR_AFE_BUF_BW;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL2_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_10P3125G, 0x1);\n+\tmask = YT8824_CSR_AFE_MANUAL_CTRL_10P3125G;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* restart calibration */\n+\tctrl = FIELD_PREP(YT8824_CUR_TX_SEQ, 0x5);\n+\tctrl |= FIELD_PREP(YT8824_CUR_RX_SEQ, 0x6);\n+\tctrl |= FIELD_PREP(YT8824_CALIB_SEQ_FINISH, 1);\n+\tctrl |= FIELD_PREP(YT8824_CALIB_SEQ_SW_RST, 1);\n+\tmask = YT8824_CUR_TX_SEQ | YT8824_CUR_RX_SEQ |\n+\t YT8824_CALIB_SEQ_FINISH | YT8824_CALIB_SEQ_SW_RST;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_DCC_CAL_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);\n+\tctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0xFF);\n+\tmask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;\n+\tret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);\n+\tctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0x7F);\n+\tmask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;\n+\tret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* restart to calibration */\n+\tret = ytphy_write_ext(phydev, YT8824_RESTART_CAL_CTRL_REG, 0x0040);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, YT8824_RESTART_CAL_CTRL_REG, 0x0);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_config_init() - phy initializatioin\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_config_init(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tif (priv-\u003epackage_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tret = yt8824_config_utp_init_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err;\n+\t} else {\n+\t\tif (!priv-\u003esds_initialized) {\n+\t\t\tret = yt8824_extern_config_sds_init_paged(phydev);\n+\t\t\tif (ret \u003c 0)\n+\t\t\t\tgoto err;\n+\t\t\tpriv-\u003esds_initialized = true;\n+\t\t}\n+\t\t/*\n+\t\t * Configuring the MII registers of the SDS,\n+\t\t * which are private to each channel.\n+\t\t */\n+\t\tret = yt8824_extern_sds_softreset(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err;\n+\n+\t\tret = yt8824_config_utp_init_paged(phydev);\n \t\tif (ret \u003c 0)\n-\t\t\tgoto err_restore_page;\n+\t\t\tgoto err;\n \t}\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\tret = yt8824_soft_reset(phydev);\n \n-err_restore_page:\n-\treturn phy_restore_page(phydev, old_page, ret);\n+\tphydev_dbg(phydev, \"%s done, phy addr: %d\\n\", __func__,\n+\t\t phydev-\u003emdio.addr);\n+\treturn ret;\n+err:\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\treturn ret;\n }\n \n static int yt8531_set_wol(struct phy_device *phydev,\n@@ -3240,6 +4701,450 @@ static int yt8821_resume(struct phy_device *phydev)\n \treturn yt8821_modify_utp_fiber_bmcr(phydev, BMCR_PDOWN, 0);\n }\n \n+/**\n+ * yt8824_get_features - read mmd register to get 2.5G capability\n+ * @phydev: target phy_device struct\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_get_features(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\tret = yt8821_get_features(phydev);\n+\n+err:\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_aneg_done() - check negotiation state.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: auto-negotiation complete status or negative errno code\n+ */\n+static int yt8824_aneg_done(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint auto_neg;\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\n+\tret = phy_read(phydev, MII_BMSR);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\tauto_neg = !!(ret \u0026 BMSR_ANEGCOMPLETE);\n+\n+\tphydev_dbg(phydev, \"%s, phy addr: %d, auto negotiation done: %d\\n\",\n+\t\t __func__, phydev-\u003emdio.addr, auto_neg);\n+\treturn auto_neg;\n+err:\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_read_status_paged() - determines the speed and duplex of one page\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_read_status_paged(struct phy_device *phydev)\n+{\n+\tint ret;\n+\tint val;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = genphy_read_status(phydev);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tif (phydev-\u003eautoneg == AUTONEG_ENABLE \u0026\u0026 phydev-\u003eautoneg_complete) {\n+\t\tret = genphy_c45_read_lpa(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t}\n+\n+\tif (!phydev-\u003elink) {\n+\t\tphydev-\u003espeed = SPEED_UNKNOWN;\n+\t\tphydev-\u003eduplex = DUPLEX_UNKNOWN;\n+\t\tif (phydev-\u003eautoneg == AUTONEG_ENABLE)\n+\t\t\tphy_resolve_aneg_pause(phydev);\n+\t\treturn 0;\n+\t}\n+\n+\tret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tval = ret;\n+\n+\tyt8821_adjust_status(phydev, val);\n+\n+\tif (phydev-\u003eautoneg == AUTONEG_ENABLE)\n+\t\tphy_resolve_aneg_pause(phydev);\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * yt8824_read_status() - determines the negotiated speed and duplex\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_read_status(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = yt8824_read_status_paged(phydev);\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_utp_power_on(): utp power on.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_utp_power_on(struct phy_device *phydev)\n+{\n+\tint ret = 0;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0x0);\n+}\n+\n+/**\n+ * yt8824_utp_power_down(): utp power down.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_utp_power_down(struct phy_device *phydev)\n+{\n+\tint ret;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);\n+}\n+\n+/**\n+ * yt8824_power_on() - set utp power on.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * NOTE: need WA like softreset\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_power_on(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\tint r;\n+\n+\tif (priv-\u003epackage_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_power_on(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t} else {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_power_on(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_and_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t}\n+\treturn 0;\n+\n+retry:\n+\t/*\n+\t * If the PHY up operation succeeds but the subsequent operation\n+\t * fails, revert to the default state.\n+\t */\n+\tr = yt8824_utp_power_down(phydev);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\tret = yt8824_restore_working_status(phydev, ret);\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_resume() - resume the hardware\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_resume(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = yt8824_power_on(phydev);\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_power_down() - set utp power down.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * NOTE: need WA like softreset\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_power_down(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\tint r;\n+\n+\tif (priv-\u003epackage_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_power_down(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t} else {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_power_down(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_and_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t}\n+\treturn 0;\n+\n+retry:\n+\t/*\n+\t * If the PHY down operation succeeds but the subsequent operation\n+\t * fails, revert to the default state.\n+\t */\n+\tr = yt8824_utp_power_on(phydev);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\tret = yt8824_restore_working_status(phydev, ret);\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_suspend() - suspend the hardware\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_suspend(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = yt8824_power_down(phydev);\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_config_aneg() - config negotiation\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_config_aneg(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint phy_ctrl = 0;\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\n+\t/*\n+\t * Only advertise 2.5G when autoneg is enabled, or when 2.5G is\n+\t * explicitly forced. When a different speed is forced, clear\n+\t * ADV2_5G so a 2.5G-capable link partner cannot negotiate 2.5G.\n+\t * __genphy_config_aneg() only rewrites the\n+\t * clause 22 registers on the forced-speed path, so it will not\n+\t * clear this bit.\n+\t */\n+\tif ((phydev-\u003eautoneg == AUTONEG_ENABLE ||\n+\t phydev-\u003espeed == SPEED_2500) \u0026\u0026\n+\t linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,\n+\t\t\t phydev-\u003eadvertising))\n+\t\tphy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G;\n+\n+\tret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,\n+\t\t\t\t MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\n+\tret = __genphy_config_aneg(phydev, ret);\n+\n+err:\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\treturn ret;\n+}\n+\n+/**\n+ * phy_mode_check() - check if mode names the PHY interface.\n+ * @mode: PHY interface mode string\n+ * @interface: PHY interface mode to compare against\n+ *\n+ * Return: true if @mode matches @interface, false otherwise.\n+ */\n+static bool phy_mode_check(const char *mode, int interface)\n+{\n+\treturn !strcasecmp(mode, phy_modes(interface));\n+}\n+\n+/**\n+ * yt8824_phy_package_probe_once() - init phy package for phy8824.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_phy_package_probe_once(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tstruct device_node *np = phy_package_get_node(phydev);\n+\tconst char *mode;\n+\n+\tif (!priv || !np) {\n+\t\tphydev_err(phydev, \"%s: missing shared priv or DT node\\n\",\n+\t\t\t __func__);\n+\t\treturn -EINVAL;\n+\t}\n+\t/* Initialise shared lock for YT8824 */\n+\tmutex_init(\u0026priv-\u003eshared_lock);\n+\tpriv-\u003esds_initialized = false;\n+\tpriv-\u003epackage_mode = PHY_INTERFACE_MODE_INTERNAL;\n+\tif (!of_property_read_string(np, \"motorcomm,package-mode\",\n+\t\t\t\t \u0026mode)) {\n+\t\tif (phy_mode_check(mode, PHY_INTERFACE_MODE_INTERNAL)) {\n+\t\t\tpriv-\u003epackage_mode = PHY_INTERFACE_MODE_INTERNAL;\n+\t\t} else if (phy_mode_check(mode,\n+\t\t\t\t\t PHY_INTERFACE_MODE_10G_QXGMII)) {\n+\t\t\tpriv-\u003epackage_mode = PHY_INTERFACE_MODE_10G_QXGMII;\n+\t\t} else {\n+\t\t\tphydev_err(phydev, \"unsupported package-mode %s\\n\",\n+\t\t\t\t mode);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t} else {\n+\t\tphydev_err(phydev, \"missing package-mode in PHY package node.\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * yt8824_probe() - phy8824 probe.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_probe(struct phy_device *phydev)\n+{\n+\tstruct device *dev = \u0026phydev-\u003emdio.dev;\n+\tstruct yt8824_shared_priv *shared_priv;\n+\tint ret;\n+\n+\tret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* Ensure other PHY probes wait for shared mutex initialization. */\n+\tphy_package_lock(phydev);\n+\tif (phy_package_probe_once(phydev)) {\n+\t\tret = yt8824_phy_package_probe_once(phydev);\n+\t\tif (ret) {\n+\t\t\tphy_package_unlock(phydev);\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\tphy_package_unlock(phydev);\n+\n+\treturn 0;\n+}\n+\n static struct phy_driver motorcomm_phy_drvs[] = {\n \t{\n \t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8511),\n@@ -3337,13 +5242,29 @@ static struct phy_driver motorcomm_phy_drvs[] = {\n \t\t.suspend\t\t= yt8821_suspend,\n \t\t.resume\t\t\t= yt8821_resume,\n \t},\n+\t{\n+\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8824),\n+\t\t.name = \"YT8824 Quad Ports 2.5Gbps Ethernet\",\n+\t\t.get_features = yt8824_get_features,\n+\t\t.read_page = yt8824_read_page,\n+\t\t.write_page = yt8824_write_page,\n+\t\t.probe = yt8824_probe,\n+\t\t.config_aneg = yt8824_config_aneg,\n+\t\t.aneg_done = yt8824_aneg_done,\n+\t\t.config_init = yt8824_config_init,\n+\t\t.read_status = yt8824_read_status,\n+\t\t.soft_reset = yt8824_soft_reset,\n+\t\t.suspend = yt8824_suspend,\n+\t\t.resume = yt8824_resume,\n+\t},\n };\n \n module_phy_driver(motorcomm_phy_drvs);\n \n-MODULE_DESCRIPTION(\"Motorcomm 8511/8521/8531/8531S/861x/8821 PHY driver\");\n+MODULE_DESCRIPTION(\"Motorcomm 8511/8521/8531/8531S/861x/8821/8824 PHY driver\");\n MODULE_AUTHOR(\"Peter Geis\");\n MODULE_AUTHOR(\"Frank\");\n+MODULE_AUTHOR(\"Kyle\");\n MODULE_LICENSE(\"GPL\");\n \n static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {\n@@ -3354,6 +5275,7 @@ static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {\n \t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) },\n \t{ PHY_ID_MATCH_EXACT(PHY_ID_INT861X) },\n \t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8821) },\n+\t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8824) },\n \t{ /* sentinel */ }\n };\n \ndiff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c\nindex 870920311f9a0..c5f5753f7194b 100644\n--- a/drivers/net/phy/phy-c45.c\n+++ b/drivers/net/phy/phy-c45.c\n@@ -1408,6 +1408,29 @@ int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable)\n }\n EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain);\n \n+/**\n+ * genphy_c45_template_testmode - configure template testmode registers\n+ * @phydev: target phy_device struct\n+ * @test_mode: testmode includes Normal to Test mode 7\n+ *\n+ * Description: Set template testmode include Normal to Test mode 7\n+ *\n+ * Return: 0 on success, or a negative error code on failure (e.g. register\n+ * read/write error).\n+ */\n+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)\n+{\n+\tu16 ctrl;\n+\n+\tif (test_mode \u003e MDIO_PMA_10GBT_TESTMODE_7)\n+\t\treturn -EOPNOTSUPP;\n+\n+\tctrl = FIELD_PREP(MDIO_PMA_10GBT_TESTMODE_MASK, test_mode);\n+\treturn phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,\n+\t\t\t MDIO_PMA_10GBT_TESTMODE_MASK, ctrl);\n+}\n+EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);\n+\n /**\n * genphy_c45_plca_get_cfg - get PLCA configuration from standard registers\n * @phydev: target phy_device struct\ndiff --git a/include/linux/phy.h b/include/linux/phy.h\nindex a5a419bc400ec..81cb7f15bb72e 100644\n--- a/include/linux/phy.h\n+++ b/include/linux/phy.h\n@@ -2359,6 +2359,7 @@ int genphy_c45_loopback(struct phy_device *phydev, bool enable, int speed);\n int genphy_c45_pma_resume(struct phy_device *phydev);\n int genphy_c45_pma_suspend(struct phy_device *phydev);\n int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable);\n+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode);\n int genphy_c45_plca_get_cfg(struct phy_device *phydev,\n \t\t\t struct phy_plca_cfg *plca_cfg);\n int genphy_c45_plca_set_cfg(struct phy_device *phydev,\ndiff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h\nindex 06f4bc3c20c71..353ca13c64fca 100644\n--- a/include/uapi/linux/mdio.h\n+++ b/include/uapi/linux/mdio.h\n@@ -63,6 +63,7 @@\n /* Media-dependent registers. */\n #define MDIO_PMA_10GBT_SWAPPOL\t130\t/* 10GBASE-T pair swap \u0026 polarity */\n #define MDIO_PMA_10GBT_TXPWR\t131\t/* 10GBASE-T TX power control */\n+#define MDIO_PMA_10GBT_TESTMODE 132 /* Test mode control */\n #define MDIO_PMA_10GBT_SNR\t133\t/* 10GBASE-T SNR margin, lane A.\n \t\t\t\t\t * Lanes B-D are numbered 134-136. */\n #define MDIO_PMA_10GBR_FSRT_CSR\t147\t/* 10GBASE-R fast retrain status and control */\n@@ -320,6 +321,17 @@\n /* PMA 10GBASE-R Fast Retrain status and control register. */\n #define MDIO_PMA_10GBR_FSRT_ENABLE\t0x0001\t/* Fast retrain enable */\n \n+/* PMA 10GBASE-T Template Test Mode Register*/\n+#define MDIO_PMA_10GBT_TESTMODE_MASK GENMASK(15, 13) /* Template test mode */\n+#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0 /* Template Normal */\n+#define MDIO_PMA_10GBT_TESTMODE_1 0x1 /* Template TestMode1 */\n+#define MDIO_PMA_10GBT_TESTMODE_2 0x2 /* Template TestMode2 */\n+#define MDIO_PMA_10GBT_TESTMODE_3 0x3 /* Template TestMode3 */\n+#define MDIO_PMA_10GBT_TESTMODE_4 0x4 /* Template TestMode4 */\n+#define MDIO_PMA_10GBT_TESTMODE_5 0x5 /* Template TestMode5 */\n+#define MDIO_PMA_10GBT_TESTMODE_6 0x6 /* Template TestMode6 */\n+#define MDIO_PMA_10GBT_TESTMODE_7 0x7 /* Template TestMode7 */\n+\n /* PCS 10GBASE-R/-T status register 1. */\n #define MDIO_PCS_10GBRT_STAT1_BLKLK\t0x0001\t/* Block lock attained */\n \n"
} |
| 2/1 | 2026/10/18 02:49 | agent | patch-evaluator |
3mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch adds driver support for the Motorcomm YT8824 quad-port Ethernet PHY in drivers/net/phy/motorcomm.c and adds a C45 template testmode helper function in drivers/net/phy/phy-c45.c (which is only referenced by the YT8824 driver). The YT8824 driver requires physical Motorcomm hardware and Device Tree configuration (via devm_of_phy_package_join), neither of which exists or is emulated in standard QEMU/GCE virtualized environments on amd64. The change in ytphy_set_wol is a control-flow no-op jumping to the immediately adjacent label in the same unreachable driver. Therefore, the modified code is structurally unreachable and not worth fuzzing.",
"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 2a4ea54257fb6c756ddc73b32d66516c4451c828
Author: syz-cluster <triage@syzkaller.com>
Date: Sun Oct 18 02:49:44 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml b/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml
new file mode 100644
index 0000000000000..4c67f8afcf27a
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/motorcomm,yt8824.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MotorComm YT8824 Ethernet PHY
+
+maintainers:
+ - Kyle Switch <kyle.switch@motor-comm.com>
+
+description:
+ Motorcomm YT8824 Ethernet PHY is a PHY package of 4 PHYs.
+
+$ref: ethernet-phy-package.yaml#
+
+properties:
+ compatible:
+ enum:
+ - motorcomm,yt8824-package
+
+ motorcomm,package-mode:
+ description: |
+ PHY package can be configured in 2 modes:
+ - internal: YT8824 is embedded in the switch, using
+ an internal interface to the MAC.
+ - 10g-qxgmii: YT8824 is a standalone external PHY,
+ connected via 10G QXGMII.
+ $ref: /schemas/types.yaml#/definitions/string
+ enum: [ internal, 10g-qxgmii ]
+
+ reg:
+ description:
+ The absolute MDIO address of the YT8824 shared top extend
+ register block.
+ For internal mode, this is fixed at 9;
+ For external mode, it is the base MDIO address of the four
+ member PHYs plus 4, where base is typically 0x0.
+ Note that this is NOT the reg of the first member PHY.
+
+required:
+ - compatible
+ - motorcomm,package-mode
+ - reg
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ mdio {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ethernet-phy-package@9 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "motorcomm,yt8824-package";
+ reg = <9>;
+
+ motorcomm,package-mode = "internal";
+
+ ethernet-phy@4 {
+ reg = <4>;
+ };
+
+ ethernet-phy@5 {
+ reg = <5>;
+ };
+
+ ethernet-phy@6 {
+ reg = <6>;
+ };
+
+ ethernet-phy@7 {
+ reg = <7>;
+ };
+ };
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index 23e9194483d9b..ac8e12e7b8392 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18424,8 +18424,10 @@ F: drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
MOTORCOMM PHY DRIVER
M: Frank <Frank.Sae@motor-comm.com>
+M: Kyle Switch <kyle.switch@motor-comm.com>
L: netdev@vger.kernel.org
S: Maintained
+F: Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml
F: Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
F: drivers/net/phy/motorcomm.c
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 30e9d22c8d1a3..04593a770e433 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -361,10 +361,12 @@ config MICROSEMI_PHY
config MOTORCOMM_PHY
tristate "Motorcomm PHYs"
+ select PHY_PACKAGE
help
Enables support for Motorcomm network PHYs.
Currently supports YT85xx Gigabit Ethernet PHYs, YT861x PHYs
- integrated in YT921x switches, and YT8821 2.5Gbps PHYs.
+ integrated in YT921x switches, YT8821 2.5Gbps PHYs and YT8824 4 * 2.5G
+ PHYs.
config NATIONAL_PHY
tristate "National Semiconductor PHYs"
diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
index 463e1ea3efc93..6628ebcca0819 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -1,19 +1,25 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Motorcomm 8511/8521/8522/8531/8531S/861x/8821 PHY driver.
+ * Motorcomm 8511/8521/8522/8531/8531S/861x/8821/8824 PHY driver.
*
* Author: Peter Geis <pgwipeout@gmail.com>
* Author: Frank <Frank.Sae@motor-comm.com>
+ * Author: Kyle <kyle.switch@motor-comm.com>
*/
#include <linux/clk.h>
#include <linux/etherdevice.h>
#include <linux/ethtool_netlink.h>
#include <linux/kernel.h>
+#include <linux/mdio.h>
#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_net.h>
#include <linux/phy.h>
#include <linux/property.h>
+#include "phylib.h"
+
#define PHY_ID_YT8511 0x0000010a
#define PHY_ID_YT8521 0x0000011a
#define PHY_ID_YT8522 0x4f51e928
@@ -22,6 +28,7 @@
/* Live captured from YT921x switch internal MDIO bus */
#define PHY_ID_INT861X 0x01e04281
#define PHY_ID_YT8821 0x4f51ea19
+#define PHY_ID_YT8824 0x4f51e8b8
/* YT8521/YT8531S/YT8821 Register Overview
* UTP Register space | FIBER Register space
* ------------------------------------------------------------
@@ -33,6 +40,18 @@
* ------------------------------------------------------------
*/
+/* YT8824 Register Overview
+ * UTP Register space | SERDES Register space
+ * ------------------------------------------------------------
+ * | UTP MII | SERDES MII |
+ * | UTP MMD | |
+ * | UTP Extended | SERDES Extended |
+ * | UTP Top Extended | SERDES Top Extended |
+ * ------------------------------------------------------------
+ * | Common Top Extended |
+ * ------------------------------------------------------------
+ */
+
/* 0x10 ~ 0x15 , 0x1E and 0x1F are common MII registers of yt phy */
/* Specific Function Control Register */
@@ -397,6 +416,226 @@
#define YT8821_CHIP_MODE_AUTO_BX2500_SGMII 0
#define YT8821_CHIP_MODE_FORCE_BX2500 1
+#define YT8824_RSSR_SPACE_MASK BIT(0)
+#define YT8824_RSSR_SERDES_SPACE (0x1)
+#define YT8824_RSSR_UTP_SPACE (0x0)
+#define YT8824_SDS_CFG_MIN_PRE_MASK GENMASK(3, 0)
+#define YT8824_SDS_EN_FILL_PRE BIT(13)
+#define YT8824_SDS_TX_PRE_PADDING (0x7)
+
+/* PHY8824 UTP init registers */
+#define YT8824_WRITE_PROTECT_CAL_REG 0x1
+#define YT8824_WRITE_PROTECT BIT(0)
+#define YT8824_PLL_VCO_ATEMP_REG 0xa20e
+#define YT8824_PLL_VCO_SEL_CURRENT GENMASK(7, 4)
+#define YT8824_PLL_VCO_SEL_CURRENT_B 0xb
+#define YT8824_PLL_PFD_CTRL_REG 0xa20a
+#define YT8824_PLL_VCO_ICOSTANT GENMASK(9, 4)
+#define YT8824_PLL_VCO_ATEMP_1_REG 0xa20c
+#define YT8824_PLL_VCO_IPTAT GENMASK(5, 0)
+#define YT8824_PLL_DAC_0_REG 0xa2b6
+#define YT8824_PLL_DAC_RST BIT(10)
+#define YT8824_IF_CTRL_REG 0xa003
+#define YT8824_U0_U1_ENABLE_ODD_PREAMBLE GENMASK(1, 0)
+#define YT8824_IDLE_CTRL_REG 0x3d0
+#define YT8824_IDLE_DETECT BIT(9)
+#define YT8824_TRACE_GAIN_THR_REG 0x372
+#define YT8824_TRACE_LNG_GAIN_THR_2500 GENMASK(14, 8)
+#define YT8824_TRACE_MED_GAIN_THR_2500 GENMASK(6, 0)
+#define YT8824_PRM_LONG_REG 0x37C
+#define YT8824_PRM_LARGE_SLAVE_2500 GENMASK(10, 0)
+#define YT8824_PRM_SMALL_REG 0x388
+#define YT8824_PRM_SMALL_LNG_2500 GENMASK(10, 0)
+#define YT8824_FAST_RETRAIN_REG 0x359
+#define YT8824_LINK_FAIL_SIG GENMASK(13, 8)
+#define YT8824_EN_GATE_CTRL_REG 0xc
+#define YT8824_EN_GATE_GMII_CLK BIT(0)
+#define YT8824_DAC_CFG_REG 0xa2fa
+#define YT8824_POWER_SAVE GENMASK(15, 0)
+#define YT8824_DAC_BIAS_CFG_REG 0x4e2
+#define YT8824_DAC_BIAS_CFG_2500 GENMASK(9, 5)
+#define YT8824_DAC_IMID_CFG_REG 0x47e
+#define YT8824_DAC_IMID_CH2 GENMASK(6, 0)
+#define YT8824_DAC_IMID_CH3 GENMASK(14, 8)
+#define YT8824_DAC_IMID_CFG1_REG 0x47f
+#define YT8824_DAC_IMID_CH0 GENMASK(6, 0)
+#define YT8824_DAC_IMID_CH1 GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CFG_REG 0x480
+#define YT8824_DAC_IMSB_CH2 GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CH3 GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CFG1_REG 0x481
+#define YT8824_DAC_IMSB_CH0 GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CH1 GENMASK(14, 8)
+#define YT8824_TRACE_LNG_GAIN_REG 0x336
+#define YT8824_TRACE_LNG_GAIN_THR GENMASK(14, 8)
+#define YT8824_TRACE_MED_GAIN_REG 0x340
+#define YT8824_TRACE_MED_GAIN_THR GENMASK(6, 0)
+#define YT8824_DAC_IMID_CH2_CH3_CFG_ORG_REG 0x46e
+#define YT8824_DAC_IMID_CH3_ORG GENMASK(14, 8)
+#define YT8824_DAC_IMID_CH2_ORG GENMASK(6, 0)
+#define YT8824_DAC_IMID_CH0_CH1_CFG_ORG_REG 0x46f
+#define YT8824_DAC_IMID_CH1_ORG GENMASK(14, 8)
+#define YT8824_DAC_IMID_CH0_ORG GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CH2_CH3_CFG_ORG_REG 0x470
+#define YT8824_DAC_IMSB_CH3_ORG GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CH2_ORG GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CH0_CH1_CFG_ORG_REG 0x471
+#define YT8824_DAC_IMSB_CH1_ORG GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CH0_ORG GENMASK(6, 0)
+#define YT8824_TRACE_LNG_GAIN_100_REG 0x030b
+#define YT8824_TRACE_LNG_GAIN_THR_100 GENMASK(14, 8)
+#define YT8824_TRACE_MED_GAIN_THR_100 GENMASK(6, 0)
+#define YT8824_CABLE_VSHT_REG 0x071f
+#define YT8824_CABLE_VSHT_THR_S GENMASK(6, 0)
+#define YT8824_DAC_LPFIL_CH2_CH3_ADJ_REG 0x046b
+#define YT8824_DAC_LPFIL_ADJ_CH3_10 GENMASK(12, 8)
+#define YT8824_DAC_LPFIL_ADJ_CH2_10 GENMASK(4, 0)
+#define YT8824_DAC_LPFIL_CH0_CH1_ADJ_REG 0x046c
+#define YT8824_DAC_LPFIL_ADJ_CH1_10 GENMASK(12, 8)
+#define YT8824_DAC_LPFIL_ADJ_CH0_10 GENMASK(4, 0)
+#define YT8824_DAC_IMID_CFG_CH2_CH3_10_ORG 0x0466
+#define YT8824_DAC_IMID_CFG_CH3_10_ORG GENMASK(14, 8)
+#define YT8824_DAC_IMID_CFG_CH2_10_ORG GENMASK(6, 0)
+#define YT8824_DAC_IMID_CFG_CH0_CH1_10_ORG 0x0467
+#define YT8824_DAC_IMID_CFG_CH1_10_ORG GENMASK(14, 8)
+#define YT8824_DAC_IMID_CFG_CH0_10_ORG GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CFG_CH2_CH3_10_ORG 0x0468
+#define YT8824_DAC_IMSB_CFG_CH3_10_ORG GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CFG_CH2_10_ORG GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CFG_CH0_CH1_10_ORG 0x0469
+#define YT8824_DAC_IMSB_CFG_CH1_10_ORG GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CFG_CH0_10_ORG GENMASK(6, 0)
+#define YT8824_FFE_REG 0x034a
+#define YT8824_WAIT_TO_1000 GENMASK(15, 8)
+#define YT8824_FFE_SUM_THRES GENMASK(2, 0)
+#define YT8824_EN_GATE_REG 0x00f8
+#define YT8824_EN_GATE_PHYDBG BIT(10)
+#define YT8824_EN_GATE_BT1000 BIT(9)
+#define YT8824_CNT_REG 0x0059
+#define YT8824_CNT_ERR_AUTO BIT(14)
+#define YT8824_PRM_LARGE_MASTER_REG 0x032c
+#define YT8824_PRM_LARGE_MASTER_1000 GENMASK(10, 0)
+#define YT8824_PRM_LARGE_SLAVE_REG 0x032d
+#define YT8824_PRM_LARGE_SLAVE_1000 GENMASK(10, 0)
+#define YT8824_SIG_GONE_REG 0x032e
+#define YT8824_SIG_GONE_THR_1000 GENMASK(7, 0)
+#define YT8824_EC_NX_TRAIN_COARSE_REG 0x0322
+#define YT8824_EC_NX_TRAIN_COARSE_TO_1000 GENMASK(7, 0)
+#define YT8824_VGA_IN_LPF2_CAP_REG 0x04d3
+#define YT8824_VGA_IN_LPF2_CAP_OTHER GENMASK(7, 4)
+#define YT8824_VGA_IN_LPF1_CAP_REG 0x04d2
+#define YT8824_VGA_IN_LPF1_CAP_OTHER GENMASK(7, 4)
+#define YT8824_LDPC_LFER_FAIL_REG 0x00c8
+#define YT8824_LDPC_FAIL_THR GENMASK(15, 8)
+#define YT8824_LFER_FAIL_THR GENMASK(7, 0)
+#define YT8824_FR_REQ_REG 0x00be
+#define YT8824_FR_REQ_THR GENMASK(4, 0)
+#define YT8824_GN_MU_COARSE_REG 0x037a
+#define YT8824_PRM_SMALL_SHT_2500 GENMASK(10, 0)
+#define YT8824_DAC_AMP_ADJ_REG 0x0482
+#define YT8824_DAC_AMP_ADJ_CH3_PBO0_2500 GENMASK(15, 12)
+#define YT8824_DAC_AMP_ADJ_CH2_PBO0_2500 GENMASK(11, 8)
+#define YT8824_DAC_AMP_ADJ_CH1_PBO0_2500 GENMASK(7, 4)
+#define YT8824_DAC_AMP_ADJ_CH0_PBO0_2500 GENMASK(3, 0)
+#define YT8824_P0_DAC_BIAS_CAS_CH3_CH2_REG 0xa2d5
+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH3 GENMASK(12, 8)
+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH2 GENMASK(4, 0)
+#define YT8824_P0_DAC_BIAS_CAS_CH1_CH0_REG 0xa2d6
+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH1 GENMASK(12, 8)
+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH0 GENMASK(4, 0)
+#define YT8824_P1_DAC_BIAS_CAS_CH3_CH2_REG 0xa2d7
+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH3 GENMASK(12, 8)
+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH2 GENMASK(4, 0)
+#define YT8824_P1_DAC_BIAS_CAS_CH1_CH0_REG 0xa2d8
+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH1 GENMASK(12, 8)
+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH0 GENMASK(4, 0)
+#define YT8824_P01_PLL_EN_REG 0xa218
+#define YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET BIT(6)
+#define YT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET BIT(5)
+#define YT8824_U0_CSR_RESET_REG 0xa01d
+#define YT8824_U0_CSR_RESETB_TX_CH0 BIT(3)
+#define YT8824_U0_CSR_RESETB_TX_CH1 BIT(2)
+#define YT8824_U0_CSR_RESETB_TX_CH2 BIT(1)
+#define YT8824_U0_CSR_RESETB_TX_CH3 BIT(0)
+#define YT8824_U1_CSR_RESET_REG 0xa01e
+#define YT8824_U1_CSR_RESETB_TX_CH0 BIT(3)
+#define YT8824_U1_CSR_RESETB_TX_CH1 BIT(2)
+#define YT8824_U1_CSR_RESETB_TX_CH2 BIT(1)
+#define YT8824_U1_CSR_RESETB_TX_CH3 BIT(0)
+/* External PHY8824 serdes init registers */
+#define YT8824_SERDES_PLL_CTRL1_REG 0xa13e
+#define YT8824_SERDES_PLL_CTRL2_REG 0xa13f
+#define YT8824_SERDES_PLL_CTRL3_REG 0xa140
+#define YT8824_WRITE_PROTECT_REG 0x4be
+#define YT8824_SERDES_REG_WR_PRT BIT(2)
+#define YT8824_CSR_CTRL_REG 0x49f
+#define YT8824_CSR_PCS_GLB_RST_BYPASS BIT(10)
+#define YT8824_CSR_SG_MODE_RST_BYPASS BIT(9)
+#define YT8824_CSR_US_GLB_RESET_N BIT(7)
+#define YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS BIT(2)
+#define YT8824_CSR_PMA_CTRL_REG 0x4a9
+#define YT8824_CSR_WATCH_DOG_ALL_BYPASS BIT(7)
+#define YT8824_CDR_CTRL_REG 0x406
+#define YT8824_CDR_MODE BIT(11)
+#define YT8824_CSR_PLL_VCO_CTRL_REG 0x438
+#define YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT GENMASK(15, 12)
+#define YT8824_CSR_PLL_VCO_ATEMP_R GENMASK(2, 0)
+#define YT8824_CSR_PLL_DIVLDO_CTRL_REG 0x439
+#define YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R GENMASK(1, 0)
+#define YT8824_CSR_PLL_FBDIV_REG 0x043a
+#define YT8824_CSR_PLL_FBDIV_SYNC_SELB BIT(1)
+#define YT8824_CSR_PLL_SPARE_CTRL_REG 0x042a
+#define YT8824_CSR_PLL_SPARE GENMASK(15, 0)
+#define YT8824_CDR_MANUAL_REG 0x0491
+#define YT8824_VDAC_AMP_THR_LNG GENMASK(6, 0)
+#define YT8824_TRAINING_CTRL_REG 0x0492
+#define YT8824_VDAC_AMP_THR_MED GENMASK(14, 8)
+#define YT8824_VDAC_AMP_THR_SHT GENMASK(7, 0)
+#define YT8824_EOM_CTRL_REG 0x0454
+#define YT8824_EOD_DURATION_SEL GENMASK(11, 8)
+#define YT8824_EOD_VTH GENMASK(6, 0)
+#define YT8824_PGA_GAIN_CTRL_REG 0x0497
+#define YT8824_CDR_OFFSET_ERR_WTH GENMASK(14, 8)
+#define YT8824_PGA_GAIN_MAX GENMASK(6, 4)
+#define YT8824_PGA_GAIN_INIT GENMASK(2, 0)
+#define YT8824_EOD_CTRL_REG 0x04cd
+#define YT8824_EOD_ERR_CNT_THR GENMASK(15, 0)
+#define YT8824_CSR_AFE_CTRL_REG 0x04af
+#define YT8824_CSR_AFE_VCM_CFG GENMASK(10, 8)
+#define YT8824_CSR_AFE_MANUAL_CTRL_1P25G BIT(4)
+#define YT8824_CSR_AFE_MANUAL_CTRL_3P125G BIT(3)
+#define YT8824_CSR_AFE_MANUAL_CTRL_10P3125G BIT(2)
+#define YT8824_DFE_CTRL_REG 0x048a
+#define YT8824_DFE_TAP_POLARITY BIT(12)
+#define YT8824_DFE_IDAC_TUNE GENMASK(11, 10)
+#define YT8824_CSR_CDR_CTRL_REG 0x0408
+#define YT8824_CSR_CDR_OFFSET_DATA GENMASK(14, 8)
+#define YT8824_DFE_VDAC_CODE_REG 0x04d6
+#define YT8824_DFE_VDAC_CODE_THR GENMASK(6, 0)
+#define YT8824_RX_SPARE_CTRL_REG 0x044f
+#define YT8824_RX_SPARE_REG GENMASK(15, 0)
+#define YT8824_DFE_VDAC_CTRL_REG 0x048e
+#define YT8824_DFE_VDAC_TUNE GENMASK(11, 10)
+#define YT8824_DFE_VDAC_SEL GENMASK(9, 8)
+#define YT8824_CSR_TX_PRE_REG 0x000d
+#define YT8824_CSR_TX_PRE_SEL GENMASK(4, 0)
+#define YT8824_CSR_AFE_CTRL1_REG 0x04b0
+#define YT8824_CSR_AFE_CTLE_BW GENMASK(6, 4)
+#define YT8824_CSR_AFE_CTRL2_REG 0x04b1
+#define YT8824_CSR_AFE_PGA_BW GENMASK(14, 12)
+#define YT8824_CSR_AFE_BUF_BW GENMASK(6, 4)
+#define YT8824_CSR_DCC_CAL_CTRL_REG 0x0003
+#define YT8824_CUR_TX_SEQ GENMASK(15, 12)
+#define YT8824_CUR_RX_SEQ GENMASK(11, 8)
+#define YT8824_CALIB_SEQ_FINISH BIT(1)
+#define YT8824_CALIB_SEQ_SW_RST BIT(0)
+#define YT8824_RESTART_CAL_CTRL_REG 0x2000
+#define YT8824_DAC_TRIM_MAIN_CFG_REG 0x429
+#define YT8824_PLL_VCO_CFG_REG 0x441
+#define YT8824_TX_MUX_CH3_CH2_REG 0x42b
+#define YT8824_C1_COARSE_CFG_REG 0x4b4
+#define YT8824_FFE_CTRL_REG 0x4b5
+
struct yt8521_priv {
/* combo_advertising is used for case of YT8521 in combo mode,
* this means that yt8521 may work in utp or fiber mode which depends
@@ -415,6 +654,14 @@ struct yt8521_priv {
u8 reg_page;
};
+struct yt8824_shared_priv {
+ phy_interface_t package_mode;
+ /* shared_lock used to UTPs operation isolation during swap reg space */
+ struct mutex shared_lock;
+ /* true once the package-wide SERDES init has been done */
+ bool sds_initialized;
+};
+
/**
* ytphy_read_ext() - read a PHY's extended register
* @phydev: a pointer to a &struct phy_device
@@ -453,6 +700,70 @@ static int ytphy_read_ext_with_lock(struct phy_device *phydev, u16 regnum)
return ret;
}
+/**
+ * ytphy_read_top_ext() - read a PHY's top extended register for YT8824
+ * @phydev: a pointer to a &struct phy_device
+ * @regnum: register number to read
+ *
+ * Returns: the value of regnum reg or negative error code
+ */
+static int ytphy_read_top_ext(struct phy_device *phydev, u16 regnum)
+{
+ int ret;
+
+ lockdep_assert_held(&phydev->mdio.bus->mdio_lock);
+ ret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);
+ if (ret < 0)
+ return ret;
+
+ return __phy_package_read(phydev, 0, YTPHY_PAGE_DATA);
+}
+
+/**
+ * ytphy_write_top_ext() - write a PHY's top extended register for YT8824
+ * @phydev: a pointer to a &struct phy_device
+ * @regnum: register number to write
+ * @val: register val to write
+ *
+ * Returns: 0 or negative error code
+ */
+static int ytphy_write_top_ext(struct phy_device *phydev, u16 regnum,
+ u16 val)
+{
+ int ret;
+
+ lockdep_assert_held(&phydev->mdio.bus->mdio_lock);
+ ret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);
+ if (ret < 0)
+ return ret;
+
+ return __phy_package_write(phydev, 0, YTPHY_PAGE_DATA, val);
+}
+
+/**
+ * phy8824_page_write_with_lock() - write page for YT8824
+ * @phydev: a pointer to a &struct phy_device
+ * @page: reg page(YT8824_RSSR_SERDES_SPACE/YT8824_RSSR_UTP_SPACE).
+ *
+ * Returns: 0 or negative error code
+ */
+static int phy8824_page_write_with_lock(struct phy_device *phydev, int page)
+{
+ int ret;
+
+ phy_lock_mdio_bus(phydev);
+ ret = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);
+ if (ret < 0)
+ goto err;
+ ret &= ~YT8824_RSSR_SPACE_MASK;
+ ret |= (page & YT8824_RSSR_SPACE_MASK);
+ ret = ytphy_write_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG, ret);
+
+err:
+ phy_unlock_mdio_bus(phydev);
+ return ret;
+}
+
/**
* ytphy_write_ext() - write a PHY's extended register
* @phydev: a pointer to a &struct phy_device
@@ -638,15 +949,1165 @@ static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
mask = YTPHY_WCR_ENABLE | YTPHY_WCR_INTR_SEL;
ret = ytphy_modify_ext(phydev, YTPHY_WOL_CONFIG_REG, mask, 0);
- /* Disable WOL interrupt */
- ret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,
- YTPHY_IER_WOL, 0);
+ /* Disable WOL interrupt */
+ ret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,
+ YTPHY_IER_WOL, 0);
+ if (ret < 0)
+ goto err_restore_page;
+ }
+
+err_restore_page:
+ return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_read_page() - read PHY8824 reg page
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: current reg space of yt8824 (YT8824_RSSR_SERDES_SPACE/
+ * YT8824_RSSR_UTP_SPACE) or negative errno code
+ */
+static int yt8824_read_page(struct phy_device *phydev)
+{
+ int old_page;
+
+ old_page = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);
+ if (old_page < 0)
+ return old_page;
+
+ return old_page & YT8824_RSSR_SPACE_MASK;
+};
+
+/**
+ * yt8824_write_page() - write reg page
+ * @phydev: a pointer to a &struct phy_device
+ * @page: Reg page(YT8824_RSSR_SERDES_SPACE/YT8824_RSSR_UTP_SPACE) to write.
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_write_page(struct phy_device *phydev, int page)
+{
+ int old_page;
+ u16 data;
+
+ old_page = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);
+ if (old_page < 0)
+ return old_page;
+ data = old_page & (~YT8824_RSSR_SPACE_MASK);
+ data |= page;
+
+ return ytphy_write_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG, data);
+};
+
+/**
+ * yt8824_utp_set_template_test_mode() - config YT8824 UTP test mode.
+ * @phydev: a pointer to a &struct phy_device
+ * @test_mode: template test mode from normal, testmode1 to testmode7
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_set_template_test_mode(struct phy_device *phydev,
+ u16 test_mode)
+{
+ int ret;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ return genphy_c45_template_testmode(phydev, test_mode);
+}
+
+/**
+ * yt8824_sds_isolate_paged() - enable YT8824 serdes isolate.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_sds_isolate_paged(struct phy_device *phydev)
+{
+ int old_page = YT8824_RSSR_UTP_SPACE;
+ int ret = 0;
+
+ old_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);
+ if (old_page < 0)
+ goto err_restore_page;
+
+ /* enable sds isolate */
+ ret = __phy_modify(phydev, MII_BMCR, BMCR_ISOLATE, BMCR_ISOLATE);
+
+err_restore_page:
+ return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_utp_softreset_paged() - config YT8824 UTP softreset.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_softreset_paged(struct phy_device *phydev)
+{
+ int ret = 0;
+ int val;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+ ret = phy_modify(phydev, MII_BMCR, BMCR_RESET, BMCR_RESET);
+ if (ret < 0)
+ return ret;
+ /* wait until softreset done. */
+ return phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET),
+ 50000, 600000, true);
+}
+
+/**
+ * yt8824_sds_isolate_and_softreset_paged() - disable YT8824 serdes isolate
+ * and sds softreset.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_sds_isolate_and_softreset_paged(struct phy_device *phydev)
+{
+ int old_page = YT8824_RSSR_UTP_SPACE;
+ int val = 0;
+ int ret = -1;
+
+ old_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);
+ if (old_page < 0)
+ goto err_restore_page;
+
+ /* sds softreset and disable isolate */
+ ret = __phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ISOLATE,
+ BMCR_RESET & ~BMCR_ISOLATE);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* poll while still holding the lock */
+ ret = read_poll_timeout(__phy_read, val,
+ (val < 0) || !(val & BMCR_RESET), 50000, 600000,
+ true, phydev, MII_BMCR);
+ if (val < 0)
+ ret = val;
+
+err_restore_page:
+ return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_restore_working_status() - called to do store working status
+ * @phydev: a pointer to a &struct phy_device
+ * @ret: operation's return code
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_restore_working_status(struct phy_device *phydev, int ret)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int r;
+
+ r = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret >= 0 && r < 0)
+ ret = r;
+ if (priv->package_mode != PHY_INTERFACE_MODE_INTERNAL) {
+ r = yt8824_sds_isolate_and_softreset_paged(phydev);
+ if (ret >= 0 && r < 0)
+ ret = r;
+ }
+
+ return ret;
+}
+
+/**
+ * yt8824_soft_reset() - called to do PHY software reset
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_soft_reset(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int ret;
+
+ mutex_lock(&priv->shared_lock);
+ if (priv->package_mode == PHY_INTERFACE_MODE_INTERNAL) {
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_softreset_paged(phydev);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+ } else {
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_sds_isolate_paged(phydev);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_softreset_paged(phydev);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_sds_isolate_and_softreset_paged(phydev);
+ if (ret < 0)
+ goto retry;
+ }
+ mutex_unlock(&priv->shared_lock);
+ return ret;
+retry:
+ ret = yt8824_restore_working_status(phydev, ret);
+ mutex_unlock(&priv->shared_lock);
+
+ return ret;
+}
+
+/**
+ * yt8824_config_utp_init_paged() - config external phy8824 utp init
+ * @phydev: target phy_device struct
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_config_utp_init_paged(struct phy_device *phydev)
+{
+ int ctrl = 0;
+ int mask = 0;
+ int ret = 0;
+ int val = 0;
+ int r;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ ret = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);
+ if (ret < 0)
+ goto err_restore;
+
+ /* write protecting */
+ mask = YT8824_WRITE_PROTECT;
+ ctrl = YT8824_WRITE_PROTECT;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_WRITE_PROTECT_CAL_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* PLL calibration */
+ ctrl = FIELD_PREP(YT8824_PLL_VCO_SEL_CURRENT, 0xb);
+ mask = YT8824_PLL_VCO_SEL_CURRENT;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_PLL_VCO_ATEMP_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_PLL_VCO_ICOSTANT, 0xf);
+ mask = YT8824_PLL_VCO_ICOSTANT;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_PLL_PFD_CTRL_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_PLL_VCO_IPTAT, 0xf);
+ mask = YT8824_PLL_VCO_IPTAT;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_PLL_VCO_ATEMP_1_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_PLL_DAC_RST, 0);
+ mask = YT8824_PLL_DAC_RST;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_PLL_DAC_0_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_PLL_DAC_RST, 1);
+ mask = YT8824_PLL_DAC_RST;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_PLL_DAC_0_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* enable nibble */
+ ctrl = FIELD_PREP(YT8824_U0_U1_ENABLE_ODD_PREAMBLE, 3);
+ mask = YT8824_U0_U1_ENABLE_ODD_PREAMBLE;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_IF_CTRL_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* idle err detect enable */
+ ctrl = YT8824_IDLE_DETECT;
+ mask = YT8824_IDLE_DETECT;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_IDLE_CTRL_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized 2.5G long cable performance */
+ ctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR_2500, 0x50);
+ ctrl |= FIELD_PREP(YT8824_TRACE_MED_GAIN_THR_2500, 0x38);
+ mask = YT8824_TRACE_LNG_GAIN_THR_2500 |
+ YT8824_TRACE_MED_GAIN_THR_2500;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_TRACE_GAIN_THR_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_PRM_LARGE_SLAVE_2500, 0x68);
+ mask = YT8824_PRM_LARGE_SLAVE_2500;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_PRM_LONG_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_PRM_SMALL_LNG_2500, 0xa0);
+ mask = YT8824_PRM_SMALL_LNG_2500;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_PRM_SMALL_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized fast retrain */
+ ctrl = FIELD_PREP(YT8824_LINK_FAIL_SIG, 0x21);
+ mask = YT8824_LINK_FAIL_SIG;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_FAST_RETRAIN_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_EN_GATE_GMII_CLK, 0);
+ mask = YT8824_EN_GATE_GMII_CLK;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_EN_GATE_CTRL_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* 2.5G template tone */
+ ctrl = FIELD_PREP(YT8824_POWER_SAVE, 0x83);
+ mask = YT8824_POWER_SAVE;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_CFG_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_DAC_BIAS_CFG_2500, 0xa);
+ mask = YT8824_DAC_BIAS_CFG_2500;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_BIAS_CFG_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized 2.5G template */
+ ctrl = FIELD_PREP(YT8824_DAC_IMID_CH2, 0x39);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMID_CH3, 0x39);
+ mask = YT8824_DAC_IMID_CH2 | YT8824_DAC_IMID_CH3;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMID_CFG_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_DAC_IMID_CH0, 0x39);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMID_CH1, 0x39);
+ mask = YT8824_DAC_IMID_CH0 | YT8824_DAC_IMID_CH1;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMID_CFG1_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_DAC_IMSB_CH2, 0x39);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH3, 0x39);
+ mask = YT8824_DAC_IMSB_CH2 | YT8824_DAC_IMSB_CH3;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMSB_CFG_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_DAC_IMSB_CH0, 0x39);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH1, 0x39);
+ mask = YT8824_DAC_IMSB_CH0 | YT8824_DAC_IMSB_CH1;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMSB_CFG1_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized 1000M cable length threshold */
+ ctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR, 0x2b);
+ mask = YT8824_TRACE_LNG_GAIN_THR;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_TRACE_LNG_GAIN_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_TRACE_MED_GAIN_THR, 0x1d);
+ mask = YT8824_TRACE_MED_GAIN_THR;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_TRACE_MED_GAIN_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* 100M template amplitude */
+ ctrl = FIELD_PREP(YT8824_DAC_IMID_CH3_ORG, 0x45);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMID_CH2_ORG, 0x45);
+ mask = YT8824_DAC_IMID_CH3_ORG | YT8824_DAC_IMID_CH2_ORG;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMID_CH2_CH3_CFG_ORG_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_DAC_IMID_CH1_ORG, 0x45);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMID_CH0_ORG, 0x45);
+ mask = YT8824_DAC_IMID_CH1_ORG | YT8824_DAC_IMID_CH0_ORG;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMID_CH0_CH1_CFG_ORG_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_DAC_IMSB_CH3_ORG, 0x45);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH2_ORG, 0x45);
+ mask = YT8824_DAC_IMSB_CH2_ORG | YT8824_DAC_IMSB_CH3_ORG;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMSB_CH2_CH3_CFG_ORG_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_DAC_IMSB_CH1_ORG, 0x45);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH0_ORG, 0x45);
+ mask = YT8824_DAC_IMSB_CH1_ORG | YT8824_DAC_IMSB_CH0_ORG;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMSB_CH0_CH1_CFG_ORG_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized 100M cable length threshold */
+ ctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR_100, 0x2A);
+ ctrl |= FIELD_PREP(YT8824_TRACE_MED_GAIN_THR_100, 0x1D);
+ mask = YT8824_TRACE_LNG_GAIN_THR_100 | YT8824_TRACE_MED_GAIN_THR_100;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_TRACE_LNG_GAIN_100_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_CABLE_VSHT_THR_S, 0x36);
+ mask = YT8824_CABLE_VSHT_THR_S;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_CABLE_VSHT_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* 10M template amplitude */
+ ctrl = FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH3_10, 0x18);
+ ctrl |= FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH2_10, 0x18);
+ mask = YT8824_DAC_LPFIL_ADJ_CH3_10 | YT8824_DAC_LPFIL_ADJ_CH2_10;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_LPFIL_CH2_CH3_ADJ_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH1_10, 0x18);
+ ctrl |= FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH0_10, 0x18);
+ mask = YT8824_DAC_LPFIL_ADJ_CH1_10 | YT8824_DAC_LPFIL_ADJ_CH0_10;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_LPFIL_CH0_CH1_ADJ_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized 10M cable length threshold */
+ ctrl = FIELD_PREP(YT8824_DAC_IMID_CFG_CH3_10_ORG, 0x6C);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMID_CFG_CH2_10_ORG, 0x6C);
+ mask = YT8824_DAC_IMID_CFG_CH3_10_ORG | YT8824_DAC_IMID_CFG_CH2_10_ORG;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMID_CFG_CH2_CH3_10_ORG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_DAC_IMID_CFG_CH1_10_ORG, 0x6C);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMID_CFG_CH0_10_ORG, 0x6C);
+ mask = YT8824_DAC_IMID_CFG_CH1_10_ORG | YT8824_DAC_IMID_CFG_CH0_10_ORG;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMID_CFG_CH0_CH1_10_ORG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized DAC IMSB config for CH2/CH3 */
+ ctrl = FIELD_PREP(YT8824_DAC_IMSB_CFG_CH3_10_ORG, 0x6C);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CFG_CH2_10_ORG, 0x6C);
+ mask = YT8824_DAC_IMSB_CFG_CH3_10_ORG | YT8824_DAC_IMSB_CFG_CH2_10_ORG;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMSB_CFG_CH2_CH3_10_ORG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized DAC IMSB config for CH0/CH1 */
+ ctrl = FIELD_PREP(YT8824_DAC_IMSB_CFG_CH1_10_ORG, 0x6C);
+ ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CFG_CH0_10_ORG, 0x6C);
+ mask = YT8824_DAC_IMSB_CFG_CH1_10_ORG | YT8824_DAC_IMSB_CFG_CH0_10_ORG;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_IMSB_CFG_CH0_CH1_10_ORG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimize utp 1000M performance */
+ ctrl = FIELD_PREP(YT8824_WAIT_TO_1000, 0xFF);
+ mask = YT8824_WAIT_TO_1000;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_FFE_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_EN_GATE_PHYDBG, 0);
+ ctrl |= FIELD_PREP(YT8824_EN_GATE_BT1000, 0);
+ mask = YT8824_EN_GATE_PHYDBG | YT8824_EN_GATE_BT1000;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_EN_GATE_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_CNT_ERR_AUTO, 1);
+ mask = YT8824_CNT_ERR_AUTO;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_CNT_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_PRM_LARGE_MASTER_1000, 0x94);
+ mask = YT8824_PRM_LARGE_MASTER_1000;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_PRM_LARGE_MASTER_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_PRM_LARGE_SLAVE_1000, 0x094);
+ mask = YT8824_PRM_LARGE_SLAVE_1000;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_PRM_LARGE_SLAVE_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_SIG_GONE_THR_1000, 0x08);
+ mask = YT8824_SIG_GONE_THR_1000;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_SIG_GONE_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_EC_NX_TRAIN_COARSE_TO_1000, 0x40);
+ mask = YT8824_EC_NX_TRAIN_COARSE_TO_1000;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_EC_NX_TRAIN_COARSE_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_VGA_IN_LPF2_CAP_OTHER, 0x2);
+ mask = YT8824_VGA_IN_LPF2_CAP_OTHER;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_VGA_IN_LPF2_CAP_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_VGA_IN_LPF1_CAP_OTHER, 0x2);
+ mask = YT8824_VGA_IN_LPF1_CAP_OTHER;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_VGA_IN_LPF1_CAP_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized EMC CS */
+ ctrl = FIELD_PREP(YT8824_LDPC_FAIL_THR, 0xFF);
+ ctrl |= FIELD_PREP(YT8824_LFER_FAIL_THR, 0xFF);
+ mask = YT8824_LDPC_FAIL_THR | YT8824_LFER_FAIL_THR;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_LDPC_LFER_FAIL_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_FR_REQ_THR, 0x06);
+ mask = YT8824_FR_REQ_THR;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_FR_REQ_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_PRM_SMALL_SHT_2500, 0x0FF);
+ mask = YT8824_PRM_SMALL_SHT_2500;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_GN_MU_COARSE_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized EMC RE */
+ ctrl = FIELD_PREP(YT8824_DAC_AMP_ADJ_CH3_PBO0_2500, 0xF);
+ ctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH2_PBO0_2500, 0xF);
+ ctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH1_PBO0_2500, 0xF);
+ ctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH0_PBO0_2500, 0xF);
+ mask = YT8824_DAC_AMP_ADJ_CH3_PBO0_2500 |
+ YT8824_DAC_AMP_ADJ_CH2_PBO0_2500 |
+ YT8824_DAC_AMP_ADJ_CH1_PBO0_2500 |
+ YT8824_DAC_AMP_ADJ_CH0_PBO0_2500;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_DAC_AMP_ADJ_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH3, 0x1F);
+ ctrl |= FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH2, 0x1F);
+ mask = YT8824_P0_DAC_BIAS_CAS_CFG_CH3 | YT8824_P0_DAC_BIAS_CAS_CFG_CH2;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_P0_DAC_BIAS_CAS_CH3_CH2_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH1, 0x1F);
+ ctrl |= FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH0, 0x1F);
+ mask = YT8824_P0_DAC_BIAS_CAS_CFG_CH1 | YT8824_P0_DAC_BIAS_CAS_CFG_CH0;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_P0_DAC_BIAS_CAS_CH1_CH0_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH3, 0x1F);
+ ctrl |= FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH2, 0x1F);
+ mask = YT8824_P1_DAC_BIAS_CAS_CFG_CH3 | YT8824_P1_DAC_BIAS_CAS_CFG_CH2;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_P1_DAC_BIAS_CAS_CH3_CH2_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH1, 0x1F);
+ ctrl |= FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH0, 0x1F);
+ mask = YT8824_P1_DAC_BIAS_CAS_CFG_CH1 | YT8824_P1_DAC_BIAS_CAS_CFG_CH0;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_P1_DAC_BIAS_CAS_CH1_CH0_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET, 1);
+ ctrl |= FIELD_PREP(YT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET, 1);
+ mask = YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET |
+ YT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET;
+ ret = ytphy_modify_ext_with_lock(phydev,
+ YT8824_P01_PLL_EN_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH0, 0);
+ ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH1, 0);
+ ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH2, 0);
+ ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH3, 0);
+ mask = YT8824_U0_CSR_RESETB_TX_CH0 | YT8824_U0_CSR_RESETB_TX_CH1 |
+ YT8824_U0_CSR_RESETB_TX_CH2 | YT8824_U0_CSR_RESETB_TX_CH3;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_U0_CSR_RESET_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH0, 0);
+ ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH1, 0);
+ ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH2, 0);
+ ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH3, 0);
+ mask = YT8824_U1_CSR_RESETB_TX_CH0 | YT8824_U1_CSR_RESETB_TX_CH1 |
+ YT8824_U1_CSR_RESETB_TX_CH2 | YT8824_U1_CSR_RESETB_TX_CH3;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_U1_CSR_RESET_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH0, 1);
+ ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH1, 1);
+ ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH2, 1);
+ ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH3, 1);
+ mask = YT8824_U0_CSR_RESETB_TX_CH0 | YT8824_U0_CSR_RESETB_TX_CH1 |
+ YT8824_U0_CSR_RESETB_TX_CH2 | YT8824_U0_CSR_RESETB_TX_CH3;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_U0_CSR_RESET_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+
+ ctrl = FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH0, 1);
+ ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH1, 1);
+ ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH2, 1);
+ ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH3, 1);
+ mask = YT8824_U1_CSR_RESETB_TX_CH0 | YT8824_U1_CSR_RESETB_TX_CH1 |
+ YT8824_U1_CSR_RESETB_TX_CH2 | YT8824_U1_CSR_RESETB_TX_CH3;
+ ret = ytphy_modify_ext_with_lock(phydev, YT8824_U1_CSR_RESET_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore;
+ /* reset */
+ ret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto err_restore_normal;
+
+ ret = phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE,
+ BMCR_RESET | BMCR_ANENABLE);
+ if (ret < 0)
+ goto err_restore_normal;
+ ret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET),
+ 50000, 600000, true);
+ if (ret < 0)
+ goto err_restore_normal;
+
+ ret = genphy_c45_template_testmode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto err_restore_normal;
+ return 0;
+
+err_restore:
+ r = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, 0);
+ if (ret >= 0 && r < 0)
+ ret = r;
+ return ret;
+
+err_restore_normal:
+ r = genphy_c45_template_testmode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret >= 0 && r < 0)
+ ret = r;
+ r = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, 0);
+ if (ret >= 0 && r < 0)
+ ret = r;
+ return ret;
+}
+
+/**
+ * yt8824_extern_sds_softreset() - config external phy8824 sds softrest
+ * @phydev: target phy_device struct
+ *
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_extern_sds_softreset(struct phy_device *phydev)
+{
+ int old_page = YT8824_RSSR_UTP_SPACE;
+ int ret = -1;
+ int val = 0;
+
+ old_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);
+ if (old_page < 0)
+ goto err_restore_page;
+
+ /* TX preamble padded to 8; RX IPG always > 8 */
+ ret = __phy_read(phydev, MII_RESV1);
+ if (ret < 0)
+ goto err_restore_page;
+ ret &= ~YT8824_SDS_CFG_MIN_PRE_MASK;
+ ret |= YT8824_SDS_TX_PRE_PADDING;
+ ret |= YT8824_SDS_EN_FILL_PRE;
+ ret = __phy_write(phydev, MII_RESV1, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = __phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE,
+ BMCR_RESET | BMCR_ANENABLE);
+ if (ret < 0)
+ goto err_restore_page;
+ /* poll while still holding the lock; __phy_read takes no lock */
+ ret = read_poll_timeout(__phy_read, val,
+ (val < 0) || !(val & BMCR_RESET), 50000, 600000,
+ true, phydev, MII_BMCR);
+ if (val < 0)
+ ret = val;
+
+err_restore_page:
+ return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_extern_config_sds_init_paged() - config external phy8824 sds init
+ * @phydev: target phy_device struct
+ *
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_extern_config_sds_init_paged(struct phy_device *phydev)
+{
+ int old_page = YT8824_RSSR_UTP_SPACE;
+ int val_1, val_2, val_3, tmp;
+ int ctrl = 0;
+ int mask = 0;
+ int ret = -1;
+
+ old_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);
+ if (old_page < 0)
+ goto err_restore_page;
+
+ /* read efuse */
+ ret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL1_REG);
+ if (ret < 0)
+ goto err_restore_page;
+ else
+ val_1 = ret;
+
+ ret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL2_REG);
+ if (ret < 0)
+ goto err_restore_page;
+ else
+ val_2 = ret;
+
+ ret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL3_REG);
+ if (ret < 0)
+ goto err_restore_page;
+ else
+ val_3 = ret;
+
+ /* Serdes optimization */
+ ctrl = FIELD_PREP(YT8824_SERDES_REG_WR_PRT, 1);
+ mask = YT8824_SERDES_REG_WR_PRT;
+ ret = ytphy_modify_ext(phydev, YT8824_WRITE_PROTECT_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_CSR_PCS_GLB_RST_BYPASS, 1);
+ ctrl |= FIELD_PREP(YT8824_CSR_SG_MODE_RST_BYPASS, 1);
+ ctrl |= FIELD_PREP(YT8824_CSR_US_GLB_RESET_N, 0);
+ ctrl |= FIELD_PREP(YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS, 1);
+ mask = YT8824_CSR_PCS_GLB_RST_BYPASS | YT8824_CSR_SG_MODE_RST_BYPASS |
+ YT8824_CSR_US_GLB_RESET_N |
+ YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_CSR_WATCH_DOG_ALL_BYPASS, 1);
+ mask = YT8824_CSR_WATCH_DOG_ALL_BYPASS;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_PMA_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* analog CDR */
+ ctrl = FIELD_PREP(YT8824_CDR_MODE, 1);
+ mask = YT8824_CDR_MODE;
+ ret = ytphy_modify_ext(phydev, YT8824_CDR_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* optimized VCO */
+ ctrl = FIELD_PREP(YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT, 0x9);
+ ctrl |= FIELD_PREP(YT8824_CSR_PLL_VCO_ATEMP_R, 0x4);
+ mask = YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT | YT8824_CSR_PLL_VCO_ATEMP_R;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_VCO_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R, 0x0);
+ mask = YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_DIVLDO_CTRL_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* optimized PLL lock */
+ ret = ytphy_read_ext(phydev, YT8824_DAC_TRIM_MAIN_CFG_REG);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret &= ~(BIT(13) | BIT(12));
+ tmp = (val_1 & (BIT(7) | BIT(6))) >> 6;
+ ret |= (tmp << 12);
+ ret = ytphy_write_ext(phydev, YT8824_DAC_TRIM_MAIN_CFG_REG, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_read_ext(phydev, YT8824_PLL_VCO_CFG_REG);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret &= ~(BIT(1) | BIT(0));
+ tmp = (val_1 & (BIT(5) | BIT(4))) >> 4;
+ ret |= tmp;
+ ret = ytphy_write_ext(phydev, YT8824_PLL_VCO_CFG_REG, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_read_ext(phydev, YT8824_TX_MUX_CH3_CH2_REG);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret &= ~(BIT(13) | BIT(12));
+ tmp = (val_3 & (BIT(1) | BIT(0)));
+ ret |= (tmp << 12);
+ ret = ytphy_write_ext(phydev, YT8824_TX_MUX_CH3_CH2_REG, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_CSR_PLL_FBDIV_SYNC_SELB, 1);
+ mask = YT8824_CSR_PLL_FBDIV_SYNC_SELB;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_FBDIV_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_CSR_PLL_SPARE, 0xf070);
+ mask = YT8824_CSR_PLL_SPARE;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_SPARE_CTRL_REG,
+ mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* cable length threshold */
+ ctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_LNG, 0x7F);
+ mask = YT8824_VDAC_AMP_THR_LNG;
+ ret = ytphy_modify_ext(phydev, YT8824_CDR_MANUAL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);
+ ctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0x7F);
+ mask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;
+ ret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* Serdes training threshold */
+ ctrl = FIELD_PREP(YT8824_EOD_DURATION_SEL, 0xF);
+ ctrl |= FIELD_PREP(YT8824_EOD_VTH, 0x14);
+ mask = YT8824_EOD_DURATION_SEL | YT8824_EOD_VTH;
+ ret = ytphy_modify_ext(phydev, YT8824_EOM_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_CDR_OFFSET_ERR_WTH, 0x0A);
+ ctrl |= FIELD_PREP(YT8824_PGA_GAIN_MAX, 0x4);
+ ctrl |= FIELD_PREP(YT8824_PGA_GAIN_INIT, 0x4);
+ mask = YT8824_CDR_OFFSET_ERR_WTH | YT8824_PGA_GAIN_MAX |
+ YT8824_PGA_GAIN_INIT;
+ ret = ytphy_modify_ext(phydev, YT8824_PGA_GAIN_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* digital eye diagram of SerDes */
+ ctrl = FIELD_PREP(YT8824_EOD_ERR_CNT_THR, 0x0000);
+ mask = YT8824_EOD_ERR_CNT_THR;
+ ret = ytphy_modify_ext(phydev, YT8824_EOD_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* Serdes LDO */
+ ret = ytphy_read_ext(phydev, YT8824_FFE_CTRL_REG);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret &= ~(BIT(6) | BIT(5) | BIT(4));
+ tmp = (val_2 & (BIT(4) | BIT(3) | BIT(2))) >> 2;
+ ret |= (tmp << 4);
+ ret = ytphy_write_ext(phydev, YT8824_FFE_CTRL_REG, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_read_ext(phydev, YT8824_C1_COARSE_CFG_REG);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret &= ~(BIT(10) | BIT(9) | BIT(8));
+ tmp = (val_2 & (BIT(7) | BIT(6) | BIT(5))) >> 5;
+ ret |= (tmp << 8);
+ ret = ytphy_write_ext(phydev, YT8824_C1_COARSE_CFG_REG, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* optimized Serdes RX */
+ ctrl = FIELD_PREP(YT8824_CSR_AFE_VCM_CFG, 0x5);
+ ctrl |= FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_1P25G, 0);
+ ctrl |= FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_3P125G, 0);
+ mask = YT8824_CSR_AFE_VCM_CFG | YT8824_CSR_AFE_MANUAL_CTRL_1P25G |
+ YT8824_CSR_AFE_MANUAL_CTRL_3P125G;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_DFE_TAP_POLARITY, 1);
+ ctrl |= FIELD_PREP(YT8824_DFE_IDAC_TUNE, 0x3);
+ mask = YT8824_DFE_TAP_POLARITY | YT8824_DFE_IDAC_TUNE;
+ ret = ytphy_modify_ext(phydev, YT8824_DFE_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_CSR_CDR_OFFSET_DATA, 0x7C);
+ mask = YT8824_CSR_CDR_OFFSET_DATA;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_CDR_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_DFE_VDAC_CODE_THR, 0x7F);
+ mask = YT8824_DFE_VDAC_CODE_THR;
+ ret = ytphy_modify_ext(phydev, YT8824_DFE_VDAC_CODE_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_RX_SPARE_REG, 0xff08);
+ mask = YT8824_RX_SPARE_REG;
+ ret = ytphy_modify_ext(phydev, YT8824_RX_SPARE_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* optimized Serdes TX */
+ ctrl = FIELD_PREP(YT8824_DFE_VDAC_TUNE, 0x1);
+ ctrl |= FIELD_PREP(YT8824_DFE_VDAC_SEL, 0x0);
+ mask = YT8824_DFE_VDAC_TUNE | YT8824_DFE_VDAC_SEL;
+ ret = ytphy_modify_ext(phydev, YT8824_DFE_VDAC_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_CSR_TX_PRE_SEL, 0x6);
+ mask = YT8824_CSR_TX_PRE_SEL;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_TX_PRE_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* Serdes manual config */
+ ctrl = FIELD_PREP(YT8824_CSR_AFE_CTLE_BW, 0x0);
+ mask = YT8824_CSR_AFE_CTLE_BW;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL1_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_CSR_AFE_PGA_BW, 0x7);
+ ctrl |= FIELD_PREP(YT8824_CSR_AFE_BUF_BW, 0x7);
+ mask = YT8824_CSR_AFE_PGA_BW | YT8824_CSR_AFE_BUF_BW;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL2_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_10P3125G, 0x1);
+ mask = YT8824_CSR_AFE_MANUAL_CTRL_10P3125G;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* restart calibration */
+ ctrl = FIELD_PREP(YT8824_CUR_TX_SEQ, 0x5);
+ ctrl |= FIELD_PREP(YT8824_CUR_RX_SEQ, 0x6);
+ ctrl |= FIELD_PREP(YT8824_CALIB_SEQ_FINISH, 1);
+ ctrl |= FIELD_PREP(YT8824_CALIB_SEQ_SW_RST, 1);
+ mask = YT8824_CUR_TX_SEQ | YT8824_CUR_RX_SEQ |
+ YT8824_CALIB_SEQ_FINISH | YT8824_CALIB_SEQ_SW_RST;
+ ret = ytphy_modify_ext(phydev, YT8824_CSR_DCC_CAL_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);
+ ctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0xFF);
+ mask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;
+ ret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);
+ ctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0x7F);
+ mask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;
+ ret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* restart to calibration */
+ ret = ytphy_write_ext(phydev, YT8824_RESTART_CAL_CTRL_REG, 0x0040);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, YT8824_RESTART_CAL_CTRL_REG, 0x0);
+ if (ret < 0)
+ goto err_restore_page;
+
+err_restore_page:
+ return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_config_init() - phy initializatioin
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_config_init(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int ret;
+
+ mutex_lock(&priv->shared_lock);
+ if (priv->package_mode == PHY_INTERFACE_MODE_INTERNAL) {
+ ret = yt8824_config_utp_init_paged(phydev);
+ if (ret < 0)
+ goto err;
+ } else {
+ if (!priv->sds_initialized) {
+ ret = yt8824_extern_config_sds_init_paged(phydev);
+ if (ret < 0)
+ goto err;
+ priv->sds_initialized = true;
+ }
+ /*
+ * Configuring the MII registers of the SDS,
+ * which are private to each channel.
+ */
+ ret = yt8824_extern_sds_softreset(phydev);
+ if (ret < 0)
+ goto err;
+
+ ret = yt8824_config_utp_init_paged(phydev);
if (ret < 0)
- goto err_restore_page;
+ goto err;
}
+ mutex_unlock(&priv->shared_lock);
+ ret = yt8824_soft_reset(phydev);
-err_restore_page:
- return phy_restore_page(phydev, old_page, ret);
+ phydev_dbg(phydev, "%s done, phy addr: %d\n", __func__,
+ phydev->mdio.addr);
+ return ret;
+err:
+ mutex_unlock(&priv->shared_lock);
+ return ret;
}
static int yt8531_set_wol(struct phy_device *phydev,
@@ -3240,6 +4701,450 @@ static int yt8821_resume(struct phy_device *phydev)
return yt8821_modify_utp_fiber_bmcr(phydev, BMCR_PDOWN, 0);
}
+/**
+ * yt8824_get_features - read mmd register to get 2.5G capability
+ * @phydev: target phy_device struct
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_get_features(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int ret;
+
+ mutex_lock(&priv->shared_lock);
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ goto err;
+ ret = yt8821_get_features(phydev);
+
+err:
+ mutex_unlock(&priv->shared_lock);
+ return ret;
+}
+
+/**
+ * yt8824_aneg_done() - check negotiation state.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: auto-negotiation complete status or negative errno code
+ */
+static int yt8824_aneg_done(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int auto_neg;
+ int ret;
+
+ mutex_lock(&priv->shared_lock);
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ goto err;
+
+ ret = phy_read(phydev, MII_BMSR);
+ if (ret < 0)
+ goto err;
+ mutex_unlock(&priv->shared_lock);
+ auto_neg = !!(ret & BMSR_ANEGCOMPLETE);
+
+ phydev_dbg(phydev, "%s, phy addr: %d, auto negotiation done: %d\n",
+ __func__, phydev->mdio.addr, auto_neg);
+ return auto_neg;
+err:
+ mutex_unlock(&priv->shared_lock);
+ return ret;
+}
+
+/**
+ * yt8824_read_status_paged() - determines the speed and duplex of one page
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_read_status_paged(struct phy_device *phydev)
+{
+ int ret;
+ int val;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ ret = genphy_read_status(phydev);
+ if (ret < 0)
+ return ret;
+
+ if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) {
+ ret = genphy_c45_read_lpa(phydev);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (!phydev->link) {
+ phydev->speed = SPEED_UNKNOWN;
+ phydev->duplex = DUPLEX_UNKNOWN;
+ if (phydev->autoneg == AUTONEG_ENABLE)
+ phy_resolve_aneg_pause(phydev);
+ return 0;
+ }
+
+ ret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);
+ if (ret < 0)
+ return ret;
+
+ val = ret;
+
+ yt8821_adjust_status(phydev, val);
+
+ if (phydev->autoneg == AUTONEG_ENABLE)
+ phy_resolve_aneg_pause(phydev);
+
+ return 0;
+}
+
+/**
+ * yt8824_read_status() - determines the negotiated speed and duplex
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_read_status(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int ret;
+
+ mutex_lock(&priv->shared_lock);
+ ret = yt8824_read_status_paged(phydev);
+ mutex_unlock(&priv->shared_lock);
+
+ return ret;
+}
+
+/**
+ * yt8824_utp_power_on(): utp power on.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_power_on(struct phy_device *phydev)
+{
+ int ret = 0;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0x0);
+}
+
+/**
+ * yt8824_utp_power_down(): utp power down.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_power_down(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ return phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);
+}
+
+/**
+ * yt8824_power_on() - set utp power on.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * NOTE: need WA like softreset
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_power_on(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int ret;
+ int r;
+
+ if (priv->package_mode == PHY_INTERFACE_MODE_INTERNAL) {
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_power_on(phydev);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+ } else {
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_sds_isolate_paged(phydev);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_power_on(phydev);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_sds_isolate_and_softreset_paged(phydev);
+ if (ret < 0)
+ goto retry;
+ }
+ return 0;
+
+retry:
+ /*
+ * If the PHY up operation succeeds but the subsequent operation
+ * fails, revert to the default state.
+ */
+ r = yt8824_utp_power_down(phydev);
+ if (ret >= 0 && r < 0)
+ ret = r;
+ ret = yt8824_restore_working_status(phydev, ret);
+ return ret;
+}
+
+/**
+ * yt8824_resume() - resume the hardware
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_resume(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int ret;
+
+ mutex_lock(&priv->shared_lock);
+ ret = yt8824_power_on(phydev);
+ mutex_unlock(&priv->shared_lock);
+
+ return ret;
+}
+
+/**
+ * yt8824_power_down() - set utp power down.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * NOTE: need WA like softreset
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_power_down(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int ret;
+ int r;
+
+ if (priv->package_mode == PHY_INTERFACE_MODE_INTERNAL) {
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_power_down(phydev);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+ } else {
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_sds_isolate_paged(phydev);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_power_down(phydev);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_utp_set_template_test_mode(phydev,
+ MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+
+ ret = yt8824_sds_isolate_and_softreset_paged(phydev);
+ if (ret < 0)
+ goto retry;
+ }
+ return 0;
+
+retry:
+ /*
+ * If the PHY down operation succeeds but the subsequent operation
+ * fails, revert to the default state.
+ */
+ r = yt8824_utp_power_on(phydev);
+ if (ret >= 0 && r < 0)
+ ret = r;
+ ret = yt8824_restore_working_status(phydev, ret);
+ return ret;
+}
+
+/**
+ * yt8824_suspend() - suspend the hardware
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_suspend(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int ret;
+
+ mutex_lock(&priv->shared_lock);
+ ret = yt8824_power_down(phydev);
+ mutex_unlock(&priv->shared_lock);
+
+ return ret;
+}
+
+/**
+ * yt8824_config_aneg() - config negotiation
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_config_aneg(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ int phy_ctrl = 0;
+ int ret;
+
+ mutex_lock(&priv->shared_lock);
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ goto err;
+
+ /*
+ * Only advertise 2.5G when autoneg is enabled, or when 2.5G is
+ * explicitly forced. When a different speed is forced, clear
+ * ADV2_5G so a 2.5G-capable link partner cannot negotiate 2.5G.
+ * __genphy_config_aneg() only rewrites the
+ * clause 22 registers on the forced-speed path, so it will not
+ * clear this bit.
+ */
+ if ((phydev->autoneg == AUTONEG_ENABLE ||
+ phydev->speed == SPEED_2500) &&
+ linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
+ phydev->advertising))
+ phy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G;
+
+ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
+ MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl);
+ if (ret < 0)
+ goto err;
+
+ ret = __genphy_config_aneg(phydev, ret);
+
+err:
+ mutex_unlock(&priv->shared_lock);
+ return ret;
+}
+
+/**
+ * phy_mode_check() - check if mode names the PHY interface.
+ * @mode: PHY interface mode string
+ * @interface: PHY interface mode to compare against
+ *
+ * Return: true if @mode matches @interface, false otherwise.
+ */
+static bool phy_mode_check(const char *mode, int interface)
+{
+ return !strcasecmp(mode, phy_modes(interface));
+}
+
+/**
+ * yt8824_phy_package_probe_once() - init phy package for phy8824.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_phy_package_probe_once(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ struct device_node *np = phy_package_get_node(phydev);
+ const char *mode;
+
+ if (!priv || !np) {
+ phydev_err(phydev, "%s: missing shared priv or DT node\n",
+ __func__);
+ return -EINVAL;
+ }
+ /* Initialise shared lock for YT8824 */
+ mutex_init(&priv->shared_lock);
+ priv->sds_initialized = false;
+ priv->package_mode = PHY_INTERFACE_MODE_INTERNAL;
+ if (!of_property_read_string(np, "motorcomm,package-mode",
+ &mode)) {
+ if (phy_mode_check(mode, PHY_INTERFACE_MODE_INTERNAL)) {
+ priv->package_mode = PHY_INTERFACE_MODE_INTERNAL;
+ } else if (phy_mode_check(mode,
+ PHY_INTERFACE_MODE_10G_QXGMII)) {
+ priv->package_mode = PHY_INTERFACE_MODE_10G_QXGMII;
+ } else {
+ phydev_err(phydev, "unsupported package-mode %s\n",
+ mode);
+ return -EINVAL;
+ }
+ } else {
+ phydev_err(phydev, "missing package-mode in PHY package node.\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/**
+ * yt8824_probe() - phy8824 probe.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_probe(struct phy_device *phydev)
+{
+ struct device *dev = &phydev->mdio.dev;
+ struct yt8824_shared_priv *shared_priv;
+ int ret;
+
+ ret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));
+ if (ret)
+ return ret;
+
+ /* Ensure other PHY probes wait for shared mutex initialization. */
+ phy_package_lock(phydev);
+ if (phy_package_probe_once(phydev)) {
+ ret = yt8824_phy_package_probe_once(phydev);
+ if (ret) {
+ phy_package_unlock(phydev);
+ return ret;
+ }
+ }
+ phy_package_unlock(phydev);
+
+ return 0;
+}
+
static struct phy_driver motorcomm_phy_drvs[] = {
{
PHY_ID_MATCH_EXACT(PHY_ID_YT8511),
@@ -3337,13 +5242,29 @@ static struct phy_driver motorcomm_phy_drvs[] = {
.suspend = yt8821_suspend,
.resume = yt8821_resume,
},
+ {
+ PHY_ID_MATCH_EXACT(PHY_ID_YT8824),
+ .name = "YT8824 Quad Ports 2.5Gbps Ethernet",
+ .get_features = yt8824_get_features,
+ .read_page = yt8824_read_page,
+ .write_page = yt8824_write_page,
+ .probe = yt8824_probe,
+ .config_aneg = yt8824_config_aneg,
+ .aneg_done = yt8824_aneg_done,
+ .config_init = yt8824_config_init,
+ .read_status = yt8824_read_status,
+ .soft_reset = yt8824_soft_reset,
+ .suspend = yt8824_suspend,
+ .resume = yt8824_resume,
+ },
};
module_phy_driver(motorcomm_phy_drvs);
-MODULE_DESCRIPTION("Motorcomm 8511/8521/8531/8531S/861x/8821 PHY driver");
+MODULE_DESCRIPTION("Motorcomm 8511/8521/8531/8531S/861x/8821/8824 PHY driver");
MODULE_AUTHOR("Peter Geis");
MODULE_AUTHOR("Frank");
+MODULE_AUTHOR("Kyle");
MODULE_LICENSE("GPL");
static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {
@@ -3354,6 +5275,7 @@ static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) },
{ PHY_ID_MATCH_EXACT(PHY_ID_INT861X) },
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8821) },
+ { PHY_ID_MATCH_EXACT(PHY_ID_YT8824) },
{ /* sentinel */ }
};
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 870920311f9a0..c5f5753f7194b 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -1408,6 +1408,29 @@ int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable)
}
EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain);
+/**
+ * genphy_c45_template_testmode - configure template testmode registers
+ * @phydev: target phy_device struct
+ * @test_mode: testmode includes Normal to Test mode 7
+ *
+ * Description: Set template testmode include Normal to Test mode 7
+ *
+ * Return: 0 on success, or a negative error code on failure (e.g. register
+ * read/write error).
+ */
+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)
+{
+ u16 ctrl;
+
+ if (test_mode > MDIO_PMA_10GBT_TESTMODE_7)
+ return -EOPNOTSUPP;
+
+ ctrl = FIELD_PREP(MDIO_PMA_10GBT_TESTMODE_MASK, test_mode);
+ return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,
+ MDIO_PMA_10GBT_TESTMODE_MASK, ctrl);
+}
+EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);
+
/**
* genphy_c45_plca_get_cfg - get PLCA configuration from standard registers
* @phydev: target phy_device struct
diff --git a/include/linux/phy.h b/include/linux/phy.h
index a5a419bc400ec..81cb7f15bb72e 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2359,6 +2359,7 @@ int genphy_c45_loopback(struct phy_device *phydev, bool enable, int speed);
int genphy_c45_pma_resume(struct phy_device *phydev);
int genphy_c45_pma_suspend(struct phy_device *phydev);
int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable);
+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode);
int genphy_c45_plca_get_cfg(struct phy_device *phydev,
struct phy_plca_cfg *plca_cfg);
int genphy_c45_plca_set_cfg(struct phy_device *phydev,
diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h
index 06f4bc3c20c71..353ca13c64fca 100644
--- a/include/uapi/linux/mdio.h
+++ b/include/uapi/linux/mdio.h
@@ -63,6 +63,7 @@
/* Media-dependent registers. */
#define MDIO_PMA_10GBT_SWAPPOL 130 /* 10GBASE-T pair swap & polarity */
#define MDIO_PMA_10GBT_TXPWR 131 /* 10GBASE-T TX power control */
+#define MDIO_PMA_10GBT_TESTMODE 132 /* Test mode control */
#define MDIO_PMA_10GBT_SNR 133 /* 10GBASE-T SNR margin, lane A.
* Lanes B-D are numbered 134-136. */
#define MDIO_PMA_10GBR_FSRT_CSR 147 /* 10GBASE-R fast retrain status and control */
@@ -320,6 +321,17 @@
/* PMA 10GBASE-R Fast Retrain status and control register. */
#define MDIO_PMA_10GBR_FSRT_ENABLE 0x0001 /* Fast retrain enable */
+/* PMA 10GBASE-T Template Test Mode Register*/
+#define MDIO_PMA_10GBT_TESTMODE_MASK GENMASK(15, 13) /* Template test mode */
+#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0 /* Template Normal */
+#define MDIO_PMA_10GBT_TESTMODE_1 0x1 /* Template TestMode1 */
+#define MDIO_PMA_10GBT_TESTMODE_2 0x2 /* Template TestMode2 */
+#define MDIO_PMA_10GBT_TESTMODE_3 0x3 /* Template TestMode3 */
+#define MDIO_PMA_10GBT_TESTMODE_4 0x4 /* Template TestMode4 */
+#define MDIO_PMA_10GBT_TESTMODE_5 0x5 /* Template TestMode5 */
+#define MDIO_PMA_10GBT_TESTMODE_6 0x6 /* Template TestMode6 */
+#define MDIO_PMA_10GBT_TESTMODE_7 0x7 /* Template TestMode7 */
+
/* PCS 10GBASE-R/-T status register 1. */
#define MDIO_PCS_10GBRT_STAT1_BLKLK 0x0001 /* Block lock attained */
|
| 3/2 | 2026/10/18 02:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37278 output: 29 thoughts: 728 Thoughts: **Kernel Patch Evaluation: Motorcomm YT8824 PHY Driver** Okay, so the user wants me to evaluate this patch series for the amd64 kernel. Right, let's dive in. The diff touches quite a few files, specifically: device tree bindings, the MAINTAINERS file, Kconfig for the PHY driver, the actual Motorcomm driver code itself (`drivers/net/phy/motorcomm.c`), and a few supporting files like `phy-c45.c`, `linux/phy.h` and `uapi/linux/mdio.h`. Looks like they're adding support for the YT8824 Quad Port 2.5Gbps Ethernet PHY, with the PHY ID of `0x4f51e8b8`. Now, the crucial question is: Can we *actually* test this driver in a standard fuzzing environment, like GCE or QEMU? That's the core issue. I need to refer back to the triage philosophy and rules. Rules 1 and 2 are clear: *Reachable code is the primary gate*. Fuzzing is only effective if the code can execute in a virtualized environment. Unreachable code is a no-go. I have to determine if this new driver falls into that category. We have to make sure this code is reachable in our virtual environment! My first thought is around whether `drivers/net/phy/motorcomm.c`, the actual driver code for the YT8824, is reachable in a typical syzkaller setup. Ethernet PHYs aren't usually directly addressable in QEMU. How do these drivers actually get loaded? I remember PHY drivers register with `module_phy_driver(motorcomm_phy_drvs)`. They match via `mdio_device_id` or `phy_device->phy_id`. So, where do these PHY devices *come from*? Ah, the MDIO bus! The key question is: Is there an emulated or user-controllable MDIO bus available in standard QEMU or syzkaller? Are there dummy MDIO buses, perhaps, or can virtual netdevs like `netdevsim`, `dummy` or `virtio-net` create PHYs? That's what I have to figure out. I need to see if any of these virtual interfaces even support probing for and using PHY drivers like this Motorcomm YT8824. Time to check with grep. That'll be the determining factor. |
| 4/2 | 2026/10/18 02:49 | tool | grepper |
0mArgs:{
"Expression": "netdevsim.*phy|mdio-gpio|mdio_bus"
}Results: {
"Output": "\nFull output is too long, showing 200 out of 2771 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (141 files in total):\nDocumentation/ABI/testing/sysfs-bus-mdio:18\nDocumentation/ABI/testing/sysfs-class-net-phydev:7\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml:7\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml:4\nDocumentation/networking/device_drivers/ethernet/stmicro/stmmac.rst:2\nDocumentation/networking/dsa/dsa.rst:1\nDocumentation/networking/kapi.rst:2\narch/arm/boot/dts/broadcom/bcm2711.dtsi:2\narch/arm/boot/dts/broadcom/bcm47094-asus-rt-ac88u.dts:1\narch/arm/boot/dts/gemini/gemini-dlink-dir-685.dts:1\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts:2\narch/arm/boot/dts/gemini/gemini-nas4210b.dts:1\narch/arm/boot/dts/gemini/gemini-nas4220b.dts:1\narch/arm/boot/dts/gemini/gemini-ns2502.dts:2\narch/arm/boot/dts/gemini/gemini-rut1xx.dts:1\narch/arm/boot/dts/gemini/gemini-sl93512r.dts:1\narch/arm/boot/dts/gemini/gemini-sq201.dts:1\narch/arm/boot/dts/gemini/gemini-ssi1328.dts:2\narch/arm/boot/dts/gemini/gemini-verbatim-s08v1901-d1.dts:1\narch/arm/boot/dts/gemini/gemini-wbd111.dts:1\narch/arm/boot/dts/gemini/gemini-wbd222.dts:1\narch/arm/boot/dts/nxp/imx/imx51-zii-rdu1.dts:2\narch/arm/boot/dts/nxp/imx/imx51-zii-scu2-mezz.dts:2\narch/arm/boot/dts/nxp/imx/imx6q-bx50v3.dtsi:2\narch/arm/boot/dts/nxp/imx/imx6qdl-skov-cpu.dtsi:1\narch/arm/boot/dts/nxp/imx/imx6qdl-zii-rdu2.dtsi:2\narch/arm/boot/dts/nxp/imx/imx6qp-prtwd3.dts:1\narch/arm/boot/dts/qcom/qcom-ipq8064-rb3011.dts:4\narch/arm/boot/dts/st/stm32mp133c-prihmb.dts:2\narch/arm/boot/dts/st/stm32mp151a-prtt1c.dts:1\narch/arm/boot/dts/st/stm32mp151a-prtt1l.dtsi:2\narch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi:2\narch/arm64/boot/dts/mediatek/mt7981b-openwrt-one.dts:1\narch/arm64/boot/dts/mediatek/mt7981b.dtsi:1\narch/arm64/boot/dts/mediatek/mt7988a.dtsi:1\ndrivers/net/dsa/microchip/ksz9477.c:1\ndrivers/net/dsa/microchip/ksz_common.c:3\ndrivers/net/dsa/microchip/ksz_common.h:2\ndrivers/net/dsa/microchip/lan937x_main.c:4\ndrivers/net/dsa/motorcomm/Makefile:1\ndrivers/net/dsa/motorcomm/chip.c:1\ndrivers/net/dsa/motorcomm/mdio_bus.c:1\ndrivers/net/dsa/motorcomm/pcs-921x.c:1\ndrivers/net/dsa/mv88e6xxx/chip.c:28\ndrivers/net/dsa/mv88e6xxx/chip.h:2\ndrivers/net/dsa/mv88e6xxx/global2.c:8\ndrivers/net/dsa/mv88e6xxx/pcs-6352.c:1\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c:2\ndrivers/net/dsa/mv88e6xxx/phy.c:4\ndrivers/net/dsa/netc/netc_main.c:4\n... and 91 more files\n\nDocumentation/ABI/testing/sysfs-bus-mdio:1:What: /sys/bus/mdio_bus/devices/.../statistics/\nDocumentation/ABI/testing/sysfs-bus-mdio:2:What: /sys/class/mdio_bus/.../statistics/\nDocumentation/ABI/testing/sysfs-bus-mdio-3-Date: January 2020\n--\nDocumentation/ABI/testing/sysfs-bus-mdio=6=Description:\n--\nDocumentation/ABI/testing/sysfs-bus-mdio-9-\nDocumentation/ABI/testing/sysfs-bus-mdio:10:What: /sys/bus/mdio_bus/devices/.../statistics/transfers\nDocumentation/ABI/testing/sysfs-bus-mdio:11:What: /sys/class/mdio_bus/.../transfers\nDocumentation/ABI/testing/sysfs-bus-mdio-12-Date: January 2020\n--\nDocumentation/ABI/testing/sysfs-bus-mdio=15=Description:\n--\nDocumentation/ABI/testing/sysfs-bus-mdio-17-\nDocumentation/ABI/testing/sysfs-bus-mdio:18:What: /sys/bus/mdio_bus/devices/.../statistics/errors\nDocumentation/ABI/testing/sysfs-bus-mdio:19:What: /sys/class/mdio_bus/.../statistics/errors\nDocumentation/ABI/testing/sysfs-bus-mdio-20-Date: January 2020\n--\nDocumentation/ABI/testing/sysfs-bus-mdio=23=Description:\n--\nDocumentation/ABI/testing/sysfs-bus-mdio-25-\nDocumentation/ABI/testing/sysfs-bus-mdio:26:What: /sys/bus/mdio_bus/devices/.../statistics/writes\nDocumentation/ABI/testing/sysfs-bus-mdio:27:What: /sys/class/mdio_bus/.../statistics/writes\nDocumentation/ABI/testing/sysfs-bus-mdio-28-Date: January 2020\n--\nDocumentation/ABI/testing/sysfs-bus-mdio=31=Description:\n--\nDocumentation/ABI/testing/sysfs-bus-mdio-33-\nDocumentation/ABI/testing/sysfs-bus-mdio:34:What: /sys/bus/mdio_bus/devices/.../statistics/reads\nDocumentation/ABI/testing/sysfs-bus-mdio:35:What: /sys/class/mdio_bus/.../statistics/reads\nDocumentation/ABI/testing/sysfs-bus-mdio-36-Date: January 2020\n--\nDocumentation/ABI/testing/sysfs-bus-mdio=39=Description:\n--\nDocumentation/ABI/testing/sysfs-bus-mdio-41-\nDocumentation/ABI/testing/sysfs-bus-mdio:42:What: /sys/bus/mdio_bus/devices/.../statistics/transfers_\u003caddr\u003e\nDocumentation/ABI/testing/sysfs-bus-mdio:43:What: /sys/class/mdio_bus/.../statistics/transfers_\u003caddr\u003e\nDocumentation/ABI/testing/sysfs-bus-mdio-44-Date: January 2020\n--\nDocumentation/ABI/testing/sysfs-bus-mdio=47=Description:\n--\nDocumentation/ABI/testing/sysfs-bus-mdio-49-\nDocumentation/ABI/testing/sysfs-bus-mdio:50:What: /sys/bus/mdio_bus/devices/.../statistics/errors_\u003caddr\u003e\nDocumentation/ABI/testing/sysfs-bus-mdio:51:What: /sys/class/mdio_bus/.../statistics/errors_\u003caddr\u003e\nDocumentation/ABI/testing/sysfs-bus-mdio-52-Date: January 2020\n--\nDocumentation/ABI/testing/sysfs-bus-mdio=55=Description:\n--\nDocumentation/ABI/testing/sysfs-bus-mdio-57-\nDocumentation/ABI/testing/sysfs-bus-mdio:58:What: /sys/bus/mdio_bus/devices/.../statistics/writes_\u003caddr\u003e\nDocumentation/ABI/testing/sysfs-bus-mdio:59:What: /sys/class/mdio_bus/.../statistics/writes_\u003caddr\u003e\nDocumentation/ABI/testing/sysfs-bus-mdio-60-Date: January 2020\n--\nDocumentation/ABI/testing/sysfs-bus-mdio=63=Description:\n--\nDocumentation/ABI/testing/sysfs-bus-mdio-65-\nDocumentation/ABI/testing/sysfs-bus-mdio:66:What: /sys/bus/mdio_bus/devices/.../statistics/reads_\u003caddr\u003e\nDocumentation/ABI/testing/sysfs-bus-mdio:67:What: /sys/class/mdio_bus/.../statistics/reads_\u003caddr\u003e\nDocumentation/ABI/testing/sysfs-bus-mdio-68-Date: January 2020\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev:1:What:\t\t/sys/class/mdio_bus/\u003cbus\u003e/\u003cdevice\u003e/attached_dev\nDocumentation/ABI/testing/sysfs-class-net-phydev-2-Date:\t\tMay 2017\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev=5=Description:\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev-8-\nDocumentation/ABI/testing/sysfs-class-net-phydev:9:What:\t\t/sys/class/mdio_bus/\u003cbus\u003e/\u003cdevice\u003e/phy_has_fixups\nDocumentation/ABI/testing/sysfs-class-net-phydev-10-Date:\t\tFebruary 2014\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev=13=Description:\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev-18-\nDocumentation/ABI/testing/sysfs-class-net-phydev:19:What:\t\t/sys/class/mdio_bus/\u003cbus\u003e/\u003cdevice\u003e/phy_id\nDocumentation/ABI/testing/sysfs-class-net-phydev-20-Date:\t\tNovember 2012\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev=23=Description:\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev-28-\nDocumentation/ABI/testing/sysfs-class-net-phydev:29:What:\t\t/sys/class/mdio_bus/\u003cbus\u003e/\u003cdevice\u003e/c45_phy_ids/mmd\u003cn\u003e_device_id\nDocumentation/ABI/testing/sysfs-class-net-phydev-30-Date:\t\tJune 2025\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev=33=Description:\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev-38-\nDocumentation/ABI/testing/sysfs-class-net-phydev:39:What:\t\t/sys/class/mdio_bus/\u003cbus\u003e/\u003cdevice\u003e/phy_interface\nDocumentation/ABI/testing/sysfs-class-net-phydev-40-Date:\t\tFebruary 2014\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev=43=Description:\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev-55-\nDocumentation/ABI/testing/sysfs-class-net-phydev:56:What:\t\t/sys/class/mdio_bus/\u003cbus\u003e/\u003cdevice\u003e/phy_standalone\nDocumentation/ABI/testing/sysfs-class-net-phydev-57-Date:\t\tMay 2019\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev=60=Description:\n--\nDocumentation/ABI/testing/sysfs-class-net-phydev-64-\nDocumentation/ABI/testing/sysfs-class-net-phydev:65:What:\t\t/sys/class/mdio_bus/\u003cbus\u003e/\u003cdevice\u003e/phy_dev_flags\nDocumentation/ABI/testing/sysfs-class-net-phydev-66-Date:\t\tMarch 2021\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml=51=properties:\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-67-\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml:68: mdio-gpios:\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-69- description: GPIO line for the MDIO data line.\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml=147=then:\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-151- - mdc-gpios\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml:152: - mdio-gpios\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-153- - mdio\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-156- mdc-gpios: false\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml:157: mdio-gpios: false\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-158- mdio: false\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml=160=else:\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-162- - mdc-gpios\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml:163: - mdio-gpios\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-164- - mdio\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml=166=required:\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-169- # - mdc-gpios\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml:170: # - mdio-gpios\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-171- # - reset-gpios\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml=176=examples:\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-185- mdc-gpios = \u003c\u0026gpio0 21 GPIO_ACTIVE_HIGH\u003e;\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml:186: mdio-gpios = \u003c\u0026gpio0 22 GPIO_ACTIVE_HIGH\u003e;\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-187- reset-gpios = \u003c\u0026gpio0 14 GPIO_ACTIVE_LOW\u003e;\n--\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-279- mdc-gpios = \u003c\u0026gpio1 16 GPIO_ACTIVE_HIGH\u003e;\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml:280: mdio-gpios = \u003c\u0026gpio1 17 GPIO_ACTIVE_HIGH\u003e;\nDocumentation/devicetree/bindings/net/dsa/realtek.yaml-281- reset-gpios = \u003c\u0026gpio5 0 GPIO_ACTIVE_LOW\u003e;\n--\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml-3----\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml:4:$id: http://devicetree.org/schemas/net/mdio-gpio.yaml#\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml-5-$schema: http://devicetree.org/meta-schemas/core.yaml#\n--\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml=17=properties:\n--\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml-19- enum:\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml:20: - virtual,mdio-gpio\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml-21- - microchip,mdio-smi0\n--\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml=41=examples:\n--\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml-43- aliases {\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml:44: mdio-gpio0 = \u0026mdio0;\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml-45- };\n--\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml-47- mdio0: mdio {\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml:48: compatible = \"virtual,mdio-gpio\";\nDocumentation/devicetree/bindings/net/mdio-gpio.yaml-49- #address-cells = \u003c1\u003e;\n--\nDocumentation/networking/device_drivers/ethernet/stmicro/stmmac.rst=351=finds::\n--\nDocumentation/networking/device_drivers/ethernet/stmicro/stmmac.rst-360-\nDocumentation/networking/device_drivers/ethernet/stmicro/stmmac.rst:361: struct stmmac_mdio_bus_data *mdio_bus_data;\nDocumentation/networking/device_drivers/ethernet/stmicro/stmmac.rst-362-\n--\nDocumentation/networking/device_drivers/ethernet/stmicro/stmmac.rst=501=For MDIO bus data, we have:\n--\nDocumentation/networking/device_drivers/ethernet/stmicro/stmmac.rst-504-\nDocumentation/networking/device_drivers/ethernet/stmicro/stmmac.rst:505: struct stmmac_mdio_bus_data {\nDocumentation/networking/device_drivers/ethernet/stmicro/stmmac.rst-506-\n--\nDocumentation/networking/dsa/dsa.rst=432=DSA currently leverages the following subsystems:\nDocumentation/networking/dsa/dsa.rst-433-\nDocumentation/networking/dsa/dsa.rst:434:- MDIO/PHY library: ``drivers/net/phy/phy.c``, ``mdio_bus.c``\nDocumentation/networking/dsa/dsa.rst-435-- Switchdev:``net/switchdev/*``\n--\nDocumentation/networking/kapi.rst=110=PHY Support\n--\nDocumentation/networking/kapi.rst-133-\nDocumentation/networking/kapi.rst:134:.. kernel-doc:: drivers/net/phy/mdio_bus.c\nDocumentation/networking/kapi.rst-135- :export:\nDocumentation/networking/kapi.rst-136-\nDocumentation/networking/kapi.rst:137:.. kernel-doc:: drivers/net/phy/mdio_bus.c\nDocumentation/networking/kapi.rst-138- :internal:\n--\narch/arm/boot/dts/broadcom/bcm2711.dtsi=938=\t\tpin-irq {\n--\narch/arm/boot/dts/broadcom/bcm2711.dtsi-942-\t};\narch/arm/boot/dts/broadcom/bcm2711.dtsi:943:\trgmii_mdio_gpio28: rgmii-mdio-gpio28 {\narch/arm/boot/dts/broadcom/bcm2711.dtsi-944-\t\tpins-mdio {\n--\narch/arm/boot/dts/broadcom/bcm2711.dtsi-949-\t};\narch/arm/boot/dts/broadcom/bcm2711.dtsi:950:\trgmii_mdio_gpio37: rgmii-mdio-gpio37 {\narch/arm/boot/dts/broadcom/bcm2711.dtsi-951-\t\tpins-mdio {\n--\narch/arm/boot/dts/broadcom/bcm47094-asus-rt-ac88u.dts=20=\tswitch {\n--\narch/arm/boot/dts/broadcom/bcm47094-asus-rt-ac88u.dts-22-\t\tmdc-gpios = \u003c\u0026chipcommon 6 GPIO_ACTIVE_HIGH\u003e;\narch/arm/boot/dts/broadcom/bcm47094-asus-rt-ac88u.dts:23:\t\tmdio-gpios = \u003c\u0026chipcommon 7 GPIO_ACTIVE_HIGH\u003e;\narch/arm/boot/dts/broadcom/bcm47094-asus-rt-ac88u.dts-24-\t\treset-gpios = \u003c\u0026chipcommon 10 GPIO_ACTIVE_LOW\u003e;\n--\narch/arm/boot/dts/gemini/gemini-dlink-dir-685.dts=190=\tethernet-switch {\n\n"
} |
| 5/2 | 2026/10/18 02:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44221 output: 40 thoughts: 313 Thoughts: **My Current Thinking: Instantiating PHYs and Syzkaller's Potential** Okay, let's break this down. My mind is focused on how these PHYs get spun up in Linux. First, the device tree (or ACPI or platform code) identifies an Ethernet controller, or specifically, an MDIO controller. Then, it's all about reading those vital PHY registers, registers 2 and 3, which hold the PHY ID. This happens during the scan process using functions like `get_phy_id` or `get_phy_device`. The `phy_device_create` function gets called using that PHY ID, and the newly created PHY device gets registered on the `mdio_bus_type`. A driver matching the PHY ID, like the `PHY_ID_MATCH_EXACT(PHY_ID_YT8824)`, gets bound to the PHY via the `phy_bus_type.match` mechanism. Finally, when an Ethernet netdev links up with the phydev (`phy_connect`, `phy_attach`), those PHY callbacks kick in – `config_init`, and so on. Now, the real question: Can Syzkaller instantiate a Motorcomm YT8824 PHY? That's where I need to dig deeper. I need to figure out what MDIO devices or PHY devices can be dynamically created without relying on actual hardware. Time to investigate. I'll need to explore those drivers – `drivers/net/phy/`, `drivers/net/`, and related areas like netlink, sysfs, configfs, ioctl, etc. The critical question is, can a user, from userspace, create an `mdio_bus` device or a `phy_device`? I'll be searching for functions like `mdiobus_register`, `phy_device_register`, and `phy_device_create` to find the answer. |
| 6/2 | 2026/10/18 02:50 | tool | grepper |
0mArgs:{
"Expression": "mdiobus_register|phy_device_create|phy_device_register",
"PathPrefixes": [
"drivers/"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 1148 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (133 files in total):\ndrivers/net/dsa/bcm_sf2.c:1\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c:1\ndrivers/net/dsa/microchip/ksz9477.c:1\ndrivers/net/dsa/microchip/ksz_common.c:1\ndrivers/net/dsa/microchip/lan937x_main.c:1\ndrivers/net/dsa/motorcomm/mdio_bus.c:2\ndrivers/net/dsa/mt7530.c:1\ndrivers/net/dsa/mt7628.c:1\ndrivers/net/dsa/mv88e6xxx/chip.c:1\ndrivers/net/dsa/mxl862xx/mxl862xx.c:1\ndrivers/net/dsa/netc/netc_main.c:1\ndrivers/net/dsa/ocelot/felix_vsc9959.c:1\ndrivers/net/dsa/ocelot/seville_vsc9953.c:1\ndrivers/net/dsa/qca/ar9331.c:1\ndrivers/net/dsa/qca/qca8k-8xxx.c:1\ndrivers/net/dsa/realtek/rtl83xx.c:1\ndrivers/net/dsa/rzn1_a5psw.c:1\ndrivers/net/dsa/sja1105/sja1105.h:1\ndrivers/net/dsa/sja1105/sja1105_main.c:1\ndrivers/net/dsa/sja1105/sja1105_mdio.c:4\ndrivers/net/ethernet/8390/ax88796.c:1\ndrivers/net/ethernet/actions/owl-emac.c:1\ndrivers/net/ethernet/adi/adin1110.c:1\ndrivers/net/ethernet/adi/adin1140.c:1\ndrivers/net/ethernet/aeroflex/greth.c:1\ndrivers/net/ethernet/agere/et131x.c:1\ndrivers/net/ethernet/altera/altera_tse_main.c:1\ndrivers/net/ethernet/amd/au1000_eth.c:1\ndrivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:4\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:1\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:4\ndrivers/net/ethernet/arc/emac_mdio.c:1\ndrivers/net/ethernet/asix/ax88796c_main.c:1\ndrivers/net/ethernet/atheros/ag71xx.c:1\ndrivers/net/ethernet/broadcom/b44.c:1\ndrivers/net/ethernet/broadcom/bcm63xx_enet.c:1\ndrivers/net/ethernet/broadcom/bgmac-bcma-mdio.c:1\ndrivers/net/ethernet/broadcom/genet/bcmmii.c:1\ndrivers/net/ethernet/broadcom/sb1250-mac.c:1\ndrivers/net/ethernet/broadcom/tg3.c:1\ndrivers/net/ethernet/cadence/macb_main.c:5\ndrivers/net/ethernet/davicom/dm9051.c:1\ndrivers/net/ethernet/engleder/tsnep_main.c:1\ndrivers/net/ethernet/ethoc.c:1\ndrivers/net/ethernet/faraday/ftgmac100.c:1\ndrivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c:1\ndrivers/net/ethernet/freescale/enetc/enetc_pf_common.c:2\ndrivers/net/ethernet/freescale/fec_main.c:1\ndrivers/net/ethernet/freescale/fec_mpc52xx_phy.c:1\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c:1\n... and 83 more files\n\ndrivers/net/dsa/bcm_sf2.c=607=static int bcm_sf2_mdio_register(struct dsa_switch *ds)\n--\ndrivers/net/dsa/bcm_sf2.c-683-\ndrivers/net/dsa/bcm_sf2.c:684:\terr = mdiobus_register(priv-\u003euser_mii_bus);\ndrivers/net/dsa/bcm_sf2.c-685-\tif (err)\n--\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c=187=static int gswip_mdio(struct gswip_priv *priv)\n--\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c-213-\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c:214:\terr = devm_of_mdiobus_register(dev, bus, mdio_np);\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c-215-\n--\ndrivers/net/dsa/microchip/ksz9477.c=321=static int ksz9477_pcs_create(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz9477.c-341-\ndrivers/net/dsa/microchip/ksz9477.c:342:\tret = devm_mdiobus_register(dev-\u003edev, bus);\ndrivers/net/dsa/microchip/ksz9477.c-343-\tif (ret)\n--\ndrivers/net/dsa/microchip/ksz_common.c=2407=int ksz_mdio_register(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz_common.c-2478-\ndrivers/net/dsa/microchip/ksz_common.c:2479:\tret = devm_of_mdiobus_register(ds-\u003edev, bus, mdio_np);\ndrivers/net/dsa/microchip/ksz_common.c-2480-\tif (ret) {\n--\ndrivers/net/dsa/microchip/lan937x_main.c=685=static int lan937x_mdio_register(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/lan937x_main.c-755-\ndrivers/net/dsa/microchip/lan937x_main.c:756:\tret = devm_of_mdiobus_register(ds-\u003edev, bus, mdio_np);\ndrivers/net/dsa/microchip/lan937x_main.c-757-\tif (ret)\n--\ndrivers/net/dsa/motorcomm/mdio_bus.c=144=int yt921x_mbus_int_init(struct yt921x_priv *priv, struct device_node *mnp)\n--\ndrivers/net/dsa/motorcomm/mdio_bus.c-161-\ndrivers/net/dsa/motorcomm/mdio_bus.c:162:\tres = devm_of_mdiobus_register(dev, mbus, mnp);\ndrivers/net/dsa/motorcomm/mdio_bus.c-163-\tif (res)\n--\ndrivers/net/dsa/motorcomm/mdio_bus.c=274=int yt921x_mbus_ext_init(struct yt921x_priv *priv, struct device_node *mnp)\n--\ndrivers/net/dsa/motorcomm/mdio_bus.c-291-\ndrivers/net/dsa/motorcomm/mdio_bus.c:292:\tres = devm_of_mdiobus_register(dev, mbus, mnp);\ndrivers/net/dsa/motorcomm/mdio_bus.c-293-\tif (res)\n--\ndrivers/net/dsa/mt7530.c=2331=mt7530_setup_mdio(struct mt7530_priv *priv)\n--\ndrivers/net/dsa/mt7530.c-2366-\ndrivers/net/dsa/mt7530.c:2367:\tret = devm_of_mdiobus_register(dev, bus, mnp);\ndrivers/net/dsa/mt7530.c-2368-\tif (ret) {\n--\ndrivers/net/dsa/mt7628.c=242=static int mt7628_setup_internal_mdio(struct dsa_switch *ds)\n--\ndrivers/net/dsa/mt7628.c-261-\ndrivers/net/dsa/mt7628.c:262:\treturn devm_mdiobus_register(dev, bus);\ndrivers/net/dsa/mt7628.c-263-}\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3843=static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3896-\ndrivers/net/dsa/mv88e6xxx/chip.c:3897:\terr = of_mdiobus_register(bus, np);\ndrivers/net/dsa/mv88e6xxx/chip.c-3898-\tif (err) {\n--\ndrivers/net/dsa/mxl862xx/mxl862xx.c=267=static int mxl862xx_setup_mdio(struct dsa_switch *ds)\n--\ndrivers/net/dsa/mxl862xx/mxl862xx.c-292-\ndrivers/net/dsa/mxl862xx/mxl862xx.c:293:\tret = devm_of_mdiobus_register(dev, bus, mdio_np);\ndrivers/net/dsa/mxl862xx/mxl862xx.c-294-\tof_node_put(mdio_np);\n--\ndrivers/net/dsa/netc/netc_main.c=149=static int netc_port_create_emdio_bus(struct netc_port *np,\n--\ndrivers/net/dsa/netc/netc_main.c-179-\ndrivers/net/dsa/netc/netc_main.c:180:\terr = devm_of_mdiobus_register(dev, bus, node);\ndrivers/net/dsa/netc/netc_main.c-181-\tif (err)\n--\ndrivers/net/dsa/ocelot/felix_vsc9959.c=957=static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)\n--\ndrivers/net/dsa/ocelot/felix_vsc9959.c-1013-\t/* Needed in order to initialize the bus mutex lock */\ndrivers/net/dsa/ocelot/felix_vsc9959.c:1014:\trc = mdiobus_register(bus);\ndrivers/net/dsa/ocelot/felix_vsc9959.c-1015-\tif (rc \u003c 0) {\n--\ndrivers/net/dsa/ocelot/seville_vsc9953.c=878=static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)\n--\ndrivers/net/dsa/ocelot/seville_vsc9953.c-903-\t/* Needed in order to initialize the bus mutex lock */\ndrivers/net/dsa/ocelot/seville_vsc9953.c:904:\trc = devm_of_mdiobus_register(dev, bus, NULL);\ndrivers/net/dsa/ocelot/seville_vsc9953.c-905-\tif (rc \u003c 0) {\n--\ndrivers/net/dsa/qca/ar9331.c=357=static int ar9331_sw_mbus_init(struct ar9331_sw_priv *priv)\n--\ndrivers/net/dsa/qca/ar9331.c-381-\ndrivers/net/dsa/qca/ar9331.c:382:\tret = devm_of_mdiobus_register(dev, mbus, mnp);\ndrivers/net/dsa/qca/ar9331.c-383-\tof_node_put(mnp);\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c=959=qca8k_mdio_register(struct qca8k_priv *priv)\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c-998-\ndrivers/net/dsa/qca/qca8k-8xxx.c:999:\tret = devm_of_mdiobus_register(dev, bus, mdio);\ndrivers/net/dsa/qca/qca8k-8xxx.c-1000-\n--\ndrivers/net/dsa/realtek/rtl83xx.c=91=int rtl83xx_setup_user_mdio(struct dsa_switch *ds)\n--\ndrivers/net/dsa/realtek/rtl83xx.c-120-\ndrivers/net/dsa/realtek/rtl83xx.c:121:\tret = devm_of_mdiobus_register(priv-\u003edev, bus, mdio_np);\ndrivers/net/dsa/realtek/rtl83xx.c-122-\tif (ret) {\n--\ndrivers/net/dsa/rzn1_a5psw.c=1117=static int a5psw_probe_mdio(struct a5psw *a5psw, struct device_node *node)\n--\ndrivers/net/dsa/rzn1_a5psw.c-1143-\ndrivers/net/dsa/rzn1_a5psw.c:1144:\treturn devm_of_mdiobus_register(dev, bus, node);\ndrivers/net/dsa/rzn1_a5psw.c-1145-}\n--\ndrivers/net/dsa/sja1105/sja1105.h=307=void sja1105_frame_memory_partitioning(struct sja1105_private *priv);\n--\ndrivers/net/dsa/sja1105/sja1105.h-309-/* From sja1105_mdio.c */\ndrivers/net/dsa/sja1105/sja1105.h:310:int sja1105_mdiobus_register(struct dsa_switch *ds);\ndrivers/net/dsa/sja1105/sja1105.h-311-void sja1105_mdiobus_unregister(struct dsa_switch *ds);\n--\ndrivers/net/dsa/sja1105/sja1105_main.c=3026=static int sja1105_setup(struct dsa_switch *ds)\n--\ndrivers/net/dsa/sja1105/sja1105_main.c-3067-\ndrivers/net/dsa/sja1105/sja1105_main.c:3068:\trc = sja1105_mdiobus_register(ds);\ndrivers/net/dsa/sja1105/sja1105_main.c-3069-\tif (rc \u003c 0) {\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c=258=static int sja1105_mdiobus_base_tx_register(struct sja1105_private *priv,\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c-287-\ndrivers/net/dsa/sja1105/sja1105_mdio.c:288:\trc = of_mdiobus_register(bus, np);\ndrivers/net/dsa/sja1105/sja1105_mdio.c-289-\tif (rc) {\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c=312=static int sja1105_mdiobus_base_t1_register(struct sja1105_private *priv,\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c-343-\ndrivers/net/dsa/sja1105/sja1105_mdio.c:344:\trc = of_mdiobus_register(bus, np);\ndrivers/net/dsa/sja1105/sja1105_mdio.c-345-\tif (rc) {\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-395-\ndrivers/net/dsa/sja1105/sja1105_mdio.c:396:\trc = mdiobus_register(bus);\ndrivers/net/dsa/sja1105/sja1105_mdio.c-397-\tif (rc) {\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c=439=static void sja1105_mdiobus_pcs_unregister(struct sja1105_private *priv)\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c-458-\ndrivers/net/dsa/sja1105/sja1105_mdio.c:459:int sja1105_mdiobus_register(struct dsa_switch *ds)\ndrivers/net/dsa/sja1105/sja1105_mdio.c-460-{\n--\ndrivers/net/ethernet/8390/ax88796.c=459=static int ax_mii_init(struct net_device *dev)\n--\ndrivers/net/ethernet/8390/ax88796.c-478-\ndrivers/net/ethernet/8390/ax88796.c:479:\terr = mdiobus_register(ax-\u003emii_bus);\ndrivers/net/ethernet/8390/ax88796.c-480-\tif (err)\n--\ndrivers/net/ethernet/actions/owl-emac.c=1321=static int owl_emac_mdio_init(struct net_device *netdev)\n--\ndrivers/net/ethernet/actions/owl-emac.c-1345-\ndrivers/net/ethernet/actions/owl-emac.c:1346:\tret = devm_of_mdiobus_register(dev, priv-\u003emii, mdio_node);\ndrivers/net/ethernet/actions/owl-emac.c-1347-\n--\ndrivers/net/ethernet/adi/adin1110.c=509=static int adin1110_register_mdiobus(struct adin1110_priv *priv,\n--\ndrivers/net/ethernet/adi/adin1110.c-529-\ndrivers/net/ethernet/adi/adin1110.c:530:\tret = devm_mdiobus_register(dev, mii_bus);\ndrivers/net/ethernet/adi/adin1110.c-531-\tif (ret)\n--\ndrivers/net/ethernet/adi/adin1140.c=617=static int adin1140_mdio_register(struct adin1140_priv *priv,\n--\ndrivers/net/ethernet/adi/adin1140.c-636-\ndrivers/net/ethernet/adi/adin1140.c:637:\treturn devm_mdiobus_register(\u0026spidev-\u003edev, priv-\u003emdiobus);\ndrivers/net/ethernet/adi/adin1140.c-638-}\n--\ndrivers/net/ethernet/aeroflex/greth.c=1290=static int greth_mdio_init(struct greth_private *greth)\n--\ndrivers/net/ethernet/aeroflex/greth.c-1306-\ndrivers/net/ethernet/aeroflex/greth.c:1307:\tret = mdiobus_register(greth-\u003emdio);\ndrivers/net/ethernet/aeroflex/greth.c-1308-\tif (ret) {\n--\ndrivers/net/ethernet/agere/et131x.c=3931=static int et131x_pci_setup(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/agere/et131x.c-4026-\ndrivers/net/ethernet/agere/et131x.c:4027:\trc = mdiobus_register(adapter-\u003emii_bus);\ndrivers/net/ethernet/agere/et131x.c-4028-\tif (rc \u003c 0) {\n--\ndrivers/net/ethernet/altera/altera_tse_main.c=121=static int altera_tse_mdio_create(struct net_device *dev, unsigned int id)\n--\ndrivers/net/ethernet/altera/altera_tse_main.c-157-\ndrivers/net/ethernet/altera/altera_tse_main.c:158:\tret = of_mdiobus_register(mdio, mdio_node);\ndrivers/net/ethernet/altera/altera_tse_main.c-159-\tif (ret != 0) {\n--\ndrivers/net/ethernet/amd/au1000_eth.c=1061=static int au1000_probe(struct platform_device *pdev)\n--\ndrivers/net/ethernet/amd/au1000_eth.c-1221-\ndrivers/net/ethernet/amd/au1000_eth.c:1222:\terr = mdiobus_register(aup-\u003emii_bus);\ndrivers/net/ethernet/amd/au1000_eth.c-1223-\tif (err) {\n--\ndrivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c=931=static int xgbe_phy_find_phy_device(struct xgbe_prv_data *pdata)\n--\ndrivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c-975-\ndrivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:976:\tret = phy_device_register(phydev);\ndrivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c-977-\tif (ret) {\ndrivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:978:\t\tnetdev_err(pdata-\u003enetdev, \"phy_device_register failed\\n\");\ndrivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c-979-\t\tphy_device_free(phydev);\n--\n\n"
} |
| 7/2 | 2026/10/18 02:50 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 51268 output: 33 thoughts: 61 Thoughts: Okay, let's see, I need to jog my memory and figure out the best way to approach this. **Investigating Network Device Simulation and MDIO Bus Creation** Right, let's start with the basics. I need to figure out if I can find an existing simulation, or perhaps a mock driver, that will allow me to create an MDIO bus without involving actual hardware. I'm thinking, off the top of my head, about looking at some likely candidates such as: `mdio-gpio`, `mdio-bitbang`, `mdio_bus`, or even `netdevsim`. I believe one of these _should_ be creating an MDIO bus. I should probably start looking at `drivers/net/netdevsim/`, just to be certain. |
| 8/2 | 2026/10/18 02:50 | tool | grepper |
0mArgs:{
"Expression": "mdio|phy",
"PathPrefixes": [
"drivers/net/netdevsim/"
]
}Results: {
"Output": "drivers/net/netdevsim/dev.c=1380=static int __nsim_dev_port_add(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type,\n--\ndrivers/net/netdevsim/dev.c-1399-\t\tattrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;\ndrivers/net/netdevsim/dev.c:1400:\t\tattrs.phys.port_number = port_index + 1;\ndrivers/net/netdevsim/dev.c-1401-\t} else {\n--\ndrivers/net/netdevsim/netdevsim.h=323=struct nsim_dev {\n--\ndrivers/net/netdevsim/netdevsim.h-342-\tstruct mutex progs_list_lock;\ndrivers/net/netdevsim/netdevsim.h:343:\tstruct netdev_phys_item_id switch_id;\ndrivers/net/netdevsim/netdevsim.h-344-\tstruct list_head port_list;\n"
} |
| 9/2 | 2026/10/18 02:50 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 51804 output: 25 thoughts: 267 Thoughts: **Investigating the Missing MDIO Support**
Okay, so I'm looking at this `netdevsim` issue, and the absence of MDIO is a real head-scratcher. Wait, hold on a minute! I need to rethink this, I have a sudden recollection. Let me go back and investigate... could there be something in `phy-c45.c`? Ah, yes! There's a new function that was added within the `drivers/net/phy/phy-c45.c` file:
```c
int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)
{
u16 ctrl;
if (test_mode > MDIO_PMA_10GBT_TESTMODE_7)
return -EOPNOTSUPP;
ctrl = FIELD_PREP(MDIO_PMA_10GBT_TESTMODE_MASK, test_mode);
return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,
MDIO_PMA_10GBT_TESTMODE_MASK, ctrl);
}
EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);
```
Right, that's interesting. Now, where is `genphy_c45_template_testmode` actually being *used*? I need to trace this back. Time to fire up the grep and search for calls to `genphy_c45_template_testmode`.
|
| 10/2 | 2026/10/18 02:50 | tool | grepper |
0mArgs:{
"Expression": "genphy_c45_template_testmode"
}Results: {
"Output": "drivers/net/phy/motorcomm.c=1009=static int yt8824_utp_set_template_test_mode(struct phy_device *phydev,\n--\ndrivers/net/phy/motorcomm.c-1017-\ndrivers/net/phy/motorcomm.c:1018:\treturn genphy_c45_template_testmode(phydev, test_mode);\ndrivers/net/phy/motorcomm.c-1019-}\n--\ndrivers/net/phy/motorcomm.c=1188=static int yt8824_config_utp_init_paged(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-1688-\t/* reset */\ndrivers/net/phy/motorcomm.c:1689:\tret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-1690-\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-1701-\ndrivers/net/phy/motorcomm.c:1702:\tret = genphy_c45_template_testmode(phydev,\ndrivers/net/phy/motorcomm.c-1703-\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\n--\ndrivers/net/phy/motorcomm.c-1714-err_restore_normal:\ndrivers/net/phy/motorcomm.c:1715:\tr = genphy_c45_template_testmode(phydev,\ndrivers/net/phy/motorcomm.c-1716-\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\n--\ndrivers/net/phy/phy-c45.c=1409=EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain);\n--\ndrivers/net/phy/phy-c45.c-1411-/**\ndrivers/net/phy/phy-c45.c:1412: * genphy_c45_template_testmode - configure template testmode registers\ndrivers/net/phy/phy-c45.c-1413- * @phydev: target phy_device struct\n--\ndrivers/net/phy/phy-c45.c-1420- */\ndrivers/net/phy/phy-c45.c:1421:int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)\ndrivers/net/phy/phy-c45.c-1422-{\n--\ndrivers/net/phy/phy-c45.c-1431-}\ndrivers/net/phy/phy-c45.c:1432:EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);\ndrivers/net/phy/phy-c45.c-1433-\n--\ninclude/linux/phy.h=2361=int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable);\ninclude/linux/phy.h:2362:int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode);\ninclude/linux/phy.h-2363-int genphy_c45_plca_get_cfg(struct phy_device *phydev,\n"
} |
| 11/2 | 2026/10/18 02:50 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 53331 output: 40 thoughts: 489 Thoughts: **Investigating the Reachability of `genphy_c45_template_testmode`** Okay, so `genphy_c45_template_testmode` is only called by `motorcomm.c`, specifically within the `yt8824_*` functions. My immediate question is: Can we even reach `drivers/net/phy/motorcomm.c` in this context? I need to understand what "Motorcomm PHY" actually *is*. Let's dig into the documentation. Ah, `Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml`... right, it's a PHY package with four individual PHYs. The document further explains that for internal mode, the base address is fixed at 9, and for external mode, it's the base MDIO address plus 4. Let's look at `drivers/net/phy/motorcomm.c` itself. The `motorcomm_tbl` seems to list various Motorcomm PHY IDs like YT8511, YT8521, YT8824, etc. That's good to know. But, a nagging thought emerges: Can ANY PHY driver realistically be probed within a QEMU environment? How is a PHY device even *created* within a Linux system? I need to understand the mechanism. Are there virtual PHY devices that I might be missing, or do the ethernet devices emulated in QEMU inherently *have* PHYs associated with them? I need to research the QEMU/GCE ethernet device landscape. What devices are supported? Let's consider `e1000` and `e1000e`. Do they utilize the phylib framework? It's time to check the sources for `drivers/net/ethernet/intel/e1000/e1000_main.c` or, alternatively, `igb` or `virtio_net` to see how those drivers handle PHY interaction, if at all. |
| 12/2 | 2026/10/18 02:50 | tool | grepper |
0mError:no matches Args: {
"Expression": "phy_connect|phy_attach|phylink",
"PathPrefixes": [
"drivers/net/ethernet/intel/"
]
}Results: {
"error": "no matches"
} |
| 13/2 | 2026/10/18 02:50 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 54307 output: 41 thoughts: 67 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Investigating PHY Abstraction Layer Usage** Alright, so Intel drivers are seemingly going rogue, managing their own PHY code internally, completely bypassing phylib, mdiobus, and `phy_driver`. Interesting, and probably a performance optimization. But I need to understand the landscape. Who *is* still using phylib? That's the key question. Let's shift focus. Realtek's r8169 driver comes to mind as a likely candidate for phylib integration. Let me confirm by looking directly at the code. I'll take a gander at `drivers/net/ethernet/realtek/r8169_main.c` and see if they're following the standard phylib structure or doing something equally custom. This should give me a good baseline for comparison and a better understanding of the ecosystem. |
| 14/2 | 2026/10/18 02:50 | tool | grepper |
0mArgs:{
"Expression": "phy_connect|phy_attach|phylink",
"PathPrefixes": [
"drivers/net/ethernet/realtek/"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 270 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (1 files in total):\ndrivers/net/ethernet/realtek/r8169_main.c:71\n\ndrivers/net/ethernet/realtek/r8169_main.c-28-#include \u003clinux/bitfield.h\u003e\ndrivers/net/ethernet/realtek/r8169_main.c:29:#include \u003clinux/phylink.h\u003e\ndrivers/net/ethernet/realtek/r8169_main.c-30-#include \u003clinux/prefetch.h\u003e\n--\ndrivers/net/ethernet/realtek/r8169_main.c=759=struct rtl8169_private {\n--\ndrivers/net/ethernet/realtek/r8169_main.c-805-\tu32 ocp_base;\ndrivers/net/ethernet/realtek/r8169_main.c:806:\tstruct phylink *phylink;\ndrivers/net/ethernet/realtek/r8169_main.c:807:\tstruct phylink_config phylink_config;\ndrivers/net/ethernet/realtek/r8169_main.c:808:\tstruct phylink_pcs pcs;\ndrivers/net/ethernet/realtek/r8169_main.c-809-};\n--\ndrivers/net/ethernet/realtek/r8169_main.c=2361=static int rtl8169_get_eee(struct net_device *dev, struct ethtool_keee *data)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-2368-\ndrivers/net/ethernet/realtek/r8169_main.c:2369:\tret = phylink_ethtool_get_eee(tp-\u003ephylink, data);\ndrivers/net/ethernet/realtek/r8169_main.c-2370-\tif (ret)\n--\ndrivers/net/ethernet/realtek/r8169_main.c=2378=static int rtl8169_set_eee(struct net_device *dev, struct ethtool_keee *data)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-2384-\ndrivers/net/ethernet/realtek/r8169_main.c:2385:\treturn phylink_ethtool_set_eee(tp-\u003ephylink, data);\ndrivers/net/ethernet/realtek/r8169_main.c-2386-}\n--\ndrivers/net/ethernet/realtek/r8169_main.c=2412=static void rtl8169_get_pauseparam(struct net_device *dev,\n--\ndrivers/net/ethernet/realtek/r8169_main.c-2416-\ndrivers/net/ethernet/realtek/r8169_main.c:2417:\tphylink_ethtool_get_pauseparam(tp-\u003ephylink, data);\ndrivers/net/ethernet/realtek/r8169_main.c-2418-}\n--\ndrivers/net/ethernet/realtek/r8169_main.c=2420=static int rtl8169_set_pauseparam(struct net_device *dev,\n--\ndrivers/net/ethernet/realtek/r8169_main.c-2427-\ndrivers/net/ethernet/realtek/r8169_main.c:2428:\treturn phylink_ethtool_set_pauseparam(tp-\u003ephylink, data);\ndrivers/net/ethernet/realtek/r8169_main.c-2429-}\n--\ndrivers/net/ethernet/realtek/r8169_main.c=2494=static int rtl8169_get_link_ksettings(struct net_device *ndev,\n--\ndrivers/net/ethernet/realtek/r8169_main.c-2498-\ndrivers/net/ethernet/realtek/r8169_main.c:2499:\treturn phylink_ethtool_ksettings_get(tp-\u003ephylink, cmd);\ndrivers/net/ethernet/realtek/r8169_main.c-2500-}\n--\ndrivers/net/ethernet/realtek/r8169_main.c=2502=static int rtl8169_set_link_ksettings(struct net_device *ndev,\n--\ndrivers/net/ethernet/realtek/r8169_main.c-2506-\ndrivers/net/ethernet/realtek/r8169_main.c:2507:\treturn phylink_ethtool_ksettings_set(tp-\u003ephylink, cmd);\ndrivers/net/ethernet/realtek/r8169_main.c-2508-}\n--\ndrivers/net/ethernet/realtek/r8169_main.c=2510=static int rtl8169_nway_reset(struct net_device *dev)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-2513-\ndrivers/net/ethernet/realtek/r8169_main.c:2514:\treturn phylink_ethtool_nway_reset(tp-\u003ephylink);\ndrivers/net/ethernet/realtek/r8169_main.c-2515-}\n--\ndrivers/net/ethernet/realtek/r8169_main.c=2865=static void rtl_prepare_power_down(struct rtl8169_private *tp)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-2871-\tif (device_may_wakeup(tp_to_dev(tp))) {\ndrivers/net/ethernet/realtek/r8169_main.c:2872:\t\tphylink_speed_down(tp-\u003ephylink, false);\ndrivers/net/ethernet/realtek/r8169_main.c-2873-\t\trtl_wol_enable_rx(tp);\n--\ndrivers/net/ethernet/realtek/r8169_main.c=2924=static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-2930-\ndrivers/net/ethernet/realtek/r8169_main.c:2931:\treturn phylink_mii_ioctl(tp-\u003ephylink, ifr, cmd);\ndrivers/net/ethernet/realtek/r8169_main.c-2932-}\n--\ndrivers/net/ethernet/realtek/r8169_main.c=4293=static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-4309-\ndrivers/net/ethernet/realtek/r8169_main.c:4310:\t\tphylink_update_mac_pause_capabilities(tp-\u003ephylink, caps);\ndrivers/net/ethernet/realtek/r8169_main.c-4311-\t}\n--\ndrivers/net/ethernet/realtek/r8169_main.c=5022=static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5040-\t\telse if (tp-\u003esfp_mode)\ndrivers/net/ethernet/realtek/r8169_main.c:5041:\t\t\tphylink_mac_change(tp-\u003ephylink,\ndrivers/net/ethernet/realtek/r8169_main.c-5042-\t\t\t\t\t !!(RTL_R8(tp, PHYstatus) \u0026 LinkStatus));\n--\ndrivers/net/ethernet/realtek/r8169_main.c=5101=static void rtl_enable_tx_lpi(struct rtl8169_private *tp, bool enable)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5132-\ndrivers/net/ethernet/realtek/r8169_main.c:5133:static int r8169_phy_connect(struct rtl8169_private *tp)\ndrivers/net/ethernet/realtek/r8169_main.c-5134-{\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5136-\ndrivers/net/ethernet/realtek/r8169_main.c:5137:\tret = phylink_connect_phy(tp-\u003ephylink, tp-\u003ephydev);\ndrivers/net/ethernet/realtek/r8169_main.c-5138-\tif (ret) {\n--\ndrivers/net/ethernet/realtek/r8169_main.c=5183=static int rtl8169_close(struct net_device *dev)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5189-\ndrivers/net/ethernet/realtek/r8169_main.c:5190:\tphylink_stop(tp-\u003ephylink);\ndrivers/net/ethernet/realtek/r8169_main.c-5191-\tnetif_stop_queue(dev);\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5196-\ndrivers/net/ethernet/realtek/r8169_main.c:5197:\tphylink_disconnect_phy(tp-\u003ephylink);\ndrivers/net/ethernet/realtek/r8169_main.c-5198-\n--\ndrivers/net/ethernet/realtek/r8169_main.c=5220=static int rtl_open(struct net_device *dev)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5254-\tif (tp-\u003ephydev) {\ndrivers/net/ethernet/realtek/r8169_main.c:5255:\t\tretval = r8169_phy_connect(tp);\ndrivers/net/ethernet/realtek/r8169_main.c-5256-\t\tif (retval)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5259-\trtl8169_up(tp);\ndrivers/net/ethernet/realtek/r8169_main.c:5260:\tphylink_start(tp-\u003ephylink);\ndrivers/net/ethernet/realtek/r8169_main.c-5261-\trtl8169_init_counter_offsets(tp);\n--\ndrivers/net/ethernet/realtek/r8169_main.c=5422=static void rtl_remove_one(struct pci_dev *pdev)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5434-\tunregister_netdev(tp-\u003edev);\ndrivers/net/ethernet/realtek/r8169_main.c:5435:\tphylink_destroy(tp-\u003ephylink);\ndrivers/net/ethernet/realtek/r8169_main.c-5436-\n--\ndrivers/net/ethernet/realtek/r8169_main.c=5734=static bool rtl_aspm_is_safe(struct rtl8169_private *tp)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5742-\ndrivers/net/ethernet/realtek/r8169_main.c:5743:static void rtl_mac_link_down(struct phylink_config *config, unsigned int mode,\ndrivers/net/ethernet/realtek/r8169_main.c-5744-\t\t\t phy_interface_t interface)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5747-\t\t\t\t\t\t struct rtl8169_private,\ndrivers/net/ethernet/realtek/r8169_main.c:5748:\t\t\t\t\t\t phylink_config);\ndrivers/net/ethernet/realtek/r8169_main.c-5749-\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5753-\ndrivers/net/ethernet/realtek/r8169_main.c:5754:static void rtl_mac_link_up(struct phylink_config *config,\ndrivers/net/ethernet/realtek/r8169_main.c-5755-\t\t\t struct phy_device *phydev,\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5762-\t\t\t\t\t\t struct rtl8169_private,\ndrivers/net/ethernet/realtek/r8169_main.c:5763:\t\t\t\t\t\t phylink_config);\ndrivers/net/ethernet/realtek/r8169_main.c-5764-\tstruct device *d = tp_to_dev(tp);\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5777-\ndrivers/net/ethernet/realtek/r8169_main.c:5778:static struct phylink_pcs *rtl_mac_select_pcs(struct phylink_config *config,\ndrivers/net/ethernet/realtek/r8169_main.c-5779-\t\t\t\t\t phy_interface_t interface)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5782-\t\t\t\t\t\t struct rtl8169_private,\ndrivers/net/ethernet/realtek/r8169_main.c:5783:\t\t\t\t\t\t phylink_config);\ndrivers/net/ethernet/realtek/r8169_main.c-5784-\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5794-\ndrivers/net/ethernet/realtek/r8169_main.c:5795:static void rtl_mac_config(struct phylink_config *config, unsigned int mode,\ndrivers/net/ethernet/realtek/r8169_main.c:5796:\t\t\t const struct phylink_link_state *state)\ndrivers/net/ethernet/realtek/r8169_main.c-5797-{\n--\ndrivers/net/ethernet/realtek/r8169_main.c=5800=static u16 rtl8169_sds_read(struct rtl8169_private *tp, u16 sds_reg)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5813-\ndrivers/net/ethernet/realtek/r8169_main.c:5814:static void rtl8169_pcs_get_state(struct phylink_pcs *pcs,\ndrivers/net/ethernet/realtek/r8169_main.c-5815-\t\t\t\t unsigned int neg_mode,\ndrivers/net/ethernet/realtek/r8169_main.c:5816:\t\t\t\t struct phylink_link_state *state)\ndrivers/net/ethernet/realtek/r8169_main.c-5817-{\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5843-\t\tlpa = rtl8169_sds_read(tp, RTL_SDS_C22_BASE + MII_LPA);\ndrivers/net/ethernet/realtek/r8169_main.c:5844:\t\tphylink_mii_c22_pcs_decode_state(state, neg_mode, bmsr, lpa);\ndrivers/net/ethernet/realtek/r8169_main.c-5845-\t}\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5847-\ndrivers/net/ethernet/realtek/r8169_main.c:5848:static int rtl8169_pcs_config(struct phylink_pcs *pcs, unsigned int mode,\ndrivers/net/ethernet/realtek/r8169_main.c-5849-\t\t\t phy_interface_t interface,\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5873-\ndrivers/net/ethernet/realtek/r8169_main.c:5874:static int rtl8169_pcs_validate(struct phylink_pcs *pcs,\ndrivers/net/ethernet/realtek/r8169_main.c-5875-\t\t\t\tunsigned long *supported,\ndrivers/net/ethernet/realtek/r8169_main.c:5876:\t\t\t\tconst struct phylink_link_state *state)\ndrivers/net/ethernet/realtek/r8169_main.c-5877-{\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5880-\ndrivers/net/ethernet/realtek/r8169_main.c:5881:static void rtl8169_pcs_an_restart(struct phylink_pcs *pcs)\ndrivers/net/ethernet/realtek/r8169_main.c-5882-{\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5884-\ndrivers/net/ethernet/realtek/r8169_main.c:5885:static void rtl_mac_disable_tx_lpi(struct phylink_config *config)\ndrivers/net/ethernet/realtek/r8169_main.c-5886-{\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5888-\t\t\t\t\t\t struct rtl8169_private,\ndrivers/net/ethernet/realtek/r8169_main.c:5889:\t\t\t\t\t\t phylink_config);\ndrivers/net/ethernet/realtek/r8169_main.c-5890-\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5893-\ndrivers/net/ethernet/realtek/r8169_main.c:5894:static int rtl_mac_enable_tx_lpi(struct phylink_config *config,\ndrivers/net/ethernet/realtek/r8169_main.c-5895-\t\t\t\t u32 timer,\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5899-\t\t\t\t\t\t struct rtl8169_private,\ndrivers/net/ethernet/realtek/r8169_main.c:5900:\t\t\t\t\t\t phylink_config);\ndrivers/net/ethernet/realtek/r8169_main.c-5901-\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5906-\ndrivers/net/ethernet/realtek/r8169_main.c:5907:static const struct phylink_mac_ops rtl_phylink_mac_ops = {\ndrivers/net/ethernet/realtek/r8169_main.c-5908-\t.mac_select_pcs = rtl_mac_select_pcs,\n--\ndrivers/net/ethernet/realtek/r8169_main.c=5916=static unsigned long rtl8169_get_lpi_caps(struct rtl8169_private *tp)\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5937-\ndrivers/net/ethernet/realtek/r8169_main.c:5938:static const struct phylink_pcs_ops r8169_pcs_ops = {\ndrivers/net/ethernet/realtek/r8169_main.c-5939-\t.pcs_validate = rtl8169_pcs_validate,\n--\ndrivers/net/ethernet/realtek/r8169_main.c-5944-\ndrivers/net/ethernet/realtek/r8169_main.c:5945:static int rtl_init_phylink(struct rtl8169_private *tp)\ndrivers/net/ethernet/realtek/r8169_main.c-5946-{\n\n"
} |
| 15/2 | 2026/10/18 02:50 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 60011 output: 33 thoughts: 885 Thoughts: **Analyzing the Motorcomm PHY Driver on amd64** Okay, so `r8169` connects to the Realtek PHY, which uses `realtek.c`. But I'm curious about the Motorcomm PHY. What devices use Motorcomm PHYs? Let's check the PHY IDs: `PHY_ID_YT8511`, `PHY_ID_YT8521`, `PHY_ID_YT8522`, `PHY_ID_YT8531`, `PHY_ID_YT8531S`, `PHY_ID_INT861X`, `PHY_ID_YT8821`, and `PHY_ID_YT8824`. I'll dive into `drivers/net/phy/motorcomm.c`. Aha, looking at the `yt8824_probe` function, I see `devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv))`. That's a strong hint! It needs OF (Device Tree), specifically the `ethernet-phy-package` property in DT. And then, `yt8824_phy_package_probe_once` explicitly expects a device tree node `np` with `motorcomm,package-mode`. The problem is, the target architecture is amd64! On amd64 (x86_64), device trees aren't used, unless it's an `of_unittest` or something synthetic, but even then, how would an MDIO bus with this PHY be probed? But wait, is there *any* way for `motorcomm.c` to be loaded or bound to a device on amd64 in QEMU? Can I, as a user, or something like syzkaller, load `motorcomm`? Yes, `modprobe motorcomm` registers `motorcomm_phy_drvs` via `phy_drivers_register`. When `phy_drivers_register` is called, it registers the driver on `mdio_bus_type`. It calls `driver_register(&new_driver->mdio.driver)`. That's the key. It just registers the driver on `mdio_bus_type`. Unless a device is *created* on `mdio_bus_type` with the matching PHY ID (`0x4f51e8b8`), `yt8824_probe` is *never* called! Now, the crucial question: can a device on `mdio_bus_type` be created from userspace? I need to check if `mdio_bus_type` allows device creation from userspace. Let's see... I'll search for `mdio_bus_type`. |
| 16/2 | 2026/10/18 02:50 | tool | grepper |
0mArgs:{
"Expression": "mdio_bus_type",
"PathPrefixes": [
"drivers/net/phy/"
]
}Results: {
"Output": "drivers/net/phy/mdio_bus_provider.c=298=__ATTRIBUTE_GROUPS(mdio_bus_device_statistics);\ndrivers/net/phy/mdio_bus_provider.c-299-\ndrivers/net/phy/mdio_bus_provider.c:300:const struct bus_type mdio_bus_type = {\ndrivers/net/phy/mdio_bus_provider.c-301-\t.name\t\t= \"mdio_bus\",\n--\ndrivers/net/phy/mdio_device.c=119=struct mdio_device *mdio_device_create(struct mii_bus *bus, int addr)\n--\ndrivers/net/phy/mdio_device.c-129-\tmdiodev-\u003edev.parent = \u0026bus-\u003edev;\ndrivers/net/phy/mdio_device.c:130:\tmdiodev-\u003edev.bus = \u0026mdio_bus_type;\ndrivers/net/phy/mdio_device.c-131-\tmdiodev-\u003edevice_free = mdio_device_free;\n--\ndrivers/net/phy/mdio_device.c=285=int mdio_driver_register(struct mdio_driver *drv)\n--\ndrivers/net/phy/mdio_device.c-291-\ndrivers/net/phy/mdio_device.c:292:\tmdiodrv-\u003edriver.bus = \u0026mdio_bus_type;\ndrivers/net/phy/mdio_device.c-293-\tmdiodrv-\u003edriver.probe = mdio_probe;\n--\ndrivers/net/phy/phy_device.c=658=struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,\n--\ndrivers/net/phy/phy_device.c-672-\tmdiodev-\u003edev.parent = \u0026bus-\u003edev;\ndrivers/net/phy/phy_device.c:673:\tmdiodev-\u003edev.bus = \u0026mdio_bus_type;\ndrivers/net/phy/phy_device.c-674-\tmdiodev-\u003edev.type = \u0026mdio_bus_phy_type;\n--\ndrivers/net/phy/phy_device.c=1171=struct phy_device *phy_connect(struct net_device *dev, const char *bus_id,\n--\ndrivers/net/phy/phy_device.c-1181-\t */\ndrivers/net/phy/phy_device.c:1182:\td = bus_find_device_by_name(\u0026mdio_bus_type, NULL, bus_id);\ndrivers/net/phy/phy_device.c-1183-\tif (!d) {\n--\ndrivers/net/phy/phy_device.c=3592=struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)\n--\ndrivers/net/phy/phy_device.c-3598-\ndrivers/net/phy/phy_device.c:3599:\td = bus_find_device_by_fwnode(\u0026mdio_bus_type, fwnode);\ndrivers/net/phy/phy_device.c-3600-\tif (!d)\n--\ndrivers/net/phy/phy_device.c=3843=static int phy_driver_register(struct phy_driver *new_driver,\n--\ndrivers/net/phy/phy_device.c-3868-\tnew_driver-\u003emdiodrv.driver.name = new_driver-\u003ename;\ndrivers/net/phy/phy_device.c:3869:\tnew_driver-\u003emdiodrv.driver.bus = \u0026mdio_bus_type;\ndrivers/net/phy/phy_device.c-3870-\tnew_driver-\u003emdiodrv.driver.probe = phy_probe;\n--\ndrivers/net/phy/phy_device.c=3957=static int __init phy_init(void)\n--\ndrivers/net/phy/phy_device.c-3964-\ndrivers/net/phy/phy_device.c:3965:\trc = bus_register(\u0026mdio_bus_type);\ndrivers/net/phy/phy_device.c-3966-\tif (rc)\n--\ndrivers/net/phy/phy_device.c-3996-\trtnl_unlock();\ndrivers/net/phy/phy_device.c:3997:\tbus_unregister(\u0026mdio_bus_type);\ndrivers/net/phy/phy_device.c-3998-err_class:\n--\ndrivers/net/phy/phy_device.c=4004=static void __exit phy_exit(void)\n--\ndrivers/net/phy/phy_device.c-4011-\trtnl_unlock();\ndrivers/net/phy/phy_device.c:4012:\tbus_unregister(\u0026mdio_bus_type);\ndrivers/net/phy/phy_device.c-4013-\tclass_unregister(\u0026mdio_bus_class);\n--\ndrivers/net/phy/phylib-internal.h=10=struct phy_device;\ndrivers/net/phy/phylib-internal.h-11-\ndrivers/net/phy/phylib-internal.h:12:extern const struct bus_type mdio_bus_type;\ndrivers/net/phy/phylib-internal.h-13-extern const struct class mdio_bus_class;\n"
} |
| 17/2 | 2026/10/18 02:50 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 62892 output: 42 thoughts: 30 Thoughts: Here's my thought process, as if I were considering this myself: **Investigating the `mdio_bus_type` Definition** Okay, time to get to the heart of this. My initial thought is to zero in on the `mdio_bus_type` definition. The obvious starting point for such a core piece of the MDIO infrastructure is going to be within the `drivers/net/phy/mdio_bus_provider.c` file. I'll need to examine that file. I expect it'll give me the structural blueprint for this key aspect. I'm especially interested in its members and how it defines the interactions and capabilities of the MDIO bus provider. I anticipate I'll likely find the basic structure laid out there, and from there I can start to follow the cross-references. |
| 18/2 | 2026/10/18 02:50 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/mdio_bus_provider.c",
"FirstLine": 295,
"LineCount": 25
}Results: {
"Contents": " 295:\t\t.name\t\t= \"statistics\",\n 296:\t\t.attrs_const\t= mdio_bus_device_statistics_attrs,\n 297:\t};\n 298:\t__ATTRIBUTE_GROUPS(mdio_bus_device_statistics);\n 299:\t\n 300:\tconst struct bus_type mdio_bus_type = {\n 301:\t\t.name\t\t= \"mdio_bus\",\n 302:\t\t.dev_groups\t= mdio_bus_device_statistics_groups,\n 303:\t\t.match\t\t= mdio_bus_match,\n 304:\t\t.uevent\t\t= mdio_uevent,\n 305:\t};\n 306:\t\n 307:\t/**\n 308:\t * mdiobus_alloc_size - allocate a mii_bus structure\n 309:\t * @size: extra amount of memory to allocate for private storage.\n 310:\t * If non-zero, then bus-\u003epriv is points to that memory.\n 311:\t *\n 312:\t * Description: called by a bus driver to allocate an mii_bus\n 313:\t * structure to fill in.\n 314:\t */\n 315:\tstruct mii_bus *mdiobus_alloc_size(size_t size)\n 316:\t{\n 317:\t\tstruct mii_bus *bus;\n 318:\t\tsize_t aligned_size = ALIGN(sizeof(*bus), NETDEV_ALIGN);\n 319:\t\tsize_t alloc_size;\n"
} |
| 19/2 | 2026/10/18 02:50 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 63553 output: 19 thoughts: 120 Thoughts: **Investigating MDIO Bus Instantiation** Okay, so I've noticed something interesting – the `mdio_bus_type` structure doesn't seem to expose the standard sysfs interfaces we often see with I2C or SPI buses, like a `new_device` or similar. That's a little unusual, and it's got me thinking. The question that immediately pops into my head is, can userspace even *instantiate* an MDIO bus or a PHY device directly? Is there some backdoor method I'm missing? My next step is to comprehensively check the usual suspects. I need to see if there's a sysfs entry, a netlink interface, or even an ioctl that provides some control for creating an MDIO device or the underlying `mii_bus` object. I'll need to dig through the kernel documentation and source code for this. I'll revisit my search for callers of `mdiobus_register` again, making sure I haven't missed anything crucial. And, critically, I need to check whether any virtual drivers, specifically, are registering MDIO buses. Sometimes these virtual drivers provide interesting insight into how the MDIO functionality is used and/or created. Finally, I'm going to perform a thorough grep across the kernel source code for `mdiobus_register`. This brute-force method should uncover any instances I've missed and give me a clear picture of all the potential registration points within the system. This comprehensive search should provide the answer, one way or another. |
| 20/2 | 2026/10/18 02:50 | tool | grepper |
0mArgs:{
"Expression": "mdiobus_register"
}Results: {
"Output": "\nFull output is too long, showing 200 out of 1138 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (142 files in total):\nDocumentation/driver-api/driver-model/devres.rst:2\nDocumentation/firmware-guide/acpi/dsd/motorcomm-yt8xxx-phy.rst:1\nDocumentation/firmware-guide/acpi/dsd/phy.rst:1\nDocumentation/networking/phy.rst:1\narch/powerpc/platforms/82xx/ep8248e.c:1\narch/powerpc/platforms/pasemi/gpio_mdio.c:1\ndrivers/net/dsa/bcm_sf2.c:1\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c:1\ndrivers/net/dsa/microchip/ksz9477.c:1\ndrivers/net/dsa/microchip/ksz_common.c:1\ndrivers/net/dsa/microchip/lan937x_main.c:1\ndrivers/net/dsa/motorcomm/mdio_bus.c:2\ndrivers/net/dsa/mt7530.c:1\ndrivers/net/dsa/mt7628.c:1\ndrivers/net/dsa/mv88e6xxx/chip.c:1\ndrivers/net/dsa/mxl862xx/mxl862xx.c:1\ndrivers/net/dsa/netc/netc_main.c:1\ndrivers/net/dsa/ocelot/felix_vsc9959.c:1\ndrivers/net/dsa/ocelot/seville_vsc9953.c:1\ndrivers/net/dsa/qca/ar9331.c:1\ndrivers/net/dsa/qca/qca8k-8xxx.c:1\ndrivers/net/dsa/realtek/rtl83xx.c:1\ndrivers/net/dsa/rzn1_a5psw.c:1\ndrivers/net/dsa/sja1105/sja1105.h:1\ndrivers/net/dsa/sja1105/sja1105_main.c:1\ndrivers/net/dsa/sja1105/sja1105_mdio.c:4\ndrivers/net/ethernet/8390/ax88796.c:1\ndrivers/net/ethernet/actions/owl-emac.c:1\ndrivers/net/ethernet/adi/adin1110.c:1\ndrivers/net/ethernet/adi/adin1140.c:1\ndrivers/net/ethernet/aeroflex/greth.c:1\ndrivers/net/ethernet/agere/et131x.c:1\ndrivers/net/ethernet/altera/altera_tse_main.c:1\ndrivers/net/ethernet/amd/au1000_eth.c:1\ndrivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:2\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:1\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:4\ndrivers/net/ethernet/arc/emac_mdio.c:1\ndrivers/net/ethernet/asix/ax88796c_main.c:1\ndrivers/net/ethernet/atheros/ag71xx.c:1\ndrivers/net/ethernet/broadcom/b44.c:1\ndrivers/net/ethernet/broadcom/bcm63xx_enet.c:1\ndrivers/net/ethernet/broadcom/bgmac-bcma-mdio.c:1\ndrivers/net/ethernet/broadcom/genet/bcmmii.c:1\ndrivers/net/ethernet/broadcom/sb1250-mac.c:1\ndrivers/net/ethernet/broadcom/tg3.c:1\ndrivers/net/ethernet/cadence/macb_main.c:5\ndrivers/net/ethernet/davicom/dm9051.c:1\ndrivers/net/ethernet/engleder/tsnep_main.c:1\ndrivers/net/ethernet/ethoc.c:1\n... and 92 more files\n\nDocumentation/driver-api/driver-model/devres.rst=349=MDIO\n--\nDocumentation/driver-api/driver-model/devres.rst-351- devm_mdiobus_alloc_size()\nDocumentation/driver-api/driver-model/devres.rst:352: devm_mdiobus_register()\nDocumentation/driver-api/driver-model/devres.rst:353: devm_of_mdiobus_register()\nDocumentation/driver-api/driver-model/devres.rst-354-\n--\nDocumentation/firmware-guide/acpi/dsd/motorcomm-yt8xxx-phy.rst=12=device (the same objects that are registered via\nDocumentation/firmware-guide/acpi/dsd/motorcomm-yt8xxx-phy.rst:13:``fwnode_mdiobus_register_phy()``). MAC-side connection properties such as\nDocumentation/firmware-guide/acpi/dsd/motorcomm-yt8xxx-phy.rst-14-``phy-handle`` and ``phy-mode`` are documented in [acpi-mdio-phy]_.\n--\nDocumentation/firmware-guide/acpi/dsd/phy.rst=7=The PHYs on an MDIO bus [phy] are probed and registered using\nDocumentation/firmware-guide/acpi/dsd/phy.rst:8:fwnode_mdiobus_register_phy().\nDocumentation/firmware-guide/acpi/dsd/phy.rst-9-\n--\nDocumentation/networking/phy.rst=40=registered as a distinct device.\n--\nDocumentation/networking/phy.rst-56- driver needs, setup the mii_bus structure, and register with the PAL using\nDocumentation/networking/phy.rst:57: mdiobus_register. Similarly, there's a remove function to undo all of\nDocumentation/networking/phy.rst-58- that (use mdiobus_unregister).\n--\narch/powerpc/platforms/82xx/ep8248e.c=109=static int ep8248e_mdio_probe(struct platform_device *ofdev)\n--\narch/powerpc/platforms/82xx/ep8248e.c-132-\narch/powerpc/platforms/82xx/ep8248e.c:133:\tret = of_mdiobus_register(bus, ofdev-\u003edev.of_node);\narch/powerpc/platforms/82xx/ep8248e.c-134-\tif (ret)\n--\narch/powerpc/platforms/pasemi/gpio_mdio.c=207=static int gpio_mdio_probe(struct platform_device *ofdev)\n--\narch/powerpc/platforms/pasemi/gpio_mdio.c-243-\narch/powerpc/platforms/pasemi/gpio_mdio.c:244:\terr = of_mdiobus_register(new_bus, np);\narch/powerpc/platforms/pasemi/gpio_mdio.c-245-\n--\ndrivers/net/dsa/bcm_sf2.c=607=static int bcm_sf2_mdio_register(struct dsa_switch *ds)\n--\ndrivers/net/dsa/bcm_sf2.c-683-\ndrivers/net/dsa/bcm_sf2.c:684:\terr = mdiobus_register(priv-\u003euser_mii_bus);\ndrivers/net/dsa/bcm_sf2.c-685-\tif (err)\n--\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c=187=static int gswip_mdio(struct gswip_priv *priv)\n--\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c-213-\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c:214:\terr = devm_of_mdiobus_register(dev, bus, mdio_np);\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c-215-\n--\ndrivers/net/dsa/microchip/ksz9477.c=321=static int ksz9477_pcs_create(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz9477.c-341-\ndrivers/net/dsa/microchip/ksz9477.c:342:\tret = devm_mdiobus_register(dev-\u003edev, bus);\ndrivers/net/dsa/microchip/ksz9477.c-343-\tif (ret)\n--\ndrivers/net/dsa/microchip/ksz_common.c=2407=int ksz_mdio_register(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz_common.c-2478-\ndrivers/net/dsa/microchip/ksz_common.c:2479:\tret = devm_of_mdiobus_register(ds-\u003edev, bus, mdio_np);\ndrivers/net/dsa/microchip/ksz_common.c-2480-\tif (ret) {\n--\ndrivers/net/dsa/microchip/lan937x_main.c=685=static int lan937x_mdio_register(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/lan937x_main.c-755-\ndrivers/net/dsa/microchip/lan937x_main.c:756:\tret = devm_of_mdiobus_register(ds-\u003edev, bus, mdio_np);\ndrivers/net/dsa/microchip/lan937x_main.c-757-\tif (ret)\n--\ndrivers/net/dsa/motorcomm/mdio_bus.c=144=int yt921x_mbus_int_init(struct yt921x_priv *priv, struct device_node *mnp)\n--\ndrivers/net/dsa/motorcomm/mdio_bus.c-161-\ndrivers/net/dsa/motorcomm/mdio_bus.c:162:\tres = devm_of_mdiobus_register(dev, mbus, mnp);\ndrivers/net/dsa/motorcomm/mdio_bus.c-163-\tif (res)\n--\ndrivers/net/dsa/motorcomm/mdio_bus.c=274=int yt921x_mbus_ext_init(struct yt921x_priv *priv, struct device_node *mnp)\n--\ndrivers/net/dsa/motorcomm/mdio_bus.c-291-\ndrivers/net/dsa/motorcomm/mdio_bus.c:292:\tres = devm_of_mdiobus_register(dev, mbus, mnp);\ndrivers/net/dsa/motorcomm/mdio_bus.c-293-\tif (res)\n--\ndrivers/net/dsa/mt7530.c=2331=mt7530_setup_mdio(struct mt7530_priv *priv)\n--\ndrivers/net/dsa/mt7530.c-2366-\ndrivers/net/dsa/mt7530.c:2367:\tret = devm_of_mdiobus_register(dev, bus, mnp);\ndrivers/net/dsa/mt7530.c-2368-\tif (ret) {\n--\ndrivers/net/dsa/mt7628.c=242=static int mt7628_setup_internal_mdio(struct dsa_switch *ds)\n--\ndrivers/net/dsa/mt7628.c-261-\ndrivers/net/dsa/mt7628.c:262:\treturn devm_mdiobus_register(dev, bus);\ndrivers/net/dsa/mt7628.c-263-}\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3843=static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3896-\ndrivers/net/dsa/mv88e6xxx/chip.c:3897:\terr = of_mdiobus_register(bus, np);\ndrivers/net/dsa/mv88e6xxx/chip.c-3898-\tif (err) {\n--\ndrivers/net/dsa/mxl862xx/mxl862xx.c=267=static int mxl862xx_setup_mdio(struct dsa_switch *ds)\n--\ndrivers/net/dsa/mxl862xx/mxl862xx.c-292-\ndrivers/net/dsa/mxl862xx/mxl862xx.c:293:\tret = devm_of_mdiobus_register(dev, bus, mdio_np);\ndrivers/net/dsa/mxl862xx/mxl862xx.c-294-\tof_node_put(mdio_np);\n--\ndrivers/net/dsa/netc/netc_main.c=149=static int netc_port_create_emdio_bus(struct netc_port *np,\n--\ndrivers/net/dsa/netc/netc_main.c-179-\ndrivers/net/dsa/netc/netc_main.c:180:\terr = devm_of_mdiobus_register(dev, bus, node);\ndrivers/net/dsa/netc/netc_main.c-181-\tif (err)\n--\ndrivers/net/dsa/ocelot/felix_vsc9959.c=957=static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)\n--\ndrivers/net/dsa/ocelot/felix_vsc9959.c-1013-\t/* Needed in order to initialize the bus mutex lock */\ndrivers/net/dsa/ocelot/felix_vsc9959.c:1014:\trc = mdiobus_register(bus);\ndrivers/net/dsa/ocelot/felix_vsc9959.c-1015-\tif (rc \u003c 0) {\n--\ndrivers/net/dsa/ocelot/seville_vsc9953.c=878=static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)\n--\ndrivers/net/dsa/ocelot/seville_vsc9953.c-903-\t/* Needed in order to initialize the bus mutex lock */\ndrivers/net/dsa/ocelot/seville_vsc9953.c:904:\trc = devm_of_mdiobus_register(dev, bus, NULL);\ndrivers/net/dsa/ocelot/seville_vsc9953.c-905-\tif (rc \u003c 0) {\n--\ndrivers/net/dsa/qca/ar9331.c=357=static int ar9331_sw_mbus_init(struct ar9331_sw_priv *priv)\n--\ndrivers/net/dsa/qca/ar9331.c-381-\ndrivers/net/dsa/qca/ar9331.c:382:\tret = devm_of_mdiobus_register(dev, mbus, mnp);\ndrivers/net/dsa/qca/ar9331.c-383-\tof_node_put(mnp);\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c=959=qca8k_mdio_register(struct qca8k_priv *priv)\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c-998-\ndrivers/net/dsa/qca/qca8k-8xxx.c:999:\tret = devm_of_mdiobus_register(dev, bus, mdio);\ndrivers/net/dsa/qca/qca8k-8xxx.c-1000-\n--\ndrivers/net/dsa/realtek/rtl83xx.c=91=int rtl83xx_setup_user_mdio(struct dsa_switch *ds)\n--\ndrivers/net/dsa/realtek/rtl83xx.c-120-\ndrivers/net/dsa/realtek/rtl83xx.c:121:\tret = devm_of_mdiobus_register(priv-\u003edev, bus, mdio_np);\ndrivers/net/dsa/realtek/rtl83xx.c-122-\tif (ret) {\n--\ndrivers/net/dsa/rzn1_a5psw.c=1117=static int a5psw_probe_mdio(struct a5psw *a5psw, struct device_node *node)\n--\ndrivers/net/dsa/rzn1_a5psw.c-1143-\ndrivers/net/dsa/rzn1_a5psw.c:1144:\treturn devm_of_mdiobus_register(dev, bus, node);\ndrivers/net/dsa/rzn1_a5psw.c-1145-}\n--\ndrivers/net/dsa/sja1105/sja1105.h=307=void sja1105_frame_memory_partitioning(struct sja1105_private *priv);\n--\ndrivers/net/dsa/sja1105/sja1105.h-309-/* From sja1105_mdio.c */\ndrivers/net/dsa/sja1105/sja1105.h:310:int sja1105_mdiobus_register(struct dsa_switch *ds);\ndrivers/net/dsa/sja1105/sja1105.h-311-void sja1105_mdiobus_unregister(struct dsa_switch *ds);\n--\ndrivers/net/dsa/sja1105/sja1105_main.c=3026=static int sja1105_setup(struct dsa_switch *ds)\n--\ndrivers/net/dsa/sja1105/sja1105_main.c-3067-\ndrivers/net/dsa/sja1105/sja1105_main.c:3068:\trc = sja1105_mdiobus_register(ds);\ndrivers/net/dsa/sja1105/sja1105_main.c-3069-\tif (rc \u003c 0) {\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c=258=static int sja1105_mdiobus_base_tx_register(struct sja1105_private *priv,\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c-287-\ndrivers/net/dsa/sja1105/sja1105_mdio.c:288:\trc = of_mdiobus_register(bus, np);\ndrivers/net/dsa/sja1105/sja1105_mdio.c-289-\tif (rc) {\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c=312=static int sja1105_mdiobus_base_t1_register(struct sja1105_private *priv,\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c-343-\ndrivers/net/dsa/sja1105/sja1105_mdio.c:344:\trc = of_mdiobus_register(bus, np);\ndrivers/net/dsa/sja1105/sja1105_mdio.c-345-\tif (rc) {\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-395-\ndrivers/net/dsa/sja1105/sja1105_mdio.c:396:\trc = mdiobus_register(bus);\ndrivers/net/dsa/sja1105/sja1105_mdio.c-397-\tif (rc) {\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c=439=static void sja1105_mdiobus_pcs_unregister(struct sja1105_private *priv)\n--\ndrivers/net/dsa/sja1105/sja1105_mdio.c-458-\ndrivers/net/dsa/sja1105/sja1105_mdio.c:459:int sja1105_mdiobus_register(struct dsa_switch *ds)\ndrivers/net/dsa/sja1105/sja1105_mdio.c-460-{\n--\ndrivers/net/ethernet/8390/ax88796.c=459=static int ax_mii_init(struct net_device *dev)\n--\ndrivers/net/ethernet/8390/ax88796.c-478-\ndrivers/net/ethernet/8390/ax88796.c:479:\terr = mdiobus_register(ax-\u003emii_bus);\ndrivers/net/ethernet/8390/ax88796.c-480-\tif (err)\n--\ndrivers/net/ethernet/actions/owl-emac.c=1321=static int owl_emac_mdio_init(struct net_device *netdev)\n--\ndrivers/net/ethernet/actions/owl-emac.c-1345-\ndrivers/net/ethernet/actions/owl-emac.c:1346:\tret = devm_of_mdiobus_register(dev, priv-\u003emii, mdio_node);\ndrivers/net/ethernet/actions/owl-emac.c-1347-\n--\ndrivers/net/ethernet/adi/adin1110.c=509=static int adin1110_register_mdiobus(struct adin1110_priv *priv,\n--\ndrivers/net/ethernet/adi/adin1110.c-529-\ndrivers/net/ethernet/adi/adin1110.c:530:\tret = devm_mdiobus_register(dev, mii_bus);\ndrivers/net/ethernet/adi/adin1110.c-531-\tif (ret)\n--\ndrivers/net/ethernet/adi/adin1140.c=617=static int adin1140_mdio_register(struct adin1140_priv *priv,\n--\ndrivers/net/ethernet/adi/adin1140.c-636-\ndrivers/net/ethernet/adi/adin1140.c:637:\treturn devm_mdiobus_register(\u0026spidev-\u003edev, priv-\u003emdiobus);\ndrivers/net/ethernet/adi/adin1140.c-638-}\n\n"
} |
| 21/2 | 2026/10/18 02:50 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 70213 output: 40 thoughts: 44 Thoughts: Okay, let's break this down. **Investigating Network Adapter Driver Configuration** Hmm, so I'm trying to figure out a specific aspect of network adapter behavior, specifically around how MDIO buses and PHY probing are handled. The question is, are there *any* USB or virtio (or even virtual ethernet) adapters that actually register an MDIO bus and initiate physical PHY probing? This is a bit of an unusual configuration, and it's not something I deal with directly too often. It’s definitely not standard to use USB or virtio devices in that context! The next logical step is to dive into the kernel source code to examine the USB Ethernet drivers. To start, I'll need to look at `drivers/net/usb/`. That seems like the right location, and I can start by inspecting those. |
| 22/2 | 2026/10/18 02:50 | tool | grepper |
0mArgs:{
"Expression": "mdiobus_register|phy_connect|phy_attach",
"PathPrefixes": [
"drivers/net/usb/"
]
}Results: {
"Output": "drivers/net/usb/asix_devices.c=669=static int ax88772_init_mdio(struct usbnet *dev)\n--\ndrivers/net/usb/asix_devices.c-686-\ndrivers/net/usb/asix_devices.c:687:\tret = mdiobus_register(priv-\u003emdio);\ndrivers/net/usb/asix_devices.c-688-\tif (ret) {\n--\ndrivers/net/usb/asix_devices.c=703=static int ax88772_init_phy(struct usbnet *dev)\n--\ndrivers/net/usb/asix_devices.c-722-\ndrivers/net/usb/asix_devices.c:723:\tphy_attached_info(priv-\u003ephydev);\ndrivers/net/usb/asix_devices.c-724-\n--\ndrivers/net/usb/ax88172a.c=61=static int ax88172a_init_mdio(struct usbnet *dev)\n--\ndrivers/net/usb/ax88172a.c-79-\ndrivers/net/usb/ax88172a.c:80:\tret = mdiobus_register(priv-\u003emdio);\ndrivers/net/usb/ax88172a.c-81-\tif (ret) {\n--\ndrivers/net/usb/ax88172a.c=260=static int ax88172a_reset(struct usbnet *dev)\n--\ndrivers/net/usb/ax88172a.c-312-\ndrivers/net/usb/ax88172a.c:313:\tpriv-\u003ephydev = phy_connect(dev-\u003enet, priv-\u003ephy_name,\ndrivers/net/usb/ax88172a.c-314-\t\t\t\t \u0026ax88172a_adjust_link,\n--\ndrivers/net/usb/lan78xx.c=2094=static int lan78xx_mdio_init(struct lan78xx_net *dev)\n--\ndrivers/net/usb/lan78xx.c-2124-\tnode = of_get_child_by_name(dev-\u003eudev-\u003edev.of_node, \"mdio\");\ndrivers/net/usb/lan78xx.c:2125:\tret = of_mdiobus_register(dev-\u003emdiobus, node);\ndrivers/net/usb/lan78xx.c-2126-\tof_node_put(node);\n--\ndrivers/net/usb/smsc95xx.c=1147=static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)\n--\ndrivers/net/usb/smsc95xx.c-1241-\ndrivers/net/usb/smsc95xx.c:1242:\tret = mdiobus_register(pdata-\u003emdiobus);\ndrivers/net/usb/smsc95xx.c-1243-\tif (ret) {\n--\ndrivers/net/usb/smsc95xx.c-1285-\ndrivers/net/usb/smsc95xx.c:1286:\tret = phy_connect_direct(dev-\u003enet, pdata-\u003ephydev,\ndrivers/net/usb/smsc95xx.c-1287-\t\t\t\t \u0026smsc95xx_handle_link_change,\n--\ndrivers/net/usb/smsc95xx.c-1293-\ndrivers/net/usb/smsc95xx.c:1294:\tphy_attached_info(dev-\u003enet-\u003ephydev);\ndrivers/net/usb/smsc95xx.c-1295-\n"
} |
| 23/2 | 2026/10/18 02:50 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 71429 output: 34 thoughts: 145 Thoughts: **USB Ethernet Driver Deep Dive** Okay, let's see what we have here. Diving into these USB Ethernet drivers… Aha! Interesting. I'm seeing `mdiobus_register` called in a few key places: `drivers/net/usb/asix_devices.c` within `ax88772_init_mdio()`, then `drivers/net/usb/smsc95xx.c` with `mdiobus_register(pdata->mdiobus)`, and also in `drivers/net/usb/lan78xx.c`. Seems like a pattern emerging related to the Media Independent Interface (MII) bus for PHY communication. But now my mind goes straight to how this `mdiobus_register` function actually *works*. I need to drill down into the definition. Let's shift our focus to `drivers/net/phy/mdio_bus.c` to see how that registration is handled and what’s happening at that level. Curious to see what data structures are being populated and how this whole PHY probing and management is initiated. The deeper I look, the more I'm appreciating the elegance of the abstractions within this networking stack. |
| 24/2 | 2026/10/18 02:51 | tool | grepper |
0mArgs:{
"Expression": "int __mdiobus_register",
"PathPrefixes": [
"drivers/net/phy/"
]
}Results: {
"Output": "drivers/net/phy/mdio_bus_provider.c=525=static bool mdiobus_prevent_c45_scan(struct mii_bus *bus)\n--\ndrivers/net/phy/mdio_bus_provider.c-552- */\ndrivers/net/phy/mdio_bus_provider.c:553:int __mdiobus_register(struct mii_bus *bus, struct module *owner)\ndrivers/net/phy/mdio_bus_provider.c-554-{\n"
} |
| 25/2 | 2026/10/18 02:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 72001 output: 42 thoughts: 27 Thoughts: Okay, let's dive into this. Here's my take on those lines of code: **Analyzing `drivers/net/phy/mdio_bus_provider.c` Around Line 553** Right, so I'm thinking we need to examine `drivers/net/phy/mdio_bus_provider.c` specifically around line 553. I'm assuming that this section is important for a reason; perhaps it involves the MDIO bus provider functionality, potentially dealing with device registration, probe, removal, or a critical data structure interaction. Given my understanding of networking and MDIO, I'm expecting to see calls related to bus operations, potentially register_mdio_bus or related functions. I'm going to look for any logic that could be creating problems with our system or maybe something we could optimize. I need to understand the control flow here and the data structures involved, like the `mdio_bus` struct, and how this particular code affects the interaction between the PHY and the MDIO bus. I'll be looking for potential race conditions, locking issues, or any unexpected behavior with respect to device initialization or shutdown. |
| 26/2 | 2026/10/18 02:51 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/mdio_bus_provider.c",
"FirstLine": 550,
"LineCount": 70
}Results: {
"Contents": " 550:\t *\n 551:\t * Returns 0 on success or \u003c 0 on error.\n 552:\t */\n 553:\tint __mdiobus_register(struct mii_bus *bus, struct module *owner)\n 554:\t{\n 555:\t\tstruct mdio_device *mdiodev;\n 556:\t\tstruct gpio_desc *gpiod;\n 557:\t\tbool prevent_c45_scan;\n 558:\t\tint i, err;\n 559:\t\n 560:\t\tif (!bus || !bus-\u003ename)\n 561:\t\t\treturn -EINVAL;\n 562:\t\n 563:\t\t/* An access method always needs both read and write operations */\n 564:\t\tif (!!bus-\u003eread != !!bus-\u003ewrite || !!bus-\u003eread_c45 != !!bus-\u003ewrite_c45)\n 565:\t\t\treturn -EINVAL;\n 566:\t\n 567:\t\t/* At least one method is mandatory */\n 568:\t\tif (!bus-\u003eread \u0026\u0026 !bus-\u003eread_c45)\n 569:\t\t\treturn -EINVAL;\n 570:\t\n 571:\t\tif (bus-\u003eparent \u0026\u0026 bus-\u003eparent-\u003eof_node)\n 572:\t\t\tfwnode_set_flag(\u0026bus-\u003eparent-\u003eof_node-\u003efwnode,\n 573:\t\t\t\t\tFWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD);\n 574:\t\n 575:\t\tWARN(bus-\u003estate != MDIOBUS_ALLOCATED \u0026\u0026\n 576:\t\t bus-\u003estate != MDIOBUS_UNREGISTERED,\n 577:\t\t \"%s: not in ALLOCATED or UNREGISTERED state\\n\", bus-\u003eid);\n 578:\t\n 579:\t\tbus-\u003eowner = owner;\n 580:\t\tbus-\u003edev.parent = bus-\u003eparent;\n 581:\t\tbus-\u003edev.class = \u0026mdio_bus_class;\n 582:\t\tbus-\u003edev.groups = NULL;\n 583:\t\tdev_set_name(\u0026bus-\u003edev, \"%s\", bus-\u003eid);\n 584:\t\n 585:\t\t/* If the bus state is allocated, we're registering a fresh bus\n 586:\t\t * that may have a fwnode associated with it. Grab a reference\n 587:\t\t * to the fwnode. This will be dropped when the bus is released.\n 588:\t\t * If the bus was set to unregistered, it means that the bus was\n 589:\t\t * previously registered, and we've already grabbed a reference.\n 590:\t\t */\n 591:\t\tif (bus-\u003estate == MDIOBUS_ALLOCATED)\n 592:\t\t\tfwnode_handle_get(dev_fwnode(\u0026bus-\u003edev));\n 593:\t\n 594:\t\t/* We need to set state to MDIOBUS_UNREGISTERED to correctly release\n 595:\t\t * the device in mdiobus_free()\n 596:\t\t *\n 597:\t\t * State will be updated later in this function in case of success\n 598:\t\t */\n 599:\t\tbus-\u003estate = MDIOBUS_UNREGISTERED;\n 600:\t\n 601:\t\terr = device_register(\u0026bus-\u003edev);\n 602:\t\tif (err) {\n 603:\t\t\tpr_err(\"mii_bus %s failed to register\\n\", bus-\u003eid);\n 604:\t\t\treturn -EINVAL;\n 605:\t\t}\n 606:\t\n 607:\t\tmutex_init(\u0026bus-\u003emdio_lock);\n 608:\t\tmutex_init(\u0026bus-\u003eshared_lock);\n 609:\t\n 610:\t\t/* assert bus level PHY GPIO reset */\n 611:\t\tgpiod = devm_gpiod_get_optional(\u0026bus-\u003edev, \"reset\", GPIOD_OUT_HIGH);\n 612:\t\tif (IS_ERR(gpiod)) {\n 613:\t\t\terr = dev_err_probe(\u0026bus-\u003edev, PTR_ERR(gpiod),\n 614:\t\t\t\t\t \"mii_bus %s couldn't get reset GPIO\\n\",\n 615:\t\t\t\t\t bus-\u003eid);\n 616:\t\t\tdevice_del(\u0026bus-\u003edev);\n 617:\t\t\treturn err;\n 618:\t\t} else\tif (gpiod) {\n 619:\t\t\tbus-\u003ereset_gpiod = gpiod;\n"
} |
| 27/2 | 2026/10/18 02:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 73473 output: 42 thoughts: 16 Thoughts: Okay, here's my summary, presented as a stream of thought: **Diving into `__mdiobus_register`** Alright, let's get down to brass tacks. I'm focusing in on the `__mdiobus_register` function, seeing what's coming up next in this sequence. I'm an expert in this, so I know where we need to focus, I'm following it through step by step. I'm keen to dissect the control flow here, understand the interactions, and identify any potential gotchas or optimizations. What are the dependencies, and what are the crucial data structures it's interacting with at this point? This function is key. I'm ready. |
| 28/2 | 2026/10/18 02:51 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/mdio_bus_provider.c",
"FirstLine": 620,
"LineCount": 60
}Results: {
"Contents": " 620:\t\t\tfsleep(bus-\u003ereset_delay_us);\n 621:\t\t\tgpiod_set_value_cansleep(gpiod, 0);\n 622:\t\t\tif (bus-\u003ereset_post_delay_us \u003e 0)\n 623:\t\t\t\tfsleep(bus-\u003ereset_post_delay_us);\n 624:\t\t}\n 625:\t\n 626:\t\tif (bus-\u003ereset) {\n 627:\t\t\terr = bus-\u003ereset(bus);\n 628:\t\t\tif (err)\n 629:\t\t\t\tgoto error_reset_gpiod;\n 630:\t\t}\n 631:\t\n 632:\t\tif (bus-\u003eread) {\n 633:\t\t\terr = mdiobus_scan_bus_c22(bus);\n 634:\t\t\tif (err)\n 635:\t\t\t\tgoto error;\n 636:\t\t}\n 637:\t\n 638:\t\tprevent_c45_scan = mdiobus_prevent_c45_scan(bus);\n 639:\t\n 640:\t\tif (!prevent_c45_scan \u0026\u0026 bus-\u003eread_c45) {\n 641:\t\t\terr = mdiobus_scan_bus_c45(bus);\n 642:\t\t\tif (err)\n 643:\t\t\t\tgoto error;\n 644:\t\t}\n 645:\t\n 646:\t\tbus-\u003estate = MDIOBUS_REGISTERED;\n 647:\t\tdev_dbg(\u0026bus-\u003edev, \"probed\\n\");\n 648:\t\treturn 0;\n 649:\t\n 650:\terror:\n 651:\t\tfor (i = 0; i \u003c PHY_MAX_ADDR; i++) {\n 652:\t\t\tmdiodev = bus-\u003emdio_map[i];\n 653:\t\t\tif (!mdiodev)\n 654:\t\t\t\tcontinue;\n 655:\t\n 656:\t\t\tmdiodev-\u003edevice_remove(mdiodev);\n 657:\t\t\tmdiodev-\u003edevice_free(mdiodev);\n 658:\t\t}\n 659:\terror_reset_gpiod:\n 660:\t\t/* Put PHYs in RESET to save power */\n 661:\t\tif (bus-\u003ereset_gpiod)\n 662:\t\t\tgpiod_set_value_cansleep(bus-\u003ereset_gpiod, 1);\n 663:\t\n 664:\t\tdevice_del(\u0026bus-\u003edev);\n 665:\t\treturn err;\n 666:\t}\n 667:\tEXPORT_SYMBOL(__mdiobus_register);\n 668:\t\n 669:\tvoid mdiobus_unregister(struct mii_bus *bus)\n 670:\t{\n 671:\t\tstruct mdio_device *mdiodev;\n 672:\t\tint i;\n 673:\t\n 674:\t\tif (WARN_ON_ONCE(bus-\u003estate != MDIOBUS_REGISTERED))\n 675:\t\t\treturn;\n 676:\t\tbus-\u003estate = MDIOBUS_UNREGISTERED;\n 677:\t\n 678:\t\tfor (i = 0; i \u003c PHY_MAX_ADDR; i++) {\n 679:\t\t\tmdiodev = bus-\u003emdio_map[i];\n"
} |
| 29/2 | 2026/10/18 02:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 74561 output: 42 thoughts: 53 Thoughts: Okay, here's my interpretation of that thought process, assuming I'm an expert in this field: **MDIO Bus Scanning: A Deep Dive** Alright, so the task at hand is definitely related to scanning the MDIO bus. My initial thought is to figure out if we're dealing with Clause 22 or Clause 45 addressing, because the function call `mdiobus_scan_bus_c22` or `mdiobus_scan_bus_c45` is our entry point into the scanning logic. The real key here is to understand *how* it's doing the scanning. I'll start with `mdiobus_scan_bus_c22` first, as that seems like a logical starting point. That function's behavior will dictate a lot of what follows, specifically regarding how it handles the different registers, potential device addresses, and error handling for the devices on the bus. Knowing Clause 22's scanning procedure will give a basic idea of what devices are present, then I can see how Clause 45 might expand on that information with its extra registers. I need to understand what's in the underlying logic. The scan process is the first step, so understanding the specifics is critical for proper operation. |
| 30/2 | 2026/10/18 02:51 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/mdio_bus_provider.c",
"FirstLine": 460,
"LineCount": 50
}Results: {
"Contents": " 460:\t{\n 461:\t\treturn mdiobus_scan(bus, addr, false);\n 462:\t}\n 463:\tEXPORT_SYMBOL(mdiobus_scan_c22);\n 464:\t\n 465:\t/**\n 466:\t * mdiobus_scan_c45 - scan one address on a bus for C45 MDIO devices.\n 467:\t * @bus: mii_bus to scan\n 468:\t * @addr: address on bus to scan\n 469:\t *\n 470:\t * This function scans one address on the MDIO bus, looking for\n 471:\t * devices which can be identified using a vendor/product ID in\n 472:\t * registers 2 and 3. Not all MDIO devices have such registers, but\n 473:\t * PHY devices typically do. Hence this function assumes anything\n 474:\t * found is a PHY, or can be treated as a PHY. Other MDIO devices,\n 475:\t * such as switches, will probably not be found during the scan.\n 476:\t */\n 477:\tstatic struct phy_device *mdiobus_scan_c45(struct mii_bus *bus, int addr)\n 478:\t{\n 479:\t\treturn mdiobus_scan(bus, addr, true);\n 480:\t}\n 481:\t\n 482:\tstatic int mdiobus_scan_bus_c22(struct mii_bus *bus)\n 483:\t{\n 484:\t\tint i;\n 485:\t\n 486:\t\tfor (i = 0; i \u003c PHY_MAX_ADDR; i++) {\n 487:\t\t\tif ((bus-\u003ephy_mask \u0026 BIT(i)) == 0) {\n 488:\t\t\t\tstruct phy_device *phydev;\n 489:\t\n 490:\t\t\t\tphydev = mdiobus_scan_c22(bus, i);\n 491:\t\t\t\tif (IS_ERR(phydev) \u0026\u0026 (PTR_ERR(phydev) != -ENODEV))\n 492:\t\t\t\t\treturn PTR_ERR(phydev);\n 493:\t\t\t}\n 494:\t\t}\n 495:\t\treturn 0;\n 496:\t}\n 497:\t\n 498:\tstatic int mdiobus_scan_bus_c45(struct mii_bus *bus)\n 499:\t{\n 500:\t\tint i;\n 501:\t\n 502:\t\tfor (i = 0; i \u003c PHY_MAX_ADDR; i++) {\n 503:\t\t\tif ((bus-\u003ephy_mask \u0026 BIT(i)) == 0) {\n 504:\t\t\t\tstruct phy_device *phydev;\n 505:\t\n 506:\t\t\t\t/* Don't scan C45 if we already have a C22 device */\n 507:\t\t\t\tif (bus-\u003emdio_map[i])\n 508:\t\t\t\t\tcontinue;\n 509:\t\n"
} |
| 31/2 | 2026/10/18 02:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 75719 output: 42 thoughts: 14 Thoughts: Okay, let's dive into this. Here's my take on understanding this `mdiobus_scan` function, given my expertise: **My Deep Dive into `mdiobus_scan`** Alright, time to get my hands dirty. I want to understand what this `mdiobus_scan` function is really all about. Based on the name, it seems pretty straightforward: it's designed to probe or discover devices on an MDIO bus. That's the core function, the starting point. I'm already anticipating the typical approach: 1. **Iterating:** It's almost guaranteed this function will iterate through a range of MDIO addresses. Probably a predefined range, perhaps specified by a configuration, or maybe even determined dynamically by probing. 2. **Probing:** At each address, the function will likely try to read some registers. These could be standard registers defined in the MDIO specification (like the PHY ID registers), or device-specific ones. It needs to read something to get a response, which tells us if there is a device present. 3. **Identification:** Based on the register values read, the function will likely try to identify the device. Perhaps it compares the values to a known database of PHY IDs or device signatures. This might require some bit manipulation and shifting, I'm already anticipating this. 4. **Device Setup:** Once a device is found, it will probably set up some necessary resources or data structures to represent the device. This might involve creating a device node, allocating memory, and adding it to an internal list or bus structure. 5. **Error Handling:** It will need to handle the scenarios where no devices are found, or where the communication fails at specific addresses. Some error codes or error messages will be required in all likeliness, so I am expecting there to be a robust error check mechanism. I'm keen to see the implementation details to confirm my assumptions and to see how efficiently it handles things. The devil's in the details, as always, so I need to understand what strategies it employs for reliability, performance, and power consumption. Let's see if it's got any clever tricks for handling potential bus contention or dynamic address allocation. I'm excited to see how this function is implemented in practice! |
| 32/2 | 2026/10/18 02:51 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/mdio_bus_provider.c",
"FirstLine": 400,
"LineCount": 60
}Results: {
"Contents": " 400:\t\n 401:\t\tif (dev-\u003eof_node || !bus-\u003edev.of_node)\n 402:\t\t\treturn;\n 403:\t\n 404:\t\tof_mdiobus_find_phy(dev, mdiodev, bus-\u003edev.of_node);\n 405:\t}\n 406:\t#endif\n 407:\t\n 408:\tstatic struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr, bool c45)\n 409:\t{\n 410:\t\tstruct phy_device *phydev = ERR_PTR(-ENODEV);\n 411:\t\tstruct fwnode_handle *fwnode;\n 412:\t\tchar node_name[16];\n 413:\t\tint err;\n 414:\t\n 415:\t\tphydev = get_phy_device(bus, addr, c45);\n 416:\t\tif (IS_ERR(phydev))\n 417:\t\t\treturn phydev;\n 418:\t\n 419:\t#if IS_ENABLED(CONFIG_OF_MDIO)\n 420:\t\t/* For DT, see if the auto-probed phy has a corresponding child\n 421:\t\t * in the bus node, and set the of_node pointer in this case.\n 422:\t\t */\n 423:\t\tof_mdiobus_link_mdiodev(bus, \u0026phydev-\u003emdio);\n 424:\t#endif\n 425:\t\n 426:\t\t/* Search for a swnode for the phy in the swnode hierarchy of the bus.\n 427:\t\t * If there is no swnode for the phy provided, just ignore it.\n 428:\t\t */\n 429:\t\tif (dev_fwnode(\u0026bus-\u003edev) \u0026\u0026 !dev_fwnode(\u0026phydev-\u003emdio.dev)) {\n 430:\t\t\tsnprintf(node_name, sizeof(node_name), \"ethernet-phy@%d\",\n 431:\t\t\t\t addr);\n 432:\t\t\tfwnode = fwnode_get_named_child_node(dev_fwnode(\u0026bus-\u003edev),\n 433:\t\t\t\t\t\t\t node_name);\n 434:\t\t\tif (fwnode)\n 435:\t\t\t\tdevice_set_node(\u0026phydev-\u003emdio.dev, fwnode);\n 436:\t\t}\n 437:\t\n 438:\t\terr = phy_device_register(phydev);\n 439:\t\tif (err) {\n 440:\t\t\tphy_device_free(phydev);\n 441:\t\t\treturn ERR_PTR(-ENODEV);\n 442:\t\t}\n 443:\t\n 444:\t\treturn phydev;\n 445:\t}\n 446:\t\n 447:\t/**\n 448:\t * mdiobus_scan_c22 - scan one address on a bus for C22 MDIO devices.\n 449:\t * @bus: mii_bus to scan\n 450:\t * @addr: address on bus to scan\n 451:\t *\n 452:\t * This function scans one address on the MDIO bus, looking for\n 453:\t * devices which can be identified using a vendor/product ID in\n 454:\t * registers 2 and 3. Not all MDIO devices have such registers, but\n 455:\t * PHY devices typically do. Hence this function assumes anything\n 456:\t * found is a PHY, or can be treated as a PHY. Other MDIO devices,\n 457:\t * such as switches, will probably not be found during the scan.\n 458:\t */\n 459:\tstruct phy_device *mdiobus_scan_c22(struct mii_bus *bus, int addr)\n"
} |
| 33/2 | 2026/10/18 02:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 77253 output: 24 thoughts: 683 Thoughts: **My Line of Reasoning**
Okay, here's what I'm seeing. In `mdiobus_scan`, the code calls `get_phy_device`, which seems to be the entry point for detecting PHY devices. This function reads MII registers `MII_PHYSID1` and `MII_PHYSID2` using the `bus->read` function. That's standard stuff. Then, crucially, `phy_device_register(phydev)` is called, which in turn calls `device_add(&phydev->mdio.dev)`. This is the important part: `device_add` triggers a driver probe on `mdio_bus_type`. Makes sense so far.
Now, let's consider a USB emulation scenario, specifically with raw-gadget or the usb-fuzzer in syzkaller. Syzkaller's ability to emulate USB devices here is the key. If syzkaller emulates a USB device that's identified as an `ax88772`, for example (like in `drivers/net/usb/asix_devices.c`), the asix driver will eventually bind and call `ax88772_init_mdio`. That function registers an mdiobus! The mdio read function (e.g., `asix_mdio_read`) will issue USB control messages to read MII registers on that emulated device. Since syzkaller controls the responses to these USB control transfers, it has complete control over what values are returned for `MII_PHYSID1` and `MII_PHYSID2`.
This is the vulnerability point. The crucial part: Syzkaller can provide arbitrary values for the PHY ID registers, and I'm guessing this might not be properly handled. Let's explore this. Even if it *returned* a specific, valid PHY ID like `PHY_ID_YT8824` (0x4f51e8b8), what happens next? What does the `yt8824_probe` function do in that situation?
I need to dig into `yt8824_probe`:
```c
static int yt8824_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
struct yt8824_shared_priv *shared_priv;
int ret;
ret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));
if (ret)
return ret;
/* Ensure other PHY probes wait for shared mutex initialization. */
phy_package_lock(phydev);
if (phy_package_probe_once(phydev)) {
ret = yt8824_phy_package_probe_once(phydev);
if (ret) {
phy_package_unlock(phydev);
return ret;
}
}
phy_package_unlock(phydev);
return 0;
}
```
Okay, the crucial part I see is `devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv))`. I need to understand what that function actually *does*. I'll need to look at its definition in `drivers/net/phy/phy_device.c` (or wherever it's defined) to fully understand the impact. That is the next logical step.
|
| 34/2 | 2026/10/18 02:51 | tool | grepper |
0mArgs:{
"Expression": "devm_of_phy_package_join"
}Results: {
"Output": "drivers/net/phy/motorcomm.c=5124=static int yt8824_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-5129-\ndrivers/net/phy/motorcomm.c:5130:\tret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));\ndrivers/net/phy/motorcomm.c-5131-\tif (ret)\n--\ndrivers/net/phy/phy_package.c=405=EXPORT_SYMBOL_GPL(devm_phy_package_join);\n--\ndrivers/net/phy/phy_package.c-407-/**\ndrivers/net/phy/phy_package.c:408: * devm_of_phy_package_join - resource managed of_phy_package_join()\ndrivers/net/phy/phy_package.c-409- * @dev: device that is registering this PHY package\n--\ndrivers/net/phy/phy_package.c-416- */\ndrivers/net/phy/phy_package.c:417:int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev,\ndrivers/net/phy/phy_package.c-418-\t\t\t size_t priv_size)\n--\ndrivers/net/phy/phy_package.c-438-}\ndrivers/net/phy/phy_package.c:439:EXPORT_SYMBOL_GPL(devm_of_phy_package_join);\ndrivers/net/phy/phy_package.c-440-\n--\ndrivers/net/phy/phylib.h=32=int devm_phy_package_join(struct device *dev, struct phy_device *phydev,\ndrivers/net/phy/phylib.h-33-\t\t\t int base_addr, size_t priv_size);\ndrivers/net/phy/phylib.h:34:int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev,\ndrivers/net/phy/phylib.h-35-\t\t\t size_t priv_size);\n--\ndrivers/net/phy/qcom/qca807x.c=694=static int qca807x_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/qcom/qca807x.c-701-\ndrivers/net/phy/qcom/qca807x.c:702:\tret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));\ndrivers/net/phy/qcom/qca807x.c-703-\tif (ret)\n--\ndrivers/net/phy/xpowers/acx00.c=195=static int acx00_ephy_init_package(struct phy_device *phydev,\n--\ndrivers/net/phy/xpowers/acx00.c-235-\ndrivers/net/phy/xpowers/acx00.c:236:\tret = devm_of_phy_package_join(dev, phydev, 0);\ndrivers/net/phy/xpowers/acx00.c-237-\tif (ret)\n"
} |
| 35/2 | 2026/10/18 02:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 79546 output: 39 thoughts: 24 Thoughts: Okay, let's dive into this. Here's my take on those lines of code, presented as if they were my own internal thought process: **Diving into `phy_package.c`** Alright, time to get my hands dirty. Let's see what's going on around line 405 in `drivers/net/phy/phy_package.c`. I know this is where they're probably handling some of the core PHY interaction, likely the more generic parts before any specific PHY has been identified or handled. I’m thinking there might be the critical initialization, probing, or device setup happening here. There may be some clock setting, interrupt configuration, or register access that's fundamental to getting *any* PHY responding. It might be where they check for the vendor and model, or initiate the PHY reset sequence. Whatever it is, I need to understand this to be sure this hardware is even communicating on the bus. Knowing how this is initialized is the bedrock to debugging any problems in higher levels of the driver, so let's start reading! |
| 36/2 | 2026/10/18 02:51 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/phy_package.c",
"FirstLine": 400,
"LineCount": 45
}Results: {
"Contents": " 400:\t\t\tdevres_free(ptr);\n 401:\t\t}\n 402:\t\n 403:\t\treturn ret;\n 404:\t}\n 405:\tEXPORT_SYMBOL_GPL(devm_phy_package_join);\n 406:\t\n 407:\t/**\n 408:\t * devm_of_phy_package_join - resource managed of_phy_package_join()\n 409:\t * @dev: device that is registering this PHY package\n 410:\t * @phydev: target phy_device struct\n 411:\t * @priv_size: if non-zero allocate this amount of bytes for private data\n 412:\t *\n 413:\t * Managed of_phy_package_join(). Shared storage fetched by this function,\n 414:\t * phy_package_leave() is automatically called on driver detach. See\n 415:\t * of_phy_package_join() for more information.\n 416:\t */\n 417:\tint devm_of_phy_package_join(struct device *dev, struct phy_device *phydev,\n 418:\t\t\t\t size_t priv_size)\n 419:\t{\n 420:\t\tstruct phy_device **ptr;\n 421:\t\tint ret;\n 422:\t\n 423:\t\tptr = devres_alloc(devm_phy_package_leave, sizeof(*ptr),\n 424:\t\t\t\t GFP_KERNEL);\n 425:\t\tif (!ptr)\n 426:\t\t\treturn -ENOMEM;\n 427:\t\n 428:\t\tret = of_phy_package_join(phydev, priv_size);\n 429:\t\n 430:\t\tif (!ret) {\n 431:\t\t\t*ptr = phydev;\n 432:\t\t\tdevres_add(dev, ptr);\n 433:\t\t} else {\n 434:\t\t\tdevres_free(ptr);\n 435:\t\t}\n 436:\t\n 437:\t\treturn ret;\n 438:\t}\n 439:\tEXPORT_SYMBOL_GPL(devm_of_phy_package_join);\n 440:\t\n 441:\tMODULE_DESCRIPTION(\"PHY package support\");\n 442:\tMODULE_LICENSE(\"GPL\");\n"
} |
| 37/2 | 2026/10/18 02:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 80450 output: 34 thoughts: 14 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary: **Analyzing `of_phy_package_join`** Alright, let's dive into this `of_phy_package_join` function. I need to understand its role within the system, its inputs, and its expected outputs. My initial thought process is to consider how it's used within the broader context of the PHY layer package handling. Is it involved in assembling packets? Deciding on routing? Is this a join operation related to the data structures used by the physical layer? I’m immediately thinking about potential bottlenecks or points of failure here. What kind of error handling is implemented? What are the implications if this function fails or returns an unexpected value? This will be crucial for robust implementation. I need to consider all the edge cases. Specifically, I need to consider whether this uses shared memory or message passing. I'll need to remember to account for potential race conditions if the implementation uses shared memory, or communication overhead if it's based on message passing. The parameters are vital, I need to examine each one to see what they mean and how they influence the behavior of the program. I'll need to figure out how it handles different types of packages. Does it work with specific packet formats, or is it designed to be flexible and handle various data payloads? I'll need to examine any data structure definitions. I'm starting to build a mental map of where this function sits in the overall data flow. My next step will be tracing how the results of this function are used. That will give me a greater understanding of how it fits into the whole system. |
| 38/2 | 2026/10/18 02:51 | tool | grepper |
0mArgs:{
"Expression": "of_phy_package_join",
"PathPrefixes": [
"drivers/net/phy/"
]
}Results: {
"Output": "drivers/net/phy/motorcomm.c=5124=static int yt8824_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-5129-\ndrivers/net/phy/motorcomm.c:5130:\tret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));\ndrivers/net/phy/motorcomm.c-5131-\tif (ret)\n--\ndrivers/net/phy/phy_package.c=276=EXPORT_SYMBOL_GPL(phy_package_join);\n--\ndrivers/net/phy/phy_package.c-278-/**\ndrivers/net/phy/phy_package.c:279: * of_phy_package_join - join a common PHY group in PHY package\ndrivers/net/phy/phy_package.c-280- * @phydev: target phy_device struct\n--\ndrivers/net/phy/phy_package.c-297- */\ndrivers/net/phy/phy_package.c:298:int of_phy_package_join(struct phy_device *phydev, size_t priv_size)\ndrivers/net/phy/phy_package.c-299-{\n--\ndrivers/net/phy/phy_package.c-332-}\ndrivers/net/phy/phy_package.c:333:EXPORT_SYMBOL_GPL(of_phy_package_join);\ndrivers/net/phy/phy_package.c-334-\n--\ndrivers/net/phy/phy_package.c=405=EXPORT_SYMBOL_GPL(devm_phy_package_join);\n--\ndrivers/net/phy/phy_package.c-407-/**\ndrivers/net/phy/phy_package.c:408: * devm_of_phy_package_join - resource managed of_phy_package_join()\ndrivers/net/phy/phy_package.c-409- * @dev: device that is registering this PHY package\n--\ndrivers/net/phy/phy_package.c-412- *\ndrivers/net/phy/phy_package.c:413: * Managed of_phy_package_join(). Shared storage fetched by this function,\ndrivers/net/phy/phy_package.c-414- * phy_package_leave() is automatically called on driver detach. See\ndrivers/net/phy/phy_package.c:415: * of_phy_package_join() for more information.\ndrivers/net/phy/phy_package.c-416- */\ndrivers/net/phy/phy_package.c:417:int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev,\ndrivers/net/phy/phy_package.c-418-\t\t\t size_t priv_size)\n--\ndrivers/net/phy/phy_package.c-427-\ndrivers/net/phy/phy_package.c:428:\tret = of_phy_package_join(phydev, priv_size);\ndrivers/net/phy/phy_package.c-429-\n--\ndrivers/net/phy/phy_package.c-438-}\ndrivers/net/phy/phy_package.c:439:EXPORT_SYMBOL_GPL(devm_of_phy_package_join);\ndrivers/net/phy/phy_package.c-440-\n--\ndrivers/net/phy/phylib.h=29=int phy_package_join(struct phy_device *phydev, int base_addr, size_t priv_size);\ndrivers/net/phy/phylib.h:30:int of_phy_package_join(struct phy_device *phydev, size_t priv_size);\ndrivers/net/phy/phylib.h-31-void phy_package_leave(struct phy_device *phydev);\ndrivers/net/phy/phylib.h=32=int devm_phy_package_join(struct device *dev, struct phy_device *phydev,\ndrivers/net/phy/phylib.h-33-\t\t\t int base_addr, size_t priv_size);\ndrivers/net/phy/phylib.h:34:int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev,\ndrivers/net/phy/phylib.h-35-\t\t\t size_t priv_size);\n--\ndrivers/net/phy/qcom/qca807x.c=694=static int qca807x_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/qcom/qca807x.c-701-\ndrivers/net/phy/qcom/qca807x.c:702:\tret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));\ndrivers/net/phy/qcom/qca807x.c-703-\tif (ret)\n--\ndrivers/net/phy/xpowers/acx00.c=195=static int acx00_ephy_init_package(struct phy_device *phydev,\n--\ndrivers/net/phy/xpowers/acx00.c-235-\ndrivers/net/phy/xpowers/acx00.c:236:\tret = devm_of_phy_package_join(dev, phydev, 0);\ndrivers/net/phy/xpowers/acx00.c-237-\tif (ret)\n"
} |
| 39/2 | 2026/10/18 02:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 82235 output: 39 thoughts: 24 Thoughts: Okay, here's my interpretation of what's going on, thinking as though I'm going through the process myself, tailored for an expert in the field: **Diving into `phy_package.c`** Alright, let's pull up that `drivers/net/phy/phy_package.c` file and zero in on around line 280. I need to get a better handle on this PHY initialization sequence, so I'm honing in on a specific spot where something interesting must be happening. I'm assuming that this section of code is important for understanding how the PHY interacts with the rest of the network stack, perhaps related to reset, autonegotiation, or even initial register writes. I'm hoping I can glean some insight into the PHY's power-up and configuration flow here. I'm especially interested in the register access patterns. Are there any unusual delays or timing constraints being handled? I'll be looking for things like mutexes, semaphores, or atomic operations. I'm already anticipating that it will involve either reading or writing certain registers to probe or control the PHY. Let's see if this particular spot offers a specific point of interest. |
| 40/2 | 2026/10/18 02:51 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/phy_package.c",
"FirstLine": 280,
"LineCount": 55
}Results: {
"Contents": " 280:\t * @phydev: target phy_device struct\n 281:\t * @priv_size: if non-zero allocate this amount of bytes for private data\n 282:\t *\n 283:\t * This is a variant of phy_package_join for PHY package defined in DT.\n 284:\t *\n 285:\t * The parent node of the @phydev is checked as a valid PHY package node\n 286:\t * structure (by matching the node name \"ethernet-phy-package\") and the\n 287:\t * base_addr for the PHY package is passed to phy_package_join.\n 288:\t *\n 289:\t * With this configuration the shared struct will also have the np value\n 290:\t * filled to use additional DT defined properties in PHY specific\n 291:\t * probe_once and config_init_once PHY package OPs.\n 292:\t *\n 293:\t * Returns \u003c 0 on error, 0 on success. Esp. calling phy_package_join()\n 294:\t * with the same cookie but a different priv_size is an error. Or a parent\n 295:\t * node is not detected or is not valid or doesn't match the expected node\n 296:\t * name for PHY package.\n 297:\t */\n 298:\tint of_phy_package_join(struct phy_device *phydev, size_t priv_size)\n 299:\t{\n 300:\t\tstruct device_node *node = phydev-\u003emdio.dev.of_node;\n 301:\t\tstruct device_node *package_node;\n 302:\t\tu32 base_addr;\n 303:\t\tint ret;\n 304:\t\n 305:\t\tif (!node)\n 306:\t\t\treturn -EINVAL;\n 307:\t\n 308:\t\tpackage_node = of_get_parent(node);\n 309:\t\tif (!package_node)\n 310:\t\t\treturn -EINVAL;\n 311:\t\n 312:\t\tif (!of_node_name_eq(package_node, \"ethernet-phy-package\")) {\n 313:\t\t\tret = -EINVAL;\n 314:\t\t\tgoto exit;\n 315:\t\t}\n 316:\t\n 317:\t\tif (of_property_read_u32(package_node, \"reg\", \u0026base_addr)) {\n 318:\t\t\tret = -EINVAL;\n 319:\t\t\tgoto exit;\n 320:\t\t}\n 321:\t\n 322:\t\tret = phy_package_join(phydev, base_addr, priv_size);\n 323:\t\tif (ret)\n 324:\t\t\tgoto exit;\n 325:\t\n 326:\t\tphydev-\u003eshared-\u003enp = package_node;\n 327:\t\n 328:\t\treturn 0;\n 329:\texit:\n 330:\t\tof_node_put(package_node);\n 331:\t\treturn ret;\n 332:\t}\n 333:\tEXPORT_SYMBOL_GPL(of_phy_package_join);\n 334:\t\n"
} |
| 41/2 | 2026/10/18 02:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 83390 output: 26 thoughts: 1108 Thoughts: **Analyzing the Motorcomm YT8824 PHY Driver Patch** Okay, let's break this down. First, I see the code for `of_phy_package_join`, and immediately it's clear: if there's no Device Tree (`phydev->mdio.dev.of_node` is NULL, which is the default for most non-DT systems), `devm_of_phy_package_join` just returns `-EINVAL`. This is a hard error. And the `yt8824_probe` function is just calling that, so it immediately fails. So, the whole driver is dead on arrival without proper DT setup. All those other `yt8824_*` functions? Forget about it; they're never getting called because `probe` fails at the gate. Then my mind jumps: Device Tree on amd64? Nope, standard amd64 uses ACPI, not DT. And the YT8824 is a *physical* PHY chip, not something abstract like a virtual device, or something with a driver that could work with ConfigFS or OF overlays. My brain instantly goes to the function calls in `of_phy_package_join`, like `of_get_parent` and `of_node_name_eq` -- ACPI doesn't have those, and there's no way this function is going to work without a device tree. The code is specifically dependent on `phydev->mdio.dev.of_node`! Now, I need to widen the scope. What *else* changed in this patch? I'm checking the surrounding files: Documentation, Kconfig, the core driver, phy-c45, and headers. I'm noting the addition of `genphy_c45_template_testmode` and the new MDIO macros in the UAPI header. Is this feature even used? So, I start digging into `genphy_c45_template_testmode`. It looks like it's only called within `motorcomm.c` itself. Nowhere else in the kernel. Interesting. Okay, is it even possible to call `genphy_c45_template_testmode` from userspace, like through `ethtool` or netlink? I don't see anything. I've searched the kernel. No dice. |
| 42/2 | 2026/10/18 02:51 | tool | grepper |
0mArgs:{
"Expression": "MDIO_PMA_10GBT_TESTMODE"
}Results: {
"Output": "drivers/net/phy/motorcomm.c=1106=static int yt8824_restore_working_status(struct phy_device *phydev, int ret)\n--\ndrivers/net/phy/motorcomm.c-1111-\tr = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:1112:\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\ndrivers/net/phy/motorcomm.c-1113-\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n--\ndrivers/net/phy/motorcomm.c=1130=static int yt8824_soft_reset(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-1137-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:1138:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-1139-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-1146-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:1147:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\ndrivers/net/phy/motorcomm.c-1148-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-1151-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:1152:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-1153-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-1164-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:1165:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\ndrivers/net/phy/motorcomm.c-1166-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c=1188=static int yt8824_config_utp_init_paged(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-1688-\t/* reset */\ndrivers/net/phy/motorcomm.c:1689:\tret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-1690-\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-1702-\tret = genphy_c45_template_testmode(phydev,\ndrivers/net/phy/motorcomm.c:1703:\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\ndrivers/net/phy/motorcomm.c-1704-\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-1715-\tr = genphy_c45_template_testmode(phydev,\ndrivers/net/phy/motorcomm.c:1716:\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\ndrivers/net/phy/motorcomm.c-1717-\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n--\ndrivers/net/phy/motorcomm.c=4864=static int yt8824_power_on(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-4871-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:4872:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-4873-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-4880-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:4881:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\ndrivers/net/phy/motorcomm.c-4882-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-4885-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:4886:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-4887-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-4898-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:4899:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\ndrivers/net/phy/motorcomm.c-4900-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c=4947=static int yt8824_power_down(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-4954-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:4955:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-4956-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-4963-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:4964:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\ndrivers/net/phy/motorcomm.c-4965-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-4968-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:4969:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-4970-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-4981-\t\tret = yt8824_utp_set_template_test_mode(phydev,\ndrivers/net/phy/motorcomm.c:4982:\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\ndrivers/net/phy/motorcomm.c-4983-\t\tif (ret \u003c 0)\n--\ndrivers/net/phy/phy-c45.c=1421=int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)\n--\ndrivers/net/phy/phy-c45.c-1424-\ndrivers/net/phy/phy-c45.c:1425:\tif (test_mode \u003e MDIO_PMA_10GBT_TESTMODE_7)\ndrivers/net/phy/phy-c45.c-1426-\t\treturn -EOPNOTSUPP;\ndrivers/net/phy/phy-c45.c-1427-\ndrivers/net/phy/phy-c45.c:1428:\tctrl = FIELD_PREP(MDIO_PMA_10GBT_TESTMODE_MASK, test_mode);\ndrivers/net/phy/phy-c45.c:1429:\treturn phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,\ndrivers/net/phy/phy-c45.c:1430:\t\t\t MDIO_PMA_10GBT_TESTMODE_MASK, ctrl);\ndrivers/net/phy/phy-c45.c-1431-}\n--\ninclude/uapi/linux/mdio.h-65-#define MDIO_PMA_10GBT_TXPWR\t131\t/* 10GBASE-T TX power control */\ninclude/uapi/linux/mdio.h:66:#define MDIO_PMA_10GBT_TESTMODE 132 /* Test mode control */\ninclude/uapi/linux/mdio.h-67-#define MDIO_PMA_10GBT_SNR\t133\t/* 10GBASE-T SNR margin, lane A.\n--\ninclude/uapi/linux/mdio.h-324-/* PMA 10GBASE-T Template Test Mode Register*/\ninclude/uapi/linux/mdio.h:325:#define MDIO_PMA_10GBT_TESTMODE_MASK GENMASK(15, 13) /* Template test mode */\ninclude/uapi/linux/mdio.h:326:#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0 /* Template Normal */\ninclude/uapi/linux/mdio.h:327:#define MDIO_PMA_10GBT_TESTMODE_1 0x1 /* Template TestMode1 */\ninclude/uapi/linux/mdio.h:328:#define MDIO_PMA_10GBT_TESTMODE_2 0x2 /* Template TestMode2 */\ninclude/uapi/linux/mdio.h:329:#define MDIO_PMA_10GBT_TESTMODE_3 0x3 /* Template TestMode3 */\ninclude/uapi/linux/mdio.h:330:#define MDIO_PMA_10GBT_TESTMODE_4 0x4 /* Template TestMode4 */\ninclude/uapi/linux/mdio.h:331:#define MDIO_PMA_10GBT_TESTMODE_5 0x5 /* Template TestMode5 */\ninclude/uapi/linux/mdio.h:332:#define MDIO_PMA_10GBT_TESTMODE_6 0x6 /* Template TestMode6 */\ninclude/uapi/linux/mdio.h:333:#define MDIO_PMA_10GBT_TESTMODE_7 0x7 /* Template TestMode7 */\ninclude/uapi/linux/mdio.h-334-\n"
} |
| 43/2 | 2026/10/18 02:51 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 87734 output: 38 thoughts: 807 Thoughts: **Analyzing the Scope of `genphy_c45_template_testmode` and Potential Environment Compatibility** Okay, here's what I'm thinking. That `genphy_c45_template_testmode` helper function... I see it's specifically for setting template test mode, and it's *only* used within the yt8824 functions in `motorcomm.c`. That's a key observation. Now, the important question I need to answer: can the code touched by this patch, especially `motorcomm.c` and any modified functions, execute correctly in standard virtualized environments? Think GCE, QEMU, the usual suspects with software-emulated devices like USB gadgets, netdev, or tun/tap on amd64 architecture. Let's break this down. First, I need to understand what's changed in `drivers/net/phy/motorcomm.c`. Alright, looking at the diff, it includes several new `#include` directives: `<linux/mdio.h>`, `<linux/of.h>`, `<linux/of_net.h>`, and `"phylib.h"`. There are also YT8824-specific registers and definitions, a `yt8824_shared_priv` struct, and some new functions: `ytphy_read_top_ext`, `ytphy_write_top_ext`, and `phy8824_page_write_with_lock`. Wait a minute, what's this? I see a modification to `ytphy_set_wol`! Let me just quickly confirm if that function was changed. YES! Okay, let's look at the actual diff for `ytphy_set_wol`. Okay, the crucial part is the addition of the error handling: ```c + if (ret < 0) + goto err_restore_page; + } + +err_restore_page: + return phy_restore_page(phydev, old_page, ret); ``` This diff has added error checking and page restoration in case of an error within the function. Let me check the context, particularly lines 930 to 970 in `drivers/net/phy/motorcomm.c`, to fully understand its impact. We need to verify if these added error handlers, specifically the `phy_restore_page` call, are compatible with virtualized environments where MDIO access may be emulated or behave differently. |
| 44/2 | 2026/10/18 02:51 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/motorcomm.c",
"FirstLine": 930,
"LineCount": 40
}Results: {
"Contents": " 930:\t\t\tmask = YTPHY_WCR_PULSE_WIDTH_MASK | YTPHY_WCR_INTR_SEL;\n 931:\t\t\tval = YTPHY_WCR_ENABLE | YTPHY_WCR_INTR_SEL;\n 932:\t\t\tval |= YTPHY_WCR_TYPE_PULSE | YTPHY_WCR_PULSE_WIDTH_672MS;\n 933:\t\t\tret = ytphy_modify_ext(phydev, YTPHY_WOL_CONFIG_REG, mask, val);\n 934:\t\t\tif (ret \u003c 0)\n 935:\t\t\t\tgoto err_restore_page;\n 936:\t\n 937:\t\t\t/* Enable WOL interrupt */\n 938:\t\t\tret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG, 0,\n 939:\t\t\t\t\t YTPHY_IER_WOL);\n 940:\t\t\tif (ret \u003c 0)\n 941:\t\t\t\tgoto err_restore_page;\n 942:\t\n 943:\t\t} else {\n 944:\t\t\told_page = phy_select_page(phydev, YT8521_RSSR_UTP_SPACE);\n 945:\t\t\tif (old_page \u003c 0)\n 946:\t\t\t\tgoto err_restore_page;\n 947:\t\n 948:\t\t\t/* Disable WOL feature */\n 949:\t\t\tmask = YTPHY_WCR_ENABLE | YTPHY_WCR_INTR_SEL;\n 950:\t\t\tret = ytphy_modify_ext(phydev, YTPHY_WOL_CONFIG_REG, mask, 0);\n 951:\t\n 952:\t\t\t/* Disable WOL interrupt */\n 953:\t\t\tret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,\n 954:\t\t\t\t\t YTPHY_IER_WOL, 0);\n 955:\t\t\tif (ret \u003c 0)\n 956:\t\t\t\tgoto err_restore_page;\n 957:\t\t}\n 958:\t\n 959:\terr_restore_page:\n 960:\t\treturn phy_restore_page(phydev, old_page, ret);\n 961:\t}\n 962:\t\n 963:\t/**\n 964:\t * yt8824_read_page() - read PHY8824 reg page\n 965:\t * @phydev: a pointer to a \u0026struct phy_device\n 966:\t *\n 967:\t * Returns: current reg space of yt8824 (YT8824_RSSR_SERDES_SPACE/\n 968:\t * YT8824_RSSR_UTP_SPACE) or negative errno code\n 969:\t */\n"
} |
| 45/2 | 2026/10/18 02:51 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 89853 output: 37 thoughts: 5943 Thoughts: **Summary of Patch Analysis** Alright, let's break this down. I'm looking at a patch that seems to be related to Motorcomm PHY drivers, specifically the YT8824. My initial thought was: what changed in `ytphy_set_wol`? It looked like some extra `if (ret < 0) goto err_restore_page;` was added. But, wait, that `goto` is totally redundant! The code was already going to `err_restore_page` regardless. A no-op. But the question is: can any of this code even *run* in a standard QEMU/syzkaller environment? That's the key. I need to figure out if these Motorcomm PHY drivers are reachable in a fuzzable environment. My investigation led me down the rabbit hole of MDIO buses, USB devices, and device tree (OF). I started by wondering if syzkaller can emulate a USB device like `asix`. The code seemed to suggest a path where an `asix` device can create an MDIO bus and probe for PHYs. Then, if the USB device exposes a Motorcomm PHY ID, it would be possible to get to the Motorcomm drivers. However, the more I dug, the more I realized this wasn't going to work. For the `yt8824` driver to probe, it relies on Device Tree (OF) information, and specifically `devm_of_phy_package_join()`. The problem is that amd64 (the target architecture) in QEMU does *not* use Device Tree. Instead, it uses ACPI. I started to read the triage guidelines carefully to see if any of the changes were in scope for fuzzing. Based on the guidelines, this is *structurally unreachable hardware* in QEMU: The Motorcomm YT8824 is a dedicated multi-port Ethernet PHY ASIC for embedded switch hardware that does not have Device Tree on amd64. Therefore, it's not possible to instantiate in QEMU. Even if `CONFIG_OF` were enabled for x86_64, `of_root` is `NULL`. So, the added code in `ytphy_set_wol` or anywhere else in this patch for YT8824 is unreachable in the target QEMU environment. The Kconfig, documentation, and header file changes don't affect the compiled image either, so they are out of scope. Therefore, this patch is *WorthFuzzing=false*. |
| 46/2 | 2026/10/18 02:53 | tool | grepper |
0mArgs:{
"Expression": "ytphy_set_wol",
"PathPrefixes": [
"drivers/net/phy/motorcomm.c"
]
}Results: {
"Output": "drivers/net/phy/motorcomm.c=864=static void ytphy_get_wol(struct phy_device *phydev,\n--\ndrivers/net/phy/motorcomm.c-880-/**\ndrivers/net/phy/motorcomm.c:881: * ytphy_set_wol() - turn wake-on-lan on or off\ndrivers/net/phy/motorcomm.c-882- * @phydev: a pointer to a \u0026struct phy_device\n--\ndrivers/net/phy/motorcomm.c-890- */\ndrivers/net/phy/motorcomm.c:891:static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)\ndrivers/net/phy/motorcomm.c-892-{\n--\ndrivers/net/phy/motorcomm.c=5148=static struct phy_driver motorcomm_phy_drvs[] = {\n--\ndrivers/net/phy/motorcomm.c-5165-\t\t.get_wol\t= ytphy_get_wol,\ndrivers/net/phy/motorcomm.c:5166:\t\t.set_wol\t= ytphy_set_wol,\ndrivers/net/phy/motorcomm.c-5167-\t\t.config_aneg\t= yt8521_config_aneg,\n--\ndrivers/net/phy/motorcomm.c-5207-\t\t.get_wol\t= ytphy_get_wol,\ndrivers/net/phy/motorcomm.c:5208:\t\t.set_wol\t= ytphy_set_wol,\ndrivers/net/phy/motorcomm.c-5209-\t\t.config_aneg\t= yt8521_config_aneg,\n--\ndrivers/net/phy/motorcomm.c-5234-\t\t.get_wol\t\t= ytphy_get_wol,\ndrivers/net/phy/motorcomm.c:5235:\t\t.set_wol\t\t= ytphy_set_wol,\ndrivers/net/phy/motorcomm.c-5236-\t\t.config_aneg\t\t= genphy_config_aneg,\n"
} |
| 47/2 | 2026/10/18 02:53 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 96910 output: 196 thoughts: 795 Thoughts: **Analysis of the Patch: Not Worth Fuzzing** Okay, let's break this down. My understanding is that `ytphy_set_wol` is specifically for Motorcomm PHYs: YT8521, YT8531, and YT8821. It doesn't even touch YT8824. And, importantly, *all* Motorcomm PHYs, including the YT8824, require physical Motorcomm hardware or a YT921x switch. Now, the question is, can we even *reach* this code in a standard QEMU environment on amd64? Let's go through it: 1. **Target Architecture:** amd64. 2. **Virtual Environment:** Standard QEMU or GCE. 3. **The Deal Breaker:** In these environments, there are *no* physical Motorcomm PHYs emulated. There are no Motorcomm switches, and QEMU doesn't emulate Motorcomm MDIO PHYs. End of story, right there. 4. **YT8824 Specifics:** The YT8824 requires Device Tree bindings (`motorcomm,yt8824-package`) and, within `yt8824_probe`, `devm_of_phy_package_join()` depends on a valid DT node. That’s another hurdle - if we don't have that DT node, it will fail. 5. **Testmode Helper:** This new `genphy_c45_template_testmode()` function in `phy-c45.c` is only called by the YT8824 functions, so it’s directly linked to the physical hardware requirement. 6. **Redundant Code in `ytphy_set_wol()`:** The redundant conditional jump to `err_restore_page` within `ytphy_set_wol()` is essentially a no-op, since it just jumps to the next label. And that function is inside the Motorcomm driver which is *unreachable*. Let's double-check against Section 2: This falls squarely under the "Structurally unreachable hardware" category, alongside things like vendor-specific PCIe switches and SmartNICs. Motorcomm Ethernet PHY drivers, like `motorcomm.c`, are vendor-specific and need actual hardware, which QEMU doesn't offer. **Therefore, it is structurally unreachable on amd64.** The code introduced by this patch is reliant on specific physical hardware components that aren't present in the standard QEMU/GCE environment, and even if we somehow got it to compile, the flow to set up those conditions is impossible. That useless change to `ytphy_set_wol()` in the specific driver is redundant, so it's not even worth considering. **Verdict: Not Worth Fuzzing.** The reasoning is sound. I'm confident in calling this now. Ready to `set-results`. |
| 48/2 | 2026/10/18 02:53 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The patch adds driver support for the Motorcomm YT8824 quad-port Ethernet PHY in drivers/net/phy/motorcomm.c and adds a C45 template testmode helper function in drivers/net/phy/phy-c45.c (which is only referenced by the YT8824 driver). The YT8824 driver requires physical Motorcomm hardware and Device Tree configuration (via devm_of_phy_package_join), neither of which exists or is emulated in standard QEMU/GCE virtualized environments on amd64. The change in ytphy_set_wol is a control-flow no-op jumping to the immediately adjacent label in the same unreachable driver. Therefore, the modified code is structurally unreachable and not worth fuzzing.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch adds driver support for the Motorcomm YT8824 quad-port Ethernet PHY in drivers/net/phy/motorcomm.c and adds a C45 template testmode helper function in drivers/net/phy/phy-c45.c (which is only referenced by the YT8824 driver). The YT8824 driver requires physical Motorcomm hardware and Device Tree configuration (via devm_of_phy_package_join), neither of which exists or is emulated in standard QEMU/GCE virtualized environments on amd64. The change in ytphy_set_wol is a control-flow no-op jumping to the immediately adjacent label in the same unreachable driver. Therefore, the modified code is structurally unreachable and not worth fuzzing.",
"WorthFuzzing": false
} |
| 49/1 | 2026/10/18 02:53 | 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) |
|---|