From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Ahmad Byagowi <ahmadexp@gmail.com>, netdev@vger.kernel.org
Cc: andrew@lunn.ch, arkadiusz.kubalewski@intel.com, arnd@arndb.de,
davem@davemloft.net, edumazet@kernel.org, jiri@resnulli.us,
john.stultz@linaro.org, jonathan.lemon@gmail.com,
kuba@kernel.org, linux-kernel@vger.kernel.org, olteanv@gmail.com,
pabeni@redhat.com, richardcochran@gmail.com,
rmk+kernel@armlinux.org.uk
Subject: Re: [PATCH net v5 3/8] ptp: disable all timestamp channels after removing the user interfaces
Date: Wed, 25 Nov 2026 09:43:50 +0000 [thread overview]
Message-ID: <5d6416ea-d927-40ac-9424-dade40191373@linux.dev> (raw)
In-Reply-To: <20261123-timecard-common-v5-d669cfa034-3-ahmadexp@gmail.com>
On 24/11/2026 04:42, Ahmad Byagowi wrote:
> PTP_EXTTS_REQUEST and extts_enable can enable channels without assigning
> a PTP_PF_EXTTS pin. ptp_disable_all_events() only visits assigned pins,
> so those channels can still generate events after the clock is released.
> ptp_ocp exposes six timestamp channels but only four SMA pin descriptors;
> the internal GNSS and PHC timestamp sources do not need an SMA assignment.
>
> Disable each advertised external timestamp channel, followed by the
> existing PPS disable, after posix_clock_unregister() has removed sysfs
> and drained active ioctls. Issue PTP_CLK_REQ_EXTTS requests directly for
> timestamp channel indices. Do not use the pin-function helper or require
> a pin assignment. Keep that helper for changes to actual pin configuration.
>
> Remove ptp_ocp's preliminary timestamp-disable loop. It runs before the
> user interfaces are removed and can race with an enable: the enable sets
> pps_req_map, detach clears it and disables the source, then the enable
> rearms the source. With shutdown delegated to the core, requests finish
> before the final disables and IRQ drains. Keep the existing resource
> cleanup for probe failures without a clock.
>
> Do not skip the shared PPS source's register disable when the final
> subscription map is empty. The map tracks software subscriptions, not
> the hardware's initial state: ptp_ocp_register_ext() requests the IRQ
> without resetting the source. An already active source must also be
> masked and drained before releasing the clock. Preserve the shortcut
> while another PPS or EXTTS subscription remains. The preceding sysfs
> serialization fix prevents runtime enables from overlapping disables;
> the SJA1105 prerequisite prevents an EXTTS disable from changing its pin.
>
> Source-derived tests with stubbed MMIO and IRQ operations reproduce the
> early-disable/map race and exercise an empty-map prearmed source. Core
> unregister tests pass in QEMU with KASAN and lockdep. These are software
> tests, not observations of a prearmed physical card.
>
> The issue was reported by the Sashiko review. Codex assisted with the
> code, tests and changelog in response to that report and Vadim's review.
>
> Fixes: a60fc3294a37 ("ptp: rework ptp_clock_unregister() to disable events")
> Fixes: 627366c51145 ("ptp: ocp: fix resource freeing order")
> 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
> Link: https://lore.kernel.org/r/179548551283.3135.17206659598806657887@kernel.org
> Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
> ---
> Changes in v5:
> - Keep the v4 code and Vadim's direct channel-disable approach unchanged.
> - Add sysfs serialization and SJA1105 prerequisites before this patch.
> - Explain the empty-map shutdown independently of the now-fixed runtime
> race, and distinguish modeled prearmed hardware from a physical test.
>
> Testing: 100 removal/shared-PPS suite runs and all eight local PTP KUnit
> cases passed. Seven cleanup mutations fail at runtime. No physical card
> was used; the review-only fixture is not part of this patch.
>
> drivers/ptp/ptp_chardev.c | 14 +++++++++-----
> drivers/ptp/ptp_ocp.c | 17 ++---------------
> 2 files changed, 11 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
> index f63b45f5ee6a..5835c01cddb4 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);
> + }
>
> /* Disable the PPS event if the driver has PPS support */
> if (info->pps) {
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 625a85b2dc7e..b16d36c3305f 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;
> }
Please, don't mix changes to the core and a single driver in the same
patch. More of it - the chunk above changes behavior, it was explained
previously, why do you still keep it??
>
> @@ -5755,19 +5755,6 @@ ptp_ocp_detach(struct ptp_ocp *bp)
> ptp_ocp_detach_sysfs(bp);
> ptp_ocp_attr_group_del(bp);
> timer_delete_sync(&bp->watchdog);
> - /* Disable interrupts on all timestampers */
> - if (bp->ts0)
> - ptp_ocp_ts_enable(bp->ts0, 0, false);
> - if (bp->ts1)
> - ptp_ocp_ts_enable(bp->ts1, 0, false);
> - if (bp->ts2)
> - ptp_ocp_ts_enable(bp->ts2, 0, false);
> - if (bp->ts3)
> - ptp_ocp_ts_enable(bp->ts3, 0, false);
> - if (bp->ts4)
> - ptp_ocp_ts_enable(bp->ts4, 0, false);
> - if (bp->pps)
> - ptp_ocp_ts_enable(bp->pps, ~0, false);
> if (bp->ptp)
> ptp_clock_unregister(bp->ptp);
> kfree(bp->ptp_info.pin_config);
next prev parent reply other threads:[~2026-11-25 9:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 1/8] ptp: serialize sysfs requests with the ioctl paths Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 2/8] net: dsa: sja1105: leave the pin function unchanged on EXTTS disable Ahmad Byagowi
2026-11-25 4:44 ` netdev-bot+sashiko
2026-11-24 4:42 ` [PATCH net v5 3/8] ptp: disable all timestamp channels after removing the user interfaces Ahmad Byagowi
2026-11-25 9:43 ` Vadim Fedorenko [this message]
2026-11-24 4:42 ` [PATCH net v5 4/8] ptp: ocp: handle hardware selectors and combined DPLL input routes Ahmad Byagowi
2026-11-25 4:44 ` netdev-bot+sashiko
2026-11-24 4:42 ` [PATCH net v5 5/8] ptp: ocp: recover disabled SMA inputs when binding the driver Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 6/8] ptp: ocp: report zero frequency for disabled SMA inputs Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 7/8] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 8/8] ptp: ocp: correct the ART 10 MHz input frequency Ahmad Byagowi
2026-11-25 4:44 ` netdev-bot+sashiko
2026-11-25 9:46 ` [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Vadim Fedorenko
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=5d6416ea-d927-40ac-9424-dade40191373@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=ahmadexp@gmail.com \
--cc=andrew@lunn.ch \
--cc=arkadiusz.kubalewski@intel.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=jiri@resnulli.us \
--cc=john.stultz@linaro.org \
--cc=jonathan.lemon@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=rmk+kernel@armlinux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.