Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Abel Vesa" <abel.vesa@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
	linux-clk@vger.kernel.org
Subject: Re: [PATCH v3 19/47] clk: qcom: gcc-sdm670: Tie the CX power domain to controller
Date: Mon, 24 Aug 2026 12:19:15 +0000	[thread overview]
Message-ID: <20260824121915.811D21F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260824-qcom-tie-cx-to-gcc-v3-19-f1205a92682b@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

New issues:
- [High] The patch adds `.use_rpm = true` to allow the CX power domain to power down when idle, but `CLK_IS_CRITICAL` clocks permanently prevent the device from suspending, entirely defeating the patch's goal.
- [High] Enabling runtime PM introduces a permanent PM runtime usage count leak on probe deferral.

Pre-existing issues:
- [High] Missing `sync_state` callback causes GDSCs initialized as active by the bootloader to stay powered on indefinitely, defeating the patch's purpose of powering down CX.
- [High] If `gdsc_init()` or `pm_genpd_add_subdomain()` fails in `gdsc_register()`, previously initialized generic PM domains are not removed, leading to a Use-After-Free.
--

--- Patch [19]: [PATCH v3 19/47] clk: qcom: gcc-sdm670: Tie the CX power domain to controller ---
commit b55a4bcc407393a5d2f7c186b77a4841507253c0
Author: Abel Vesa <abel.vesa@oss.qualcomm.com>

clk: qcom: gcc-sdm670: Tie the CX power domain to controller

This commit sets use_rpm to true in the gcc_sdm670_desc configuration to
enable runtime PM for the controller. The goal is to allow the CX power
domain to be powered down when all consumers have released their clocks and
GDSCs.

