From: Ahmad Byagowi <ahmadexp@gmail.com>
To: netdev-bot+sashiko@kernel.org
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: Mon, 23 Nov 2026 20:42:54 -0800 [thread overview]
Message-ID: <20261123-timecard-common-v5-d669cfa034-r1-ahmadexp@gmail.com> (raw)
In-Reply-To: <179548551283.3135.17206659598806657887@kernel.org>
On Tue, 24 Nov 2026 at 01:58:32 +0000, netdev-bot+sashiko@kernel.org wrote:
> [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.
You're right. V4 addressed final shutdown but left the runtime callers
unserialized. The reported schedule reproduces with the actual v4
functions and stubbed registers: the map ends at OCP_REQ_PPS while both
enable and intr_mask are zero.
The v5 series adds a prerequisite taking pincfg_mux around the enable
callback in extts_enable_store(), pps_enable_store() and period_store().
The latter two also lacked the lock. This uses the same mutex as the
ioctl paths and permits synchronize_irq() to sleep. Permission and parse
checks remain outside the critical section; callback errors and an
interrupted lock acquisition are propagated.
Four controlled sysfs/ioctl interleavings passed in 100 ASan/UBSan runs.
The final map and hardware enable/mask agree. Three additional local
KUnit cases call the real sysfs stores against a registered test clock
while pincfg_mux is held, then verify completion after release. All
eight KUnit cases passed in QEMU with KASAN, lockdep and
DEBUG_ATOMIC_SLEEP. No physical OCP card was used.
> With either one in place, the original shortcut would still be correct
> and this change would not be needed.
That removes the runtime-race justification for changing the shortcut.
I corrected the message accordingly. The series retains the final
empty-map disable for a separate reason: ptp_ocp_register_ext() requests
the IRQ without resetting the timestamp source, so an empty software
subscription map is not proof that the initial hardware state is idle.
The final disable still masks and drains that source before releasing
the clock. The test explicitly models a prearmed source with map == 0;
it no longer simulates a sysfs callback bypassing the now-held mutex.
This is a modeled state, not an observation on physical hardware.
> [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:
Yes, and that side effect was not intended. A second prerequisite makes
sja1105_extts_enable() select EXTTS only when enabling capture. Disable
clears extts_enabled and synchronously deletes the timer without changing
cas_master or attempting the AVB_PARAMS write. Repeated disable is safe,
and the enable/error paths are retained.
The actual-function test reproduces the output-to-input change on v4.
The correction passes 14 modeled chip/direction cases per run, repeated
100 times, including repeated disable and enable/error paths. The writes
are stubbed: this is not an SJA1105/SJA1110 hardware test. All four
x86_64/i386 allmodconfig/allyesconfig builds passed for PTP and the
SJA1105 PTP object with W=1 and KCFLAGS=-Werror.
Vadim's teardown approach remains unchanged: remove the user interfaces,
then directly disable every advertised EXTTS channel followed by PPS.
No pin assignment, pin-function helper misuse, new stopping flag or
spinlock is introduced. The removal/shared-PPS suite passed 100 runs,
and all seven deliberately broken cleanup variants failed at runtime.
I have sent v5 for review. The v4 series should not be applied as-is.
Thank you for identifying both gaps.
Series:
https://lore.kernel.org/r/20261123-timecard-common-v5-d669cfa034-0-ahmadexp@gmail.com
Patch 1:
https://lore.kernel.org/r/20261123-timecard-common-v5-d669cfa034-1-ahmadexp@gmail.com
Patch 2:
https://lore.kernel.org/r/20261123-timecard-common-v5-d669cfa034-2-ahmadexp@gmail.com
Patch 3:
https://lore.kernel.org/r/20261123-timecard-common-v5-d669cfa034-3-ahmadexp@gmail.com
Ahmad
pw-bot: cr
next prev parent reply other threads:[~2026-11-24 4:42 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
2026-11-24 4:42 ` Ahmad Byagowi [this message]
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=20261123-timecard-common-v5-d669cfa034-r1-ahmadexp@gmail.com \
--to=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-bot+sashiko@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