From: Yixun Lan <dlan@kernel.org>
To: Junhui Liu <junhui.liu@pigmoral.tech>
Cc: u-boot@lists.u-boot-project.org,
Lukasz Majewski <lukma@nabladev.com>,
Tom Rini <trini@konsulko.com>, Anand Moon <linux.amoon@gmail.com>
Subject: Re: [PATCH] clk: spacemit: k1: Use generic CCF enable/disable callbacks
Date: Tue, 24 Nov 2026 10:36:32 +0000 [thread overview]
Message-ID: <20261124103632-GKA245721@kernel.org> (raw)
In-Reply-To: <20261124-k1-clk-fix-v1-1-fca6382fdf48@pigmoral.tech>
Hi Junhui,
On 15:38 Tue 24 Nov , Junhui Liu wrote:
> The custom enable/disable callbacks look up the requested clock in the
> provider's clock table, handle its parent and call the gate operations
> directly. If the ID is not found, they still use the caller's struct clk
> as a hardware clock. The gate operations then interpret it as part of a
> struct ccu_mix and access invalid register mapping data, which can cause
> a load access fault.
>
> These callbacks provide no K1-specific sequencing. CCF already handles
> clock lookup, parents and reference counts, and dispatches hardware
> operations through the registered clock's callbacks.
>
> Use ccf_clk_enable() and ccf_clk_disable() to look up the registered
> clock by ID and delegate to clk_enable() and clk_disable(). Return an
> error for an unregistered ID instead of accessing an invalid hardware
> clock object.
>
> Fixes: 3aa2882a3e1 ("clk: spacemit: Add support for K1 SoC")
> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech>
Looks good, thanks for the patch
Reviewed-by: Yixun Lan <dlan@kernel.org>
> ---
> I found this while testing SPL pinctrl support on a K1 board with
> Anand's GPIO/pinctrl SPL support series [1]. CLK_AIB and CLK_AIB_BUS,
> which the pinctrl controller requires, are not registered in SPL.
> After retaining the SD pin configuration nodes in the SPL device tree
> and attempting to boot from SD, enabling these missing clocks caused
> SPL to crash.
>
> The custom callbacks crashed without indicating what operation had
> failed:
>
> Trying to boot from MMC2
> Unhandled exception: Load access fault
> EPC: 00000000c080a378 RA: 00000000c080a4f6 TVAL: 0000006b0000306e
>
> With the generic CCF callbacks, the same test returns an error instead
> of crashing and reports:
>
> Trying to boot from MMC2
> Enable system-controller@d4015000 failed
> spacemit_pinctrl pinctrl@d401e000: Fail to enable bulk clks
>
> This makes the clock enable failure visible. The missing SPL AIB clocks
> need to be added separately. This patch only fixes the callbacks.
>
> [1] https://lore.kernel.org/u-boot/20261123193714.5096-1-linux.amoon@gmail.com/
> ---
> drivers/clk/spacemit/clk-k1.c | 58 ++-----------------------------------------
> 1 file changed, 2 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/clk/spacemit/clk-k1.c b/drivers/clk/spacemit/clk-k1.c
> index 20b8595aa3c..ae2bdcbd18a 100644
> --- a/drivers/clk/spacemit/clk-k1.c
> +++ b/drivers/clk/spacemit/clk-k1.c
> @@ -1501,66 +1501,12 @@ static struct clk *k1_ccu_apmu_clks[] = {
> };
> #endif
>
> -static int clk_k1_enable(struct clk *clk)
> -{
> - const struct spacemit_ccu_data *data;
> - struct clk *c;
> - struct clk *pclk;
> - int ret, i;
> -
> - data = (struct spacemit_ccu_data *)dev_get_driver_data(clk->dev);
> - for (i = 0; i < data->num; i++) {
> - if (clk->id == data->clks[i]->id) {
> - c = data->clks[i];
> - break;
> - }
> - }
> - if (i == data->num)
> - c = clk;
> -
> - pclk = clk_get_parent(c);
> - if (!IS_ERR_OR_NULL(pclk)) {
> - ret = ccf_clk_enable(pclk);
> - if (ret)
> - return ret;
> - }
> - ret = ccu_gate_enable(c);
> - return ret;
> -}
> -
> -static int clk_k1_disable(struct clk *clk)
> -{
> - const struct spacemit_ccu_data *data;
> - struct clk *c;
> - struct clk *pclk;
> - int ret, i;
> -
> - data = (struct spacemit_ccu_data *)dev_get_driver_data(clk->dev);
> - for (i = 0; i < data->num; i++) {
> - if (clk->id == data->clks[i]->id) {
> - c = data->clks[i];
> - break;
> - }
> - }
> - if (i == data->num)
> - c = clk;
> -
> - pclk = clk_get_parent(c);
> - if (!IS_ERR_OR_NULL(pclk)) {
> - ret = ccf_clk_disable(pclk);
> - if (ret)
> - return ret;
> - }
> - ret = ccu_gate_disable(c);
> - return ret;
> -}
> -
> #define K1_CLK_OPS(name) \
> static const struct clk_ops k1_##name##_clk_ops = { \
> .set_rate = ccf_clk_set_rate, \
> .get_rate = ccf_clk_get_rate, \
> - .enable = clk_k1_enable, \
> - .disable = clk_k1_disable, \
> + .enable = ccf_clk_enable, \
> + .disable = ccf_clk_disable, \
> .set_parent = ccf_clk_set_parent, \
> .of_xlate = k1_##name##_clk_of_xlate, \
> }
>
> ---
> base-commit: ee1b3477e3af6af1ae9b8f98bc84d2cc6f32a3a6
> change-id: 20261124-k1-clk-fix-f918f7b26001
>
> Best regards,
> --
> Junhui Liu <junhui.liu@pigmoral.tech>
>
--
Yixun Lan (dlan)
prev parent reply other threads:[~2026-11-24 10:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 7:38 [PATCH] clk: spacemit: k1: Use generic CCF enable/disable callbacks Junhui Liu
2026-11-24 10:36 ` Yixun Lan [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=20261124103632-GKA245721@kernel.org \
--to=dlan@kernel.org \
--cc=junhui.liu@pigmoral.tech \
--cc=linux.amoon@gmail.com \
--cc=lukma@nabladev.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
/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