Article View: linux.kernel.netdev
Article #21515[PATCH net v5 4/8] ptp: ocp: handle hardware selectors and combined DPLL input routes
From: Ahmad Byagowi
Date: Tue, 24 Nov 2026 04:42
Date: Tue, 24 Nov 2026 04:42
93 lines
14174 bytes
14174 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 v5:
- Renumbered from v4 patch 2; code and commit message unchanged.
Testing: 4,669 input-route combinations and X1 direction-change recovery.
The boundary test also confirms disabled X1 reads zero Hz and re-enables
PPS at this point in the series, before patches 5 and 6.
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:
<20261123-timecard-common-v5-d669cfa034-4-ahmadexp@gmail.com>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370003-linux-kernel-netdev=dewy.ruReferences:
<20261123-timecard-common-v5-d669cfa034-0-ahmadexp@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370003-linux-kernel-netdev=dewy.ru From: ahmadexp@gmail.com (Ahmad Byagowi) Newsgroups: linux.kernel.netdev Subject: [PATCH net v5 4/8] ptp: ocp: handle hardware selectors and combined DPLL input routes Date: Mon, 23 Nov 2026 20:42:43 -0800 Organization: Usenet Network Message-ID: <20261123-timecard-common-v5-d669cfa034-4-ahmadexp@gmail.com> References: <20261123-timecard-common-v5-d669cfa034-0-ahmadexp@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4052901"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:5NCARk/fueyR1+/r90OVXOQxJu8= sha256:VyZ5+nKGwYLQdDLodhIWiAheVzPT0JPcnOtArWk9o2Y= sha1:Yz4Br/holgfpsHzbquoNkmiyvvs= sha256:2v2HppwNWSB5baokqClSFXOGdDUceTFlwvOd6MBhMes= 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 C3324125DCF; Tue, 24 Nov 2026 07:43:23 +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 oKcNmiZ1WMUV; Tue, 24 Nov 2026 07:43:20 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-370003-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id C8271125DC9; Tue, 24 Nov 2026 07:43:11 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id C992F33E1A; Tue, 24 Nov 2026 04:43:00 +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=1795495367; b=0FO8FartPYjOi2qw45v7TkkbWaiEq5Kbfa0n4xDr1J3FqFqhT3zGBqRQVqdw6sR5HKUA wysVth1UoHGghY0pBpCqBPtlGIxkkbehnE6+PeQv9P5X2O52XUMnlCq1fLEGSyIVTxIJH qcAlrTDWvuSXrbOTcpWP55DjAfeF02C+OtBMzLxwejU8el4mmQd84Twmp57p3AduQbL/z LU52+7K0wNzlVmmpBKUEWE+ozmYVw5Qx0sZhCwAgU3/bUdnFTAtsRX9j6sO1X3t7xRAb+ 9nDJZzJ7U2+WhTwUgnA2KntGN1rHrldyuZVAwMoJgfOjSF0DAQMh/wpj5RUvub8apCw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795495367; 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=g0REQExNNyBnd2hiqzHK7o6gPmAUPJWtB27KGrID9vE=; b=Y+LM2XHeOEGQVTzymFDppYRYkH0Uw2kCeQedWEp8Fy2k+7Imh+av1k+OtSNPUZb2Lzq4 YgJlFIsiiRwU93jqosICqAw4XbnlLCCKBGRw8b0iH5bndXGvpmjKBHSR672AM6kUDytqm BTjIApzApAPB8wlBujwYcSoXTKjb6xB6OnqGDAsQrCZQiM2GGNWdSCA3cOB+99TdCsIWZ gQMI7tjs6iyPMA5d5jm+1XSJQL3DdJzU/r5jqbcLVYtgI8sH2AF+OiWGKTD25UoPOaCuO fvS2Vxb0eNQ+x1qCl/yRBpfojgPJMb5eQeC+6bjILeFMQonWf0Qp0q6PhgOMIpFLPOw== 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=PE1U3dGd; 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 29D0B60A2615; Tue, 24 Nov 2026 04:42:47 +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=PE1U3dGd X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.53 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795495366; b=XkZx9ZI9dA7FWIiR1/iCAbJ9FpyHgp2NtYFPekvJnkefoVcaDWVUb42NcmnIjqAa/edQ wNGzBj9BVAnTxcXaWLsrHEgwDC6jzWp0A0hgxVkgIXGqjhM4MkEy9DcWBrh0YkiYINrP1 yrLVGXaxLbLw0eO8lqd6JCbellbv+AQWFAHDXJfanXMXSI1dVElHU4jiWegp+NBjX+wo0 8Gce+UDbBnqld6PZqujA9QMMFJJDNnqezWsWEbnvCM4fZeiR60W/dm5dG8Yo7+Q5xDe6+ 73bINW6kXcL537Q5pNAyX8gwOM0ziyRthFn0n30ZnqgZnQ0VvIFCGxFJobQrJ3IFuuw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795495366; 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=g0REQExNNyBnd2hiqzHK7o6gPmAUPJWtB27KGrID9vE=; b=CxLifuA1CVpEt/vkot1FBRcmluC1fiWhMubzCFEtLW1K9B1PojOK0+kwHRKCVX1alCyO ryY4DX+IKuMwqF8XepzjG/AFHbuLhj7IXf+r7TSYmRCXsUQBrWGIMCXmYjb6Z2f09WGjL uj9i350yHvPk+6OwY8r8eSvvOKCuz9zKDNeTpa4e2Qq6ubelkHthkG8NoyZDQT8gIvUjo JjrsnY/YkPQUwrJk3wUtpGCPppOexKAHpgLwwsYxf9xeOlppvEODqhCpR4xpaxkENClsy Y/jh9ETNG8C4/Gj0kBVrHYdxy2Ko4BY1/tK6T0+hrvtE+CsqHSKKvD1wik3hJLUoLWA== 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=PE1U3dGd; arc=none smtp.remote-ip=74.125.82.53 X-Received: from mail-dl1-f53.google.com (mail-dl1-f53.google.com [74.125.82.53]) (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 016C0606A6BB for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 04:42:45 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 016C0606A6BB 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-f53.google.com with SMTP id a92af1059eb24-1a3c08d6928so5781562c88.0 for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 20:42:45 -0800 (PST) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795495365; x=1796100165; 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=g0REQExNNyBnd2hiqzHK7o6gPmAUPJWtB27KGrID9vE=; b=PE1U3dGdxQ0Tp+ZOsxchIei3Jcht4ICbD+oLd4d7Shm9oMxLE/wjt5IB5Jpcq+bBjo wqeOIGmAC9UK5AYWN18JGHj3gkREOCjJnEihTFLTExI9LovkAFtZjfSPlICxtsGy2E4e BY+Im2rDxgoTq7iJTMPkJEHrZh2CaqxoUMC1UoYZ03J+rv7vIjFoyqx+cXWuNZpnfqs2 Q/cZsiFGdTc2AOx4H5eKQOWKxbHS7kjT9tXWw0KXwjOP2AslDKmLU/FuIB6DhQ1wiW9w 88doSUvOU/AjAXD2bRq50TkQFIR4Lnxm1D8LXsbOjp8c3xH1CtLRBpGvo4iRlko2mcRW 8xxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795495365; x=1796100165; 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=g0REQExNNyBnd2hiqzHK7o6gPmAUPJWtB27KGrID9vE=; b=txB5mpkwQTPpUf5IGevfG0U080r+RwytloEPbQbdEbme5p0gpBytIZ/eSAgS8zPOYF omtuQ7Myvox7KsRl+2CavO1uzkGH3+719jFrgrpyeOFmsfIqnirHTRfUOX8drjeSGiQr cpNK6wjPoLAKWkcicFVYi73mvtwNrQ2AvdPqOPX8t+XTx/orAn/YU1TYiC6PAENewt8S f//x9QMBW9Sks7QCoCDwjAi7iA7l1/af4Vg7rf6Qw7K1V1b7qAomCi1mBC0f+OBK9A7Y Ynkmc+a78hG5BCj7q8B7qhHVFNypRXY8BxrmEDQUyQWF8hZzeDLiz2YO30TRWj+VKDMN /USw== X-Gm-Message-State: APuU4Z+tJ/+SN/IxryMDTiALLFNCVuktYk3KeylnGfmF2l7LwBBpcvkR eLRt8hQkYVBhqk+4FCbg7+JOShvhSEPilKMRwUwoFGSeOSQpeBCsrDMoPl/UWffL X-Gm-Gg: AZFdTZeiP0NST43Aa8ujXSmtmDo4i3vVIoyA3gPMylOw9g+Eg3GLkyQ7yn0W67bCluK 8awrSzgYy3nGkyh+5Io+SS8uC/+iuLbSP7XcSucARPwV0cqNy2gegkf1mr1hf15sicZdiSSehQx b68x5C2mcUWJMNcCjtJfBqK/nxGoGo2iPbl7tFk7ExKqcMNO0mMwduAA5ABEY+aZ1oPLzbCKbgh qlbb+hMbtEg/GVpleOZoGrII06YMV9eeNAf01aeFXQAQpNph//zBj9gBGf1w81c8qUPkR/hiPLs eAlHdIsqitLtxNLstjcDyiVtLQAkgk9LColT4HUPzsdQgl2Ocvi/v8be5Rz+UFVqgG4mHseAM1g UBGVpa/Y/THlu6aroN4BfiridZFbT5BBNoC6ynkGdbsSDZm4piKZRC+XK1+iNLZKb72YBkd82Ro YGZ/b5i2gwkk42LnH4C+AsvO6BrvQzzk/uvJ/02whby1uc7cKFH8VIHlSF5q2k+LvpTp/WMIjX0 Ruy1WNRYhE6Bo741oJAjdXk+A5tr6z3qkEgHBda1qu1F3NO8Q2ltrP21Y6a1nmWaJZQBoowIN20 nNzEoCAtQhyDu+1zcyqSlg0VLQzc9zFlWYU3Tied2+VYJux/A6WDh7rOfcHfTSVOOD8OtHwpxOG urOaA79C9WNTcKxHEjBjNDHbEAdOjaVIQ3sVLEZdwFjtD2nSSTDU2deWMOr9rdyZRk4d2D/d4 X-Received: by 2002:a05:7300:1486:b0:369:d8e1:7bb6 with SMTP id 5a478bee46e88-38570e24c35mr18256272eec.25.1795495365075; Mon, 23 Nov 2026 20:42:45 -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-38566cd46c5sm49224329eec.11.2026.11.23.20.42.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 23 Nov 2026 20:42:44 -0800 (PST) X-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, vadim.fedorenko@linux.dev X-In-Reply-To: <20261123-timecard-common-v5-d669cfa034-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