All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Luo Jie" <jie.luo@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH 05/12] clk: qcom: ipq-cmn-pll: Add PPE clock support
Date: Fri, 24 Jul 2026 15:19:28 +0000	[thread overview]
Message-ID: <20260724151928.CFC1A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724-qcom_ipq5210_cmnpll-v1-5-a8b8679d215f@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Using DIV_ROUND_CLOSEST_ULL() with a 64-bit divisor causes a divide-by-zero kernel panic due to 32-bit truncation.
--

--- Patch [5]: [PATCH 05/12] clk: qcom: ipq-cmn-pll: Add PPE clock support ---
commit aed5f1938300824fb26726205b9e4ce2ebf415fa
Author: Luo Jie <jie.luo@oss.qualcomm.com>

clk: qcom: ipq-cmn-pll: Add PPE clock support

This commit adds support for the PPE (packet process engine) clock,
which is derived from the CMN PLL output. It uses a configurable 6-bit
divider and shares a frequency control register with the NSS clock.

> diff --git a/drivers/clk/qcom/ipq-cmn-pll.c b/drivers/clk/qcom/ipq-cmn-pll.c
> index 3df326c22fbac..020ad12ca1f2b 100644
> --- a/drivers/clk/qcom/ipq-cmn-pll.c
> +++ b/drivers/clk/qcom/ipq-cmn-pll.c

[ ... ]

> @@ -462,6 +463,83 @@ static struct clk_hw *ipq_cmn_pll_nss_register(struct platform_device *pdev,
>  	return &nss_clk->hw;
>  }
>  
> +/*
> + * PPE (Packet Process Engine) clock operations.
> + * The PPE clock is derived from CMN PLL rate / 2, then divided by
> + * a configurable 6-bit divider (8-63).
> + */

[ ... ]

> +static int clk_ppe_set_rate(struct clk_hw *hw, unsigned long rate,
> +			    unsigned long parent_rate)
> +{
> +	struct clk_cmn_pll *ppe_clk = to_clk_cmn_pll(hw);
> +	unsigned long div;
> +	int ret;
> +
> +	if (rate == 0)
> +		return -EINVAL;
> +
> +	div = DIV_ROUND_CLOSEST_ULL((u64)parent_rate, 2ULL * rate);

[Severity: High]
Does this code overflow the 32-bit divisor limit of DIV_ROUND_CLOSEST_ULL?

DIV_ROUND_CLOSEST_ULL relies on the kernel do_div() macro, which strictly
truncates the divisor to 32 bits on all architectures. If a caller requests
a large rate (e.g. 2,147,483,648 Hz), 2ULL * rate will have its lower 32
bits as 0. Could this regression cause the divisor to truncate to 0 and
trigger a direct divide-by-zero kernel panic?

> +	if (div < CMN_PLL_NSS_PPE_DIV_MIN || div > CMN_PLL_NSS_PPE_DIV_MAX)
> +		return -EINVAL;
> +

[ ... ]

> +static const struct clk_ops clk_ppe_ops = {
> +	.recalc_rate = clk_ppe_recalc_rate,
> +	.determine_rate = clk_nss_ppe_determine_rate,
> +	.set_rate = clk_ppe_set_rate,
> +};

While clk_ppe_set_rate might be protected if the clock framework previously
clamps the rate via determine_rate, this patch also points to the shared
clk_nss_ppe_determine_rate. 

Can unconstrained rates passed into clk_nss_ppe_determine_rate from the
clock framework (such as via debugfs or a malformed device tree) cause a
similar truncation and kernel panic during rate calculation?

> +static struct clk_hw *ipq_cmn_pll_ppe_register(struct platform_device *pdev,
> +					       struct regmap *regmap,
> +					       struct clk_hw *cmn_pll_hw)
> +{

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260724-qcom_ipq5210_cmnpll-v1-0-a8b8679d215f@oss.qualcomm.com?part=5

  reply	other threads:[~2026-07-24 15:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 15:00 [PATCH 00/12] clk: qcom: ipq-cmn-pll: Add IPQ5210 CMN PLL support Luo Jie
2026-07-24 15:00 ` [PATCH 01/12] clk: qcom: ipq-cmn-pll: Use devm_clk_hw_register_fixed_rate_parent_data Luo Jie
2026-07-24 15:50   ` Konrad Dybcio
2026-07-24 15:00 ` [PATCH 02/12] dt-bindings: clock: qcom: Add CMN PLL support for IPQ5210 SoC Luo Jie
2026-07-24 15:00 ` [PATCH 03/12] clk: qcom: ipq-cmn-pll: Add analog soft-reset helper Luo Jie
2026-07-24 15:00 ` [PATCH 04/12] clk: qcom: ipq-cmn-pll: Add NSS clock support Luo Jie
2026-07-24 15:15   ` sashiko-bot
2026-07-24 15:00 ` [PATCH 05/12] clk: qcom: ipq-cmn-pll: Add PPE " Luo Jie
2026-07-24 15:19   ` sashiko-bot [this message]
2026-07-24 15:00 ` [PATCH 06/12] clk: qcom: ipq-cmn-pll: Add PON reference " Luo Jie
2026-07-24 15:11   ` sashiko-bot
2026-07-24 15:00 ` [PATCH 07/12] clk: qcom: ipq-cmn-pll: Add EPHY-RAW " Luo Jie
2026-07-24 15:00 ` [PATCH 08/12] clk: composite: Export devm_clk_hw_register_composite_pdata Luo Jie
2026-07-24 16:01   ` Brian Masney
2026-07-24 15:00 ` [PATCH 09/12] clk: qcom: ipq-cmn-pll: Add clock gate support for fixed clocks Luo Jie
2026-07-24 15:00 ` [PATCH 10/12] clk: qcom: ipq-cmn-pll: Add all output clocks for IPQ5210 Luo Jie
2026-07-24 15:00 ` [PATCH 11/12] arm64: dts: qcom: ipq5210: Add CMN PLL device node Luo Jie
2026-07-24 15:00 ` [PATCH 12/12] arm64: dts: qcom: Update IPQ5210 xo_board to use fixed factor clock Luo Jie

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=20260724151928.CFC1A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jie.luo@oss.qualcomm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.