From: sashiko-bot@kernel.org
To: "Jian Hu" <jian.hu@amlogic.com>
Cc: linux-clk@vger.kernel.org, linux-amlogic@lists.infradead.org,
devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
neil.armstrong@linaro.org
Subject: Re: [PATCH RFC RFT v3 08/13] clk: meson: g12a: Model the PLL pre-divider as a divider clock
Date: Tue, 01 Dec 2026 09:19:30 +0000 [thread overview]
Message-ID: <sashiko-outbox-242950@kernel.org> (raw)
In-Reply-To: <20261201-meson_refactor_n-v3-8-f85a4460fd80@amlogic.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] clk: meson: g12a: CLK_GET_RATE_NOCACHE on prediv clocks does
not update children
--
commit 1cb730ae65d6d705f933c3659db77a276e9bbf91
Author: Jian Hu <jian.hu@amlogic.com>
clk: meson: g12a: Model the PLL pre-divider as a divider clock
This commit replaces the embedded n pre-divider parameter on G12A/G12B/SM1
PLL DCO clocks with standalone clk_regmap divider clocks wired as parents of
each PLL DCO.
> diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
> index beed610e4a825..09eb842e0b1aa 100644
> --- a/drivers/clk/meson/g12a.c
> +++ b/drivers/clk/meson/g12a.c
[ ... ]
> @@ -609,6 +704,32 @@ static struct clk_regmap g12a_hifi_pll = {
> },
> };
>
> +static struct clk_regmap g12a_pcie_prediv = {
> + .data = &(struct clk_regmap_div_data){
> + .offset = HHI_PCIE_PLL_CNTL0,
> + .shift = 10,
> + .width = 5,
> + .table = g12a_pll_prediv_div_table,
> + .flags = CLK_DIVIDER_INVALID_ZERO,
> + },
> + .hw.init = &(struct clk_init_data){
> + .name = "pcie_prediv",
> + .ops = &clk_regmap_divider_ops,
> + .parent_data = &(const struct clk_parent_data) {
> + .fw_name = "xtal",
> + },
> + .num_parents = 1,
> + /*
> + * The PCIe prediv register reads zero on power-on.
> + * CLK_DIVIDER_INVALID_ZERO makes the first rate return 0 Hz,
> + * which gets cached by CCF. The PCIe PLL enable callback
> + * later writes a valid non-zero divider value. Use
> + * CLK_GET_RATE_NOCACHE to avoid stale cached rate.
> + */
> + .flags = CLK_GET_RATE_NOCACHE,
> + },
> +};
[ ... ]
> @@ -674,10 +790,11 @@ static struct clk_regmap g12a_pcie_pll_dco = {
> .hw.init = &(struct clk_init_data){
> .name = "pcie_pll_dco",
> .ops = &meson_clk_pcie_pll_ops,
> - .parent_data = &(const struct clk_parent_data) {
> - .fw_name = "xtal",
> + .parent_hws = (const struct clk_hw *[]) {
> + &g12a_pcie_prediv.hw
> },
> .num_parents = 1,
> + .flags = CLK_SET_RATE_PARENT,
> },
> };
>
> @@ -729,6 +846,33 @@ static struct clk_fixed_factor g12a_pcie_pll = {
> },
> };
>
> +static struct clk_regmap g12a_hdmi_prediv = {
> + .data = &(struct clk_regmap_div_data){
> + .offset = HHI_HDMI_PLL_CNTL0,
> + .shift = 10,
> + .width = 5,
> + /*
> + * The pre-divider register reads zero until the display driver
> + * programs the HDMI PLL, so a zero divisor is not a fault here:
> + * treat it as a bypass instead of warning at registration.
> + */
> + .flags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
> + },
> + .hw.init = &(struct clk_init_data){
> + .name = "hdmi_prediv",
> + .ops = &clk_regmap_divider_ro_ops,
> + .parent_data = &(const struct clk_parent_data) {
> + .fw_name = "xtal",
> + },
> + .num_parents = 1,
> + /*
> + * Display directly handle hdmi pll registers ATM, we need
> + * NOCACHE to keep our view of the clock as accurate as possible
> + */
> + .flags = CLK_GET_RATE_NOCACHE,
> + },
> +};
[Severity: Medium]
Does setting CLK_GET_RATE_NOCACHE on g12a_pcie_prediv and g12a_hdmi_prediv
actually refresh their rates when clk_get_rate() is called on descendant
clocks such as CLKID_PCIE_PLL or CLKID_HDMI_PLL?
In clk_core_get_rate_recalc(), CCF only invokes __clk_recalc_rates() if
CLK_GET_RATE_NOCACHE is set on the queried clock itself, and
__clk_recalc_rates() walks downward using core->parent->rate from the parent's
cache without walking upward to recalculate ancestors:
drivers/clk/clk.c:clk_core_get_rate_recalc() {
if (core && (core->flags & CLK_GET_RATE_NOCACHE))
__clk_recalc_rates(core, false, 0);
return clk_core_get_rate_nolock(core);
}
For PCIe, HHI_PCIE_PLL_CNTL0 reads 0 at boot, so g12a_pcie_prediv and its
descendants register with a cached rate of 0 Hz. Because meson_clk_pcie_pll_ops
has no .set_rate callback and only writes g12a_pcie_pll_init_regs in .enable
(meson_clk_pcie_pll_enable()), and none of g12a_pcie_pll_dco..g12a_pcie_pll
carry CLK_GET_RATE_NOCACHE, CLKID_PCIE_PLL remains cached at 0 Hz even after
clk_prepare_enable(). At this commit (prior to commit "clk: meson: pll:
Remove the dedicated n parameter" adding parent rate negotiation to
meson_clk_pll_determine_rate()), clk_set_rate(CLKID_PCIE_PLL, 100000000) from
assigned-clock-rates on usb3_pcie_phy also fails with -EINVAL because
req->best_parent_rate is 0.
Similarly, for HDMI, calling clk_get_rate() on g12a_hdmi_pll_dco or
g12a_hdmi_pll after the display driver directly updates HHI_HDMI_PLL_CNTL0
recalculates from g12a_hdmi_prediv's cached rate rather than re-reading the
pre-divider register.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-meson_refactor_n-v3-0-f85a4460fd80@amlogic.com?part=8
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Jian Hu" <jian.hu@amlogic.com>
Cc: linux-clk@vger.kernel.org, linux-amlogic@lists.infradead.org,
devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
neil.armstrong@linaro.org
Subject: Re: [PATCH RFC RFT v3 08/13] clk: meson: g12a: Model the PLL pre-divider as a divider clock
Date: Tue, 01 Dec 2026 09:19:30 +0000 [thread overview]
Message-ID: <sashiko-outbox-242950@kernel.org> (raw)
In-Reply-To: <20261201-meson_refactor_n-v3-8-f85a4460fd80@amlogic.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] clk: meson: g12a: CLK_GET_RATE_NOCACHE on prediv clocks does
not update children
--
commit 1cb730ae65d6d705f933c3659db77a276e9bbf91
Author: Jian Hu <jian.hu@amlogic.com>
clk: meson: g12a: Model the PLL pre-divider as a divider clock
This commit replaces the embedded n pre-divider parameter on G12A/G12B/SM1
PLL DCO clocks with standalone clk_regmap divider clocks wired as parents of
each PLL DCO.
> diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
> index beed610e4a825..09eb842e0b1aa 100644
> --- a/drivers/clk/meson/g12a.c
> +++ b/drivers/clk/meson/g12a.c
[ ... ]
> @@ -609,6 +704,32 @@ static struct clk_regmap g12a_hifi_pll = {
> },
> };
>
> +static struct clk_regmap g12a_pcie_prediv = {
> + .data = &(struct clk_regmap_div_data){
> + .offset = HHI_PCIE_PLL_CNTL0,
> + .shift = 10,
> + .width = 5,
> + .table = g12a_pll_prediv_div_table,
> + .flags = CLK_DIVIDER_INVALID_ZERO,
> + },
> + .hw.init = &(struct clk_init_data){
> + .name = "pcie_prediv",
> + .ops = &clk_regmap_divider_ops,
> + .parent_data = &(const struct clk_parent_data) {
> + .fw_name = "xtal",
> + },
> + .num_parents = 1,
> + /*
> + * The PCIe prediv register reads zero on power-on.
> + * CLK_DIVIDER_INVALID_ZERO makes the first rate return 0 Hz,
> + * which gets cached by CCF. The PCIe PLL enable callback
> + * later writes a valid non-zero divider value. Use
> + * CLK_GET_RATE_NOCACHE to avoid stale cached rate.
> + */
> + .flags = CLK_GET_RATE_NOCACHE,
> + },
> +};
[ ... ]
> @@ -674,10 +790,11 @@ static struct clk_regmap g12a_pcie_pll_dco = {
> .hw.init = &(struct clk_init_data){
> .name = "pcie_pll_dco",
> .ops = &meson_clk_pcie_pll_ops,
> - .parent_data = &(const struct clk_parent_data) {
> - .fw_name = "xtal",
> + .parent_hws = (const struct clk_hw *[]) {
> + &g12a_pcie_prediv.hw
> },
> .num_parents = 1,
> + .flags = CLK_SET_RATE_PARENT,
> },
> };
>
> @@ -729,6 +846,33 @@ static struct clk_fixed_factor g12a_pcie_pll = {
> },
> };
>
> +static struct clk_regmap g12a_hdmi_prediv = {
> + .data = &(struct clk_regmap_div_data){
> + .offset = HHI_HDMI_PLL_CNTL0,
> + .shift = 10,
> + .width = 5,
> + /*
> + * The pre-divider register reads zero until the display driver
> + * programs the HDMI PLL, so a zero divisor is not a fault here:
> + * treat it as a bypass instead of warning at registration.
> + */
> + .flags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
> + },
> + .hw.init = &(struct clk_init_data){
> + .name = "hdmi_prediv",
> + .ops = &clk_regmap_divider_ro_ops,
> + .parent_data = &(const struct clk_parent_data) {
> + .fw_name = "xtal",
> + },
> + .num_parents = 1,
> + /*
> + * Display directly handle hdmi pll registers ATM, we need
> + * NOCACHE to keep our view of the clock as accurate as possible
> + */
> + .flags = CLK_GET_RATE_NOCACHE,
> + },
> +};
[Severity: Medium]
Does setting CLK_GET_RATE_NOCACHE on g12a_pcie_prediv and g12a_hdmi_prediv
actually refresh their rates when clk_get_rate() is called on descendant
clocks such as CLKID_PCIE_PLL or CLKID_HDMI_PLL?
In clk_core_get_rate_recalc(), CCF only invokes __clk_recalc_rates() if
CLK_GET_RATE_NOCACHE is set on the queried clock itself, and
__clk_recalc_rates() walks downward using core->parent->rate from the parent's
cache without walking upward to recalculate ancestors:
drivers/clk/clk.c:clk_core_get_rate_recalc() {
if (core && (core->flags & CLK_GET_RATE_NOCACHE))
__clk_recalc_rates(core, false, 0);
return clk_core_get_rate_nolock(core);
}
For PCIe, HHI_PCIE_PLL_CNTL0 reads 0 at boot, so g12a_pcie_prediv and its
descendants register with a cached rate of 0 Hz. Because meson_clk_pcie_pll_ops
has no .set_rate callback and only writes g12a_pcie_pll_init_regs in .enable
(meson_clk_pcie_pll_enable()), and none of g12a_pcie_pll_dco..g12a_pcie_pll
carry CLK_GET_RATE_NOCACHE, CLKID_PCIE_PLL remains cached at 0 Hz even after
clk_prepare_enable(). At this commit (prior to commit "clk: meson: pll:
Remove the dedicated n parameter" adding parent rate negotiation to
meson_clk_pll_determine_rate()), clk_set_rate(CLKID_PCIE_PLL, 100000000) from
assigned-clock-rates on usb3_pcie_phy also fails with -EINVAL because
req->best_parent_rate is 0.
Similarly, for HDMI, calling clk_get_rate() on g12a_hdmi_pll_dco or
g12a_hdmi_pll after the display driver directly updates HHI_HDMI_PLL_CNTL0
recalculates from g12a_hdmi_prediv's cached rate rather than re-reading the
pre-divider register.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-meson_refactor_n-v3-0-f85a4460fd80@amlogic.com?part=8
next prev parent reply other threads:[~2026-12-01 9:19 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 8:56 [PATCH RFC RFT v3 00/13] clk: meson: Refactor PLL pre-divider as a divider clock Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 01/13] clk: divider: Add CLK_DIVIDER_INVALID_ZERO flag Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 9:10 ` sashiko-bot
2026-12-01 9:10 ` sashiko-bot
2026-12-01 8:56 ` [PATCH RFC RFT v3 02/13] clk: meson: clk-regmap: Widen the divider flags to 16 bits Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 03/13] dt-bindings: clock: amlogic: Add PLL pre-divider clock IDs Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 04/13] clk: meson: axg: Model the PLL pre-divider as a divider clock Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 9:11 ` sashiko-bot
2026-12-01 9:11 ` sashiko-bot
2026-12-01 8:56 ` [PATCH RFC RFT v3 05/13] clk: meson: a1: " Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 06/13] clk: meson: c3: " Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 07/13] clk: meson: gxbb: " Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 9:16 ` sashiko-bot
2026-12-01 9:16 ` sashiko-bot
2026-12-01 8:56 ` [PATCH RFC RFT v3 08/13] clk: meson: g12a: " Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 9:19 ` sashiko-bot [this message]
2026-12-01 9:19 ` sashiko-bot
2026-12-01 8:56 ` [PATCH RFC RFT v3 09/13] clk: meson: meson8: " Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 10/13] clk: meson: s4: " Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 11/13] clk: meson: s7: " Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 11:37 ` Carlo Caione
2026-12-01 11:37 ` Carlo Caione
2026-12-01 8:56 ` [PATCH RFC RFT v3 12/13] clk: meson: t7: " Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` [PATCH RFC RFT v3 13/13] clk: meson: pll: Remove the dedicated n parameter Jian Hu
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 8:56 ` Jian Hu via B4 Relay
2026-12-01 9:28 ` sashiko-bot
2026-12-01 9:28 ` sashiko-bot
2026-12-01 13:16 ` Carlo Caione
2026-12-01 13:16 ` Carlo Caione
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-242950@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jian.hu@amlogic.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--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.