mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: ahmadexp@gmail.com
Cc: netdev@vger.kernel.org, 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: Re: [PATCH net v5 4/8] ptp: ocp: handle hardware selectors and combined DPLL input routes
Date: Wed, 25 Nov 2026 04:44:46 +0000	[thread overview]
Message-ID: <179558188666.3135.18134824042622584333@kernel.org> (raw)
In-Reply-To: <20261123-timecard-common-v5-d669cfa034-4-ahmadexp@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · 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] Because of this patch, ptp_ocp_dpll_frequency_get() now
  succeeds for input selectors that feed several destinations.
- [Low] The commit message understates the impact of the SMA_SELECT_MASK
  change in ptp_ocp_dpll_frequency_get() (drivers/ptp/ptp_ocp.c).

--

ptp: ocp: handle hardware selectors and combined DPLL input routes

This commit changes ptp_ocp_dpll_frequency_set() to pass the selector
table value to ptp_ocp_sma_store_val() instead of the table index. It
also masks the direction enable bit in ptp_ocp_dpll_frequency_get().
For input selectors that feed several destinations, frequency_get now
returns a frequency, or zero, instead of -EINVAL.

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

> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index b16d36c3305f9..df1a428eb2fed 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c

[ ... ]

> @@ -5887,6 +5888,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;

[Severity: Low]

The commit message mentions this mask only briefly:

  "and mask the direction enable bit before looking up the frequency."

It then gives the combined-input case (selector 0x000c) as the reason
the get-before-set step and the pin dump fail. Is that the whole impact?

ptp_ocp_sma_fb_get() returns the full 16-bit half-register:

	return (ioread32(gpio) >> shift) & 0xffff;

ptp_ocp_sma_store_val() always adds the enable bit when the direction
is not fixed:

	if (!sma->fixed_dir)
		val |= SMA_ENABLE;		/* add enable bit */

ptp_ocp_sma_fb_init() also uses BIT(15) to work out each pin's
direction, so that bit is normally set for the active direction.

Every table value is below BIT(15). Before this patch, wouldn't a
readback such as 0x8001 for PPS1 never match a table entry? That would
make frequency_get return -EINVAL for every SMA pin on FB, ADVA and
ADVA-X1 boards whose direction can change, not only for combined
routes.

If so, DPLL pin-get/dump failed for those pins. dpll_pin_freq_set()
also stopped at "unable to get old frequency value", so frequency
changes never ran either.

Could the commit message state this more directly, since it affects
stable backport priority?

>  	tbl = bp->sma_op->tbl[sma->mode];
>  	for (i = 0; tbl[i].name; i++)
>  		if (val == tbl[i].value) {
> @@ -5894,7 +5896,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;

[Severity: Medium]

With this change, ptp_ocp_dpll_frequency_get() succeeds for input
selectors that feed several destinations. For example, PPS1|TS1
(0x0005) reports 1 Hz and TS1|TS2 (0x000c) reports 0 Hz.

These selectors used to return -EINVAL, so dpll_pin_freq_set() stopped
before reaching frequency_set:

drivers/dpll/dpll_netlink.c:dpll_pin_freq_set() {
    ...
	ret = ops->frequency_get(pin, ..., &old_freq, extack);
	if (ret) {
		NL_SET_ERR_MSG(extack, "unable to get old frequency value");
		return ret;
	}
	if (freq == old_freq)
		return 0;

	ret = ops->frequency_set(...);
    ...
}

Now the set runs. ptp_ocp_dpll_frequency_set() takes the first table
entry with the requested frequency and stores only that value:

			return ptp_ocp_sma_store_val(bp, tbl[i].value,
						     sma->mode, sma_nr + 1);

ptp_ocp_sma_fb_set_inputs() and ptp_ocp_sma_adva_set_inputs() then
replace the pin's whole 16-bit selector half:

	reg = (reg & mask) | (val << shift);

Does this silently drop TS1..TS4 or FREQ1..FREQ4 routes that were set
up through sysfs?

For example, after "IN: PPS1 TS1" is written to the smaN attribute, a
DPLL pin-set to 10 MHz would store 0x0000. That removes the TS1 route,
so EXTTS timestamping on that input stops and no error is reported.

The get path treats timestamp and counter destinations as not
constraining the frequency, but the set path throws them away. Should
ptp_ocp_dpll_frequency_set() keep the destination bits that carry no
frequency, or reject the change when the input has a combined route?

>  }
>  
>  static const struct dpll_device_ops dpll_ops = {

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123-timecard-common-v5-d669cfa034-0-ahmadexp%40gmail.com

  reply	other threads:[~2026-11-25  4:44 UTC|newest]

Thread overview: 12+ 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-25  4:44   ` netdev-bot+sashiko
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-25  4:44   ` netdev-bot+sashiko [this message]
2026-11-24  4:42 ` [PATCH net v5 5/8] ptp: ocp: recover disabled SMA inputs when binding the driver Ahmad Byagowi
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
2026-11-25  4:44   ` 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=179558188666.3135.18134824042622584333@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=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

all inboxes | Powered by JetHome®