From: Ahmad Byagowi <ahmadexp@gmail.com>
To: netdev@vger.kernel.org, richardcochran@gmail.com,
vadim.fedorenko@linux.dev
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, linux-kernel@vger.kernel.org, pabeni@redhat.com
Subject: Re: [PATCH net 1/4] ptp: ocp: prevent timestamp rearming during detach
Date: Thu, 19 Nov 2026 13:19:57 -0800 [thread overview]
Message-ID: <20261119-timecard-common-v2-078fe69f33-r1-ahmadexp@gmail.com> (raw)
In-Reply-To: <ad6883e5-c103-4f82-8040-e5463477ca10@linux.dev>
On Thu, 19 Nov 2026 at 18:24:24 +0000, Vadim Fedorenko wrote:
> On 18/11/2026 20:05, Ahmad Byagowi wrote:
>> + 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
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
next prev parent reply other threads:[~2026-11-19 21:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 20:05 [PATCH net 0/4] ptp: ocp: fix timestamp teardown and DPLL routing Ahmad Byagowi
2026-11-18 20:05 ` [PATCH net 1/4] ptp: ocp: prevent timestamp rearming during detach Ahmad Byagowi
2026-11-19 18:24 ` Vadim Fedorenko
2026-11-19 21:19 ` Ahmad Byagowi [this message]
2026-11-18 20:05 ` [PATCH net 2/4] ptp: ocp: use hardware selectors in DPLL frequency operations Ahmad Byagowi
2026-11-18 20:05 ` [PATCH net 3/4] ptp: ocp: report disabled SMA inputs consistently over DPLL Ahmad Byagowi
2026-11-18 20:05 ` [PATCH net 4/4] ptp: ocp: correct the DCF output 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=20261119-timecard-common-v2-078fe69f33-r1-ahmadexp@gmail.com \
--to=ahmadexp@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--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 \
/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®