drivers/fpga/dfl-fme-perf.c
Source file repositories/reference/linux-study-clean/drivers/fpga/dfl-fme-perf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/fpga/dfl-fme-perf.c- Extension
.c- Size
- 30226 bytes
- Lines
- 1023
- Domain
- Driver Families
- Bucket
- drivers/fpga
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/perf_event.hdfl.hdfl-fme.h
Detected Declarations
struct fme_perf_privstruct fme_perf_event_opsfunction cpumask_showfunction is_portid_rootfunction is_portid_portfunction is_portid_root_or_portfunction fme_read_perf_cntr_regfunction basic_event_initfunction basic_read_event_counterfunction cache_event_initfunction cache_read_event_counterfunction is_fabric_event_supportedfunction fabric_event_initfunction fabric_event_destroyfunction fabric_read_event_counterfunction vtd_event_initfunction vtd_read_event_counterfunction vtd_sip_event_initfunction vtd_sip_read_event_counterfunction fme_perf_event_showfunction fme_perf_events_visiblefunction fme_perf_fabric_events_visiblefunction fme_perf_event_destroyfunction fme_perf_event_initfunction fme_perf_event_updatefunction fme_perf_event_startfunction fme_perf_event_stopfunction fme_perf_event_addfunction fme_perf_event_delfunction fme_perf_event_readfunction fme_perf_setup_hardwarefunction fme_perf_pmu_registerfunction fme_perf_pmu_unregisterfunction fme_perf_offline_cpufunction fme_perf_initfunction fme_perf_uinit
Annotated Snippet
struct fme_perf_priv {
struct device *dev;
void __iomem *ioaddr;
struct pmu pmu;
u16 id;
u32 fab_users;
u32 fab_port_id;
spinlock_t fab_lock;
unsigned int cpu;
struct hlist_node node;
enum cpuhp_state cpuhp_state;
};
/**
* struct fme_perf_event_ops - callbacks for fme perf events
*
* @event_init: callback invoked during event init.
* @event_destroy: callback invoked during event destroy.
* @read_counter: callback to read hardware counters.
*/
struct fme_perf_event_ops {
int (*event_init)(struct fme_perf_priv *priv, u32 event, u32 portid);
void (*event_destroy)(struct fme_perf_priv *priv, u32 event,
u32 portid);
u64 (*read_counter)(struct fme_perf_priv *priv, u32 event, u32 portid);
};
#define to_fme_perf_priv(_pmu) container_of(_pmu, struct fme_perf_priv, pmu)
static ssize_t cpumask_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct pmu *pmu = dev_get_drvdata(dev);
struct fme_perf_priv *priv;
priv = to_fme_perf_priv(pmu);
return cpumap_print_to_pagebuf(true, buf, cpumask_of(priv->cpu));
}
static DEVICE_ATTR_RO(cpumask);
static struct attribute *fme_perf_cpumask_attrs[] = {
&dev_attr_cpumask.attr,
NULL,
};
static const struct attribute_group fme_perf_cpumask_group = {
.attrs = fme_perf_cpumask_attrs,
};
#define FME_EVENT_MASK GENMASK_ULL(11, 0)
#define FME_EVENT_SHIFT 0
#define FME_EVTYPE_MASK GENMASK_ULL(15, 12)
#define FME_EVTYPE_SHIFT 12
#define FME_EVTYPE_BASIC 0
#define FME_EVTYPE_CACHE 1
#define FME_EVTYPE_FABRIC 2
#define FME_EVTYPE_VTD 3
#define FME_EVTYPE_VTD_SIP 4
#define FME_EVTYPE_MAX FME_EVTYPE_VTD_SIP
#define FME_PORTID_MASK GENMASK_ULL(23, 16)
#define FME_PORTID_SHIFT 16
#define FME_PORTID_ROOT (0xffU)
#define get_event(_config) FIELD_GET(FME_EVENT_MASK, _config)
#define get_evtype(_config) FIELD_GET(FME_EVTYPE_MASK, _config)
#define get_portid(_config) FIELD_GET(FME_PORTID_MASK, _config)
PMU_FORMAT_ATTR(event, "config:0-11");
PMU_FORMAT_ATTR(evtype, "config:12-15");
PMU_FORMAT_ATTR(portid, "config:16-23");
static struct attribute *fme_perf_format_attrs[] = {
&format_attr_event.attr,
&format_attr_evtype.attr,
&format_attr_portid.attr,
NULL,
};
static const struct attribute_group fme_perf_format_group = {
.name = "format",
.attrs = fme_perf_format_attrs,
};
/*
* There are no default events, but we need to create
* "events" group (with empty attrs) before updating
* it with detected events (using pmu->attr_update).
Annotation
- Immediate include surface: `linux/perf_event.h`, `dfl.h`, `dfl-fme.h`.
- Detected declarations: `struct fme_perf_priv`, `struct fme_perf_event_ops`, `function cpumask_show`, `function is_portid_root`, `function is_portid_port`, `function is_portid_root_or_port`, `function fme_read_perf_cntr_reg`, `function basic_event_init`, `function basic_read_event_counter`, `function cache_event_init`.
- Atlas domain: Driver Families / drivers/fpga.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.