Commit ad51b504 authored by Mark Rutland's avatar Mark Rutland Committed by Will Deacon

arm_pmu: acpi: factor out PMU<->CPU association

A subsequent patch will rework the ACPI probing of PMUs, and we'll need
to associate a CPU with a PMU in two separate paths.

Factor out the association logic into a helper function so that it can
be reused.

There should be no functional change as a result of this patch.
Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Will Deacon <will@kernel.org>
Reviewed-and-tested-by: default avatarPierre Gondois <pierre.gondois@arm.com>
Link: https://lore.kernel.org/r/20220930111844.1522365-2-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent 05da178c
...@@ -242,6 +242,22 @@ static bool pmu_irq_matches(struct arm_pmu *pmu, int irq) ...@@ -242,6 +242,22 @@ static bool pmu_irq_matches(struct arm_pmu *pmu, int irq)
return true; return true;
} }
static void arm_pmu_acpi_associate_pmu_cpu(struct arm_pmu *pmu,
unsigned int cpu)
{
int irq = per_cpu(pmu_irqs, cpu);
per_cpu(probed_pmus, cpu) = pmu;
if (pmu_irq_matches(pmu, irq)) {
struct pmu_hw_events __percpu *hw_events;
hw_events = pmu->hw_events;
per_cpu(hw_events->irq, cpu) = irq;
}
cpumask_set_cpu(cpu, &pmu->supported_cpus);
}
/* /*
* This must run before the common arm_pmu hotplug logic, so that we can * This must run before the common arm_pmu hotplug logic, so that we can
* associate a CPU and its interrupt before the common code tries to manage the * associate a CPU and its interrupt before the common code tries to manage the
...@@ -254,27 +270,16 @@ static bool pmu_irq_matches(struct arm_pmu *pmu, int irq) ...@@ -254,27 +270,16 @@ static bool pmu_irq_matches(struct arm_pmu *pmu, int irq)
static int arm_pmu_acpi_cpu_starting(unsigned int cpu) static int arm_pmu_acpi_cpu_starting(unsigned int cpu)
{ {
struct arm_pmu *pmu; struct arm_pmu *pmu;
struct pmu_hw_events __percpu *hw_events;
int irq;
/* If we've already probed this CPU, we have nothing to do */ /* If we've already probed this CPU, we have nothing to do */
if (per_cpu(probed_pmus, cpu)) if (per_cpu(probed_pmus, cpu))
return 0; return 0;
irq = per_cpu(pmu_irqs, cpu);
pmu = arm_pmu_acpi_find_alloc_pmu(); pmu = arm_pmu_acpi_find_alloc_pmu();
if (!pmu) if (!pmu)
return -ENOMEM; return -ENOMEM;
per_cpu(probed_pmus, cpu) = pmu; arm_pmu_acpi_associate_pmu_cpu(pmu, cpu);
if (pmu_irq_matches(pmu, irq)) {
hw_events = pmu->hw_events;
per_cpu(hw_events->irq, cpu) = irq;
}
cpumask_set_cpu(cpu, &pmu->supported_cpus);
/* /*
* Ideally, we'd probe the PMU here when we find the first matching * Ideally, we'd probe the PMU here when we find the first matching
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment