Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: ahmadexp@gmail.com
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+netdev@lunn.ch, arnd@arndb.de,
	john.stultz@linaro.org, rmk+kernel@armlinux.org.uk
Subject: Re: [PATCH net v6 2/2] ptp: disable unassigned timestamp channels on unregister
Date: Fri, 27 Nov 2026 17:09:38 +0000	[thread overview]
Message-ID: <179579937848.3135.14198689317939903929@kernel.org> (raw)
In-Reply-To: <20261126-timecard-core-v6-2-ahmadexp@gmail.com>

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

Critical: 0 · High: 0 · Medium: 1 · Low: 3

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] ptp_disable_all_events() in drivers/ptp/ptp_chardev.c now
  sends PTP_CLK_REQ_EXTTS with on=0 to every channel below n_ext_ts,…
- [Low] The changelog says a coding assistant helped 'develop the core
  fix and regression tests' and that 'The regression harness exercises…
- [Low] The commit author is 'ahmadexp <ahmadexp@gmail.com>' but the
  Signed-off-by is 'Ahmad Byagowi <ahmadexp@gmail.com>'.
- [Low] ptp: ptp_disable_all_events() triggers spurious dev_err() on
  idt82p33 removal

--

ptp: disable unassigned timestamp channels on unregister

This commit changes ptp_disable_all_events() so it sends a
PTP_CLK_REQ_EXTTS disable request to every channel below n_ext_ts. Before,
the request went only to pins whose function was PTP_PF_EXTTS. The goal is
to shut down EXTTS channels that were enabled through PTP_EXTTS_REQUEST
without a pin assignment once the clock is unregistered.

Link: https://lore.kernel.org/r/179548551283.3135.17206659598806657887@kernel.org

> A coding assistant helped identify the unassigned-channel teardown gap, develop the core fix and regression tests, and prepare this changelog. The regression harness exercises the actual cleanup path with controlled clock callbacks; no physical card was tested.

[Severity: Low]
The changelog mentions regression tests and a regression harness. The patch
only touches drivers/ptp/ptp_chardev.c and contains no selftest, KUnit test
or harness code.

No physical card was tested either, so the only validation described here
can't be inspected or run.

Could the harness be submitted too, for example as a ptp_mock or netdevsim
based selftest? If not, could the wording be changed so it doesn't suggest
the tests are part of this change?

> Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>

[Severity: Low]
This isn't a bug, but the Author line is "ahmadexp <ahmadexp@gmail.com>"
and the Signed-off-by uses "Ahmad Byagowi <ahmadexp@gmail.com>". checkpatch
reports this as a From:/Signed-off-by: name mismatch.

Could the author identity be updated to match the name used in the
sign-off?

> diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
> index f63b45f5ee6ae..5835c01cddb49 100644
> --- a/drivers/ptp/ptp_chardev.c
> +++ b/drivers/ptp/ptp_chardev.c
> @@ -53,11 +53,15 @@ void ptp_disable_all_events(struct ptp_clock *ptp)
>  	unsigned int i;
>  
>  	mutex_lock(&ptp->pincfg_mux);
> -	/* Disable any pins that may raise EXTTS events */
> -	for (i = 0; i < info->n_pins; i++)
> -		if (info->pin_config[i].func == PTP_PF_EXTTS)
> -			ptp_disable_pinfunc(info, info->pin_config[i].func,
> -					    info->pin_config[i].chan);
> +	/* EXTTS requests do not require a pin assignment. */
> +	for (i = 0; i < info->n_ext_ts; i++) {
> +		struct ptp_clock_request req = {
> +			.type = PTP_CLK_REQ_EXTTS,
> +			.extts.index = i,
> +		};
> +
> +		info->enable(info, &req, 0);
> +	}

[Severity: Low]
Does this make every idt82p33 removal print error messages, even when
EXTTS was never used?

idt82p33_caps_init() sets caps->n_ext_ts to MAX_PHC_PLL (2) and leaves
all pins at PTP_PF_NONE. Before this patch, ptp_disable_all_events()
never called idt82p33_enable() for such a clock, because no pin had
func == PTP_PF_EXTTS.

On teardown the driver does:

