Article View: linux.kernel.netdev
Article #20643[PATCH net v4 2/5] ptp: ocp: handle hardware selectors and combined DPLL input routes
From: Ahmad Byagowi
Date: Mon, 23 Nov 2026 01:57
Date: Mon, 23 Nov 2026 01:57
97 lines
14739 bytes
14739 bytes
The selector table index is not the hardware selector value. Passing the
index to the SMA setter can select unrelated signals. Use the table
value, as the sysfs path already does, and mask the direction enable bit
before looking up the frequency.
Inputs can feed several destinations. For example, IN: TS1 TS2 produces
selector 0x000c, which is not an individual table entry. An exact-match
frequency lookup fails with -EINVAL, preventing the DPLL core from
reading the old frequency before a later frequency change. The error
also propagates through the DPLL pin dump.
For input combinations, report a known frequency only when the selected
frequency-bearing destinations agree. Timestamp and counter destinations
do not constrain it. Report zero when there is no known frequency, when
destinations disagree, or when unknown selector bits remain. This uses
the same zero-frequency representation as individual timestamp routes.
Keep the exact-match requirement for output selectors.
Source-derived tests reproduce the selector and combined-input failures
using stubbed MMIO and the DPLL core get-before-set function. They pass
with the fix under ASan/UBSan. No physical card was tested.
The issues were reported by the Sashiko review. Codex assisted with the
code, tests and changelog in response to those reports.
Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Link: https://lore.kernel.org/r/179538006772.3135.15875996486888374193@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v4:
- Handle input masks with multiple destinations and make ambiguous
frequencies explicit as zero. Keep exact output matching.
- Drop the earlier review tag because this expands the implementation.
Testing: 4,669 input masks across FB/ADVA/ADVA X1 tables, timestamp-only
and mixed-frequency routes, unknown bits, strict output matching and
recovery through the actual DPLL core get-before-set function. The old
source fails the combined-input test. Selector, mask, combined-route and
conflicting-frequency negative variants fail at runtime under ASan/UBSan.
drivers/ptp/ptp_ocp.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index b16d36c3305f..df1a428eb2fe 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -5869,7 +5869,8 @@ static int ptp_ocp_dpll_frequency_set(const struct dpll_pin *pin,
tbl = bp->sma_op->tbl[sma->mode];
for (i = 0; tbl[i].name; i++)
if (tbl[i].frequency == frequency)
- return ptp_ocp_sma_store_val(bp, i, sma->mode, sma_nr + 1);
+ return ptp_ocp_sma_store_val(bp, tbl[i].value,
+ sma->mode, sma_nr + 1);
return -EINVAL;
}
@@ -5887,6 +5888,7 @@ static int ptp_ocp_dpll_frequency_get(const struct dpll_pin *pin,
int i;
val = bp->sma_op->get(bp, sma_nr + 1);
+ val &= SMA_SELECT_MASK;
tbl = bp->sma_op->tbl[sma->mode];
for (i = 0; tbl[i].name; i++)
if (val == tbl[i].value) {
@@ -5894,7 +5896,28 @@ static int ptp_ocp_dpll_frequency_get(const struct dpll_pin *pin,
return 0;
}
- return -EINVAL;
+ if (sma->mode == SMA_MODE_OUT)
+ return -EINVAL;
+
+ /* Inputs can feed several destinations, including timestampers. */
+ *frequency = 0;
+ for (i = 0; tbl[i].name; i++) {
+ if (!(val & tbl[i].value))
+ continue;
+ val &= ~tbl[i].value;
+ if (!tbl[i].frequency)
+ continue;
+ if (*frequency && *frequency != tbl[i].frequency) {
+ *frequency = 0;
+ return 0;
+ }
+ *frequency = tbl[i].frequency;
+ }
+ /* Unknown destinations do not establish a frequency either. */
+ if (val)
+ *frequency = 0;
+
+ return 0;
}
static const struct dpll_device_ops dpll_ops = {
Technical Details
Message-ID:
<20261122-timecard-common-v4-e0db4ab1aa-2-ahmadexp@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368946-linux-kernel-netdev=dewy.ruReferences:
<20261122-timecard-common-v4-e0db4ab1aa-0-ahmadexp@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368946-linux-kernel-netdev=dewy.ru
From: ahmadexp@gmail.com (Ahmad Byagowi)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v4 2/5] ptp: ocp: handle hardware selectors and combined DPLL input routes
Date: Sun, 22 Nov 2026 17:57:38 -0800
Organization: Usenet Network
Message-ID: <20261122-timecard-common-v4-e0db4ab1aa-2-ahmadexp@gmail.com>
References: <20261122-timecard-common-v4-e0db4ab1aa-0-ahmadexp@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3766739"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:e1cn9fVbL4GRfvD3BGONf/8b8OY= sha256:qQpDMga4Q0w7vgAT56KzgDg93tQ18Xht1sl2bWyLDOg=
sha1:+HcW9wJStPZg9c3EqQ9lbLBBo30= sha256:gqO+A/yV0ZFyHsAZuICM9uOqcKpQn5pPtDq31R4mB6k=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 0FAF8125D8D; Mon, 23 Nov 2026 04:57:57 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id mOn_HWUkj4tn;
Mon, 23 Nov 2026 04:57:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368946-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 26367125D8B; Mon, 23 Nov 2026 04:57:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 121CA2904C; Mon, 23 Nov 2026 01:57:43 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1795399063;
b=V4ohz/opoOwoXWSTPWhKq6mqEQxe/WsMxur0o9SIKAuRskMLRCTCDfKgX7fkOmNYzxnl
xZUS688qy6TWZZRVo1TL17q+kINiqx8ED49Zz3mi58ffzGvJkFuO1RNmo2eLp3C8l0R+I
d5Jp0PvYqxNA6U8ekGAdhsuZaL+8uJNXjon5BRv+ktPohUgaLlndsRQz3Ih/KWVZWTsd6
Kl06YByalZP/DIqdcSS5j3b3R15FKAb9kcJDrG+GYh8qvb/cqJdrlimD0raz0fEUWWK0q
ovv35aEpRJWz6Udcrf07uUTYnFJhRjA74KKznaf//DH6lGEDCo5Rxq1z2dLAiGD1euA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795399063;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=Yz+h8e6nlUGS3YHD1p73owGomONCcK+wC5nQNATZT5I=;
b=QZAek+XEF7XnhmdYNDIVZJIAFbH3ssF1YwXFS3RqwUOHTb8gaLOQSFTYovAugcbPxeFk
q8JIgMCjx7ulG2oAIVWEjRYIcwrrD0wVwJYBtv1s19+Vbzsp8qSPwUOQNFsxxtofqS8YD
0pJfka5nGEbYf6d+I7lmyvLy/L9JwcQ1jw5K1/hjpUI6ia0Dm+h7KREFs6Zv47xh5tlJA
/pRvtKGRQV7MXZQiYtKyj4MDigGeYDqhMQlYwO35hATgX7nWGXaYproudSLowPWIX5CYK
OMeXXto1ayTZJmGb08YC6DVmlTbLfWBaIvhzXJYWE2Y7YXiKt+mDOIA0j8nHIYCDHpw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="e+ia0Ge/";
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id DDBBC606A32D;
Mon, 23 Nov 2026 01:57:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=e+ia0Ge/
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795399062;
b=nRoqSp8g9gMIwJdd61HD6ZgAMwidXXHJKIp48I/Q+nboMAzu5jASdAnjFG/GgRk96zZQ
3Htzy+kLb5h+AAKzrumsBqEJPwPqsBePEEZm7yJvRHTZZnJpdbUciS6C1qsLxt50aNvVq
HordcnwDiPza25XoxCArbM051w2JXoBf1/o8741bbBxP21tyvXnq3u3AdGKmWwaOMeBQN
smtmXldVYVVugb+KOSMEgZA2L/i1ZSPRVUzFh+KODa3QJK2Biqpf7+1ls/3UCPSr6zQ46
5U7PYDXwZOeLDA62yWU6mhU0J4iBvTE6huT0odlz9M2llr7Iy/0Qcd8FrG+MGZLX2Uw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795399062;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=Yz+h8e6nlUGS3YHD1p73owGomONCcK+wC5nQNATZT5I=;
b=5XRZ4qAiEdXVbdFoRTvPiAh1WX8/OMxq5857Z7X4En3d6oX5Hz939hSoocuZa9MPA+zU
EwULpMRErzOiblZhhyDZG4JKiTj5/OqdPYIJrKwy8i9Q0gGPHd+ZJXVp0m87u114SKbAa
5yhFGg3SsgIW6uK8iujzO9CB9zmDTKnZ2ztg9EppjPXKiNHZ+DtkMVOvtqW2+v0c+D1vI
7/79hyZA2aN4eHk+I7bZrUnzSlJSA9db9qY8Hn3fAz8gFeD7KoqHZotUdhRPIBJEx7kKR
q9mqnpdKsk/JQbT151nypTg7dIBeXS5WYvG8viNbUrVKkgXsLc3vglEBCUnPaDSoRHw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="e+ia0Ge/";
arc=none smtp.remote-ip=74.125.82.51
X-Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF97D606A31A
for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 01:57:41 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AF97D606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-15dd124bbe7so969997c88.1
for <netdev@vger.kernel.org>; Sun, 22 Nov 2026 17:57:41 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795399061; x=1796003861; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=Yz+h8e6nlUGS3YHD1p73owGomONCcK+wC5nQNATZT5I=;
b=e+ia0Ge/5Z+b5LRVJTFyzd5GeA3yjJkTZV1waFmedghs32YyHpqSFNlGcPvO8m7cOR
bYEYNUpsM2S4xd1U38UG9cAnu/rq67gHZHlDRWYRnQU2Fgwn4vV5tjKTxvouhibYyTYu
LrWL0dBQQmgzIOVmWVm7sOAc3qxvylTWw9sZ1HO181sRz3m4xc6kAv0Lc7ZXmH2Eou6W
vKb+qlpujLDnUqMpYTUML3ZWQjd/oYWI1Qp8KGfVTgs1JQ8BQLk8IkRgWNrBAmb0yUkI
zSmc3sA8A7x9WOywWXuFGgsOPHsE4s33y56gJXBoZS7l98dtt+R5cX+K+4eCPrTGzABL
jUXw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795399061; x=1796003861;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=Yz+h8e6nlUGS3YHD1p73owGomONCcK+wC5nQNATZT5I=;
b=Yhz2WqnFdse22Nt73szr7PDfBSclAU66o/CreRjmUInB8gkQY/SDR/k1fSDcndj36f
Fb0P4z4Up5ajWqLh+WRMVMcdkhO/t+R4mMCUq/2eneezc4Mhi4DHTSwzhf6380x5Q7+p
cmG7mXiypDqQ4Kp6O4MUedKpf2ejpl2kLzRmxVgWkpK8wQaaGaG0Z/RSHp660WdPJshx
d/0Pagh02maaSSRuKCLyTcmSSijP9Zlo8QuW4UZvTf/OUfF73PZemixjlGqD/JljH5jN
Sv2dQN3zWmMZ4iQyT2t9LW3ljLBV0bvxnoI+5qbZuSAkmUPmEJM7LFZucUI7AjrvXfjz
LY7g==
X-Gm-Message-State: APuU4Z8VU491A7DC5JBJaWovMf6c45JAC1K2eBXVUh10jvpWP1c4Efer
EvZMHdTwSIT7zIaY7Lw58MTR+eGgBUIAgf1l91U85y3Jt0e5qnFxI56QZt3g31xK
X-Gm-Gg: AZFdTZf/4qBVBBZgdvVuyvnSQfM7j+pioMFs7DapUyvON/oE4rM1sOXEjnY57i6Yddd
H0XLD2HShcVLAred+8vjEiOsWIj6dN2+SEbrlJKJ9JvYSZcLjfZ97CAj6xYX9brLidhVaNTNcFl
hb3hfDVwtx/wOR8td6r8Za2KbwIroJsg0J/wYRUqsybdSdaqV8/24Decxs3pCjMoJTkwO3IWkGq
F+ve6wKPeZhdCH29SXareNYQuYCiH7JixYPL91uH2kCJVSj4QnBunXovQMX6MoxmWfboa76p3My
Sz0ZBqAzuAS7OjVTqC7z6PXJXbwibE9oY6jEZU0KCytcVNOfWTEXz6Z7P6omfkSgedXsTL0x2BJ
+xH4bbZNdw+j8576Qvsc49gcah7sdcuddVIW6CiW+uzamygZ2dy0BZQB5etYUUbYaXdpWGIQmqZ
q7UBU6FcNw3ofZjv/yRe0z8lPfT8JO2faD27d4qX2W5CG67buoqKK6HTGWg+sHtZlgntvy7xDmk
9Pxpin44zefLg8ycbxDeFva0SZwikNrOHUUTiRptXB6OixurP4Kw1Zdo5wqEzcOhggdWnIH0YZR
t9UIm+pyCtkpSIIQhKju5FK42b3tC6dQ1BYiWY3aLgjdiY8isjSvTNOcfJrtNGAPmIf/a2zrFfa
MiyfNKhmVa3UNE6Ho0wwhu5MyXIn42bdV0s5s3SCr4iOHrWi+0CWb6x7jkVj+Vq/fhOUBL5SO
X-Received: by 2002:a05:693c:414e:10b0:386:a1ae:6762 with SMTP id 5a478bee46e88-386a1ae6d5fmr6018064eec.36.1795399060780;
Sun, 22 Nov 2026 17:57:40 -0800 (PST)
X-Received: from Mac.localdomain (198-27-228-154.fiber.dynamic.sonic.net. [198.27.228.154])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38567abb870sm25648335eec.25.2026.11.22.17.57.39
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Sun, 22 Nov 2026 17:57:40 -0800 (PST)
X-Cc: 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
X-In-Reply-To: <20261122-timecard-common-v4-e0db4ab1aa-0-ahmadexp@gmail.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list