Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Shubhrajyoti Datta" <shubhrajyoti.datta@amd.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH 6/8] clk: clocking-wizard: Add static-config clock provider support
Date: Mon, 15 Jun 2026 04:02:22 +0000	[thread overview]
Message-ID: <20260615040222.6849A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260615034845.3320286-7-shubhrajyoti.datta@amd.com>

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

Pre-existing issues:
- [High] Division by zero in `clk_wzrd_determine_rate` when the requested rate is significantly larger than the parent rate.
- [High] Logic bug with ignored `min_t` return value leads to unbounded register writes.
- [High] Division by zero in `clk_wzrd_get_divisors` and `clk_wzrd_get_divisors_ver` when the target rate is 0.
--

commit b31cd102641055f0a34c6e79498f21e726bb2a91
Author: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>

clk: clocking-wizard: Add static-config clock provider support

When xlnx,static-config is present the divider/multiplier path is
synthesized inside the Wizard without exposing runtime MMIO
reconfiguration, so omit the AXI register mapping and advertise each
routed output clock as a clk_fixed_factor child of clk_in1 using the
synthesized ratios exported through xlnx,clk-mul-div.

> diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> index ffc78c90bee6f..5470a717fccc8 100644
> --- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> +++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c

[ ... ]

This isn't a bug introduced by this patch, but I noticed a potential division
by zero in the unpatched code:

drivers/clk/xilinx/clk-xlnx-clock-wizard.c:clk_wzrd_determine_rate() {
    ...
    div = DIV_ROUND_CLOSEST(req->best_parent_rate, req->rate);

    req->rate = req->best_parent_rate / div;
    ...
}

[Severity: High]
If the requested rate is significantly larger than the best parent rate, 
could div evaluate to 0 and trigger a division by zero exception here?


This is a pre-existing issue, but the capping logic appears to be unused
in the following code:

drivers/clk/xilinx/clk-xlnx-clock-wizard.c:clk_wzrd_dynamic_reconfig() {
    ...
    /* Cap the value to max */
    min_t(u32, value, WZRD_DR_MAX_INT_DIV_VALUE);

    /* Set divisor and clear phase offset */
    writel(value, div_addr);
    ...
}

[Severity: High]
Does this code leave value unbounded before the register write since the
return value of min_t() is not assigned to anything?


This isn't a bug introduced by this patch, but there might be another division
by zero risk in the divisor calculations:

drivers/clk/xilinx/clk-xlnx-clock-wizard.c:clk_wzrd_get_divisors_ver() {
    ...
    o = DIV_ROUND_CLOSEST_ULL(vco_freq, rate);
    ...
}

And similarly in clk_wzrd_get_divisors():

drivers/clk/xilinx/clk-xlnx-clock-wizard.c:clk_wzrd_get_divisors() {
    ...
    o = DIV_ROUND_CLOSEST_ULL(vco_freq, rate);
    ...
}

[Severity: High]
If rate is exactly 0, can this cause a kernel panic due to a division
by zero?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260615034845.3320286-1-shubhrajyoti.datta@amd.com?part=6

  reply	other threads:[~2026-06-15  4:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15  3:48 [PATCH 0/8] clk: clocking-wizard: Add static-config clock provider support Shubhrajyoti Datta
2026-06-15  3:48 ` [PATCH 1/8] dt-bindings: clock: clocking-wizard: Add xlnx,clk-mul-div property Shubhrajyoti Datta
2026-06-15  3:48 ` [PATCH 2/8] dt-bindings: clock: clocking-wizard: Make reg optional for static-config Shubhrajyoti Datta
2026-06-15  3:48 ` [PATCH 3/8] dt-bindings: clock: clocking-wizard: Make s_axi_aclk " Shubhrajyoti Datta
2026-06-15  3:58   ` sashiko-bot
2026-06-15  3:48 ` [PATCH 4/8] clk: clocking-wizard: Do not map the memory " Shubhrajyoti Datta
2026-06-15  3:58   ` sashiko-bot
2026-06-15  3:48 ` [PATCH 5/8] clk: clocking-wizard: Move clk_in1 acquisition before static-config check Shubhrajyoti Datta
2026-06-15  3:48 ` [PATCH 6/8] clk: clocking-wizard: Add static-config clock provider support Shubhrajyoti Datta
2026-06-15  4:02   ` sashiko-bot [this message]
2026-06-15  3:48 ` [PATCH 7/8] clk: clocking-wizard: Skip s_axi_aclk for static-config Shubhrajyoti Datta
2026-06-15  3:58   ` sashiko-bot
2026-06-15  3:48 ` [PATCH 8/8] clk: clocking-wizard: Use dev_err_probe() when mapping registers Shubhrajyoti Datta
2026-06-15  3:54   ` sashiko-bot

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=20260615040222.6849A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shubhrajyoti.datta@amd.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