> diff --git a/drivers/clk/qcom/gcc-sdm845.c b/drivers/clk/qcom/gcc-sdm845.c
> index 6d0f9cede5cfe..57d54b45fa527 100644
> --- a/drivers/clk/qcom/gcc-sdm845.c
> +++ b/drivers/clk/qcom/gcc-sdm845.c
> @@ -3948,6 +3948,7 @@ static const struct qcom_cc_desc gcc_sdm670_desc = {
>  	.num_resets = ARRAY_SIZE(gcc_sdm845_resets),
>  	.gdscs = gcc_sdm670_gdscs,
>  	.num_gdscs = ARRAY_SIZE(gcc_sdm670_gdscs),
> +	.use_rpm = true,

[Severity: High]
Does setting use_rpm to true actually allow the device to suspend?

When use_rpm is true, clk_core_prepare() takes a PM runtime vote on the GCC
device. However, critical clocks are permanently prepared at registration:

drivers/clk/qcom/gcc-sdm845.c:gcc_camera_ahb_clk {
	...
	.flags = CLK_IS_CRITICAL,
}

Since critical clocks are never unprepared, the runtime PM vote is never
dropped, which appears to keep the CX power domain permanently active. Does
this prevent the patch from achieving its power-savings objective?


[Severity: High]
Will enabling runtime PM here introduce a usage count leak on probe deferral?

Critical clocks take a PM runtime reference during registration. If probe
defers later (for example in qcom_cc_icc_register()), the clocks are
unregistered via clk_unregister().

However, clk_unregister() doesn't unprepare critical clocks or drop the PM
runtime reference:

drivers/clk/clk.c:clk_unregister() {
	if (clk->core->prepare_count)
		pr_warn("%s: unregistering prepared clock: %s\n",
				__func__, clk->core->name);
	...
}

Does this lead to permanently unbalanced usage counts every time probe defers?

>  };
>  
>  static const struct qcom_cc_desc gcc_sdm845_desc = {

[Severity: High]
This isn't a bug introduced by this patch, but does the lack of a sync_state
callback in gcc_sdm845_driver prevent the CX power domain from powering down?

When GDSCs are initialized as active by the bootloader, pm_genpd_init() is
called with is_off=false, and the genpd framework sets stay_on=true. This
flag is only cleared when the device driver's sync_state callback fires.

Since gcc_sdm845_driver lacks a sync_state callback (like
of_genpd_sync_state), the stay_on flag is never cleared:

drivers/clk/qcom/gcc-sdm845.c:gcc_sdm845_driver {
	.probe		= gcc_sdm845_probe,
	.driver		= {
		.name	= "gcc-sdm845",
		.of_match_table = gcc_sdm845_match_table,
	},
}

Could this cause active GDSCs to stay powered on indefinitely?


[Severity: High]
This is a pre-existing issue, but can the error path in gdsc_register() lead
to a use-after-free?

If gdsc_init() or pm_genpd_add_subdomain() fails during the loop in
gdsc_register(), it exits immediately and only cleans up subdomains:

drivers/clk/qcom/gdsc.c:gdsc_register() {
	...
		ret = gdsc_init(scs[i]);
		if (ret)
			return ret;
	...
err_pm_subdomain_remove:
	gdsc_pm_subdomain_remove(desc, i);

	return ret;
}

The error path fails to call pm_genpd_remove() for the previously
initialized generic PM domains, leaving them in the global gpd_list. If the
module is later unloaded, the statically allocated GDSC structures are
freed, which might cause a kernel panic on the next gpd_list traversal.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260824-qcom-tie-cx-to-gcc-v3-0-f1205a92682b@oss.qualcomm.com?part=19

  reply	other threads:[~2026-08-24 12:19 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 11:53 [PATCH v3 00/47] clk: qcom: Tie CX power domains to GCCs Abel Vesa
2026-08-24 11:53 ` [PATCH v3 01/47] dt-bindings: clock: qcom: gcc-sdm845: Add CX power domain Abel Vesa
2026-08-24 20:39   ` Krzysztof Kozlowski
2026-08-25  7:30     ` Abel Vesa
2026-08-25  7:34       ` Krzysztof Kozlowski
2026-08-25  8:01         ` Abel Vesa
2026-08-24 11:53 ` [PATCH v3 02/47] dt-bindings: clock: qcom: gcc-sm8150: " Abel Vesa
2026-08-24 11:53 ` [PATCH v3 03/47] dt-bindings: clock: qcom: gcc-sm8250: " Abel Vesa
2026-08-24 11:53 ` [PATCH v3 04/47] dt-bindings: clock: qcom: gcc-sm8350: " Abel Vesa
2026-08-24 12:11   ` sashiko-bot
2026-08-24 11:53 ` [PATCH v3 05/47] dt-bindings: clock: qcom: gcc-sm8450: " Abel Vesa
2026-08-24 12:13   ` sashiko-bot
2026-08-24 11:53 ` [PATCH v3 06/47] dt-bindings: clock: qcom: qcs615-gcc: " Abel Vesa
2026-08-24 11:53 ` [PATCH v3 07/47] dt-bindings: clock: qcom: sm8550-gcc: " Abel Vesa
2026-08-24 12:08   ` sashiko-bot
2026-08-24 11:53 ` [PATCH v3 08/47] dt-bindings: clock: qcom: sm8650-gcc: " Abel Vesa
2026-08-24 12:08   ` sashiko-bot
2026-08-24 11:53 ` [PATCH v3 09/47] dt-bindings: clock: qcom: sm8750-gcc: " Abel Vesa
2026-08-24 11:53 ` [PATCH v3 10/47] clk: qcom: gcc-eliza: Tie the CX power domain to controller Abel Vesa
2026-08-24 11:53 ` [PATCH v3 11/47] clk: qcom: gcc-kaanapali: " Abel Vesa
2026-08-24 11:53 ` [PATCH v3 12/47] clk: qcom: gcc-qcs615: " Abel Vesa
2026-08-24 12:25   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 13/47] clk: qcom: gcc-qcs8300: " Abel Vesa
2026-08-24 12:25   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 14/47] clk: qcom: gcc-qdu1000: " Abel Vesa
2026-08-24 12:28   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 15/47] clk: qcom: gcc-sa8775p: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 16/47] clk: qcom: gcc-sar2130p: " Abel Vesa
2026-08-24 12:19   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 17/47] clk: qcom: gcc-sc7180: " Abel Vesa
2026-08-24 12:22   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 18/47] clk: qcom: gcc-sc7280: " Abel Vesa
2026-08-24 12:36   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 19/47] clk: qcom: gcc-sdm670: " Abel Vesa
2026-08-24 12:19   ` sashiko-bot [this message]
2026-08-24 11:54 ` [PATCH v3 20/47] clk: qcom: gcc-sdm845: " Abel Vesa
2026-08-24 12:18   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 21/47] clk: qcom: gcc-sdx75: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 22/47] clk: qcom: gcc-sm4450: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 23/47] clk: qcom: gcc-sm6350: " Abel Vesa
2026-08-24 12:22   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 24/47] clk: qcom: gcc-sm8150: " Abel Vesa
2026-08-24 12:28   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 25/47] clk: qcom: gcc-sm8250: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 26/47] clk: qcom: gcc-sm8350: " Abel Vesa
2026-08-24 12:20   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 27/47] clk: qcom: gcc-sm8450: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 28/47] clk: qcom: gcc-sm8550: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 29/47] clk: qcom: gcc-sm8650: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 30/47] clk: qcom: gcc-sm8750: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 31/47] clk: qcom: gcc-x1e80100: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 32/47] arm64: dts: qcom: kaanapali: Add GCC CX power domain Abel Vesa
2026-08-24 11:54 ` [PATCH v3 33/47] arm64: dts: qcom: monaco: " Abel Vesa
2026-08-24 12:24   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 34/47] arm64: dts: qcom: qdu1000: " Abel Vesa
2026-08-24 12:27   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 35/47] arm64: dts: qcom: sar2130p: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 36/47] arm64: dts: qcom: sdm670: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 37/47] arm64: dts: qcom: sdx75: " Abel Vesa
2026-08-24 12:28   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 38/47] arm64: dts: qcom: sm4450: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 39/47] arm64: dts: qcom: sm6350: " Abel Vesa
2026-08-24 12:30   ` sashiko-bot
2026-08-24 11:54 ` [PATCH v3 40/47] arm64: dts: qcom: sm8150: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 41/47] arm64: dts: qcom: sm8250: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 42/47] arm64: dts: qcom: sm8350: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 43/47] arm64: dts: qcom: sm8450: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 44/47] arm64: dts: qcom: sm8550: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 45/47] arm64: dts: qcom: sm8650: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 46/47] arm64: dts: qcom: sm8750: " Abel Vesa
2026-08-24 11:54 ` [PATCH v3 47/47] arm64: dts: qcom: talos: " Abel Vesa
2026-08-24 16:28 ` [PATCH v3 00/47] clk: qcom: Tie CX power domains to GCCs Vinod Koul
2026-08-25  7:32   ` Abel Vesa

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=20260824121915.811D21F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=abel.vesa@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox