mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Olech, Milena" <milena.olech@intel.com>
To: Ahmad Byagowi <ahmadexp@gmail.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "richardcochran@gmail.com" <richardcochran@gmail.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@kernel.org" <edumazet@kernel.org>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"vladimir.oltean@nxp.com" <vladimir.oltean@nxp.com>,
	"vadim.fedorenko@linux.dev" <vadim.fedorenko@linux.dev>,
	"andrew@lunn.ch" <andrew@lunn.ch>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Kubalewski, Arkadiusz" <arkadiusz.kubalewski@intel.com>,
	"jiri@resnulli.us" <jiri@resnulli.us>,
	"jonathan.lemon@gmail.com" <jonathan.lemon@gmail.com>
Subject: RE: [PATCH net v6 3/8] ptp: ocp: preserve timestamp routes on DPLL frequency changes
Date: Fri, 27 Nov 2026 16:53:04 +0000	[thread overview]
Message-ID: <PH0SPRMB01975FBC031CB35AF5077EB08E412@PH0SPRMB0197.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20261126-timecard-driver-v6-3-ahmadexp@gmail.com>

On 11/26/26 5:43 PM, Ahmad Byagowi wrote:

>
>DPLL frequency changes on a combined SMA input currently replace its complete selector value. This silently removes timestamp or counter destinations configured through the SMA sysfs interface.
>
>When changing an input frequency, retain selector bits for destinations that do not define a frequency. Preserve the existing output path and continue to clear disabled inputs. This keeps the timestamp route while changing the frequency-bearing source.
>
>A coding assistant helped identify the route-loss issue, develop the fix and regression test, and prepare this changelog. The test uses the actual selector and DPLL functions with instrumented register access.
>
>Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
>Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
>---
> drivers/ptp/ptp_ocp.c | 47 ++++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 42 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
>index 625a85b2dc7e..284908c6abc2 100644
>--- a/drivers/ptp/ptp_ocp.c
>+++ b/drivers/ptp/ptp_ocp.c
>@@ -5873,16 +5873,31 @@ static int ptp_ocp_dpll_frequency_set(const struct dpll_pin *pin,
> 	struct ptp_ocp_sma_connector *sma = pin_priv;
> 	struct ptp_ocp *bp = dpll_priv;
> 	const struct ocp_selector *tbl;
>+	u32 val, aux = 0;
> 	int sma_nr = (sma - bp->sma);
>-	int i;
>+	int i, j;
> 
> 	if (sma->fixed_fcn)
> 		return -EOPNOTSUPP;
> 
> 	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);
>+	for (i = 0; tbl[i].name; i++) {
>+		if (tbl[i].frequency != frequency)
>+			continue;
>+
>+		if (sma->mode == SMA_MODE_IN) {
>+			val = bp->sma_op->get(bp, sma_nr + 1) & SMA_SELECT_MASK;
>+			if (sma->disabled)
>+				val = 0;
>+
>+			for (j = 0; tbl[j].name; j++) {
>+				if (!tbl[j].frequency && (val & tbl[j].value))
>+					aux |= tbl[j].value;
>+			}
>+		}
>+		return ptp_ocp_sma_store_val(bp, tbl[i].value | aux,
>+					     sma->mode, sma_nr + 1);

One observation on the tables that these functions rely on:

ptp_ocp_art_sma_in has the entry "10Mhz" with .frequency = 1000000, while
ptp_ocp_sma_freq has 10 MHz. So with these tables frequency_set(10 MHz)
finds no entry and returns -EINVAL, and 1 MHz cannot be requested
through the DPLL. Is 1000000 a typo...?

The old code stored the table index , so this patch also changes the
behavior of the devices that use ocp_art_sma_op. Maybe it's worth
mentioning it in the commit message?

BR,
Milena

>+	}
> 	return -EINVAL;
> }
> 
>@@ -5900,6 +5915,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) {
>@@ -5907,7 +5923,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 = {
>-- 
>2.54.0 (Apple Git-157)

  parent reply	other threads:[~2026-11-27 16:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 16:42 [PATCH net v6 0/8] ptp: fix OCP routes and SJA1105 pin direction Ahmad Byagowi
2026-11-26 16:42 ` [PATCH net v6 1/8] net: dsa: sja1105: keep pin function on EXTTS disable Ahmad Byagowi
2026-11-27 16:47   ` netdev-bot+sashiko
2026-11-26 16:42 ` [PATCH net v6 2/8] net: dsa: sja1105: keep pin function on PEROUT disable Ahmad Byagowi
2026-11-27 16:47   ` netdev-bot+sashiko
2026-11-26 16:42 ` [PATCH net v6 3/8] ptp: ocp: preserve timestamp routes on DPLL frequency changes Ahmad Byagowi
2026-11-27 16:48   ` netdev-bot+sashiko
2026-11-27 16:53   ` Olech, Milena [this message]
2026-11-26 16:42 ` [PATCH net v6 4/8] ptp: ocp: restore disabled SMA inputs when binding Ahmad Byagowi
2026-11-27 16:48   ` netdev-bot+sashiko
2026-11-26 16:42 ` [PATCH net v6 5/8] ptp: ocp: report disabled SMA inputs as zero Hz Ahmad Byagowi
2026-11-27 16:48   ` netdev-bot+sashiko
2026-11-26 16:42 ` [PATCH net v6 6/8] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-27 16:48   ` netdev-bot+sashiko
2026-11-26 16:42 ` [PATCH net v6 7/8] ptp: ocp: match ART DPLL frequencies to selectors Ahmad Byagowi
2026-11-26 16:42 ` [PATCH net v6 8/8] ptp: ocp: defer timestamp shutdown to clock unregister Ahmad Byagowi
2026-11-27 16:48   ` netdev-bot+sashiko

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=PH0SPRMB01975FBC031CB35AF5077EB08E412@PH0SPRMB0197.namprd11.prod.outlook.com \
    --to=milena.olech@intel.com \
    --cc=ahmadexp@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=jonathan.lemon@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=vadim.fedorenko@linux.dev \
    --cc=vladimir.oltean@nxp.com \
    /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

all inboxes | Powered by JetHome®