| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/08/02 08:32 | flow | patch-triage |
2mArgs:null Results: {
"EnableConfigs": [
"MOTORCOMM_PHY",
"MDIO_MVUSB"
],
"FocusSymbols": [
"yt8824_probe",
"yt8824_config_init",
"yt8824_config_aneg",
"yt8824_aneg_done",
"yt8824_read_status",
"yt8824_soft_reset",
"yt8824_suspend",
"yt8824_resume",
"yt8824_read_page",
"yt8824_write_page",
"genphy_c45_template_testmode"
],
"Reasoning": "The patch adds support for the Motorcomm YT8824 PHY driver. It introduces a new PHY driver structure with various callbacks for probing, initialization, auto-negotiation, status reading, and power management. These functions are reachable via MDIO bus emulation (e.g., using the Marvell USB MDIO adapter driver). Fuzzing should focus on the newly added PHY driver callbacks and the exported helper `genphy_c45_template_testmode`.",
"WorthFuzzing": true
} |
| 1/1 | 2026/08/02 08:32 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit e2df19e61631e3fcf366dfd29fc19a9e08227044\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sun Aug 2 08:32:40 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c\nindex 3396a38cfc0f2..868a0c9f29a7e 100644\n--- a/drivers/net/phy/motorcomm.c\n+++ b/drivers/net/phy/motorcomm.c\n@@ -1,24 +1,33 @@\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/module.h\u003e\n+#include \u003clinux/of.h\u003e\n #include \u003clinux/phy.h\u003e\n #include \u003clinux/property.h\u003e\n \n+#include \"phylib.h\"\n+\n+/* define PHY8824 top extend addr offset internal and external*/\n+#define INTERNAL_PHY8824_TOP_EXTEND_OFFSET (5)\n+#define EXTERNAL_PHY8824_TOP_EXTEND_OFFSET (4)\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 +39,18 @@\n * ------------------------------------------------------------\n */\n \n+/* YT8824 Register Overview\n+ *\tUTP Register space\t|\tFIBER Register space\n+ * ------------------------------------------------------------\n+ * |\tUTP MII\t\t\t|\tFIBER MII\t |\n+ * |\tUTP MMD\t\t\t|\t\t\t\t|\n+ * |\tUTP Extended\t\t|\tFIBER Extended\t\t|\n+ * |\tUTP Top Extended\t|\tFIBER Top Extended\t|\n+ * ------------------------------------------------------------\n+ * |\t\t\tCommon 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@@ -376,6 +397,15 @@\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_UTP_TEMPLATE_TEST_MODE1\t\t0x2000\n+#define YT8824_UTP_TEMPLATE_TEST_NORMAL\t\t0x0000\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@@ -394,6 +424,11 @@ struct yt8521_priv {\n \tu8 reg_page;\n };\n \n+struct yt8824_shared_priv {\n+\tunsigned int interface_mode;\n+\tunsigned int offset;\n+};\n+\n /**\n * ytphy_read_ext() - read a PHY's extended register\n * @phydev: a pointer to a \u0026struct phy_device\n@@ -432,6 +467,70 @@ static int ytphy_read_ext_with_lock(struct phy_device *phydev, u16 regnum)\n \treturn ret;\n }\n \n+/**\n+ * ytphy_read_top_ext() - read a PHY's top extended register for YT8824\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @regnum: register number to read\n+ *\n+ * Returns: the value of regnum reg or negative error code\n+ */\n+static int ytphy_read_top_ext(struct phy_device *phydev, u16 regnum)\n+{\n+\tint ret;\n+\n+\tlockdep_assert_held(\u0026phydev-\u003emdio.bus-\u003emdio_lock);\n+\tret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn __phy_package_read(phydev, 0, YTPHY_PAGE_DATA);\n+}\n+\n+/**\n+ * ytphy_write_top_ext() - write a PHY's top extended register for YT8824\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @regnum: register number to write\n+ * @val: register val to write\n+ *\n+ * Returns: the value of regnum reg 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: the value of regnum reg 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_restore_page;\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_restore_page:\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@@ -621,11 +720,998 @@ static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)\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\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_invalid_test_mode_paged() - config YT8824 to invalid test mode.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_utp_invalid_test_mode_paged(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 genphy_c45_template_testmode(phydev,\n+\t\t\t\t\t YT8824_UTP_TEMPLATE_TEST_MODE1);\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;\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+\tret = __phy_read(phydev, MII_BMCR);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\t/* isolation */\n+\tret |= BMCR_ISOLATE;\n+\tret = __phy_write(phydev, MII_BMCR, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_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_read(phydev, MII_BMCR);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret |= BMCR_RESET;\n+\tret = phy_write(phydev, MII_BMCR, ret);\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,\n+\t\t\t\t !(val \u0026 BMCR_RESET),\n+\t\t\t\t 50000, 600000, true);\n+}\n+\n+/**\n+ * yt8824_utp_normal_test_mode_paged() - config YT8824 to normal test mode.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_utp_normal_test_mode_paged(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 genphy_c45_template_testmode(phydev,\n+\t\t\t\t\t YT8824_UTP_TEMPLATE_TEST_NORMAL);\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+\tunsigned int retry = 12;\n+\tint old_page;\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+\tret = __phy_read(phydev, MII_BMCR);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* disable isolation */\n+\tret \u0026= ~BIT(10);\n+\t/* soft reset */\n+\tret |= BMCR_RESET;\n+\tret = __phy_write(phydev, MII_BMCR, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\tdo {\n+\t\tmsleep(50);\n+\t\tret = __phy_read(phydev, MII_BMCR);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\t} while ((ret \u0026 BMCR_RESET) \u0026\u0026 --retry);\n+\n+\tif (ret \u0026 BMCR_RESET) {\n+\t\tret = -ETIMEDOUT;\n+\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_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+\tint ret;\n+\n+\tif (phydev-\u003einterface == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\t/* invalid test mode */\n+\t\tret = yt8824_utp_invalid_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = yt8824_utp_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_normal_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t} else {\n+\t\t/* invalid test mode */\n+\t\tret = yt8824_utp_invalid_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\n+\t\t/* sds isolation */\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\n+\t\t/* utp soft reset */\n+\t\tret = yt8824_utp_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_normal_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\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\treturn ret;\n+\t}\n+\treturn 0;\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 data = 0;\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+\t/* power down */\n+\tdata = phy_read(phydev, MII_BMCR);\n+\tif (data \u003c 0)\n+\t\treturn data;\n+\tdata |= BMCR_PDOWN;\n+\tret = phy_write(phydev, MII_BMCR, data);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* pll calibration */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0001, 0x0003);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa20e, 0x0cba);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa20a, 0xc3f1);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa20c, 0x1620);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0x0a00);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0x0e00);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* optimization utp */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0001, 0x0003);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* enable nibble */\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa003, 0x0003);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* idle err detect enable */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x03d0, 0x5210);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\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\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x037c, 0x6068);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0388, 0x00a0);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* optimized fast retrain */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0359, 0x2140);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x000c, 0xc1a0);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* 2.5G template tone */\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2fa, 0x0083);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x04e2, 0x0149);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* optimized 2.5G template */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x047e, 0x3939);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x047f, 0x3939);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0480, 0x3939);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0481, 0x3939);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\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\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0340, 0x301d);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* 100M template amplitude */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x046e, 0x4545);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x046f, 0x4545);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0470, 0x4545);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0471, 0x4545);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\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\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x071f, 0x0036);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* 10M template amplitude */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x046b, 0x1818);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x046c, 0x1818);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\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\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0467, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0468, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0469, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* optimize utp 1000M performance */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x034a, 0xff03);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x00f8, 0xb3ff);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0059, 0x4040);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x032c, 0x5094);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x032d, 0xd094);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x032e, 0x5308);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0322, 0x6440);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x04d3, 0x5220);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x04d2, 0x5220);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* optimized EMC CS */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x00c8, 0xffff);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x00be, 0x6406);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0x037a, 0x40ff);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\t/* optimized EMC RE */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x0482, 0xffff);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d5, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d6, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d7, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2d8, 0x1f1f);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa218, 0x006e);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xfff0);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xfff0);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xffff);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xffff);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\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+\tstruct yt8824_shared_priv *shared_priv;\n+\tint ret = 0, old_page;\n+\tint val_1, val_2, val_3, tmp;\n+\tu16 data = 0;\n+\tint port;\n+\n+\tshared_priv = phy_package_get_priv(phydev);\n+\tport = phydev-\u003emdio.addr - shared_priv-\u003eoffset;\n+\tif (port \u003c 0)\n+\t\treturn -EINVAL;\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+\tval_1 = ytphy_read_top_ext(phydev, 0xa13e);\n+\tif (val_1 \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tval_2 = ytphy_read_top_ext(phydev, 0xa13f);\n+\tif (val_2 \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tval_3 = ytphy_read_top_ext(phydev, 0xa140);\n+\tif (val_3 \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tif (port == 0) {\n+\t\t/* Serdes optimization */\n+\t\tret = ytphy_write_ext(phydev, 0x04be, 0x000d);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x049f, 0x7ded);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x04a9, 0x009f);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* analog CDR */\n+\t\tret = ytphy_write_ext(phydev, 0x0406, 0x0800);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* optimized VCO */\n+\t\tret = ytphy_write_ext(phydev, 0x0438, 0x9024);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x0439, 0x00c0);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* optimized PLL lock */\n+\t\tret = ytphy_read_ext(phydev, 0x0429);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret \u0026= ~(BIT(13) | BIT(12));\n+\t\ttmp = (val_1 \u0026 (BIT(7) | BIT(6))) \u003e\u003e 6;\n+\t\tret |= (tmp \u003c\u003c 12);\n+\t\tret = ytphy_write_ext(phydev, 0x0429, ret);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_read_ext(phydev, 0x0441);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret \u0026= ~(BIT(1) | BIT(0));\n+\t\ttmp = (val_1 \u0026 (BIT(5) | BIT(4))) \u003e\u003e 4;\n+\t\tret |= tmp;\n+\t\tret = ytphy_write_ext(phydev, 0x0441, ret);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_read_ext(phydev, 0x042b);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret \u0026= ~(BIT(13) | BIT(12));\n+\t\ttmp = (val_3 \u0026 (BIT(1) | BIT(0)));\n+\t\tret |= (tmp \u003c\u003c 12);\n+\t\tret = ytphy_write_ext(phydev, 0x042b, ret);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x043a, 0x1006);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x042a, 0xf070);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* cable length threshold */\n+\t\tret = ytphy_write_ext(phydev, 0x0491, 0x007f);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x0492, 0x7f7f);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* Serdes training threshold */\n+\t\tret = ytphy_write_ext(phydev, 0x0454, 0x0f14);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x0497, 0x0a44);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* digital eye diagram of SerDes */\n+\t\tret = ytphy_write_ext(phydev, 0x04cd, 0x0000);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* Serdes LDO */\n+\t\tret = ytphy_read_ext(phydev, 0x04b5);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret \u0026= ~(BIT(6) | BIT(5) | BIT(4));\n+\t\ttmp = (val_2 \u0026 (BIT(4) | BIT(3) | BIT(2))) \u003e\u003e 2;\n+\t\tret |= (tmp \u003c\u003c 4);\n+\t\tret = ytphy_write_ext(phydev, 0x04b5, ret);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_read_ext(phydev, 0x04b4);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret \u0026= ~(BIT(10) | BIT(9) | BIT(8));\n+\t\ttmp = (val_2 \u0026 (BIT(7) | BIT(6) | BIT(5))) \u003e\u003e 5;\n+\t\tret |= (tmp \u003c\u003c 8);\n+\t\tret = ytphy_write_ext(phydev, 0x04b4, ret);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* optimized Serdes RX */\n+\t\tret = ytphy_write_ext(phydev, 0x04af, 0x45e3);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x048a, 0x0fff);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x0408, 0x7c00);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x04d6, 0x007f);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x044f, 0xff08);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* optimized Serdes TX */\n+\t\tret = ytphy_write_ext(phydev, 0x048e, 0x7d00);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x000d, 0x0606);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* Serdes manual config */\n+\t\tret = ytphy_write_ext(phydev, 0x04b0, 0x0804);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x04b1, 0x7074);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x04af, 0x45e7);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\t/* restart calibration */\n+\t\tret = ytphy_write_ext(phydev, 0x0003, 0x5603);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x0492, 0x7fff);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x0492, 0x7f7f);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x2000, 0x0040);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\n+\t\tret = ytphy_write_ext(phydev, 0x2000, 0x0000);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\t}\n+\n+\t/* TX preamble padded to 8; RX IPG always \u003e 8 */\n+\tret = __phy_read(phydev, MII_RESV1);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\tret \u0026= ~YT8824_SDS_CFG_MIN_PRE_MASK;\n+\tret |= YT8824_SDS_TX_PRE_PADDING;\n+\tret |= YT8824_SDS_EN_FILL_PRE;\n+\tret = __phy_write(phydev, MII_RESV1, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tdata = __phy_read(phydev, MII_BMCR);\n+\tif (data \u003c 0)\n+\t\tgoto err_restore_page;\n+\tdata |= BMCR_RESET;\n+\tdata |= BMCR_ANENABLE;\n+\tret = __phy_write(phydev, MII_BMCR, data);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_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+\tstruct yt8824_shared_priv *shared_priv;\n+\tint port = 0;\n+\tint ret = 0;\n+\tint data;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tshared_priv = phy_package_get_priv(phydev);\n+\tport = phydev-\u003emdio.addr - shared_priv-\u003eoffset;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x1, 0x3);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tdata = phy_read(phydev, MII_BMCR);\n+\tif (data \u003c 0)\n+\t\treturn data;\n+\tdata |= BMCR_PDOWN;\n+\tret = phy_write(phydev, MII_BMCR, data);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tif (port == 0) {\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa20e, 0xcba);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa20a, 0xc3f1);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa20c, 0x1620);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0xa00);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0xe00);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa003, 0x3);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t}\n+\tret = ytphy_write_ext_with_lock(phydev, 0x3d0, 0x5210);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x372, 0x5038);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x37c, 0x6068);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x388, 0xa0);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x359, 0x2140);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xa2fa, 0x83);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x4e2, 0x149);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* 2.5G tempate */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x47e, 0x3939);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x47f, 0x3939);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x480, 0x3939);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x481, 0x3939);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* 1000 cable length threshold */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x336, 0xab0a);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x340, 0x301d);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* 1000 performance */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x34a, 0xff03);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xf8, 0xb3ff);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x32c, 0x5094);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x32d, 0xd094);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x32e, 0x5308);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x322, 0x6440);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x4d3, 0x5220);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x4d2, 0x5220);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* 100 tempate */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x46e, 0x4545);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x46f, 0x4545);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x470, 0x4545);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x471, 0x4545);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* 100 cable length threshold */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x30b, 0xaa1d);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x71f, 0x36);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* 10 tempate */\n+\tret = ytphy_write_ext_with_lock(phydev, 0x46b, 0x1818);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x46c, 0x1818);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* 10 tempate MAU*/\n+\tret = ytphy_write_ext_with_lock(phydev, 0x466, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x467, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x468, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x469, 0x6c6c);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* EMC CS */\n+\tret = ytphy_write_ext_with_lock(phydev, 0xc8, 0xfff);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0xbe, 0x6406);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = ytphy_write_ext_with_lock(phydev, 0x37a, 0x40ff);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* EMC RE*/\n+\tret = ytphy_write_ext_with_lock(phydev, 0x482, 0xffff);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tif (port == 0) {\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0x482, 0xffff);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa2d5, 0x1f1f);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa2d6, 0x1f1f);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa2d7, 0x1f1f);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa2d8, 0x1f1f);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa218, 0x6e);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xfff0);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xfff0);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xffff);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xffff);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t}\n+\tret = ytphy_write_ext_with_lock(phydev, 0xc, 0x41a1);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = genphy_c45_template_testmode(phydev,\n+\t\t\t\t\t YT8824_UTP_TEMPLATE_TEST_MODE1);\n+\tif (ret)\n+\t\treturn ret;\n+\tdata = phy_read(phydev, MII_BMCR);\n+\tif (data \u003c 0)\n+\t\treturn ret;\n+\tdata |= BMCR_RESET;\n+\tdata |= BMCR_ANENABLE;\n+\tret = phy_write(phydev, MII_BMCR, data);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = genphy_c45_template_testmode(phydev,\n+\t\t\t\t\t YT8824_UTP_TEMPLATE_TEST_NORMAL);\n+\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+\tint ret;\n+\n+\tif (phydev-\u003einterface == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tret = yt8824_internal_config_init_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t} else {\n+\t\tret = yt8824_extern_config_utp_init_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tret = yt8824_extern_config_sds_init_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n \t}\n+\tret = yt8824_soft_reset(phydev);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n \n-err_restore_page:\n-\treturn phy_restore_page(phydev, old_page, ret);\n+\tphydev_dbg(phydev, \"%s done, phy addr: %d\\n\",\n+\t\t __func__, phydev-\u003emdio.addr);\n+\n+\treturn 0;\n }\n \n static int yt8531_set_wol(struct phy_device *phydev,\n@@ -3066,6 +4152,373 @@ static int yt8821_resume(struct phy_device *phydev)\n \treturn yt8821_modify_utp_fiber_bmcr(phydev, BMCR_PDOWN, 0);\n }\n \n+/**\n+ * yt8824_aneg_done() - check negotiation state.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_aneg_done(struct phy_device *phydev)\n+{\n+\tint link = 0;\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+\tret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tlink = !!(ret \u0026 YTPHY_SSR_LINK);\n+\n+\tphydev_dbg(phydev, \"%s, phy addr: %d, link_utp: %d\\n\",\n+\t\t __func__, phydev-\u003emdio.addr, link);\n+\n+\treturn link;\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+ * @status: The link status, include speed, duplex and link state.\n+ * @lpa: link partner advertising.\n+ *\n+ * Returns: 1 (utp link),0 (no link) or negative errno code\n+ */\n+static int yt8824_read_status_paged(struct phy_device *phydev,\n+\t\t\t\t int *status, int *lpa)\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+\tret = phy_read(phydev, MII_LPA);\n+\t*lpa = ret;\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);\n+\t*status = ret;\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = !!(*status \u0026 YTPHY_SSR_LINK);\n+\n+\treturn ret;\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+\tint link;\n+\tint lpa;\n+\tint val;\n+\n+\tphydev-\u003epause = 0;\n+\tphydev-\u003easym_pause = 0;\n+\tphydev-\u003elink = 0;\n+\tphydev-\u003espeed = SPEED_UNKNOWN;\n+\tphydev-\u003eduplex = DUPLEX_UNKNOWN;\n+\n+\tlink = yt8824_read_status_paged(phydev,\n+\t\t\t\t\t\u0026val, \u0026lpa);\n+\tif (link \u003c 0)\n+\t\treturn link;\n+\n+\tif (link) {\n+\t\tphydev-\u003elink = 1;\n+\t\tphydev-\u003epause = !!(lpa \u0026 BIT(10));\n+\t\tphydev-\u003easym_pause = !!(lpa \u0026 BIT(11));\n+\n+\t\t/* update speed \u0026 duplex */\n+\t\tyt8821_adjust_status(phydev, val);\n+\t} else {\n+\t\tphydev-\u003elink = 0;\n+\t\tphydev-\u003epause = 0;\n+\t\tphydev-\u003easym_pause = 0;\n+\t\tphydev-\u003espeed = SPEED_UNKNOWN;\n+\t\tphydev-\u003eduplex = DUPLEX_UNKNOWN;\n+\t}\n+\n+\treturn 0;\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+\tret = phy_read(phydev, MII_BMCR);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret \u0026= ~BMCR_PDOWN;\n+\tret \u0026= ~BMCR_ISOLATE;\n+\n+\treturn phy_write(phydev, MII_BMCR, ret);\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 = 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 = phy_read(phydev, MII_BMCR);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn phy_write(phydev, MII_BMCR, ret | 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+\tint ret;\n+\n+\tif (phydev-\u003einterface == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\t/* invalid test mode */\n+\t\tret = yt8824_utp_invalid_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\t/* utp power on */\n+\t\tret = yt8824_utp_power_on(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_normal_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t} else {\n+\t\t/* invalid test mode */\n+\t\tret = yt8824_utp_invalid_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\n+\t\t/* sds isolation */\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\n+\t\t/* utp power on */\n+\t\tret = yt8824_utp_power_on(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_normal_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\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\treturn ret;\n+\t}\n+\treturn 0;\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+\treturn yt8824_power_on(phydev);\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+\tint ret;\n+\n+\tif (phydev-\u003einterface == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\t/* invalid test mode */\n+\t\tret = yt8824_utp_invalid_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\t/* utp power down */\n+\t\tret = yt8824_utp_power_down(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_normal_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t} else {\n+\t\t/* invalid test mode */\n+\t\tret = yt8824_utp_invalid_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\n+\t\t/* sds isolation */\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\n+\t\t/* utp power down */\n+\t\tret = yt8824_utp_power_down(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\n+\t\t/* normal mode */\n+\t\tret = yt8824_utp_normal_test_mode_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\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\treturn ret;\n+\t}\n+\treturn 0;\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+\treturn yt8824_power_down(phydev);\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+\tint phy_ctrl = 0;\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+\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,\n+\t\t\t\t MDIO_AN_10GBT_CTRL,\n+\t\t\t\t MDIO_AN_10GBT_CTRL_ADV2_5G,\n+\t\t\t\t phy_ctrl);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn genphy_config_aneg(phydev);\n+}\n+\n+/**\n+ * yt8824_phy_package_probe_once() - init phy packet for phy8824.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_phy_package_probe_once(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tstruct device_node *np = phy_package_get_node(phydev);\n+\tconst char *interface_mode_name;\n+\n+\tpriv-\u003einterface_mode = PHY_INTERFACE_MODE_NA;\n+\tpriv-\u003eoffset = INTERNAL_PHY8824_TOP_EXTEND_OFFSET;\n+\tif (!of_property_read_string(np, \"motorcomm,interface-mode\",\n+\t\t\t\t \u0026interface_mode_name)) {\n+\t\tif (!strcasecmp(interface_mode_name,\n+\t\t\t\tphy_modes(PHY_INTERFACE_MODE_USXGMII))) {\n+\t\t\tpriv-\u003einterface_mode = PHY_INTERFACE_MODE_USXGMII;\n+\t\t\tpriv-\u003eoffset = EXTERNAL_PHY8824_TOP_EXTEND_OFFSET;\n+\t\t} else if (!strcasecmp\n+\t\t\t\t(interface_mode_name,\n+\t\t\t\t phy_modes(PHY_INTERFACE_MODE_INTERNAL))) {\n+\t\t\tpriv-\u003einterface_mode = PHY_INTERFACE_MODE_INTERNAL;\n+\t\t\tpriv-\u003eoffset = INTERNAL_PHY8824_TOP_EXTEND_OFFSET;\n+\t\t} else {\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\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+\tstruct yt8521_priv *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+\tpriv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);\n+\tif (!priv)\n+\t\treturn -ENOMEM;\n+\n+\tphydev-\u003epriv = priv;\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@@ -3152,13 +4605,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\t\t\t= \"YT8824 Quad Ports 2.5Gbps Ethernet\",\n+\t\t.get_features\t\t= yt8821_get_features,\n+\t\t.read_page\t\t= yt8824_read_page,\n+\t\t.write_page\t\t= yt8824_write_page,\n+\t\t.probe\t\t = yt8824_probe,\n+\t\t.config_aneg\t\t= yt8824_config_aneg,\n+\t\t.aneg_done\t\t= yt8824_aneg_done,\n+\t\t.config_init\t\t= yt8824_config_init,\n+\t\t.read_status\t\t= yt8824_read_status,\n+\t\t.soft_reset\t\t= yt8824_soft_reset,\n+\t\t.suspend\t\t= yt8824_suspend,\n+\t\t.resume\t\t\t= 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@@ -3168,6 +4637,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 1269517414288..904306af6c1a7 100644\n--- a/drivers/net/phy/phy-c45.c\n+++ b/drivers/net/phy/phy-c45.c\n@@ -1283,6 +1283,23 @@ 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 Test mode 1 to Test mode 7\n+ *\n+ * Description: Set template testmode include Test mode 1 to Test mode 7\n+ *\n+ * Return: 0 on success, or a negative error code on failure (e.g. register\n+ *\tread/write error).\n+ */\n+int genphy_c45_template_testmode(struct phy_device *phydev, int test_mode)\n+{\n+\treturn phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,\n+\t\t\tMDIO_PMA_TEMPLATE_TESTMODE, test_mode);\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 11092c3175b3d..5dbc692f442d0 100644\n--- a/include/linux/phy.h\n+++ b/include/linux/phy.h\n@@ -2338,6 +2338,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, int 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 b2541c948fc1e..bcf183e008f58 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\t/* 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@@ -139,7 +140,8 @@\n #define MDIO_PMA_CTRL1_SPEED2_5G\t(MDIO_CTRL1_SPEEDSELEXT | 0x18)\n /* 5 Gb/s */\n #define MDIO_PMA_CTRL1_SPEED5G\t\t(MDIO_CTRL1_SPEEDSELEXT | 0x1c)\n-\n+/* template test mode */\n+#define MDIO_PMA_TEMPLATE_TESTMODE 0xE000\n \n /* Status register 1. */\n #define MDIO_STAT1_LPOWERABLE\t\t0x0002\t/* Low-power ability */\n"
} |
| 2/1 | 2026/08/02 08:32 | agent | patch-evaluator |
2mModel:best-expensive Args: null Results: {
"EnableConfigs": [
"MOTORCOMM_PHY",
"MDIO_MVUSB"
],
"FocusSymbols": [
"yt8824_probe",
"yt8824_config_init",
"yt8824_config_aneg",
"yt8824_aneg_done",
"yt8824_read_status",
"yt8824_soft_reset",
"yt8824_suspend",
"yt8824_resume",
"yt8824_read_page",
"yt8824_write_page",
"genphy_c45_template_testmode"
],
"Reasoning": "The patch adds support for the Motorcomm YT8824 PHY driver. It introduces a new PHY driver structure with various callbacks for probing, initialization, auto-negotiation, status reading, and power management. These functions are reachable via MDIO bus emulation (e.g., using the Marvell USB MDIO adapter driver). Fuzzing should focus on the newly added PHY driver callbacks and the exported helper `genphy_c45_template_testmode`.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). - Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU. - Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove) that are executed only during PCI hot-unplug or sysfs driver unbind operations. If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. Prefer non-static, non-inlined API entrypoint functions over internal static helper functions (which are inlined by the compiler and do not have distinct symbol addresses). 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs output array, and DO NOT add a '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: For your convenience, here is the diff of the changes:
commit e2df19e61631e3fcf366dfd29fc19a9e08227044
Author: syz-cluster <triage@syzkaller.com>
Date: Sun Aug 2 08:32:40 2026 +0000
syz-cluster: applied patch under review
diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
index 3396a38cfc0f2..868a0c9f29a7e 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -1,24 +1,33 @@
// 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/module.h>
+#include <linux/of.h>
#include <linux/phy.h>
#include <linux/property.h>
+#include "phylib.h"
+
+/* define PHY8824 top extend addr offset internal and external*/
+#define INTERNAL_PHY8824_TOP_EXTEND_OFFSET (5)
+#define EXTERNAL_PHY8824_TOP_EXTEND_OFFSET (4)
+
#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 +39,18 @@
* ------------------------------------------------------------
*/
+/* YT8824 Register Overview
+ * UTP Register space | FIBER Register space
+ * ------------------------------------------------------------
+ * | UTP MII | FIBER MII |
+ * | UTP MMD | |
+ * | UTP Extended | FIBER Extended |
+ * | UTP Top Extended | FIBER Top Extended |
+ * ------------------------------------------------------------
+ * | Common Top Extended |
+ * ------------------------------------------------------------
+ */
+
/* 0x10 ~ 0x15 , 0x1E and 0x1F are common MII registers of yt phy */
/* Specific Function Control Register */
@@ -376,6 +397,15 @@
#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_UTP_TEMPLATE_TEST_MODE1 0x2000
+#define YT8824_UTP_TEMPLATE_TEST_NORMAL 0x0000
+#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
@@ -394,6 +424,11 @@ struct yt8521_priv {
u8 reg_page;
};
+struct yt8824_shared_priv {
+ unsigned int interface_mode;
+ unsigned int offset;
+};
+
/**
* ytphy_read_ext() - read a PHY's extended register
* @phydev: a pointer to a &struct phy_device
@@ -432,6 +467,70 @@ static int ytphy_read_ext_with_lock(struct phy_device *phydev, u16 regnum)
return ret;
}
+/**
+ * ytphy_read_top_ext() - read a PHY's top extended register for YT8824
+ * @phydev: a pointer to a &struct phy_device
+ * @regnum: register number to read
+ *
+ * Returns: the value of regnum reg or negative error code
+ */
+static int ytphy_read_top_ext(struct phy_device *phydev, u16 regnum)
+{
+ int ret;
+
+ lockdep_assert_held(&phydev->mdio.bus->mdio_lock);
+ ret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);
+ if (ret < 0)
+ return ret;
+
+ return __phy_package_read(phydev, 0, YTPHY_PAGE_DATA);
+}
+
+/**
+ * ytphy_write_top_ext() - write a PHY's top extended register for YT8824
+ * @phydev: a pointer to a &struct phy_device
+ * @regnum: register number to write
+ * @val: register val to write
+ *
+ * Returns: the value of regnum reg 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: the value of regnum reg 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_restore_page;
+ ret &= ~YT8824_RSSR_SPACE_MASK;
+ ret |= (page & YT8824_RSSR_SPACE_MASK);
+ ret = ytphy_write_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG, ret);
+
+err_restore_page:
+ phy_unlock_mdio_bus(phydev);
+ return ret;
+}
+
/**
* ytphy_write_ext() - write a PHY's extended register
* @phydev: a pointer to a &struct phy_device
@@ -621,11 +720,998 @@ static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
ret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,
YTPHY_IER_WOL, 0);
if (ret < 0)
- goto err_restore_page;
+ 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_invalid_test_mode_paged() - config YT8824 to invalid test mode.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_invalid_test_mode_paged(struct phy_device *phydev)
+{
+ int ret = 0;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ return genphy_c45_template_testmode(phydev,
+ YT8824_UTP_TEMPLATE_TEST_MODE1);
+}
+
+/**
+ * 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;
+ int ret = 0;
+
+ old_page = phy_select_page(phydev, YT8824_RSSR_USXGMII_SPACE);
+ if (old_page < 0)
+ goto err_restore_page;
+
+ ret = __phy_read(phydev, MII_BMCR);
+ if (ret < 0)
+ goto err_restore_page;
+ /* isolation */
+ ret |= BMCR_ISOLATE;
+ ret = __phy_write(phydev, MII_BMCR, ret);
+ if (ret < 0)
+ goto err_restore_page;
+
+err_restore_page:
+ return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_utp_softreset_paged() - config YT8824 UTP softreset.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_softreset_paged(struct phy_device *phydev)
+{
+ int ret = 0;
+ int val;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+ ret = phy_read(phydev, MII_BMCR);
+ if (ret < 0)
+ return ret;
+ ret |= BMCR_RESET;
+ ret = phy_write(phydev, MII_BMCR, ret);
+ 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_utp_normal_test_mode_paged() - config YT8824 to normal test mode.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_normal_test_mode_paged(struct phy_device *phydev)
+{
+ int ret = 0;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ return genphy_c45_template_testmode(phydev,
+ YT8824_UTP_TEMPLATE_TEST_NORMAL);
+}
+
+/**
+ * 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)
+{
+ unsigned int retry = 12;
+ int old_page;
+ int ret = -1;
+
+ old_page = phy_select_page(phydev, YT8824_RSSR_USXGMII_SPACE);
+ if (old_page < 0)
+ goto err_restore_page;
+
+ ret = __phy_read(phydev, MII_BMCR);
+ if (ret < 0)
+ goto err_restore_page;
+
+ /* disable isolation */
+ ret &= ~BIT(10);
+ /* soft reset */
+ ret |= BMCR_RESET;
+ ret = __phy_write(phydev, MII_BMCR, ret);
+ if (ret < 0)
+ goto err_restore_page;
+ do {
+ msleep(50);
+ ret = __phy_read(phydev, MII_BMCR);
+ if (ret < 0)
+ goto err_restore_page;
+ } while ((ret & BMCR_RESET) && --retry);
+
+ if (ret & BMCR_RESET) {
+ ret = -ETIMEDOUT;
+ goto err_restore_page;
+ }
+
+err_restore_page:
+ return phy_restore_page(phydev, old_page, 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)
+{
+ int ret;
+
+ if (phydev->interface == PHY_INTERFACE_MODE_INTERNAL) {
+ /* invalid test mode */
+ ret = yt8824_utp_invalid_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+ ret = yt8824_utp_softreset_paged(phydev);
+ if (ret < 0)
+ return ret;
+ /* normal mode */
+ ret = yt8824_utp_normal_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+ } else {
+ /* invalid test mode */
+ ret = yt8824_utp_invalid_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* sds isolation */
+ ret = yt8824_sds_isolate_paged(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* utp soft reset */
+ ret = yt8824_utp_softreset_paged(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* normal mode */
+ ret = yt8824_utp_normal_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* sds soft reset and disable isolation */
+ ret = yt8824_sds_isolate_and_softreset_paged(phydev);
+ if (ret < 0)
+ return ret;
+ }
+ return 0;
+}
+
+/**
+ * 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 data = 0;
+ int ret = 0;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+ /* power down */
+ data = phy_read(phydev, MII_BMCR);
+ if (data < 0)
+ return data;
+ data |= BMCR_PDOWN;
+ ret = phy_write(phydev, MII_BMCR, data);
+ if (ret < 0)
+ return ret;
+
+ /* pll calibration */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0001, 0x0003);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20e, 0x0cba);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20a, 0xc3f1);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20c, 0x1620);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0x0a00);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0x0e00);
+ if (ret < 0)
+ return ret;
+
+ /* optimization utp */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0001, 0x0003);
+ if (ret < 0)
+ return ret;
+
+ /* enable nibble */
+ ret = ytphy_write_ext_with_lock(phydev, 0xa003, 0x0003);
+ if (ret < 0)
+ return ret;
+
+ /* idle err detect enable */
+ ret = ytphy_write_ext_with_lock(phydev, 0x03d0, 0x5210);
+ if (ret < 0)
+ return ret;
+
+ /* optimized 2.5G long cable performance */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0372, 0x5038);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x037c, 0x6068);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0388, 0x00a0);
+ if (ret < 0)
+ return ret;
+
+ /* optimized fast retrain */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0359, 0x2140);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x000c, 0xc1a0);
+ if (ret < 0)
+ return ret;
+
+ /* 2.5G template tone */
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2fa, 0x0083);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x04e2, 0x0149);
+ if (ret < 0)
+ return ret;
+
+ /* optimized 2.5G template */
+ ret = ytphy_write_ext_with_lock(phydev, 0x047e, 0x3939);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x047f, 0x3939);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0480, 0x3939);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0481, 0x3939);
+ if (ret < 0)
+ return ret;
+
+ /* optimized 1000M cable length threshold */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0336, 0xab0a);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0340, 0x301d);
+ if (ret < 0)
+ return ret;
+
+ /* 100M template amplitude */
+ ret = ytphy_write_ext_with_lock(phydev, 0x046e, 0x4545);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x046f, 0x4545);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0470, 0x4545);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0471, 0x4545);
+ if (ret < 0)
+ return ret;
+
+ /* optimized 100M cable length threshold */
+ ret = ytphy_write_ext_with_lock(phydev, 0x030b, 0xaa1d);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x071f, 0x0036);
+ if (ret < 0)
+ return ret;
+
+ /* 10M template amplitude */
+ ret = ytphy_write_ext_with_lock(phydev, 0x046b, 0x1818);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x046c, 0x1818);
+ if (ret < 0)
+ return ret;
+
+ /* optimized 10M cable length threshold */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0466, 0x6c6c);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0467, 0x6c6c);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0468, 0x6c6c);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0469, 0x6c6c);
+ if (ret < 0)
+ return ret;
+
+ /* optimize utp 1000M performance */
+ ret = ytphy_write_ext_with_lock(phydev, 0x034a, 0xff03);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x00f8, 0xb3ff);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0059, 0x4040);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x032c, 0x5094);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x032d, 0xd094);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x032e, 0x5308);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x0322, 0x6440);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x04d3, 0x5220);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x04d2, 0x5220);
+ if (ret < 0)
+ return ret;
+
+ /* optimized EMC CS */
+ ret = ytphy_write_ext_with_lock(phydev, 0x00c8, 0xffff);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x00be, 0x6406);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0x037a, 0x40ff);
+ if (ret < 0)
+ return ret;
+
+ /* optimized EMC RE */
+ ret = ytphy_write_ext_with_lock(phydev, 0x0482, 0xffff);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d5, 0x1f1f);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d6, 0x1f1f);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d7, 0x1f1f);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d8, 0x1f1f);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa218, 0x006e);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xfff0);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xfff0);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xffff);
+ if (ret < 0)
+ return ret;
+
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xffff);
+ if (ret < 0)
+ return ret;
+
+ 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)
+{
+ struct yt8824_shared_priv *shared_priv;
+ int ret = 0, old_page;
+ int val_1, val_2, val_3, tmp;
+ u16 data = 0;
+ int port;
+
+ shared_priv = phy_package_get_priv(phydev);
+ port = phydev->mdio.addr - shared_priv->offset;
+ if (port < 0)
+ return -EINVAL;
+ old_page = phy_select_page(phydev, YT8824_RSSR_USXGMII_SPACE);
+ if (old_page < 0)
+ goto err_restore_page;
+
+ /* read efuse */
+ val_1 = ytphy_read_top_ext(phydev, 0xa13e);
+ if (val_1 < 0)
+ goto err_restore_page;
+
+ val_2 = ytphy_read_top_ext(phydev, 0xa13f);
+ if (val_2 < 0)
+ goto err_restore_page;
+
+ val_3 = ytphy_read_top_ext(phydev, 0xa140);
+ if (val_3 < 0)
+ goto err_restore_page;
+
+ if (port == 0) {
+ /* 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;
+
+ data = __phy_read(phydev, MII_BMCR);
+ if (data < 0)
+ goto err_restore_page;
+ data |= BMCR_RESET;
+ data |= BMCR_ANENABLE;
+ ret = __phy_write(phydev, MII_BMCR, data);
+ if (ret < 0)
+ goto err_restore_page;
+
+err_restore_page:
+ 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)
+{
+ struct yt8824_shared_priv *shared_priv;
+ int port = 0;
+ int ret = 0;
+ int data;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ shared_priv = phy_package_get_priv(phydev);
+ port = phydev->mdio.addr - shared_priv->offset;
+ ret = ytphy_write_ext_with_lock(phydev, 0x1, 0x3);
+ if (ret < 0)
+ return ret;
+ data = phy_read(phydev, MII_BMCR);
+ if (data < 0)
+ return data;
+ data |= BMCR_PDOWN;
+ ret = phy_write(phydev, MII_BMCR, data);
+ if (ret < 0)
+ return ret;
+ if (port == 0) {
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20e, 0xcba);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20a, 0xc3f1);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa20c, 0x1620);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0xa00);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2b6, 0xe00);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa003, 0x3);
+ if (ret < 0)
+ return ret;
+ }
+ ret = ytphy_write_ext_with_lock(phydev, 0x3d0, 0x5210);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x372, 0x5038);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x37c, 0x6068);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x388, 0xa0);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x359, 0x2140);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2fa, 0x83);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x4e2, 0x149);
+ if (ret < 0)
+ return ret;
+ /* 2.5G tempate */
+ ret = ytphy_write_ext_with_lock(phydev, 0x47e, 0x3939);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x47f, 0x3939);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x480, 0x3939);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x481, 0x3939);
+ if (ret < 0)
+ return ret;
+ /* 1000 cable length threshold */
+ ret = ytphy_write_ext_with_lock(phydev, 0x336, 0xab0a);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x340, 0x301d);
+ if (ret < 0)
+ return ret;
+ /* 1000 performance */
+ ret = ytphy_write_ext_with_lock(phydev, 0x34a, 0xff03);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xf8, 0xb3ff);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x32c, 0x5094);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x32d, 0xd094);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x32e, 0x5308);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x322, 0x6440);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x4d3, 0x5220);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x4d2, 0x5220);
+ if (ret < 0)
+ return ret;
+ /* 100 tempate */
+ ret = ytphy_write_ext_with_lock(phydev, 0x46e, 0x4545);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x46f, 0x4545);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x470, 0x4545);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x471, 0x4545);
+ if (ret < 0)
+ return ret;
+ /* 100 cable length threshold */
+ ret = ytphy_write_ext_with_lock(phydev, 0x30b, 0xaa1d);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x71f, 0x36);
+ if (ret < 0)
+ return ret;
+ /* 10 tempate */
+ ret = ytphy_write_ext_with_lock(phydev, 0x46b, 0x1818);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x46c, 0x1818);
+ if (ret < 0)
+ return ret;
+ /* 10 tempate MAU*/
+ ret = ytphy_write_ext_with_lock(phydev, 0x466, 0x6c6c);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x467, 0x6c6c);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x468, 0x6c6c);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x469, 0x6c6c);
+ if (ret < 0)
+ return ret;
+ /* EMC CS */
+ ret = ytphy_write_ext_with_lock(phydev, 0xc8, 0xfff);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xbe, 0x6406);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0x37a, 0x40ff);
+ if (ret < 0)
+ return ret;
+ /* EMC RE*/
+ ret = ytphy_write_ext_with_lock(phydev, 0x482, 0xffff);
+ if (ret < 0)
+ return ret;
+ if (port == 0) {
+ ret = ytphy_write_ext_with_lock(phydev, 0x482, 0xffff);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d5, 0x1f1f);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d6, 0x1f1f);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d7, 0x1f1f);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa2d8, 0x1f1f);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa218, 0x6e);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xfff0);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xfff0);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01d, 0xffff);
+ if (ret < 0)
+ return ret;
+ ret = ytphy_write_ext_with_lock(phydev, 0xa01e, 0xffff);
+ if (ret < 0)
+ return ret;
+ }
+ ret = ytphy_write_ext_with_lock(phydev, 0xc, 0x41a1);
+ if (ret < 0)
+ return ret;
+ ret = genphy_c45_template_testmode(phydev,
+ YT8824_UTP_TEMPLATE_TEST_MODE1);
+ if (ret)
+ return ret;
+ data = phy_read(phydev, MII_BMCR);
+ if (data < 0)
+ return ret;
+ data |= BMCR_RESET;
+ data |= BMCR_ANENABLE;
+ ret = phy_write(phydev, MII_BMCR, data);
+ if (ret < 0)
+ return ret;
+ ret = genphy_c45_template_testmode(phydev,
+ YT8824_UTP_TEMPLATE_TEST_NORMAL);
+
+ 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)
+{
+ int ret;
+
+ if (phydev->interface == PHY_INTERFACE_MODE_INTERNAL) {
+ ret = yt8824_internal_config_init_paged(phydev);
+ if (ret < 0)
+ return ret;
+ } else {
+ ret = yt8824_extern_config_utp_init_paged(phydev);
+ if (ret < 0)
+ return ret;
+ ret = yt8824_extern_config_sds_init_paged(phydev);
+ if (ret < 0)
+ return ret;
}
+ ret = yt8824_soft_reset(phydev);
+ if (ret < 0)
+ return ret;
-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 0;
}
static int yt8531_set_wol(struct phy_device *phydev,
@@ -3066,6 +4152,373 @@ static int yt8821_resume(struct phy_device *phydev)
return yt8821_modify_utp_fiber_bmcr(phydev, BMCR_PDOWN, 0);
}
+/**
+ * yt8824_aneg_done() - check negotiation state.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_aneg_done(struct phy_device *phydev)
+{
+ int link = 0;
+ int ret = 0;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ ret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);
+ if (ret < 0)
+ return ret;
+ link = !!(ret & YTPHY_SSR_LINK);
+
+ phydev_dbg(phydev, "%s, phy addr: %d, link_utp: %d\n",
+ __func__, phydev->mdio.addr, link);
+
+ return link;
+}
+
+/**
+ * yt8824_read_status_paged() - determines the speed and duplex of one page
+ * @phydev: a pointer to a &struct phy_device
+ * @status: The link status, include speed, duplex and link state.
+ * @lpa: link partner advertising.
+ *
+ * Returns: 1 (utp link),0 (no link) or negative errno code
+ */
+static int yt8824_read_status_paged(struct phy_device *phydev,
+ int *status, int *lpa)
+{
+ int ret = 0;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ ret = phy_read(phydev, MII_LPA);
+ *lpa = ret;
+ if (ret < 0)
+ return ret;
+
+ ret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);
+ *status = ret;
+ if (ret < 0)
+ return ret;
+
+ ret = !!(*status & YTPHY_SSR_LINK);
+
+ return ret;
+}
+
+/**
+ * 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)
+{
+ int link;
+ int lpa;
+ int val;
+
+ phydev->pause = 0;
+ phydev->asym_pause = 0;
+ phydev->link = 0;
+ phydev->speed = SPEED_UNKNOWN;
+ phydev->duplex = DUPLEX_UNKNOWN;
+
+ link = yt8824_read_status_paged(phydev,
+ &val, &lpa);
+ if (link < 0)
+ return link;
+
+ if (link) {
+ phydev->link = 1;
+ phydev->pause = !!(lpa & BIT(10));
+ phydev->asym_pause = !!(lpa & BIT(11));
+
+ /* update speed & duplex */
+ yt8821_adjust_status(phydev, val);
+ } else {
+ phydev->link = 0;
+ phydev->pause = 0;
+ phydev->asym_pause = 0;
+ phydev->speed = SPEED_UNKNOWN;
+ phydev->duplex = DUPLEX_UNKNOWN;
+ }
+
+ return 0;
+}
+
+/**
+ * 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;
+
+ ret = phy_read(phydev, MII_BMCR);
+ if (ret < 0)
+ return ret;
+
+ ret &= ~BMCR_PDOWN;
+ ret &= ~BMCR_ISOLATE;
+
+ return phy_write(phydev, MII_BMCR, ret);
+}
+
+/**
+ * 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 = 0;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ ret = phy_read(phydev, MII_BMCR);
+ if (ret < 0)
+ return ret;
+
+ return phy_write(phydev, MII_BMCR, ret | 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)
+{
+ int ret;
+
+ if (phydev->interface == PHY_INTERFACE_MODE_INTERNAL) {
+ /* invalid test mode */
+ ret = yt8824_utp_invalid_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+ /* utp power on */
+ ret = yt8824_utp_power_on(phydev);
+ if (ret < 0)
+ return ret;
+ /* normal mode */
+ ret = yt8824_utp_normal_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+ } else {
+ /* invalid test mode */
+ ret = yt8824_utp_invalid_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* sds isolation */
+ ret = yt8824_sds_isolate_paged(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* utp power on */
+ ret = yt8824_utp_power_on(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* normal mode */
+ ret = yt8824_utp_normal_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* sds soft reset and disable isolation */
+ ret = yt8824_sds_isolate_and_softreset_paged(phydev);
+ if (ret < 0)
+ return ret;
+ }
+ return 0;
+}
+
+/**
+ * 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)
+{
+ return yt8824_power_on(phydev);
+}
+
+/**
+ * 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)
+{
+ int ret;
+
+ if (phydev->interface == PHY_INTERFACE_MODE_INTERNAL) {
+ /* invalid test mode */
+ ret = yt8824_utp_invalid_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+ /* utp power down */
+ ret = yt8824_utp_power_down(phydev);
+ if (ret < 0)
+ return ret;
+ /* normal mode */
+ ret = yt8824_utp_normal_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+ } else {
+ /* invalid test mode */
+ ret = yt8824_utp_invalid_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* sds isolation */
+ ret = yt8824_sds_isolate_paged(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* utp power down */
+ ret = yt8824_utp_power_down(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* normal mode */
+ ret = yt8824_utp_normal_test_mode_paged(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* sds soft reset and disable isolation */
+ ret = yt8824_sds_isolate_and_softreset_paged(phydev);
+ if (ret < 0)
+ return ret;
+ }
+ return 0;
+}
+
+/**
+ * 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)
+{
+ return yt8824_power_down(phydev);
+}
+
+/**
+ * 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)
+{
+ int phy_ctrl = 0;
+ int ret = 0;
+
+ ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+ if (ret < 0)
+ return ret;
+
+ 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)
+ return ret;
+
+ return genphy_config_aneg(phydev);
+}
+
+/**
+ * yt8824_phy_package_probe_once() - init phy packet for phy8824.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_phy_package_probe_once(struct phy_device *phydev)
+{
+ struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+ struct device_node *np = phy_package_get_node(phydev);
+ const char *interface_mode_name;
+
+ priv->interface_mode = PHY_INTERFACE_MODE_NA;
+ priv->offset = INTERNAL_PHY8824_TOP_EXTEND_OFFSET;
+ if (!of_property_read_string(np, "motorcomm,interface-mode",
+ &interface_mode_name)) {
+ if (!strcasecmp(interface_mode_name,
+ phy_modes(PHY_INTERFACE_MODE_USXGMII))) {
+ priv->interface_mode = PHY_INTERFACE_MODE_USXGMII;
+ priv->offset = EXTERNAL_PHY8824_TOP_EXTEND_OFFSET;
+ } else if (!strcasecmp
+ (interface_mode_name,
+ phy_modes(PHY_INTERFACE_MODE_INTERNAL))) {
+ priv->interface_mode = PHY_INTERFACE_MODE_INTERNAL;
+ priv->offset = INTERNAL_PHY8824_TOP_EXTEND_OFFSET;
+ } else {
+ return -EINVAL;
+ }
+ }
+ return 0;
+}
+
+/**
+ * yt8824_probe() - phy8824 probe.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_probe(struct phy_device *phydev)
+{
+ struct device *dev = &phydev->mdio.dev;
+ struct yt8824_shared_priv *shared_priv;
+ struct yt8521_priv *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;
+ }
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ phydev->priv = priv;
+
+ return 0;
+}
+
static struct phy_driver motorcomm_phy_drvs[] = {
{
PHY_ID_MATCH_EXACT(PHY_ID_YT8511),
@@ -3152,13 +4605,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 = yt8821_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[] = {
@@ -3168,6 +4637,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 1269517414288..904306af6c1a7 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -1283,6 +1283,23 @@ 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 Test mode 1 to Test mode 7
+ *
+ * Description: Set template testmode include Test mode 1 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, int test_mode)
+{
+ return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,
+ MDIO_PMA_TEMPLATE_TESTMODE, test_mode);
+}
+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 11092c3175b3d..5dbc692f442d0 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2338,6 +2338,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, int 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 b2541c948fc1e..bcf183e008f58 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 */
@@ -139,7 +140,8 @@
#define MDIO_PMA_CTRL1_SPEED2_5G (MDIO_CTRL1_SPEEDSELEXT | 0x18)
/* 5 Gb/s */
#define MDIO_PMA_CTRL1_SPEED5G (MDIO_CTRL1_SPEEDSELEXT | 0x1c)
-
+/* template test mode */
+#define MDIO_PMA_TEMPLATE_TESTMODE 0xE000
/* Status register 1. */
#define MDIO_STAT1_LPOWERABLE 0x0002 /* Low-power ability */
|
| 3/2 | 2026/08/02 08:32 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 22336 output: 19 thoughts: 313 Thoughts: **Reaching the New PHY Driver in QEMU with Syzkaller** Okay, so we've got this patch adding Motorcomm YT8824 PHY driver support. It also includes this helper function, `genphy_c45_template_testmode`, in `phy-c45.c`. My immediate thought is, "Can we actually *reach* this thing in a QEMU environment?" PHY drivers, classically, are brought up through the MDIO bus. So the next logical question is: can we get this PHY emulated within QEMU? The usual dance is reading the PHY ID from those MDIO registers during the probe process. The real challenge is: can syzkaller help us get there? Does it have any capability to emulate MDIO devices? Or is there some other trick to trigger PHY probing without relying on a real MDIO bus? Hang on, didn't I vaguely recall something about syzkaller having *some* MDIO injection possibilities? I should really check if there are any syzkaller descriptions specifically for MDIO or PHY. Hmmm, right, syzkaller mostly relies on `tun`/`tap` or `veth` interfaces, so pure MDIO is probably out. Wait, didn't we have things like `vhci` for USB and `mac80211_hwsim` for wifi that could be used with syzkaller? Is there anything like an MDIO emulator *within the kernel itself* that syzkaller could leverage? Maybe a `drivers/net/phy/mdio-mockup.c` type thing? Need to do some kernel spelunking. Alright, time to get serious. Let's dig into the possibility of fuzzing MDIO itself. I need to run some specific searches for `mdio` or `phy` fuzzing. See what comes up. |
| 4/2 | 2026/08/02 08:32 | tool | grepper |
0mError:no matches Args: {
"Expression": "mdio.*mockup"
}Results: {
"error": "no matches"
} |
| 5/2 | 2026/08/02 08:32 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 23078 output: 24 thoughts: 19 Thoughts: Here's my thought process, as it stands: **Looking for Placeholder PHY Drivers** Okay, I need to investigate the potential for mock or dummy drivers within the network PHY (Physical Layer) driver space. The logical place to start that investigation is `drivers/net/phy/`. That directory is where I'd expect to find these sorts of placeholder implementations, if they exist within the kernel's source tree. I'll need to poke around there to get a better handle on the testing strategy within the PHY component. Hopefully there's something readily apparent in the folder. |
| 6/2 | 2026/08/02 08:32 | tool | codesearch-dir-index |
0mArgs:{
"Dir": "drivers/net/phy/"
}Results: {
"Files": [
"adin.c",
"adin1100.c",
"adin1140-phy.c",
"air_an8801.c",
"air_en8811h.c",
"air_phy_lib.c",
"air_phy_lib.h",
"amd.c",
"as21xxx.c",
"ax88796b.c",
"ax88796b_rust.rs",
"bcm-cygnus.c",
"bcm-phy-lib.c",
"bcm-phy-lib.h",
"bcm-phy-ptp.c",
"bcm54140.c",
"bcm63xx.c",
"bcm7xxx.c",
"bcm84881.c",
"bcm87xx.c",
"broadcom.c",
"cicada.c",
"cortina.c",
"davicom.c",
"dp83640.c",
"dp83640_reg.h",
"dp83822.c",
"dp83848.c",
"dp83867.c",
"dp83869.c",
"dp83tc811.c",
"dp83td510.c",
"dp83tg720.c",
"et1011c.c",
"fixed_phy.c",
"icplus.c",
"intel-xway.c",
"linkmode.c",
"lxt.c",
"marvell-88q2xxx.c",
"marvell-88x2222.c",
"marvell.c",
"marvell10g.c",
"mdio-open-alliance.h",
"mdio_bus.c",
"mdio_bus_provider.c",
"mdio_device.c",
"mdio_devres.c",
"meson-gxl.c",
"micrel.c",
"microchip.c",
"microchip_rds_ptp.c",
"microchip_rds_ptp.h",
"microchip_t1.c",
"microchip_t1s.c",
"mii_timestamper.c",
"motorcomm.c",
"mxl-86110.c",
"mxl-gpy.c",
"national.c",
"ncn26000.c",
"nxp-c45-tja11xx-macsec.c",
"nxp-c45-tja11xx.c",
"nxp-c45-tja11xx.h",
"nxp-cbtx.c",
"nxp-tja11xx.c",
"open_alliance_helpers.c",
"open_alliance_helpers.h",
"phy-c45.c",
"phy-caps.h",
"phy-core.c",
"phy.c",
"phy_caps.c",
"phy_device.c",
"phy_led_triggers.c",
"phy_link_topology.c",
"phy_package.c",
"phy_port.c",
"phylib-internal.h",
"phylib.h",
"phylink.c",
"qsemi.c",
"qt2025.rs",
"rockchip.c",
"sfp-bus.c",
"sfp.c",
"sfp.h",
"smsc.c",
"ste10Xp.c",
"stubs.c",
"swphy.c",
"swphy.h",
"teranetics.c",
"uPD60620.c",
"vitesse.c",
"xilinx_gmii2rgmii.c"
],
"Subdirs": [
"aquantia",
"mediatek",
"mscc",
"qcom",
"realtek"
]
} |
| 7/2 | 2026/08/02 08:32 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 24230 output: 24 thoughts: 61 Thoughts: **MDIO Device Emulation Exploration** Okay, so I'm trying to figure out how to emulate MDIO devices. My immediate thought is, can this even be done? Then I remember that I saw `fixed_phy.c` somewhere, and that's likely for fixed PHYs, which isn't quite what I'm after. But that gets me thinking about syzkaller. Could it potentially generate a dummy MDIO bus and then attach a PHY to it? That would be ideal for testing. Time to see if there are any syzlang definitions for MDIO out there. That would give me a starting point. |
| 8/2 | 2026/08/02 08:32 | tool | grepper |
0mArgs:{
"Expression": "mdio",
"PathPrefix": "net/"
}Results: {
"Output": "net/dsa/dsa.c=622=static int dsa_switch_setup(struct dsa_switch *ds)\n--\nnet/dsa/dsa.c-654-\tif (!ds-\u003euser_mii_bus \u0026\u0026 ds-\u003eops-\u003ephy_read) {\nnet/dsa/dsa.c:655:\t\tds-\u003euser_mii_bus = mdiobus_alloc();\nnet/dsa/dsa.c-656-\t\tif (!ds-\u003euser_mii_bus) {\n--\nnet/dsa/dsa.c-662-\nnet/dsa/dsa.c:663:\t\terr = mdiobus_register(ds-\u003euser_mii_bus);\nnet/dsa/dsa.c-664-\t\tif (err \u003c 0)\n--\nnet/dsa/dsa.c-674-\tif (ds-\u003euser_mii_bus \u0026\u0026 ds-\u003eops-\u003ephy_read)\nnet/dsa/dsa.c:675:\t\tmdiobus_free(ds-\u003euser_mii_bus);\nnet/dsa/dsa.c-676-teardown:\n--\nnet/dsa/dsa.c=686=static void dsa_switch_teardown(struct dsa_switch *ds)\n--\nnet/dsa/dsa.c-693-\tif (ds-\u003euser_mii_bus \u0026\u0026 ds-\u003eops-\u003ephy_read) {\nnet/dsa/dsa.c:694:\t\tmdiobus_unregister(ds-\u003euser_mii_bus);\nnet/dsa/dsa.c:695:\t\tmdiobus_free(ds-\u003euser_mii_bus);\nnet/dsa/dsa.c-696-\t\tds-\u003euser_mii_bus = NULL;\n--\nnet/dsa/port.c-11-#include \u003clinux/notifier.h\u003e\nnet/dsa/port.c:12:#include \u003clinux/of_mdio.h\u003e\nnet/dsa/port.c-13-#include \u003clinux/of_net.h\u003e\n--\nnet/dsa/port.c=1726=static const char * const dsa_switches_apply_workarounds[] = {\n--\nnet/dsa/port.c-1796-#if IS_ENABLED(CONFIG_NET_DSA_SMSC_LAN9303_MDIO)\nnet/dsa/port.c:1797:\t\"smsc,lan9303-mdio\",\nnet/dsa/port.c-1798-#endif\n--\nnet/dsa/user.c-13-#include \u003clinux/of_net.h\u003e\nnet/dsa/user.c:14:#include \u003clinux/of_mdio.h\u003e\nnet/dsa/user.c:15:#include \u003clinux/mdio.h\u003e\nnet/dsa/user.c-16-#include \u003cnet/netdev_lock.h\u003e\n--\nnet/dsa/user.c=2638=static int dsa_user_phy_connect(struct net_device *user_dev, int addr,\n--\nnet/dsa/user.c-2643-\nnet/dsa/user.c:2644:\tuser_dev-\u003ephydev = mdiobus_get_phy(ds-\u003euser_mii_bus, addr);\nnet/dsa/user.c-2645-\tif (!user_dev-\u003ephydev) {\n--\nnet/ethtool/common.c=587=convert_legacy_settings_to_link_ksettings(\n--\nnet/ethtool/common.c-621-\t\t= legacy_settings-\u003eautoneg;\nnet/ethtool/common.c:622:\tlink_ksettings-\u003ebase.mdio_support\nnet/ethtool/common.c:623:\t\t= legacy_settings-\u003emdio_support;\nnet/ethtool/common.c-624-\tlink_ksettings-\u003ebase.eth_tp_mdix\n--\nnet/ethtool/ioctl.c=382=convert_link_ksettings_to_legacy_settings(\n--\nnet/ethtool/ioctl.c-412-\t\t= link_ksettings-\u003ebase.autoneg;\nnet/ethtool/ioctl.c:413:\tlegacy_settings-\u003emdio_support\nnet/ethtool/ioctl.c:414:\t\t= link_ksettings-\u003ebase.mdio_support;\nnet/ethtool/ioctl.c-415-\tlegacy_settings-\u003eeth_tp_mdix\n--\nnet/ethtool/phy.c=70=static int phy_prepare_data(const struct ethnl_req_info *req_info,\n--\nnet/ethtool/phy.c-91-\nnet/ethtool/phy.c:92:\trep_data-\u003ename = kstrdup(dev_name(\u0026phydev-\u003emdio.dev), GFP_KERNEL);\nnet/ethtool/phy.c-93-\tif (!rep_data-\u003ename)\n"
} |
| 9/2 | 2026/08/02 08:32 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 25703 output: 29 thoughts: 87 Thoughts: **My Syzkaller Investigation** Okay, so I'm hitting a roadblock. It just hit me that syzkaller doesn't offer a direct method to emulate these PHYs arbitrarily. Damn. That throws a wrench in the works. My goal is to get to `yt8824_probe`, but I'm realizing the constraints. I know it needs an MDIO bus and a specific PHY ID. The immediate issue, of course, is that unless syzkaller can configure a virtual MDIO bus to report that particular PHY ID, it's a dead end. I need to figure out if there is even a virtual MDIO bus I can use within the tool to work with. Time to check if any of the underlying infrastructure provides a solution. |
| 10/2 | 2026/08/02 08:33 | tool | grepper |
0mError:no matches Args: {
"Expression": "mdio.*mockup",
"PathPrefix": "drivers/net/"
}Results: {
"error": "no matches"
} |
| 11/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 25992 output: 25 thoughts: 13 Thoughts: Here's my thought process, summarized as you requested: **Navigating the Network Driver Landscape** Okay, so I need to find something specific, likely related to media-independent interface (MDIO) interaction within the network stack. My first instinct, given my experience, is to head directly into the kernel source tree. I know that network driver code is typically well-organized within the `drivers/net/` directory. Given the specific mention of MDIO, I'm going to drill down into the `mdio` subdirectory within that. That seems like the most logical starting point for investigating the relevant code. Time to navigate there and see what I can find. Let's start with `drivers/net/mdio/` and go from there. |
| 12/2 | 2026/08/02 08:33 | tool | codesearch-dir-index |
0mArgs:{
"Dir": "drivers/net/mdio/"
}Results: {
"Files": [
"acpi_mdio.c",
"fwnode_mdio.c",
"mdio-airoha.c",
"mdio-aspeed.c",
"mdio-bcm-iproc.c",
"mdio-bcm-unimac.c",
"mdio-bitbang.c",
"mdio-cavium.c",
"mdio-cavium.h",
"mdio-gpio.c",
"mdio-hisi-femac.c",
"mdio-i2c.c",
"mdio-ipq4019.c",
"mdio-ipq8064.c",
"mdio-moxart.c",
"mdio-mscc-miim.c",
"mdio-mux-bcm-iproc.c",
"mdio-mux-bcm6368.c",
"mdio-mux-gpio.c",
"mdio-mux-meson-g12a.c",
"mdio-mux-meson-gxl.c",
"mdio-mux-mmioreg.c",
"mdio-mux-multiplexer.c",
"mdio-mux.c",
"mdio-mvusb.c",
"mdio-octeon.c",
"mdio-pic64hpsc.c",
"mdio-realtek-rtl9300.c",
"mdio-regmap.c",
"mdio-sun4i.c",
"mdio-thunder.c",
"mdio-xgene.c",
"of_mdio.c"
],
"Subdirs": null
} |
| 13/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 26589 output: 30 thoughts: 426 Thoughts: **Emulating Marvell USB MDIO with Syzkaller** Okay, so I'm looking at these MDIO drivers: `mdio-mvusb.c`, `mdio-gpio.c`, and `mdio-i2c.c`. The question is, can Syzkaller help me emulate this? I know Syzkaller uses `vhci` for USB emulation, which is promising. But `mdio-mvusb.c` specifically targets Marvell USB MDIO. Does Syzkaller account for that? Let's see... Yes, Syzkaller does have USB fuzzing capabilities. If I can get it to emulate a USB device, it *could* register an MDIO bus. The real challenge is, how do I get it to return the precise PHY ID, `0x4f51e8b8`? That's the key. The USB device, emulated by Syzkaller, needs to respond with this ID when the MDIO bus performs read operations. Aha! Since Syzkaller controls the responses from the USB device, it *can* be configured to return `0x4f51e8b8` when the MDIO bus reads those crucial PHY ID registers, specifically MII_PHYSID1 and MII_PHYSID2. That's the critical bit! If Syzkaller can emulate a Marvell USB MDIO device, the kernel *will* register an MDIO bus. Then, the kernel will scan that bus for PHYs, and it does this by reading registers 2 and 3 (MII_PHYSID1 and MII_PHYSID2). Syzkaller can be the source of these responses, providing the expected `0x4f51e8b8` value. And if that's the case, the kernel *will* match the PHY ID and probe the `yt8824` driver! Okay, time to verify. I need to check if `mdio-mvusb.c` is enabled in typical Syzkaller configurations, or if I can enable it easily. Is there another way? What about `vhci` for I2C? Syzkaller has some I2C fuzzing, but probably not the solution I'm looking for here. What about `mac80211_hwsim`? No, that's not it. Or `netdevsim`? Does `netdevsim` have an MDIO bus? I need to look into that. |
| 14/2 | 2026/08/02 08:33 | tool | grepper |
0mError:no matches Args: {
"Expression": "mdio",
"PathPrefix": "drivers/net/netdevsim/"
}Results: {
"error": "no matches"
} |
| 15/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 27589 output: 41 thoughts: 24 Thoughts: Here's my thought process, summarized as you requested: **Diving into the `mdio-mvusb.c` Source Code** Okay, time to get my hands dirty. My first instinct is to see what's actually going on inside `mdio-mvusb.c`. The name itself hints at some kind of Media Independent Interface (MII) over USB interaction, which is a bit unusual. My immediate focus is to figure out if this driver adheres to standard USB driver conventions, or if it's employing some custom Marvell-specific protocol on top of the USB stack. I'll be looking for typical USB descriptors, endpoint configurations, and how it handles device enumeration and communication. Knowing if it leverages standard USB classes or a vendor-specific approach will fundamentally shape my understanding of its design and how it's intended to be used. |
| 16/2 | 2026/08/02 08:33 | tool | read-file |
0mArgs:{
"File": "drivers/net/mdio/mdio-mvusb.c",
"FirstLine": 1,
"LineCount": 100
}Results: {
"Contents": " 1:\t// SPDX-License-Identifier: GPL-2.0\n 2:\t\n 3:\t#include \u003clinux/kernel.h\u003e\n 4:\t#include \u003clinux/module.h\u003e\n 5:\t#include \u003clinux/of_mdio.h\u003e\n 6:\t#include \u003clinux/phy.h\u003e\n 7:\t#include \u003clinux/usb.h\u003e\n 8:\t\n 9:\t#define USB_MARVELL_VID\t0x1286\n 10:\t\n 11:\tstatic const struct usb_device_id mvusb_mdio_table[] = {\n 12:\t\t{ USB_DEVICE(USB_MARVELL_VID, 0x1fa4) },\n 13:\t\n 14:\t\t{}\n 15:\t};\n 16:\tMODULE_DEVICE_TABLE(usb, mvusb_mdio_table);\n 17:\t\n 18:\tenum {\n 19:\t\tMVUSB_CMD_PREAMBLE0,\n 20:\t\tMVUSB_CMD_PREAMBLE1,\n 21:\t\tMVUSB_CMD_ADDR,\n 22:\t\tMVUSB_CMD_VAL,\n 23:\t};\n 24:\t\n 25:\tstruct mvusb_mdio {\n 26:\t\tstruct usb_device *udev;\n 27:\t\tstruct mii_bus *mdio;\n 28:\t\n 29:\t\t__le16 buf[4];\n 30:\t};\n 31:\t\n 32:\tstatic int mvusb_mdio_read(struct mii_bus *mdio, int dev, int reg)\n 33:\t{\n 34:\t\tstruct mvusb_mdio *mvusb = mdio-\u003epriv;\n 35:\t\tint err, alen;\n 36:\t\n 37:\t\tmvusb-\u003ebuf[MVUSB_CMD_ADDR] = cpu_to_le16(0xa400 | (dev \u003c\u003c 5) | reg);\n 38:\t\n 39:\t\terr = usb_bulk_msg(mvusb-\u003eudev, usb_sndbulkpipe(mvusb-\u003eudev, 2),\n 40:\t\t\t\t mvusb-\u003ebuf, 6, \u0026alen, 100);\n 41:\t\tif (err)\n 42:\t\t\treturn err;\n 43:\t\n 44:\t\terr = usb_bulk_msg(mvusb-\u003eudev, usb_rcvbulkpipe(mvusb-\u003eudev, 6),\n 45:\t\t\t\t \u0026mvusb-\u003ebuf[MVUSB_CMD_VAL], 2, \u0026alen, 100);\n 46:\t\tif (err)\n 47:\t\t\treturn err;\n 48:\t\n 49:\t\treturn le16_to_cpu(mvusb-\u003ebuf[MVUSB_CMD_VAL]);\n 50:\t}\n 51:\t\n 52:\tstatic int mvusb_mdio_write(struct mii_bus *mdio, int dev, int reg, u16 val)\n 53:\t{\n 54:\t\tstruct mvusb_mdio *mvusb = mdio-\u003epriv;\n 55:\t\tint alen;\n 56:\t\n 57:\t\tmvusb-\u003ebuf[MVUSB_CMD_ADDR] = cpu_to_le16(0x8000 | (dev \u003c\u003c 5) | reg);\n 58:\t\tmvusb-\u003ebuf[MVUSB_CMD_VAL] = cpu_to_le16(val);\n 59:\t\n 60:\t\treturn usb_bulk_msg(mvusb-\u003eudev, usb_sndbulkpipe(mvusb-\u003eudev, 2),\n 61:\t\t\t\t mvusb-\u003ebuf, 8, \u0026alen, 100);\n 62:\t}\n 63:\t\n 64:\tstatic int mvusb_mdio_probe(struct usb_interface *interface,\n 65:\t\t\t\t const struct usb_device_id *id)\n 66:\t{\n 67:\t\tstruct device *dev = \u0026interface-\u003edev;\n 68:\t\tstruct mvusb_mdio *mvusb;\n 69:\t\tstruct mii_bus *mdio;\n 70:\t\n 71:\t\tmdio = devm_mdiobus_alloc_size(dev, sizeof(*mvusb));\n 72:\t\tif (!mdio)\n 73:\t\t\treturn -ENOMEM;\n 74:\t\n 75:\t\tmvusb = mdio-\u003epriv;\n 76:\t\tmvusb-\u003emdio = mdio;\n 77:\t\tmvusb-\u003eudev = interface_to_usbdev(interface);\n 78:\t\n 79:\t\t/* Reversed from USB PCAPs, no idea what these mean. */\n 80:\t\tmvusb-\u003ebuf[MVUSB_CMD_PREAMBLE0] = cpu_to_le16(0xe800);\n 81:\t\tmvusb-\u003ebuf[MVUSB_CMD_PREAMBLE1] = cpu_to_le16(0x0001);\n 82:\t\n 83:\t\tsnprintf(mdio-\u003eid, MII_BUS_ID_SIZE, \"mvusb-%s\", dev_name(dev));\n 84:\t\tmdio-\u003ename = mdio-\u003eid;\n 85:\t\tmdio-\u003eparent = dev;\n 86:\t\tmdio-\u003eread = mvusb_mdio_read;\n 87:\t\tmdio-\u003ewrite = mvusb_mdio_write;\n 88:\t\n 89:\t\tusb_set_intfdata(interface, mvusb);\n 90:\t\n 91:\t\treturn of_mdiobus_register(mdio, dev-\u003eof_node);\n 92:\t}\n 93:\t\n 94:\tstatic void mvusb_mdio_disconnect(struct usb_interface *interface)\n 95:\t{\n 96:\t\tstruct mvusb_mdio *mvusb = usb_get_intfdata(interface);\n 97:\t\n 98:\t\tmdiobus_unregister(mvusb-\u003emdio);\n 99:\t\tusb_set_intfdata(interface, NULL);\n 100:\t}\n"
} |
| 17/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 29368 output: 40 thoughts: 143 Thoughts: **MDIO Over USB: A Favorable Setup for Fuzzing** Yes! The `mdio-mvusb.c` driver is exactly what I was hoping for. It registers an MDIO bus and, crucially, translates MDIO read/write operations into USB bulk messages. This is key! If I can successfully leverage Syzkaller's USB fuzzer to emulate the specific device with vendor ID `0x1286` and product ID `0x1fa4` and have it respond to those bulk messages with the expected PHY ID, `0x4f51e8b8`, I'll be in business. But hold on... I need to consider a potential wrinkle. The code utilizes `of_mdiobus_register`. If, as I suspect, the `dev->of_node` is `NULL` for a USB device that isn't described in the Device Tree, it should gracefully fall back to a standard `mdiobus_register`. Just to be sure, I should check the implementation of `of_mdiobus_register` to confirm this assumption. Let's dig into that function definition now. |
| 18/2 | 2026/08/02 08:33 | tool | grepper |
0mArgs:{
"Expression": "of_mdiobus_register",
"PathPrefix": "drivers/net/mdio/of_mdio.c"
}Results: {
"Output": "drivers/net/mdio/of_mdio.c=44=EXPORT_SYMBOL(of_mdiobus_phy_device_register);\ndrivers/net/mdio/of_mdio.c-45-\ndrivers/net/mdio/of_mdio.c:46:static int of_mdiobus_register_phy(struct mii_bus *mdio,\ndrivers/net/mdio/of_mdio.c-47-\t\t\t\t struct device_node *child, u32 addr)\n--\ndrivers/net/mdio/of_mdio.c-51-\ndrivers/net/mdio/of_mdio.c:52:static int of_mdiobus_register_device(struct mii_bus *mdio,\ndrivers/net/mdio/of_mdio.c-53-\t\t\t\t struct device_node *child, u32 addr)\n--\ndrivers/net/mdio/of_mdio.c=139=static int __of_mdiobus_parse_phys(struct mii_bus *mdio, struct device_node *np,\n--\ndrivers/net/mdio/of_mdio.c-167-\t\tif (of_mdiobus_child_is_phy(child))\ndrivers/net/mdio/of_mdio.c:168:\t\t\trc = of_mdiobus_register_phy(mdio, child, addr);\ndrivers/net/mdio/of_mdio.c-169-\t\telse\ndrivers/net/mdio/of_mdio.c:170:\t\t\trc = of_mdiobus_register_device(mdio, child, addr);\ndrivers/net/mdio/of_mdio.c-171-\n--\ndrivers/net/mdio/of_mdio.c-186-/**\ndrivers/net/mdio/of_mdio.c:187: * __of_mdiobus_register - Register mii_bus and create PHYs from the device tree\ndrivers/net/mdio/of_mdio.c-188- * @mdio: pointer to mii_bus structure\n--\ndrivers/net/mdio/of_mdio.c-194- */\ndrivers/net/mdio/of_mdio.c:195:int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,\ndrivers/net/mdio/of_mdio.c-196-\t\t\t struct module *owner)\n--\ndrivers/net/mdio/of_mdio.c-254-\t\t\t\t */\ndrivers/net/mdio/of_mdio.c:255:\t\t\t\trc = of_mdiobus_register_phy(mdio, child, addr);\ndrivers/net/mdio/of_mdio.c-256-\t\t\t\tif (!rc)\n--\ndrivers/net/mdio/of_mdio.c-271-}\ndrivers/net/mdio/of_mdio.c:272:EXPORT_SYMBOL(__of_mdiobus_register);\ndrivers/net/mdio/of_mdio.c-273-\n"
} |
| 19/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 30572 output: 42 thoughts: 14 Thoughts: Okay, let's dive into this. Here's my thought process on what we're looking at, summarized in the first person, assuming I'm already pretty familiar with this codebase: **Reviewing `__of_mdiobus_register`** Alright, time to get a good look at `__of_mdiobus_register`. This is a crucial function, and understanding it will be vital. Based on the naming, it's pretty clear this is about registering an MDIO bus, and the double underscore suggests it is a internal function. I imagine the "of" prefix is critical; it probably handles registering an MDIO bus from a Device Tree. This is where the magic happens for platform device configuration on these systems. I'll need to pay close attention to the parameter list, and especially how it interacts with the device tree. I'll want to see how the bus is initialized, how its clock and interrupt resources are configured, and ultimately how it's integrated with the rest of the MDIO subsystem. Any potential quirks or error handling during the registration process would also be something to watch. It is likely called as part of MDIO or Ethernet driver initialization. The code should provide insights for hardware detection and management. |
| 20/2 | 2026/08/02 08:33 | tool | read-file |
0mArgs:{
"File": "drivers/net/mdio/of_mdio.c",
"FirstLine": 186,
"LineCount": 100
}Results: {
"Contents": " 186:\t/**\n 187:\t * __of_mdiobus_register - Register mii_bus and create PHYs from the device tree\n 188:\t * @mdio: pointer to mii_bus structure\n 189:\t * @np: pointer to device_node of MDIO bus.\n 190:\t * @owner: module owning the @mdio object.\n 191:\t *\n 192:\t * This function registers the mii_bus structure and registers a phy_device\n 193:\t * for each child node of @np.\n 194:\t */\n 195:\tint __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,\n 196:\t\t\t\t struct module *owner)\n 197:\t{\n 198:\t\tstruct device_node *child;\n 199:\t\tbool scanphys = false;\n 200:\t\tint addr, rc;\n 201:\t\n 202:\t\tif (!np)\n 203:\t\t\treturn __mdiobus_register(mdio, owner);\n 204:\t\n 205:\t\t/* Do not continue if the node is disabled */\n 206:\t\tif (!of_device_is_available(np))\n 207:\t\t\treturn -ENODEV;\n 208:\t\n 209:\t\t/* Mask out all PHYs from auto probing. Instead the PHYs listed in\n 210:\t\t * the device tree are populated after the bus has been registered */\n 211:\t\tmdio-\u003ephy_mask = ~0;\n 212:\t\n 213:\t\tdevice_set_node(\u0026mdio-\u003edev, of_fwnode_handle(np));\n 214:\t\n 215:\t\t/* Get bus level PHY reset GPIO details */\n 216:\t\tmdio-\u003ereset_delay_us = DEFAULT_GPIO_RESET_DELAY;\n 217:\t\tof_property_read_u32(np, \"reset-delay-us\", \u0026mdio-\u003ereset_delay_us);\n 218:\t\tmdio-\u003ereset_post_delay_us = 0;\n 219:\t\tof_property_read_u32(np, \"reset-post-delay-us\", \u0026mdio-\u003ereset_post_delay_us);\n 220:\t\n 221:\t\t/* Register the MDIO bus */\n 222:\t\trc = __mdiobus_register(mdio, owner);\n 223:\t\tif (rc)\n 224:\t\t\treturn rc;\n 225:\t\n 226:\t\t/* Loop over the child nodes and register a phy_device for each phy */\n 227:\t\trc = __of_mdiobus_parse_phys(mdio, np, \u0026scanphys);\n 228:\t\tif (rc)\n 229:\t\t\tgoto unregister;\n 230:\t\n 231:\t\tif (!scanphys)\n 232:\t\t\treturn 0;\n 233:\t\n 234:\t\t/* auto scan for PHYs with empty reg property */\n 235:\t\tfor_each_available_child_of_node(np, child) {\n 236:\t\t\t/* Skip PHYs with reg property set or ethernet-phy-package node */\n 237:\t\t\tif (of_property_present(child, \"reg\") ||\n 238:\t\t\t of_node_name_eq(child, \"ethernet-phy-package\"))\n 239:\t\t\t\tcontinue;\n 240:\t\n 241:\t\t\tfor (addr = 0; addr \u003c PHY_MAX_ADDR; addr++) {\n 242:\t\t\t\t/* skip already registered PHYs */\n 243:\t\t\t\tif (mdiobus_is_registered_device(mdio, addr))\n 244:\t\t\t\t\tcontinue;\n 245:\t\n 246:\t\t\t\t/* be noisy to encourage people to set reg property */\n 247:\t\t\t\tdev_info(\u0026mdio-\u003edev, \"scan phy %pOFn at address %i\\n\",\n 248:\t\t\t\t\t child, addr);\n 249:\t\n 250:\t\t\t\tif (of_mdiobus_child_is_phy(child)) {\n 251:\t\t\t\t\t/* -ENODEV is the return code that PHYLIB has\n 252:\t\t\t\t\t * standardized on to indicate that bus\n 253:\t\t\t\t\t * scanning should continue.\n 254:\t\t\t\t\t */\n 255:\t\t\t\t\trc = of_mdiobus_register_phy(mdio, child, addr);\n 256:\t\t\t\t\tif (!rc)\n 257:\t\t\t\t\t\tbreak;\n 258:\t\t\t\t\tif (rc != -ENODEV)\n 259:\t\t\t\t\t\tgoto put_unregister;\n 260:\t\t\t\t}\n 261:\t\t\t}\n 262:\t\t}\n 263:\t\n 264:\t\treturn 0;\n 265:\t\n 266:\tput_unregister:\n 267:\t\tof_node_put(child);\n 268:\tunregister:\n 269:\t\tmdiobus_unregister(mdio);\n 270:\t\treturn rc;\n 271:\t}\n 272:\tEXPORT_SYMBOL(__of_mdiobus_register);\n 273:\t\n 274:\t/**\n 275:\t * of_mdio_find_device - Given a device tree node, find the mdio_device\n 276:\t * @np: pointer to the mdio_device's device tree node\n 277:\t *\n 278:\t * If successful, returns a pointer to the mdio_device with the embedded\n 279:\t * struct device refcount incremented by one, or NULL on failure.\n 280:\t * The caller should call put_device() on the mdio_device after its use\n 281:\t */\n 282:\tstruct mdio_device *of_mdio_find_device(struct device_node *np)\n 283:\t{\n 284:\t\treturn fwnode_mdio_find_device(of_fwnode_handle(np));\n 285:\t}\n"
} |
| 21/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 32455 output: 38 thoughts: 36 Thoughts: Okay, let's break this down. **Diving into the MDIO Bus Registration** Right, so I'm looking at this code, and the first thing that jumps out is this conditional: *If `np` is NULL...* Well, that's straightforward enough: If `np` is NULL, then the code *immediately* calls `__mdiobus_register(mdio, owner)`. The implication is that `np` probably represents some sort of device node or associated structure. Null means it doesn't exist. Now, the core functionality here must be within that registration function. So, my next logical step is to dive into `__mdiobus_register`. I need to understand what's happening *inside* that function in order to grasp the overall intention of this section of code. I need to understand how the MDIO bus is being registered in the absence of a device node. Is it a fallback? A legacy path? What are the implications of this registration when `np` is NULL? I need to analyze `__mdiobus_register` to determine the answer to these questions. |
| 22/2 | 2026/08/02 08:33 | tool | grepper |
0mError:no matches Args: {
"Expression": "__mdiobus_register",
"PathPrefix": "drivers/net/phy/mdio_bus.c"
}Results: {
"error": "no matches"
} |
| 23/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 32778 output: 31 thoughts: 38 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **MDIO Bus Registration: Digging into the Core** Okay, hold on a second. I need to make sure I've got this straight. That `__mdiobus_register` function… I thought I had a handle on where it lived. Let me double-check. *Wait, it's actually in* `drivers/net/phy/mdio_bus.c`? Good to know, it helps to keep a map of these things, especially when it comes to the lower-level bus interactions. Let me quickly refresh myself on the arguments it takes and its general behavior by checking the implementation of `mdiobus_register`, just to make sure my understanding is accurate. No point in making any assumptions at this level of abstraction. Always good to drill down and confirm the details, particularly with the more critical bus management code. |
| 24/2 | 2026/08/02 08:33 | tool | grepper |
0mArgs:{
"Expression": "mdiobus_register",
"PathPrefix": "drivers/net/phy/"
}Results: {
"Output": "drivers/net/phy/fixed_phy.c=195=static int __init fixed_mdio_bus_init(void)\n--\ndrivers/net/phy/fixed_phy.c-208-\ndrivers/net/phy/fixed_phy.c:209:\tret = mdiobus_register(fmb_mii_bus);\ndrivers/net/phy/fixed_phy.c-210-\tif (ret)\n--\ndrivers/net/phy/mdio_bus_provider.c=525=static bool mdiobus_prevent_c45_scan(struct mii_bus *bus)\n--\ndrivers/net/phy/mdio_bus_provider.c-539-/**\ndrivers/net/phy/mdio_bus_provider.c:540: * __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus\ndrivers/net/phy/mdio_bus_provider.c-541- * @bus: target mii_bus\n--\ndrivers/net/phy/mdio_bus_provider.c-545- * on a given bus, and attach them to the bus. Drivers should use\ndrivers/net/phy/mdio_bus_provider.c:546: * mdiobus_register() rather than __mdiobus_register() unless they\ndrivers/net/phy/mdio_bus_provider.c-547- * need to pass a specific owner module. MDIO devices which are not\ndrivers/net/phy/mdio_bus_provider.c-548- * PHYs will not be brought up by this function. They are expected\ndrivers/net/phy/mdio_bus_provider.c:549: * to be explicitly listed in DT and instantiated by of_mdiobus_register().\ndrivers/net/phy/mdio_bus_provider.c-550- *\n--\ndrivers/net/phy/mdio_bus_provider.c-552- */\ndrivers/net/phy/mdio_bus_provider.c:553:int __mdiobus_register(struct mii_bus *bus, struct module *owner)\ndrivers/net/phy/mdio_bus_provider.c-554-{\n--\ndrivers/net/phy/mdio_bus_provider.c-666-}\ndrivers/net/phy/mdio_bus_provider.c:667:EXPORT_SYMBOL(__mdiobus_register);\ndrivers/net/phy/mdio_bus_provider.c-668-\n--\ndrivers/net/phy/mdio_bus_provider.c=734=EXPORT_SYMBOL(mdio_find_bus);\n--\ndrivers/net/phy/mdio_bus_provider.c-745- * Because the association of a device_node and mii_bus is made via\ndrivers/net/phy/mdio_bus_provider.c:746: * of_mdiobus_register(), the mii_bus cannot be found before it is\ndrivers/net/phy/mdio_bus_provider.c:747: * registered with of_mdiobus_register().\ndrivers/net/phy/mdio_bus_provider.c-748- *\n--\ndrivers/net/phy/mdio_device.c=151=int mdio_device_register(struct mdio_device *mdiodev)\n--\ndrivers/net/phy/mdio_device.c-156-\ndrivers/net/phy/mdio_device.c:157:\terr = mdiobus_register_device(mdiodev);\ndrivers/net/phy/mdio_device.c-158-\tif (err)\n--\ndrivers/net/phy/mdio_device.c=189=EXPORT_SYMBOL(mdio_device_remove);\ndrivers/net/phy/mdio_device.c-190-\ndrivers/net/phy/mdio_device.c:191:int mdiobus_register_device(struct mdio_device *mdiodev)\ndrivers/net/phy/mdio_device.c-192-{\n--\ndrivers/net/phy/mdio_devres.c=56=static int mdiobus_devres_match(struct device *dev,\n--\ndrivers/net/phy/mdio_devres.c-65-/**\ndrivers/net/phy/mdio_devres.c:66: * __devm_mdiobus_register - Resource-managed variant of mdiobus_register()\ndrivers/net/phy/mdio_devres.c-67- * @dev:\tDevice to register mii_bus for\n--\ndrivers/net/phy/mdio_devres.c-72- */\ndrivers/net/phy/mdio_devres.c:73:int __devm_mdiobus_register(struct device *dev, struct mii_bus *bus,\ndrivers/net/phy/mdio_devres.c-74-\t\t\t struct module *owner)\n--\ndrivers/net/phy/mdio_devres.c-86-\ndrivers/net/phy/mdio_devres.c:87:\tret = __mdiobus_register(bus, owner);\ndrivers/net/phy/mdio_devres.c-88-\tif (ret) {\n--\ndrivers/net/phy/mdio_devres.c-96-}\ndrivers/net/phy/mdio_devres.c:97:EXPORT_SYMBOL(__devm_mdiobus_register);\ndrivers/net/phy/mdio_devres.c-98-\n--\ndrivers/net/phy/mdio_devres.c-100-/**\ndrivers/net/phy/mdio_devres.c:101: * __devm_of_mdiobus_register - Resource managed variant of of_mdiobus_register()\ndrivers/net/phy/mdio_devres.c-102- * @dev:\tDevice to register mii_bus for\n--\ndrivers/net/phy/mdio_devres.c-106- */\ndrivers/net/phy/mdio_devres.c:107:int __devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,\ndrivers/net/phy/mdio_devres.c-108-\t\t\t struct device_node *np, struct module *owner)\n--\ndrivers/net/phy/mdio_devres.c-120-\ndrivers/net/phy/mdio_devres.c:121:\tret = __of_mdiobus_register(mdio, np, owner);\ndrivers/net/phy/mdio_devres.c-122-\tif (ret) {\n--\ndrivers/net/phy/mdio_devres.c-130-}\ndrivers/net/phy/mdio_devres.c:131:EXPORT_SYMBOL(__devm_of_mdiobus_register);\ndrivers/net/phy/mdio_devres.c-132-#endif /* CONFIG_OF_MDIO */\n--\ndrivers/net/phy/phy_device.c=1109=int phy_device_register(struct phy_device *phydev)\n--\ndrivers/net/phy/phy_device.c-1112-\ndrivers/net/phy/phy_device.c:1113:\terr = mdiobus_register_device(\u0026phydev-\u003emdio);\ndrivers/net/phy/phy_device.c-1114-\tif (err)\n--\ndrivers/net/phy/phylib-internal.h=25=void phy_check_downshift(struct phy_device *phydev);\ndrivers/net/phy/phylib-internal.h-26-\ndrivers/net/phy/phylib-internal.h:27:int mdiobus_register_device(struct mdio_device *mdiodev);\ndrivers/net/phy/phylib-internal.h-28-int mdiobus_unregister_device(struct mdio_device *mdiodev);\n--\ndrivers/net/phy/sfp.c=942=static int sfp_i2c_mdiobus_create(struct sfp *sfp)\n--\ndrivers/net/phy/sfp.c-953-\ndrivers/net/phy/sfp.c:954:\tret = mdiobus_register(i2c_mii);\ndrivers/net/phy/sfp.c-955-\tif (ret \u003c 0) {\n"
} |
| 25/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 35125 output: 43 thoughts: 49 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Analyzing the PHY Registration Process** Right, let's see, `__mdiobus_register` is defined in `drivers/net/phy/mdio_bus_provider.c`. My immediate thought is, does this routine perform any PHY scanning or enumeration as part of its registration process? I need to understand how PHYs are initially discovered and associated with the MDIO bus. I'm going to jump into the `__mdiobus_register` function definition and see what it actually *does*. Is it simply registering the bus, or is it digging around in the MDIO space for available devices during the registration itself? That's the critical question here, since I'm thinking about the low-level PHY interaction. |
| 26/2 | 2026/08/02 08:33 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/mdio_bus_provider.c",
"FirstLine": 550,
"LineCount": 100
}Results: {
"Contents": " 550:\t *\n 551:\t * Returns 0 on success or \u003c 0 on error.\n 552:\t */\n 553:\tint __mdiobus_register(struct mii_bus *bus, struct module *owner)\n 554:\t{\n 555:\t\tstruct mdio_device *mdiodev;\n 556:\t\tstruct gpio_desc *gpiod;\n 557:\t\tbool prevent_c45_scan;\n 558:\t\tint i, err;\n 559:\t\n 560:\t\tif (!bus || !bus-\u003ename)\n 561:\t\t\treturn -EINVAL;\n 562:\t\n 563:\t\t/* An access method always needs both read and write operations */\n 564:\t\tif (!!bus-\u003eread != !!bus-\u003ewrite || !!bus-\u003eread_c45 != !!bus-\u003ewrite_c45)\n 565:\t\t\treturn -EINVAL;\n 566:\t\n 567:\t\t/* At least one method is mandatory */\n 568:\t\tif (!bus-\u003eread \u0026\u0026 !bus-\u003eread_c45)\n 569:\t\t\treturn -EINVAL;\n 570:\t\n 571:\t\tif (bus-\u003eparent \u0026\u0026 bus-\u003eparent-\u003eof_node)\n 572:\t\t\tfwnode_set_flag(\u0026bus-\u003eparent-\u003eof_node-\u003efwnode,\n 573:\t\t\t\t\tFWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD);\n 574:\t\n 575:\t\tWARN(bus-\u003estate != MDIOBUS_ALLOCATED \u0026\u0026\n 576:\t\t bus-\u003estate != MDIOBUS_UNREGISTERED,\n 577:\t\t \"%s: not in ALLOCATED or UNREGISTERED state\\n\", bus-\u003eid);\n 578:\t\n 579:\t\tbus-\u003eowner = owner;\n 580:\t\tbus-\u003edev.parent = bus-\u003eparent;\n 581:\t\tbus-\u003edev.class = \u0026mdio_bus_class;\n 582:\t\tbus-\u003edev.groups = NULL;\n 583:\t\tdev_set_name(\u0026bus-\u003edev, \"%s\", bus-\u003eid);\n 584:\t\n 585:\t\t/* If the bus state is allocated, we're registering a fresh bus\n 586:\t\t * that may have a fwnode associated with it. Grab a reference\n 587:\t\t * to the fwnode. This will be dropped when the bus is released.\n 588:\t\t * If the bus was set to unregistered, it means that the bus was\n 589:\t\t * previously registered, and we've already grabbed a reference.\n 590:\t\t */\n 591:\t\tif (bus-\u003estate == MDIOBUS_ALLOCATED)\n 592:\t\t\tfwnode_handle_get(dev_fwnode(\u0026bus-\u003edev));\n 593:\t\n 594:\t\t/* We need to set state to MDIOBUS_UNREGISTERED to correctly release\n 595:\t\t * the device in mdiobus_free()\n 596:\t\t *\n 597:\t\t * State will be updated later in this function in case of success\n 598:\t\t */\n 599:\t\tbus-\u003estate = MDIOBUS_UNREGISTERED;\n 600:\t\n 601:\t\terr = device_register(\u0026bus-\u003edev);\n 602:\t\tif (err) {\n 603:\t\t\tpr_err(\"mii_bus %s failed to register\\n\", bus-\u003eid);\n 604:\t\t\treturn -EINVAL;\n 605:\t\t}\n 606:\t\n 607:\t\tmutex_init(\u0026bus-\u003emdio_lock);\n 608:\t\tmutex_init(\u0026bus-\u003eshared_lock);\n 609:\t\n 610:\t\t/* assert bus level PHY GPIO reset */\n 611:\t\tgpiod = devm_gpiod_get_optional(\u0026bus-\u003edev, \"reset\", GPIOD_OUT_HIGH);\n 612:\t\tif (IS_ERR(gpiod)) {\n 613:\t\t\terr = dev_err_probe(\u0026bus-\u003edev, PTR_ERR(gpiod),\n 614:\t\t\t\t\t \"mii_bus %s couldn't get reset GPIO\\n\",\n 615:\t\t\t\t\t bus-\u003eid);\n 616:\t\t\tdevice_del(\u0026bus-\u003edev);\n 617:\t\t\treturn err;\n 618:\t\t} else\tif (gpiod) {\n 619:\t\t\tbus-\u003ereset_gpiod = gpiod;\n 620:\t\t\tfsleep(bus-\u003ereset_delay_us);\n 621:\t\t\tgpiod_set_value_cansleep(gpiod, 0);\n 622:\t\t\tif (bus-\u003ereset_post_delay_us \u003e 0)\n 623:\t\t\t\tfsleep(bus-\u003ereset_post_delay_us);\n 624:\t\t}\n 625:\t\n 626:\t\tif (bus-\u003ereset) {\n 627:\t\t\terr = bus-\u003ereset(bus);\n 628:\t\t\tif (err)\n 629:\t\t\t\tgoto error_reset_gpiod;\n 630:\t\t}\n 631:\t\n 632:\t\tif (bus-\u003eread) {\n 633:\t\t\terr = mdiobus_scan_bus_c22(bus);\n 634:\t\t\tif (err)\n 635:\t\t\t\tgoto error;\n 636:\t\t}\n 637:\t\n 638:\t\tprevent_c45_scan = mdiobus_prevent_c45_scan(bus);\n 639:\t\n 640:\t\tif (!prevent_c45_scan \u0026\u0026 bus-\u003eread_c45) {\n 641:\t\t\terr = mdiobus_scan_bus_c45(bus);\n 642:\t\t\tif (err)\n 643:\t\t\t\tgoto error;\n 644:\t\t}\n 645:\t\n 646:\t\tbus-\u003estate = MDIOBUS_REGISTERED;\n 647:\t\tdev_dbg(\u0026bus-\u003edev, \"probed\\n\");\n 648:\t\treturn 0;\n 649:\t\n"
} |
| 27/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 36969 output: 39 thoughts: 433 Thoughts: **My Analysis of the PHY Driver Path** Okay, so I've traced the path. `__mdiobus_register` is definitely the key entry point here. It calls `mdiobus_scan_bus_c22(bus)`, which does exactly what I expected: it scans the MDIO bus for PHYs, iterating through addresses 0 to 31. When it finds something, it registers it. From there, the PHY subsystem takes over, matching the PHY ID against `motorcomm_phy_drvs` and ultimately probing `yt8824_probe`. So, there's a good shot this is reachable through USB fuzzing! But, hold on. `mdio-mvusb.c`... that's a USB driver, isn't it? I need to check the syzkaller configs to see if `CONFIG_USB_MDIO` or `CONFIG_MDIO_MVUSB` or something similar is enabled. Wait, let me not jump to conclusions... there are other ways to register an MDIO bus besides that driver, like `mdio-i2c.c`, `mdio-gpio.c`, or even a `fixed-phy`. But, yeah, the `vhci` support in syzkaller makes `mdio-mvusb` a perfectly valid path to explore. Alright, time to dive deeper into `yt8824_probe`. It calls `devm_of_phy_package_join`, `phy_package_probe_once`, `yt8824_phy_package_probe_once`, and `devm_kzalloc`. Let's focus on `yt8824_phy_package_probe_once` specifically. Ah! It's reading from the device tree: `of_property_read_string(np, "motorcomm,interface-mode", &interface_mode_name)`. Crucially, `np` is going to be NULL for a USB MDIO bus, and `of_property_read_string` will return an error (probably `-EINVAL`). Time to check `yt8824_phy_package_probe_once`. |
| 28/2 | 2026/08/02 08:33 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/motorcomm.c",
"FirstLine": 4560,
"LineCount": 50
}Results: {
"Contents": "4560:\t\t{\n4561:\t\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8531),\n4562:\t\t\t.name\t\t= \"YT8531 Gigabit Ethernet\",\n4563:\t\t\t.probe\t\t= yt8531_probe,\n4564:\t\t\t.config_init\t= yt8531_config_init,\n4565:\t\t\t.suspend\t= genphy_suspend,\n4566:\t\t\t.resume\t\t= genphy_resume,\n4567:\t\t\t.get_wol\t= ytphy_get_wol,\n4568:\t\t\t.set_wol\t= yt8531_set_wol,\n4569:\t\t\t.link_change_notify = yt8531_link_change_notify,\n4570:\t\t\t.led_hw_is_supported = yt8521_led_hw_is_supported,\n4571:\t\t\t.led_hw_control_set = yt8521_led_hw_control_set,\n4572:\t\t\t.led_hw_control_get = yt8521_led_hw_control_get,\n4573:\t\t},\n4574:\t\t{\n4575:\t\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8531S),\n4576:\t\t\t.name\t\t= \"YT8531S Gigabit Ethernet\",\n4577:\t\t\t.get_features\t= yt8521_get_features,\n4578:\t\t\t.probe\t\t= yt8521_probe,\n4579:\t\t\t.read_page\t= yt8521_read_page,\n4580:\t\t\t.write_page\t= yt8521_write_page,\n4581:\t\t\t.get_wol\t= ytphy_get_wol,\n4582:\t\t\t.set_wol\t= ytphy_set_wol,\n4583:\t\t\t.config_aneg\t= yt8521_config_aneg,\n4584:\t\t\t.aneg_done\t= yt8521_aneg_done,\n4585:\t\t\t.config_init\t= yt8521_config_init,\n4586:\t\t\t.read_status\t= yt8521_read_status,\n4587:\t\t\t.soft_reset\t= yt8521_soft_reset,\n4588:\t\t\t.suspend\t= yt8521_suspend,\n4589:\t\t\t.resume\t\t= yt8521_resume,\n4590:\t\t},\n4591:\t\t{\n4592:\t\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8821),\n4593:\t\t\t.name\t\t\t= \"YT8821 2.5Gbps PHY\",\n4594:\t\t\t.get_features\t\t= yt8821_get_features,\n4595:\t\t\t.read_page\t\t= yt8521_read_page,\n4596:\t\t\t.write_page\t\t= yt8521_write_page,\n4597:\t\t\t.get_wol\t\t= ytphy_get_wol,\n4598:\t\t\t.set_wol\t\t= ytphy_set_wol,\n4599:\t\t\t.config_aneg\t\t= genphy_config_aneg,\n4600:\t\t\t.aneg_done\t\t= yt8821_aneg_done,\n4601:\t\t\t.config_init\t\t= yt8821_config_init,\n4602:\t\t\t.get_rate_matching\t= yt8821_get_rate_matching,\n4603:\t\t\t.read_status\t\t= yt8821_read_status,\n4604:\t\t\t.soft_reset\t\t= yt8821_soft_reset,\n4605:\t\t\t.suspend\t\t= yt8821_suspend,\n4606:\t\t\t.resume\t\t\t= yt8821_resume,\n4607:\t\t},\n4608:\t\t{\n4609:\t\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8824),\n"
} |
| 29/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 38958 output: 39 thoughts: 21 Thoughts: Here's my thought process, summarized as you requested: **Navigating the Codebase** Okay, hold on a second. I need to get oriented. Before I dive too deep into anything, I'm getting a sense that `yt8824_phy_package_probe_once` is going to be central to understanding this section of code. I'm having a strong instinct that something hinges on how that function is being used, or what its dependencies are. So, I need to make sure I grasp its role and implementation before I go any further. I'm going to track it down and see exactly what's going on with it. Let's see... |
| 30/2 | 2026/08/02 08:33 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/motorcomm.c",
"FirstLine": 4520,
"LineCount": 50
}Results: {
"Contents": "4520:\t}\n4521:\t\n4522:\tstatic struct phy_driver motorcomm_phy_drvs[] = {\n4523:\t\t{\n4524:\t\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8511),\n4525:\t\t\t.name\t\t= \"YT8511 Gigabit Ethernet\",\n4526:\t\t\t.config_init\t= yt8511_config_init,\n4527:\t\t\t.suspend\t= genphy_suspend,\n4528:\t\t\t.resume\t\t= genphy_resume,\n4529:\t\t\t.read_page\t= yt8511_read_page,\n4530:\t\t\t.write_page\t= yt8511_write_page,\n4531:\t\t},\n4532:\t\t{\n4533:\t\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8521),\n4534:\t\t\t.name\t\t= \"YT8521 Gigabit Ethernet\",\n4535:\t\t\t.get_features\t= yt8521_get_features,\n4536:\t\t\t.probe\t\t= yt8521_probe,\n4537:\t\t\t.read_page\t= yt8521_read_page,\n4538:\t\t\t.write_page\t= yt8521_write_page,\n4539:\t\t\t.get_wol\t= ytphy_get_wol,\n4540:\t\t\t.set_wol\t= ytphy_set_wol,\n4541:\t\t\t.config_aneg\t= yt8521_config_aneg,\n4542:\t\t\t.aneg_done\t= yt8521_aneg_done,\n4543:\t\t\t.config_init\t= yt8521_config_init,\n4544:\t\t\t.read_status\t= yt8521_read_status,\n4545:\t\t\t.soft_reset\t= yt8521_soft_reset,\n4546:\t\t\t.suspend\t= yt8521_suspend,\n4547:\t\t\t.resume\t\t= yt8521_resume,\n4548:\t\t\t.led_hw_is_supported = yt8521_led_hw_is_supported,\n4549:\t\t\t.led_hw_control_set = yt8521_led_hw_control_set,\n4550:\t\t\t.led_hw_control_get = yt8521_led_hw_control_get,\n4551:\t\t},\n4552:\t\t{\n4553:\t\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8522),\n4554:\t\t\t.name\t\t= \"YT8522 100 Megabit Ethernet\",\n4555:\t\t\t.config_aneg\t= genphy_config_aneg,\n4556:\t\t\t.config_init\t= yt8522_config_init,\n4557:\t\t\t.suspend\t= genphy_suspend,\n4558:\t\t\t.resume\t\t= genphy_resume,\n4559:\t\t},\n4560:\t\t{\n4561:\t\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8531),\n4562:\t\t\t.name\t\t= \"YT8531 Gigabit Ethernet\",\n4563:\t\t\t.probe\t\t= yt8531_probe,\n4564:\t\t\t.config_init\t= yt8531_config_init,\n4565:\t\t\t.suspend\t= genphy_suspend,\n4566:\t\t\t.resume\t\t= genphy_resume,\n4567:\t\t\t.get_wol\t= ytphy_get_wol,\n4568:\t\t\t.set_wol\t= yt8531_set_wol,\n4569:\t\t\t.link_change_notify = yt8531_link_change_notify,\n"
} |
| 31/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 40161 output: 39 thoughts: 21 Thoughts: Here's my thought process, summarized as you requested: **Navigating the Codebase** Okay, hold on a second. Before I proceed any further with this line of investigation, I need to get a clear understanding of `yt8824_phy_package_probe_once`. It's crucial to understand how this probe function operates. I need to know precisely what it's responsible for initializing, how it handles the hardware detection, and what its overall lifecycle looks like. I cannot move on until I have fully understood how that probe function works. Only then will I be able to continue. |
| 32/2 | 2026/08/02 08:33 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/motorcomm.c",
"FirstLine": 4480,
"LineCount": 50
}Results: {
"Contents": "4480:\t\t\t\t\t phy_modes(PHY_INTERFACE_MODE_INTERNAL))) {\n4481:\t\t\t\tpriv-\u003einterface_mode = PHY_INTERFACE_MODE_INTERNAL;\n4482:\t\t\t\tpriv-\u003eoffset = INTERNAL_PHY8824_TOP_EXTEND_OFFSET;\n4483:\t\t\t} else {\n4484:\t\t\t\treturn -EINVAL;\n4485:\t\t\t}\n4486:\t\t}\n4487:\t\treturn 0;\n4488:\t}\n4489:\t\n4490:\t/**\n4491:\t * yt8824_probe() - phy8824 probe.\n4492:\t * @phydev: a pointer to a \u0026struct phy_device\n4493:\t *\n4494:\t * Returns: 0 or negative errno code\n4495:\t */\n4496:\tstatic int yt8824_probe(struct phy_device *phydev)\n4497:\t{\n4498:\t\tstruct device *dev = \u0026phydev-\u003emdio.dev;\n4499:\t\tstruct yt8824_shared_priv *shared_priv;\n4500:\t\tstruct yt8521_priv *priv;\n4501:\t\tint ret;\n4502:\t\n4503:\t\tret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));\n4504:\t\tif (ret)\n4505:\t\t\treturn ret;\n4506:\t\n4507:\t\tif (phy_package_probe_once(phydev)) {\n4508:\t\t\tret = yt8824_phy_package_probe_once(phydev);\n4509:\t\t\tif (ret)\n4510:\t\t\t\treturn ret;\n4511:\t\t}\n4512:\t\n4513:\t\tpriv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);\n4514:\t\tif (!priv)\n4515:\t\t\treturn -ENOMEM;\n4516:\t\n4517:\t\tphydev-\u003epriv = priv;\n4518:\t\n4519:\t\treturn 0;\n4520:\t}\n4521:\t\n4522:\tstatic struct phy_driver motorcomm_phy_drvs[] = {\n4523:\t\t{\n4524:\t\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8511),\n4525:\t\t\t.name\t\t= \"YT8511 Gigabit Ethernet\",\n4526:\t\t\t.config_init\t= yt8511_config_init,\n4527:\t\t\t.suspend\t= genphy_suspend,\n4528:\t\t\t.resume\t\t= genphy_resume,\n4529:\t\t\t.read_page\t= yt8511_read_page,\n"
} |
| 33/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 41089 output: 39 thoughts: 21 Thoughts: Okay, here's my attempt at summarizing the thought process, as requested, in the first person and targeted towards an expert: **Analyzing the Probe Routine: yt8824_phy_package_probe_once** Alright, let's dive into this `yt8824_phy_package_probe_once` routine. I need to understand this completely. I'm going to carefully read every line, because a probe function can be a critical point of failure or success when dealing with PHY initialization and bringup. I’ll be looking for things like: * **Initialization Sequence:** How does it actually detect and configure the PHY? Is it using a standard MII/GMII interface, or are there custom register access patterns? I need to understand the initial assumptions. * **Device Identification:** What's the detection mechanism? Does it rely on a specific PHY ID or autonegotiation parameters? Are there any hardcoded assumptions about the PHY type, or is it more robust? * **Error Handling:** What happens if the probe fails? Are there retries? Are there fallback mechanisms, or does it simply return an error? The error handling is key, especially in complex environments where PHYs can be unreliable or require specific clocking. * **Clocking:** Is the clocking configuration handled here? Or is that delegated elsewhere? Understanding the clocking relationships is *crucial* for stable operation. Improper clock configuration is a common root cause. * **Register Configuration:** What registers are being read and written to during the probe? I need to understand the intent of each register access – what are we trying to achieve? * **Dependencies:** Does this routine have any dependencies on other functions or data structures? Are there any global variables that it relies on, or does it call other functions that I need to investigate as well? * **Hardware Abstraction:** How abstracted is the hardware? Is it using a generic MII/GMII driver, or are there device-specific register definitions and access methods directly coded here? This will inform how portable the design is. * **Resource Allocation:** Does it allocate any resources? This matters to ensure it’s operating with adequate memory space. I'm essentially reverse-engineering the intended behavior to build a comprehensive mental model. I want to build a rock-solid understanding of what the function *should* do, *will* do, and *might* do under various conditions. |
| 34/2 | 2026/08/02 08:33 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/motorcomm.c",
"FirstLine": 4450,
"LineCount": 50
}Results: {
"Contents": "4450:\t\t\t\t\t MDIO_AN_10GBT_CTRL_ADV2_5G,\n4451:\t\t\t\t\t phy_ctrl);\n4452:\t\tif (ret \u003c 0)\n4453:\t\t\treturn ret;\n4454:\t\n4455:\t\treturn genphy_config_aneg(phydev);\n4456:\t}\n4457:\t\n4458:\t/**\n4459:\t * yt8824_phy_package_probe_once() - init phy packet for phy8824.\n4460:\t * @phydev: a pointer to a \u0026struct phy_device\n4461:\t *\n4462:\t * Returns: 0 or negative errno code\n4463:\t */\n4464:\tstatic int yt8824_phy_package_probe_once(struct phy_device *phydev)\n4465:\t{\n4466:\t\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n4467:\t\tstruct device_node *np = phy_package_get_node(phydev);\n4468:\t\tconst char *interface_mode_name;\n4469:\t\n4470:\t\tpriv-\u003einterface_mode = PHY_INTERFACE_MODE_NA;\n4471:\t\tpriv-\u003eoffset = INTERNAL_PHY8824_TOP_EXTEND_OFFSET;\n4472:\t\tif (!of_property_read_string(np, \"motorcomm,interface-mode\",\n4473:\t\t\t\t\t \u0026interface_mode_name)) {\n4474:\t\t\tif (!strcasecmp(interface_mode_name,\n4475:\t\t\t\t\tphy_modes(PHY_INTERFACE_MODE_USXGMII))) {\n4476:\t\t\t\tpriv-\u003einterface_mode = PHY_INTERFACE_MODE_USXGMII;\n4477:\t\t\t\tpriv-\u003eoffset = EXTERNAL_PHY8824_TOP_EXTEND_OFFSET;\n4478:\t\t\t} else if (!strcasecmp\n4479:\t\t\t\t\t(interface_mode_name,\n4480:\t\t\t\t\t phy_modes(PHY_INTERFACE_MODE_INTERNAL))) {\n4481:\t\t\t\tpriv-\u003einterface_mode = PHY_INTERFACE_MODE_INTERNAL;\n4482:\t\t\t\tpriv-\u003eoffset = INTERNAL_PHY8824_TOP_EXTEND_OFFSET;\n4483:\t\t\t} else {\n4484:\t\t\t\treturn -EINVAL;\n4485:\t\t\t}\n4486:\t\t}\n4487:\t\treturn 0;\n4488:\t}\n4489:\t\n4490:\t/**\n4491:\t * yt8824_probe() - phy8824 probe.\n4492:\t * @phydev: a pointer to a \u0026struct phy_device\n4493:\t *\n4494:\t * Returns: 0 or negative errno code\n4495:\t */\n4496:\tstatic int yt8824_probe(struct phy_device *phydev)\n4497:\t{\n4498:\t\tstruct device *dev = \u0026phydev-\u003emdio.dev;\n4499:\t\tstruct yt8824_shared_priv *shared_priv;\n"
} |
| 35/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 42497 output: 39 thoughts: 157 Thoughts: **Analyzing the Driver Probe Logic** Okay, so I'm looking at this driver's probe function. It seems like the core logic revolves around reading a string property from the device tree using `of_property_read_string`. The key is that this function returns `-EINVAL` when the property isn't present. And the code is using the inverse logic: `!of_property_read_string`. So, when the property is *missing*, the function *returns* `-EINVAL`, making the *result of the expression false*! Then, the code immediately returns 0, indicating a successful probe. This also applies when the node pointer, `np`, is NULL. `of_property_read_string` still returns `-EINVAL`. The conditional statement is then false. The probe will appear successful as well. The interesting part is how this absence is handled. It seems that if the string property is missing, the code defaults `priv->interface_mode` to `PHY_INTERFACE_MODE_NA` and sets `priv->offset` to `INTERNAL_PHY8824_TOP_EXTEND_OFFSET`. This probably means the driver is set up to use default configuration values. Ultimately, `yt8824_config_init` will still be called. I'll need to dig into that function to understand how the default configuration behaves. |
| 36/2 | 2026/08/02 08:33 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/motorcomm.c",
"FirstLine": 1130,
"LineCount": 50
}Results: {
"Contents": "1130:\t\t\treturn ret;\n1131:\t\n1132:\t\tret = ytphy_write_ext_with_lock(phydev, 0x00f8, 0xb3ff);\n1133:\t\tif (ret \u003c 0)\n1134:\t\t\treturn ret;\n1135:\t\n1136:\t\tret = ytphy_write_ext_with_lock(phydev, 0x0059, 0x4040);\n1137:\t\tif (ret \u003c 0)\n1138:\t\t\treturn ret;\n1139:\t\n1140:\t\tret = ytphy_write_ext_with_lock(phydev, 0x032c, 0x5094);\n1141:\t\tif (ret \u003c 0)\n1142:\t\t\treturn ret;\n1143:\t\n1144:\t\tret = ytphy_write_ext_with_lock(phydev, 0x032d, 0xd094);\n1145:\t\tif (ret \u003c 0)\n1146:\t\t\treturn ret;\n1147:\t\n1148:\t\tret = ytphy_write_ext_with_lock(phydev, 0x032e, 0x5308);\n1149:\t\tif (ret \u003c 0)\n1150:\t\t\treturn ret;\n1151:\t\n1152:\t\tret = ytphy_write_ext_with_lock(phydev, 0x0322, 0x6440);\n1153:\t\tif (ret \u003c 0)\n1154:\t\t\treturn ret;\n1155:\t\n1156:\t\tret = ytphy_write_ext_with_lock(phydev, 0x04d3, 0x5220);\n1157:\t\tif (ret \u003c 0)\n1158:\t\t\treturn ret;\n1159:\t\n1160:\t\tret = ytphy_write_ext_with_lock(phydev, 0x04d2, 0x5220);\n1161:\t\tif (ret \u003c 0)\n1162:\t\t\treturn ret;\n1163:\t\n1164:\t\t/* optimized EMC CS */\n1165:\t\tret = ytphy_write_ext_with_lock(phydev, 0x00c8, 0xffff);\n1166:\t\tif (ret \u003c 0)\n1167:\t\t\treturn ret;\n1168:\t\n1169:\t\tret = ytphy_write_ext_with_lock(phydev, 0x00be, 0x6406);\n1170:\t\tif (ret \u003c 0)\n1171:\t\t\treturn ret;\n1172:\t\n1173:\t\tret = ytphy_write_ext_with_lock(phydev, 0x037a, 0x40ff);\n1174:\t\tif (ret \u003c 0)\n1175:\t\t\treturn ret;\n1176:\t\n1177:\t\t/* optimized EMC RE */\n1178:\t\tret = ytphy_write_ext_with_lock(phydev, 0x0482, 0xffff);\n1179:\t\tif (ret \u003c 0)\n"
} |
| 37/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 43847 output: 39 thoughts: 15 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Analyzing the Configuration Initialization** Alright, time to dig into this. My initial thought is to zero in on the `yt8824_config_init` function. It's the starting point, the foundation, so to speak. Understanding its behavior is critical before I move any further. What's it doing? Is it handling the base register setup? Does it call any supporting functions, and if so, what are they doing behind the scenes? Are there any obvious potential issues, like missed boundary checks or improperly initialized data structures, right off the bat? This is where everything gets set up; if there's a problem here, it'll cascade and cause significant downstream problems. |
| 38/2 | 2026/08/02 08:33 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/motorcomm.c",
"FirstLine": 1410,
"LineCount": 50
}Results: {
"Contents": "1410:\t\t\t\tgoto err_restore_page;\n1411:\t\n1412:\t\t\tret = ytphy_write_ext(phydev, 0x04af, 0x45e7);\n1413:\t\t\tif (ret \u003c 0)\n1414:\t\t\t\tgoto err_restore_page;\n1415:\t\n1416:\t\t\t/* restart calibration */\n1417:\t\t\tret = ytphy_write_ext(phydev, 0x0003, 0x5603);\n1418:\t\t\tif (ret \u003c 0)\n1419:\t\t\t\tgoto err_restore_page;\n1420:\t\n1421:\t\t\tret = ytphy_write_ext(phydev, 0x0492, 0x7fff);\n1422:\t\t\tif (ret \u003c 0)\n1423:\t\t\t\tgoto err_restore_page;\n1424:\t\n1425:\t\t\tret = ytphy_write_ext(phydev, 0x0492, 0x7f7f);\n1426:\t\t\tif (ret \u003c 0)\n1427:\t\t\t\tgoto err_restore_page;\n1428:\t\n1429:\t\t\tret = ytphy_write_ext(phydev, 0x2000, 0x0040);\n1430:\t\t\tif (ret \u003c 0)\n1431:\t\t\t\tgoto err_restore_page;\n1432:\t\n1433:\t\t\tret = ytphy_write_ext(phydev, 0x2000, 0x0000);\n1434:\t\t\tif (ret \u003c 0)\n1435:\t\t\t\tgoto err_restore_page;\n1436:\t\t}\n1437:\t\n1438:\t\t/* TX preamble padded to 8; RX IPG always \u003e 8 */\n1439:\t\tret = __phy_read(phydev, MII_RESV1);\n1440:\t\tif (ret \u003c 0)\n1441:\t\t\tgoto err_restore_page;\n1442:\t\tret \u0026= ~YT8824_SDS_CFG_MIN_PRE_MASK;\n1443:\t\tret |= YT8824_SDS_TX_PRE_PADDING;\n1444:\t\tret |= YT8824_SDS_EN_FILL_PRE;\n1445:\t\tret = __phy_write(phydev, MII_RESV1, ret);\n1446:\t\tif (ret \u003c 0)\n1447:\t\t\tgoto err_restore_page;\n1448:\t\n1449:\t\tdata = __phy_read(phydev, MII_BMCR);\n1450:\t\tif (data \u003c 0)\n1451:\t\t\tgoto err_restore_page;\n1452:\t\tdata |= BMCR_RESET;\n1453:\t\tdata |= BMCR_ANENABLE;\n1454:\t\tret = __phy_write(phydev, MII_BMCR, data);\n1455:\t\tif (ret \u003c 0)\n1456:\t\t\tgoto err_restore_page;\n1457:\t\n1458:\terr_restore_page:\n1459:\t\treturn phy_restore_page(phydev, old_page, ret);\n"
} |
| 39/2 | 2026/08/02 08:33 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 44918 output: 39 thoughts: 17 Thoughts: Here's my thought process, summarized as you requested: **Navigating the Codebase** Okay, hold on a second. I need to get my bearings here. I'm working on something, and the key function I'm looking for is `yt8824_config_init`. It's crucial, so I need to track down exactly where it's defined and how it's being called. I'm going to have to dive into the codebase and quickly locate that specific function. This initialization is likely the backbone for whatever I'm troubleshooting, debugging, or extending right now. Let's see if I can find it quickly. Time to navigate the code! |
| 40/2 | 2026/08/02 08:34 | tool | grepper |
0mArgs:{
"Expression": "yt8824_config_init",
"PathPrefix": "drivers/net/phy/motorcomm.c"
}Results: {
"Output": "drivers/net/phy/motorcomm.c=1469=static int yt8824_internal_config_init_paged(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-1685-/**\ndrivers/net/phy/motorcomm.c:1686: * yt8824_config_init() - phy initializatioin\ndrivers/net/phy/motorcomm.c-1687- * @phydev: a pointer to a \u0026struct phy_device\n--\ndrivers/net/phy/motorcomm.c-1690- */\ndrivers/net/phy/motorcomm.c:1691:static int yt8824_config_init(struct phy_device *phydev)\ndrivers/net/phy/motorcomm.c-1692-{\n--\ndrivers/net/phy/motorcomm.c=4522=static struct phy_driver motorcomm_phy_drvs[] = {\n--\ndrivers/net/phy/motorcomm.c-4616-\t\t.aneg_done\t\t= yt8824_aneg_done,\ndrivers/net/phy/motorcomm.c:4617:\t\t.config_init\t\t= yt8824_config_init,\ndrivers/net/phy/motorcomm.c-4618-\t\t.read_status\t\t= yt8824_read_status,\n"
} |
| 41/2 | 2026/08/02 08:34 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 45472 output: 39 thoughts: 15 Thoughts: Okay, here we go... **Initial Assessment: Diving into `yt8824_config_init`** Alright, time to get my head in this code. Let's see, the file name already suggests we're dealing with configuration initialization, specifically for something related to `yt8824`. That likely points to a particular hardware component or driver, possibly video or network-related. My mind immediately starts running through the typical initialization sequences I've worked with before. I'm thinking about the order of operations: register setup, memory allocation (if relevant), perhaps some device detection and validation, and definitely the parsing and loading of some kind of configuration data. I'm expecting to find a series of function calls, potentially nested, that handle these tasks. I'll be keeping an eye out for any error handling, particularly around resource allocation and config file parsing. That's usually where the subtle bugs like to hide! Let's get reading and see what we've got. |
| 42/2 | 2026/08/02 08:34 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/motorcomm.c",
"FirstLine": 1685,
"LineCount": 50
}Results: {
"Contents": "1685:\t/**\n1686:\t * yt8824_config_init() - phy initializatioin\n1687:\t * @phydev: a pointer to a \u0026struct phy_device\n1688:\t *\n1689:\t * Returns: 0 or negative errno code\n1690:\t */\n1691:\tstatic int yt8824_config_init(struct phy_device *phydev)\n1692:\t{\n1693:\t\tint ret;\n1694:\t\n1695:\t\tif (phydev-\u003einterface == PHY_INTERFACE_MODE_INTERNAL) {\n1696:\t\t\tret = yt8824_internal_config_init_paged(phydev);\n1697:\t\t\tif (ret \u003c 0)\n1698:\t\t\t\treturn ret;\n1699:\t\t} else {\n1700:\t\t\tret = yt8824_extern_config_utp_init_paged(phydev);\n1701:\t\t\tif (ret \u003c 0)\n1702:\t\t\t\treturn ret;\n1703:\t\t\tret = yt8824_extern_config_sds_init_paged(phydev);\n1704:\t\t\tif (ret \u003c 0)\n1705:\t\t\t\treturn ret;\n1706:\t\t}\n1707:\t\tret = yt8824_soft_reset(phydev);\n1708:\t\tif (ret \u003c 0)\n1709:\t\t\treturn ret;\n1710:\t\n1711:\t\tphydev_dbg(phydev, \"%s done, phy addr: %d\\n\",\n1712:\t\t\t __func__, phydev-\u003emdio.addr);\n1713:\t\n1714:\t\treturn 0;\n1715:\t}\n1716:\t\n1717:\tstatic int yt8531_set_wol(struct phy_device *phydev,\n1718:\t\t\t\t struct ethtool_wolinfo *wol)\n1719:\t{\n1720:\t\tconst u16 mac_addr_reg[] = {\n1721:\t\t\tYTPHY_WOL_MACADDR2_REG,\n1722:\t\t\tYTPHY_WOL_MACADDR1_REG,\n1723:\t\t\tYTPHY_WOL_MACADDR0_REG,\n1724:\t\t};\n1725:\t\tconst u8 *mac_addr;\n1726:\t\tu16 mask, val;\n1727:\t\tint ret;\n1728:\t\tu8 i;\n1729:\t\n1730:\t\tif (wol-\u003ewolopts \u0026 WAKE_MAGIC) {\n1731:\t\t\tmac_addr = phydev-\u003eattached_dev-\u003edev_addr;\n1732:\t\n1733:\t\t\t/* Store the device address for the magic packet */\n1734:\t\t\tfor (i = 0; i \u003c 3; i++) {\n"
} |
| 43/2 | 2026/08/02 08:34 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 46502 output: 32 thoughts: 267 Thoughts: **Analyzing the YT8824 PHY Driver Implementation** Okay, let's break this down. From what I'm seeing, `yt8824_config_init` is the key initialization function here. It delegates to either `yt8824_internal_config_init_paged` or `yt8824_extern_config_utp_init_paged` and `yt8824_extern_config_sds_init_paged`, and then it concludes with a `yt8824_soft_reset`. Seems like a standard initialization sequence with specific configurations, then a reset. All of these functions are definitely reachable, so that's good. This is a real functional addition. This patch introduces support for a new PHY driver, the `YT8824`, within `motorcomm.c`. That's a solid, tangible change. And the MDIO bus emulation aspect – USB or I2C – is important because it means this isn't just a theoretical driver; it has practical application. It suggests we can interact with this PHY through a variety of interfaces. Now, let's zero in on the core functionality. I need to closely examine the following functions: `yt8824_probe`, `yt8824_config_init`, `yt8824_config_aneg`, `yt8824_aneg_done`, `yt8824_read_status`, `yt8824_soft_reset`, `yt8824_suspend`, and `yt8824_resume`. I'll want to trace the control flow, understand their interactions, and check the MDIO register access pattern. Before I go any further, I'll check if the `MOTORCOMM_PHY` configuration is needed to enable this driver. I'll make sure it's enabled or not and that there are no conditional compilation problems. |
| 44/2 | 2026/08/02 08:34 | tool | grepper |
0mArgs:{
"Expression": "MOTORCOMM_PHY",
"PathPrefix": "drivers/net/phy/Kconfig"
}Results: {
"Output": "drivers/net/phy/Kconfig=344=config MICROSEMI_PHY\n--\ndrivers/net/phy/Kconfig-352-\ndrivers/net/phy/Kconfig:353:config MOTORCOMM_PHY\ndrivers/net/phy/Kconfig-354-\ttristate \"Motorcomm PHYs\"\n"
} |
| 45/2 | 2026/08/02 08:34 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 47312 output: 36 thoughts: 51 Thoughts: **My Current Assessment** Okay, yes, I've got it. We definitely need `MOTORCOMM_PHY` in this configuration. Wait a second... I just remembered that `MOTORCOMM_PHY` is, in fact, a tristate. Given that, the correct thing to do here is to make sure it's returned within `EnableConfigs`. That’s the right approach. Now, before I commit to that, I need to make sure I haven’t missed anything. Let me quickly scan for any other potential dependencies or related configuration points that might be affected by this change. Gotta be thorough. |
| 46/2 | 2026/08/02 08:34 | tool | read-file |
0mArgs:{
"File": "drivers/net/phy/Kconfig",
"FirstLine": 353,
"LineCount": 10
}Results: {
"Contents": " 353:\tconfig MOTORCOMM_PHY\n 354:\t\ttristate \"Motorcomm PHYs\"\n 355:\t\thelp\n 356:\t\t Enables support for Motorcomm network PHYs.\n 357:\t\t Currently supports YT85xx Gigabit Ethernet PHYs.\n 358:\t\n 359:\tconfig NATIONAL_PHY\n 360:\t\ttristate \"National Semiconductor PHYs\"\n 361:\t\thelp\n 362:\t\t Currently supports the DP83865 PHY.\n"
} |
| 47/2 | 2026/08/02 08:34 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 47673 output: 34 thoughts: 80 Thoughts: **Considering Dependencies for MOTORCOMM_PHY** Okay, so I'm focusing on `MOTORCOMM_PHY` here. It seems, initially, that it might be standalone, no immediate dependencies jumping out at me. But wait, let's just make sure – isn't there something…`MDIO_MVUSB`? Or a similar module used for MDIO bus emulation? I feel like there's some connection there, some way to simulate the MDIO interface. Right, time to consider how Syzkaller could interact with it; it offers a few options to interface with MDIO buses: `MDIO_BITBANG`, `MDIO_GPIO`, `MDIO_I2C`, and that `MDIO_MVUSB` I was just mulling over. Let’s double-check how `MDIO_MVUSB` works; that's the path I want to investigate now, see if it is relevant. |
| 48/2 | 2026/08/02 08:34 | tool | grepper |
0mArgs:{
"Expression": "MDIO_MVUSB",
"PathPrefix": "drivers/net/mdio/Kconfig"
}Results: {
"Output": "drivers/net/mdio/Kconfig=107=config MDIO_I2C\n--\ndrivers/net/mdio/Kconfig-116-\ndrivers/net/mdio/Kconfig:117:config MDIO_MVUSB\ndrivers/net/mdio/Kconfig-118-\ttristate \"Marvell USB to MDIO Adapter\"\n"
} |
| 49/2 | 2026/08/02 08:34 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 48084 output: 37 thoughts: 13 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **MDIO_MVUSB Dependency Check** Okay, so the first thing on my mind is to rigorously examine the dependencies of `MDIO_MVUSB`. It's a key module, so I need to make sure I understand everything it relies on. I'm thinking I'll need to go through the typical dependency analysis. I'll need to double check any headers, libraries, or other modules that `MDIO_MVUSB` pulls in. I'm considering potential version conflicts, library compatibility, and the impact of changes in those downstream components on this core module. I'll probably start with a quick code inspection to get a birds-eye view and then drill down as needed. I’m thinking there might be some subtle interactions with the USB stack that I need to look out for, so I'll prioritize those areas. Gotta ensure a solid foundation before I start poking around with it. |
| 50/2 | 2026/08/02 08:34 | tool | read-file |
0mArgs:{
"File": "drivers/net/mdio/Kconfig",
"FirstLine": 117,
"LineCount": 10
}Results: {
"Contents": " 117:\tconfig MDIO_MVUSB\n 118:\t\ttristate \"Marvell USB to MDIO Adapter\"\n 119:\t\tdepends on USB\n 120:\t\thelp\n 121:\t\t A USB to MDIO converter present on development boards for\n 122:\t\t Marvell's Link Street family of Ethernet switches.\n 123:\t\n 124:\tconfig MDIO_MSCC_MIIM\n 125:\t\ttristate \"Microsemi MIIM interface support\"\n 126:\t\tdepends on HAS_IOMEM\n"
} |
| 51/2 | 2026/08/02 08:34 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 48496 output: 37 thoughts: 98 Thoughts: **Considering USB and MDIO Bus Emulation for Syzkaller** Okay, so I'm thinking about how to handle the MDIO bus for testing, particularly within the Syzkaller environment. The usual Syzkaller configs tend to have `USB` enabled, which is a good starting point. My initial thought was to just add `MDIO_MVUSB` to the `EnableConfigs` to be completely safe, and ensure that the MDIO bus can always be emulated. But, hang on... didn't I see something about Syzkaller also using `MDIO_I2C`? Ah yes, it does! And that can be emulated using either `i2c-stub` or `i2c-mock`. Hmmm. Right, better to verify that `MDIO_I2C` configuration and make sure my setup accounts for that. Let me double-check that part... |
| 52/2 | 2026/08/02 08:34 | tool | read-file |
0mArgs:{
"File": "drivers/net/mdio/Kconfig",
"FirstLine": 107,
"LineCount": 10
}Results: {
"Contents": " 107:\tconfig MDIO_I2C\n 108:\t\ttristate\n 109:\t\tdepends on I2C\n 110:\t\thelp\n 111:\t\t Support I2C based PHYs. This provides a MDIO bus bridged\n 112:\t\t to I2C to allow PHYs connected in I2C mode to be accessed\n 113:\t\t using the existing infrastructure.\n 114:\t\n 115:\t\t This is library mode.\n 116:\t\n"
} |
| 53/2 | 2026/08/02 08:34 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 48968 output: 35 thoughts: 47 Thoughts: Okay, let me think this through. **MDIO Interface Confusion** Alright, I need to clarify my understanding of this MDIO interface configuration. Hang on... `MDIO_I2C`. That's not a standalone mode, is it? Right, it's used as a library! It's invoked by other drivers, like the SFP driver, so it doesn't have its own command prompt or anything like that. That makes sense. Okay, so `MDIO_I2C` isn't the one I should be focused on here. Now, what about `MDIO_BITBANG`? That's the mode I *should* be looking at more closely, it seems. Let me consider the implications of that one for a moment. |
| 54/2 | 2026/08/02 08:34 | tool | read-file |
0mArgs:{
"File": "drivers/net/mdio/Kconfig",
"FirstLine": 1,
"LineCount": 20
}Results: {
"Contents": " 1:\t# SPDX-License-Identifier: GPL-2.0-only\n 2:\t#\n 3:\t# MDIO Layer Configuration\n 4:\t#\n 5:\t\n 6:\tmenu \"MDIO controller drivers\"\n 7:\t\tdepends on PHYLIB\n 8:\t\n 9:\tconfig FWNODE_MDIO\n 10:\t\tdef_tristate (ACPI || OF) || COMPILE_TEST\n 11:\t\thelp\n 12:\t\t FWNODE MDIO bus (Ethernet PHY) accessors\n 13:\t\n 14:\tconfig OF_MDIO\n 15:\t\tdef_tristate OF\n 16:\t\tselect FIXED_PHY\n 17:\t\thelp\n 18:\t\t OpenFirmware MDIO bus (Ethernet PHY) accessors\n 19:\t\n 20:\tconfig ACPI_MDIO\n"
} |
| 55/2 | 2026/08/02 08:34 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 49441 output: 44 thoughts: 219 Thoughts: **Kernel Patch Deep Dive** Okay, so I'm looking at this patch and my initial thought is, "Let's just include `MOTORCOMM_PHY` and `MDIO_MVUSB` in `EnableConfigs`. Seems straightforward enough." Then I recognize that this is more than just a configuration change – it introduces functional kernel modifications. This is serious. Specifically, it's adding a new PHY driver, `YT8824`. I need to understand this driver thoroughly. Therefore, I need to focus my attention on the core functionalities: `yt8824_probe`, to understand its initialization; `yt8824_config_init` and `yt8824_config_aneg` which manage configuration and auto-negotiation; `yt8824_aneg_done` to check when auto-negotiation has finished; `yt8824_read_status` to determine the state; and `yt8824_soft_reset` for bringing it back from a non-responsive state. I need to understand how power management is handled, so I should look into `yt8824_suspend` and `yt8824_resume`. Of course, there are also functions for interacting with the hardware, like `yt8824_read_page` and `yt8824_write_page`. Finally, it also includes `genphy_c45_template_testmode`, and before I go any further, I should verify that this function isn't declared as `static`. It's important to know that it is available to the rest of the kernel, if it is to be useful. |
| 56/2 | 2026/08/02 08:34 | tool | grepper |
0mArgs:{
"Expression": "genphy_c45_template_testmode",
"PathPrefix": "drivers/net/phy/phy-c45.c"
}Results: {
"Output": "drivers/net/phy/phy-c45.c=1284=EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain);\n--\ndrivers/net/phy/phy-c45.c-1286-/**\ndrivers/net/phy/phy-c45.c:1287: * genphy_c45_template_testmode - configure template testmode registers\ndrivers/net/phy/phy-c45.c-1288- * @phydev: target phy_device struct\n--\ndrivers/net/phy/phy-c45.c-1295- */\ndrivers/net/phy/phy-c45.c:1296:int genphy_c45_template_testmode(struct phy_device *phydev, int test_mode)\ndrivers/net/phy/phy-c45.c-1297-{\n--\ndrivers/net/phy/phy-c45.c-1300-}\ndrivers/net/phy/phy-c45.c:1301:EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);\ndrivers/net/phy/phy-c45.c-1302-\n"
} |
| 57/2 | 2026/08/02 08:34 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 50376 output: 271 thoughts: 704 Thoughts: **Analyzing the Motorcomm PHY Driver** Okay, it looks like this code has been exported, good. Time to dive into the `motorcomm.c` file and understand the recent additions. I'm going to start by reviewing the functions that have been implemented. I see a wide variety here, from low-level register access (`ytphy_read_top_ext`, `ytphy_write_top_ext`, page access with locks) to more high-level PHY control and configuration (`yt8824_config_init`, `yt8824_aneg_done`, `yt8824_power_on/down`). There are also specific test mode functions, reset operations, and power management callbacks. Now, I need to identify which of these functions are actually *relevant* to my current investigation. My focus will be on the non-static functions, particularly those that are directly associated with the `phy_driver` struct or are called externally. However, wait a minute, `yt8824_probe` is declared static, but it's assigned to the `.probe` field within `motorcomm_phy_drvs`. So, it’s still important and I will include it. I'm making a list for the `FocusSymbols` section now. It'll include: `yt8824_probe`, `yt8824_config_init`, `yt8824_config_aneg`, `yt8824_aneg_done`, `yt8824_read_status`, `yt8824_soft_reset`, `yt8824_suspend`, `yt8824_resume`, `yt8824_read_page`, and `yt8824_write_page`. I'm also going to add `genphy_c45_template_testmode`, as this function seems important to debugging. Finally, I need to ensure the correct configuration options are set. Let me just confirm that `MOTORCOMM_PHY` is indeed the main driver configuration for `drivers/net/phy/motorcomm.c`. Yup, that looks correct. I should also include `MDIO_MVUSB` to ensure that I have MDIO bus emulation available. Okay, with the symbol list and configuration sorted, it's time to call `set-results`. I can begin analyzing the code now. |
| 58/2 | 2026/08/02 08:34 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"MOTORCOMM_PHY",
"MDIO_MVUSB"
],
"FocusSymbols": [
"yt8824_probe",
"yt8824_config_init",
"yt8824_config_aneg",
"yt8824_aneg_done",
"yt8824_read_status",
"yt8824_soft_reset",
"yt8824_suspend",
"yt8824_resume",
"yt8824_read_page",
"yt8824_write_page",
"genphy_c45_template_testmode"
],
"Reasoning": "The patch adds support for the Motorcomm YT8824 PHY driver. It introduces a new PHY driver structure with various callbacks for probing, initialization, auto-negotiation, status reading, and power management. These functions are reachable via MDIO bus emulation (e.g., using the Marvell USB MDIO adapter driver). Fuzzing should focus on the newly added PHY driver callbacks and the exported helper `genphy_c45_template_testmode`.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"MOTORCOMM_PHY",
"MDIO_MVUSB"
],
"FocusSymbols": [
"yt8824_probe",
"yt8824_config_init",
"yt8824_config_aneg",
"yt8824_aneg_done",
"yt8824_read_status",
"yt8824_soft_reset",
"yt8824_suspend",
"yt8824_resume",
"yt8824_read_page",
"yt8824_write_page",
"genphy_c45_template_testmode"
],
"Reasoning": "The patch adds support for the Motorcomm YT8824 PHY driver. It introduces a new PHY driver structure with various callbacks for probing, initialization, auto-negotiation, status reading, and power management. These functions are reachable via MDIO bus emulation (e.g., using the Marvell USB MDIO adapter driver). Fuzzing should focus on the newly added PHY driver callbacks and the exported helper `genphy_c45_template_testmode`.",
"WorthFuzzing": true
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|