Netdev List
 help / color / mirror / Atom feed
From: Ahmad Byagowi <ahmadexp@gmail.com>
To: netdev@vger.kernel.org
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
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	[thread overview]
Message-ID: <20261123-timecard-common-v5-d669cfa034-5-ahmadexp@gmail.com> (raw)
In-Reply-To: <20261123-timecard-common-v5-d669cfa034-0-ahmadexp@gmail.com>

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;
+		}
 	}
 }
 

  parent reply	other threads:[~2026-11-24  4:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
2026-11-24  4:42 ` [PATCH net v5 1/8] ptp: serialize sysfs requests with the ioctl paths Ahmad Byagowi
2026-11-24  4:42 ` [PATCH net v5 2/8] net: dsa: sja1105: leave the pin function unchanged on EXTTS disable Ahmad Byagowi
2026-11-24  4:42 ` [PATCH net v5 3/8] ptp: disable all timestamp channels after removing the user interfaces Ahmad Byagowi
2026-11-24  4:42 ` [PATCH net v5 4/8] ptp: ocp: handle hardware selectors and combined DPLL input routes Ahmad Byagowi
2026-11-24  4:42 ` Ahmad Byagowi [this message]
2026-11-24  4:42 ` [PATCH net v5 6/8] ptp: ocp: report zero frequency for disabled SMA inputs Ahmad Byagowi
2026-11-24  4:42 ` [PATCH net v5 7/8] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-24  4:42 ` [PATCH net v5 8/8] ptp: ocp: correct the ART 10 MHz input frequency Ahmad Byagowi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123-timecard-common-v5-d669cfa034-5-ahmadexp@gmail.com \
    --to=ahmadexp@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=john.stultz@linaro.org \
    --cc=jonathan.lemon@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=vadim.fedorenko@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox