From: sashiko-bot@kernel.org
To: "Shubhrajyoti Datta" <shubhrajyoti.datta@amd.com>,
linux-clk@vger.kernel.org
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 4/8] clk: clocking-wizard: Add static-config clock provider support
Date: Tue, 24 Nov 2026 04:14:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-230499@kernel.org> (raw)
In-Reply-To: <20261124035613.1968260-5-shubhrajyoti.datta@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] clk: clocking-wizard: unchecked NULL parent in duplicated
fixed-factor ops
--
commit a94e28a314af06a6c676828212ead79533144464
Author: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
clk: clocking-wizard: Add static-config clock provider support
This commit adds support for the xlnx,static-config property by skipping
AXI register mapping and registering each output clock as a fixed-factor
child of clk_in1 with a 10 us enable delay.
> diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> index 649cf2d219437..31fed0e1ed308 100644
> --- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> +++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
[ ... ]
> @@ -926,6 +935,85 @@ static const struct clk_ops clk_wzrd_clk_divider_ops_f = {
> .recalc_rate = clk_wzrd_recalc_ratef,
> };
>
> +static unsigned long
> +clk_wzrd_static_factor_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
> +{
> + struct clk_fixed_factor *fix = to_clk_fixed_factor(hw);
> + unsigned long long rate;
> +
> + rate = (unsigned long long)parent_rate * fix->mult;
> + do_div(rate, fix->div);
> + return (unsigned long)rate;
> +}
> +
> +static int clk_wzrd_static_factor_determine_rate(struct clk_hw *hw,
> + struct clk_rate_request *req)
> +{
> + struct clk_fixed_factor *fix = to_clk_fixed_factor(hw);
> +
> + if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {
> + unsigned long best_parent;
> +
> + best_parent = (req->rate / fix->mult) * fix->div;
> + req->best_parent_rate =
> + clk_hw_round_rate(clk_hw_get_parent(hw), best_parent);
> + }
> +
> + req->rate = (req->best_parent_rate / fix->div) * fix->mult;
> +
> + return 0;
> +}
> +
> +static int clk_wzrd_static_factor_set_rate(struct clk_hw *hw,
> + unsigned long rate,
> + unsigned long parent_rate)
> +{
> + return 0;
> +}
> +
> +static const struct clk_ops clk_wzrd_static_fixed_factor_ops = {
> + .enable = clk_wzrd_enable,
> + .determine_rate = clk_wzrd_static_factor_determine_rate,
> + .set_rate = clk_wzrd_static_factor_set_rate,
> + .recalc_rate = clk_wzrd_static_factor_recalc_rate,
> +};
[Severity: Medium]
Can clk_wzrd_static_factor_determine_rate() pass a NULL parent to
clk_hw_round_rate()?
Every static-config output clock is registered with CLK_SET_RATE_PARENT.
If the upstream clk_in1 provider unregisters its clock (for example during
FPGA reconfiguration or overlay removal), the output clock is orphaned and
clk_hw_get_parent(hw) returns NULL, causing clk_hw_round_rate() to
dereference hw->core on a NULL pointer when rate determination runs.
In addition, clk_wzrd_static_factor_recalc_rate(),
clk_wzrd_static_factor_determine_rate(), and
clk_wzrd_static_factor_set_rate() duplicate the exported
clk_fixed_factor_ops callbacks in drivers/clk/clk-fixed-factor.c (where
clk_factor_determine_rate() checks parent_hw for NULL). Could
clk_wzrd_static_fixed_factor_ops reuse clk_fixed_factor_ops for
.determine_rate, .recalc_rate, and .set_rate?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124035613.1968260-1-shubhrajyoti.datta@amd.com?part=4
next prev parent reply other threads:[~2026-11-24 4:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 3:55 [PATCH v4 0/8] clk: clocking-wizard: Add static-config clock provider support Shubhrajyoti Datta
2026-11-24 3:55 ` [PATCH v4 1/8] dt-bindings: clock: clocking-wizard: Add static-config mode support Shubhrajyoti Datta
2026-11-24 3:55 ` [PATCH v4 2/8] clk: clocking-wizard: Do not map the memory for static-config Shubhrajyoti Datta
2026-11-24 3:55 ` [PATCH v4 3/8] clk: clocking-wizard: Move clk_in1 acquisition before static-config check Shubhrajyoti Datta
2026-11-24 3:55 ` [PATCH v4 4/8] clk: clocking-wizard: Add static-config clock provider support Shubhrajyoti Datta
2026-11-24 4:14 ` sashiko-bot [this message]
2026-11-24 3:55 ` [PATCH v4 5/8] clk: clocking-wizard: Skip s_axi_aclk for static-config Shubhrajyoti Datta
2026-11-24 3:55 ` [PATCH v4 6/8] clk: clocking-wizard: Use dev_err_probe() when mapping registers Shubhrajyoti Datta
2026-11-24 4:03 ` sashiko-bot
2026-11-24 3:55 ` [PATCH v4 7/8] clk: clocking-wizard: Fix division by zero and unbounded register write Shubhrajyoti Datta
2026-11-24 4:18 ` sashiko-bot
2026-11-24 3:55 ` [PATCH v4 8/8] clk: clocking-wizard: Use separate notifier_block for each clock Shubhrajyoti Datta
2026-11-24 4:06 ` 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=sashiko-outbox-230499@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-clk@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