Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: "Johnny.Fan" <johnny.fan@cixtech.com>
Cc: will@kernel.org, mark.rutland@arm.com,
	linux-arm-kernel@lists.infradead.org,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	james.clark@linaro.org, leo.yan@arm.com, jeremy.linton@arm.com,
	cix-kernel-upstream@cixtech.com, bob.zhang@cixtech.com,
	jie.fu@cixtech.com, "Johnny.Fan" <Johnny.Fan@cixtech.com>,
	Fugang Duan <fugang.duan@cixtech.com>
Subject: Re: [PATCH] perf: arm_spe: Support heterogeneous ACPI systems
Date: Thu, 15 Oct 2026 11:49:24 +0100	[thread overview]
Message-ID: <86mrsf1bnv.wl-maz@kernel.org> (raw)
In-Reply-To: <20261015062908.3565761-1-johnny.fan@cixtech.com>

On Thu, 15 Oct 2026 07:29:08 +0100,
"Johnny.Fan" <johnny.fan@cixtech.com> wrote:
> 
> From: "Johnny.Fan" <Johnny.Fan@cixtech.com>
> 
> The ACPI MADT describes the SPE overflow interrupt on a per-CPU basis
> in the GICC structure, where a CPU that does not implement SPE simply
> reports 0. Heterogeneous systems therefore only report the interrupt
> on the CPUs that implement SPE, but arm_pmu_acpi.c rejects this as a
> non-homogeneous mapping and never creates the SPE platform device.
> 
> Treat the SPE interrupt as optional when walking the MADT: skip the
> GICCs that report 0 and only require that the CPUs which do report it
> agree on the number.
> 
> Note that the CPUs reporting the interrupt must still share a single
> GSI, as the platform device only exposes one IRQ resource. A system
> that assigns a different PPI per cluster cannot be described by this
> single-device model.
> 
> The CPUs without SPE are trimmed from the PMU supported CPUs by
> probing PMSVer on each CPU, both at probe time (for online CPUs) and
> from the hotplug callback (for CPUs that were offline at probe), as
> ACPI conveys no affinity information and the PPI otherwise defaults
> to all possible CPUs.

This is a bit odd: at the beginning, you are stating that the SPE
interrupt being 0 is an indication of SPE not being supported. Then
you check for PMSVer for the same properly. This seems pretty wrong.

It should be possible to build the mask of SPE-enabled CPUs without
IPI-ing the other CPUs, and only rely on the firmware table.

> 
> Tested on a CIX sky1 SoC with heterogeneous SPE support.
> 
> Signed-off-by: Johnny.Fan <Johnny.Fan@cixtech.com>
> 
> Reviewed-by: Fugang Duan <fugang.duan@cixtech.com>
> ---
>  drivers/perf/arm_pmu_acpi.c | 34 +++++++++++++++++++++++-------
>  drivers/perf/arm_spe_pmu.c  | 41 ++++++++++++++++++++++++++++++++++---
>  2 files changed, 65 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c
> index ca6bf8f86cfe..4ece1070827b 100644
> --- a/drivers/perf/arm_pmu_acpi.c
> +++ b/drivers/perf/arm_pmu_acpi.c
> @@ -70,7 +70,8 @@ static void arm_pmu_acpi_unregister_irq(int cpu)
>  
>  static int __maybe_unused
>  arm_acpi_register_pmu_device(struct platform_device *pdev, u8 len,
> -			     u16 (*parse_gsi)(struct acpi_madt_generic_interrupt *))
> +			     u16 (*parse_gsi)(struct acpi_madt_generic_interrupt *),
> +			     bool optional)
>  {
>  	int cpu, this_hetid, hetid, irq, ret;
>  	u16 this_gsi = 0, gsi = 0;
> @@ -87,7 +88,9 @@ arm_acpi_register_pmu_device(struct platform_device *pdev, u8 len,
>  
>  	/*
>  	 * Sanity check all the GICC tables for the same interrupt
> -	 * number. For now, only support homogeneous ACPI machines.
> +	 * number. For now, only support homogeneous ACPI machines,
> +	 * unless the interrupt is optional, in which case a CPU that
> +	 * does not implement the feature simply reports 0.
>  	 */
>  	for_each_possible_cpu(cpu) {
>  		struct acpi_madt_generic_interrupt *gicc;
> @@ -97,6 +100,20 @@ arm_acpi_register_pmu_device(struct platform_device *pdev, u8 len,
>  			return gsi ? -ENXIO : 0;
>  
>  		this_gsi = parse_gsi(gicc);
> +
> +		if (optional) {
> +			if (!this_gsi)
> +				continue;
> +
> +			if (gsi && gsi != this_gsi) {
> +				pr_warn("ACPI: %s: CPU%d: inconsistent interrupt %u/%u\n",
> +					pdev->name, cpu, gsi, this_gsi);
> +				return -ENXIO;
> +			}
> +			gsi = this_gsi;
> +			continue;
> +		}
> +

This "optional" parameter feels very wrong. We now have an
infrastructure to get a set of affinities for an interrupt (see
5324fe21ba9b7 and following patches). What this needs is ACPI to be
plumbed into this.

Unfortunately, ACPI is awkward and very badly abstracted in this area,
but that doesn't mean we should make the driver code more bizarre.

Treating SPE and TRBE differently is just as odd, and there is no
reason to do other than suiting your particular platform.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.


  reply	other threads:[~2026-10-15 10:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  6:29 [PATCH] perf: arm_spe: Support heterogeneous ACPI systems Johnny.Fan
2026-10-15 10:49 ` Marc Zyngier [this message]
2026-10-15 11:52   ` Johnny Fan
2026-10-15 15:58     ` Jeremy Linton
2026-10-15 14:19   ` Leo Yan

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=86mrsf1bnv.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=bob.zhang@cixtech.com \
    --cc=cix-kernel-upstream@cixtech.com \
    --cc=fugang.duan@cixtech.com \
    --cc=james.clark@linaro.org \
    --cc=jeremy.linton@arm.com \
    --cc=jie.fu@cixtech.com \
    --cc=johnny.fan@cixtech.com \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=will@kernel.org \
    /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