From: netdev-bot+sashiko@kernel.org
To: ahmadexp@gmail.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
arkadiusz.kubalewski@intel.com, davem@davemloft.net,
edumazet@kernel.org, jiri@resnulli.us, kuba@kernel.org,
pabeni@redhat.com, richardcochran@gmail.com,
rmk+kernel@armlinux.org.uk, vadim.fedorenko@linux.dev,
vladimir.oltean@nxp.com
Subject: Re: [PATCH net v4 1/5] ptp: disable all timestamp channels after removing the user interfaces
Date: Tue, 24 Nov 2026 01:58:32 +0000 [thread overview]
Message-ID: <179548551283.3135.17206659598806657887@kernel.org> (raw)
In-Reply-To: <20261122-timecard-common-v4-e0db4ab1aa-1-ahmadexp@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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).
- [Medium] Nothing serializes the two callers of ptp_ocp_ts_enable()
(drivers/ptp/ptp_ocp.c).
- [Low] ptp_disable_all_events() (drivers/ptp/ptp_chardev.c) now sends
PTP_CLK_REQ_EXTTS with on=0 to every channel below info->n_ext_ts,…
--
I found two possible regressions in commit 9b634abf9770 (ptp: disable all timestamp channels after removing the user interfaces). One is a runtime race on the shared PPS source in ptp_ocp_ts_enable() that the narrowed shortcut opens up. The other is a teardown side effect on sja1105, where the new blanket EXTTS disable changes the pin direction.
ptp: disable all timestamp channels after removing the user interfaces
This patch changes ptp_disable_all_events() to send an EXTTS disable to
every channel below n_ext_ts, not only to pins assigned to PTP_PF_EXTTS.
It removes the early timestamper disable loop from ptp_ocp_detach(). It
also narrows the pps_req_map shortcut in ptp_ocp_ts_enable() so that a
disable with an empty map still reaches the registers.
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Link: https://lore.kernel.org/r/4e42134b-b017-4836-9772-9c1915b16e77@linux.dev
Link: https://lore.kernel.org/r/08537eb6-3f85-4a46-b3be-46796998eda4@linux.dev
> diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
> index f63b45f5ee6ae..5835c01cddb49 100644
> --- a/drivers/ptp/ptp_chardev.c
> +++ b/drivers/ptp/ptp_chardev.c
> @@ -53,11 +53,15 @@ void ptp_disable_all_events(struct ptp_clock *ptp)
> unsigned int i;
>
> mutex_lock(&ptp->pincfg_mux);
> - /* Disable any pins that may raise EXTTS events */
> - for (i = 0; i < info->n_pins; i++)
> - if (info->pin_config[i].func == PTP_PF_EXTTS)
> - ptp_disable_pinfunc(info, info->pin_config[i].func,
> - info->pin_config[i].chan);
> + /* EXTTS requests do not require a pin assignment. */
> + for (i = 0; i < info->n_ext_ts; i++) {
> + struct ptp_clock_request req = {
> + .type = PTP_CLK_REQ_EXTTS,
> + .extts.index = i,
> + };
> +
> + info->enable(info, &req, 0);
> + }
[Severity: Low]
Can this loop change the hardware pin direction on sja1105 during
teardown?
The commit message says "Keep the pin configuration unchanged". However,
sja1105 registers n_pins=1, n_ext_ts=1 and n_per_out=1, and EXTTS and
PEROUT share the single PTP_CLK pin. Its EXTTS handler switches the pin
function whatever the value of on:
drivers/net/dsa/sja1105/sja1105_ptp.c:sja1105_extts_enable() {
...
rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_EXTTS);
if (rc)
return rc;
priv->ptp_data.extts_enabled = on;
...
}
When the old function differs, sja1105_change_ptp_clk_pin_func() does:
avb->cas_master = (func == PTP_PF_PEROUT);
return sja1105_dynamic_config_write(priv, BLK_IDX_AVB_PARAMS, 0, avb,
true);
On SJA1105P/Q/R/S and SJA1110, suppose PEROUT was the last function used
on the pin (through PTP_PEROUT_REQUEST or PTP_PIN_SETFUNC). Teardown then
takes this path:
sja1105_teardown()
sja1105_ptp_clock_unregister()
ptp_clock_unregister()
ptp_disable_all_events()
sja1105_extts_enable(on=0)
That path now clears cas_master and writes AVB_PARAMS over SPI. PTP_CLK
becomes an input and the periodic output stops, while
pin_config[0].func still reads PTP_PF_PEROUT.
Before this patch the pin's func was not PTP_PF_EXTTS, so no EXTTS
disable was sent and the output kept running.
On SJA1105E/T the helper always sees old_func as PEROUT. Every unregister
now calls sja1105_dynamic_config_write(BLK_IDX_AVB_PARAMS), which returns
-ERANGE before any SPI transfer, so it has no effect there.
Is this teardown side effect intended? If so, should the commit message
mention it?
[ ... ]
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 625a85b2dc7e5..b16d36c3305f9 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -2559,8 +2559,8 @@ ptp_ocp_ts_enable(void *priv, u32 req, bool enable)
> else
> bp->pps_req_map &= ~req;
>
> - /* if no state change, just return */
> - if ((!!old_map ^ !!bp->pps_req_map) == 0)
> + /* Skip the register update while a subscription remains. */
> + if (old_map && bp->pps_req_map)
> return 0;
> }
[Severity: Medium]
Can a disable that finds the map already empty now undo a concurrent
enable at runtime?
Nothing serializes the callers of ptp_ocp_ts_enable():
- extts_enable_store() in drivers/ptp/ptp_sysfs.c calls ops->enable()
without taking ptp->pincfg_mux.
- ptp_extts_request() and ptp_enable_pps() in ptp_chardev.c call it
under pincfg_mux.
- ptp_ocp_enable() sends both PTP_CLK_REQ_PPS and PTP_CLK_REQ_EXTTS
index 5 to bp->pps, and takes no driver lock.
Before this patch, a disable with old_map == 0 and a new map of 0
returned early. Now it goes on to the register disable. Suppose the map
is 0 and the source is disabled:
CPU A (sysfs: echo "5 0" > extts_enable)
ptp_ocp_ts_enable(bp->pps, OCP_REQ_TIMESTAMP, false)
old_map = 0, pps_req_map = 0
shortcut not taken, enters the disable branch
CPU B (PTP_ENABLE_PPS ioctl, enable=1)
ptp_ocp_ts_enable(bp->pps, OCP_REQ_PPS, true)
old_map = 0, pps_req_map = OCP_REQ_PPS
iowrite32(1, ®->enable);
iowrite32(1, ®->intr_mask);
returns success
CPU A
iowrite32(0, ®->intr_mask);
iowrite32(0, ®->enable);
synchronize_irq(irq_vec);
The result is pps_req_map == OCP_REQ_PPS with the source hardware
disabled. No PPS events reach the pps device, even though the ioctl
returned success. The state stays inconsistent until userspace disables
and re-enables PPS.
Older interleavings of the same kind also remain. Examples are an ioctl
disable racing a sysfs enable, or a lost |= or &= update on pps_req_map.
The commit message acknowledges that "An overlapping extts_enable sysfs
request and ioctl can leave an empty map with the source enabled", but
this patch only handles that at teardown.
Could the pps_req_map update and the register writes be serialized
instead? Two options:
- Use a driver mutex. A spinlock won't work, because synchronize_irq()
can sleep.
- Make extts_enable_store() take pincfg_mux, as the ioctl paths do.
With either one in place, the original shortcut would still be correct
and this change would not be needed.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122-timecard-common-v4-e0db4ab1aa-0-ahmadexp%40gmail.com
next prev parent reply other threads:[~2026-11-24 1:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 1:57 [PATCH net v4 0/5] Fix PTP teardown and Time Card DPLL operations Ahmad Byagowi
2026-11-23 1:57 ` [PATCH net v4 1/5] ptp: disable all timestamp channels after removing the user interfaces Ahmad Byagowi
2026-11-24 1:58 ` netdev-bot+sashiko [this message]
2026-11-24 4:42 ` Ahmad Byagowi
2026-11-23 1:57 ` [PATCH net v4 2/5] ptp: ocp: handle hardware selectors and combined DPLL input routes Ahmad Byagowi
2026-11-23 1:57 ` [PATCH net v4 3/5] ptp: ocp: preserve disabled SMA inputs across driver rebind Ahmad Byagowi
2026-11-24 1:58 ` netdev-bot+sashiko
2026-11-24 4:42 ` Ahmad Byagowi
2026-11-23 1:57 ` [PATCH net v4 4/5] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-23 1:57 ` [PATCH net v4 5/5] ptp: ocp: correct the ART 10 MHz input frequency Ahmad Byagowi
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=179548551283.3135.17206659598806657887@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=ahmadexp@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=arkadiusz.kubalewski@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=rmk+kernel@armlinux.org.uk \
--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