Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Frieder Schrempf" <frieder@fris.de>
Cc: imx@lists.linux.dev, devicetree@vger.kernel.org, robh@kernel.org,
	conor+dt@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH net-next 4/4] ptp: netc: use 133 MHz system clock on i.MX952
Date: Thu, 19 Nov 2026 10:38:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-222970@kernel.org> (raw)
In-Reply-To: <20261118-imx952-enetc-v1-4-25721440602e@kontron.de>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] ptp: netc: divide-by-zero in
  netc_timer_get_reference_clk_source() [1]
--

commit e475f16482c806a640a726db8d69f83db4761a16
Author: Clark Wang <xiaoning.wang@nxp.com>

ptp: netc: use 133 MHz system clock on i.MX952

This commit sets the default NETC timer reference clock frequency to
133 MHz on i.MX952 (NETC revision 4.6) when no reference clock is specified
in the device tree.

> diff --git a/drivers/ptp/ptp_netc.c b/drivers/ptp/ptp_netc.c
> index 1a327a7561e39..7b9c0a4cbb4c3 100644
> --- a/drivers/ptp/ptp_netc.c
> +++ b/drivers/ptp/ptp_netc.c

[ ... ]

> @@ -858,7 +860,10 @@ static int netc_timer_get_reference_clk_source(struct netc_timer *priv)
>  
>  	/* Select NETC system clock as the reference clock by default */
>  	priv->clk_select = NETC_TMR_SYSTEM_CLK;
> -	priv->clk_freq = NETC_TMR_SYSCLK_333M;
> +	if (priv->revision == NETC_REV_4_6)
> +		priv->clk_freq = NETC_TMR_SYSCLK_133M;
> +	else
> +		priv->clk_freq = NETC_TMR_SYSCLK_333M;
>  
>  	/* Update the clock source of the reference clock if the clock
>  	 * is specified in DT node.

[Severity: High]
This problem wasn't introduced by this patch, but can a reference clock in
the device tree cause a divide-by-zero in
netc_timer_get_reference_clk_source() [1]?

drivers/ptp/ptp_netc.c:netc_timer_get_reference_clk_source() {
    ...
		if (clk) {
			priv->clk_freq = clk_get_rate(clk);
			priv->clk_select = i ? NETC_TMR_EXT_OSC :
					       NETC_TMR_CCM_TIMER1;
			break;
		}
	}
    ...
	priv->period = div_u64((u64)NSEC_PER_SEC << 32, priv->clk_freq);
}

When a DT clock is present, clk_get_rate(clk) overwrites priv->clk_freq
without checking for 0 before dividing by it in div_u64() (and later in
netc_timer_get_gclk_period()).  If an uninitialized or misconfigured clock
provider returns 0 Hz, probe will crash with a divide-by-zero exception.

[1] https://sashiko.dev/#/bug/linux-3717398e-82c6-4e7a-897d-56088b4c53be

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-imx952-enetc-v1-0-25721440602e@kontron.de?part=4

  reply	other threads:[~2026-11-19 10:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 10:37 [PATCH net-next 0/4] net: enetc: Add i.MX952 support Frieder Schrempf
2026-11-18 10:37 ` [PATCH net-next 1/4] dt-bindings: net: nxp,netc-blk-ctrl: add i.MX952 compatible Frieder Schrempf
2026-11-18 17:43   ` Conor Dooley
2026-11-18 10:37 ` [PATCH net-next 2/4] net: enetc: netc_blk_ctrl: add i.MX952 support Frieder Schrempf
2026-11-18 13:51   ` Andrew Lunn
2026-11-18 10:37 ` [PATCH net-next 3/4] net: enetc: add i.MX952 ENETC support Frieder Schrempf
2026-11-19 10:38   ` sashiko-bot
2026-11-18 10:37 ` [PATCH net-next 4/4] ptp: netc: use 133 MHz system clock on i.MX952 Frieder Schrempf
2026-11-19 10:38   ` sashiko-bot [this message]
2026-11-18 10:43 ` [PATCH net-next 0/4] net: enetc: Add i.MX952 support Clark Wang
2026-11-18 10:50   ` Frieder Schrempf

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=sashiko-outbox-222970@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frieder@fris.de \
    --cc=imx@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.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