On Thu, 19 Nov 2026 at 18:24:24 +0000, Vadim Fedorenko wrote:
On 18/11/2026 20:05, Ahmad Byagowi wrote:
quoted
+ mutex_lock(&bp->ts_lock);
+ if (enable && bp->ts_stopping) {
+ err = -ENODEV;
+ goto out;
+ }
ts_stopping is changed only in device detach callback, there is actually
no need to cover whole ptp_ocp_ts_enable() with mutex, I believe
existing spinlock can be used to serialize this access, no?
Yes, the existing bp->lock is sufficient. I have sent the four-patch
v2 common-fix series to net:
https://lore.kernel.org/r/20261119-timecard-common-v2-078fe69f33-0-ahmadexp@gmail.com (local)
The revised timestamp fix uses spin_lock_irqsave() for the stopping
check, PPS subscription updates and MMIO. Detach sets ts_stopping under the same lock. Keeping
the register writes in that critical section prevents an enable which
passed the check from writing after detach has disabled the channel.
The disable path still flushes the interrupt-mask write, but drops the
spinlock and restores IRQ flags before both pci_irq_vector() and
synchronize_irq(). The former takes the MSI descriptor mutex on this
kernel; the latter may sleep. There is no new driver mutex or associated
initialization/destruction.
One additional detail is the PPS no-state-change shortcut. Once the
IRQ wait is outside the lock, another disable can clear pps_req_map and
unlock before draining its IRQ. While stopping, the candidate bypasses
that shortcut so detach still disables and drains the channel itself.
Outside teardown, removing one of the PPS/EXTTS subscriptions still
leaves the other subscription armed without unnecessary MMIO.
The source-derived ASan/UBSan harness passes late-enable, in-flight-enable,
active-IRQ and in-flight-disable cases, shared PPS/EXTTS handling, and all
six channels. It asserts that MMIO is locked and vector lookup and IRQ
waits are unlocked; six deliberately broken variants are rejected.
Both common and WiWi integration PTP objects compile for x86-64 with W=1
and KCFLAGS=-Werror.
This is software evidence, not kernel lockdep or physical unbind testing.
Thanks for the suggestion.
Ahmad