drivers/perf/amlogic/meson_ddr_pmu_core.c
Source file repositories/reference/linux-study-clean/drivers/perf/amlogic/meson_ddr_pmu_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/perf/amlogic/meson_ddr_pmu_core.c- Extension
.c- Size
- 14376 bytes
- Lines
- 565
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/init.hlinux/irqreturn.hlinux/kernel.hlinux/module.hlinux/of.hlinux/perf_event.hlinux/platform_device.hlinux/printk.hlinux/sysfs.hlinux/types.hsoc/amlogic/meson_ddr_pmu.h
Detected Declarations
struct ddr_pmufunction dmc_pmu_enablefunction dmc_pmu_disablefunction meson_ddr_set_axi_filterfunction ddr_cnt_additionfunction meson_ddr_perf_event_updatefunction meson_ddr_perf_event_initfunction meson_ddr_perf_event_startfunction meson_ddr_perf_event_addfunction meson_ddr_perf_event_stopfunction meson_ddr_perf_event_delfunction meson_ddr_perf_cpumask_showfunction pmu_event_showfunction event_show_unitfunction event_show_scalefunction meson_ddr_perf_format_attr_visiblefunction meson_ddr_perf_identifier_showfunction dmc_irq_handlerfunction ddr_perf_offline_cpufunction fill_event_attrfunction fmt_attr_fillfunction ddr_pmu_parse_dtfunction meson_ddr_pmu_createfunction meson_ddr_pmu_remove
Annotated Snippet
struct ddr_pmu {
struct pmu pmu;
struct dmc_info info;
struct dmc_counter counters; /* save counters from hw */
bool pmu_enabled;
struct device *dev;
char *name;
struct hlist_node node;
enum cpuhp_state cpuhp_state;
int cpu; /* for cpu hotplug */
};
#define DDR_PERF_DEV_NAME "meson_ddr_bw"
#define MAX_AXI_PORTS_OF_CHANNEL 4 /* A DMC channel can monitor max 4 axi ports */
#define to_ddr_pmu(p) container_of(p, struct ddr_pmu, pmu)
#define dmc_info_to_pmu(p) container_of(p, struct ddr_pmu, info)
static void dmc_pmu_enable(struct ddr_pmu *pmu)
{
if (!pmu->pmu_enabled)
pmu->info.hw_info->enable(&pmu->info);
pmu->pmu_enabled = true;
}
static void dmc_pmu_disable(struct ddr_pmu *pmu)
{
if (pmu->pmu_enabled)
pmu->info.hw_info->disable(&pmu->info);
pmu->pmu_enabled = false;
}
static void meson_ddr_set_axi_filter(struct perf_event *event, u8 axi_id)
{
struct ddr_pmu *pmu = to_ddr_pmu(event->pmu);
int chann;
if (event->attr.config > ALL_CHAN_COUNTER_ID &&
event->attr.config < COUNTER_MAX_ID) {
chann = event->attr.config - CHAN1_COUNTER_ID;
pmu->info.hw_info->set_axi_filter(&pmu->info, axi_id, chann);
}
}
static void ddr_cnt_addition(struct dmc_counter *sum,
struct dmc_counter *add1,
struct dmc_counter *add2,
int chann_nr)
{
int i;
u64 cnt1, cnt2;
sum->all_cnt = add1->all_cnt + add2->all_cnt;
sum->all_req = add1->all_req + add2->all_req;
for (i = 0; i < chann_nr; i++) {
cnt1 = add1->channel_cnt[i];
cnt2 = add2->channel_cnt[i];
sum->channel_cnt[i] = cnt1 + cnt2;
}
}
static void meson_ddr_perf_event_update(struct perf_event *event)
{
struct ddr_pmu *pmu = to_ddr_pmu(event->pmu);
u64 new_raw_count = 0;
struct dmc_counter dc = {0}, sum_dc = {0};
int idx;
int chann_nr = pmu->info.hw_info->chann_nr;
/* get the remain counters in register. */
pmu->info.hw_info->get_counters(&pmu->info, &dc);
ddr_cnt_addition(&sum_dc, &pmu->counters, &dc, chann_nr);
switch (event->attr.config) {
case ALL_CHAN_COUNTER_ID:
new_raw_count = sum_dc.all_cnt;
break;
case CHAN1_COUNTER_ID:
case CHAN2_COUNTER_ID:
case CHAN3_COUNTER_ID:
case CHAN4_COUNTER_ID:
case CHAN5_COUNTER_ID:
case CHAN6_COUNTER_ID:
case CHAN7_COUNTER_ID:
case CHAN8_COUNTER_ID:
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/init.h`, `linux/irqreturn.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/perf_event.h`, `linux/platform_device.h`.
- Detected declarations: `struct ddr_pmu`, `function dmc_pmu_enable`, `function dmc_pmu_disable`, `function meson_ddr_set_axi_filter`, `function ddr_cnt_addition`, `function meson_ddr_perf_event_update`, `function meson_ddr_perf_event_init`, `function meson_ddr_perf_event_start`, `function meson_ddr_perf_event_add`, `function meson_ddr_perf_event_stop`.
- 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.