Article View: linux.kernel.netdev
Article #23652Re: [PATCH net v6 4/8] ptp: ocp: restore disabled SMA inputs when binding
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 16:48
Date: Fri, 27 Nov 2026 16:48
146 lines
13519 bytes
13519 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 1
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 commit message describes a hardware bug that does not
exist.
- [Medium] The code that disables an SMA input and the new restore code
in ptp_ocp_sma_fb_init() read the hardware state differently for…
- [Low] There are three submission metadata problems.
--
ptp: ocp: restore disabled SMA inputs when binding
This commit adds a loop to ptp_ocp_sma_fb_init(). At probe time the loop
reads each SMA selector through ptp_ocp_sma_fb_get() and sets
bp->sma[i].disabled when SMA_ENABLE is clear. It also forces disabled
pins to SMA_MODE_IN, so they show as "IN: None" after a rebind.
> The SMA disable state is stored in software and is lost when the driver is unbound. The hardware selector may therefore route an input after a rebind even though userspace had disabled it.
>
> Apply the disabled state during SMA initialization so the hardware mux and software state agree after binding. This fix is independent of DPLL reporting.
[Severity: Medium]
Is this description accurate? The disable path already writes the
disabled state into the hardware input selector:
drivers/ptp/ptp_ocp.c:ptp_ocp_sma_store_val() {
...
if (sma->disabled)
val = 0;
if (mode == SMA_MODE_IN)
val = ptp_ocp_sma_set_inputs(bp, sma_nr, val);
...
}
Neither ptp_ocp_detach() nor the probe path writes sma_map1 or
sma_map2. The probe path goes through
ptp_ocp_sma_init()->ptp_ocp_sma_fb_init(). So the cleared input selector
should survive an unbind and rebind. The new loop also only reads
hardware, through ptp_ocp_sma_fb_get(). It updates bp->sma[i].disabled
and bp->sma[i].mode but writes nothing to the mux.
Before the patch, the user-visible problem looks like a reporting one. A
disabled SMA1/SMA2 has its input field cleared, so BIT(15)/BIT(31) of
sma_map1->gpio1 is clear and the pin is detected as an output:
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;
sysfs then reports it as an output. A disabled SMA3/SMA4 is reported as
an input without "None".
On "independent of DPLL reporting": ptp_ocp_dpll_direction_get() takes
the direction from sma->mode:
*direction = sma->mode == SMA_MODE_IN ?
DPLL_PIN_DIRECTION_INPUT :
DPLL_PIN_DIRECTION_OUTPUT;
The patch forces SMA_MODE_IN for disabled pins. After a rebind, the DPLL
netlink direction for a disabled SMA1/SMA2 therefore changes from OUTPUT
to INPUT.
Could the commit message describe the reporting fix and this change to
the DPLL-reported direction instead?
> A coding assistant helped validate the rebind behavior and prepare the source-derived regression test and changelog.
[Severity: Low]
The patch only touches drivers/ptp/ptp_ocp.c, so the regression test
mentioned here isn't included. Can it be posted for reviewers?
This isn't a bug, but the From: name (ahmadexp) doesn't match the
Signed-off-by: name (Ahmad Byagowi), and checkpatch will flag that. The
body paragraphs are also not wrapped at 75 columns.
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 284908c6abc22..aa18c5e5eba45 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -2932,6 +2932,14 @@ ptp_ocp_sma_fb_init(struct ptp_ocp *bp)
> 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;
> +
> + for (i = 0; i < OCP_SMA_NUM; i++) {
> + reg = ptp_ocp_sma_fb_get(bp, i + 1);
> + bp->sma[i].disabled = !(reg & SMA_ENABLE);
[Severity: Medium]
For SMA1/SMA2, can this miss a pin that was disabled while it was
already in input mode?
If the pin is already SMA_MODE_IN, ptp_ocp_sma_store_val() skips the
direction switch, so only the input selector is cleared:
if (mode != sma->mode) {
if (mode == SMA_MODE_IN)
ptp_ocp_sma_set_output(bp, sma_nr, 0);
...
}
...
if (sma->disabled)
val = 0;
On rebind, the SMA1/SMA2 direction comes only from the input-enable bit
in sma_map1->gpio1, so the disabled pin is first classified as
SMA_MODE_OUT. Because of that mode, ptp_ocp_sma_fb_get() then reads the
output register:
else
gpio = sma_nr > 2 ? &bp->sma_map1->gpio2 : &bp->sma_map2->gpio2;
disabled is set only if SMA_ENABLE is also clear in sma_map2->gpio2.
Suppose the output half has SMA_ENABLE set while the pin is in input
mode. Then the "IN: None" setting is not restored, and the pin comes
back as an enabled output, the same as before the patch.
Every direction switch in the driver clears the other half, so this
state would have to come from the firmware power-on defaults for
sma_map2->gpio2. I couldn't verify those defaults. SMA3/SMA4 don't seem
affected, because their direction comes from the output-enable bit.
Should the restore check the input selector for these pins? Or should
the disable path also clear the output half?
> + /* Both buffers disabled: report None. */
> + if (bp->sma[i].disabled)
> + bp->sma[i].mode = SMA_MODE_IN;
> + }
> }
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-timecard-driver-v6-0-ahmadexp%40gmail.com
Technical Details
Message-ID:
<179579808276.3135.5382400825629748441@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372854-linux-kernel-netdev=dewy.ruReferences:
<20261126-timecard-driver-v6-4-ahmadexp@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372854-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v6 4/8] ptp: ocp: restore disabled SMA inputs when binding Date: Fri, 27 Nov 2026 16:48:02 +0000 Organization: Usenet Network Message-ID: <179579808276.3135.5382400825629748441@kernel.org> References: <20261126-timecard-driver-v6-4-ahmadexp@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="775649"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Wuwp3m3AgMc1QFnRgR2HOkwljaY= sha256:UvZpePknHA55A1rR0LZuTHdnuxH22q4gjOevOsTOQ0s= sha1:yuADp2FBL5qe0uhIU0IEMP8xXAw= sha256:E2spvgxvX0i9fj0YEB+UjDHP5uDYRQ6C9UfT303Vj/o= 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 91CD5125F64; Fri, 27 Nov 2026 19:48:25 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 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] 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 9bAPkYUla6gD; Fri, 27 Nov 2026 19:48:22 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-372854-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id A9C37125F60; Fri, 27 Nov 2026 19:48:12 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id ECD012756F; Fri, 27 Nov 2026 16:48:09 +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=1795798085; b=N/rcOivMMgvhJoVZZpSdpahNBoNBt1mZoe3lbf4RCnkxB4pFbruqXYIniwdX4JLhS47r wnSpt+fKtqgmNA4LSOacZo4O4DquOXuDdFFDSZrI9BLTlWSru3rcFjRCJovod4tP6IY8r EM8gTFfS+s8y8djU5IESVfsYSIonXEFX5uvmM0BZt4NQTbr5omFMtwaGpPq1aWr9QblQ3 X89oDC3WKPrS49mvY9QYaPg9yvSCB+HXnbiA3Gtht4xemc57L8Ub6VzrAiAKucj2vW8Up Dawce+7myPf9lMIKgqUUdqhaa2VxajLZs/F/pb249ti3qCsm8+572+rw/+iS8iNzeZA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795798085; 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=Gxrq+wTNFJE4UAmtLE4bDuZwtUUzAFZI+KbF7SkCIZk=; b=Y/MB5kYCi10g4MO3W9jJ/UzDQmaA0XiZH4tZuWDrL/cf+sJ91VgsXbg8G96XsAuPSc1E 2wb6LZ/lHapWPmS7Hahby5MS/cvC6Goa76pwRly19yyi1z9WKF6R4AJHkDZ17U36EwxWX B7557bLQaJqsHUXrf52FvumVj5H6dcs6ufC+udCi1uww5xfLVc592o2tYmZ6OPDv2Uz6l ceH32D3tJtvkbK+IdXLJXT5gdpwpGJAm0lvAFEYGhUUYB8QK/s5nExKrGYFBzOOWB53tO NSUrYUKAlXp69UkmQubs4/EMe+tqvkSCit46yuWTox3n4j1cEz0DKGcNqx8NP5nTM7w== 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=GuHdK9hx; 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 294EB606A68E; Fri, 27 Nov 2026 16:48:05 +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=GuHdK9hx 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=1795798084; b=DOwsSZ/BIxRtdzpiNW5O0oYjLMuKuyfmmCVaXmabmaipZ1I/l8P0CVE23IVpK7EdryDF iMh4GSEhQS9iIeg4fwXfJG3BcnlUZ1GCC/2bGG50dKjPTIS6PyqPuIE36HBjOcNISOtRK h7O1K6jriDSW14L0S1fr2S0Rz/MJpLPEApQjFO9Ayk2s0PMVE3QwnH2fhdNgwV9Zm6hZK LLd00YC+ws9SOpa2OUfeoXNtq9NvjlzUG4N+0rNVnSj96afKSSEE2OvmgXk90tThQbH/G isaRLAlAlp3fXaXOLeVHQkLtPcQOfME4Fue+d7oWDYBfd4oBo1U6qKXnayWc2KEQoOQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795798084; 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=Gxrq+wTNFJE4UAmtLE4bDuZwtUUzAFZI+KbF7SkCIZk=; b=JPPr+NSG6n7JN83QA/Kf8mO5A8mowUurEYJlsGYVs6QrIDztOMDBgo/HktggFbDxwvw1 WSz+sqSmXBK0+AQk0Azk0CU2+cViOGYyj1sorAMitq2p+8/4awqVo2psGLxGcXmKRtpRL LjfB4dE+KhoXQdkVKW0wxpk//0odunoz4fOT+dkZq+ZCsoxmfQmCy+PP6iSRZDVm81/op q8deTAfXIfWdcC3Ga8gqgJR3unO+Rz5aH1kkt4TzSi9CH1Vu/Ck0Yj8iMpJD57sqv5rYN sNwuGJ1y59QKnvyvx24BNlnBBIir0fk0hk2MjVjnYcJoDovupf1iFRoqyytt+/k5J2A== 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=GuHdK9hx; 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 496AF606A32F; Fri, 27 Nov 2026 16:48:04 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F9F41F00897; Fri, 27 Nov 2026 16:48:03 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795798083; bh=Gxrq+wTNFJE4UAmtLE4bDuZwtUUzAFZI+KbF7SkCIZk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=GuHdK9hxhorwyGDf/NWUtSntyUl7kZOsP2iWa42j0SBqsrwGmxXSdTLZhfu2Gr9/e LdNHipNIexo6WqI8BpRwTjf8gNWoFX04wVcK3aPLavtG/kDO3LolnKjxuzQDQkjR4c MBbkCv9n5ElUYGUqE0WnymJSXx6B5H7AYU0WN6qIqIvyY5yepqZjbjmSHm5rXKGDlO v4J1iKitJ9iV803UpK7ebhVMC1rZx8wBRQGFv8pN0IaLFMIRIGzFoCih/Z806swSbt sKVb+QaGc1G0oDAN9OhdT1WgzEsBfoYc9f2gRwlsJBdZSWJbI4dutaF+pWorN4wZiB 7PZN4nxyjasrg== X-Cc: netdev@vger.kernel.org, richardcochran@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, vladimir.oltean@nxp.com, vadim.fedorenko@linux.dev, andrew@lunn.ch, linux-kernel@vger.kernel.org, arkadiusz.kubalewski@intel.com, jiri@resnulli.us, jonathan.lemon@gmail.com X-In-Reply-To: <20261126-timecard-driver-v6-4-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