Re: [PATCH v4 8/8] clk: clocking-wizard: Use separate notifier_block for each clock
From: Brian Masney
Date: Wed Nov 25 2026 - 10:37:22 EST
Hi Shubhrajyoti,
> A struct notifier_block has a single 'next' pointer, so registering the
> same instance to two different notification chains corrupts the linked
> lists. Use a dedicated nb_axi for the s_axi_aclk notifier chain.
>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xxxxxxx>
Same as previous patch. Needs a Fixes and Cc stable.
> ---
> (no changes since v3)
>
> Changes in v3:
> - New patch: split the shared notifier_block into per-clock callbacks
> to avoid corrupting the notifier chains
>
> drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 42 +++++++++++++++++-----
> 1 file changed, 33 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> index 046efa5c77c9..f71e464e0fca 100644
> --- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> +++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> @@ -133,7 +133,8 @@ enum clk_wzrd_int_clks {
> /**
> * struct clk_wzrd - Clock wizard private data structure
> *
> - * @nb: Notifier block
> + * @nb: Notifier block for clk_in1
> + * @nb_axi: Notifier block for s_axi_aclk
> * @base: Memory base
> * @clk_in1: Handle to input clock 'clk_in1'
> * @axi_clk: Handle to input clock 's_axi_aclk'
> @@ -144,6 +145,7 @@ enum clk_wzrd_int_clks {
> */
> struct clk_wzrd {
> struct notifier_block nb;
> + struct notifier_block nb_axi;
> void __iomem *base;
> struct clk *clk_in1;
> struct clk *axi_clk;
> @@ -191,6 +193,7 @@ struct versal_clk_data {
> };
>
> #define to_clk_wzrd(_nb) container_of(_nb, struct clk_wzrd, nb)
> +#define to_clk_wzrd_axi(_nb) container_of(_nb, struct clk_wzrd, nb_axi)
>
> /* maximum frequencies for input/output clocks per speed grade */
> static const unsigned long clk_wzrd_max_freq[] = {
> @@ -1160,6 +1163,30 @@ static struct clk_hw *clk_wzrd_register_divider(struct device *dev,
>
> static int clk_wzrd_clk_notifier(struct notifier_block *nb, unsigned long event,
> void *data)
> +{
> + unsigned long max;
> + struct clk_notifier_data *ndata = data;
> + struct clk_wzrd *clk_wzrd = to_clk_wzrd_axi(nb);
> +
> + if (clk_wzrd->suspended)
> + return NOTIFY_OK;
> +
> + max = WZRD_ACLK_MAX_FREQ;
> +
> + switch (event) {
> + case PRE_RATE_CHANGE:
> + if (ndata->new_rate > max)
> + return NOTIFY_BAD;
> + return NOTIFY_OK;
> + case POST_RATE_CHANGE:
> + case ABORT_RATE_CHANGE:
> + default:
> + return NOTIFY_DONE;
> + }
> +}
> +
> +static int clk_wzrd_clk_notifier_in1(struct notifier_block *nb, unsigned long event,
After this change, clk_wzrd_clk_notifier() and
clk_wzrd_clk_notifier_in1() can be combined with a common helper.
Brian
--
Brian Masney <masneyb@xxxxxxxxxx>