All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rudraksha Gupta via B4 Relay" <devnull+guptarud.gmail.com@kernel.org>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 2/3] soc: qcom: spm: Add MSM8960 SAW2 CPU support
Date: Thu, 28 May 2026 04:18:19 +0000	[thread overview]
Message-ID: <20260528041820.1C0DF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260527-expressatt_cpufreq-v2-2-b9b7726ccb6d@gmail.com>

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

Pre-existing issues:
- [Critical] Unconditional division by zero during regulator registration
- [High] Infinite polling loop in hardware register write sequence
--

commit 17a126a384bb63507998b0691e4ff49e0de54dab
Author: Rudraksha Gupta <guptarud@gmail.com>

soc: qcom: spm: Add MSM8960 SAW2 CPU support

This commit adds SPM register data for the MSM8960 CPU. It configures the SPM
sequences, PMIC delays, and regulator ranges to support the SAW2 v1.1 hardware
present in this SoC.

Link: https://github.com/CyanogenMod/android_kernel_samsung_d2/blob/0dbe2b56847b304d30b809dfd08ba3b4a61d9af8/arch/arm/mach-msm/board-express.c#L3265-L3285
Link: https://github.com/CyanogenMod/android_kernel_samsung_d2/blob/0dbe2b56847b304d30b809dfd08ba3b4a61d9af8/arch/arm/mach-msm/board-express.c#L3353-L3381

> diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c
> index f75659fff2874..fb3ec8aa42b07 100644
> --- a/drivers/soc/qcom/spm.c
> +++ b/drivers/soc/qcom/spm.c
> @@ -253,6 +253,22 @@ static const struct spm_reg_data spm_reg_8064_cpu = {
>  	.ramp_delay = 1250,
>  };
>  
> +static const struct spm_reg_data spm_reg_8960_cpu = {
> +	.reg_offset = spm_reg_offset_v1_1,

[Severity: High]
This isn't a regression introduced by this patch, but registering these
offsets enables a code path with an unbounded polling loop.

During probe, setting up the default low power mode eventually calls
spm_register_write_sync():

drivers/soc/qcom/spm.c:spm_register_write_sync() {
	...
	do {
		writel_relaxed(val, drv->reg_base +
				drv->reg_data->reg_offset[reg]);
		ret = readl_relaxed(drv->reg_base +
				drv->reg_data->reg_offset[reg]);
		if (ret == val)
			break;
		cpu_relax();
	} while (1);
}

If the hardware is in an invalid state, or if certain register bits are
read-only and fail to reflect the written toggle, could this loop hang
indefinitely?

Would it be safer to use a proper timeout mechanism like
read_poll_timeout_atomic() here to allow for graceful recovery?

> +	.spm_cfg = 0x1f,
> +	.pmic_dly = 0x03020004,
> +	.pmic_data[0] = 0x0084009c,
> +	.pmic_data[1] = 0x00a4001c,
> +	.seq = { 0x03, 0x0f, 0x00, 0x24, 0x54, 0x10, 0x09, 0x03, 0x01,
> +		0x10, 0x54, 0x30, 0x0c, 0x24, 0x30, 0x0f },
> +	.start_index[PM_SLEEP_MODE_STBY] = 0,
> +	.start_index[PM_SLEEP_MODE_SPC] = 2,
> +	.set_vdd = smp_set_vdd_v1_1,
> +	.range = &spm_v1_1_regulator_range,
> +	.init_uV = 1300000,

[Severity: Critical]
This is a pre-existing issue, but I noticed that setting init_uV here
triggers a division by zero during probe.

When spm_register_regulator() allocates rdesc via devm_kzalloc(),
rdesc->uV_step is zero-initialized and never explicitly set. Later, it
performs this calculation:

drivers/soc/qcom/spm.c:spm_register_regulator() {
	...
	drv->volt_sel = DIV_ROUND_UP(drv->reg_data->init_uV - rdesc->min_uV,
				     rdesc->uV_step);
	...
}

Will this result in an unconditional division by zero when calculating
drv->volt_sel?

> +	.ramp_delay = 1250,
> +};
> +

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260527-expressatt_cpufreq-v2-0-b9b7726ccb6d@gmail.com?part=2

  reply	other threads:[~2026-05-28  4:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28  3:39 [PATCH v2 0/3] Add cpufreq to MSM8960 Rudraksha Gupta
2026-05-28  3:39 ` Rudraksha Gupta via B4 Relay
2026-05-28  3:39 ` [PATCH v2 1/3] dt-bindings: opp: Allow optional -vN suffix in opp-microvolt property name Rudraksha Gupta
2026-05-28  3:39   ` Rudraksha Gupta via B4 Relay
2026-05-28  6:35   ` Dmitry Baryshkov
2026-07-13 11:14     ` Rudraksha Gupta
2026-05-28  3:39 ` [PATCH v2 2/3] soc: qcom: spm: Add MSM8960 SAW2 CPU support Rudraksha Gupta
2026-05-28  3:39   ` Rudraksha Gupta via B4 Relay
2026-05-28  4:18   ` sashiko-bot [this message]
2026-05-28  6:04   ` Dmitry Baryshkov
2026-05-28  3:39 ` [PATCH v2 3/3] ARM: dts: qcom: msm8960: Add CPU frequency scaling support Rudraksha Gupta
2026-05-28  3:39   ` Rudraksha Gupta via B4 Relay
2026-05-28  4:43   ` 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=20260528041820.1C0DF1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+guptarud.gmail.com@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 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.