AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/09/03 04:40 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch modifies the Microchip KSZ/LAN series DSA Ethernet switch drivers (specifically adding PTP periodic output and pin capabilities for KSZ8463 and related switches). These switch drivers operate over SPI, I2C, or SMI buses and require physical Microchip switch ASICs that are not emulated in standard virtualized environments (such as QEMU or GCE), making these code paths unreachable for fuzzing.",
  "WorthFuzzing": false
}

1/1 2026/09/03 04:40 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit e37cc1141962b276ab5802ef6826af2c311d96a9\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Thu Sep 3 04:40:25 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c\nindex 941ae9f66f70b..6b08bb8fed5b7 100644\n--- a/drivers/net/dsa/microchip/ksz8.c\n+++ b/drivers/net/dsa/microchip/ksz8.c\n@@ -2478,6 +2478,7 @@ static int ksz8463_setup(struct dsa_switch *ds)\n \t\tif (ret)\n \t\t\tgoto free_girq;\n \n+\t\tksz8463_ptp_set_caps(ds);\n \t\tret = ksz_ptp_clock_register(ds);\n \t\tif (ret) {\n \t\t\tdev_err(dev-\u003edev, \"Failed to register PTP clock: %d\\n\",\n@@ -2775,6 +2776,7 @@ static int ksz8_setup(struct dsa_switch *ds)\n \t}\n \n \tif (dev-\u003einfo-\u003eptp_capable) {\n+\t\tksz_ptp_set_caps(ds);\n \t\tret = ksz_ptp_clock_register(ds);\n \t\tif (ret) {\n \t\t\tdev_err(dev-\u003edev, \"Failed to register PTP clock: %d\\n\",\ndiff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c\nindex 3ee995545c579..72528a53b67d2 100644\n--- a/drivers/net/dsa/microchip/ksz9477.c\n+++ b/drivers/net/dsa/microchip/ksz9477.c\n@@ -1781,6 +1781,7 @@ static int ksz9477_setup(struct dsa_switch *ds)\n \t}\n \n \tif (dev-\u003einfo-\u003eptp_capable) {\n+\t\tksz_ptp_set_caps(ds);\n \t\tret = ksz_ptp_clock_register(ds);\n \t\tif (ret) {\n \t\t\tdev_err(dev-\u003edev, \"Failed to register PTP clock: %d\\n\",\ndiff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c\nindex 1a9d6f83a0232..9e234ad71b723 100644\n--- a/drivers/net/dsa/microchip/ksz_common.c\n+++ b/drivers/net/dsa/microchip/ksz_common.c\n@@ -1161,6 +1161,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t.supports_mii = {false, false, true},\n \t\t.supports_rmii = {false, false, true},\n \t\t.internal_phy = {true, true, false},\n+\t\t.n_pins = 12,\n+\t\t.n_per_out = 12,\n \t},\n \n \t[KSZ8563] = {\n@@ -1194,6 +1196,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t.ptp_capable = true,\n \t\t.wr_table = \u0026ksz8563_register_set,\n \t\t.rd_table = \u0026ksz8563_register_set,\n+\t\t.n_pins = 2,\n+\t\t.n_per_out = 3,\n \t},\n \n \t[KSZ8795] = {\n@@ -1414,6 +1418,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t.sgmii_port = 7,\n \t\t.wr_table = \u0026ksz9477_register_set,\n \t\t.rd_table = \u0026ksz9477_register_set,\n+\t\t.n_pins = 2,\n+\t\t.n_per_out = 3,\n \t},\n \n \t[KSZ9896] = {\n@@ -1544,6 +1550,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t.internal_phy = {true, true, false},\n \t\t.gbit_capable = {true, true, true},\n \t\t.ptp_capable = true,\n+\t\t.n_pins = 2,\n+\t\t.n_per_out = 3,\n \t},\n \n \t[KSZ8567] = {\n@@ -1581,6 +1589,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t.gbit_capable\t= {false, false, false, false, false,\n \t\t\t\t   true, true},\n \t\t.ptp_capable = true,\n+\t\t.n_pins = 2,\n+\t\t.n_per_out = 3,\n \t},\n \n \t[KSZ9567] = {\n@@ -1615,6 +1625,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t\t\t   true, false, false},\n \t\t.gbit_capable\t= {true, true, true, true, true, true, true},\n \t\t.ptp_capable = true,\n+\t\t.n_pins = 2,\n+\t\t.n_per_out = 3,\n \t},\n \n \t[LAN9370] = {\n@@ -1646,6 +1658,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t.supports_rgmii = {false, false, false, false, true},\n \t\t.internal_phy = {true, true, true, true, false},\n \t\t.ptp_capable = true,\n+\t\t.n_pins = 2,\n+\t\t.n_per_out = 3,\n \t},\n \n \t[LAN9371] = {\n@@ -1677,6 +1691,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t.supports_rgmii = {false, false, false, false, true, true},\n \t\t.internal_phy = {true, true, true, true, false, false},\n \t\t.ptp_capable = true,\n+\t\t.n_pins = 2,\n+\t\t.n_per_out = 3,\n \t},\n \n \t[LAN9372] = {\n@@ -1712,6 +1728,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t.internal_phy\t= {true, true, true, true,\n \t\t\t\t   false, false, true, true},\n \t\t.ptp_capable = true,\n+\t\t.n_pins = 2,\n+\t\t.n_per_out = 3,\n \t},\n \n \t[LAN9373] = {\n@@ -1747,6 +1765,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t.internal_phy\t= {true, true, true, false,\n \t\t\t\t   false, false, true, true},\n \t\t.ptp_capable = true,\n+\t\t.n_pins = 2,\n+\t\t.n_per_out = 3,\n \t},\n \n \t[LAN9374] = {\n@@ -1782,6 +1802,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {\n \t\t.internal_phy\t= {true, true, true, true,\n \t\t\t\t   false, false, true, true},\n \t\t.ptp_capable = true,\n+\t\t.n_pins = 2,\n+\t\t.n_per_out = 3,\n \t},\n \n \t[LAN9646] = {\ndiff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h\nindex cbe98494578c3..1155b39350c2b 100644\n--- a/drivers/net/dsa/microchip/ksz_common.h\n+++ b/drivers/net/dsa/microchip/ksz_common.h\n@@ -139,6 +139,8 @@ struct ksz_chip_data {\n \tu8 sgmii_port;\n \tconst struct regmap_access_table *wr_table;\n \tconst struct regmap_access_table *rd_table;\n+\tconst u8 n_pins;\n+\tconst u8 n_per_out;\n };\n \n struct ksz_irq {\ndiff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c\nindex 39cc70d65900b..d33034892a8f6 100644\n--- a/drivers/net/dsa/microchip/ksz_ptp.c\n+++ b/drivers/net/dsa/microchip/ksz_ptp.c\n@@ -26,6 +26,7 @@\n  */\n #define KSZ_MAX_DRIFT_CORR 6249999\n #define KSZ_MAX_PULSE_WIDTH 125000000LL\n+#define KSZ8463_MAX_PULSE_WIDTH 500000LL\n \n #define KSZ_PTP_INC_NS 40ULL  /* HW clock is incremented every 40 ns (by 40) */\n #define KSZ_PTP_SUBNS_BITS 32\n@@ -63,6 +64,17 @@ static int ksz_ptp_tou_gpio(struct ksz_device *dev)\n \t\t\t LED_SRC_PTP_GPIO_1 | LED_SRC_PTP_GPIO_2);\n }\n \n+static int ksz8463_ptp_tou_reset(struct ksz_device *dev, u8 unit)\n+{\n+\tint ret;\n+\n+\tret = ksz_rmw16(dev, KSZ8463_TOU_SW_RST, BIT(unit), BIT(unit));\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn ksz_rmw16(dev, KSZ8463_TOU_SW_RST, BIT(unit), 0);\n+}\n+\n static int ksz_ptp_tou_reset(struct ksz_device *dev, u8 unit)\n {\n \tu32 data;\n@@ -86,7 +98,7 @@ static int ksz_ptp_tou_reset(struct ksz_device *dev, u8 unit)\n \t\t\t 0);\n }\n \n-static int ksz_ptp_tou_pulse_verify(u64 pulse_ns)\n+static int ksz_ptp_tou_pulse_verify(u64 pulse_ns, u32 mask)\n {\n \tu32 data;\n \n@@ -94,7 +106,7 @@ static int ksz_ptp_tou_pulse_verify(u64 pulse_ns)\n \t\treturn -EINVAL;\n \n \tdata = (pulse_ns / 8);\n-\tif (!FIELD_FIT(TRIG_PULSE_WIDTH_M, data))\n+\tif ((mask \u0026 data) != data)\n \t\treturn -ERANGE;\n \n \treturn 0;\n@@ -120,6 +132,28 @@ static int ksz_ptp_tou_target_time_set(struct ksz_device *dev,\n \treturn 0;\n }\n \n+static int ksz8463_ptp_tou_start(struct ksz_device *dev, u8 unit)\n+{\n+\tu16 data;\n+\tint ret;\n+\n+\tret = ksz_rmw16(dev, KSZ8463_TOU_EN, BIT(unit), BIT(unit));\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = ksz_read16(dev, KSZ8463_TOU_ACTIVE, \u0026data);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (!(data \u0026 BIT(unit))) {\n+\t\tdev_err(dev-\u003edev, \"%s: Trigger unit%d error!\\n\", __func__,\n+\t\t\tunit);\n+\t\treturn -EIO;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int ksz_ptp_tou_start(struct ksz_device *dev, u8 unit)\n {\n \tu32 data;\n@@ -147,6 +181,56 @@ static int ksz_ptp_tou_start(struct ksz_device *dev, u8 unit)\n \treturn 0;\n }\n \n+static int ksz8463_ptp_configure_perout(struct ksz_device *dev,\n+\t\t\t\t\tu32 cycle_width_ns, u32 pulse_width_ns,\n+\t\t\t\t\tstruct timespec64 const *target_time,\n+\t\t\t\t\tu8 index)\n+{\n+\tstruct ptp_pin_desc *pin = \u0026dev-\u003eptp_data.pin_config[index];\n+\tu16 cfg_base = KSZ8463_TRIG1_CFG + KSZ8463_TRIGN_CFG_SIZE * pin-\u003echan;\n+\tu16 data;\n+\tint ret;\n+\n+\t/* Hardware has only 32 bit */\n+\tif ((target_time-\u003etv_sec \u0026 0xffffffff) != target_time-\u003etv_sec)\n+\t\treturn -EINVAL;\n+\n+\tdata = KSZ8463_NOTIFY_BIT |\n+\t       FIELD_PREP(KSZ8463_PATTERN_M, TRIG_POS_PERIOD) |\n+\t       pin-\u003eindex;\n+\tret = ksz_write16(dev, cfg_base + KSZ8463_PATTERN_OFF, data);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = ksz_write32(dev, cfg_base + KSZ8463_CYCLE_WIDTH_OFF,\n+\t\t\t  cycle_width_ns);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* Set cycle count 0 - Infinite */\n+\tret = ksz_write16(dev, cfg_base + KSZ8463_CYCLE_CNT_OFF, 0);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* KSZ8463 uses a 8 ns unit value to compute the pulse width */\n+\tdata = (pulse_width_ns / 8);\n+\tret = ksz_write16(dev, cfg_base + KSZ8463_PULSE_WIDTH_OFF, data);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = ksz_write32(dev, cfg_base + KSZ8463_TARGET_NSEC,\n+\t\t\t  target_time-\u003etv_nsec);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = ksz_write32(dev, cfg_base + KSZ8463_TARGET_SEC,\n+\t\t\t  target_time-\u003etv_sec);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n static int ksz_ptp_configure_perout(struct ksz_device *dev,\n \t\t\t\t    u32 cycle_width_ns, u32 pulse_width_ns,\n \t\t\t\t    struct timespec64 const *target_time,\n@@ -183,17 +267,11 @@ static int ksz_ptp_configure_perout(struct ksz_device *dev,\n \treturn 0;\n }\n \n-static int ksz_ptp_enable_perout(struct ksz_device *dev,\n-\t\t\t\t struct ptp_perout_request const *request,\n-\t\t\t\t int on)\n+static int ksz_ptp_get_pin(struct ksz_device *dev,\n+\t\t\t   struct ptp_perout_request const *request)\n {\n \tstruct ksz_ptp_data *ptp_data = \u0026dev-\u003eptp_data;\n-\tu64 req_pulse_width_ns;\n-\tu64 cycle_width_ns;\n-\tu64 pulse_width_ns;\n-\tint pin = 0;\n-\tu32 data32;\n-\tint ret;\n+\tint pin;\n \n \tif (request-\u003eflags \u0026 ~PTP_PEROUT_DUTY_CYCLE)\n \t\treturn -EOPNOTSUPP;\n@@ -206,6 +284,114 @@ static int ksz_ptp_enable_perout(struct ksz_device *dev,\n \tif (pin \u003c 0)\n \t\treturn -EINVAL;\n \n+\treturn pin;\n+}\n+\n+static int ksz_ptp_compute_perout_cycle(struct ksz_device *dev,\n+\t\t\t\t\tstruct ptp_perout_request const *request,\n+\t\t\t\t\tu64 *cycle_width_ns)\n+{\n+\tstruct ksz_ptp_data *ptp_data = \u0026dev-\u003eptp_data;\n+\n+\tptp_data-\u003eperout_target_time_first.tv_sec  = request-\u003estart.sec;\n+\tptp_data-\u003eperout_target_time_first.tv_nsec = request-\u003estart.nsec;\n+\n+\tptp_data-\u003eperout_period.tv_sec = request-\u003eperiod.sec;\n+\tptp_data-\u003eperout_period.tv_nsec = request-\u003eperiod.nsec;\n+\n+\t*cycle_width_ns = timespec64_to_ns(\u0026ptp_data-\u003eperout_period);\n+\tif ((*cycle_width_ns \u0026 TRIG_CYCLE_WIDTH_M) != *cycle_width_ns) {\n+\t\t*cycle_width_ns = 0;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static u64 ksz_ptp_compute_perout_pulse(struct ksz_device *dev,\n+\t\t\t\t\tstruct ptp_perout_request const *request,\n+\t\t\t\t\tu64 max_pulse_width)\n+{\n+\tu64 req_pulse_width_ns;\n+\n+\tif (request-\u003eflags \u0026 PTP_PEROUT_DUTY_CYCLE)\n+\t\treturn request-\u003eon.sec * NSEC_PER_SEC +\trequest-\u003eon.nsec;\n+\n+\t/* Use a duty cycle of 50%. Maximum pulse width supported by the\n+\t * hardware is a little bit more than 125 ms.\n+\t */\n+\treq_pulse_width_ns = (request-\u003eperiod.sec * NSEC_PER_SEC +\n+\t\t\t      request-\u003eperiod.nsec) / 2;\n+\treturn min_t(u64, req_pulse_width_ns, max_pulse_width);\n+}\n+\n+static int ksz8463_ptp_enable_perout(struct ksz_device *dev,\n+\t\t\t\t     struct ptp_perout_request const *request,\n+\t\t\t\t     int on)\n+{\n+\tstruct ksz_ptp_data *ptp_data = \u0026dev-\u003eptp_data;\n+\tu64 cycle_width_ns;\n+\tu64 pulse_width_ns;\n+\tint pin;\n+\tint ret;\n+\n+\tpin = ksz_ptp_get_pin(dev, request);\n+\tif (pin \u003c 0)\n+\t\treturn pin;\n+\n+\tret = ksz8463_ptp_tou_reset(dev, request-\u003eindex);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (!on) {\n+\t\tptp_data-\u003etou_mode = KSZ_PTP_TOU_IDLE;\n+\t\treturn 0;\n+\t}\n+\tret = ksz_ptp_compute_perout_cycle(dev, request, \u0026cycle_width_ns);\n+\tif (ret)\n+\t\treturn ret;\n+\tpulse_width_ns = ksz_ptp_compute_perout_pulse(dev, request,\n+\t\t\t\t\t\t      KSZ8463_MAX_PULSE_WIDTH);\n+\n+\tret = ksz_ptp_tou_pulse_verify(pulse_width_ns,\n+\t\t\t\t       KSZ8463_TRIG_PULSE_WIDTH_M);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = ksz8463_ptp_configure_perout(dev, cycle_width_ns, pulse_width_ns,\n+\t\t\t\t\t   \u0026ptp_data-\u003eperout_target_time_first,\n+\t\t\t\t\t   pin);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = ksz_ptp_tou_gpio(dev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = ksz8463_ptp_tou_start(dev, request-\u003eindex);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tptp_data-\u003etou_mode = KSZ_PTP_TOU_PEROUT;\n+\n+\treturn 0;\n+}\n+\n+static int ksz_ptp_enable_perout(struct ksz_device *dev,\n+\t\t\t\t struct ptp_perout_request const *request,\n+\t\t\t\t int on)\n+{\n+\tstruct ksz_ptp_data *ptp_data = \u0026dev-\u003eptp_data;\n+\tu64 cycle_width_ns;\n+\tu64 pulse_width_ns;\n+\tint pin = 0;\n+\tu32 data32;\n+\tint ret;\n+\n+\tpin = ksz_ptp_get_pin(dev, request);\n+\tif (pin \u003c 0)\n+\t\treturn pin;\n+\n \tdata32 = FIELD_PREP(PTP_GPIO_INDEX, pin) |\n \t\t FIELD_PREP(PTP_TOU_INDEX, request-\u003eindex);\n \tret = ksz_rmw32(dev, REG_PTP_UNIT_INDEX__4,\n@@ -221,31 +407,13 @@ static int ksz_ptp_enable_perout(struct ksz_device *dev,\n \t\tptp_data-\u003etou_mode = KSZ_PTP_TOU_IDLE;\n \t\treturn 0;\n \t}\n+\tret = ksz_ptp_compute_perout_cycle(dev, request, \u0026cycle_width_ns);\n+\tif (ret)\n+\t\treturn ret;\n+\tpulse_width_ns = ksz_ptp_compute_perout_pulse(dev, request,\n+\t\t\t\t\t\t      KSZ_MAX_PULSE_WIDTH);\n \n-\tptp_data-\u003eperout_target_time_first.tv_sec  = request-\u003estart.sec;\n-\tptp_data-\u003eperout_target_time_first.tv_nsec = request-\u003estart.nsec;\n-\n-\tptp_data-\u003eperout_period.tv_sec = request-\u003eperiod.sec;\n-\tptp_data-\u003eperout_period.tv_nsec = request-\u003eperiod.nsec;\n-\n-\tcycle_width_ns = timespec64_to_ns(\u0026ptp_data-\u003eperout_period);\n-\tif ((cycle_width_ns \u0026 TRIG_CYCLE_WIDTH_M) != cycle_width_ns)\n-\t\treturn -EINVAL;\n-\n-\tif (request-\u003eflags \u0026 PTP_PEROUT_DUTY_CYCLE) {\n-\t\tpulse_width_ns = request-\u003eon.sec * NSEC_PER_SEC +\n-\t\t\trequest-\u003eon.nsec;\n-\t} else {\n-\t\t/* Use a duty cycle of 50%. Maximum pulse width supported by the\n-\t\t * hardware is a little bit more than 125 ms.\n-\t\t */\n-\t\treq_pulse_width_ns = (request-\u003eperiod.sec * NSEC_PER_SEC +\n-\t\t\t\t      request-\u003eperiod.nsec) / 2;\n-\t\tpulse_width_ns = min_t(u64, req_pulse_width_ns,\n-\t\t\t\t       KSZ_MAX_PULSE_WIDTH);\n-\t}\n-\n-\tret = ksz_ptp_tou_pulse_verify(pulse_width_ns);\n+\tret = ksz_ptp_tou_pulse_verify(pulse_width_ns, TRIG_PULSE_WIDTH_M);\n \tif (ret)\n \t\treturn ret;\n \n@@ -756,11 +924,11 @@ static int ksz_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)\n \treturn ret;\n }\n \n-static int ksz_ptp_restart_perout(struct ksz_device *dev)\n+static int ksz_ptp_prepare_restart_perout(struct ksz_device *dev,\n+\t\t\t\t\t  struct ptp_perout_request *request)\n {\n \tstruct ksz_ptp_data *ptp_data = \u0026dev-\u003eptp_data;\n \ts64 now_ns, first_ns, period_ns, next_ns;\n-\tstruct ptp_perout_request request;\n \tstruct timespec64 next;\n \tstruct timespec64 now;\n \tunsigned int count;\n@@ -791,40 +959,111 @@ static int ksz_ptp_restart_perout(struct ksz_device *dev)\n \n \t/* Restart periodic output signal */\n \tnext = ns_to_timespec64(next_ns);\n-\trequest.start.sec  = next.tv_sec;\n-\trequest.start.nsec = next.tv_nsec;\n-\trequest.period.sec  = ptp_data-\u003eperout_period.tv_sec;\n-\trequest.period.nsec = ptp_data-\u003eperout_period.tv_nsec;\n-\trequest.index = 0;\n-\trequest.flags = 0;\n+\trequest-\u003estart.sec  = next.tv_sec;\n+\trequest-\u003estart.nsec = next.tv_nsec;\n+\trequest-\u003eperiod.sec  = ptp_data-\u003eperout_period.tv_sec;\n+\trequest-\u003eperiod.nsec = ptp_data-\u003eperout_period.tv_nsec;\n+\trequest-\u003eindex = 0;\n+\trequest-\u003eflags = 0;\n+\n+\treturn 0;\n+}\n+\n+static int ksz_ptp_restart_perout(struct ksz_device *dev)\n+{\n+\tstruct ptp_perout_request request;\n+\tint ret;\n+\n+\tret = ksz_ptp_prepare_restart_perout(dev, \u0026request);\n+\tif (ret)\n+\t\treturn ret;\n \n \treturn ksz_ptp_enable_perout(dev, \u0026request, 1);\n }\n \n-static int ksz_ptp_settime(struct ptp_clock_info *ptp,\n-\t\t\t   const struct timespec64 *ts)\n+static int ksz8463_ptp_restart_perout(struct ksz_device *dev)\n {\n-\tstruct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);\n-\tstruct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);\n-\tconst u16 *regs = dev-\u003einfo-\u003eregs;\n+\tstruct ptp_perout_request request;\n \tint ret;\n \n-\tmutex_lock(\u0026ptp_data-\u003elock);\n+\tret = ksz_ptp_prepare_restart_perout(dev, \u0026request);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn ksz8463_ptp_enable_perout(dev, \u0026request, 1);\n+}\n+\n+static int __ksz_ptp_settime(struct ksz_device *dev,\n+\t\t\t     const struct timespec64 *ts)\n+{\n+\tconst u16 *regs = dev-\u003einfo-\u003eregs;\n+\tint ret;\n \n \t/* Write to shadow registers and Load PTP clock */\n \tret = ksz_write16(dev, regs[PTP_RTC_SUB_NANOSEC], PTP_RTC_0NS);\n \tif (ret)\n-\t\tgoto unlock;\n+\t\treturn ret;\n \n \tret = ksz_write32(dev, regs[PTP_RTC_NANOSEC], ts-\u003etv_nsec);\n \tif (ret)\n-\t\tgoto unlock;\n+\t\treturn ret;\n \n \tret = ksz_write32(dev, regs[PTP_RTC_SEC], ts-\u003etv_sec);\n \tif (ret)\n-\t\tgoto unlock;\n+\t\treturn ret;\n \n \tret = ksz_rmw16(dev, regs[PTP_CLK_CTRL], PTP_LOAD_TIME, PTP_LOAD_TIME);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n+static int ksz8463_ptp_settime(struct ptp_clock_info *ptp,\n+\t\t\t       const struct timespec64 *ts)\n+{\n+\tstruct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);\n+\tstruct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);\n+\tint ret;\n+\n+\tmutex_lock(\u0026ptp_data-\u003elock);\n+\n+\tret = __ksz_ptp_settime(dev, ts);\n+\tif (ret)\n+\t\tgoto unlock;\n+\n+\tswitch (ptp_data-\u003etou_mode) {\n+\tcase KSZ_PTP_TOU_IDLE:\n+\t\tbreak;\n+\n+\tcase KSZ_PTP_TOU_PEROUT:\n+\t\tret = ksz8463_ptp_restart_perout(dev);\n+\t\tif (ret)\n+\t\t\tgoto unlock;\n+\n+\t\tbreak;\n+\t}\n+\n+\tspin_lock_bh(\u0026ptp_data-\u003eclock_lock);\n+\tptp_data-\u003eclock_time = *ts;\n+\tspin_unlock_bh(\u0026ptp_data-\u003eclock_lock);\n+\n+unlock:\n+\tmutex_unlock(\u0026ptp_data-\u003elock);\n+\n+\treturn ret;\n+}\n+\n+static int ksz_ptp_settime(struct ptp_clock_info *ptp,\n+\t\t\t   const struct timespec64 *ts)\n+{\n+\tstruct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);\n+\tstruct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);\n+\tint ret;\n+\n+\tmutex_lock(\u0026ptp_data-\u003elock);\n+\n+\tret = __ksz_ptp_settime(dev, ts);\n \tif (ret)\n \t\tgoto unlock;\n \n@@ -890,18 +1129,13 @@ static int ksz_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)\n \treturn ret;\n }\n \n-static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)\n+static int __ksz_ptp_adjtime(struct ksz_device *dev, s64 delta)\n {\n-\tstruct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);\n-\tstruct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);\n-\tstruct timespec64 delta64 = ns_to_timespec64(delta);\n \tconst u16 *regs = dev-\u003einfo-\u003eregs;\n \ts32 sec, nsec;\n \tu16 data16;\n \tint ret;\n \n-\tmutex_lock(\u0026ptp_data-\u003elock);\n-\n \t/* do not use ns_to_timespec64(),\n \t * both sec and nsec are subtracted by hw\n \t */\n@@ -909,15 +1143,15 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)\n \n \tret = ksz_write32(dev, regs[PTP_RTC_NANOSEC], abs(nsec));\n \tif (ret)\n-\t\tgoto unlock;\n+\t\treturn ret;\n \n \tret = ksz_write32(dev, regs[PTP_RTC_SEC], abs(sec));\n \tif (ret)\n-\t\tgoto unlock;\n+\t\treturn ret;\n \n \tret = ksz_read16(dev, regs[PTP_CLK_CTRL], \u0026data16);\n \tif (ret)\n-\t\tgoto unlock;\n+\t\treturn ret;\n \n \tdata16 |= PTP_STEP_ADJ;\n \n@@ -928,6 +1162,56 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)\n \t\tdata16 |= PTP_STEP_DIR;\n \n \tret = ksz_write16(dev, regs[PTP_CLK_CTRL], data16);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n+static int ksz8463_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)\n+{\n+\tstruct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);\n+\tstruct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);\n+\tstruct timespec64 delta64 = ns_to_timespec64(delta);\n+\tint ret;\n+\n+\tmutex_lock(\u0026ptp_data-\u003elock);\n+\n+\tret = __ksz_ptp_adjtime(dev, delta);\n+\tif (ret)\n+\t\tgoto unlock;\n+\n+\tswitch (ptp_data-\u003etou_mode) {\n+\tcase KSZ_PTP_TOU_IDLE:\n+\t\tbreak;\n+\n+\tcase KSZ_PTP_TOU_PEROUT:\n+\t\tret = ksz8463_ptp_restart_perout(dev);\n+\t\tif (ret)\n+\t\t\tgoto unlock;\n+\n+\t\tbreak;\n+\t}\n+\n+\tspin_lock_bh(\u0026ptp_data-\u003eclock_lock);\n+\tptp_data-\u003eclock_time = timespec64_add(ptp_data-\u003eclock_time, delta64);\n+\tspin_unlock_bh(\u0026ptp_data-\u003eclock_lock);\n+\n+unlock:\n+\tmutex_unlock(\u0026ptp_data-\u003elock);\n+\treturn ret;\n+}\n+\n+static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)\n+{\n+\tstruct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);\n+\tstruct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);\n+\tstruct timespec64 delta64 = ns_to_timespec64(delta);\n+\tint ret;\n+\n+\tmutex_lock(\u0026ptp_data-\u003elock);\n+\n+\tret = __ksz_ptp_adjtime(dev, delta);\n \tif (ret)\n \t\tgoto unlock;\n \n@@ -952,6 +1236,26 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)\n \treturn ret;\n }\n \n+static int ksz8463_ptp_enable(struct ptp_clock_info *ptp,\n+\t\t\t      struct ptp_clock_request *req, int on)\n+{\n+\tstruct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);\n+\tstruct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);\n+\tint ret;\n+\n+\tswitch (req-\u003etype) {\n+\tcase PTP_CLK_REQ_PEROUT:\n+\t\tmutex_lock(\u0026ptp_data-\u003elock);\n+\t\tret = ksz8463_ptp_enable_perout(dev, \u0026req-\u003eperout, on);\n+\t\tmutex_unlock(\u0026ptp_data-\u003elock);\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\treturn ret;\n+}\n+\n static int ksz_ptp_enable(struct ptp_clock_info *ptp,\n \t\t\t  struct ptp_clock_request *req, int on)\n {\n@@ -1028,17 +1332,33 @@ static int ksz_ptp_start_clock(struct ksz_device *dev)\n \treturn 0;\n }\n \n-int ksz_ptp_clock_register(struct dsa_switch *ds)\n+void ksz8463_ptp_set_caps(struct dsa_switch *ds)\n+{\n+\tstruct ksz_device *dev = ds-\u003epriv;\n+\tstruct ksz_ptp_data *ptp_data;\n+\n+\tptp_data = \u0026dev-\u003eptp_data;\n+\n+\tptp_data-\u003ecaps.owner\t\t= THIS_MODULE;\n+\tsnprintf(ptp_data-\u003ecaps.name, 16, \"Microchip Clock\");\n+\tptp_data-\u003ecaps.max_adj\t\t= KSZ_MAX_DRIFT_CORR;\n+\tptp_data-\u003ecaps.gettime64\t= ksz_ptp_gettime;\n+\tptp_data-\u003ecaps.settime64\t= ksz8463_ptp_settime;\n+\tptp_data-\u003ecaps.adjfine\t\t= ksz_ptp_adjfine;\n+\tptp_data-\u003ecaps.adjtime\t\t= ksz8463_ptp_adjtime;\n+\tptp_data-\u003ecaps.do_aux_work\t= ksz_ptp_do_aux_work;\n+\tptp_data-\u003ecaps.enable\t\t= ksz8463_ptp_enable;\n+\tptp_data-\u003ecaps.verify\t\t= ksz_ptp_verify_pin;\n+\tptp_data-\u003ecaps.n_pins\t\t= dev-\u003einfo-\u003en_pins;\n+\tptp_data-\u003ecaps.n_per_out\t= dev-\u003einfo-\u003en_per_out;\n+}\n+\n+void ksz_ptp_set_caps(struct dsa_switch *ds)\n {\n \tstruct ksz_device *dev = ds-\u003epriv;\n-\tconst u16 *regs = dev-\u003einfo-\u003eregs;\n \tstruct ksz_ptp_data *ptp_data;\n-\tint ret;\n-\tu8 i;\n \n \tptp_data = \u0026dev-\u003eptp_data;\n-\tmutex_init(\u0026ptp_data-\u003elock);\n-\tspin_lock_init(\u0026ptp_data-\u003eclock_lock);\n \n \tptp_data-\u003ecaps.owner\t\t= THIS_MODULE;\n \tsnprintf(ptp_data-\u003ecaps.name, 16, \"Microchip Clock\");\n@@ -1050,14 +1370,27 @@ int ksz_ptp_clock_register(struct dsa_switch *ds)\n \tptp_data-\u003ecaps.do_aux_work\t= ksz_ptp_do_aux_work;\n \tptp_data-\u003ecaps.enable\t\t= ksz_ptp_enable;\n \tptp_data-\u003ecaps.verify\t\t= ksz_ptp_verify_pin;\n-\tptp_data-\u003ecaps.n_pins\t\t= KSZ_PTP_N_GPIO;\n-\tptp_data-\u003ecaps.n_per_out\t= 3;\n+\tptp_data-\u003ecaps.n_pins\t\t= dev-\u003einfo-\u003en_pins;\n+\tptp_data-\u003ecaps.n_per_out\t= dev-\u003einfo-\u003en_per_out;\n+}\n+\n+int ksz_ptp_clock_register(struct dsa_switch *ds)\n+{\n+\tstruct ksz_device *dev = ds-\u003epriv;\n+\tconst u16 *regs = dev-\u003einfo-\u003eregs;\n+\tstruct ksz_ptp_data *ptp_data;\n+\tint ret;\n+\tu8 i;\n+\n+\tptp_data = \u0026dev-\u003eptp_data;\n+\tmutex_init(\u0026ptp_data-\u003elock);\n+\tspin_lock_init(\u0026ptp_data-\u003eclock_lock);\n \n \tret = ksz_ptp_start_clock(dev);\n \tif (ret)\n \t\treturn ret;\n \n-\tfor (i = 0; i \u003c KSZ_PTP_N_GPIO; i++) {\n+\tfor (i = 0; i \u003c dev-\u003einfo-\u003en_pins; i++) {\n \t\tstruct ptp_pin_desc *ptp_pin = \u0026ptp_data-\u003epin_config[i];\n \n \t\tsnprintf(ptp_pin-\u003ename,\ndiff --git a/drivers/net/dsa/microchip/ksz_ptp.h b/drivers/net/dsa/microchip/ksz_ptp.h\nindex 7067ec9bd1e6f..92589cf373ac2 100644\n--- a/drivers/net/dsa/microchip/ksz_ptp.h\n+++ b/drivers/net/dsa/microchip/ksz_ptp.h\n@@ -12,7 +12,7 @@\n \n #include \u003clinux/ptp_clock_kernel.h\u003e\n \n-#define KSZ_PTP_N_GPIO\t\t2\n+#define KSZ_PTP_N_GPIO\t\t12\n \n enum ksz_ptp_tou_mode {\n \tKSZ_PTP_TOU_IDLE,\n@@ -33,6 +33,8 @@ struct ksz_ptp_data {\n \tstruct timespec64 perout_period;\n };\n \n+void ksz_ptp_set_caps(struct dsa_switch *ds);\n+void ksz8463_ptp_set_caps(struct dsa_switch *ds);\n int ksz_ptp_clock_register(struct dsa_switch *ds);\n \n void ksz_ptp_clock_unregister(struct dsa_switch *ds);\n@@ -65,6 +67,7 @@ struct ksz_ptp_data {\n \tstruct mutex lock;\n };\n \n+static inline void ksz_ptp_set_caps(struct dsa_switch *ds) { }\n static inline int ksz_ptp_clock_register(struct dsa_switch *ds)\n {\n \treturn 0;\ndiff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/microchip/ksz_ptp_reg.h\nindex 65ea8577af755..16f117fa5d49b 100644\n--- a/drivers/net/dsa/microchip/ksz_ptp_reg.h\n+++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h\n@@ -51,6 +51,22 @@\n \n #define REG_PTP_UNIT_INDEX__4\t\t0x0520\n \n+#define KSZ8463_TOU_ACTIVE\t\t0x202\n+#define KSZ8463_TOU_EN\t\t\t0x206\n+#define KSZ8463_TOU_SW_RST\t\t0x208\n+\n+#define KSZ8463_TRIGN_CFG_SIZE\t\t0x20\n+#define KSZ8463_TRIG1_CFG\t\t0x220\n+#define KSZ8463_TARGET_NSEC\t\t0x000\n+#define KSZ8463_TARGET_SEC\t\t0x004\n+#define KSZ8463_PATTERN_OFF\t\t0x008\n+#define KSZ8463_NOTIFY_BIT\t\tBIT(8)\n+#define KSZ8463_PATTERN_M\t\tGENMASK(6, 4)\n+#define KSZ8463_PULSE_WIDTH_OFF\t\t0x00A\n+#define KSZ8463_TRIG_PULSE_WIDTH_M\tGENMASK(15, 0)\n+#define KSZ8463_CYCLE_WIDTH_OFF\t\t0x00C\n+#define KSZ8463_CYCLE_CNT_OFF\t\t0x010\n+\n #define PTP_GPIO_INDEX\t\t\tGENMASK(19, 16)\n #define PTP_TSI_INDEX\t\t\tBIT(8)\n #define PTP_TOU_INDEX\t\t\tGENMASK(1, 0)\ndiff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c\nindex 86ce3a86705f9..3a209122fc7dc 100644\n--- a/drivers/net/dsa/microchip/lan937x_main.c\n+++ b/drivers/net/dsa/microchip/lan937x_main.c\n@@ -867,6 +867,7 @@ static int lan937x_setup(struct dsa_switch *ds)\n \t\t}\n \t}\n \n+\tksz_ptp_set_caps(ds);\n \tret = ksz_ptp_clock_register(ds);\n \tif (ret) {\n \t\tdev_err(dev-\u003edev, \"Failed to register PTP clock: %d\\n\",\n"
}

2/1 2026/09/03 04:40 agent patch-evaluator
0m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the Microchip KSZ/LAN series DSA Ethernet switch drivers (specifically adding PTP periodic output and pin capabilities for KSZ8463 and related switches). These switch drivers operate over SPI, I2C, or SMI buses and require physical Microchip switch ASICs that are not emulated in standard virtualized environments (such as QEMU or GCE), making these code paths unreachable for fuzzing.",
  "WorthFuzzing": false
}

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 e37cc1141962b276ab5802ef6826af2c311d96a9
Author: syz-cluster <triage@syzkaller.com>
Date:   Thu Sep 3 04:40:25 2026 +0000

    syz-cluster: applied patch under review

diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c
index 941ae9f66f70b..6b08bb8fed5b7 100644
--- a/drivers/net/dsa/microchip/ksz8.c
+++ b/drivers/net/dsa/microchip/ksz8.c
@@ -2478,6 +2478,7 @@ static int ksz8463_setup(struct dsa_switch *ds)
 		if (ret)
 			goto free_girq;
 
+		ksz8463_ptp_set_caps(ds);
 		ret = ksz_ptp_clock_register(ds);
 		if (ret) {
 			dev_err(dev->dev, "Failed to register PTP clock: %d\n",
@@ -2775,6 +2776,7 @@ static int ksz8_setup(struct dsa_switch *ds)
 	}
 
 	if (dev->info->ptp_capable) {
+		ksz_ptp_set_caps(ds);
 		ret = ksz_ptp_clock_register(ds);
 		if (ret) {
 			dev_err(dev->dev, "Failed to register PTP clock: %d\n",
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 3ee995545c579..72528a53b67d2 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1781,6 +1781,7 @@ static int ksz9477_setup(struct dsa_switch *ds)
 	}
 
 	if (dev->info->ptp_capable) {
+		ksz_ptp_set_caps(ds);
 		ret = ksz_ptp_clock_register(ds);
 		if (ret) {
 			dev_err(dev->dev, "Failed to register PTP clock: %d\n",
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 1a9d6f83a0232..9e234ad71b723 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -1161,6 +1161,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 		.supports_mii = {false, false, true},
 		.supports_rmii = {false, false, true},
 		.internal_phy = {true, true, false},
+		.n_pins = 12,
+		.n_per_out = 12,
 	},
 
 	[KSZ8563] = {
@@ -1194,6 +1196,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 		.ptp_capable = true,
 		.wr_table = &ksz8563_register_set,
 		.rd_table = &ksz8563_register_set,
+		.n_pins = 2,
+		.n_per_out = 3,
 	},
 
 	[KSZ8795] = {
@@ -1414,6 +1418,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 		.sgmii_port = 7,
 		.wr_table = &ksz9477_register_set,
 		.rd_table = &ksz9477_register_set,
+		.n_pins = 2,
+		.n_per_out = 3,
 	},
 
 	[KSZ9896] = {
@@ -1544,6 +1550,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 		.internal_phy = {true, true, false},
 		.gbit_capable = {true, true, true},
 		.ptp_capable = true,
+		.n_pins = 2,
+		.n_per_out = 3,
 	},
 
 	[KSZ8567] = {
@@ -1581,6 +1589,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 		.gbit_capable	= {false, false, false, false, false,
 				   true, true},
 		.ptp_capable = true,
+		.n_pins = 2,
+		.n_per_out = 3,
 	},
 
 	[KSZ9567] = {
@@ -1615,6 +1625,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 				   true, false, false},
 		.gbit_capable	= {true, true, true, true, true, true, true},
 		.ptp_capable = true,
+		.n_pins = 2,
+		.n_per_out = 3,
 	},
 
 	[LAN9370] = {
@@ -1646,6 +1658,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 		.supports_rgmii = {false, false, false, false, true},
 		.internal_phy = {true, true, true, true, false},
 		.ptp_capable = true,
+		.n_pins = 2,
+		.n_per_out = 3,
 	},
 
 	[LAN9371] = {
@@ -1677,6 +1691,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 		.supports_rgmii = {false, false, false, false, true, true},
 		.internal_phy = {true, true, true, true, false, false},
 		.ptp_capable = true,
+		.n_pins = 2,
+		.n_per_out = 3,
 	},
 
 	[LAN9372] = {
@@ -1712,6 +1728,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 		.internal_phy	= {true, true, true, true,
 				   false, false, true, true},
 		.ptp_capable = true,
+		.n_pins = 2,
+		.n_per_out = 3,
 	},
 
 	[LAN9373] = {
@@ -1747,6 +1765,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 		.internal_phy	= {true, true, true, false,
 				   false, false, true, true},
 		.ptp_capable = true,
+		.n_pins = 2,
+		.n_per_out = 3,
 	},
 
 	[LAN9374] = {
@@ -1782,6 +1802,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
 		.internal_phy	= {true, true, true, true,
 				   false, false, true, true},
 		.ptp_capable = true,
+		.n_pins = 2,
+		.n_per_out = 3,
 	},
 
 	[LAN9646] = {
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index cbe98494578c3..1155b39350c2b 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -139,6 +139,8 @@ struct ksz_chip_data {
 	u8 sgmii_port;
 	const struct regmap_access_table *wr_table;
 	const struct regmap_access_table *rd_table;
+	const u8 n_pins;
+	const u8 n_per_out;
 };
 
 struct ksz_irq {
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index 39cc70d65900b..d33034892a8f6 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -26,6 +26,7 @@
  */
 #define KSZ_MAX_DRIFT_CORR 6249999
 #define KSZ_MAX_PULSE_WIDTH 125000000LL
+#define KSZ8463_MAX_PULSE_WIDTH 500000LL
 
 #define KSZ_PTP_INC_NS 40ULL  /* HW clock is incremented every 40 ns (by 40) */
 #define KSZ_PTP_SUBNS_BITS 32
@@ -63,6 +64,17 @@ static int ksz_ptp_tou_gpio(struct ksz_device *dev)
 			 LED_SRC_PTP_GPIO_1 | LED_SRC_PTP_GPIO_2);
 }
 
+static int ksz8463_ptp_tou_reset(struct ksz_device *dev, u8 unit)
+{
+	int ret;
+
+	ret = ksz_rmw16(dev, KSZ8463_TOU_SW_RST, BIT(unit), BIT(unit));
+	if (ret)
+		return ret;
+
+	return ksz_rmw16(dev, KSZ8463_TOU_SW_RST, BIT(unit), 0);
+}
+
 static int ksz_ptp_tou_reset(struct ksz_device *dev, u8 unit)
 {
 	u32 data;
@@ -86,7 +98,7 @@ static int ksz_ptp_tou_reset(struct ksz_device *dev, u8 unit)
 			 0);
 }
 
-static int ksz_ptp_tou_pulse_verify(u64 pulse_ns)
+static int ksz_ptp_tou_pulse_verify(u64 pulse_ns, u32 mask)
 {
 	u32 data;
 
@@ -94,7 +106,7 @@ static int ksz_ptp_tou_pulse_verify(u64 pulse_ns)
 		return -EINVAL;
 
 	data = (pulse_ns / 8);
-	if (!FIELD_FIT(TRIG_PULSE_WIDTH_M, data))
+	if ((mask & data) != data)
 		return -ERANGE;
 
 	return 0;
@@ -120,6 +132,28 @@ static int ksz_ptp_tou_target_time_set(struct ksz_device *dev,
 	return 0;
 }
 
+static int ksz8463_ptp_tou_start(struct ksz_device *dev, u8 unit)
+{
+	u16 data;
+	int ret;
+
+	ret = ksz_rmw16(dev, KSZ8463_TOU_EN, BIT(unit), BIT(unit));
+	if (ret)
+		return ret;
+
+	ret = ksz_read16(dev, KSZ8463_TOU_ACTIVE, &data);
+	if (ret)
+		return ret;
+
+	if (!(data & BIT(unit))) {
+		dev_err(dev->dev, "%s: Trigger unit%d error!\n", __func__,
+			unit);
+		return -EIO;
+	}
+
+	return 0;
+}
+
 static int ksz_ptp_tou_start(struct ksz_device *dev, u8 unit)
 {
 	u32 data;
@@ -147,6 +181,56 @@ static int ksz_ptp_tou_start(struct ksz_device *dev, u8 unit)
 	return 0;
 }
 
+static int ksz8463_ptp_configure_perout(struct ksz_device *dev,
+					u32 cycle_width_ns, u32 pulse_width_ns,
+					struct timespec64 const *target_time,
+					u8 index)
+{
+	struct ptp_pin_desc *pin = &dev->ptp_data.pin_config[index];
+	u16 cfg_base = KSZ8463_TRIG1_CFG + KSZ8463_TRIGN_CFG_SIZE * pin->chan;
+	u16 data;
+	int ret;
+
+	/* Hardware has only 32 bit */
+	if ((target_time->tv_sec & 0xffffffff) != target_time->tv_sec)
+		return -EINVAL;
+
+	data = KSZ8463_NOTIFY_BIT |
+	       FIELD_PREP(KSZ8463_PATTERN_M, TRIG_POS_PERIOD) |
+	       pin->index;
+	ret = ksz_write16(dev, cfg_base + KSZ8463_PATTERN_OFF, data);
+	if (ret)
+		return ret;
+
+	ret = ksz_write32(dev, cfg_base + KSZ8463_CYCLE_WIDTH_OFF,
+			  cycle_width_ns);
+	if (ret)
+		return ret;
+
+	/* Set cycle count 0 - Infinite */
+	ret = ksz_write16(dev, cfg_base + KSZ8463_CYCLE_CNT_OFF, 0);
+	if (ret)
+		return ret;
+
+	/* KSZ8463 uses a 8 ns unit value to compute the pulse width */
+	data = (pulse_width_ns / 8);
+	ret = ksz_write16(dev, cfg_base + KSZ8463_PULSE_WIDTH_OFF, data);
+	if (ret)
+		return ret;
+
+	ret = ksz_write32(dev, cfg_base + KSZ8463_TARGET_NSEC,
+			  target_time->tv_nsec);
+	if (ret)
+		return ret;
+
+	ret = ksz_write32(dev, cfg_base + KSZ8463_TARGET_SEC,
+			  target_time->tv_sec);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static int ksz_ptp_configure_perout(struct ksz_device *dev,
 				    u32 cycle_width_ns, u32 pulse_width_ns,
 				    struct timespec64 const *target_time,
@@ -183,17 +267,11 @@ static int ksz_ptp_configure_perout(struct ksz_device *dev,
 	return 0;
 }
 
-static int ksz_ptp_enable_perout(struct ksz_device *dev,
-				 struct ptp_perout_request const *request,
-				 int on)
+static int ksz_ptp_get_pin(struct ksz_device *dev,
+			   struct ptp_perout_request const *request)
 {
 	struct ksz_ptp_data *ptp_data = &dev->ptp_data;
-	u64 req_pulse_width_ns;
-	u64 cycle_width_ns;
-	u64 pulse_width_ns;
-	int pin = 0;
-	u32 data32;
-	int ret;
+	int pin;
 
 	if (request->flags & ~PTP_PEROUT_DUTY_CYCLE)
 		return -EOPNOTSUPP;
@@ -206,6 +284,114 @@ static int ksz_ptp_enable_perout(struct ksz_device *dev,
 	if (pin < 0)
 		return -EINVAL;
 
+	return pin;
+}
+
+static int ksz_ptp_compute_perout_cycle(struct ksz_device *dev,
+					struct ptp_perout_request const *request,
+					u64 *cycle_width_ns)
+{
+	struct ksz_ptp_data *ptp_data = &dev->ptp_data;
+
+	ptp_data->perout_target_time_first.tv_sec  = request->start.sec;
+	ptp_data->perout_target_time_first.tv_nsec = request->start.nsec;
+
+	ptp_data->perout_period.tv_sec = request->period.sec;
+	ptp_data->perout_period.tv_nsec = request->period.nsec;
+
+	*cycle_width_ns = timespec64_to_ns(&ptp_data->perout_period);
+	if ((*cycle_width_ns & TRIG_CYCLE_WIDTH_M) != *cycle_width_ns) {
+		*cycle_width_ns = 0;
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static u64 ksz_ptp_compute_perout_pulse(struct ksz_device *dev,
+					struct ptp_perout_request const *request,
+					u64 max_pulse_width)
+{
+	u64 req_pulse_width_ns;
+
+	if (request->flags & PTP_PEROUT_DUTY_CYCLE)
+		return request->on.sec * NSEC_PER_SEC +	request->on.nsec;
+
+	/* Use a duty cycle of 50%. Maximum pulse width supported by the
+	 * hardware is a little bit more than 125 ms.
+	 */
+	req_pulse_width_ns = (request->period.sec * NSEC_PER_SEC +
+			      request->period.nsec) / 2;
+	return min_t(u64, req_pulse_width_ns, max_pulse_width);
+}
+
+static int ksz8463_ptp_enable_perout(struct ksz_device *dev,
+				     struct ptp_perout_request const *request,
+				     int on)
+{
+	struct ksz_ptp_data *ptp_data = &dev->ptp_data;
+	u64 cycle_width_ns;
+	u64 pulse_width_ns;
+	int pin;
+	int ret;
+
+	pin = ksz_ptp_get_pin(dev, request);
+	if (pin < 0)
+		return pin;
+
+	ret = ksz8463_ptp_tou_reset(dev, request->index);
+	if (ret)
+		return ret;
+
+	if (!on) {
+		ptp_data->tou_mode = KSZ_PTP_TOU_IDLE;
+		return 0;
+	}
+	ret = ksz_ptp_compute_perout_cycle(dev, request, &cycle_width_ns);
+	if (ret)
+		return ret;
+	pulse_width_ns = ksz_ptp_compute_perout_pulse(dev, request,
+						      KSZ8463_MAX_PULSE_WIDTH);
+
+	ret = ksz_ptp_tou_pulse_verify(pulse_width_ns,
+				       KSZ8463_TRIG_PULSE_WIDTH_M);
+	if (ret)
+		return ret;
+
+	ret = ksz8463_ptp_configure_perout(dev, cycle_width_ns, pulse_width_ns,
+					   &ptp_data->perout_target_time_first,
+					   pin);
+	if (ret)
+		return ret;
+
+	ret = ksz_ptp_tou_gpio(dev);
+	if (ret)
+		return ret;
+
+	ret = ksz8463_ptp_tou_start(dev, request->index);
+	if (ret)
+		return ret;
+
+	ptp_data->tou_mode = KSZ_PTP_TOU_PEROUT;
+
+	return 0;
+}
+
+static int ksz_ptp_enable_perout(struct ksz_device *dev,
+				 struct ptp_perout_request const *request,
+				 int on)
+{
+	struct ksz_ptp_data *ptp_data = &dev->ptp_data;
+	u64 cycle_width_ns;
+	u64 pulse_width_ns;
+	int pin = 0;
+	u32 data32;
+	int ret;
+
+	pin = ksz_ptp_get_pin(dev, request);
+	if (pin < 0)
+		return pin;
+
 	data32 = FIELD_PREP(PTP_GPIO_INDEX, pin) |
 		 FIELD_PREP(PTP_TOU_INDEX, request->index);
 	ret = ksz_rmw32(dev, REG_PTP_UNIT_INDEX__4,
@@ -221,31 +407,13 @@ static int ksz_ptp_enable_perout(struct ksz_device *dev,
 		ptp_data->tou_mode = KSZ_PTP_TOU_IDLE;
 		return 0;
 	}
+	ret = ksz_ptp_compute_perout_cycle(dev, request, &cycle_width_ns);
+	if (ret)
+		return ret;
+	pulse_width_ns = ksz_ptp_compute_perout_pulse(dev, request,
+						      KSZ_MAX_PULSE_WIDTH);
 
-	ptp_data->perout_target_time_first.tv_sec  = request->start.sec;
-	ptp_data->perout_target_time_first.tv_nsec = request->start.nsec;
-
-	ptp_data->perout_period.tv_sec = request->period.sec;
-	ptp_data->perout_period.tv_nsec = request->period.nsec;
-
-	cycle_width_ns = timespec64_to_ns(&ptp_data->perout_period);
-	if ((cycle_width_ns & TRIG_CYCLE_WIDTH_M) != cycle_width_ns)
-		return -EINVAL;
-
-	if (request->flags & PTP_PEROUT_DUTY_CYCLE) {
-		pulse_width_ns = request->on.sec * NSEC_PER_SEC +
-			request->on.nsec;
-	} else {
-		/* Use a duty cycle of 50%. Maximum pulse width supported by the
-		 * hardware is a little bit more than 125 ms.
-		 */
-		req_pulse_width_ns = (request->period.sec * NSEC_PER_SEC +
-				      request->period.nsec) / 2;
-		pulse_width_ns = min_t(u64, req_pulse_width_ns,
-				       KSZ_MAX_PULSE_WIDTH);
-	}
-
-	ret = ksz_ptp_tou_pulse_verify(pulse_width_ns);
+	ret = ksz_ptp_tou_pulse_verify(pulse_width_ns, TRIG_PULSE_WIDTH_M);
 	if (ret)
 		return ret;
 
@@ -756,11 +924,11 @@ static int ksz_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 	return ret;
 }
 
-static int ksz_ptp_restart_perout(struct ksz_device *dev)
+static int ksz_ptp_prepare_restart_perout(struct ksz_device *dev,
+					  struct ptp_perout_request *request)
 {
 	struct ksz_ptp_data *ptp_data = &dev->ptp_data;
 	s64 now_ns, first_ns, period_ns, next_ns;
-	struct ptp_perout_request request;
 	struct timespec64 next;
 	struct timespec64 now;
 	unsigned int count;
@@ -791,40 +959,111 @@ static int ksz_ptp_restart_perout(struct ksz_device *dev)
 
 	/* Restart periodic output signal */
 	next = ns_to_timespec64(next_ns);
-	request.start.sec  = next.tv_sec;
-	request.start.nsec = next.tv_nsec;
-	request.period.sec  = ptp_data->perout_period.tv_sec;
-	request.period.nsec = ptp_data->perout_period.tv_nsec;
-	request.index = 0;
-	request.flags = 0;
+	request->start.sec  = next.tv_sec;
+	request->start.nsec = next.tv_nsec;
+	request->period.sec  = ptp_data->perout_period.tv_sec;
+	request->period.nsec = ptp_data->perout_period.tv_nsec;
+	request->index = 0;
+	request->flags = 0;
+
+	return 0;
+}
+
+static int ksz_ptp_restart_perout(struct ksz_device *dev)
+{
+	struct ptp_perout_request request;
+	int ret;
+
+	ret = ksz_ptp_prepare_restart_perout(dev, &request);
+	if (ret)
+		return ret;
 
 	return ksz_ptp_enable_perout(dev, &request, 1);
 }
 
-static int ksz_ptp_settime(struct ptp_clock_info *ptp,
-			   const struct timespec64 *ts)
+static int ksz8463_ptp_restart_perout(struct ksz_device *dev)
 {
-	struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
-	struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
-	const u16 *regs = dev->info->regs;
+	struct ptp_perout_request request;
 	int ret;
 
-	mutex_lock(&ptp_data->lock);
+	ret = ksz_ptp_prepare_restart_perout(dev, &request);
+	if (ret)
+		return ret;
+
+	return ksz8463_ptp_enable_perout(dev, &request, 1);
+}
+
+static int __ksz_ptp_settime(struct ksz_device *dev,
+			     const struct timespec64 *ts)
+{
+	const u16 *regs = dev->info->regs;
+	int ret;
 
 	/* Write to shadow registers and Load PTP clock */
 	ret = ksz_write16(dev, regs[PTP_RTC_SUB_NANOSEC], PTP_RTC_0NS);
 	if (ret)
-		goto unlock;
+		return ret;
 
 	ret = ksz_write32(dev, regs[PTP_RTC_NANOSEC], ts->tv_nsec);
 	if (ret)
-		goto unlock;
+		return ret;
 
 	ret = ksz_write32(dev, regs[PTP_RTC_SEC], ts->tv_sec);
 	if (ret)
-		goto unlock;
+		return ret;
 
 	ret = ksz_rmw16(dev, regs[PTP_CLK_CTRL], PTP_LOAD_TIME, PTP_LOAD_TIME);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static int ksz8463_ptp_settime(struct ptp_clock_info *ptp,
+			       const struct timespec64 *ts)
+{
+	struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
+	struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
+	int ret;
+
+	mutex_lock(&ptp_data->lock);
+
+	ret = __ksz_ptp_settime(dev, ts);
+	if (ret)
+		goto unlock;
+
+	switch (ptp_data->tou_mode) {
+	case KSZ_PTP_TOU_IDLE:
+		break;
+
+	case KSZ_PTP_TOU_PEROUT:
+		ret = ksz8463_ptp_restart_perout(dev);
+		if (ret)
+			goto unlock;
+
+		break;
+	}
+
+	spin_lock_bh(&ptp_data->clock_lock);
+	ptp_data->clock_time = *ts;
+	spin_unlock_bh(&ptp_data->clock_lock);
+
+unlock:
+	mutex_unlock(&ptp_data->lock);
+
+	return ret;
+}
+
+static int ksz_ptp_settime(struct ptp_clock_info *ptp,
+			   const struct timespec64 *ts)
+{
+	struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
+	struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
+	int ret;
+
+	mutex_lock(&ptp_data->lock);
+
+	ret = __ksz_ptp_settime(dev, ts);
 	if (ret)
 		goto unlock;
 
@@ -890,18 +1129,13 @@ static int ksz_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
 	return ret;
 }
 
-static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
+static int __ksz_ptp_adjtime(struct ksz_device *dev, s64 delta)
 {
-	struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
-	struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
-	struct timespec64 delta64 = ns_to_timespec64(delta);
 	const u16 *regs = dev->info->regs;
 	s32 sec, nsec;
 	u16 data16;
 	int ret;
 
-	mutex_lock(&ptp_data->lock);
-
 	/* do not use ns_to_timespec64(),
 	 * both sec and nsec are subtracted by hw
 	 */
@@ -909,15 +1143,15 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 
 	ret = ksz_write32(dev, regs[PTP_RTC_NANOSEC], abs(nsec));
 	if (ret)
-		goto unlock;
+		return ret;
 
 	ret = ksz_write32(dev, regs[PTP_RTC_SEC], abs(sec));
 	if (ret)
-		goto unlock;
+		return ret;
 
 	ret = ksz_read16(dev, regs[PTP_CLK_CTRL], &data16);
 	if (ret)
-		goto unlock;
+		return ret;
 
 	data16 |= PTP_STEP_ADJ;
 
@@ -928,6 +1162,56 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 		data16 |= PTP_STEP_DIR;
 
 	ret = ksz_write16(dev, regs[PTP_CLK_CTRL], data16);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static int ksz8463_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
+{
+	struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
+	struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
+	struct timespec64 delta64 = ns_to_timespec64(delta);
+	int ret;
+
+	mutex_lock(&ptp_data->lock);
+
+	ret = __ksz_ptp_adjtime(dev, delta);
+	if (ret)
+		goto unlock;
+
+	switch (ptp_data->tou_mode) {
+	case KSZ_PTP_TOU_IDLE:
+		break;
+
+	case KSZ_PTP_TOU_PEROUT:
+		ret = ksz8463_ptp_restart_perout(dev);
+		if (ret)
+			goto unlock;
+
+		break;
+	}
+
+	spin_lock_bh(&ptp_data->clock_lock);
+	ptp_data->clock_time = timespec64_add(ptp_data->clock_time, delta64);
+	spin_unlock_bh(&ptp_data->clock_lock);
+
+unlock:
+	mutex_unlock(&ptp_data->lock);
+	return ret;
+}
+
+static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
+{
+	struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
+	struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
+	struct timespec64 delta64 = ns_to_timespec64(delta);
+	int ret;
+
+	mutex_lock(&ptp_data->lock);
+
+	ret = __ksz_ptp_adjtime(dev, delta);
 	if (ret)
 		goto unlock;
 
@@ -952,6 +1236,26 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 	return ret;
 }
 
+static int ksz8463_ptp_enable(struct ptp_clock_info *ptp,
+			      struct ptp_clock_request *req, int on)
+{
+	struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
+	struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
+	int ret;
+
+	switch (req->type) {
+	case PTP_CLK_REQ_PEROUT:
+		mutex_lock(&ptp_data->lock);
+		ret = ksz8463_ptp_enable_perout(dev, &req->perout, on);
+		mutex_unlock(&ptp_data->lock);
+		break;
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	return ret;
+}
+
 static int ksz_ptp_enable(struct ptp_clock_info *ptp,
 			  struct ptp_clock_request *req, int on)
 {
@@ -1028,17 +1332,33 @@ static int ksz_ptp_start_clock(struct ksz_device *dev)
 	return 0;
 }
 
-int ksz_ptp_clock_register(struct dsa_switch *ds)
+void ksz8463_ptp_set_caps(struct dsa_switch *ds)
+{
+	struct ksz_device *dev = ds->priv;
+	struct ksz_ptp_data *ptp_data;
+
+	ptp_data = &dev->ptp_data;
+
+	ptp_data->caps.owner		= THIS_MODULE;
+	snprintf(ptp_data->caps.name, 16, "Microchip Clock");
+	ptp_data->caps.max_adj		= KSZ_MAX_DRIFT_CORR;
+	ptp_data->caps.gettime64	= ksz_ptp_gettime;
+	ptp_data->caps.settime64	= ksz8463_ptp_settime;
+	ptp_data->caps.adjfine		= ksz_ptp_adjfine;
+	ptp_data->caps.adjtime		= ksz8463_ptp_adjtime;
+	ptp_data->caps.do_aux_work	= ksz_ptp_do_aux_work;
+	ptp_data->caps.enable		= ksz8463_ptp_enable;
+	ptp_data->caps.verify		= ksz_ptp_verify_pin;
+	ptp_data->caps.n_pins		= dev->info->n_pins;
+	ptp_data->caps.n_per_out	= dev->info->n_per_out;
+}
+
+void ksz_ptp_set_caps(struct dsa_switch *ds)
 {
 	struct ksz_device *dev = ds->priv;
-	const u16 *regs = dev->info->regs;
 	struct ksz_ptp_data *ptp_data;
-	int ret;
-	u8 i;
 
 	ptp_data = &dev->ptp_data;
-	mutex_init(&ptp_data->lock);
-	spin_lock_init(&ptp_data->clock_lock);
 
 	ptp_data->caps.owner		= THIS_MODULE;
 	snprintf(ptp_data->caps.name, 16, "Microchip Clock");
@@ -1050,14 +1370,27 @@ int ksz_ptp_clock_register(struct dsa_switch *ds)
 	ptp_data->caps.do_aux_work	= ksz_ptp_do_aux_work;
 	ptp_data->caps.enable		= ksz_ptp_enable;
 	ptp_data->caps.verify		= ksz_ptp_verify_pin;
-	ptp_data->caps.n_pins		= KSZ_PTP_N_GPIO;
-	ptp_data->caps.n_per_out	= 3;
+	ptp_data->caps.n_pins		= dev->info->n_pins;
+	ptp_data->caps.n_per_out	= dev->info->n_per_out;
+}
+
+int ksz_ptp_clock_register(struct dsa_switch *ds)
+{
+	struct ksz_device *dev = ds->priv;
+	const u16 *regs = dev->info->regs;
+	struct ksz_ptp_data *ptp_data;
+	int ret;
+	u8 i;
+
+	ptp_data = &dev->ptp_data;
+	mutex_init(&ptp_data->lock);
+	spin_lock_init(&ptp_data->clock_lock);
 
 	ret = ksz_ptp_start_clock(dev);
 	if (ret)
 		return ret;
 
-	for (i = 0; i < KSZ_PTP_N_GPIO; i++) {
+	for (i = 0; i < dev->info->n_pins; i++) {
 		struct ptp_pin_desc *ptp_pin = &ptp_data->pin_config[i];
 
 		snprintf(ptp_pin->name,
diff --git a/drivers/net/dsa/microchip/ksz_ptp.h b/drivers/net/dsa/microchip/ksz_ptp.h
index 7067ec9bd1e6f..92589cf373ac2 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.h
+++ b/drivers/net/dsa/microchip/ksz_ptp.h
@@ -12,7 +12,7 @@
 
 #include <linux/ptp_clock_kernel.h>
 
-#define KSZ_PTP_N_GPIO		2
+#define KSZ_PTP_N_GPIO		12
 
 enum ksz_ptp_tou_mode {
 	KSZ_PTP_TOU_IDLE,
@@ -33,6 +33,8 @@ struct ksz_ptp_data {
 	struct timespec64 perout_period;
 };
 
+void ksz_ptp_set_caps(struct dsa_switch *ds);
+void ksz8463_ptp_set_caps(struct dsa_switch *ds);
 int ksz_ptp_clock_register(struct dsa_switch *ds);
 
 void ksz_ptp_clock_unregister(struct dsa_switch *ds);
@@ -65,6 +67,7 @@ struct ksz_ptp_data {
 	struct mutex lock;
 };
 
+static inline void ksz_ptp_set_caps(struct dsa_switch *ds) { }
 static inline int ksz_ptp_clock_register(struct dsa_switch *ds)
 {
 	return 0;
diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/microchip/ksz_ptp_reg.h
index 65ea8577af755..16f117fa5d49b 100644
--- a/drivers/net/dsa/microchip/ksz_ptp_reg.h
+++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h
@@ -51,6 +51,22 @@
 
 #define REG_PTP_UNIT_INDEX__4		0x0520
 
+#define KSZ8463_TOU_ACTIVE		0x202
+#define KSZ8463_TOU_EN			0x206
+#define KSZ8463_TOU_SW_RST		0x208
+
+#define KSZ8463_TRIGN_CFG_SIZE		0x20
+#define KSZ8463_TRIG1_CFG		0x220
+#define KSZ8463_TARGET_NSEC		0x000
+#define KSZ8463_TARGET_SEC		0x004
+#define KSZ8463_PATTERN_OFF		0x008
+#define KSZ8463_NOTIFY_BIT		BIT(8)
+#define KSZ8463_PATTERN_M		GENMASK(6, 4)
+#define KSZ8463_PULSE_WIDTH_OFF		0x00A
+#define KSZ8463_TRIG_PULSE_WIDTH_M	GENMASK(15, 0)
+#define KSZ8463_CYCLE_WIDTH_OFF		0x00C
+#define KSZ8463_CYCLE_CNT_OFF		0x010
+
 #define PTP_GPIO_INDEX			GENMASK(19, 16)
 #define PTP_TSI_INDEX			BIT(8)
 #define PTP_TOU_INDEX			GENMASK(1, 0)
diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
index 86ce3a86705f9..3a209122fc7dc 100644
--- a/drivers/net/dsa/microchip/lan937x_main.c
+++ b/drivers/net/dsa/microchip/lan937x_main.c
@@ -867,6 +867,7 @@ static int lan937x_setup(struct dsa_switch *ds)
 		}
 	}
 
+	ksz_ptp_set_caps(ds);
 	ret = ksz_ptp_clock_register(ds);
 	if (ret) {
 		dev_err(dev->dev, "Failed to register PTP clock: %d\n",

3/2 2026/09/03 04:40 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 13434
							output: 35
							thoughts: 179
						

Thoughts:
**Fuzzing Feasibility Assessment**

Okay, let's take a look at this patch and decide if we're going to put it through the fuzzing mill. My initial thought is to figure out the scope. I see that it touches `drivers/net/dsa/microchip/`, which means we're dealing with Microchip KSZ/LAN DSA Ethernet switch drivers. Specifically, things like the KSZ8463, KSZ8563, KSZ9477, KSZ9567, and LAN937x.

Now, the real question is, how does the kernel interface with these switches? SPI, I2C, memory-mapped, MDIO? Knowing that will be crucial. And more importantly, can we even reach these drivers in a virtualized environment like QEMU? Can we emulate a DSA switch or a basic SPI/I2C Microchip switch, or are we stuck with physical hardware? If it's the latter, that's going to be a significant hurdle.

Time to fire up the grepper or read-file to do a little digging and get some answers.



4/2 2026/09/03 04:40 tool grepper
0m Args:
{
  "Expression": "MICROCHIP_KSZ",
  "PathPrefix": "drivers/net/dsa/microchip"
}

Results:
{
  "Output": "drivers/net/dsa/microchip/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/net/dsa/microchip/Kconfig:2:menuconfig NET_DSA_MICROCHIP_KSZ_COMMON\ndrivers/net/dsa/microchip/Kconfig-3-\ttristate \"Microchip KSZ8XXX/KSZ9XXX/LAN937X series switch support\"\n--\ndrivers/net/dsa/microchip/Kconfig-16-\ndrivers/net/dsa/microchip/Kconfig:17:config NET_DSA_MICROCHIP_KSZ9477_I2C\ndrivers/net/dsa/microchip/Kconfig-18-\ttristate \"KSZ series I2C connected switch driver\"\ndrivers/net/dsa/microchip/Kconfig:19:\tdepends on NET_DSA_MICROCHIP_KSZ_COMMON \u0026\u0026 I2C\ndrivers/net/dsa/microchip/Kconfig-20-\tselect REGMAP_I2C\n--\ndrivers/net/dsa/microchip/Kconfig-23-\ndrivers/net/dsa/microchip/Kconfig:24:config NET_DSA_MICROCHIP_KSZ_SPI\ndrivers/net/dsa/microchip/Kconfig-25-\ttristate \"KSZ series SPI connected switch driver\"\ndrivers/net/dsa/microchip/Kconfig:26:\tdepends on NET_DSA_MICROCHIP_KSZ_COMMON \u0026\u0026 SPI\ndrivers/net/dsa/microchip/Kconfig-27-\tselect REGMAP_SPI\n--\ndrivers/net/dsa/microchip/Kconfig-30-\ndrivers/net/dsa/microchip/Kconfig:31:config NET_DSA_MICROCHIP_KSZ_PTP\ndrivers/net/dsa/microchip/Kconfig-32-\tbool \"Support for the PTP clock on the KSZ9563/LAN937x Ethernet Switch\"\ndrivers/net/dsa/microchip/Kconfig:33:\tdepends on NET_DSA_MICROCHIP_KSZ_COMMON \u0026\u0026 PTP_1588_CLOCK\ndrivers/net/dsa/microchip/Kconfig:34:\tdepends on NET_DSA_MICROCHIP_KSZ_COMMON=m || PTP_1588_CLOCK=y\ndrivers/net/dsa/microchip/Kconfig-35-\thelp\n--\ndrivers/net/dsa/microchip/Kconfig-40-\ndrivers/net/dsa/microchip/Kconfig:41:config NET_DSA_MICROCHIP_KSZ8863_SMI\ndrivers/net/dsa/microchip/Kconfig-42-\ttristate \"KSZ series SMI connected switch driver\"\ndrivers/net/dsa/microchip/Kconfig:43:\tdepends on NET_DSA_MICROCHIP_KSZ_COMMON\ndrivers/net/dsa/microchip/Kconfig-44-\tselect MDIO_BITBANG\n--\ndrivers/net/dsa/microchip/Makefile-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/net/dsa/microchip/Makefile:2:obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON)\t+= ksz_switch.o\ndrivers/net/dsa/microchip/Makefile-3-ksz_switch-objs := ksz_common.o ksz_dcb.o\n--\ndrivers/net/dsa/microchip/Makefile=6=ksz_switch-objs += lan937x_main.o\ndrivers/net/dsa/microchip/Makefile-7-\ndrivers/net/dsa/microchip/Makefile:8:ifdef CONFIG_NET_DSA_MICROCHIP_KSZ_PTP\ndrivers/net/dsa/microchip/Makefile-9-ksz_switch-objs += ksz_ptp.o\ndrivers/net/dsa/microchip/Makefile=10=endif\ndrivers/net/dsa/microchip/Makefile-11-\ndrivers/net/dsa/microchip/Makefile:12:obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477_I2C)\t+= ksz9477_i2c.o\ndrivers/net/dsa/microchip/Makefile:13:obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_SPI)\t\t+= ksz_spi.o\ndrivers/net/dsa/microchip/Makefile:14:obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ8863_SMI)\t+= ksz8863_smi.o\n--\ndrivers/net/dsa/microchip/ksz_common.h=171=struct ksz_port {\n--\ndrivers/net/dsa/microchip/ksz_common.h-194-\tstruct phylink_pcs *pcs;\ndrivers/net/dsa/microchip/ksz_common.h:195:#if IS_ENABLED(CONFIG_NET_DSA_MICROCHIP_KSZ_PTP)\ndrivers/net/dsa/microchip/ksz_common.h-196-\tstruct kernel_hwtstamp_config tstamp_config;\n--\ndrivers/net/dsa/microchip/ksz_ptp.h-10-\ndrivers/net/dsa/microchip/ksz_ptp.h:11:#if IS_ENABLED(CONFIG_NET_DSA_MICROCHIP_KSZ_PTP)\ndrivers/net/dsa/microchip/ksz_ptp.h-12-\n--\ndrivers/net/dsa/microchip/ksz_ptp.h=90=static inline void ksz8463_ptp_irq_free(struct dsa_switch *ds) {}\n--\ndrivers/net/dsa/microchip/ksz_ptp.h-105-\ndrivers/net/dsa/microchip/ksz_ptp.h:106:#endif\t/* End of CONFIG_NET_DSA_MICROCHIP_KSZ_PTP */\ndrivers/net/dsa/microchip/ksz_ptp.h-107-\n"
}

5/2 2026/09/03 04:40 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 15385
							output: 49
							thoughts: 66
						

Thoughts:
Okay, let's dive into this driver situation. First things first, I need to understand the fundamental architecture: are these drivers strictly tied to specific physical hardware components? I need to get a clear picture of how they're probed and bound.

My instinct is to start digging into the code itself. I'll need to examine the implementation of these `ksz` drivers directly to see the binding mechanism in detail. I'll target the `ksz_spi.c`, `ksz9477_i2c.c`, and `ksz8863_smi.c` files as a starting point. Those seem like they'll cover a range of interface methodologies that should give me a good handle on things. This will allow me to see the interactions firsthand.



6/2 2026/09/03 04:40 tool grepper
0m Args:
{
  "Expression": "module_spi_driver|module_i2c_driver|module_mdio_driver",
  "PathPrefix": "drivers/net/dsa/microchip"
}

Results:
{
  "Output": "drivers/net/dsa/microchip/ksz9477_i2c.c=133=static struct i2c_driver ksz9477_i2c_driver = {\n--\ndrivers/net/dsa/microchip/ksz9477_i2c.c-144-\ndrivers/net/dsa/microchip/ksz9477_i2c.c:145:module_i2c_driver(ksz9477_i2c_driver);\ndrivers/net/dsa/microchip/ksz9477_i2c.c-146-\n--\ndrivers/net/dsa/microchip/ksz_spi.c=349=static struct spi_driver ksz_spi_driver = {\n--\ndrivers/net/dsa/microchip/ksz_spi.c-360-\ndrivers/net/dsa/microchip/ksz_spi.c:361:module_spi_driver(ksz_spi_driver);\ndrivers/net/dsa/microchip/ksz_spi.c-362-\n"
}

7/2 2026/09/03 04:40 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 15938
							output: 40
							thoughts: 545
						

Thoughts:
**My Thought Process on DSA Switches and Fuzzing Worthiness**

Okay, first things first, DSA switches. The prompt says "WorthFuzzing=false" if it falls under specific criteria, so let's break it down: Are DSA switches always physical hardware-dependent, or can we get at them somehow in syzkaller or a virtualized QEMU environment? I need to figure out if we can even *reach* this code.

Alright, let's step back and look at the "not WorthFuzzing" conditions. It's a lot of things, like documentation, logging, constants that don't change flow, unreachable code in virtualized environments, vendor-specific stuff tied to actual hardware (like PCIe cards not emulated), and teardown callbacks that only run during hot-unplug.

The real question is, can these DSA switches on SPI or I2C (specifically, thinking about something like a Microchip KSZ) even be *probed* or instantiated in QEMU/syzkaller without a physical setup? Now I'm remembering that SPI and I2C drivers can sometimes be interacted with from userspace, right? Like, can I create an I2C device via sysfs with `/sys/bus/i2c/devices/i2c-X/new_device`? Or via SPI/OF, or even with a dummy device?

Aha, that's it! In Linux, you *can* instantiate I2C devices with that `/sys/bus/i2c/devices/i2c-X/new_device` path. But, the question becomes, can syzkaller *use* this? Does QEMU even have an I2C bus implemented? I need to check if syzkaller has "i2c new_device" functionality, and if DSA switches can be controlled via this.

Okay, let's dig into the details. DSA switch driver probing requires a DSA tree and platform/device tree data. So now I need to check the code: Specifically, let's look at `ksz9477_i2c_probe` and `ksz_switch_register` in `drivers/net/dsa/microchip/` to see if they can somehow be accessed virtually.



8/2 2026/09/03 04:40 tool grepper
0m Args:
{
  "Expression": "ksz9477_i2c_probe",
  "PathPrefix": "drivers/net/dsa/microchip"
}

Results:
{
  "Output": "drivers/net/dsa/microchip/ksz9477_i2c.c=15=KSZ_REGMAP_TABLE(ksz9477, not_used, 16, 0, 0);\ndrivers/net/dsa/microchip/ksz9477_i2c.c-16-\ndrivers/net/dsa/microchip/ksz9477_i2c.c:17:static int ksz9477_i2c_probe(struct i2c_client *i2c)\ndrivers/net/dsa/microchip/ksz9477_i2c.c-18-{\n--\ndrivers/net/dsa/microchip/ksz9477_i2c.c=133=static struct i2c_driver ksz9477_i2c_driver = {\n--\ndrivers/net/dsa/microchip/ksz9477_i2c.c-138-\t},\ndrivers/net/dsa/microchip/ksz9477_i2c.c:139:\t.probe = ksz9477_i2c_probe,\ndrivers/net/dsa/microchip/ksz9477_i2c.c-140-\t.remove\t= ksz9477_i2c_remove,\n"
}

9/2 2026/09/03 04:40 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 17348
							output: 48
							thoughts: 57
						

Thoughts:
Here's my thinking process:

**Diving into the KSZ9477 Driver**

Okay, so I need to get a handle on how this KSZ9477 switch is being handled in the Linux kernel. Time to dig into the source code. I'm going to start by looking at `ksz9477_i2c_probe` and `ksz_switch_register` functions. These are likely the core entry points for initializing and registering the device, I'd expect. The file paths are straightforward enough: `drivers/net/dsa/microchip/ksz9477_i2c.c` and `ksz_common.c`. I'm hoping to understand how the I2C communication is set up, what data structures are being used, and how the switch is integrated within the DSA (Distributed Switch Architecture) framework. I'll need to pay close attention to the error handling and resource allocation too, as that's always a critical aspect in driver development. Let's see what gems are hidden in there.



10/2 2026/09/03 04:40 tool read-file
0m Args:
{
  "File": "drivers/net/dsa/microchip/ksz9477_i2c.c",
  "FirstLine": 17,
  "LineCount": 80
}

Results:
{
  "Contents": "  17:\tstatic int ksz9477_i2c_probe(struct i2c_client *i2c)\n  18:\t{\n  19:\t\tconst struct ksz_chip_data *chip;\n  20:\t\tstruct device *ddev = \u0026i2c-\u003edev;\n  21:\t\tstruct regmap_config rc;\n  22:\t\tstruct ksz_device *dev;\n  23:\t\tint i, ret;\n  24:\t\n  25:\t\tchip = device_get_match_data(ddev);\n  26:\t\tif (!chip)\n  27:\t\t\treturn -EINVAL;\n  28:\t\n  29:\t\tdev = ksz_switch_alloc(\u0026i2c-\u003edev, chip, i2c);\n  30:\t\tif (!dev)\n  31:\t\t\treturn -ENOMEM;\n  32:\t\n  33:\t\t/* Save chip id to do special initialization when probing. */\n  34:\t\tdev-\u003echip_id = chip-\u003echip_id;\n  35:\t\tfor (i = 0; i \u003c __KSZ_NUM_REGMAPS; i++) {\n  36:\t\t\trc = ksz9477_regmap_config[i];\n  37:\t\t\trc.lock_arg = \u0026dev-\u003eregmap_mutex;\n  38:\t\t\tdev-\u003eregmap[i] = devm_regmap_init_i2c(i2c, \u0026rc);\n  39:\t\t\tif (IS_ERR(dev-\u003eregmap[i])) {\n  40:\t\t\t\treturn dev_err_probe(\u0026i2c-\u003edev, PTR_ERR(dev-\u003eregmap[i]),\n  41:\t\t\t\t\t\t     \"Failed to initialize regmap%i\\n\",\n  42:\t\t\t\t\t\t     ksz9477_regmap_config[i].val_bits);\n  43:\t\t\t}\n  44:\t\t}\n  45:\t\n  46:\t\tif (i2c-\u003edev.platform_data)\n  47:\t\t\tdev-\u003epdata = i2c-\u003edev.platform_data;\n  48:\t\n  49:\t\tdev-\u003eirq = i2c-\u003eirq;\n  50:\t\n  51:\t\tret = ksz_switch_register(dev);\n  52:\t\n  53:\t\t/* Main DSA driver may not be started yet. */\n  54:\t\tif (ret)\n  55:\t\t\treturn ret;\n  56:\t\n  57:\t\ti2c_set_clientdata(i2c, dev);\n  58:\t\n  59:\t\treturn 0;\n  60:\t}\n  61:\t\n  62:\tstatic void ksz9477_i2c_remove(struct i2c_client *i2c)\n  63:\t{\n  64:\t\tstruct ksz_device *dev = i2c_get_clientdata(i2c);\n  65:\t\n  66:\t\tif (dev)\n  67:\t\t\tksz_switch_remove(dev);\n  68:\t}\n  69:\t\n  70:\tstatic void ksz9477_i2c_shutdown(struct i2c_client *i2c)\n  71:\t{\n  72:\t\tstruct ksz_device *dev = i2c_get_clientdata(i2c);\n  73:\t\n  74:\t\tif (!dev)\n  75:\t\t\treturn;\n  76:\t\n  77:\t\tksz_switch_shutdown(dev);\n  78:\t\n  79:\t\ti2c_set_clientdata(i2c, NULL);\n  80:\t}\n  81:\t\n  82:\tstatic const struct i2c_device_id ksz9477_i2c_id[] = {\n  83:\t\t{ .name = \"ksz9477-switch\" },\n  84:\t\t{ }\n  85:\t};\n  86:\t\n  87:\tMODULE_DEVICE_TABLE(i2c, ksz9477_i2c_id);\n  88:\t\n  89:\tstatic const struct of_device_id ksz9477_dt_ids[] = {\n  90:\t\t{\n  91:\t\t\t.compatible = \"microchip,ksz9477\",\n  92:\t\t\t.data = \u0026ksz_switch_chips[KSZ9477]\n  93:\t\t},\n  94:\t\t{\n  95:\t\t\t.compatible = \"microchip,ksz9896\",\n  96:\t\t\t.data = \u0026ksz_switch_chips[KSZ9896]\n"
}

11/2 2026/09/03 04:40 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 18845
							output: 36
							thoughts: 148
						

Thoughts:
**My Initial Thoughts on the ksz9477 Driver Probe**

Okay, so I'm looking at the `ksz9477_i2c_probe` function. Lines 25-27 jump out at me immediately: they try to retrieve match data from the device using `device_get_match_data(ddev)`, and then bail if it's NULL. This makes sense in most contexts, but hold on a second... if the device is initialized through the I2C ID, specifically `"ksz9477-switch"` as defined in `ksz9477_i2c_id`, wouldn't that mean `driver_data` is `0` or NULL? In that scenario, `device_get_match_data` would *always* return NULL, right? That looks like a bug. Before I dig deeper, let me check the `ksz_switch_register` function in `ksz_common.c`. I need to understand how the chip is meant to be registered and if there's any implicit data setup that might be missed.



12/2 2026/09/03 04:40 tool grepper
0m Args:
{
  "Expression": "int ksz_switch_register",
  "PathPrefix": "drivers/net/dsa/microchip"
}

Results:
{
  "Output": "drivers/net/dsa/microchip/ksz_common.c=3911=static int ksz8463_release_straps_spi(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz_common.c-3915-\ndrivers/net/dsa/microchip/ksz_common.c:3916:int ksz_switch_register(struct ksz_device *dev)\ndrivers/net/dsa/microchip/ksz_common.c-3917-{\n--\ndrivers/net/dsa/microchip/ksz_common.h=429=struct ksz_device *ksz_switch_alloc(struct device *base,\n--\ndrivers/net/dsa/microchip/ksz_common.h-431-\t\t\t\t    void *priv);\ndrivers/net/dsa/microchip/ksz_common.h:432:int ksz_switch_register(struct ksz_device *dev);\ndrivers/net/dsa/microchip/ksz_common.h-433-void ksz_switch_remove(struct ksz_device *dev);\n"
}

13/2 2026/09/03 04:40 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 19546
							output: 44
							thoughts: 29
						

Thoughts:
Okay, let's dive into this. I'm going to pull up `ksz_switch_register` function, specifically within the `drivers/net/dsa/microchip/ksz_common.c` file. I'm assuming, given the naming convention and location, this function is responsible for registering a Microchip KSZ series switch within the DSA (Distributed Switch Architecture) framework. Knowing KSZ switches, it likely handles the basic hardware initialization, setting up communication with the switch (likely through MDIO), and then integrating the switch's functionality within the Linux networking stack. It will probably involve some device tree parsing to configure its hardware, possibly including things like the MDIO bus address, the PHY addresses, and any specific clock configurations needed for proper operation. I expect to see the standard device registration calls for DSA, along with the definition of the switch's various ports and their characteristics. Hopefully it contains a clean error handling path - that's always good practice, especially in a driver. I'll be looking to see how well it's written and if it provides robust enough support for all of the features that KSZ switches provide. I'm also hoping for clear documentation.



14/2 2026/09/03 04:40 tool read-file
0m Args:
{
  "File": "drivers/net/dsa/microchip/ksz_common.c",
  "FirstLine": 3916,
  "LineCount": 80
}

Results:
{
  "Contents": "3916:\tint ksz_switch_register(struct ksz_device *dev)\n3917:\t{\n3918:\t\tconst struct ksz_chip_data *info;\n3919:\t\tstruct device_node *ports;\n3920:\t\tphy_interface_t interface;\n3921:\t\tunsigned int port_num;\n3922:\t\tint ret;\n3923:\t\tint i;\n3924:\t\n3925:\t\tdev-\u003ereset_gpio = devm_gpiod_get_optional(dev-\u003edev, \"reset\",\n3926:\t\t\t\t\t\t\t  GPIOD_OUT_LOW);\n3927:\t\tif (IS_ERR(dev-\u003ereset_gpio))\n3928:\t\t\treturn PTR_ERR(dev-\u003ereset_gpio);\n3929:\t\n3930:\t\tif (dev-\u003ereset_gpio) {\n3931:\t\t\tif (of_device_is_compatible(dev-\u003edev-\u003eof_node, \"microchip,ksz8463\")) {\n3932:\t\t\t\tret = ksz8463_configure_straps_spi(dev);\n3933:\t\t\t\tif (ret)\n3934:\t\t\t\t\treturn ret;\n3935:\t\t\t}\n3936:\t\n3937:\t\t\tgpiod_set_value_cansleep(dev-\u003ereset_gpio, 1);\n3938:\t\t\tusleep_range(10000, 12000);\n3939:\t\t\tgpiod_set_value_cansleep(dev-\u003ereset_gpio, 0);\n3940:\t\t\tmsleep(100);\n3941:\t\n3942:\t\t\tif (of_device_is_compatible(dev-\u003edev-\u003eof_node, \"microchip,ksz8463\")) {\n3943:\t\t\t\tret = ksz8463_release_straps_spi(dev);\n3944:\t\t\t\tif (ret)\n3945:\t\t\t\t\treturn ret;\n3946:\t\t\t}\n3947:\t\t}\n3948:\t\n3949:\t\tmutex_init(\u0026dev-\u003edev_mutex);\n3950:\t\tmutex_init(\u0026dev-\u003eregmap_mutex);\n3951:\t\tmutex_init(\u0026dev-\u003ealu_mutex);\n3952:\t\tmutex_init(\u0026dev-\u003evlan_mutex);\n3953:\t\n3954:\t\tret = ksz_switch_detect(dev);\n3955:\t\tif (ret)\n3956:\t\t\treturn ret;\n3957:\t\n3958:\t\tinfo = ksz_lookup_info(dev-\u003echip_id);\n3959:\t\tif (!info)\n3960:\t\t\treturn -ENODEV;\n3961:\t\n3962:\t\t/* Update the compatible info with the probed one */\n3963:\t\tdev-\u003einfo = info;\n3964:\t\n3965:\t\tdev_info(dev-\u003edev, \"found switch: %s, rev %i\\n\",\n3966:\t\t\t dev-\u003einfo-\u003edev_name, dev-\u003echip_rev);\n3967:\t\n3968:\t\tret = ksz_check_device_id(dev);\n3969:\t\tif (ret)\n3970:\t\t\treturn ret;\n3971:\t\n3972:\t\tdev-\u003edev_ops = dev-\u003einfo-\u003eops;\n3973:\t\n3974:\t\tret = dev-\u003edev_ops-\u003einit(dev);\n3975:\t\tif (ret)\n3976:\t\t\treturn ret;\n3977:\t\n3978:\t\tdev-\u003eports = devm_kzalloc(dev-\u003edev,\n3979:\t\t\t\t\t  dev-\u003einfo-\u003eport_cnt * sizeof(struct ksz_port),\n3980:\t\t\t\t\t  GFP_KERNEL);\n3981:\t\tif (!dev-\u003eports)\n3982:\t\t\treturn -ENOMEM;\n3983:\t\n3984:\t\tfor (i = 0; i \u003c dev-\u003einfo-\u003eport_cnt; i++) {\n3985:\t\t\tspin_lock_init(\u0026dev-\u003eports[i].mib.stats64_lock);\n3986:\t\t\tmutex_init(\u0026dev-\u003eports[i].mib.cnt_mutex);\n3987:\t\t\tdev-\u003eports[i].mib.counters =\n3988:\t\t\t\tdevm_kzalloc(dev-\u003edev,\n3989:\t\t\t\t\t     sizeof(u64) * (dev-\u003einfo-\u003emib_cnt + 1),\n3990:\t\t\t\t\t     GFP_KERNEL);\n3991:\t\t\tif (!dev-\u003eports[i].mib.counters)\n3992:\t\t\t\treturn -ENOMEM;\n3993:\t\n3994:\t\t\tdev-\u003eports[i].ksz_dev = dev;\n3995:\t\t\tdev-\u003eports[i].num = i;\n"
}

15/2 2026/09/03 04:40 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 21109
							output: 44
							thoughts: 15
						

Thoughts:
Okay, let's dive into this `ksz_switch_register` function and see what's happening.

**Analyzing the `ksz_switch_register` Function's Next Steps**

Alright, so I need to understand what's coming next in this `ksz_switch_register` function. I've got my debugging hat on, and I'm ready to follow the flow. I know the general purpose, of course, but it's time to drill down into the specifics. What are the key operations being performed? Is it handling hardware initialization, device configuration, or interrupt setup? I'm going to pay close attention to the data structures involved; those usually hold the secrets to the logic. Any interaction with the kernel's resource management system needs careful scrutiny, particularly with these sorts of device drivers. I'll be looking for potential race conditions or memory management issues. The error handling is critical as well: are the error codes meaningful? Are there sufficient retries in case of transient failures? I'll probably start by looking for any calls to other functions and tracing them out. I'm especially interested in looking at any hardware access, or calls to resource allocation routines, which could be the source of issues. I also want to make sure the data structures are properly initialized. In short, let's get down to the low level and see what's being done and whether it's done correctly.



16/2 2026/09/03 04:40 tool read-file
0m Args:
{
  "File": "drivers/net/dsa/microchip/ksz_common.c",
  "FirstLine": 3996,
  "LineCount": 80
}

Results:
{
  "Contents": "3996:\t\t}\n3997:\t\n3998:\t\t/* set the real number of ports */\n3999:\t\tdev-\u003eds-\u003enum_ports = dev-\u003einfo-\u003eport_cnt;\n4000:\t\n4001:\t\t/* set the phylink ops */\n4002:\t\tdev-\u003eds-\u003ephylink_mac_ops = dev-\u003einfo-\u003ephylink_mac_ops;\n4003:\t\n4004:\t\t/* Host port interface will be self detected, or specifically set in\n4005:\t\t * device tree.\n4006:\t\t */\n4007:\t\tfor (port_num = 0; port_num \u003c dev-\u003einfo-\u003eport_cnt; ++port_num)\n4008:\t\t\tdev-\u003eports[port_num].interface = PHY_INTERFACE_MODE_NA;\n4009:\t\tif (dev-\u003edev-\u003eof_node) {\n4010:\t\t\tret = of_get_phy_mode(dev-\u003edev-\u003eof_node, \u0026interface);\n4011:\t\t\tif (ret == 0)\n4012:\t\t\t\tdev-\u003ecompat_interface = interface;\n4013:\t\t\tports = of_get_child_by_name(dev-\u003edev-\u003eof_node, \"ethernet-ports\");\n4014:\t\t\tif (!ports)\n4015:\t\t\t\tports = of_get_child_by_name(dev-\u003edev-\u003eof_node, \"ports\");\n4016:\t\t\tif (ports) {\n4017:\t\t\t\tfor_each_available_child_of_node_scoped(ports, port) {\n4018:\t\t\t\t\tif (of_property_read_u32(port, \"reg\",\n4019:\t\t\t\t\t\t\t\t \u0026port_num))\n4020:\t\t\t\t\t\tcontinue;\n4021:\t\t\t\t\tif (!(dev-\u003eport_mask \u0026 BIT(port_num))) {\n4022:\t\t\t\t\t\tof_node_put(ports);\n4023:\t\t\t\t\t\treturn -EINVAL;\n4024:\t\t\t\t\t}\n4025:\t\t\t\t\tof_get_phy_mode(port,\n4026:\t\t\t\t\t\t\t\u0026dev-\u003eports[port_num].interface);\n4027:\t\n4028:\t\t\t\t\tksz_parse_rgmii_delay(dev, port_num, port);\n4029:\t\t\t\t\tdev-\u003eports[port_num].fiber =\n4030:\t\t\t\t\t\tof_property_read_bool(port,\n4031:\t\t\t\t\t\t\t\t      \"micrel,fiber-mode\");\n4032:\t\t\t\t}\n4033:\t\t\t\tof_node_put(ports);\n4034:\t\t\t}\n4035:\t\t\tdev-\u003esynclko_125 = of_property_read_bool(dev-\u003edev-\u003eof_node,\n4036:\t\t\t\t\t\t\t\t \"microchip,synclko-125\");\n4037:\t\t\tdev-\u003esynclko_disable = of_property_read_bool(dev-\u003edev-\u003eof_node,\n4038:\t\t\t\t\t\t\t\t     \"microchip,synclko-disable\");\n4039:\t\t\tif (dev-\u003esynclko_125 \u0026\u0026 dev-\u003esynclko_disable) {\n4040:\t\t\t\tdev_err(dev-\u003edev, \"inconsistent synclko settings\\n\");\n4041:\t\t\t\treturn -EINVAL;\n4042:\t\t\t}\n4043:\t\n4044:\t\t\tdev-\u003ewakeup_source = of_property_read_bool(dev-\u003edev-\u003eof_node,\n4045:\t\t\t\t\t\t\t\t   \"wakeup-source\");\n4046:\t\t\tdev-\u003epme_active_high = of_property_read_bool(dev-\u003edev-\u003eof_node,\n4047:\t\t\t\t\t\t\t\t     \"microchip,pme-active-high\");\n4048:\t\t}\n4049:\t\n4050:\t\tret = dsa_register_switch(dev-\u003eds);\n4051:\t\tif (ret)\n4052:\t\t\treturn ret;\n4053:\t\n4054:\t\t/* Read MIB counters every 30 seconds to avoid overflow. */\n4055:\t\tdev-\u003emib_read_interval = msecs_to_jiffies(5000);\n4056:\t\n4057:\t\t/* Start the MIB timer. */\n4058:\t\tschedule_delayed_work(\u0026dev-\u003emib_read, 0);\n4059:\t\n4060:\t\treturn ret;\n4061:\t}\n4062:\tEXPORT_SYMBOL(ksz_switch_register);\n4063:\t\n4064:\tvoid ksz_switch_remove(struct ksz_device *dev)\n4065:\t{\n4066:\t\t/* timer started */\n4067:\t\tif (dev-\u003emib_read_interval) {\n4068:\t\t\tdev-\u003emib_read_interval = 0;\n4069:\t\t\tcancel_delayed_work_sync(\u0026dev-\u003emib_read);\n4070:\t\t}\n4071:\t\n4072:\t\tdsa_unregister_switch(dev-\u003eds);\n4073:\t}\n4074:\tEXPORT_SYMBOL(ksz_switch_remove);\n4075:\t\n"
}

17/2 2026/09/03 04:40 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 22764
							output: 34
							thoughts: 48
						

Thoughts:
Okay, let's dive into this code.

**Analyzing ksz\_switch\_detect(dev)**

Alright, so I'm tracing through this `ksz_switch` driver, and the first thing that jumps out is the call to `ksz_switch_detect(dev)` in `ksz_switch_register`. Now, *that* piques my interest! Clearly, this is where the system is trying to figure out if there's an actual switch present and, if so, what kind. Let's dig into the `ksz_switch_detect` function itself and see how it goes about doing that detection. This is the crux of the initialization, I bet. I'm expecting some kind of probe sequence, register reads... maybe even some vendor-specific magic to identify the hardware. Let's see what secrets it's hiding!



18/2 2026/09/03 04:40 tool grepper
0m Args:
{
  "Expression": "ksz_switch_detect",
  "PathPrefix": "drivers/net/dsa/microchip"
}

Results:
{
  "Output": "drivers/net/dsa/microchip/ksz_common.c=2916=void ksz_phylink_mac_config(struct phylink_config *config,\n--\ndrivers/net/dsa/microchip/ksz_common.c-2927-\ndrivers/net/dsa/microchip/ksz_common.c:2928:static int ksz_switch_detect(struct ksz_device *dev)\ndrivers/net/dsa/microchip/ksz_common.c-2929-{\n--\ndrivers/net/dsa/microchip/ksz_common.c=3916=int ksz_switch_register(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz_common.c-3953-\ndrivers/net/dsa/microchip/ksz_common.c:3954:\tret = ksz_switch_detect(dev);\ndrivers/net/dsa/microchip/ksz_common.c-3955-\tif (ret)\n"
}

19/2 2026/09/03 04:40 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 23287
							output: 44
							thoughts: 29
						

Thoughts:
Okay, let's dive into this. Here's my take on that function, `ksz_switch_detect`, nestled within `drivers/net/dsa/microchip/ksz_common.c`.

**Diving Deep into KSZ Switch Detection**

Alright, time to dissect `ksz_switch_detect` from `ksz_common.c`. I'm going to want to understand what triggers this routine, the key registers it's reading and writing, and the logic behind how it determines if a Microchip KSZ switch is present and functioning correctly. I'll be looking for any hardware-specific quirks or workarounds in this low-level driver. I'll need to remember that this function is part of a larger DSA (Distributed Switch Architecture) framework, so I should be keeping an eye out for how this function interacts with the higher-level DSA components. I'll be particularly interested in any error handling and retry mechanisms. I'm already anticipating some potential challenges – the need to handle different KSZ switch revisions, variations in PHY configurations, and maybe even some clever register probing techniques. This is where the magic happens, so let's see what they've come up with. Let's see if this code is well-written, efficient, and robust.



20/2 2026/09/03 04:41 tool read-file
0m Args:
{
  "File": "drivers/net/dsa/microchip/ksz_common.c",
  "FirstLine": 2928,
  "LineCount": 60
}

Results:
{
  "Contents": "2928:\tstatic int ksz_switch_detect(struct ksz_device *dev)\n2929:\t{\n2930:\t\tu8 id1, id2, id4;\n2931:\t\tu16 id16;\n2932:\t\tu32 id32;\n2933:\t\tint ret;\n2934:\t\n2935:\t\t/* read chip id */\n2936:\t\tret = ksz_read16(dev, REG_CHIP_ID0, \u0026id16);\n2937:\t\tif (ret)\n2938:\t\t\treturn ret;\n2939:\t\n2940:\t\tid1 = FIELD_GET(SW_FAMILY_ID_M, id16);\n2941:\t\tid2 = FIELD_GET(SW_CHIP_ID_M, id16);\n2942:\t\n2943:\t\tswitch (id1) {\n2944:\t\tcase KSZ84_FAMILY_ID:\n2945:\t\t\tdev-\u003echip_id = KSZ8463_CHIP_ID;\n2946:\t\t\tbreak;\n2947:\t\tcase KSZ87_FAMILY_ID:\n2948:\t\t\tif (id2 == KSZ87_CHIP_ID_95) {\n2949:\t\t\t\tu8 val;\n2950:\t\n2951:\t\t\t\tdev-\u003echip_id = KSZ8795_CHIP_ID;\n2952:\t\n2953:\t\t\t\tksz_read8(dev, KSZ8_PORT_STATUS_0, \u0026val);\n2954:\t\t\t\tif (val \u0026 KSZ8_PORT_FIBER_MODE)\n2955:\t\t\t\t\tdev-\u003echip_id = KSZ8765_CHIP_ID;\n2956:\t\t\t} else if (id2 == KSZ87_CHIP_ID_94) {\n2957:\t\t\t\tdev-\u003echip_id = KSZ8794_CHIP_ID;\n2958:\t\t\t} else {\n2959:\t\t\t\treturn -ENODEV;\n2960:\t\t\t}\n2961:\t\t\tbreak;\n2962:\t\tcase KSZ88_FAMILY_ID:\n2963:\t\t\tif (id2 == KSZ88_CHIP_ID_63)\n2964:\t\t\t\tdev-\u003echip_id = KSZ88X3_CHIP_ID;\n2965:\t\t\telse\n2966:\t\t\t\treturn -ENODEV;\n2967:\t\t\tbreak;\n2968:\t\tcase KSZ8895_FAMILY_ID:\n2969:\t\t\tif (id2 == KSZ8895_CHIP_ID_95 ||\n2970:\t\t\t    id2 == KSZ8895_CHIP_ID_95R)\n2971:\t\t\t\tdev-\u003echip_id = KSZ8895_CHIP_ID;\n2972:\t\t\telse\n2973:\t\t\t\treturn -ENODEV;\n2974:\t\t\tret = ksz_read8(dev, REG_KSZ8864_CHIP_ID, \u0026id4);\n2975:\t\t\tif (ret)\n2976:\t\t\t\treturn ret;\n2977:\t\t\tif (id4 \u0026 SW_KSZ8864)\n2978:\t\t\t\tdev-\u003echip_id = KSZ8864_CHIP_ID;\n2979:\t\t\tbreak;\n2980:\t\tdefault:\n2981:\t\t\tret = ksz_read32(dev, REG_CHIP_ID0, \u0026id32);\n2982:\t\t\tif (ret)\n2983:\t\t\t\treturn ret;\n2984:\t\n2985:\t\t\tdev-\u003echip_rev = FIELD_GET(SW_REV_ID_M, id32);\n2986:\t\t\tid32 \u0026= ~0xFF;\n2987:\t\n"
}

21/2 2026/09/03 04:41 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 24638
							output: 118
							thoughts: 1121
						

Thoughts:
**WorthFuzzing Assessment: Microchip KSZ/LAN DSA Switch Driver Patch**

Okay, let's break this down. First, I see `ksz_switch_detect` which uses `regmap` to read registers over I2C/SPI/SMI. This immediately tells me we're dealing with hardware interaction. If there's no actual KSZ hardware present, it'll either return a 0/0xFF or error out. This confirms it's a dedicated driver for Microchip KSZ/LAN ethernet switches – KSZ8463, KSZ8563, KSZ9477, KSZ9567, LAN937x.

Now, the question is, does QEMU emulate any of these? Nope, QEMU has plenty of network emulations, but it doesn't touch Microchip KSZ switches. So, we are not running this code on QEMU.

Alright, time to check the WorthFuzzing guidelines. I need to make sure this patch isn't falling into the "unfuzzable" category. I need to verify that the code isn't something that can only run in a virtualized fuzzing environment. The guidelines say it is `WorthFuzzing=false` if it modifies code paths that are impossible to reach in virtualized environments like GCE or QEMU, especially for hardware drivers that require physical hardware. This includes vendor-specific switch drivers.

Now, let's be absolutely sure. Are there any software mock or dummy DSA devices I can use? No, DSA (Distributed Switch Architecture) switches are hardware specific, and, specifically, the `drivers/net/dsa/microchip/` code is designed for embedded Ethernet switch chips, like the ones I mentioned before. No way to run it without the physical ASIC.

Okay, let's review the files that are being patched: `drivers/net/dsa/microchip/ksz8.c`, `drivers/net/dsa/microchip/ksz9477.c`, `ksz_common.c`, `ksz_common.h`, `ksz_ptp.c`, `ksz_ptp.h`, `ksz_ptp_reg.h`, and `lan937x_main.c`. The patch adds PTP per-out support and pin capabilities for KSZ8463 and other Microchip switches in the DSA driver.

All the modified code is within `drivers/net/dsa/microchip/`. This is undeniably hardware-specific driver code that requires physical Microchip switch hardware (KSZ/LAN series) connected via SPI/I2C/SMI. Standard QEMU/GCE does NOT emulate this. Because of this, the code paths are unreachable for fuzzing.

Therefore, my conclusion is that `WorthFuzzing` is `false`.

The arguments for `set-results` will be:
*   `WorthFuzzing: false`
*   `EnableConfigs: []`
*   `FocusSymbols: []`
*   `Reasoning: The patch modifies the Microchip KSZ/LAN series DSA switch driver (specifically PTP support for KSZ8463 and other Microchip switch chips). These drivers require physical Microchip hardware connected via SPI, I2C, or SMI, which is not emulated in virtualized environments like QEMU or GCE. Thus, the modified code is unreachable for fuzzing.`

Let's make that tool call.



22/2 2026/09/03 04:41 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the Microchip KSZ/LAN series DSA Ethernet switch drivers (specifically adding PTP periodic output and pin capabilities for KSZ8463 and related switches). These switch drivers operate over SPI, I2C, or SMI buses and require physical Microchip switch ASICs that are not emulated in standard virtualized environments (such as QEMU or GCE), making these code paths unreachable for fuzzing.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the Microchip KSZ/LAN series DSA Ethernet switch drivers (specifically adding PTP periodic output and pin capabilities for KSZ8463 and related switches). These switch drivers operate over SPI, I2C, or SMI buses and require physical Microchip switch ASICs that are not emulated in standard virtualized environments (such as QEMU or GCE), making these code paths unreachable for fuzzing.",
  "WorthFuzzing": false
}

23/1 2026/09/03 04:41 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)