| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/09/19 12:29 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "The patch series adds support for the Motorcomm YT8824 Ethernet PHY in drivers/net/phy/motorcomm.c, along with an export helper genphy_c45_template_testmode() in drivers/net/phy/phy-c45.c that is exclusively called by the YT8824 driver. Motorcomm Ethernet PHY chips are physical hardware devices attached via MDIO and configured via DeviceTree, which are not emulated in standard virtualized environments (QEMU/GCE). Consequently, the modified code paths are structurally unreachable and do not warrant fuzzing.",
"WorthFuzzing": false
} |
| 1/1 | 2026/09/19 12:29 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 7a9ae17e4ee405de7888846c8d67c973188ab846\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sat Sep 19 12:29:17 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..9737364744a07\n--- /dev/null\n+++ b/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml\n@@ -0,0 +1,62 @@\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+ phy-mode:\n+ $ref: /schemas/types.yaml#/definitions/string\n+ enum: [ internal, usxgmii ]\n+\n+required:\n+ - compatible\n+ - phy-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@0 {\n+ #address-cells = \u003c1\u003e;\n+ #size-cells = \u003c0\u003e;\n+ compatible = \"motorcomm,yt8824-package\";\n+ reg = \u003c9\u003e;\n+\n+ phy-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/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig\nindex d3835597e3795..996d75afed446 100644\n--- a/drivers/net/phy/Kconfig\n+++ b/drivers/net/phy/Kconfig\n@@ -361,9 +361,10 @@ 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.\n+\t Currently supports YT85xx Gigabit Ethernet PHYs and YT8824 4 * 2.5G PHY.\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 90a4f86f2758b..7ab09666ab3f4 100644\n--- a/drivers/net/phy/motorcomm.c\n+++ b/drivers/net/phy/motorcomm.c\n@@ -1,24 +1,31 @@\n // SPDX-License-Identifier: GPL-2.0+\n /*\n- * Motorcomm 8511/8521/8522/8531/8531S/8821 PHY driver.\n+ * Motorcomm 8511/8521/8522/8531/8531S/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/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 #define PHY_ID_YT8531\t\t0x4f51e91b\n #define PHY_ID_YT8531S\t\t0x4f51e91a\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@@ -30,6 +37,18 @@\n * ------------------------------------------------------------\n */\n \n+/* YT8824 Register Overview\n+ * UTP Register space | USXGMII Register space\n+ * ------------------------------------------------------------\n+ * | UTP MII\t\t| USXGMII MII\t\t|\n+ * | UTP MMD\t\t|\t\t\t|\n+ * | UTP Extended\t| USXGMII Extended\t|\n+ * | UTP Top Extended\t| USXGMII 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@@ -381,6 +400,13 @@\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_USXGMII_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 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@@ -399,6 +425,12 @@ struct yt8521_priv {\n \tu8 reg_page;\n };\n \n+struct yt8824_shared_priv {\n+\tphy_interface_t interface_mode;\n+\t/* shared_lock used to UTPs operation isolation during swap reg space */\n+\tstruct mutex shared_lock;\n+};\n+\n /**\n * ytphy_read_ext() - read a PHY's extended register\n * @phydev: a pointer to a \u0026struct phy_device\n@@ -437,6 +469,78 @@ 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+\t/*\n+\t * The package base address is used here to read the top ext registers.\n+\t * For example, in internal mode, the top ext address is fixed at 9;\n+\t * for usxgmii, the offset is 4. Instead of using the offset approach\n+\t * a fixed address is used here to avoid situations such as when phy0\n+\t * is not in use, where the top ext register address cannot be obtained\n+\t * correctly.\n+\t */\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_USXGMII_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@@ -622,15 +726,1045 @@ 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_USXGMII_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_USXGMII_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_USXGMII_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+\t/* restore page, release the lock */\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_USXGMII_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+\t/* restore page, release the lock */\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+\t/* configure normal test mode */\n+\tr = yt8824_utp_set_template_test_mode\n+\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\tif (priv-\u003einterface_mode != PHY_INTERFACE_MODE_INTERNAL) {\n+\t\t/* sds soft reset and disable isolation */\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-\u003einterface_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\t/* test mode 1 */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t\tret = yt8824_utp_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t} else {\n+\t\t/* test mode 1 */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* sds isolation */\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* utp soft reset */\n+\t\tret = yt8824_utp_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* sds soft reset and disable isolation */\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_extern_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_extern_config_utp_init_paged(struct phy_device *phydev)\n+{\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+\t/* power down */\n+\tret = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* pll calibration */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0001, 0x0003);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa20e, 0x0cba);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa20a, 0xc3f1);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa20c, 0x1620);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0x0a00);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0x0e00);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimization utp */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0001, 0x0003);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* enable nibble */\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa003, 0x0003);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* idle err detect enable */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x03d0, 0x5210);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 2.5G long cable performance */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0372, 0x5038);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x037c, 0x6068);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0388, 0x00a0);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized fast retrain */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0359, 0x2140);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x000c, 0xc1a0);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* 2.5G template tone */\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2fa, 0x0083);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x04e2, 0x0149);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 2.5G template */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x047e, 0x3939);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x047f, 0x3939);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0480, 0x3939);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0481, 0x3939);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 1000M cable length threshold */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0336, 0xab0a);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0340, 0x301d);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* 100M template amplitude */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x046e, 0x4545);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x046f, 0x4545);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0470, 0x4545);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0471, 0x4545);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 100M cable length threshold */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x030b, 0xaa1d);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x071f, 0x0036);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* 10M template amplitude */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x046b, 0x1818);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x046c, 0x1818);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 10M cable length threshold */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0466, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0467, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0468, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0469, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimize utp 1000M performance */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x034a, 0xff03);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x00f8, 0xb3ff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0059, 0x4040);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x032c, 0x5094);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x032d, 0xd094);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x032e, 0x5308);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0322, 0x6440);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x04d3, 0x5220);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x04d2, 0x5220);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized EMC CS */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x00c8, 0xffff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x00be, 0x6406);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x037a, 0x40ff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized EMC RE */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0482, 0xffff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d5, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d6, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d7, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d8, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa218, 0x006e);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xfff0);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xfff0);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xffff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xffff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_normal;\n+\t/* reset */\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_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 ret = -1;\n+\tint val;\n+\n+\told_page = phy_select_page(phydev, YT8824_RSSR_USXGMII_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, 0xa13e);\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, 0xa13f);\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, 0xa140);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\telse\n+\t\tval_3 = ret;\n+\n+\t/* Serdes optimization */\n+\tret = ytphy_write_ext(phydev, 0x04be, 0x000d);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x049f, 0x7ded);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x04a9, 0x009f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* analog CDR */\n+\tret = ytphy_write_ext(phydev, 0x0406, 0x0800);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized VCO */\n+\tret = ytphy_write_ext(phydev, 0x0438, 0x9024);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x0439, 0x00c0);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized PLL lock */\n+\tret = ytphy_read_ext(phydev, 0x0429);\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, 0x0429, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_read_ext(phydev, 0x0441);\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, 0x0441, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_read_ext(phydev, 0x042b);\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, 0x042b, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x043a, 0x1006);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x042a, 0xf070);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* cable length threshold */\n+\tret = ytphy_write_ext(phydev, 0x0491, 0x007f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x0492, 0x7f7f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* Serdes training threshold */\n+\tret = ytphy_write_ext(phydev, 0x0454, 0x0f14);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x0497, 0x0a44);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* digital eye diagram of SerDes */\n+\tret = ytphy_write_ext(phydev, 0x04cd, 0x0000);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* Serdes LDO */\n+\tret = ytphy_read_ext(phydev, 0x04b5);\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, 0x04b5, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_read_ext(phydev, 0x04b4);\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, 0x04b4, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized Serdes RX */\n+\tret = ytphy_write_ext(phydev, 0x04af, 0x45e3);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x048a, 0x0fff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x0408, 0x7c00);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x04d6, 0x007f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x044f, 0xff08);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized Serdes TX */\n+\tret = ytphy_write_ext(phydev, 0x048e, 0x7d00);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x000d, 0x0606);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* Serdes manual config */\n+\tret = ytphy_write_ext(phydev, 0x04b0, 0x0804);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x04b1, 0x7074);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x04af, 0x45e7);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* restart calibration */\n+\tret = ytphy_write_ext(phydev, 0x0003, 0x5603);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x0492, 0x7fff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x0492, 0x7f7f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x2000, 0x0040);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, 0x2000, 0x0000);\n+\tif (ret \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+\t/* reset serdes */\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+err_restore_page:\n+\t/* restore page, release the lock */\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_internal_config_init_paged() - config internal phy8824 init\n+ * @phydev: target phy_device struct\n+ *\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_internal_config_init_paged(struct phy_device *phydev)\n+{\n+\tint ret = 0;\n+\tint val = 0;\n+\tint r = 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+\tret = ytphy_write_ext_with_lock(phydev, 0x1, 0x3);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* power down */\n+\tret = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa20e, 0xcba);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa20a, 0xc3f1);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa20c, 0x1620);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0xa00);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0xe00);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa003, 0x3);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x3d0, 0x5210);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x372, 0x5038);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x37c, 0x6068);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x388, 0xa0);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x359, 0x2140);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2fa, 0x83);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x4e2, 0x149);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* 2.5G tempate */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x47e, 0x3939);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x47f, 0x3939);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x480, 0x3939);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x481, 0x3939);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* 1000 cable length threshold */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x336, 0xab0a);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x340, 0x301d);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* 1000 performance */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x34a, 0xff03);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xf8, 0xb3ff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x32c, 0x5094);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x32d, 0xd094);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x32e, 0x5308);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x322, 0x6440);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x4d3, 0x5220);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x4d2, 0x5220);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* 100 tempate */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x46e, 0x4545);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x46f, 0x4545);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x470, 0x4545);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x471, 0x4545);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* 100 cable length threshold */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x30b, 0xaa1d);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x71f, 0x36);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* 10 tempate */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x46b, 0x1818);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x46c, 0x1818);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* 10 tempate MAU*/\n+\tret = ytphy_write_ext_with_lock(phydev, 0x466, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x467, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x468, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x469, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* EMC CS, Inconsistent with external phy */\n+\tret = ytphy_write_ext_with_lock(phydev, 0xc8, 0xfff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xbe, 0x6406);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x37a, 0x40ff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* EMC RE*/\n+\tret = ytphy_write_ext_with_lock(phydev, 0x482, 0xffff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d5, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d6, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d7, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d8, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa218, 0x6e);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xfff0);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xfff0);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xffff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xffff);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xc, 0x41a1);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\tret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);\n+\tif (ret)\n+\t\tgoto err_restore_normal;\n+\t/* reset */\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+\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_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-\u003einterface_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tret = yt8824_internal_config_init_paged(phydev);\n \t\tif (ret \u003c 0)\n-\t\t\tgoto err_restore_page;\n+\t\t\tgoto err;\n+\t} else {\n+\t\tret = yt8824_extern_config_sds_init_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err;\n+\t\tret = yt8824_extern_config_utp_init_paged(phydev);\n+\t\tif (ret \u003c 0)\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@@ -3104,6 +4238,426 @@ 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 link = 0;\n+\tint ret = 0;\n+\tint val = 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+\tret = genphy_read_status(phydev);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tif (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+\tret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tval = ret;\n+\n+\tlink = val \u0026 YTPHY_SSR_LINK;\n+\tif (link)\n+\t\tyt8821_adjust_status(phydev, val);\n+\n+\tif (link) {\n+\t\tif (phydev-\u003elink == 0)\n+\t\t\tphydev_dbg(phydev, \"%s, phy addr: %d, link up\\n\",\n+\t\t\t\t __func__, phydev-\u003emdio.addr);\n+\t\tphydev-\u003elink = 1;\n+\t} else {\n+\t\tif (phydev-\u003elink == 1)\n+\t\t\tphydev_dbg(phydev, \"%s, phy addr: %d, link down\\n\",\n+\t\t\t\t __func__, phydev-\u003emdio.addr);\n+\t\tphydev-\u003elink = 0;\n+\t}\n+\tphy_resolve_aneg_pause(phydev);\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-\u003einterface_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\t/* test mode 1 */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t\t/* utp power on */\n+\t\tret = yt8824_utp_power_on(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t} else {\n+\t\t/* test mode 1 */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* sds isolation */\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* utp power on */\n+\t\tret = yt8824_utp_power_on(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* sds soft reset and disable isolation */\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-\u003einterface_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\t/* test mode 1 */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t\t/* utp power down */\n+\t\tret = yt8824_utp_power_down(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t} else {\n+\t\t/* test mode 1 */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* sds isolation */\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* utp power down */\n+\t\tret = yt8824_utp_power_down(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_set_template_test_mode\n+\t\t\t(phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\t/* sds soft reset and disable isolation */\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+\tif (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+ * 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+\tint res;\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+\tres = of_get_phy_mode(np, \u0026priv-\u003einterface_mode);\n+\tif (res \u003c 0) {\n+\t\tphydev_warn(phydev, \"%s, phy-mode missing in DTS.\\n\", __func__);\n+\t\treturn res;\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+\tif (phy_package_probe_once(phydev)) {\n+\t\tret = yt8824_phy_package_probe_once(phydev);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\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@@ -3190,13 +4744,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/8821 PHY driver\");\n+MODULE_DESCRIPTION(\"Motorcomm 8511/8521/8531/8531S/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@@ -3206,6 +4776,7 @@ static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {\n \t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531) },\n \t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) },\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 3d8afe6b7f1c5..2db804b8fd4df 100644\n--- a/include/linux/phy.h\n+++ b/include/linux/phy.h\n@@ -2357,6 +2357,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/09/19 12:29 | agent | patch-evaluator |
1mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch series adds support for the Motorcomm YT8824 Ethernet PHY in drivers/net/phy/motorcomm.c, along with an export helper genphy_c45_template_testmode() in drivers/net/phy/phy-c45.c that is exclusively called by the YT8824 driver. Motorcomm Ethernet PHY chips are physical hardware devices attached via MDIO and configured via DeviceTree, which are not emulated in standard virtualized environments (QEMU/GCE). Consequently, the modified code paths are structurally unreachable and do not warrant 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 7a9ae17e4ee405de7888846c8d67c973188ab846
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Sep 19 12:29:17 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..9737364744a07
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml
@@ -0,0 +1,62 @@
+# 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
+ phy-mode:
+ $ref: /schemas/types.yaml#/definitions/string
+ enum: [ internal, usxgmii ]
+
+required:
+ - compatible
+ - phy-mode
+ - reg
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ mdio {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ethernet-phy-package@0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "motorcomm,yt8824-package";
+ reg = <9>;
+
+ phy-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/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index d3835597e3795..996d75afed446 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -361,9 +361,10 @@ 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.
+ Currently supports YT85xx Gigabit Ethernet PHYs and YT8824 4 * 2.5G PHY.
config NATIONAL_PHY
tristate "National Semiconductor PHYs"
diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
index 90a4f86f2758b..7ab09666ab3f4 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -1,24 +1,31 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Motorcomm 8511/8521/8522/8531/8531S/8821 PHY driver.
+ * Motorcomm 8511/8521/8522/8531/8531S/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/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
#define PHY_ID_YT8531 0x4f51e91b
#define PHY_ID_YT8531S 0x4f51e91a
#define PHY_ID_YT8821 0x4f51ea19
+#define PHY_ID_YT8824 0x4f51e8b8
/* YT8521/YT8531S/YT8821 Register Overview
* UTP Register space | FIBER Register space
* ------------------------------------------------------------
@@ -30,6 +37,18 @@
* ------------------------------------------------------------
*/
+/* YT8824 Register Overview
+ * UTP Register space | USXGMII Register space
+ * ------------------------------------------------------------
+ * | UTP MII | USXGMII MII |
+ * | UTP MMD | |
+ * | UTP Extended | USXGMII Extended |
+ * | UTP Top Extended | USXGMII Top Extended |
+ * ------------------------------------------------------------
+ * | Common Top Extended |
+ * ------------------------------------------------------------
+ */
+
/* 0x10 ~ 0x15 , 0x1E and 0x1F are common MII registers of yt phy */
/* Specific Function Control Register */
@@ -381,6 +400,13 @@
#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_USXGMII_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)
+
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
@@ -399,6 +425,12 @@ struct yt8521_priv {
u8 reg_page;
};
+struct yt8824_shared_priv {
+ phy_interface_t interface_mode;
+ /* shared_lock used to UTPs operation isolation during swap reg space */
+ struct mutex shared_lock;
+};
+
/**
* ytphy_read_ext() - read a PHY's extended register
* @phydev: a pointer to a &struct phy_device
@@ -437,6 +469,78 @@ 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;
+
+ /*
+ * The package base address is used here to read the top ext registers.
+ * For example, in internal mode, the top ext address is fixed at 9;
+ * for usxgmii, the offset is 4. Instead of using the offset approach
+ * a fixed address is used here to avoid situations such as when phy0
+ * is not in use, where the top ext register address cannot be obtained
+ * correctly.
+ */
+ 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_USXGMII_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
@@ -622,15 +726,1045 @@ 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_USXGMII_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_USXGMII_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_USXGMII_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:
+ /* restore page, release the lock */
+ 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_USXGMII_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:
+ /* restore page, release the lock */
+ 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;
+
+ /* configure normal test mode */
+ r = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret >= 0 && r < 0)
+ ret = r;
+ if (priv->interface_mode != PHY_INTERFACE_MODE_INTERNAL) {
+ /* sds soft reset and disable isolation */
+ 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->interface_mode == PHY_INTERFACE_MODE_INTERNAL) {
+ /* test mode 1 */
+ 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;
+ /* normal mode */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+ } else {
+ /* test mode 1 */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+
+ /* sds isolation */
+ ret = yt8824_sds_isolate_paged(phydev);
+ if (ret < 0)
+ goto retry;
+
+ /* utp soft reset */
+ ret = yt8824_utp_softreset_paged(phydev);
+ if (ret < 0)
+ goto retry;
+
+ /* normal mode */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+
+ /* sds soft reset and disable isolation */
+ 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_extern_config_utp_init_paged() - config external phy8824 utp init
+ * @phydev: target phy_device struct
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_extern_config_utp_init_paged(struct phy_device *phydev)
+{
+ int ret = 0;
+ int val = 0;
+ int r;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+ /* power down */
+ ret = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);
+ if (ret < 0)
+ goto err_restore;
+
+ /* pll calibration */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0001, 0x0003);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20e, 0x0cba);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20a, 0xc3f1);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20c, 0x1620);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0x0a00);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0x0e00);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimization utp */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0001, 0x0003);
+ if (ret < 0)
+ goto err_restore;
+
+ /* enable nibble */
+ ret = ytphy_write_ext_with_lock(phydev, 0xa003, 0x0003);
+ if (ret < 0)
+ goto err_restore;
+
+ /* idle err detect enable */
+ ret = ytphy_write_ext_with_lock(phydev, 0x03d0, 0x5210);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized 2.5G long cable performance */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0372, 0x5038);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x037c, 0x6068);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0388, 0x00a0);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized fast retrain */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0359, 0x2140);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x000c, 0xc1a0);
+ if (ret < 0)
+ goto err_restore;
+
+ /* 2.5G template tone */
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2fa, 0x0083);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x04e2, 0x0149);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized 2.5G template */
+ ret = ytphy_write_ext_with_lock(phydev, 0x047e, 0x3939);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x047f, 0x3939);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0480, 0x3939);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0481, 0x3939);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized 1000M cable length threshold */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0336, 0xab0a);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0340, 0x301d);
+ if (ret < 0)
+ goto err_restore;
+
+ /* 100M template amplitude */
+ ret = ytphy_write_ext_with_lock(phydev, 0x046e, 0x4545);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x046f, 0x4545);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0470, 0x4545);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0471, 0x4545);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized 100M cable length threshold */
+ ret = ytphy_write_ext_with_lock(phydev, 0x030b, 0xaa1d);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x071f, 0x0036);
+ if (ret < 0)
+ goto err_restore;
+
+ /* 10M template amplitude */
+ ret = ytphy_write_ext_with_lock(phydev, 0x046b, 0x1818);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x046c, 0x1818);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized 10M cable length threshold */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0466, 0x6c6c);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0467, 0x6c6c);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0468, 0x6c6c);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0469, 0x6c6c);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimize utp 1000M performance */
+ ret = ytphy_write_ext_with_lock(phydev, 0x034a, 0xff03);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x00f8, 0xb3ff);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0059, 0x4040);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x032c, 0x5094);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x032d, 0xd094);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x032e, 0x5308);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0322, 0x6440);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x04d3, 0x5220);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x04d2, 0x5220);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized EMC CS */
+ ret = ytphy_write_ext_with_lock(phydev, 0x00c8, 0xffff);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x00be, 0x6406);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x037a, 0x40ff);
+ if (ret < 0)
+ goto err_restore;
+
+ /* optimized EMC RE */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0482, 0xffff);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d5, 0x1f1f);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d6, 0x1f1f);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d7, 0x1f1f);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d8, 0x1f1f);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa218, 0x006e);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xfff0);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xfff0);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xffff);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xffff);
+ if (ret < 0)
+ goto err_restore;
+
+ ret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto err_restore_normal;
+ /* reset */
+ 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_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 ret = -1;
+ int val;
+
+ old_page = phy_select_page(phydev, YT8824_RSSR_USXGMII_SPACE);
+ if (old_page < 0)
+ goto err_restore_page;
+
+ /* read efuse */
+ ret = ytphy_read_top_ext(phydev, 0xa13e);
+ if (ret < 0)
+ goto err_restore_page;
+ else
+ val_1 = ret;
+
+ ret = ytphy_read_top_ext(phydev, 0xa13f);
+ if (ret < 0)
+ goto err_restore_page;
+ else
+ val_2 = ret;
+
+ ret = ytphy_read_top_ext(phydev, 0xa140);
+ if (ret < 0)
+ goto err_restore_page;
+ else
+ val_3 = ret;
+
+ /* Serdes optimization */
+ ret = ytphy_write_ext(phydev, 0x04be, 0x000d);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x049f, 0x7ded);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x04a9, 0x009f);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* analog CDR */
+ ret = ytphy_write_ext(phydev, 0x0406, 0x0800);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* optimized VCO */
+ ret = ytphy_write_ext(phydev, 0x0438, 0x9024);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x0439, 0x00c0);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* optimized PLL lock */
+ ret = ytphy_read_ext(phydev, 0x0429);
+ 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, 0x0429, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_read_ext(phydev, 0x0441);
+ 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, 0x0441, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_read_ext(phydev, 0x042b);
+ 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, 0x042b, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x043a, 0x1006);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x042a, 0xf070);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* cable length threshold */
+ ret = ytphy_write_ext(phydev, 0x0491, 0x007f);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x0492, 0x7f7f);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* Serdes training threshold */
+ ret = ytphy_write_ext(phydev, 0x0454, 0x0f14);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x0497, 0x0a44);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* digital eye diagram of SerDes */
+ ret = ytphy_write_ext(phydev, 0x04cd, 0x0000);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* Serdes LDO */
+ ret = ytphy_read_ext(phydev, 0x04b5);
+ 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, 0x04b5, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_read_ext(phydev, 0x04b4);
+ 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, 0x04b4, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* optimized Serdes RX */
+ ret = ytphy_write_ext(phydev, 0x04af, 0x45e3);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x048a, 0x0fff);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x0408, 0x7c00);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x04d6, 0x007f);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x044f, 0xff08);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* optimized Serdes TX */
+ ret = ytphy_write_ext(phydev, 0x048e, 0x7d00);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x000d, 0x0606);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* Serdes manual config */
+ ret = ytphy_write_ext(phydev, 0x04b0, 0x0804);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x04b1, 0x7074);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x04af, 0x45e7);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* restart calibration */
+ ret = ytphy_write_ext(phydev, 0x0003, 0x5603);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x0492, 0x7fff);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x0492, 0x7f7f);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x2000, 0x0040);
+ if (ret < 0)
+ goto err_restore_page;
+
+ ret = ytphy_write_ext(phydev, 0x2000, 0x0000);
+ if (ret < 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;
+ /* reset serdes */
+ 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:
+ /* restore page, release the lock */
+ return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_internal_config_init_paged() - config internal phy8824 init
+ * @phydev: target phy_device struct
+ *
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_internal_config_init_paged(struct phy_device *phydev)
+{
+ int ret = 0;
+ int val = 0;
+ int r = 0;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x1, 0x3);
+ if (ret < 0)
+ return ret;
+ /* power down */
+ ret = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20e, 0xcba);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20a, 0xc3f1);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20c, 0x1620);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0xa00);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0xe00);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa003, 0x3);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x3d0, 0x5210);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x372, 0x5038);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x37c, 0x6068);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x388, 0xa0);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x359, 0x2140);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2fa, 0x83);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x4e2, 0x149);
+ if (ret < 0)
+ goto err_restore;
+ /* 2.5G tempate */
+ ret = ytphy_write_ext_with_lock(phydev, 0x47e, 0x3939);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x47f, 0x3939);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x480, 0x3939);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x481, 0x3939);
+ if (ret < 0)
+ goto err_restore;
+ /* 1000 cable length threshold */
+ ret = ytphy_write_ext_with_lock(phydev, 0x336, 0xab0a);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x340, 0x301d);
+ if (ret < 0)
+ goto err_restore;
+ /* 1000 performance */
+ ret = ytphy_write_ext_with_lock(phydev, 0x34a, 0xff03);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xf8, 0xb3ff);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x32c, 0x5094);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x32d, 0xd094);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x32e, 0x5308);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x322, 0x6440);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x4d3, 0x5220);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x4d2, 0x5220);
+ if (ret < 0)
+ goto err_restore;
+ /* 100 tempate */
+ ret = ytphy_write_ext_with_lock(phydev, 0x46e, 0x4545);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x46f, 0x4545);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x470, 0x4545);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x471, 0x4545);
+ if (ret < 0)
+ goto err_restore;
+ /* 100 cable length threshold */
+ ret = ytphy_write_ext_with_lock(phydev, 0x30b, 0xaa1d);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x71f, 0x36);
+ if (ret < 0)
+ goto err_restore;
+ /* 10 tempate */
+ ret = ytphy_write_ext_with_lock(phydev, 0x46b, 0x1818);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x46c, 0x1818);
+ if (ret < 0)
+ goto err_restore;
+ /* 10 tempate MAU*/
+ ret = ytphy_write_ext_with_lock(phydev, 0x466, 0x6c6c);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x467, 0x6c6c);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x468, 0x6c6c);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x469, 0x6c6c);
+ if (ret < 0)
+ goto err_restore;
+ /* EMC CS, Inconsistent with external phy */
+ ret = ytphy_write_ext_with_lock(phydev, 0xc8, 0xfff);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xbe, 0x6406);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0x37a, 0x40ff);
+ if (ret < 0)
+ goto err_restore;
+ /* EMC RE*/
+ ret = ytphy_write_ext_with_lock(phydev, 0x482, 0xffff);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d5, 0x1f1f);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d6, 0x1f1f);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d7, 0x1f1f);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d8, 0x1f1f);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa218, 0x6e);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xfff0);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xfff0);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xffff);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xffff);
+ if (ret < 0)
+ goto err_restore;
+ ret = ytphy_write_ext_with_lock(phydev, 0xc, 0x41a1);
+ if (ret < 0)
+ goto err_restore;
+ ret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret)
+ goto err_restore_normal;
+ /* reset */
+ 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_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->interface_mode == PHY_INTERFACE_MODE_INTERNAL) {
+ ret = yt8824_internal_config_init_paged(phydev);
if (ret < 0)
- goto err_restore_page;
+ goto err;
+ } else {
+ ret = yt8824_extern_config_sds_init_paged(phydev);
+ if (ret < 0)
+ goto err;
+ ret = yt8824_extern_config_utp_init_paged(phydev);
+ if (ret < 0)
+ 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,
@@ -3104,6 +4238,426 @@ 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 link = 0;
+ int ret = 0;
+ int val = 0;
+
+ 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_complete) {
+ ret = genphy_c45_read_lpa(phydev);
+ if (ret < 0)
+ return ret;
+ }
+
+ ret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);
+ if (ret < 0)
+ return ret;
+
+ val = ret;
+
+ link = val & YTPHY_SSR_LINK;
+ if (link)
+ yt8821_adjust_status(phydev, val);
+
+ if (link) {
+ if (phydev->link == 0)
+ phydev_dbg(phydev, "%s, phy addr: %d, link up\n",
+ __func__, phydev->mdio.addr);
+ phydev->link = 1;
+ } else {
+ if (phydev->link == 1)
+ phydev_dbg(phydev, "%s, phy addr: %d, link down\n",
+ __func__, phydev->mdio.addr);
+ phydev->link = 0;
+ }
+ 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->interface_mode == PHY_INTERFACE_MODE_INTERNAL) {
+ /* test mode 1 */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+ /* utp power on */
+ ret = yt8824_utp_power_on(phydev);
+ if (ret < 0)
+ goto retry;
+ /* normal mode */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+ } else {
+ /* test mode 1 */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+
+ /* sds isolation */
+ ret = yt8824_sds_isolate_paged(phydev);
+ if (ret < 0)
+ goto retry;
+
+ /* utp power on */
+ ret = yt8824_utp_power_on(phydev);
+ if (ret < 0)
+ goto retry;
+
+ /* normal mode */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+
+ /* sds soft reset and disable isolation */
+ 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->interface_mode == PHY_INTERFACE_MODE_INTERNAL) {
+ /* test mode 1 */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+ /* utp power down */
+ ret = yt8824_utp_power_down(phydev);
+ if (ret < 0)
+ goto retry;
+ /* normal mode */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+ } else {
+ /* test mode 1 */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_1);
+ if (ret < 0)
+ goto retry;
+
+ /* sds isolation */
+ ret = yt8824_sds_isolate_paged(phydev);
+ if (ret < 0)
+ goto retry;
+
+ /* utp power down */
+ ret = yt8824_utp_power_down(phydev);
+ if (ret < 0)
+ goto retry;
+
+ /* normal mode */
+ ret = yt8824_utp_set_template_test_mode
+ (phydev, MDIO_PMA_10GBT_TESTMODE_NORMAL);
+ if (ret < 0)
+ goto retry;
+
+ /* sds soft reset and disable isolation */
+ 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;
+
+ if (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;
+}
+
+/**
+ * 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);
+ int res;
+
+ 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);
+ res = of_get_phy_mode(np, &priv->interface_mode);
+ if (res < 0) {
+ phydev_warn(phydev, "%s, phy-mode missing in DTS.\n", __func__);
+ return res;
+ }
+
+ 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;
+
+ if (phy_package_probe_once(phydev)) {
+ ret = yt8824_phy_package_probe_once(phydev);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static struct phy_driver motorcomm_phy_drvs[] = {
{
PHY_ID_MATCH_EXACT(PHY_ID_YT8511),
@@ -3190,13 +4744,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/8821 PHY driver");
+MODULE_DESCRIPTION("Motorcomm 8511/8521/8531/8531S/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[] = {
@@ -3206,6 +4776,7 @@ static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531) },
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) },
{ 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 3d8afe6b7f1c5..2db804b8fd4df 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2357,6 +2357,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/09/19 12:29 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26078 output: 25 thoughts: 806 Thoughts: **Analyzing the Patch for Fuzzing Potential** Okay, so the question is whether this patch series is a good candidate for syzkaller fuzzing, targeting an amd64 architecture. I need to figure out the attack surface. First, let's break down what's being introduced here. We have devicetree bindings documentation for the Motorcomm YT8824 PHY, which is a PHY package of four PHYs. There's a new `MOTORCOMM_PHY` config option that selects `PHY_PACKAGE`. The core driver implementation in `drivers/net/phy/motorcomm.c` adds a substantial number of new functions specific to the YT8824. I see a lot of functions related to reading, writing, configuration, and control of this PHY chip, including functions handling "paged" access, soft resets, and power management. Then there's some change in `drivers/net/phy/phy-c45.c`, specifically the addition of `genphy_c45_template_testmode()` and the corresponding prototype in `include/linux/phy.h` with related defines added to `include/uapi/linux/mdio.h`. Now, the critical question is reachability. Can I trigger the code in a standard virtualized environment like QEMU or GCE? The Motorcomm YT8824 is an MDIO Ethernet PHY. These are typically connected to a network interface card (NIC) or a System-on-a-Chip (SoC) MAC through an MDIO bus. Can syzkaller even probe and interact with MDIO PHYs directly? Can a standard virtualized environment emulate or expose the YT8824, or the MDIO bus to begin with? I need to know how the driver gets instantiated and if it's possible at all in a virtualized context. This makes me question that new `genphy_c45_template_testmode` function. Who's calling it? Is it also reachable? I need to check the call sites to see if they offer a possible fuzzing entry point. |
| 4/2 | 2026/09/19 12:29 | tool | grepper |
0mArgs:{
"Expression": "genphy_c45_template_testmode"
}Results: {
"Output": "drivers/net/phy/motorcomm.c=786=static int yt8824_utp_set_template_test_mode(struct phy_device *phydev,\n--\ndrivers/net/phy/motorcomm.c-794-\ndrivers/net/phy/motorcomm.c:795:\treturn genphy_c45_template_testmode(phydev, test_mode);\ndrivers/net/phy/motorcomm.c-796-}\n--\ndrivers/net/phy/motorcomm.c=974=static int yt8824_extern_config_utp_init_paged(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-1227-\ndrivers/net/phy/motorcomm.c:1228:\tret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-1229-\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-1240-\ndrivers/net/phy/motorcomm.c:1241:\tret = genphy_c45_template_testmode(phydev,\ndrivers/net/phy/motorcomm.c-1242-\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\n--\ndrivers/net/phy/motorcomm.c-1253-err_restore_normal:\ndrivers/net/phy/motorcomm.c:1254:\tr = genphy_c45_template_testmode(phydev,\ndrivers/net/phy/motorcomm.c-1255-\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\n--\ndrivers/net/phy/motorcomm.c=1513=static int yt8824_internal_config_init_paged(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-1697-\t\tgoto err_restore;\ndrivers/net/phy/motorcomm.c:1698:\tret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-1699-\tif (ret)\n--\ndrivers/net/phy/motorcomm.c-1710-\ndrivers/net/phy/motorcomm.c:1711:\tret = genphy_c45_template_testmode(phydev,\ndrivers/net/phy/motorcomm.c-1712-\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\n--\ndrivers/net/phy/motorcomm.c-1724-err_restore_normal:\ndrivers/net/phy/motorcomm.c:1725:\tr = genphy_c45_template_testmode(phydev,\ndrivers/net/phy/motorcomm.c-1726-\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=2359=int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable);\ninclude/linux/phy.h:2360:int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode);\ninclude/linux/phy.h-2361-int genphy_c45_plca_get_cfg(struct phy_device *phydev,\n"
} |
| 5/2 | 2026/09/19 12:29 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28546 output: 28 thoughts: 246 Thoughts: **My Investigation into Motorcomm PHY Testing** Okay, so `genphy_c45_template_testmode` is *only* called from `motorcomm.c` – that's a key starting point. Now, I need to understand the connection between Ethernet PHY devices and this `motorcomm.c` file. How are these PHYs probed and bound within the system? Let's look at instantiation and probing of `motorcomm.c`. Aha, `yt8824_probe` is called by phylib, and it is called when a phy_device with PHY ID `PHY_ID_YT8824` (0x4f51e8b8) is discovered on an MDIO bus. Interesting... The next question: does QEMU or any other virtualization environment emulate the Motorcomm YT8824 PHY? If it doesn't, that will make testing tricky. Looking at the standard QEMU emulated devices (Intel e1000, rtl8139, virtio-net, etc.), none of them emulate a Motorcomm YT8824 quad-PHY package. Okay, then how can I test this in a virtual environment? Is there any virtual MDIO bus or software-emulated PHY available? I should check if an MDIO bus can be created from userspace, or if there's a mock netdev or something similar. Time to grep for `mdio`, `phy_device_create`, and `phy_driver_register` to explore further. |
| 6/2 | 2026/09/19 12:29 | tool | grepper |
0mArgs:{
"Expression": "mdio_bus",
"PathPrefix": "drivers/net/"
}Results: {
"Output": "\nFull output is too long, showing 500 out of 2213 lines.\nUse more precise expression if possible.\n\ndrivers/net/dsa/microchip/ksz9477.c=321=static int ksz9477_pcs_create(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz9477.c-332-\ndrivers/net/dsa/microchip/ksz9477.c:333:\tbus-\u003ename = \"ksz_pcs_mdio_bus\";\ndrivers/net/dsa/microchip/ksz9477.c-334-\tsnprintf(bus-\u003eid, MII_BUS_ID_SIZE, \"%s-pcs\",\n--\ndrivers/net/dsa/microchip/ksz_common.c=2160=int ksz_parent_mdio_read(struct mii_bus *bus, int addr, int regnum)\n--\ndrivers/net/dsa/microchip/ksz_common.c-2163-\ndrivers/net/dsa/microchip/ksz_common.c:2164:\treturn mdiobus_read_nested(dev-\u003eparent_mdio_bus, addr, regnum);\ndrivers/net/dsa/microchip/ksz_common.c-2165-}\n--\ndrivers/net/dsa/microchip/ksz_common.c=2180=int ksz_parent_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val)\n--\ndrivers/net/dsa/microchip/ksz_common.c-2183-\ndrivers/net/dsa/microchip/ksz_common.c:2184:\treturn mdiobus_write_nested(dev-\u003eparent_mdio_bus, addr, regnum, val);\ndrivers/net/dsa/microchip/ksz_common.c-2185-}\n--\ndrivers/net/dsa/microchip/ksz_common.c=2356=int ksz_mdio_register(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz_common.c-2382-\ndrivers/net/dsa/microchip/ksz_common.c:2383:\t\tdev-\u003eparent_mdio_bus = parent_bus;\ndrivers/net/dsa/microchip/ksz_common.c-2384-\t}\n--\ndrivers/net/dsa/microchip/ksz_common.h=206=struct ksz_device {\n--\ndrivers/net/dsa/microchip/ksz_common.h-258-\t/**\ndrivers/net/dsa/microchip/ksz_common.h:259:\t * @parent_mdio_bus: Pointer to the external MDIO bus controller.\ndrivers/net/dsa/microchip/ksz_common.h-260-\t *\n--\ndrivers/net/dsa/microchip/ksz_common.h-265-\t */\ndrivers/net/dsa/microchip/ksz_common.h:266:\tstruct mii_bus *parent_mdio_bus;\ndrivers/net/dsa/microchip/ksz_common.h-267-\n--\ndrivers/net/dsa/microchip/lan937x_main.c=143=static int lan937x_create_phy_addr_map(struct ksz_device *dev, bool side_mdio)\n--\ndrivers/net/dsa/microchip/lan937x_main.c-210-/**\ndrivers/net/dsa/microchip/lan937x_main.c:211: * lan937x_mdio_bus_preinit - Pre-initialize MDIO bus for accessing PHYs.\ndrivers/net/dsa/microchip/lan937x_main.c-212- * @dev: Pointer to device structure.\n--\ndrivers/net/dsa/microchip/lan937x_main.c-226- */\ndrivers/net/dsa/microchip/lan937x_main.c:227:static int lan937x_mdio_bus_preinit(struct ksz_device *dev, bool side_mdio)\ndrivers/net/dsa/microchip/lan937x_main.c-228-{\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-711-\ndrivers/net/dsa/microchip/lan937x_main.c:712:\t\tdev-\u003eparent_mdio_bus = parent_bus;\ndrivers/net/dsa/microchip/lan937x_main.c-713-\t}\n--\ndrivers/net/dsa/microchip/lan937x_main.c-720-\ndrivers/net/dsa/microchip/lan937x_main.c:721:\tret = lan937x_mdio_bus_preinit(dev, !!parent_bus);\ndrivers/net/dsa/microchip/lan937x_main.c-722-\tif (ret)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=126=int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-132-\ndrivers/net/dsa/mv88e6xxx/chip.c:133:struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)\ndrivers/net/dsa/mv88e6xxx/chip.c-134-{\ndrivers/net/dsa/mv88e6xxx/chip.c:135:\tstruct mv88e6xxx_mdio_bus *mdio_bus;\ndrivers/net/dsa/mv88e6xxx/chip.c-136-\ndrivers/net/dsa/mv88e6xxx/chip.c:137:\tmdio_bus = list_first_entry_or_null(\u0026chip-\u003emdios,\ndrivers/net/dsa/mv88e6xxx/chip.c:138:\t\t\t\t\t struct mv88e6xxx_mdio_bus, list);\ndrivers/net/dsa/mv88e6xxx/chip.c:139:\tif (!mdio_bus)\ndrivers/net/dsa/mv88e6xxx/chip.c-140-\t\treturn NULL;\ndrivers/net/dsa/mv88e6xxx/chip.c-141-\ndrivers/net/dsa/mv88e6xxx/chip.c:142:\treturn mdio_bus-\u003ebus;\ndrivers/net/dsa/mv88e6xxx/chip.c-143-}\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3765=static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)\ndrivers/net/dsa/mv88e6xxx/chip.c-3766-{\ndrivers/net/dsa/mv88e6xxx/chip.c:3767:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/chip.c:3768:\tstruct mv88e6xxx_chip *chip = mdio_bus-\u003echip;\ndrivers/net/dsa/mv88e6xxx/chip.c-3769-\tu16 prod_id;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3791=static int mv88e6xxx_mdio_read_c45(struct mii_bus *bus, int phy, int devad,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3793-{\ndrivers/net/dsa/mv88e6xxx/chip.c:3794:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/chip.c:3795:\tstruct mv88e6xxx_chip *chip = mdio_bus-\u003echip;\ndrivers/net/dsa/mv88e6xxx/chip.c-3796-\tu16 val;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3809=static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)\ndrivers/net/dsa/mv88e6xxx/chip.c-3810-{\ndrivers/net/dsa/mv88e6xxx/chip.c:3811:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/chip.c:3812:\tstruct mv88e6xxx_chip *chip = mdio_bus-\u003echip;\ndrivers/net/dsa/mv88e6xxx/chip.c-3813-\tint err;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3825=static int mv88e6xxx_mdio_write_c45(struct mii_bus *bus, int phy, int devad,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3827-{\ndrivers/net/dsa/mv88e6xxx/chip.c:3828:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/chip.c:3829:\tstruct mv88e6xxx_chip *chip = mdio_bus-\u003echip;\ndrivers/net/dsa/mv88e6xxx/chip.c-3830-\tint err;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3842=static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3846-\tstatic int index;\ndrivers/net/dsa/mv88e6xxx/chip.c:3847:\tstruct mv88e6xxx_mdio_bus *mdio_bus;\ndrivers/net/dsa/mv88e6xxx/chip.c-3848-\tstruct mii_bus *bus;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3862-\ndrivers/net/dsa/mv88e6xxx/chip.c:3863:\tbus = mdiobus_alloc_size(sizeof(*mdio_bus));\ndrivers/net/dsa/mv88e6xxx/chip.c-3864-\tif (!bus)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3866-\ndrivers/net/dsa/mv88e6xxx/chip.c:3867:\tmdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/chip.c:3868:\tmdio_bus-\u003ebus = bus;\ndrivers/net/dsa/mv88e6xxx/chip.c:3869:\tmdio_bus-\u003echip = chip;\ndrivers/net/dsa/mv88e6xxx/chip.c:3870:\tINIT_LIST_HEAD(\u0026mdio_bus-\u003elist);\ndrivers/net/dsa/mv88e6xxx/chip.c:3871:\tmdio_bus-\u003eexternal = external;\ndrivers/net/dsa/mv88e6xxx/chip.c-3872-\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3903-\tif (external)\ndrivers/net/dsa/mv88e6xxx/chip.c:3904:\t\tlist_add_tail(\u0026mdio_bus-\u003elist, \u0026chip-\u003emdios);\ndrivers/net/dsa/mv88e6xxx/chip.c-3905-\telse\ndrivers/net/dsa/mv88e6xxx/chip.c:3906:\t\tlist_add(\u0026mdio_bus-\u003elist, \u0026chip-\u003emdios);\ndrivers/net/dsa/mv88e6xxx/chip.c-3907-\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3915=static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3917-{\ndrivers/net/dsa/mv88e6xxx/chip.c:3918:\tstruct mv88e6xxx_mdio_bus *mdio_bus, *p;\ndrivers/net/dsa/mv88e6xxx/chip.c-3919-\tstruct mii_bus *bus;\ndrivers/net/dsa/mv88e6xxx/chip.c-3920-\ndrivers/net/dsa/mv88e6xxx/chip.c:3921:\tlist_for_each_entry_safe(mdio_bus, p, \u0026chip-\u003emdios, list) {\ndrivers/net/dsa/mv88e6xxx/chip.c:3922:\t\tbus = mdio_bus-\u003ebus;\ndrivers/net/dsa/mv88e6xxx/chip.c-3923-\ndrivers/net/dsa/mv88e6xxx/chip.c:3924:\t\tif (!mdio_bus-\u003eexternal)\ndrivers/net/dsa/mv88e6xxx/chip.c-3925-\t\t\tmv88e6xxx_g2_irq_mdio_free(chip, bus);\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3988=static int mv88e6xxx_setup(struct dsa_switch *ds)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3999-\tchip-\u003eds = ds;\ndrivers/net/dsa/mv88e6xxx/chip.c:4000:\tds-\u003euser_mii_bus = mv88e6xxx_default_mdio_bus(chip);\ndrivers/net/dsa/mv88e6xxx/chip.c-4001-\n--\ndrivers/net/dsa/mv88e6xxx/chip.h=488=struct mv88e6xxx_bus_ops {\n--\ndrivers/net/dsa/mv88e6xxx/chip.h-493-\ndrivers/net/dsa/mv88e6xxx/chip.h:494:struct mv88e6xxx_mdio_bus {\ndrivers/net/dsa/mv88e6xxx/chip.h-495-\tstruct mii_bus *bus;\n--\ndrivers/net/dsa/mv88e6xxx/chip.h=873=int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,\ndrivers/net/dsa/mv88e6xxx/chip.h-874-\t\t int bit, int val);\ndrivers/net/dsa/mv88e6xxx/chip.h:875:struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip);\ndrivers/net/dsa/mv88e6xxx/chip.h-876-\n--\ndrivers/net/dsa/mv88e6xxx/global2.c=787=int mv88e6xxx_g2_smi_phy_read_c22(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/global2.c-790-{\ndrivers/net/dsa/mv88e6xxx/global2.c:791:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/global2.c:792:\tbool external = mdio_bus-\u003eexternal;\ndrivers/net/dsa/mv88e6xxx/global2.c-793-\n--\ndrivers/net/dsa/mv88e6xxx/global2.c=798=int mv88e6xxx_g2_smi_phy_read_c45(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/global2.c-801-{\ndrivers/net/dsa/mv88e6xxx/global2.c:802:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/global2.c:803:\tbool external = mdio_bus-\u003eexternal;\ndrivers/net/dsa/mv88e6xxx/global2.c-804-\n--\ndrivers/net/dsa/mv88e6xxx/global2.c=809=int mv88e6xxx_g2_smi_phy_write_c22(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/global2.c-812-{\ndrivers/net/dsa/mv88e6xxx/global2.c:813:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/global2.c:814:\tbool external = mdio_bus-\u003eexternal;\ndrivers/net/dsa/mv88e6xxx/global2.c-815-\n--\ndrivers/net/dsa/mv88e6xxx/global2.c=820=int mv88e6xxx_g2_smi_phy_write_c45(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/global2.c-823-{\ndrivers/net/dsa/mv88e6xxx/global2.c:824:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/global2.c:825:\tbool external = mdio_bus-\u003eexternal;\ndrivers/net/dsa/mv88e6xxx/global2.c-826-\n--\ndrivers/net/dsa/mv88e6xxx/pcs-6352.c=324=static int mv88e6352_pcs_init(struct mv88e6xxx_chip *chip, int port)\n--\ndrivers/net/dsa/mv88e6xxx/pcs-6352.c-336-\tirq = mv88e6xxx_serdes_irq_mapping(chip, port);\ndrivers/net/dsa/mv88e6xxx/pcs-6352.c:337:\tbus = mv88e6xxx_default_mdio_bus(chip);\ndrivers/net/dsa/mv88e6xxx/pcs-6352.c-338-\tdev = chip-\u003edev;\n--\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c=549=static int mv88e6390_pcs_init(struct mv88e6xxx_chip *chip, int port)\n--\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c-559-\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c:560:\tbus = mv88e6xxx_default_mdio_bus(chip);\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c-561-\tdev = chip-\u003edev;\n--\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c=927=static int mv88e6393x_pcs_init(struct mv88e6xxx_chip *chip, int port)\n--\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c-937-\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c:938:\tbus = mv88e6xxx_default_mdio_bus(chip);\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c-939-\tdev = chip-\u003edev;\n--\ndrivers/net/dsa/mv88e6xxx/phy.c=28=int mv88e6xxx_phy_read(struct mv88e6xxx_chip *chip, int phy, int reg, u16 *val)\n--\ndrivers/net/dsa/mv88e6xxx/phy.c-32-\ndrivers/net/dsa/mv88e6xxx/phy.c:33:\tbus = mv88e6xxx_default_mdio_bus(chip);\ndrivers/net/dsa/mv88e6xxx/phy.c-34-\tif (!bus)\n--\ndrivers/net/dsa/mv88e6xxx/phy.c=43=int mv88e6xxx_phy_write(struct mv88e6xxx_chip *chip, int phy, int reg, u16 val)\n--\ndrivers/net/dsa/mv88e6xxx/phy.c-47-\ndrivers/net/dsa/mv88e6xxx/phy.c:48:\tbus = mv88e6xxx_default_mdio_bus(chip);\ndrivers/net/dsa/mv88e6xxx/phy.c-49-\tif (!bus)\n--\ndrivers/net/dsa/mv88e6xxx/phy.c=58=int mv88e6xxx_phy_read_c45(struct mv88e6xxx_chip *chip, int phy, int devad,\n--\ndrivers/net/dsa/mv88e6xxx/phy.c-63-\ndrivers/net/dsa/mv88e6xxx/phy.c:64:\tbus = mv88e6xxx_default_mdio_bus(chip);\ndrivers/net/dsa/mv88e6xxx/phy.c-65-\tif (!bus)\n--\ndrivers/net/dsa/mv88e6xxx/phy.c=74=int mv88e6xxx_phy_write_c45(struct mv88e6xxx_chip *chip, int phy, int devad,\n--\ndrivers/net/dsa/mv88e6xxx/phy.c-79-\ndrivers/net/dsa/mv88e6xxx/phy.c:80:\tbus = mv88e6xxx_default_mdio_bus(chip);\ndrivers/net/dsa/mv88e6xxx/phy.c-81-\tif (!bus)\n--\ndrivers/net/dsa/netc/netc_main.c=133=static int netc_port_get_info_from_dt(struct netc_port *np,\n--\ndrivers/net/dsa/netc/netc_main.c-148-\ndrivers/net/dsa/netc/netc_main.c:149:static int netc_port_create_emdio_bus(struct netc_port *np,\ndrivers/net/dsa/netc/netc_main.c-150-\t\t\t\t struct device_node *node)\n--\ndrivers/net/dsa/netc/netc_main.c-189-\ndrivers/net/dsa/netc/netc_main.c:190:static int netc_port_create_mdio_bus(struct netc_port *np,\ndrivers/net/dsa/netc/netc_main.c-191-\t\t\t\t struct device_node *node)\n--\ndrivers/net/dsa/netc/netc_main.c-197-\tif (mdio_node) {\ndrivers/net/dsa/netc/netc_main.c:198:\t\terr = netc_port_create_emdio_bus(np, mdio_node);\ndrivers/net/dsa/netc/netc_main.c-199-\t\tof_node_put(mdio_node);\n--\ndrivers/net/dsa/netc/netc_main.c=241=static int netc_init_all_ports(struct netc_switch *priv)\n--\ndrivers/net/dsa/netc/netc_main.c-283-\t\tif (dsa_port_is_user(dp)) {\ndrivers/net/dsa/netc/netc_main.c:284:\t\t\terr = netc_port_create_mdio_bus(np, dp-\u003edn);\ndrivers/net/dsa/netc/netc_main.c-285-\t\t\tif (err) {\n--\ndrivers/net/dsa/ocelot/felix.c=1517=static int felix_init_structs(struct felix *felix, int num_phys_ports)\n--\ndrivers/net/dsa/ocelot/felix.c-1602-\ndrivers/net/dsa/ocelot/felix.c:1603:\tif (felix-\u003einfo-\u003emdio_bus_alloc) {\ndrivers/net/dsa/ocelot/felix.c:1604:\t\terr = felix-\u003einfo-\u003emdio_bus_alloc(ocelot);\ndrivers/net/dsa/ocelot/felix.c-1605-\t\tif (err \u003c 0)\n--\ndrivers/net/dsa/ocelot/felix.c=1696=static int felix_setup(struct dsa_switch *ds)\n--\ndrivers/net/dsa/ocelot/felix.c-1768-out_mdiobus_free:\ndrivers/net/dsa/ocelot/felix.c:1769:\tif (felix-\u003einfo-\u003emdio_bus_free)\ndrivers/net/dsa/ocelot/felix.c:1770:\t\tfelix-\u003einfo-\u003emdio_bus_free(ocelot);\ndrivers/net/dsa/ocelot/felix.c-1771-\n--\ndrivers/net/dsa/ocelot/felix.c=1775=static void felix_teardown(struct dsa_switch *ds)\n--\ndrivers/net/dsa/ocelot/felix.c-1792-\ndrivers/net/dsa/ocelot/felix.c:1793:\tif (felix-\u003einfo-\u003emdio_bus_free)\ndrivers/net/dsa/ocelot/felix.c:1794:\t\tfelix-\u003einfo-\u003emdio_bus_free(ocelot);\ndrivers/net/dsa/ocelot/felix.c-1795-}\n--\ndrivers/net/dsa/ocelot/felix.h=22=struct felix_info {\n--\ndrivers/net/dsa/ocelot/felix.h-55-\ndrivers/net/dsa/ocelot/felix.h:56:\tint\t(*mdio_bus_alloc)(struct ocelot *ocelot);\ndrivers/net/dsa/ocelot/felix.h:57:\tvoid\t(*mdio_bus_free)(struct ocelot *ocelot);\ndrivers/net/dsa/ocelot/felix.h-58-\tint\t(*port_setup_tc)(struct dsa_switch *ds, int port,\n--\ndrivers/net/dsa/ocelot/felix_vsc9959.c=951=static void vsc9959_wm_stat(u32 val, u32 *inuse, u32 *maxuse)\n--\ndrivers/net/dsa/ocelot/felix_vsc9959.c-956-\ndrivers/net/dsa/ocelot/felix_vsc9959.c:957:static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)\ndrivers/net/dsa/ocelot/felix_vsc9959.c-958-{\n--\ndrivers/net/dsa/ocelot/felix_vsc9959.c-1044-\ndrivers/net/dsa/ocelot/felix_vsc9959.c:1045:static void vsc9959_mdio_bus_free(struct ocelot *ocelot)\ndrivers/net/dsa/ocelot/felix_vsc9959.c-1046-{\n--\ndrivers/net/dsa/ocelot/felix_vsc9959.c=2659=static const struct felix_info felix_info_vsc9959 = {\n--\ndrivers/net/dsa/ocelot/felix_vsc9959.c-2675-\t.ptp_caps\t\t= \u0026vsc9959_ptp_caps,\ndrivers/net/dsa/ocelot/felix_vsc9959.c:2676:\t.mdio_bus_alloc\t\t= vsc9959_mdio_bus_alloc,\ndrivers/net/dsa/ocelot/felix_vsc9959.c:2677:\t.mdio_bus_free\t\t= vsc9959_mdio_bus_free,\ndrivers/net/dsa/ocelot/felix_vsc9959.c-2678-\t.port_modes\t\t= vsc9959_port_modes,\n--\ndrivers/net/dsa/ocelot/seville_vsc9953.c=869=static const struct ocelot_ops vsc9953_ops = {\n--\ndrivers/net/dsa/ocelot/seville_vsc9953.c-877-\ndrivers/net/dsa/ocelot/seville_vsc9953.c:878:static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)\ndrivers/net/dsa/ocelot/seville_vsc9953.c-879-{\n--\ndrivers/net/dsa/ocelot/seville_vsc9953.c-934-\ndrivers/net/dsa/ocelot/seville_vsc9953.c:935:static void vsc9953_mdio_bus_free(struct ocelot *ocelot)\ndrivers/net/dsa/ocelot/seville_vsc9953.c-936-{\n--\ndrivers/net/dsa/ocelot/seville_vsc9953.c=950=static const struct felix_info seville_info_vsc9953 = {\n--\ndrivers/net/dsa/ocelot/seville_vsc9953.c-964-\t.num_ports\t\t= VSC9953_NUM_PORTS,\ndrivers/net/dsa/ocelot/seville_vsc9953.c:965:\t.mdio_bus_alloc\t\t= vsc9953_mdio_bus_alloc,\ndrivers/net/dsa/ocelot/seville_vsc9953.c:966:\t.mdio_bus_free\t\t= vsc9953_mdio_bus_free,\ndrivers/net/dsa/ocelot/seville_vsc9953.c-967-\t.port_modes\t\t= vsc9953_port_modes,\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c=793=static int\ndrivers/net/dsa/qca/qca8k-8xxx.c:794:qca8k_mdio_busy_wait(struct mii_bus *bus, u32 reg, u32 mask)\ndrivers/net/dsa/qca/qca8k-8xxx.c-795-{\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c=816=qca8k_mdio_write(struct qca8k_priv *priv, int phy, int regnum, u16 data)\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c-840-\ndrivers/net/dsa/qca/qca8k-8xxx.c:841:\tret = qca8k_mdio_busy_wait(bus, QCA8K_MDIO_MASTER_CTRL,\ndrivers/net/dsa/qca/qca8k-8xxx.c-842-\t\t\t\t QCA8K_MDIO_MASTER_BUSY);\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c=854=qca8k_mdio_read(struct qca8k_priv *priv, int phy, int regnum)\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c-877-\ndrivers/net/dsa/qca/qca8k-8xxx.c:878:\tret = qca8k_mdio_busy_wait(bus, QCA8K_MDIO_MASTER_CTRL,\ndrivers/net/dsa/qca/qca8k-8xxx.c-879-\t\t\t\t QCA8K_MDIO_MASTER_BUSY);\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c=947=qca8k_mdio_register(struct qca8k_priv *priv)\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c-964-\ndrivers/net/dsa/qca/qca8k-8xxx.c:965:\tpriv-\u003einternal_mdio_bus = bus;\ndrivers/net/dsa/qca/qca8k-8xxx.c-966-\tbus-\u003epriv = (void *)priv;\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c=994=static int\ndrivers/net/dsa/qca/qca8k-8xxx.c:995:qca8k_setup_mdio_bus(struct qca8k_priv *priv)\ndrivers/net/dsa/qca/qca8k-8xxx.c-996-{\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c=1843=qca8k_setup(struct dsa_switch *ds)\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c-1860-\ndrivers/net/dsa/qca/qca8k-8xxx.c:1861:\tret = qca8k_setup_mdio_bus(priv);\ndrivers/net/dsa/qca/qca8k-8xxx.c-1862-\tif (ret)\n--\ndrivers/net/dsa/qca/qca8k-leds.c=365=qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int port_num)\n--\ndrivers/net/dsa/qca/qca8k-leds.c-431-\t\tinit_data.devicename = kasprintf(GFP_KERNEL, \"%s:0%d\",\ndrivers/net/dsa/qca/qca8k-leds.c:432:\t\t\t\t\t\t priv-\u003einternal_mdio_bus ?\ndrivers/net/dsa/qca/qca8k-leds.c:433:\t\t\t\t\t\t priv-\u003einternal_mdio_bus-\u003eid : priv-\u003ebus-\u003eid,\ndrivers/net/dsa/qca/qca8k-leds.c-434-\t\t\t\t\t\t port_num);\n--\ndrivers/net/dsa/qca/qca8k.h=445=struct qca8k_priv {\n--\ndrivers/net/dsa/qca/qca8k.h-458-\tstruct mii_bus *bus;\ndrivers/net/dsa/qca/qca8k.h:459:\tstruct mii_bus *internal_mdio_bus;\ndrivers/net/dsa/qca/qca8k.h-460-\tstruct dsa_switch *ds;\n--\ndrivers/net/dsa/vitesse-vsc73xx-core.c=521=static int vsc73xx_detect(struct vsc73xx *vsc)\n--\ndrivers/net/dsa/vitesse-vsc73xx-core.c-604-\ndrivers/net/dsa/vitesse-vsc73xx-core.c:605:static int vsc73xx_mdio_busy_check(struct vsc73xx *vsc)\ndrivers/net/dsa/vitesse-vsc73xx-core.c-606-{\n--\ndrivers/net/dsa/vitesse-vsc73xx-core.c=621=static int vsc73xx_phy_read(struct dsa_switch *ds, int phy, int regnum)\n--\ndrivers/net/dsa/vitesse-vsc73xx-core.c-627-\ndrivers/net/dsa/vitesse-vsc73xx-core.c:628:\tret = vsc73xx_mdio_busy_check(vsc);\ndrivers/net/dsa/vitesse-vsc73xx-core.c-629-\tif (ret)\n--\ndrivers/net/dsa/vitesse-vsc73xx-core.c-640-\ndrivers/net/dsa/vitesse-vsc73xx-core.c:641:\tret = vsc73xx_mdio_busy_check(vsc);\ndrivers/net/dsa/vitesse-vsc73xx-core.c-642-\tif (ret)\n--\ndrivers/net/dsa/vitesse-vsc73xx-core.c=662=static int vsc73xx_phy_write(struct dsa_switch *ds, int phy, int regnum,\n--\ndrivers/net/dsa/vitesse-vsc73xx-core.c-668-\ndrivers/net/dsa/vitesse-vsc73xx-core.c:669:\tret = vsc73xx_mdio_busy_check(vsc);\ndrivers/net/dsa/vitesse-vsc73xx-core.c-670-\tif (ret)\n--\ndrivers/net/ethernet/apm/xgene-v2/main.h=51=struct xge_pdata {\n--\ndrivers/net/ethernet/apm/xgene-v2/main.h-56-\tchar irq_name[IRQ_ID_SIZE];\ndrivers/net/ethernet/apm/xgene-v2/main.h:57:\tstruct mii_bus *mdio_bus;\ndrivers/net/ethernet/apm/xgene-v2/main.h-58-\tstruct net_device *ndev;\n--\ndrivers/net/ethernet/apm/xgene-v2/mdio.c=84=void xge_mdio_remove(struct net_device *ndev)\n--\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-86-\tstruct xge_pdata *pdata = netdev_priv(ndev);\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:87:\tstruct mii_bus *mdio_bus = pdata-\u003emdio_bus;\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-88-\n--\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-91-\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:92:\tif (mdio_bus-\u003estate == MDIOBUS_REGISTERED)\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:93:\t\tmdiobus_unregister(mdio_bus);\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-94-\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:95:\tmdiobus_free(mdio_bus);\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-96-}\n--\ndrivers/net/ethernet/apm/xgene-v2/mdio.c=98=int xge_mdio_config(struct net_device *ndev)\n--\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-101-\tstruct device *dev = \u0026pdata-\u003epdev-\u003edev;\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:102:\tstruct mii_bus *mdio_bus;\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-103-\tstruct phy_device *phydev;\n--\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-105-\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:106:\tmdio_bus = mdiobus_alloc();\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:107:\tif (!mdio_bus)\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-108-\t\treturn -ENOMEM;\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-109-\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:110:\tmdio_bus-\u003ename = \"APM X-Gene Ethernet (v2) MDIO Bus\";\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:111:\tmdio_bus-\u003eread = xge_mdio_read;\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:112:\tmdio_bus-\u003ewrite = xge_mdio_write;\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:113:\tmdio_bus-\u003epriv = pdata;\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:114:\tmdio_bus-\u003eparent = dev;\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:115:\tsnprintf(mdio_bus-\u003eid, MII_BUS_ID_SIZE, \"%s-mii\", dev_name(dev));\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:116:\tpdata-\u003emdio_bus = mdio_bus;\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-117-\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:118:\tmdio_bus-\u003ephy_mask = 0x1;\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:119:\tret = mdiobus_register(mdio_bus);\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-120-\tif (ret)\n--\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-122-\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:123:\tphydev = phy_find_first(mdio_bus);\ndrivers/net/ethernet/apm/xgene-v2/mdio.c-124-\tif (!phydev) {\n--\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c=939=int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata)\n--\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-941-\tstruct net_device *ndev = pdata-\u003endev;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:942:\tstruct mii_bus *mdio_bus;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-943-\tint ret;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-944-\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:945:\tmdio_bus = mdiobus_alloc();\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:946:\tif (!mdio_bus)\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-947-\t\treturn -ENOMEM;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-948-\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:949:\tmdio_bus-\u003ename = \"APM X-Gene MDIO bus\";\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:950:\tmdio_bus-\u003eread = xgene_mdio_rgmii_read;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:951:\tmdio_bus-\u003ewrite = xgene_mdio_rgmii_write;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:952:\tsnprintf(mdio_bus-\u003eid, MII_BUS_ID_SIZE, \"%s-%s\", \"xgene-mii\",\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-953-\t\t ndev-\u003ename);\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-954-\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:955:\tmdio_bus-\u003epriv = (void __force *)pdata-\u003emcx_mac_addr;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:956:\tmdio_bus-\u003eparent = \u0026pdata-\u003epdev-\u003edev;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-957-\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:958:\tret = xgene_mdiobus_register(pdata, mdio_bus);\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-959-\tif (ret) {\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-960-\t\tnetdev_err(ndev, \"Failed to register MDIO bus\\n\");\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:961:\t\tmdiobus_free(mdio_bus);\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-962-\t\treturn ret;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-963-\t}\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:964:\tpdata-\u003emdio_bus = mdio_bus;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-965-\n--\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c=981=void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata)\n--\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-987-\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:988:\tmdiobus_unregister(pdata-\u003emdio_bus);\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:989:\tmdiobus_free(pdata-\u003emdio_bus);\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:990:\tpdata-\u003emdio_bus = NULL;\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c-991-}\n--\ndrivers/net/ethernet/apm/xgene/xgene_enet_main.h=184=struct xgene_enet_pdata {\ndrivers/net/ethernet/apm/xgene/xgene_enet_main.h-185-\tstruct net_device *ndev;\ndrivers/net/ethernet/apm/xgene/xgene_enet_main.h:186:\tstruct mii_bus *mdio_bus;\ndrivers/net/ethernet/apm/xgene/xgene_enet_main.h-187-\tint phy_speed;\n--\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-11-\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c:12:bool aq_mdio_busy_wait(struct aq_hw_s *aq_hw)\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-13-{\n--\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-16-\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c:17:\terr = readx_poll_timeout_atomic(hw_atl_mdio_busy_get, aq_hw,\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-18-\t\t\t\t\tval, val == 0U, 10U, 100000U);\n--\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c=26=u16 aq_mdio_read_word(struct aq_hw_s *aq_hw, u16 mmd, u16 addr)\n--\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-38-\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c:39:\taq_mdio_busy_wait(aq_hw);\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-40-\n--\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-46-\t/* Read result. */\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c:47:\taq_mdio_busy_wait(aq_hw);\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-48-\n--\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c=52=void aq_mdio_write_word(struct aq_hw_s *aq_hw, u16 mmd, u16 addr, u16 data)\n--\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-64-\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c:65:\taq_mdio_busy_wait(aq_hw);\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-66-\n--\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-74-\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c:75:\taq_mdio_busy_wait(aq_hw);\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c-76-}\n--\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.h-19-\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.h:20:bool aq_mdio_busy_wait(struct aq_hw_s *aq_hw);\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.h-21-\n--\ndrivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c=1886=u32 hw_atl_glb_mdio_iface5_get(struct aq_hw_s *aq_hw)\n--\ndrivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c-1890-\ndrivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c:1891:u32 hw_atl_mdio_busy_get(struct aq_hw_s *aq_hw)\ndrivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c-1892-{\n--\ndrivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h=871=u32 hw_atl_glb_mdio_iface5_get(struct aq_hw_s *hw);\ndrivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h-872-\ndrivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h:873:u32 hw_atl_mdio_busy_get(struct aq_hw_s *aq_hw);\ndrivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h-874-\n--\ndrivers/net/ethernet/arc/emac.h=100=struct buffer_state {\n--\ndrivers/net/ethernet/arc/emac.h-105-\n\n"
} |
| 7/2 | 2026/09/19 12:29 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42972 output: 20 thoughts: 788 Thoughts: **Analyzing the MotorComm YT8824 PHY Driver for WorthFuzzing Determination** Okay, so I'm looking at `drivers/net/phy/motorcomm.c` and specifically how `yt8824_probe()` gets called. I see `devm_of_phy_package_join` which strongly suggests this driver relies on DeviceTree (Open Firmware) for device discovery and configuration, which is a key hint. And, of course, the name makes it clear that this is a PHY driver for a *specific* hardware chip: the MotorComm YT8824, a quad 2.5G Ethernet PHY. The question then becomes: is this "structurally unreachable hardware" according to the "NEGATIVE CRITERIA" for WorthFuzzing? Specifically, does it fall under that category where we exclude drivers for vendor-specific hardware that *requires* an actual physical ASIC or PCIe card not emulated in standard QEMU? My initial instinct is "probably," but I need to be sure. Let's think this through. The docs provide clear guidance. Let's check Section 2 again: I need to determine if this is "structurally unreachable". The critical question now is, are Ethernet PHYs generally considered to be structurally unreachable in QEMU? Can they be emulated or accessed in a standard QEMU setup? I know QEMU emulates several network cards. Let's see... e1000, e1000e, igb, virtio-net, rtl8139, ne2k_pci, pcnet32. None of these use the `motorcomm.c` driver. The e1000 and the other virtual devices that QEMU provides all seem to have their own internal PHY code. Virtio-net, for instance, doesn't even have a MDIO PHY! I need to be sure that the `motorcomm.c` is not part of this emulated network path. Okay, so the MotorComm YT8824 is a discrete, physical Ethernet PHY chip—a physical piece of silicon made by Motorcomm, a semiconductor company. This is a *physical* device. I need to know if syzkaller can instantiate MDIO PHY devices somehow via netlink, sysfs, or anything, to determine if this particular driver is reachable. I need to determine if there is a user-space interface to instantiate an mdio device or phy device! |
| 8/2 | 2026/09/19 12:29 | tool | grepper |
0mError:no matches Args: {
"Expression": "mdio.*new_device"
}Results: {
"error": "no matches"
} |
| 9/2 | 2026/09/19 12:29 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44318 output: 19 thoughts: 21 Thoughts: Here's a summary of my thought process, as requested: **Navigating the Registering Maze** Okay, so I'm trying to figure out where the core registration logic lies for this networking PHY device. Time to drill down. Given the context, I immediately need to zero in on the key functions for device registration. My gut says it's got to be either `mdiobus_register_device` or `phy_device_register`. Those are the usual suspects in this kind of scenario, especially when dealing with the MDIO bus and PHY-specific device interfaces. I need to quickly determine which one is the appropriate entry point, or if there's some kind of wrapper around them, or, potentially, a custom function. It's time to check which one is the point of entry. Let's see what's what. |
| 10/2 | 2026/09/19 12:29 | tool | grepper |
0mArgs:{
"Expression": "phy_device_register"
}Results: {
"Output": "drivers/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--\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c=716=hns_mac_register_phydev(struct mii_bus *mdio, struct hns_mac_cb *mac_cb,\n--\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c-744-\t */\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c:745:\trc = phy_device_register(phy);\ndrivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c-746-\tif (rc) {\n--\ndrivers/net/ethernet/socionext/netsec.c=1929=static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr)\n--\ndrivers/net/ethernet/socionext/netsec.c-1983-\ndrivers/net/ethernet/socionext/netsec.c:1984:\t\tret = phy_device_register(priv-\u003ephydev);\ndrivers/net/ethernet/socionext/netsec.c-1985-\t\tif (ret) {\n--\ndrivers/net/ethernet/socionext/netsec.c-1988-\t\t\tdev_err(priv-\u003edev,\ndrivers/net/ethernet/socionext/netsec.c:1989:\t\t\t\t\"phy_device_register err(%d)\\n\", ret);\ndrivers/net/ethernet/socionext/netsec.c-1990-\t\t}\n--\ndrivers/net/mdio/fwnode_mdio.c=42=fwnode_find_mii_timestamper(struct fwnode_handle *fwnode)\n--\ndrivers/net/mdio/fwnode_mdio.c-69-\ndrivers/net/mdio/fwnode_mdio.c:70:int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,\ndrivers/net/mdio/fwnode_mdio.c-71-\t\t\t\t struct phy_device *phy,\n--\ndrivers/net/mdio/fwnode_mdio.c-103-\t */\ndrivers/net/mdio/fwnode_mdio.c:104:\trc = phy_device_register(phy);\ndrivers/net/mdio/fwnode_mdio.c-105-\tif (rc) {\n--\ndrivers/net/mdio/fwnode_mdio.c-114-}\ndrivers/net/mdio/fwnode_mdio.c:115:EXPORT_SYMBOL(fwnode_mdiobus_phy_device_register);\ndrivers/net/mdio/fwnode_mdio.c-116-\ndrivers/net/mdio/fwnode_mdio.c=117=int fwnode_mdiobus_register_phy(struct mii_bus *bus,\n--\ndrivers/net/mdio/fwnode_mdio.c-149-\t\t/* All data is now stored in the phy struct, so register it */\ndrivers/net/mdio/fwnode_mdio.c:150:\t\trc = phy_device_register(phy);\ndrivers/net/mdio/fwnode_mdio.c-151-\t\tif (rc) {\n--\ndrivers/net/mdio/fwnode_mdio.c-156-\t} else if (is_of_node(child)) {\ndrivers/net/mdio/fwnode_mdio.c:157:\t\trc = fwnode_mdiobus_phy_device_register(bus, phy, child, addr);\ndrivers/net/mdio/fwnode_mdio.c-158-\t\tif (rc)\n--\ndrivers/net/mdio/mdio-xgene.c=263=struct phy_device *xgene_enet_phy_register(struct mii_bus *bus, int phy_addr)\n--\ndrivers/net/mdio/mdio-xgene.c-270-\ndrivers/net/mdio/mdio-xgene.c:271:\tif (phy_device_register(phy_dev))\ndrivers/net/mdio/mdio-xgene.c-272-\t\tphy_device_free(phy_dev);\n--\ndrivers/net/mdio/of_mdio.c=32=static int of_get_phy_id(struct device_node *device, u32 *phy_id)\n--\ndrivers/net/mdio/of_mdio.c-36-\ndrivers/net/mdio/of_mdio.c:37:int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,\ndrivers/net/mdio/of_mdio.c-38-\t\t\t\t struct device_node *child, u32 addr)\ndrivers/net/mdio/of_mdio.c-39-{\ndrivers/net/mdio/of_mdio.c:40:\treturn fwnode_mdiobus_phy_device_register(mdio, phy,\ndrivers/net/mdio/of_mdio.c-41-\t\t\t\t\t\t of_fwnode_handle(child),\n--\ndrivers/net/mdio/of_mdio.c-43-}\ndrivers/net/mdio/of_mdio.c:44:EXPORT_SYMBOL(of_mdiobus_phy_device_register);\ndrivers/net/mdio/of_mdio.c-45-\n--\ndrivers/net/phy/fixed_phy.c=131=struct phy_device *fixed_phy_register(const struct fixed_phy_status *status,\n--\ndrivers/net/phy/fixed_phy.c-162-\ndrivers/net/phy/fixed_phy.c:163:\tret = phy_device_register(phy);\ndrivers/net/phy/fixed_phy.c-164-\tif (ret) {\n--\ndrivers/net/phy/mdio_bus_provider.c=408=static struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr, bool c45)\n--\ndrivers/net/phy/mdio_bus_provider.c-437-\ndrivers/net/phy/mdio_bus_provider.c:438:\terr = phy_device_register(phydev);\ndrivers/net/phy/mdio_bus_provider.c-439-\tif (err) {\n--\ndrivers/net/phy/nxp-tja11xx.c=551=static void tja1102_p1_register(struct work_struct *work)\n--\ndrivers/net/phy/nxp-tja11xx.c-597-\ndrivers/net/phy/nxp-tja11xx.c:598:\t\tret = of_mdiobus_phy_device_register(bus, phy, child, addr);\ndrivers/net/phy/nxp-tja11xx.c-599-\t\tif (ret) {\n--\ndrivers/net/phy/phy_device.c=1103=EXPORT_SYMBOL(get_phy_device);\n--\ndrivers/net/phy/phy_device.c-1105-/**\ndrivers/net/phy/phy_device.c:1106: * phy_device_register - Register the phy device on the MDIO bus\ndrivers/net/phy/phy_device.c-1107- * @phydev: phy_device structure to be added to the MDIO bus\ndrivers/net/phy/phy_device.c-1108- */\ndrivers/net/phy/phy_device.c:1109:int phy_device_register(struct phy_device *phydev)\ndrivers/net/phy/phy_device.c-1110-{\n--\ndrivers/net/phy/phy_device.c-1141-}\ndrivers/net/phy/phy_device.c:1142:EXPORT_SYMBOL(phy_device_register);\ndrivers/net/phy/phy_device.c-1143-\n--\ndrivers/net/phy/phy_device.c-1148- * This doesn't free the phy_device itself, it merely reverses the effects\ndrivers/net/phy/phy_device.c:1149: * of phy_device_register(). Use phy_device_free() to free the device\ndrivers/net/phy/phy_device.c-1150- * after calling this function.\n--\ndrivers/net/phy/sfp.c=2105=static int sfp_sm_probe_phy(struct sfp *sfp, int addr, bool is_c45)\n--\ndrivers/net/phy/sfp.c-2120-\ndrivers/net/phy/sfp.c:2121:\terr = phy_device_register(phy);\ndrivers/net/phy/sfp.c-2122-\tif (err) {\ndrivers/net/phy/sfp.c-2123-\t\tphy_device_free(phy);\ndrivers/net/phy/sfp.c:2124:\t\tdev_err(sfp-\u003edev, \"phy_device_register failed: %pe\\n\",\ndrivers/net/phy/sfp.c-2125-\t\t\tERR_PTR(err));\n--\ninclude/linux/fwnode_mdio.h-11-#if IS_ENABLED(CONFIG_FWNODE_MDIO)\ninclude/linux/fwnode_mdio.h:12:int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,\ninclude/linux/fwnode_mdio.h-13-\t\t\t\t struct phy_device *phy,\n--\ninclude/linux/fwnode_mdio.h=16=int fwnode_mdiobus_register_phy(struct mii_bus *bus,\n--\ninclude/linux/fwnode_mdio.h-19-#else /* CONFIG_FWNODE_MDIO */\ninclude/linux/fwnode_mdio.h:20:int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,\ninclude/linux/fwnode_mdio.h-21-\t\t\t\t struct phy_device *phy,\n--\ninclude/linux/of_mdio.h=49=bool of_phy_is_fixed_link(struct device_node *np);\ninclude/linux/of_mdio.h:50:int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,\ninclude/linux/of_mdio.h-51-\t\t\t\t struct device_node *child, u32 addr);\n--\ninclude/linux/of_mdio.h=140=static inline bool of_phy_is_fixed_link(struct device_node *np)\n--\ninclude/linux/of_mdio.h-144-\ninclude/linux/of_mdio.h:145:static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio,\ninclude/linux/of_mdio.h-146-\t\t\t\t\t struct phy_device *phy,\n--\ninclude/linux/phy.h=2177=struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);\ninclude/linux/phy.h:2178:int phy_device_register(struct phy_device *phy);\ninclude/linux/phy.h-2179-void phy_device_free(struct phy_device *phydev);\n"
} |
| 11/2 | 2026/09/19 12:29 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 47694 output: 38 thoughts: 2619 Thoughts: **Analysis of Patch for Fuzzing Eligibility** Okay, let's break this down. My initial assessment is that this patch is *not* suitable for fuzzing. Here's my reasoning, walking through my thought process: First, I see the core of this patch seems to introduce functionality, specifically related to the Motorcomm YT8824 Ethernet PHY chip. The initial call to `mdiobus_scan()` and `of_mdiobus_register` made me think about PHY devices in general. However, there's a strong indicator: `PHY_ID_YT8824` points to physical silicon. I considered the possibility of creating a virtual representation, but the conclusion is that there is *no* user-space mechanism to instantiate an arbitrary PHY device without a physical hardware setup. Next, I looked carefully at the negative criteria. The "structurally unreachable hardware" category is particularly relevant here, and I'm very familiar with these kinds of exclusions. I'm thinking about whether or not this change hits that criteria. I then honed in on the specific code changes in `drivers/net/phy/phy-c45.c` which, importantly, is where `genphy_c45_template_testmode` resides. I wanted to verify its reachability. My investigation led me to `motorcomm.c`, and I confirm this: `genphy_c45_template_testmode` *is* only called within the `motorcomm.c` driver. The driver registers using `PHY_ID_YT8824`, which confirms my understanding: it's tied to physical hardware. I tried to imagine if a virtual setup could emulate a Motorcomm YT8824 PHY, and I conclude it's not possible. The MDIO bus binding process further solidifies my view. When the MDIO bus driver scans, it uses the PHY ID (0x4f51e8b8). The `yt8824_probe` function is called and the `devm_of_phy_package_join` is executed. This function crucially depends on a DeviceTree node (`dev->of_node`). This strongly suggests an underlying requirement for DeviceTree configuration which is not typical in the standard QEMU environment for amd64 architecture. The discussion of reachability is key. The fuzzing framework prioritizes code that *can* actually be executed within a virtualized environment. This patch deals with an Ethernet PHY chip requiring physical hardware that is *not* emulated in standard QEMU. I checked again whether any part of this code would be accessible via ethtool or any netlink/ioctl commands. It's newly introduced and not exposed in any known mechanisms. `genphy_c45_template_testmode` can't be called, it's not exposed, and it isn't part of any existing ethtool operations. Finally, I checked the diff, specifically around line 622, I found that `ytphy_set_wol` was modified. However, the modification is minor. My conclusion: This patch affects structurally unreachable hardware and, therefore, is *not* suitable for fuzzing. |
| 12/2 | 2026/09/19 12:30 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/motorcomm.c",
"FirstLine": 710,
"LineCount": 40
}Results: {
"Contents": " 710:\t\t\tret = ytphy_modify_ext(phydev, YTPHY_WOL_CONFIG_REG, mask, val);\n 711:\t\t\tif (ret \u003c 0)\n 712:\t\t\t\tgoto err_restore_page;\n 713:\t\n 714:\t\t\t/* Enable WOL interrupt */\n 715:\t\t\tret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG, 0,\n 716:\t\t\t\t\t YTPHY_IER_WOL);\n 717:\t\t\tif (ret \u003c 0)\n 718:\t\t\t\tgoto err_restore_page;\n 719:\t\n 720:\t\t} else {\n 721:\t\t\told_page = phy_select_page(phydev, YT8521_RSSR_UTP_SPACE);\n 722:\t\t\tif (old_page \u003c 0)\n 723:\t\t\t\tgoto err_restore_page;\n 724:\t\n 725:\t\t\t/* Disable WOL feature */\n 726:\t\t\tmask = YTPHY_WCR_ENABLE | YTPHY_WCR_INTR_SEL;\n 727:\t\t\tret = ytphy_modify_ext(phydev, YTPHY_WOL_CONFIG_REG, mask, 0);\n 728:\t\n 729:\t\t\t/* Disable WOL interrupt */\n 730:\t\t\tret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,\n 731:\t\t\t\t\t YTPHY_IER_WOL, 0);\n 732:\t\t\tif (ret \u003c 0)\n 733:\t\t\t\tgoto err_restore_page;\n 734:\t\t}\n 735:\t\n 736:\terr_restore_page:\n 737:\t\treturn phy_restore_page(phydev, old_page, ret);\n 738:\t}\n 739:\t\n 740:\t/**\n 741:\t * yt8824_read_page() - read PHY8824 reg page\n 742:\t * @phydev: a pointer to a \u0026struct phy_device\n 743:\t *\n 744:\t * Returns: current reg space of yt8824 (YT8824_RSSR_USXGMII_SPACE/\n 745:\t * YT8824_RSSR_UTP_SPACE) or negative errno code\n 746:\t */\n 747:\tstatic int yt8824_read_page(struct phy_device *phydev)\n 748:\t{\n 749:\t\tint old_page;\n"
} |
| 13/2 | 2026/09/19 12:30 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 51712 output: 18 thoughts: 649 Thoughts: **Analyzing the ytphy_set_wol Function and QEMU's Motorcomm PHY Emulation (or Lack Thereof)** Okay, let's break this down. In the `ytphy_set_wol` function, I see they've added an error check right before the `err_restore_page:` label. Specifically, `if (ret < 0) goto err_restore_page;`. But hold on... that `goto` jumps to the *very next* line, `return phy_restore_page(...)`, effectively negating the added check! It returns regardless of the `ret` value. What's the point? More importantly, it's making me consider how these PHYs are tested. Are we even dealing with Motorcomm PHYs in a virtual environment? The question needs to be asked: does QEMU emulate ANY Motorcomm PHY? I mean, Motorcomm manufactures *physical* transceiver chips – YT8511, YT8521, YT8531, YT8531S, YT8821, YT8824 are the common ones. These are *physical* devices meant for boards, like Rockchip or Allwinner. Let's verify: What does QEMU offer? I know it supports Intel NICs (e1000, e1000e, igb), VirtIO, RTL8139, and a few others. But... is there anything related to Motorcomm? No, there is no emulation. This is unsurprising; Motorcomm is a Chinese manufacturer. Their chips are *hardware*, not something you run in QEMU. They're on embedded boards, not emulated. So, how is this driver *actually* tested? Can syzkaller interact with PHY drivers through some mock or virtual bus? Let's search the syzkaller or kernel source for "virtual mdio". Maybe there's a trick to it, but I highly doubt it. There may need to be a dummy PHY or other abstraction, and the tests should have been built to deal with them, although I am not finding clear evidence of this yet. |
| 14/2 | 2026/09/19 12:30 | tool | grepper |
0mError:no matches Args: {
"Expression": "mdio.*virtual"
}Results: {
"error": "no matches"
} |
| 15/2 | 2026/09/19 12:30 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 52854 output: 156 thoughts: 922 Thoughts: **Fuzzing Verdict: Not Worth It** Okay, let's break this down systematically. My initial thought was to look at options like `mdio-gpio`, `mdio-bitbang`, or `fixed_mdio`. However, `fixed_mdio` is only relevant for fixed PHYs, not this Motorcomm hardware, and even if `mdio-gpio` existed, it'd rely on GPIO chips and Device Tree or platform data. The bigger problem is that based on Section 2 of the documentation, this clearly falls under vendor-specific hardware requiring physical silicon that's not emulated in standard QEMU. That's a fundamental roadblock. Then, I double-checked the reachability of the `genphy_c45_template_testmode` function in `drivers/net/phy/phy-c45.c`, introduced in this patch. I saw that it's `EXPORT_SYMBOL_GPL` and *only* called by the `yt8824_*` functions within `drivers/net/phy/motorcomm.c`. This strongly suggests that all the executable code introduced or modified by this patch is solely dedicated to Motorcomm PHYs, specifically YT8824 support. Since this is physical silicon, it cannot be executed in virtualized environments like QEMU or GCE. Let's do a quick scan of other changes. We've got: `Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml` (docs), `drivers/net/phy/Kconfig` (PHY_PACKAGE), `drivers/net/phy/motorcomm.c` (YT8824 support), `drivers/net/phy/phy-c45.c` (`genphy_c45_template_testmode`), `include/linux/phy.h` (header) and `include/uapi/linux/mdio.h` (header constants). So, the modifications are either documentation, headers, or, critically, code that is exclusively for Motorcomm YT8824 PHY hardware, which is *structurally unreachable* in our target environments. Therefore, `WorthFuzzing` has to be `false`. Now, let's verify the `set-results` requirements. We need `WorthFuzzing: false`, a good `Reasoning`, `FocusSymbols: []`, and `EnableConfigs: []`. Let's be clear and concise in our reasoning: The patch adds support for the Motorcomm YT8824, a quad-port 2.5GbE PHY package, along with a C45 helper, but this code is exclusively for physical hardware (MDIO and DeviceTree based), which isn't emulated in standard QEMU/GCE environments. Since the modified executable code is not accessible without the physical silicon, fuzzing isn't warranted. Finally, just a sanity check: amd64 architecture, correct result parameters, `FocusSymbols` and `EnableConfigs` are empty arrays as expected because `WorthFuzzing` is `false`. Everything looks good. We're ready to `set-results`. |
| 16/2 | 2026/09/19 12:30 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The patch series adds support for the Motorcomm YT8824 Ethernet PHY in drivers/net/phy/motorcomm.c, along with an export helper genphy_c45_template_testmode() in drivers/net/phy/phy-c45.c that is exclusively called by the YT8824 driver. Motorcomm Ethernet PHY chips are physical hardware devices attached via MDIO and configured via DeviceTree, which are not emulated in standard virtualized environments (QEMU/GCE). Consequently, the modified code paths are structurally unreachable and do not warrant fuzzing.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch series adds support for the Motorcomm YT8824 Ethernet PHY in drivers/net/phy/motorcomm.c, along with an export helper genphy_c45_template_testmode() in drivers/net/phy/phy-c45.c that is exclusively called by the YT8824 driver. Motorcomm Ethernet PHY chips are physical hardware devices attached via MDIO and configured via DeviceTree, which are not emulated in standard virtualized environments (QEMU/GCE). Consequently, the modified code paths are structurally unreachable and do not warrant fuzzing.",
"WorthFuzzing": false
} |
| 17/1 | 2026/09/19 12:30 | 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) |
|---|