🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21514

[PATCH net v5 5/8] ptp: ocp: recover disabled SMA inputs when binding the driver

#21514
From: Ahmad Byagowi
Date: Tue, 24 Nov 2026 04:42
63 lines
13852 bytes
Disabling an SMA input clears its mux field and sets the software-only
disabled flag. After unbind and rebind, the hardware retains the cleared
field but the newly allocated driver state loses the flag. Direction
initialization can then report an output function for a connector with
neither buffer enabled. This happens independently of DPLL support.

Recover the disabled state from the mux enable bits when initializing
direction-configurable FB-style connectors, including ADVA and ADVA X1.
The existing direction selection picks an enabled side if either side
is enabled. If the selected side is also disabled, neither buffer is
enabled: represent this as an input with the None function. The mux does
not preserve a direction for that disconnected state.

Do not write the mux or change fixed-direction firmware's interpretation,
since it does not provide these enable bits. Keep this initialization
fix separate from the DPLL frequency-reporting correction so it can be
backported to kernels predating DPLL support.

Source-derived tests reproduce the lost state with retained mux values
and fresh driver state. The corrected initialization passes 243 modeled
FB/ADVA/X1 rebind states with stubbed MMIO under ASan/UBSan, without mux
writes. No physical rebind was performed.

The issue and missing earlier Fixes tag were reported by Sashiko review.
Codex assisted with the tests, correction and changelog.

Fixes: b2c4f0ac53f3 ("ptp: ocp: Add ability to disable input selectors.")
Link: https://lore.kernel.org/r/179538006912.3135.16971430532149423594@kernel.org
Link: https://lore.kernel.org/r/179548551472.3135.11972018356692852897@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v5:
 - Split initialization from v4 patch 3's DPLL frequency substitution.
 - Use b2c4f0ac53f3 as the earlier Fixes tag for the lost rebind state.
 - Describe the DPLL-independent behavior and backport scope.

Testing: this patch alone applies to the net base and passes 243 modeled
initialization states, without DPLL calls or mux writes. The unmodified
base reproduces the lost state. Older trees may need context adjustments.

 drivers/ptp/ptp_ocp.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index df1a428eb2fe..c4c9d3501edf 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);
+			/* Both buffers disabled: report None. */
+			if (bp->sma[i].disabled)
+				bp->sma[i].mode = SMA_MODE_IN;
+		}
 	}
 }
 
