๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20515

Re: [PATCH net 3/4] ptp: ocp: report disabled SMA inputs consistently over DPLL

#20515
From: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 20:41
140 lines
13753 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The fix decides whether an input is disabled only from the
  software flag sma->disabled.
- [Low] The commit message has a testing/provenance paragraph that does
  not describe this patch.
- [Low] The commit message only describes the 10 MHz case: a disabled
  input reads back as 10 MHz and the DPLL core skips the setter.

--

ptp: ocp: report disabled SMA inputs consistently over DPLL

This patch makes ptp_ocp_dpll_frequency_get() use SMA_DISABLE for SMA
inputs flagged as disabled before it looks up the selector table. Before
this, a disabled input read back as the 10 MHz selector. The DPLL core
then skipped a later 10 MHz request as unchanged.

Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org

> Disabling an SMA input clears its mux field. Zero is also the selector
> for 10 MHz, so a DPLL read reports 10 MHz while sysfs reports None. The
> DPLL core then treats a request to enable 10 MHz as unchanged and skips
> the setter, leaving the input disabled.

[Severity: Low]
This covers the 10 MHz case. Was the old behaviour worse on adva_x1
boards? ptp_ocp_adva_x1_sma_in[] has no entry with value 0x0000:

static const struct ocp_selector ptp_ocp_adva_x1_sma_in[] = {
	{ .name = "PPS1",	.value = 0x0001,      .frequency = 1 },
	...
	{ .name = "None",	.value = SMA_DISABLE, .frequency = 0 },
	{ }
};

So after ptp_ocp_sma_store_val() wrote 0 for a disabled input,
ptp_ocp_dpll_frequency_get() found no match and returned -EINVAL.

dpll_msg_add_pin_freq() passed that error up, so DPLL_CMD_PIN_GET failed
for the pin. dpll_nl_pin_get_dumpit() skips only -ENODEV, so the pin dump
also stopped at that pin. dpll_pin_freq_set() failed with "unable to get
old frequency value", so the input could not be re-enabled over DPLL.

This patch fixes that as well, because SMA_DISABLE matches the x1 "None"
entry. Should the changelog mention this case for stable backporters?

> Reported by the netdev Sashiko AI review and confirmed by code
> inspection. Source-derived C regression tests pass with ASan/UBSan;
> restoring the faulty selector, mask, disabled-state or DCF value makes
> the corresponding regression fail. Tests use stubbed MMIO, not hardware.

[ ... ]

> Codex prepared the fix, tests and changelog from the review and upstream
> source, at the request to separate common-driver fixes from WiWi support
> and validate removal ordering.

[Severity: Low]
Does this paragraph describe this patch? The same text appears word for
word in all four patches of the series. This patch only adds the
sma->disabled check in ptp_ocp_dpll_frequency_get().

The selector and SMA_SELECT_MASK changes are in "ptp: ocp: use hardware
selectors in DPLL frequency operations". The DCF value is in "ptp: ocp:
correct the DCF output frequency". The removal ordering work is in "ptp:
ocp: prevent timestamp rearming during detach".

Could the paragraph be cut down to the testing that applies to this
patch? Someone backporting only this commit could otherwise think it
covers those other defects too.

> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index d449ed8ca2d8a..650047581fd41 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -5920,6 +5920,8 @@ static int ptp_ocp_dpll_frequency_get(const struct dpll_pin *pin,
>  
>  	val = bp->sma_op->get(bp, sma_nr + 1);
>  	val &= SMA_SELECT_MASK;
> +	if (sma->mode == SMA_MODE_IN && sma->disabled)
> +		val = SMA_DISABLE;

[Severity: Medium]
Can this check give the wrong answer after the driver is unbound and
rebound, or after a module reload? sma->disabled exists only in software,
and ptp_ocp_sma_store_val() is the only code that sets it. The FPGA keeps
the mux values that the previous driver instance wrote.

ptp_ocp_sma_fb_init() reads the mux registers only to work out the
direction. It never sets sma->disabled:

	reg = ioread32(&bp->sma_map1->gpio1);
	bp->sma[0].mode = reg & BIT(15) ? SMA_MODE_IN : SMA_MODE_OUT;
	bp->sma[1].mode = reg & BIT(31) ? SMA_MODE_IN : SMA_MODE_OUT;

	reg = ioread32(&bp->sma_map1->gpio2);
	bp->sma[2].mode = reg & BIT(15) ? SMA_MODE_OUT : SMA_MODE_IN;
	bp->sma[3].mode = reg & BIT(31) ? SMA_MODE_OUT : SMA_MODE_IN;

Disabling a direction-changeable input writes 0 to its input field, which
also clears SMA_ENABLE. In this function, val &= SMA_SELECT_MASK drops the
enable bit before sma->disabled is checked.

Take SMA3/SMA4 after a rebind: mode comes back as SMA_MODE_IN and
disabled is false. The input field reads 0, which matches "10Mhz". A
10 MHz request then hits this check in dpll_pin_freq_set():

	if (freq == old_freq)
		return 0;

So it never reaches ptp_ocp_dpll_frequency_set(). Isn't that the case
this patch sets out to fix?

For SMA1/SMA2, BIT(15) or BIT(31) in gpio1 is clear for a disabled input.
The pin therefore comes back as SMA_MODE_OUT, and DPLL reports its output
field instead.

Would it help to set sma->disabled in ptp_ocp_sma_fb_init() from the
enable bits, or to test SMA_ENABLE before masking?

All of this assumes the FPGA treats mux 0 without SMA_ENABLE as disabled
rather than as the 10 MHz selection, which I could not confirm.

>  	tbl = bp->sma_op->tbl[sma->mode];
>  	for (i = 0; tbl[i].name; i++)
>  		if (val == tbl[i].value) {

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118-timecard-common-301f823ddd-0-ahmadexp%40gmail.com
Technical Details
Message-ID: <179538006912.3135.16971430532149423594@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368815-linux-kernel-netdev=dewy.ru
References: <20261118-timecard-common-301f823ddd-3-ahmadexp@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368815-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 3/4] ptp: ocp: report disabled SMA inputs consistently
 over DPLL
Date: Sun, 22 Nov 2026 20:41:09 +0000
Organization: Usenet Network
Message-ID: <179538006912.3135.16971430532149423594@kernel.org>
References: <20261118-timecard-common-301f823ddd-3-ahmadexp@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3719724"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:giPMrT/jT4Z1S/aaVojrACTL3Nc= sha256:lpNstByFJ5v37U7om7xWItvNsyq8hcgI/7SkF4AoYak=
	sha1:59FB2Njeb2yyXKEKx0vq3NDu4yI= sha256:V5fzkmKtDBzEnsSzKKq16BE5SItCK9R7SVjhZzgOV4o=
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 8F5DF125D87; Sun, 22 Nov 2026 23:41:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
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 J_fQgEMgbWIX;
	Sun, 22 Nov 2026 23:41:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368815-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 3C53A125D84; Sun, 22 Nov 2026 23:41:17 +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 70C1D2C6BB; Sun, 22 Nov 2026 20:41:12 +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=1795380071;
	b=UTJfryVnfVdAb3STjXvivVu+e9tP25A3OSciNTiU45ebhboxAU9S3bWpi3OSGi2ngql5
	 ycEyLFmYHMX5+I0h938ZyBGTzGxyNmoAdGmok/26XWPOyxqaX0UnsAoREzzUJTFSYRnMN
	 0uJUZtI95ZX2/y/2efWW0vXFym40i9uqcnRkB/mDY58hm/Zzrkqb1wciiJtoSG71Kws2g
	 XKkS8djPHnRxh90CsY81la9uUqDLnJBrw7HUoz7yCKDAeypoPthfA+JqrMoQsp9ofH6Ky
	 vv1fOvDSJXplG39XYGkwWCApp+2vIJ5p9OAQUAKYjNxZfu9zKIOR4j23oWJwot9LmeQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795380071;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=R8LwHFk/EYoKJPpPeV8B12mFwSu3Wc9W6pgecicIHhc=;
	b=irzr8ZUmPviu5RWVkO0wpoXiWIc+ONJtDPaf5I1Sgk4vOMQhsuD6ypghv31GFNSMyxxL
	 lIuY4MPRMaINGaJF/GEDkxwa253ZNC4DUqe9WUwrsjcIKvYvhvLyoEcPaNWu0qd7XyRHc
	 TkGD9f9l3j145jG3L5lufDxqysiSh6Rgn4NuaiBbMorbtYIgQ4JCHBhPfXNmuSWiosA/Q
	 A/j9HyMKPDYweCUBY5LzSF8FN/Ac8t/k1dUSBQ5Q1Jly7sJ5flaW2leOCvfkZHrGhW2Je
	 Rz8rB08kvmXtk8rI0AE9sYfp8nmfnTj9HENvUKfJVjp4bkR4ULAm+aAJr76vkkwDYeg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=otqNSz1m;
	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 43ADD606A330;
	Sun, 22 Nov 2026 20:41:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=otqNSz1m
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795380070;
	b=S79Q6Qr0+RgpG2QQY7N7YVBDqw9UMf7KIfhEnQZqZXCLv1BGKsYeW1jCfelt7twD7inC
	 FHj1nH28LpO0M+48qSew7o/XzkmlWklrk+4WEUorpaIQbfQgpaPAHWD2nK1uD79TyRMdW
	 5uOqxnK/GfutAzHDuWH1JKxMSkMIayJOZB6rV91lAoKeG8+60nim7yw7YIG2xlf6sUvOK
	 GYQP865HFxHq3OgoYMPaYc4XIdKdEVpZ9eNUiKl6LgzvXSOiqZcxVTKDIXIyQ0au/jllM
	 DE+RmrVTgFoxTt68wenwN0WY9zzbsCp71axRKgGnfdpDi4qQPbltwtUhz6rxVTPI7Ig==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795380070;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=R8LwHFk/EYoKJPpPeV8B12mFwSu3Wc9W6pgecicIHhc=;
	b=09wb2Dm1KNkVB/CyWJ3Caz64sPZCb3pLbQCUstHqUoqJzDlPQZVq/ZzHWSItF/q3N600
	 ATFHje3cdh4lfrQhg0WAWMMcU1rKmKXSik0gd1tdLJukIc9CrzDEBshuEQ329/cGn5kyh
	 JPMeeeW+F4Zf2ylMHfaCIJHWrHOaj2guqxsy4zbLmq8KTkxqSvKFl0IE0QxEsjhIVjq+H
	 JjDjh3U2u6Uu3qPjbESU45Uoj4S7szusn2XgUzSiohK1IwKw6mQWyt5Z/D0SDQpcZ7nvc
	 l3KURVmSPjH7xMCIITFvlJ/OWOwJGQg3t4QXpEGBAbAyrLhWUsXWWySY9bh1WUbSTaw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=otqNSz1m;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6553D606A334;
	Sun, 22 Nov 2026 20:41:10 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8613C1F000CA;
	Sun, 22 Nov 2026 20:41:09 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795380070;
	bh=R8LwHFk/EYoKJPpPeV8B12mFwSu3Wc9W6pgecicIHhc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=otqNSz1m1tGLxeL4v3MSNtb/rziqsVQkgT7J9A7b0SuX2HZn70+E+NftHf+Joou5C
	 v5ZVHgb8CIZnYItrDle4ftvawAaY1YAYtLAfwDxmVZibpSmgVmVFVvhrvvWWtp/tSN
	 MB5KR0Z/fKcdArzLbbOsKjhbML3iZObrjRtS8+m2VRenVDJqakIitnHq4pZu0MTXCu
	 FGVjWR//dUnPBns/Dbou7YDQgfDFyejkanx+A1et+sX3YzaRhp84M5o+y5W1gRt/xf
	 9IS8ti/ehtARPiZ2FuaKY4g6/5Ax9XQ7vgCjFwQzVkspXU0vNogvOMPx4REbZM3Ndp
	 fLCfXByXzDOIw==
X-Cc: netdev@vger.kernel.org, vadim.fedorenko@linux.dev,
 richardcochran@gmail.com, andrew+netdev@lunn.ch,
 arkadiusz.kubalewski@intel.com, davem@davemloft.net, edumazet@kernel.org,
 jiri@resnulli.us, kuba@kernel.org, linux-kernel@vger.kernel.org,
 pabeni@redhat.com
X-In-Reply-To: <20261118-timecard-common-301f823ddd-3-ahmadexp@gmail.com>
X-sashiko-severity: Medium
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