Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexey Klimov" <alexey.klimov@linaro.org>
Cc: robh@kernel.org, conor+dt@kernel.org, krzk+dt@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v4 4/6] soc: samsung: exynos-pmu: add Exynos850 CPU hotplug support
Date: Thu, 14 May 2026 06:04:34 +0000	[thread overview]
Message-ID: <20260514060434.BB1E2C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260513-exynos850-cpuhotplug-v4-4-54fec5f65362@linaro.org>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] exynos850_cpu_pmu_online() and exynos850_cpu_pmu_offline() incorrectly configure PMU registers for the executing control CPU instead of the target CPU.
- [High] Lock nesting violation (sleeping in atomic context) when accessing the Exynos850 syscon regmap.
- [Low] Missing parentheses around the macro argument `cl` in `EXYNOS850_CLUSTER_CPU_OFFSET`.
--

commit 1fa894e1840a285a12214486e682639554622ecb
Author: Alexey Klimov <alexey.klimov@linaro.org>

soc: samsung: exynos-pmu: add Exynos850 CPU hotplug support

This commit adds CPU hotplug support for Exynos850 platforms by providing
specific PMU and interrupt generation register updates for sleep states
and CPU online/offline transitions.

> diff --git a/drivers/soc/samsung/exynos850-pmu.c b/drivers/soc/samsung/exynos850-pmu.c
> new file mode 100644
> index 0000000000000..40df158819239
> --- /dev/null
> +++ b/drivers/soc/samsung/exynos850-pmu.c

[ ... ]

> +static int exynos850_cpu_pmu_offline(struct exynos_pmu_context *pmu_context, unsigned int cpu)
> +	__must_hold(&pmu_context->cpupm_lock)
> +{
> +	u32 this_cluster = MPIDR_AFFINITY_LEVEL(read_cpuid_mpidr(), 2);
> +	u32 cluster_cpu = MPIDR_AFFINITY_LEVEL(read_cpuid_mpidr(), 1);
> +	unsigned int cpuhint = smp_processor_id();

Since exynos850_cpu_pmu_offline() is invoked during the CPUHP_BP_PREPARE_DYN
hotplug state, won't this code execute on the control CPU (Boot Processor)
instead of the target CPU being taken offline?

By using read_cpuid_mpidr() and smp_processor_id() here, it looks like this
reads the physical ID and hardware MPIDR of the executing control CPU rather
than deriving them from the target cpu argument.

> +	u32 reg, mask;
> +
> +	/* set cpu inform hint */
> +	regmap_write(pmu_context->pmureg, EXYNOS850_CPU_INFORM(cpuhint),
> +		     CPU_INFORM_C2);

Could calling regmap_write() here cause a lock nesting regression?

Because cpupm_lock is a raw_spinlock_t, and the pmureg for Exynos850 is
created via syscon_node_to_regmap(), pmureg is protected by a standard
spinlock_t instead of a raw spinlock. Acquiring a spinlock_t while holding
a raw_spinlock_t can lead to a sleeping in atomic context bug on PREEMPT_RT.

> +
> +	mask = BIT(cpu);

Does this need to convert the logical cpu parameter to a physical core ID
using cpu_logical_map(cpu) before using it as a hardware bitmask?

Using the logical CPU index directly might configure the wrong hardware
registers if the logical to physical mapping is not 1:1.

[ ... ]

> diff --git a/include/linux/soc/samsung/exynos-regs-pmu.h b/include/linux/soc/samsung/exynos-regs-pmu.h
> index 9c4d3da41dbf2..93c4d724c8eac 100644
> --- a/include/linux/soc/samsung/exynos-regs-pmu.h
> +++ b/include/linux/soc/samsung/exynos-regs-pmu.h

[ ... ]

> @@ -1015,6 +1015,11 @@
>  #define EXYNOS_GRP2_INTR_BID_UPEND				(0x0208)
>  #define EXYNOS_GRP2_INTR_BID_CLEAR				(0x020c)
>  
> +/* Exynos850 PMU Alive */
> +#define EXYNOS850_CPU_INFORM(cpu)		(0x0860 + ((cpu) & 7) * 4)
> +#define EXYNOS850_CLUSTER_CPU_OFFSET(cl, cpu)	(0x1000 + ((cl * 0x400) + ((cpu) * 0x80)))

Is it safer to wrap the cl argument in parentheses?

If an arithmetic expression is passed for cl in the future, operator
precedence could cause it to evaluate incorrectly and result in out-of-bounds
register offsets.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260513-exynos850-cpuhotplug-v4-0-54fec5f65362@linaro.org?part=4

  reply	other threads:[~2026-05-14  6:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 12:37 [PATCH v4 0/6] Exynos-pmu: Generalise cpu{hotplug,idle},PMU intr gen and add Exynos850 CPU hotplug Alexey Klimov
2026-05-13 12:37 ` [PATCH v4 1/6] dt-bindings: soc: move,rename google,gs101-pmu-intr-gen and add exynos850 Alexey Klimov
2026-05-13 12:37 ` [PATCH v4 2/6] dt-bindings: soc: samsung: exynos-pmu: Require pmu-intr-gen-syscon for Exynos850 Alexey Klimov
2026-05-13 12:37 ` [PATCH v4 3/6] soc: samsung: exynos-pmu: generalise gs101-specific cpu{idle,hotplug} for Exynos SoCs Alexey Klimov
2026-05-14  5:30   ` sashiko-bot
2026-05-13 12:37 ` [PATCH v4 4/6] soc: samsung: exynos-pmu: add Exynos850 CPU hotplug support Alexey Klimov
2026-05-14  6:04   ` sashiko-bot [this message]
2026-05-13 12:37 ` [PATCH v4 5/6] MAINTAINERS: add Exynos850 PMU entry Alexey Klimov
2026-05-13 12:37 ` [PATCH v4 6/6] arm64: dts: exynos850: add PMU interrupt generation node Alexey Klimov

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=20260514060434.BB1E2C2BCB7@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexey.klimov@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@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