From: sashiko-bot@kernel.org
To: "Jisheng Zhang" <jszhang@kernel.org>
Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
linux-gpio@vger.kernel.org, mfd@lists.linux.dev, robh@kernel.org,
conor+dt@kernel.org, lee@kernel.org
Subject: Re: [PATCH v4 10/13] clk: berlin: add Synaptics SL2610 clocks and PLLs
Date: Fri, 04 Dec 2026 17:39:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-250330@kernel.org> (raw)
In-Reply-To: <20261204140732.31223-11-jszhang@kernel.org>
Thank you for your contribution! Sashiko AI review found 8 potential
issues to consider:
- [Medium] clk: berlin: hardcoded osc parent breaks ge0 and ge1 ptp
refclks
- [Medium] clk: berlin: IRQ-unsafe sl_sysmgr_gateclk_lock risks hardirq
deadlock
- [Medium] clk: berlin: external clk_hw stored in clk_parent_data.hw
- [Medium] clk: berlin: unchecked platform_get_device_id() in
sl2610_clks_probe()
- [Low] clk: berlin: misspelled gate clock names apbuart3lck and
apbi2c1lck
- [Low] clk: berlin: unused SL2610_APLL macro and struct forward
declarations
- [Low] clk: berlin: ARCH_BERLIN gate in drivers/clk/Makefile breaks
COMPILE_TEST
- [Low] clk: berlin: dereference of dev before NULL check in
sl2610_pll_register()
--
commit b1f80cb9b6c334b2a4faa23585bae12adc210391
Author: Jisheng Zhang <jszhang@kernel.org>
clk: berlin: add Synaptics SL2610 clocks and PLLs
This commit adds the Synaptics SL2610 PLL and clock controller drivers,
registering the SoC, CPU, AVIO, and MCU clocks via MFD platform devices.
> diff --git a/drivers/clk/berlin/Kconfig b/drivers/clk/berlin/Kconfig
> index 8f71d4c7a478b..88760ad0af5b9 100644
> --- a/drivers/clk/berlin/Kconfig
> +++ b/drivers/clk/berlin/Kconfig
> @@ -5,3 +5,29 @@ config SL_COMMON_CLK
>
> config SL_SYSMGR_CLK
> bool
> +
> +config SL2610_PLL
> + tristate "Synaptics SL2610 PLL Driver"
> + depends on ARCH_BERLIN || COMPILE_TEST
> + default n
> + help
> + Support the integer and fractional PLL outputs used by the SoC,
> + CPU and audio clock controllers on Synaptics SL2610 SoCs.
> +
> + To compile this driver as a module, choose M here. The module will
> + be called sl2610-pll.
> +
> +config SL2610_CLK
> + tristate "Synaptics SL2610 Clock Driver"
> + depends on ARCH_BERLIN || COMPILE_TEST
> + depends on OF && HAS_IOMEM
[Severity: Low]
Will SL2610_PLL and SL2610_CLK actually be built when COMPILE_TEST is
enabled without ARCH_BERLIN?
drivers/clk/Makefile still gates descent into the directory on
obj-$(CONFIG_ARCH_BERLIN) += berlin/, so Kbuild silently skips
drivers/clk/berlin/ when ARCH_BERLIN is disabled. Switching that entry to
obj-y += berlin/ would also require gating the unconditional berlin2-*.o
objects in drivers/clk/berlin/Makefile.
> diff --git a/drivers/clk/berlin/clk-sl2610.c b/drivers/clk/berlin/clk-sl2610.c
> new file mode 100644
> index 0000000000000..b51d3523028de
> --- /dev/null
> +++ b/drivers/clk/berlin/clk-sl2610.c
[ ... ]
> + { "apbuart3lck", "apbcoreclk", CLK_APBUART3, 13 },
> + { "apbi2c0clk", "apbcoreclk", CLK_APBI2C0, 14 },
> + { "apbi2c1lck", "apbcoreclk", CLK_APBI2C1, 15 },
[Severity: Low]
apbuart3lck and apbi2c1lck appear to be typos for apbuart3clk and
apbi2c1clk, which exposes misspelled names in debugfs and breaks any
name-based lookup for those clocks.
[ ... ]
> +static const char * const ge_ptp_refclk_parent_names[] = {
> + "osc",
> + "apll0_outf",
> + "syspll1_out",
> + "syspll0_out",
> + "clk_mcu_axi",
> +};
[Severity: Medium]
Can ge0_ptp_refclk and ge1_ptp_refclk end up orphaned at 0 Hz when parent
index 0 is selected?
The DT binding passes the external reference clock by phandle without
requiring it to be globally named "osc". In sl2611.dtsi, the fixed-clock
node is named clock-osc without clock-output-names, so
_of_fixed_clk_setup() registers it as "clock-osc" rather than "osc".
Resolving the reference clock from dev->parent->of_node or using
clk_parent_data would avoid the mismatch.
[ ... ]
> +static int sl2610_sysmgr_clk_setup(struct platform_device *pdev)
> +{
> + return sl_sysmgr_clk_setup(pdev, sl2610_sysmgr_fixeds, ARRAY_SIZE(sl2610_sysmgr_fixeds),
> + sl2610_sysmgr_gates, ARRAY_SIZE(sl2610_sysmgr_gates),
> + CLK_GATE_CTRL0,
> + sl2610_sysmgr_clks, ARRAY_SIZE(sl2610_sysmgr_clks));
> +}
[Severity: Medium]
Can registering these MCU gate clocks trigger a hardirq deadlock on
sl_sysmgr_gateclk_lock?
In drivers/clk/berlin/sl-sysmgr-clk.c, both sl_sysmgr_gateclk_enable() and
sl_sysmgr_gateclk_is_enabled() acquire sl_sysmgr_gateclk_lock with plain
guard(spinlock) without disabling interrupts. Reading
/sys/kernel/debug/clk/clk_summary calls sl_sysmgr_gateclk_is_enabled() in
process context with IRQs enabled, which can deadlock if a hardirq enables
a gate clock on the same CPU:
clk_summary_show_one()
clk_core_is_enabled()
sl_sysmgr_gateclk_is_enabled()
guard(spinlock)(&sl_sysmgr_gateclk_lock)
<hardirq>
clk_enable()
sl_sysmgr_gateclk_enable()
guard(spinlock)(&sl_sysmgr_gateclk_lock) <-- spins forever
It also creates an ABBA lock inversion with CCF's global enable_lock across
CPUs. Using guard(spinlock_irqsave) in sl_sysmgr_gateclk_enable() (and
either guard(spinlock_irqsave) or a lockless readl_relaxed() in
sl_sysmgr_gateclk_is_enabled()) avoids the inversion.
[ ... ]
> +static int sl2610_clks_probe(struct platform_device *pdev)
> +{
> + int (*clk_setup)(struct platform_device *pdev);
> +
> + clk_setup = (void *)platform_get_device_id(pdev)->driver_data;
> +
> + return clk_setup(pdev);
> +}
[Severity: Medium]
Can platform_get_device_id(pdev) return NULL and cause a NULL pointer
dereference here?
If an unbound platform device is bound to sl2610-clk via sysfs
driver_override, platform_match() returns early on
device_match_driver_override() without calling platform_match_id(), leaving
pdev->id_entry NULL. Checking for a NULL id and returning -ENODEV prevents
the oops.
> diff --git a/drivers/clk/berlin/sl2610-pll.c b/drivers/clk/berlin/sl2610-pll.c
> new file mode 100644
> index 0000000000000..62c5d2d19c362
> --- /dev/null
> +++ b/drivers/clk/berlin/sl2610-pll.c
[ ... ]
> +#define SL2610_APLL
> +struct sl2610_pll {
[Severity: Low]
SL2610_APLL is an unused leftover macro. In addition, sl2610-pll.h
contains unused forward declarations for struct clk_hw_onecell_data and
struct device_node.
[ ... ]
> +int sl2610_pll_register(struct device *dev, void __iomem *ctrl,
> + const char *out, const char *outf)
> +{
> + struct device_node *np = dev->parent->of_node;
> + struct clk_parent_data parent = {};
> + struct clk_init_data init = {};
> + struct sl2610_pll *pll;
> + struct clk *input;
> + int ret;
> +
> + if (!dev || !ctrl || !out || !outf)
> + return -EINVAL;
[Severity: Low]
Does the initializer for np dereference dev before the !dev check?
Initializing np after validating dev (and dev->parent and np if defensive
checking is intended) avoids the dead NULL check and prevents an oops if a
caller ever passes a NULL dev.
> + input = of_clk_get(np, 0);
> + if (IS_ERR(input))
> + return dev_err_probe(dev, PTR_ERR(input),
> + "failed to get PLL reference clock\n");
> + parent.hw = __clk_get_hw(input);
> + ret = devm_add_action_or_reset(dev, sl2610_pll_put_clk, input);
> + if (ret)
> + return ret;
> +
> + pll = devm_kzalloc(dev, sizeof(*pll), GFP_KERNEL);
> + if (!pll)
> + return -ENOMEM;
> + pll->ctrl = ctrl;
> +
> + init.name = out;
> + init.ops = &sl2610_pllout_ops;
> + init.parent_data = &parent;
> + init.num_parents = 1;
> + init.flags = CLK_GET_RATE_NOCACHE;
> + pll->pllout.init = &init;
> +
> + ret = devm_clk_hw_register(dev, &pll->pllout);
[Severity: Medium]
Can storing __clk_get_hw(input) in parent.hw cause a use-after-free if the
external reference clock provider is unregistered?
clk_parent_data.hw is only valid for provider-internal clocks, and holding
the struct clk from of_clk_get() does not prevent an external provider from
unregistering and freeing its struct clk_hw. On unregistration,
clk_core_evict_parent_cache() clears entry->core while leaving entry->hw
set, so a later clk_core_fill_parent_index() dereferences entry->hw->core
on the freed clk_hw. Since clk_hw_register() already attaches
dev->parent->of_node, initializing parent with { .index = 0 } lets CCF
resolve the DT parent directly without of_clk_get() or storing an external
clk_hw pointer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204140732.31223-1-jszhang@kernel.org?part=10
next prev parent reply other threads:[~2026-12-04 17:39 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 14:07 [PATCH v4 00/13] arm64: add Synaptics SL2610 SoCs and RDK boards Jisheng Zhang
2026-12-04 14:07 ` [PATCH v4 01/13] arm64: kconfig: let ARCH_BERLIN cover Synaptics arm64 SoCs Jisheng Zhang
2026-12-04 14:07 ` [PATCH v4 02/13] pinctrl: berlin: use u16 instead of u8 for the offset Jisheng Zhang
2026-12-04 14:07 ` [PATCH v4 03/13] pinctrl: berlin: enable module build support Jisheng Zhang
2026-12-04 15:03 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 04/13] pinctrl: berlin: add optional pinconf support Jisheng Zhang
2026-12-04 15:22 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 05/13] dt-bindings: soc: synaptics: add SL2610 system controllers Jisheng Zhang
2026-12-04 15:41 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 06/13] mfd: synaptics: add SL2610 system controller support Jisheng Zhang
2026-12-04 15:58 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 07/13] reset: add Synaptics SL2610 reset " Jisheng Zhang
2026-12-04 16:24 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 08/13] pinctrl: berlin: add Synaptics SL2610 pin " Jisheng Zhang
2026-12-04 16:51 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 09/13] clk: berlin: add Synaptics clock controller helpers Jisheng Zhang
2026-12-04 17:13 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 10/13] clk: berlin: add Synaptics SL2610 clocks and PLLs Jisheng Zhang
2026-12-04 17:39 ` sashiko-bot [this message]
2026-12-04 14:07 ` [PATCH v4 11/13] dt-bindings: arm: berlin: add Synaptics SL2610 SoCs and RDK boards Jisheng Zhang
2026-12-04 14:07 ` [PATCH v4 12/13] arm64: dts: synaptics: add SL2610 family SoCs Jisheng Zhang
2026-12-04 18:05 ` sashiko-bot
2026-12-04 14:07 ` [PATCH v4 13/13] arm64: dts: synaptics: add SL2610 family RDK boards Jisheng Zhang
2026-12-04 18:19 ` sashiko-bot
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-250330@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jszhang@kernel.org \
--cc=lee@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox