drivers/hwtracing/coresight/coresight-etm-perf.c
Source file repositories/reference/linux-study-clean/drivers/hwtracing/coresight/coresight-etm-perf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwtracing/coresight/coresight-etm-perf.c- Extension
.c- Size
- 26909 bytes
- Lines
- 1018
- Domain
- Driver Families
- Bucket
- drivers/hwtracing
- 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.
- 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/coresight.hlinux/coresight-pmu.hlinux/cpumask.hlinux/device.hlinux/list.hlinux/mm.hlinux/init.hlinux/perf_event.hlinux/perf/arm_pmu.hlinux/percpu-defs.hlinux/slab.hlinux/stringhash.hlinux/types.hlinux/workqueue.hcoresight-config.hcoresight-etm-perf.hcoresight-priv.hcoresight-syscfg.hcoresight-trace-id.h
Detected Declarations
struct etm_ctxtfunction format_attr_contextid_showfunction etm_event_cpu_path_ptrfunction etm_event_cpu_pathfunction etm_event_readfunction etm_event_destroyfunction etm_event_initfunction free_sink_bufferfunction free_event_datafunction for_each_cpufunction etm_free_auxfunction sinks_compatiblefunction etm_event_resumefunction etm_event_startfunction etm_event_pausefunction etm_event_stopfunction etm_setup_auxfunction etm_event_addfunction etm_event_delfunction etm_addr_filters_validatefunction list_for_each_entryfunction etm_addr_filters_syncfunction list_for_each_entryfunction etm_perf_symlinkfunction etm_perf_sink_name_showfunction etm_perf_add_symlink_groupfunction etm_perf_add_symlink_sinkfunction etm_perf_del_symlink_groupfunction etm_perf_del_symlink_sinkfunction etm_perf_cscfg_event_showfunction etm_perf_add_symlink_cscfgfunction etm_perf_del_symlink_cscfgfunction etm_perf_initfunction etm_perf_exitexport etm_perf_symlink
Annotated Snippet
struct etm_ctxt {
struct perf_output_handle handle;
struct etm_event_data *event_data;
};
static DEFINE_PER_CPU(struct etm_ctxt, etm_ctxt);
static DEFINE_PER_CPU(struct coresight_device *, csdev_src);
GEN_PMU_FORMAT_ATTR(cycacc);
GEN_PMU_FORMAT_ATTR(timestamp);
GEN_PMU_FORMAT_ATTR(retstack);
GEN_PMU_FORMAT_ATTR(sinkid);
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
GEN_PMU_FORMAT_ATTR(branch_broadcast);
/* contextid1 enables tracing CONTEXTIDR_EL1*/
GEN_PMU_FORMAT_ATTR(contextid1);
/* contextid2 enables tracing CONTEXTIDR_EL2*/
GEN_PMU_FORMAT_ATTR(contextid2);
/* preset - if sink ID is used as a configuration selector */
GEN_PMU_FORMAT_ATTR(preset);
/* config ID - set if a system configuration is selected */
GEN_PMU_FORMAT_ATTR(configid);
GEN_PMU_FORMAT_ATTR(cc_threshold);
/*
* contextid always traces the "PID". The PID is in CONTEXTIDR_EL1
* when the kernel is running at EL1; when the kernel is at EL2,
* the PID is in CONTEXTIDR_EL2.
*/
static ssize_t format_attr_contextid_show(struct device *dev,
struct device_attribute *attr,
char *page)
{
if (is_kernel_in_hyp_mode())
return contextid2_show(dev, attr, page);
return contextid1_show(dev, attr, page);
}
static struct device_attribute format_attr_contextid =
__ATTR(contextid, 0444, format_attr_contextid_show, NULL);
#endif
/*
* ETMv3 only uses the first 3 attributes for programming itself (see
* ETM3X_SUPPORTED_OPTIONS). Sink ID is also supported for selecting a
* sink in both, but not used for configuring the ETM. The remaining
* attributes are ETMv4 specific.
*/
static struct attribute *etm_config_formats_attr[] = {
&format_attr_cycacc.attr,
&format_attr_timestamp.attr,
&format_attr_retstack.attr,
&format_attr_sinkid.attr,
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
&format_attr_contextid.attr,
&format_attr_contextid1.attr,
&format_attr_contextid2.attr,
&format_attr_preset.attr,
&format_attr_configid.attr,
&format_attr_branch_broadcast.attr,
&format_attr_cc_threshold.attr,
#endif
NULL,
};
static const struct attribute_group etm_pmu_format_group = {
.name = "format",
.attrs = etm_config_formats_attr,
};
static struct attribute *etm_config_sinks_attr[] = {
NULL,
};
static const struct attribute_group etm_pmu_sinks_group = {
.name = "sinks",
.attrs = etm_config_sinks_attr,
};
static struct attribute *etm_config_events_attr[] = {
NULL,
};
static const struct attribute_group etm_pmu_events_group = {
.name = "events",
.attrs = etm_config_events_attr,
};
static const struct attribute_group *etm_pmu_attr_groups[] = {
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/coresight.h`, `linux/coresight-pmu.h`, `linux/cpumask.h`, `linux/device.h`, `linux/list.h`, `linux/mm.h`, `linux/init.h`.
- Detected declarations: `struct etm_ctxt`, `function format_attr_contextid_show`, `function etm_event_cpu_path_ptr`, `function etm_event_cpu_path`, `function etm_event_read`, `function etm_event_destroy`, `function etm_event_init`, `function free_sink_buffer`, `function free_event_data`, `function for_each_cpu`.
- Atlas domain: Driver Families / drivers/hwtracing.
- Implementation status: integration implementation candidate.
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.