drivers/perf/hisilicon/hisi_uncore_pmu.c
Source file repositories/reference/linux-study-clean/drivers/perf/hisilicon/hisi_uncore_pmu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/perf/hisilicon/hisi_uncore_pmu.c- Extension
.c- Size
- 17548 bytes
- Lines
- 626
- Domain
- Driver Families
- Bucket
- drivers/perf
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitmap.hlinux/bitops.hlinux/bug.hlinux/err.hlinux/errno.hlinux/interrupt.hlinux/property.hasm/cputype.hasm/local64.hhisi_uncore_pmu.h
Detected Declarations
function Copyrightfunction hisi_cpumask_sysfs_showfunction hisi_associated_cpus_sysfs_showfunction hisi_uncore_pmu_identifier_attr_showfunction hisi_validate_event_groupfunction for_each_sibling_eventfunction hisi_uncore_pmu_get_event_idxfunction hisi_uncore_pmu_clear_event_idxfunction hisi_uncore_pmu_isrfunction hisi_uncore_pmu_init_irqfunction hisi_uncore_pmu_event_initfunction hisi_uncore_pmu_enable_eventfunction hisi_uncore_pmu_disable_eventfunction hisi_uncore_pmu_set_event_periodfunction hisi_uncore_pmu_event_updatefunction hisi_uncore_pmu_startfunction hisi_uncore_pmu_stopfunction hisi_uncore_pmu_addfunction hisi_uncore_pmu_delfunction hisi_uncore_pmu_readfunction hisi_uncore_pmu_enablefunction hisi_uncore_pmu_disablefunction Clusterfunction hisi_pmu_cpu_is_associated_pmufunction hisi_uncore_pmu_online_cpufunction hisi_uncore_pmu_offline_cpufunction hisi_uncore_pmu_init_topologyfunction hisi_pmu_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* HiSilicon SoC Hardware event counters support
*
* Copyright (C) 2017 HiSilicon Limited
* Author: Anurup M <anurup.m@huawei.com>
* Shaokun Zhang <zhangshaokun@hisilicon.com>
*
* This code is based on the uncore PMUs like arm-cci and arm-ccn.
*/
#include <linux/bitmap.h>
#include <linux/bitops.h>
#include <linux/bug.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/property.h>
#include <asm/cputype.h>
#include <asm/local64.h>
#include "hisi_uncore_pmu.h"
#define HISI_MAX_PERIOD(nr) (GENMASK_ULL((nr) - 1, 0))
/*
* PMU event attributes
*/
ssize_t hisi_event_sysfs_show(struct device *dev,
struct device_attribute *attr, char *page)
{
struct dev_ext_attribute *eattr;
eattr = container_of(attr, struct dev_ext_attribute, attr);
return sysfs_emit(page, "config=0x%lx\n", (unsigned long)eattr->var);
}
EXPORT_SYMBOL_NS_GPL(hisi_event_sysfs_show, "HISI_PMU");
/*
* sysfs cpumask attributes. For uncore PMU, we only have a single CPU to show
*/
ssize_t hisi_cpumask_sysfs_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct hisi_pmu *hisi_pmu = to_hisi_pmu(dev_get_drvdata(dev));
return sysfs_emit(buf, "%d\n", hisi_pmu->on_cpu);
}
EXPORT_SYMBOL_NS_GPL(hisi_cpumask_sysfs_show, "HISI_PMU");
static DEVICE_ATTR(cpumask, 0444, hisi_cpumask_sysfs_show, NULL);
static ssize_t hisi_associated_cpus_sysfs_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct hisi_pmu *hisi_pmu = to_hisi_pmu(dev_get_drvdata(dev));
return cpumap_print_to_pagebuf(true, buf, &hisi_pmu->associated_cpus);
}
static DEVICE_ATTR(associated_cpus, 0444, hisi_associated_cpus_sysfs_show, NULL);
static struct attribute *hisi_pmu_cpumask_attrs[] = {
&dev_attr_cpumask.attr,
&dev_attr_associated_cpus.attr,
NULL
};
const struct attribute_group hisi_pmu_cpumask_attr_group = {
.attrs = hisi_pmu_cpumask_attrs,
};
EXPORT_SYMBOL_NS_GPL(hisi_pmu_cpumask_attr_group, "HISI_PMU");
ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
struct device_attribute *attr,
char *page)
{
struct hisi_pmu *hisi_pmu = to_hisi_pmu(dev_get_drvdata(dev));
return sysfs_emit(page, "0x%08x\n", hisi_pmu->identifier);
}
EXPORT_SYMBOL_NS_GPL(hisi_uncore_pmu_identifier_attr_show, "HISI_PMU");
static struct device_attribute hisi_pmu_identifier_attr =
__ATTR(identifier, 0444, hisi_uncore_pmu_identifier_attr_show, NULL);
static struct attribute *hisi_pmu_identifier_attrs[] = {
&hisi_pmu_identifier_attr.attr,
NULL
};
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/bitops.h`, `linux/bug.h`, `linux/err.h`, `linux/errno.h`, `linux/interrupt.h`, `linux/property.h`, `asm/cputype.h`.
- Detected declarations: `function Copyright`, `function hisi_cpumask_sysfs_show`, `function hisi_associated_cpus_sysfs_show`, `function hisi_uncore_pmu_identifier_attr_show`, `function hisi_validate_event_group`, `function for_each_sibling_event`, `function hisi_uncore_pmu_get_event_idx`, `function hisi_uncore_pmu_clear_event_idx`, `function hisi_uncore_pmu_isr`, `function hisi_uncore_pmu_init_irq`.
- Atlas domain: Driver Families / drivers/perf.
- Implementation status: integration 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.