linux-yocto/drivers/clk
Sascha Hauer 1d21977828 clk: scmi: Handle case where child clocks are initialized before their parents
commit 6306e0c5a0 upstream.

The SCMI clock driver currently assumes that parent clocks are always
initialized before their children. However, this assumption can fail if
a child clock is encountered before its parent during probe.

This leads to an issue during initialization of the parent_data array:

    sclk->parent_data[i].hw = hws[sclk->info->parents[i]];

If the parent clock's hardware structure has not been initialized yet,
this assignment results in invalid data.

To resolve this, allocate all struct scmi_clk instances as a contiguous
array at the beginning of the probe and populate the hws[] array
upfront. This ensures that any parent referenced later is already
initialized, regardless of the order in which clocks are processed.

Note that we can no longer free individual scmi_clk instances if
scmi_clk_ops_init() fails which shouldn't be a problem if the SCMI
platform has proper per-agent clock discovery.

Fixes: 65a8a3dd3b ("clk: scmi: Add support for clock {set,get}_parent")
Reviewed-by: peng.fan@nxp.com
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.kernel.org/r/20250612-clk-scmi-children-parent-fix-v3-1-7de52a27593d@pengutronix.de
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-07-17 18:37:14 +02:00
..
actions
analogbits clk: analogbits: Fix incorrect calculation of vco rate delta 2025-02-08 09:57:23 +01:00
at91 Merge branches 'clk-amlogic', 'clk-microchip' and 'clk-imx' into clk-next 2024-09-21 14:10:59 -07:00
axis
axs10x clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
baikal-t1
bcm clk: bcm: rpi: Add NULL check in raspberrypi_clk_register() 2025-06-19 15:31:47 +02:00
berlin
davinci clk:davinci: make use of dev_err_cast_probe() 2024-08-28 13:11:21 -07:00
hisilicon clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
imgtec
imx clk: imx: Fix an out-of-bounds access in dispmix_csr_clk_dev_data 2025-07-17 18:37:14 +02:00
ingenic
keystone clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
mediatek clk: mediatek: mt2701-mm: add missing dummy clk 2025-02-17 10:05:12 +01:00
meson clk: meson-g12a: add missing fclk_div2 to spicc 2025-06-27 11:11:22 +01:00
microchip clock, reset: microchip: move all mpfs reset code to the reset subsystem 2024-05-07 14:57:46 -07:00
mmp clk: mmp2: call pm_genpd_init() only after genpd.name is set 2025-02-17 10:05:09 +01:00
mstar
mvebu clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
mxs clk: mxs: Use clamp() in clk_ref_round_rate() and clk_ref_set_rate() 2024-07-10 13:08:59 -07:00
nuvoton
nxp clk: lpc32xx: Constify struct regmap_config 2024-07-08 13:32:47 -07:00
pistachio
pxa
qcom clk: qcom: gcc-x1e80100: Set FORCE MEM CORE for UFS clocks 2025-06-27 11:11:29 +01:00
ralink clk: ralink: mtmips: remove duplicated 'xtal' clock for Ralink SoC RT3883 2025-02-08 09:57:15 +01:00
renesas clk: renesas: rzg2l-cpg: Refactor Runtime PM clock validation 2025-05-29 11:03:06 +02:00
rockchip clk: rockchip: rk3036: mark ddrphy as critical 2025-06-27 11:11:32 +01:00
samsung clk: samsung: Fix UBSAN panic in samsung_clk_init() 2025-04-10 14:39:18 +02:00
sifive This a large collection of clk driver updates and a handful of new SoC 2024-07-19 12:16:28 -07:00
socfpga
sophgo clk: sophgo: avoid integer overflow in sg2042_pll_recalc_rate() 2024-12-05 14:02:05 +01:00
spear
sprd clk: sprd: add missing MODULE_DESCRIPTION() macro 2024-06-03 15:43:16 -07:00
st
starfive The core clk framework is left largely untouched this time around except for 2024-09-23 15:01:48 -07:00
stm32 clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
sunxi of: remove internal arguments from of_property_for_each_u32() 2024-07-25 06:53:47 -05:00
sunxi-ng clk: sunxi-ng: d1: Add missing divider for MMC mod clocks 2025-05-29 11:03:14 +02:00
tegra clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
thead clk: thead: Fix cpu2vp_clk for TH1520 AP_SUBSYS clocks 2025-02-08 09:57:15 +01:00
ti clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
uniphier
ux500
versatile clk: Use of_property_present() 2024-08-02 16:53:38 -07:00
visconti clk: visconti: Switch to use kmemdup_array() 2024-08-14 17:37:25 -07:00
x86 clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
xilinx clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
zynq clk: zynq: Prevent null pointer dereference caused by kmalloc failure 2024-03-08 17:15:20 -08:00
zynqmp drivers: clk: zynqmp: update divider round rate logic 2023-12-16 17:20:14 -08:00
.kunitconfig clk: Allow kunit tests to run without OF_OVERLAY enabled 2024-12-05 14:02:05 +01:00
clk_kunit_helpers.c clk: Add test managed clk provider/consumer APIs 2024-07-29 15:33:12 -07:00
clk_parent_data_test.h clk: Add KUnit tests for clks registered with struct clk_parent_data 2024-07-29 15:33:13 -07:00
clk_test.c clk: test: Fix some memory leaks 2024-10-16 14:39:18 -07:00
clk-apple-nco.c clk: clk-apple-nco: Add NULL check in applnco_probe 2024-12-05 14:02:15 +01:00
clk-asm9260.c
clk-aspeed.c
clk-aspeed.h
clk-ast2600.c clk: ast2600: Add FSI parent clock with correct rate 2024-02-21 21:46:13 -08:00
clk-axi-clkgen.c clk: clk-axi-clkgen: make sure to enable the AXI bus clock 2024-12-05 14:02:16 +01:00
clk-axm5516.c
clk-bd718x7.c
clk-bm1880.c
clk-bulk.c
clk-cdce706.c
clk-cdce925.c clk: cdce925: Remove redundant assignment to variable 'rate' 2024-02-21 21:36:09 -08:00
clk-clps711x.c
clk-composite.c
clk-conf.c clk: clk-conf: support assigned-clock-rates-u64 2024-08-16 15:21:19 -07:00
clk-cs2000-cp.c
clk-devres.c clk: provide devm_clk_get_optional_enabled_with_rate() 2024-09-05 13:51:46 -07:00
clk-divider.c
clk-en7523.c clk: en7523: Fix wrong BUS clock for EN7581 2024-12-19 18:12:58 +01:00
clk-ep93xx.c clk: ep93xx: Fix off by one in ep93xx_div_recalc_rate() 2024-09-12 14:33:12 +00:00
clk-fixed-factor.c clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
clk-fixed-mmio.c clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
clk-fixed-rate_test.c clk: Add KUnit tests for clk fixed rate basic type 2024-07-29 15:33:13 -07:00
clk-fixed-rate_test.h clk: Add KUnit tests for clk fixed rate basic type 2024-07-29 15:33:13 -07:00
clk-fixed-rate.c clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
clk-fractional-divider_test.c clk: test: add missing MODULE_DESCRIPTION() macros 2024-06-03 15:46:46 -07:00
clk-fractional-divider.c clk: fractional-divider: Use bit operations consistently 2024-03-08 17:07:11 -08:00
clk-fractional-divider.h
clk-fsl-flexspi.c
clk-fsl-sai.c
clk-gate_test.c clk: test: add missing MODULE_DESCRIPTION() macros 2024-06-03 15:46:46 -07:00
clk-gate.c
clk-gemini.c clk: gemini: Remove an unused field in struct clk_gemini_pci 2024-04-19 18:58:36 -07:00
clk-gpio.c
clk-hi655x.c
clk-highbank.c clk: highbank: Remove an unused field in struct hb_clk 2024-04-19 18:57:30 -07:00
clk-hsdk-pll.c
clk-k210.c
clk-lan966x.c
clk-lmk04832.c clk: lmk04832: Use devm_clk_get_enabled() helpers 2024-08-27 17:25:04 -07:00
clk-lochnagar.c
clk-loongson1.c
clk-loongson2.c clk: clk-loongson2: Fix the number count of clk provider 2025-02-17 10:05:10 +01:00
clk-max9485.c
clk-max77686.c
clk-milbeaut.c
clk-moxart.c
clk-multiplier.c
clk-mux.c
clk-nomadik.c
clk-npcm7xx.c
clk-nspire.c
clk-palmas.c clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
clk-plldig.c
clk-pwm.c clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
clk-qoriq.c
clk-renesas-pcie.c clk: rs9: fix wrong default value for clock amplitude 2024-04-19 19:09:41 -07:00
clk-rk808.c
clk-s2mps11.c clk: s2mps11: initialise clk_hw_onecell_data::num before accessing ::hws[] in probe() 2025-05-29 11:03:18 +02:00
clk-scmi.c clk: scmi: Handle case where child clocks are initialized before their parents 2025-07-17 18:37:14 +02:00
clk-scpi.c clk: Switch back to struct platform_driver::remove() 2024-09-21 14:12:05 -07:00
clk-si514.c
clk-si521xx.c Merge branch 'clk-cleanup' into clk-next 2023-10-30 14:12:53 -07:00
clk-si544.c Merge branch 'clk-cleanup' into clk-next 2023-10-30 14:12:53 -07:00
clk-si570.c Merge branch 'clk-cleanup' into clk-next 2023-10-30 14:12:53 -07:00
clk-si5341.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
clk-si5351.c of: remove internal arguments from of_property_for_each_u32() 2024-07-25 06:53:47 -05:00
clk-si5351.h
clk-sp7021.c clk: sp7021: fix return value check in sp7021_clk_probe() 2023-12-16 17:10:17 -08:00
clk-sparx5.c
clk-stm32f4.c
clk-stm32h7.c
clk-tps68470.c
clk-twl.c
clk-twl6040.c
clk-versaclock3.c clk: versaclock3: Drop ret variable 2023-12-17 15:56:14 -08:00
clk-versaclock5.c
clk-versaclock7.c
clk-vt8500.c
clk-wm831x.c
clk-xgene.c
clk.c clk: check for disabled clock-provider in of_clk_get_hw_from_clkspec() 2025-05-02 07:59:15 +02:00
clk.h
clkdev.c Merge topic branches 'clkdev' and 'fixes' into for-linus 2024-06-10 12:03:21 +01:00
Kconfig clk: Allow kunit tests to run without OF_OVERLAY enabled 2024-12-05 14:02:05 +01:00
kunit_clk_fixed_rate_test.dtso clk: Add KUnit tests for clk fixed rate basic type 2024-07-29 15:33:13 -07:00
kunit_clk_parent_data_test.dtso clk: Add KUnit tests for clks registered with struct clk_parent_data 2024-07-29 15:33:13 -07:00
Makefile soc: convert ep93xx to devicetree 2024-09-26 12:00:25 -07:00