From: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
To: <linux-clk@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <git@amd.com>, <shubhrajyoti.datta@gmail.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Michal Simek <michal.simek@amd.com>,
"Shubhrajyoti Datta" <shubhrajyoti.datta@amd.com>,
<devicetree@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>
Subject: [PATCH v4 8/8] clk: clocking-wizard: Use separate notifier_block for each clock
Date: Tue, 24 Nov 2026 09:25:53 +0530 [thread overview]
Message-ID: <20261124035613.1968260-9-shubhrajyoti.datta@amd.com> (raw)
In-Reply-To: <20261124035613.1968260-1-shubhrajyoti.datta@amd.com>
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@amd.com>
---
(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,
+ void *data)
{
unsigned long max;
struct clk_notifier_data *ndata = data;
@@ -1168,12 +1195,7 @@ static int clk_wzrd_clk_notifier(struct notifier_block *nb, unsigned long event,
if (clk_wzrd->suspended)
return NOTIFY_OK;
- if (ndata->clk == clk_wzrd->clk_in1)
- max = clk_wzrd_max_freq[clk_wzrd->speed_grade - 1];
- else if (ndata->clk == clk_wzrd->axi_clk)
- max = WZRD_ACLK_MAX_FREQ;
- else
- return NOTIFY_DONE; /* should never happen */
+ max = clk_wzrd_max_freq[clk_wzrd->speed_grade - 1];
switch (event) {
case PRE_RATE_CHANGE:
@@ -1446,7 +1468,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
}
if (clk_wzrd->speed_grade) {
- clk_wzrd->nb.notifier_call = clk_wzrd_clk_notifier;
+ clk_wzrd->nb.notifier_call = clk_wzrd_clk_notifier_in1;
ret = devm_clk_notifier_register(&pdev->dev, clk_wzrd->clk_in1,
&clk_wzrd->nb);
@@ -1454,8 +1476,10 @@ static int clk_wzrd_probe(struct platform_device *pdev)
dev_warn(&pdev->dev,
"unable to register clock notifier\n");
+ clk_wzrd->nb_axi.notifier_call = clk_wzrd_clk_notifier;
+
ret = devm_clk_notifier_register(&pdev->dev, clk_wzrd->axi_clk,
- &clk_wzrd->nb);
+ &clk_wzrd->nb_axi);
if (ret)
dev_warn(&pdev->dev,
"unable to register clock notifier\n");
--
2.34.1
prev parent reply other threads:[~2026-11-24 3:56 UTC|newest]
Thread overview: 9+ 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 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 3:55 ` [PATCH v4 7/8] clk: clocking-wizard: Fix division by zero and unbounded register write Shubhrajyoti Datta
2026-11-24 3:55 ` Shubhrajyoti Datta [this message]
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=20261124035613.1968260-9-shubhrajyoti.datta@amd.com \
--to=shubhrajyoti.datta@amd.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=git@amd.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=mturquette@baylibre.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=shubhrajyoti.datta@gmail.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
all inboxes | Powered by JetHome®