sja1105_extts_enable() selects the EXTTS pin function even when disabling timestamp capture. EXTTS and PEROUT share PTP_CLK, so disabling EXTTS while the pin is an output changes it to an input and stops the periodic output. This also makes the hardware function disagree with a retained PTP_PF_PEROUT pin assignment. Only select the EXTTS function when enabling timestamp capture. On disable, clear extts_enabled and synchronously delete the polling timer without reprogramming the pin. This also avoids attempting the unsupported AVB_PARAMS dynamic configuration on SJA1105E/T when disabling an already inactive EXTTS channel. The Sashiko review found this side effect when reviewing a PTP core change to disable every advertised timestamp channel during teardown. Codex assisted with the correction, tests and changelog. Tests executing the actual functions with stubbed configuration writes reproduce the output-to-input change and pass with this fix, including repeated disable, enable and error paths. No physical switch was tested. Fixes: 747e5eb31d59 ("net: dsa: sja1105: configure the PTP_CLK pin as EXT_TS or PER_OUT") Link: https://lore.kernel.org/r/179548551283.3135.17206659598806657887@kernel.org Signed-off-by: Ahmad Byagowi --- Changes in v5: - New prerequisite from the SJA1105 side-effect review of v4 patch 1. Testing: 100 actual-function suites with 14 chip/direction cases each, repeated disable, enable and error paths; four x86_64/i386 PTP/SJA1105 build configurations with W=1 KCFLAGS=-Werror. Configuration writes are stubbed. Restoring unconditional pin selection fails at runtime. drivers/net/dsa/sja1105/sja1105_ptp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja1105/sja1105_ptp.c index 350f958dcb2a..da35805152e0 100644 --- a/drivers/net/dsa/sja1105/sja1105_ptp.c +++ b/drivers/net/dsa/sja1105/sja1105_ptp.c @@ -816,9 +816,11 @@ static int sja1105_extts_enable(struct sja1105_private *priv, (extts->flags & PTP_EXTTS_EDGES) != PTP_EXTTS_EDGES) return -EOPNOTSUPP; - rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_EXTTS); - if (rc) - return rc; + if (on) { + rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_EXTTS); + if (rc) + return rc; + } priv->ptp_data.extts_enabled = on;