drivers/perf/arm_pmu_platform.c
Source file repositories/reference/linux-study-clean/drivers/perf/arm_pmu_platform.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/perf/arm_pmu_platform.c- Extension
.c- Size
- 5665 bytes
- Lines
- 248
- Domain
- Driver Families
- Bucket
- drivers/perf
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bug.hlinux/cpumask.hlinux/device.hlinux/errno.hlinux/irq.hlinux/irqdesc.hlinux/kconfig.hlinux/of.hlinux/percpu.hlinux/perf/arm_pmu.hlinux/platform_device.hlinux/printk.hlinux/smp.h
Detected Declarations
function Copyrightfunction pmu_parse_percpu_irqfunction pmu_has_irq_affinityfunction pmu_parse_irq_affinityfunction pmu_parse_irqsfunction armpmu_request_irqsfunction for_each_cpufunction armpmu_free_irqsfunction for_each_cpufunction arm_pmu_device_probe
Annotated Snippet
if (irq_is_percpu_devid(irq)) {
dev_warn(dev, "multiple PPIs or mismatched SPI/PPI detected\n");
return -EINVAL;
}
cpu = pmu_parse_irq_affinity(dev, i);
if (cpu < 0)
return cpu;
if (cpu >= nr_cpu_ids)
continue;
if (per_cpu(hw_events->irq, cpu)) {
dev_warn(dev, "multiple PMU IRQs for the same CPU detected\n");
return -EINVAL;
}
per_cpu(hw_events->irq, cpu) = irq;
cpumask_set_cpu(cpu, &pmu->supported_cpus);
}
return 0;
}
static int armpmu_request_irqs(struct arm_pmu *armpmu)
{
struct pmu_hw_events __percpu *hw_events = armpmu->hw_events;
int cpu, err = 0;
for_each_cpu(cpu, &armpmu->supported_cpus) {
int irq = per_cpu(hw_events->irq, cpu);
if (!irq)
continue;
err = armpmu_request_irq(&hw_events->percpu_pmu, irq, cpu);
if (err)
break;
}
return err;
}
static void armpmu_free_irqs(struct arm_pmu *armpmu)
{
int cpu;
struct pmu_hw_events __percpu *hw_events = armpmu->hw_events;
for_each_cpu(cpu, &armpmu->supported_cpus) {
int irq = per_cpu(hw_events->irq, cpu);
armpmu_free_irq(&hw_events->percpu_pmu, irq, cpu);
}
}
int arm_pmu_device_probe(struct platform_device *pdev,
const struct of_device_id *of_table,
const struct pmu_probe_info *probe_table)
{
armpmu_init_fn init_fn;
struct device *dev = &pdev->dev;
struct arm_pmu *pmu;
int ret = -ENODEV;
pmu = armpmu_alloc();
if (!pmu)
return -ENOMEM;
pmu->pmu.parent = &pdev->dev;
pmu->plat_device = pdev;
ret = pmu_parse_irqs(pmu);
if (ret)
goto out_free;
init_fn = of_device_get_match_data(dev);
if (init_fn) {
pmu->secure_access = of_property_read_bool(dev->of_node,
"secure-reg-access");
/* arm64 systems boot only as non-secure */
if (IS_ENABLED(CONFIG_ARM64) && pmu->secure_access) {
dev_warn(dev, "ignoring \"secure-reg-access\" property for arm64\n");
pmu->secure_access = false;
}
ret = init_fn(pmu);
} else if (probe_table) {
cpumask_setall(&pmu->supported_cpus);
ret = probe_current_pmu(pmu, probe_table);
}
Annotation
- Immediate include surface: `linux/bug.h`, `linux/cpumask.h`, `linux/device.h`, `linux/errno.h`, `linux/irq.h`, `linux/irqdesc.h`, `linux/kconfig.h`, `linux/of.h`.
- Detected declarations: `function Copyright`, `function pmu_parse_percpu_irq`, `function pmu_has_irq_affinity`, `function pmu_parse_irq_affinity`, `function pmu_parse_irqs`, `function armpmu_request_irqs`, `function for_each_cpu`, `function armpmu_free_irqs`, `function for_each_cpu`, `function arm_pmu_device_probe`.
- Atlas domain: Driver Families / drivers/perf.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.