drivers/perf/xgene_pmu.c

Source file repositories/reference/linux-study-clean/drivers/perf/xgene_pmu.c

File Facts

System
Linux kernel
Corpus path
drivers/perf/xgene_pmu.c
Extension
.c
Size
56955 bytes
Lines
1956
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct hw_pmu_info {
	u32 type;
	u32 enable_mask;
	void __iomem *csr;
};

struct xgene_pmu_dev {
	struct hw_pmu_info *inf;
	struct xgene_pmu *parent;
	struct pmu pmu;
	u8 max_counters;
	DECLARE_BITMAP(cntr_assign_mask, PMU_MAX_COUNTERS);
	u64 max_period;
	const struct attribute_group **attr_groups;
	struct perf_event *pmu_counter_event[PMU_MAX_COUNTERS];
};

struct xgene_pmu_ops {
	void (*mask_int)(struct xgene_pmu *pmu);
	void (*unmask_int)(struct xgene_pmu *pmu);
	u64 (*read_counter)(struct xgene_pmu_dev *pmu, int idx);
	void (*write_counter)(struct xgene_pmu_dev *pmu, int idx, u64 val);
	void (*write_evttype)(struct xgene_pmu_dev *pmu_dev, int idx, u32 val);
	void (*write_agentmsk)(struct xgene_pmu_dev *pmu_dev, u32 val);
	void (*write_agent1msk)(struct xgene_pmu_dev *pmu_dev, u32 val);
	void (*enable_counter)(struct xgene_pmu_dev *pmu_dev, int idx);
	void (*disable_counter)(struct xgene_pmu_dev *pmu_dev, int idx);
	void (*enable_counter_int)(struct xgene_pmu_dev *pmu_dev, int idx);
	void (*disable_counter_int)(struct xgene_pmu_dev *pmu_dev, int idx);
	void (*reset_counters)(struct xgene_pmu_dev *pmu_dev);
	void (*start_counters)(struct xgene_pmu_dev *pmu_dev);
	void (*stop_counters)(struct xgene_pmu_dev *pmu_dev);
};

struct xgene_pmu {
	struct device *dev;
	struct hlist_node node;
	int version;
	void __iomem *pcppmu_csr;
	u32 mcb_active_mask;
	u32 mc_active_mask;
	u32 l3c_active_mask;
	cpumask_t cpu;
	int irq;
	raw_spinlock_t lock;
	const struct xgene_pmu_ops *ops;
	struct list_head l3cpmus;
	struct list_head iobpmus;
	struct list_head mcbpmus;
	struct list_head mcpmus;
};

struct xgene_pmu_dev_ctx {
	char *name;
	struct list_head next;
	struct xgene_pmu_dev *pmu_dev;
	struct hw_pmu_info inf;
};

struct xgene_pmu_data {
	int id;
	u32 data;
};

enum xgene_pmu_version {
	PCP_PMU_V1 = 1,
	PCP_PMU_V2,
	PCP_PMU_V3,
};

enum xgene_pmu_dev_type {
	PMU_TYPE_L3C = 0,
	PMU_TYPE_IOB,
	PMU_TYPE_IOB_SLOW,
	PMU_TYPE_MCB,
	PMU_TYPE_MC,
};

/*
 * sysfs format attributes
 */
#define XGENE_PMU_FORMAT_ATTR(_name, _config)		\
	(&((struct dev_ext_attribute[]) {		\
		{ .attr = __ATTR(_name, S_IRUGO, device_show_string, NULL), \
		  .var = (void *) _config, }		\
	})[0].attr.attr)

static struct attribute *l3c_pmu_format_attrs[] = {
	XGENE_PMU_FORMAT_ATTR(l3c_eventid, "config:0-7"),
	XGENE_PMU_FORMAT_ATTR(l3c_agentid, "config1:0-9"),

Annotation

Implementation Notes