From: netdev-bot+sashiko@kernel.org
To: ahmadexp@gmail.com
Cc: netdev@vger.kernel.org, richardcochran@gmail.com,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, vladimir.oltean@nxp.com,
vadim.fedorenko@linux.dev, andrew@lunn.ch,
linux-kernel@vger.kernel.org, arkadiusz.kubalewski@intel.com,
jiri@resnulli.us, jonathan.lemon@gmail.com
Subject: Re: [PATCH net v6 1/8] net: dsa: sja1105: keep pin function on EXTTS disable
Date: Fri, 27 Nov 2026 16:47:58 +0000 [thread overview]
Message-ID: <179579807811.3135.3342251402434914609@kernel.org> (raw)
In-Reply-To: <20261126-timecard-driver-v6-1-ahmadexp@gmail.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The changelog says the coding assistant helped 'develop the
correction and source-derived regression test' and that 'The test…
- [Low] The commit author is 'ahmadexp <ahmadexp@gmail.com>' but the
trailer is 'Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>'.
Pre-existing issues:
- [High] Pre-existing teardown race, not introduced by this patch: the
EXTTS poll timer can be re-armed after it is cancelled in…
- [High] Pre-existing init-order race, not introduced by this patch:
sja1105_ptp_clock_register() makes the PHC (and its .enable callback)…
--
net: dsa: sja1105: keep pin function on EXTTS disable
This patch changes sja1105_extts_enable() so that the PTP_CLK pin is only
switched to PTP_PF_EXTTS when capture is being enabled. Disabling EXTTS
now only clears the enabled state and stops the poll timer. The pin is no
longer moved away from periodic output.
> A coding assistant helped analyze the teardown side effect, develop the correction and source-derived regression test, and prepare this changelog. The test exercises the actual function with configuration writes stubbed.
[Severity: Low]
The changelog mentions a regression test. The patch only touches
drivers/net/dsa/sja1105/sja1105_ptp.c, and the test is neither included
nor linked. Could the test be included, or the reference dropped?
With sja1105_dynamic_config_write() stubbed, can the test see whether
PTP_CLK keeps driving the periodic output after an EXTTS disable?
Was this change run on SJA1105 hardware? If not, could the changelog say
so, as Documentation/process/coding-assistants.rst asks? Another patch in
the series, "ptp: ocp: match ART DPLL frequencies to selectors", states
that no physical card was used.
> Author: ahmadexp <ahmadexp@gmail.com>
> [ ... ]
> Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
[Severity: Low]
The email addresses match, but the author name differs from the
Signed-off-by name. checkpatch reports this as FROM_SIGN_OFF_MISMATCH.
Could the git author be set to the name used in the sign-off before
resending? The same mismatch appears on every patch in the series.
> 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;
> + }
>
> priv->ptp_data.extts_enabled = on;
>
[Severity: High]
This isn't a bug introduced by this patch, but the enable path just below
this hunk can re-arm the EXTTS poll timer after teardown has cancelled it:
drivers/net/dsa/sja1105/sja1105_ptp.c:sja1105_extts_enable() {
...
if (on)
sja1105_ptp_extts_setup_timer(&priv->ptp_data);
...
}
sja1105_ptp_clock_unregister() stops the timer before the PHC is
unregistered:
drivers/net/dsa/sja1105/sja1105_ptp.c:sja1105_ptp_clock_unregister() {
...
timer_delete_sync(&ptp_data->extts_timer);
ptp_cancel_worker_sync(ptp_data->clock);
...
ptp_clock_unregister(ptp_data->clock);
ptp_data->clock = NULL;
}
Userspace can still reach sja1105_extts_enable() with on=1 until
posix_clock_unregister() marks the clock as a zombie inside
ptp_clock_unregister(). Two ways in are a PTP_EXTTS_REQUEST ioctl on an
already open /dev/ptpN and a write to the extts_enable sysfs file:
ptp_extts_request()
ops->enable(ops, &req, 1)
sja1105_ptp_enable()
sja1105_extts_enable()
sja1105_ptp_extts_setup_timer()
mod_timer()
ptp_disable_all_events() doesn't undo this. It only disables EXTTS
channels whose pin is set to PTP_PF_EXTTS:
drivers/ptp/ptp_chardev.c:ptp_disable_all_events() {
...
if (info->pin_config[i].func == PTP_PF_EXTTS)
ptp_disable_pinfunc(info, info->pin_config[i].func,
info->pin_config[i].chan);
...
}
sja1105_ptp_pin defaults to .func = PTP_PF_NONE, and ptp_extts_request()
doesn't require a pin assignment. The re-armed timer would therefore stay
pending.
sja1105_ptp_extts_timer() re-arms itself and calls
ptp_schedule_worker(ptp_data->clock, 0). Can this touch a freed ptp_clock
after kthread_destroy_worker() or put_device()? Or a NULL clock once
ptp_data->clock is cleared?
And once the devm allocated priv is freed, wouldn't a pending timer_list
be left behind in freed memory?
[Severity: High]
This is also a pre-existing issue, not introduced by this patch.
sja1105_ptp_clock_register() makes the PHC, and its .enable callback,
visible to userspace before the EXTTS timer is set up:
drivers/net/dsa/sja1105/sja1105_ptp.c:sja1105_ptp_clock_register() {
...
ptp_data->clock = ptp_clock_register(&ptp_data->caps, ds->dev);
...
timer_setup(&ptp_data->extts_timer, sja1105_ptp_extts_timer, 0);
...
}
On the first setup, priv comes from devm_kzalloc_obj(), so timer->function
is NULL and __mod_timer() returns early. An EXTTS enable that lands in this
window is silently dropped. EXTTS then reports as enabled but never polls.
The later setup of a live priv looks more serious. In a multi-switch tree,
removing and re-probing another switch goes through
dsa_switch_remove()->dsa_tree_teardown(). That runs sja1105_teardown() and
then sja1105_setup() on the surviving sja1105.
sja1105_ptp_clock_unregister() uses timer_delete_sync() rather than
timer_shutdown_sync(), so timer->function still points at
sja1105_ptp_extts_timer. An EXTTS enable on the newly registered /dev/ptpN
could then enqueue the timer before timer_setup() runs:
sja1105_setup()
sja1105_ptp_clock_register()
ptp_clock_register() /dev/ptpN is now live
PTP_EXTTS_REQUEST
sja1105_extts_enable(on=1)
mod_timer()
timer_setup()
Can timer_setup() then reset entry.pprev and timer->flags while the timer
is still linked in the timer wheel?
If so, expiry would seem to reach __hlist_del() with a NULL pprev. Another
outcome is a later timer_delete_sync() that sees the timer as not pending
and leaves it in the wheel.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-timecard-driver-v6-0-ahmadexp%40gmail.com
next prev parent reply other threads:[~2026-11-27 16:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 16:42 [PATCH net v6 0/8] ptp: fix OCP routes and SJA1105 pin direction Ahmad Byagowi
2026-11-26 16:42 ` [PATCH net v6 1/8] net: dsa: sja1105: keep pin function on EXTTS disable Ahmad Byagowi
2026-11-27 16:47 ` netdev-bot+sashiko [this message]
2026-11-26 16:42 ` [PATCH net v6 2/8] net: dsa: sja1105: keep pin function on PEROUT disable Ahmad Byagowi
2026-11-27 16:47 ` netdev-bot+sashiko
2026-11-26 16:42 ` [PATCH net v6 3/8] ptp: ocp: preserve timestamp routes on DPLL frequency changes Ahmad Byagowi
2026-11-27 16:48 ` netdev-bot+sashiko
2026-11-27 16:53 ` Olech, Milena
2026-11-26 16:42 ` [PATCH net v6 4/8] ptp: ocp: restore disabled SMA inputs when binding Ahmad Byagowi
2026-11-27 16:48 ` netdev-bot+sashiko
2026-11-26 16:42 ` [PATCH net v6 5/8] ptp: ocp: report disabled SMA inputs as zero Hz Ahmad Byagowi
2026-11-27 16:48 ` netdev-bot+sashiko
2026-11-26 16:42 ` [PATCH net v6 6/8] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-27 16:48 ` netdev-bot+sashiko
2026-11-26 16:42 ` [PATCH net v6 7/8] ptp: ocp: match ART DPLL frequencies to selectors Ahmad Byagowi
2026-11-26 16:42 ` [PATCH net v6 8/8] ptp: ocp: defer timestamp shutdown to clock unregister Ahmad Byagowi
2026-11-27 16:48 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179579807811.3135.3342251402434914609@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=ahmadexp@gmail.com \
--cc=andrew@lunn.ch \
--cc=arkadiusz.kubalewski@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=jiri@resnulli.us \
--cc=jonathan.lemon@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®