Re: [PATCH net v5 2/8] net: dsa: sja1105: leave the pin function unchanged on EXTTS disable
From: netdev-bot+sashiko
Date: Tue Nov 24 2026 - 23:44:58 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] This patch fixes only one direction of the shared PTP_CLK pin
problem.
--
net: dsa: sja1105: leave the pin function unchanged on EXTTS disable
This patch makes sja1105_extts_enable() switch the shared PTP_CLK pin to
the EXTTS function only when timestamp capture is being enabled. Disabling
EXTTS previously turned an output pin back into an input and stopped the
periodic output.
Link: https://lore.kernel.org/r/179548551283.3135.17206659598806657887@xxxxxxxxxx
> diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja1105/sja1105_ptp.c
> index 350f958dcb2af..da35805152e05 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;
> + }
[Severity: High]
Should sja1105_per_out_enable() in the same file get the same guard? It
still switches the pin before it looks at on:
drivers/net/dsa/sja1105/sja1105_ptp.c:sja1105_per_out_enable() {
...
mutex_lock(&ptp_data->lock);
rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_PEROUT);
if (rc)
goto out;
if (on) {
...
}
On SJA1105P/Q/R/S and SJA1110, avb->cas_master is 0 when PTP_CLK is an
input. This is the boot default, and it is also the state after an EXTTS
enable:
drivers/net/dsa/sja1105/sja1105_main.c:sja1105_init_avb_params() {
...
/* On P/Q/R/S, configure the direction of the PTP_CLK pin as input by
* default. This is because there might be boards with a hardware
* layout where enabling the pin as output might cause an electrical
* clash. ...
*/
avb->cas_master = false;
...
}
In that state, sja1105_change_ptp_clk_pin_func() computes
old_func = PTP_PF_EXTTS. It then sets avb->cas_master = 1 and writes
BLK_IDX_AVB_PARAMS. As a result, a PEROUT disable turns the pin into an
output, and the disable branch only issues stopptpcp after that.
Userspace can trigger this through two paths:
ptp_ioctl(PTP_PEROUT_REQUEST) with a zero period
-> ptp_perout_request()
-> ops->enable(ops, &req, 0)
-> sja1105_per_out_enable(on = false)
-> sja1105_change_ptp_clk_pin_func(priv, PTP_PF_PEROUT)
ptp_ioctl(PTP_PIN_SETFUNC) moving pin 0 away from PTP_PF_PEROUT
-> ptp_set_pinfunc()
-> ptp_disable_pinfunc(info, PTP_PF_PEROUT, chan)
-> enable(PEROUT, 0)
Neither path checks whether PEROUT was ever started. That means this can
happen even on a freshly booted switch.
Could the switch then drive a line that an external source, such as a PPS
input, is also driving? Avoiding that is the reason for the boot default
above.
If EXTTS was active, capture also stops in hardware. However,
priv->ptp_data.extts_enabled stays true and extts_timer keeps polling. A
retained PTP_PF_EXTTS pin assignment would no longer match the hardware.
The commit message says "EXTTS and PEROUT share PTP_CLK". The same
mechanism is still reachable through this mirror call site. No later patch
in the series changes sja1105_per_out_enable().
Would it make sense to call
sja1105_change_ptp_clk_pin_func(priv, PTP_PF_PEROUT) there only when on is
true, as part of this patch?
>
> priv->ptp_data.extts_enabled = on;
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123-timecard-common-v5-d669cfa034-0-ahmadexp%40gmail.com