idt82p33_ptp_clock_unregister_all()
  idt82p33->stopping = true
  idt82p33->extts_mask = 0
  cancel_delayed_work_sync(&idt82p33->extts_work)
  ptp_clock_unregister(channel->ptp_clock)   (for each channel)
    ptp_disable_all_events()
      info->enable(EXTTS index i, on=0)
        idt82p33_enable()

idt82p33_enable() sees idt82p33->stopping, sets err = -ENODEV and jumps
to out, where it logs:

  Failed in idt82p33_enable with err -19!

With two PHC channels and two EXTTS indexes each, that is up to four
dev_err() lines on every unbind, module removal or probe error unwind.

Nothing is actually leaked here, since the driver already clears
extts_mask and cancels extts_work before unregistering, and the core
ignores the return value of info->enable(). But it's a new user-visible
regression that makes a clean removal look like a failure.

The commit message says no clock driver is modified, but this is
another case where calling the EXTTS callback for channels that were
never enabled changes driver behaviour. Would tracking the channels
enabled through PTP_EXTTS_REQUEST in the core, and only disabling those,
avoid this too? Otherwise idt82p33 would need to treat a disable
request while stopping as a no-op.

[Severity: Medium]
Can this reprogram hardware on drivers whose EXTTS callback does work even
when on == 0?

Before this patch, the off request was only sent when pin_config[i].func
was PTP_PF_EXTTS. Now every channel below n_ext_ts gets it, whatever
function its pin has at the time.

The sja1105 driver re-muxes its only PTP_CLK pin before it checks on:

drivers/net/dsa/sja1105/sja1105_ptp.c:sja1105_extts_enable() {
    ...
	rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_EXTTS);
	if (rc)
		return rc;

	priv->ptp_data.extts_enabled = on;
    ...
}

drivers/net/dsa/sja1105/sja1105_ptp.c:sja1105_change_ptp_clk_pin_func() {
    ...
	avb->cas_master = (func == PTP_PF_PEROUT);

	return sja1105_dynamic_config_write(priv, BLK_IDX_AVB_PARAMS, 0, avb,
					    true);
}

Suppose pin 0 (ptp_clk) is set to PTP_PF_PEROUT and PTP_PEROUT_REQUEST is
issued. Then sja1105_per_out_enable() sets avb->cas_master = true. On
unbind, the path is:

sja1105_teardown()
  sja1105_ptp_clock_unregister()
    ptp_clock_unregister()
      ptp_disable_all_events()
        info->enable(EXTTS index 0, on=0)
          sja1105_ptp_enable()
            sja1105_extts_enable()
              sja1105_change_ptp_clk_pin_func(priv, PTP_PF_EXTTS)

This clears cas_master and writes AVB_PARAMS over SPI. That switches the
PTP_CLK pin from output to input while the periodic output is still
programmed: startptpcp was set and stopptpcp was never issued.

pin_config[0].func still reads PTP_PF_PEROUT, so the driver's bookkeeping
no longer matches the hardware. In a cascaded setup, the switch silently
stops driving PTP_CLK.

On SJA1105E/T, the dynamic write fails with -ERANGE because the sja1105et
dyn_ops has no AVB_PARAMS entry. Only the in-memory static config is
changed.

This also conflicts with the changelog. It says pin assignments are kept
unchanged and suggests no clock driver is affected.

The new loop assumes that disabling EXTTS on a channel that was never
enabled leaves the hardware alone. The driver API doesn't promise that.

Would it be safer for the core to track which channels were enabled
through PTP_EXTTS_REQUEST, and send the off request only to those?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-timecard-core-v6-0-ahmadexp%40gmail.com

      reply	other threads:[~2026-11-27 17:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 16:41 [PATCH net v6 0/2] ptp: serialize requests and stop unassigned timestamps Ahmad Byagowi
2026-11-26 16:41 ` [PATCH net v6 1/2] ptp: serialize sysfs enable requests with ioctl paths Ahmad Byagowi
2026-11-27 17:09   ` netdev-bot+sashiko
2026-11-26 16:41 ` [PATCH net v6 2/2] ptp: disable unassigned timestamp channels on unregister Ahmad Byagowi
2026-11-27 17:09   ` netdev-bot+sashiko [this message]

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=179579937848.3135.14198689317939903929@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=ahmadexp@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=john.stultz@linaro.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --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