Technical Details
Message-ID: <20261123-timecard-common-v5-d669cfa034-5-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-370004-linux-kernel-netdev=dewy.ru
References: <20261123-timecard-common-v5-d669cfa034-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-370004-linux-kernel-netdev=dewy.ru
From: ahmadexp@gmail.com (Ahmad Byagowi)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v5 5/8] ptp: ocp: recover disabled SMA inputs when binding the driver
Date: Mon, 23 Nov 2026 20:42:45 -0800
Organization: Usenet Network
Message-ID: <20261123-timecard-common-v5-d669cfa034-5-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="4052852"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:mrp3KIz2KhoWXuFeNfaZNcWWOw0= sha256:Yw2Gnv4I6musgd4g4vBbP1DLNdPLD3va8lS1OkEg+G0=
	sha1:mWvMMwcW52fjDYmd+q+eOMMYwhM= sha256:f7H5GG2PjVSrzFlBs8vq6+YIuQLCVmF9rlFS2YAwdwE=
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 850DB125DCF; Tue, 24 Nov 2026 07:43:20 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
	tests=[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 nk1AQ1Zh1w3B;
	Tue, 24 Nov 2026 07:43:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-370004-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 7D297125DC7; Tue, 24 Nov 2026 07:43:08 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 04EFB6056CA; Tue, 24 Nov 2026 04:43:08 +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=1795495369;
	b=HaiZQZ+s3dF5v6dtPQFzVnwiyLPu1cH4xsdq7nT4SO4GNX937DV43MIsRSKTVGetzVri
	 r8r16IbhG1Zb90Po8fBnBDkO1UhF53Rpyp4X+lVa2BRQuGCMLlNKMMvjm6g9aoKqZbBzg
	 t0/xr1i9+cBj+eGJaPGRVKKZHjLqAXeaQOl+D3hrphhPNb8pYMjSCunH96JELgwFaVJZX
	 GQUuPc9y4vG6Vt44EidCfIp295ABG9C8D/gKtQ6+N8XF7Uk1b3rNv07uUtkf1ryQtm1be
	 BR4CMsVnm3l0Pt/aKi7K1se1LhLl/rOMg3GfHJR9Tb9syfbIWtQpOOX/JiqXevMC1wA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795495369;
	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=h8MKC8Lxgq/9MW67tGoN5njDnP7Mi9uawf/28NfiV+Q=;
	b=jqoUo1BzrzvmEu+7Cq5/TE09DAl6uD30YNAAo4lqQZzB2+7HS+uGy7HsMipI+7N7f4Fm
	 yOL7RqnZiY+tfD8XFV11y6liqgi0A5OWAZwGiJ1FJAgrrs6PLPaooDKKvXvZB2go6G10t
	 7YWL9eYSzWCQJ/eT0IVt8u+BTy7I0d06VEutsdXkDC5sekr88JvpIQptExVbjA1lZNuVn
	 y6ItlDIMmLi1d5tZYNjvFKz33BzL1Pt/yy5HVrLJXoxEeeukCwuNL0sxQqIF7em58LfjP
	 gFH3AzVktwt8ivmoLA8mxcTzAjq7VSSN1YrGkrp5cWTfQqRzW9Ps1L7ZlmnFx5GznlA==
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=kypXJeUH;
	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 81B0F60A262A;
	Tue, 24 Nov 2026 04:42:49 +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=kypXJeUH
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.46
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795495368;
	b=IpdIgbMucva3K2f6AtC2aJKsgOxd/DLVvL4UCBxUgKW+vqZ3/PVRSRCaWI8IGm13hLn7
	 QliIrkJa5IEXMYgLobvlUbaaJFpUgX/RiTZjza8YQmBpac8ZYMtDOjwdN+RX0IppTg/I4
	 acbiEe2KyVEu0mRirrcwuv/yepoIpl2Iiyz/+wLGnIl9VOeKB31XscJ94WdASzE4e7IiP
	 CPFf4hmwfvJwRatoQCRiS7YeQ4CMtmKWRDK9gYaEy2lqytN0xNDIeGYi1/s5JyLOu2ja/
	 BdLP3J0Ql/zvMgy/yMC8C/dD8K6+NBltXSckdgliNsfmhescvdt7R7SR+z6wR6YVQwA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795495368;
	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=h8MKC8Lxgq/9MW67tGoN5njDnP7Mi9uawf/28NfiV+Q=;
	b=YaUgj0OJ5g5+M68vNwGDt3292gIVjVi3fdzcJfu68bY2hMd/qT8Fyg0rCzfHDYMVAUEC
	 Jeu98tyGNqNDi8nhFAD18HZbBrYmYlpAhE5QOk7IhSU8RH1xOLGH6Ymhw1BRNJBNc21d7
	 qocIKym/5hM6rQ5w8hkSMsHYG3o+L65NUS4H5adheJqJZ8PYVhaPCqllih0a25DTqGRmH
	 60oA2SdGRAKzmMDG6kxs6E323rXHmoi2c9uzGt0gVElTX1+mvGHzHEMc9+OIYk3J1NUR0
	 DgUk5KuDEg1GExkxitErdmBWyvLWj8q3gmzNF7X1MOjPuGSuGJCpS0DAVHGmLQUMPAA==
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=kypXJeUH;
	arc=none smtp.remote-ip=74.125.82.46
X-Received: from mail-dl1-f46.google.com (mail-dl1-f46.google.com [74.125.82.46])
	(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 5BF3360A260B
	for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 04:42:48 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5BF3360A260B
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-f46.google.com with SMTP id a92af1059eb24-1a2761c69fbso3562669c88.0
        for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 20:42:48 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1795495367; x=1796100167; 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=h8MKC8Lxgq/9MW67tGoN5njDnP7Mi9uawf/28NfiV+Q=;
        b=kypXJeUH1IswXcwnOpxZ5nFz/QhCTLna/YbDFxvbtQa6TMQFBuYd+WllGHDHEvOWi8
         ddK7p6tc67DsR5MSOvfFaHMYguRs7gfHp0zTGkCgGE+cepWrYHRMj9jPKdH9aOoUUkjo
         fxDJHTnglOroCLgM4u5F8zguOZGqjxg7h2FBaUJ97CQQL0s7oqZ6bMl4hkHcd2lEZH4/
         x8q+SGQnqk8+oAJ2ZA7hcEFJ/jpewlYqaLOsOVGaWOI9Lt7mHz49ONjDVUvQF7rOjXU6
         VhC+VGSWsNnAqy/vcA3+tT0r4s1m1beYp3WufCJp64VKbENaoVqHp42WggC4gDmR4P3s
         6M2w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795495367; x=1796100167;
        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=h8MKC8Lxgq/9MW67tGoN5njDnP7Mi9uawf/28NfiV+Q=;
        b=fK9bmNyU7BoRU8w9EuzfrcIFarIOHfRo4DwuGGCGf1SCuo35lrLtUq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8niEhdpNy9iR7nPKM84eYVF52n1xO/DtqrWrg+lSVzxpoaPK2HNe5qEAWvO+
	lFhvwETUVlgFY9tHNlwTFnV4p8qrK3jdHRi+FGFAlS2nTk+BzDkfIS4ub4+gZ/kMWsOwO86Ec
X-Received: by 2002:a05:7022:285:20b0:1b5:75d1:3c98 with SMTP id a92af1059eb24-1b575d13eeemr4181161c88.8.1795495367344;
        Mon, 23 Nov 2026 20:42:47 -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 a92af1059eb24-1b55682d301sm32217346c88.10.2026.11.23.20.42.46
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Mon, 23 Nov 2026 20:42:46 -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