Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2a981a9
perf/x86/intel/uncore: Switch to new Intel CPU model defines
aegl Apr 24, 2024
3a1994d
perf/x86/intel/uncore: Factor out common MMIO init and ops functions
Jul 31, 2024
527fdb6
perf/x86/intel/uncore: Add Lunar Lake support
Jul 31, 2024
95992a8
perf/x86/intel/uncore: Add Panther Lake support
Jul 7, 2025
006c740
perf/x86/intel/uncore: Move uncore discovery init struct to header
ZideChen0 Dec 31, 2025
1e22691
perf/x86/intel/uncore: Support per-platform discovery base devices
ZideChen0 Dec 31, 2025
bb54522
perf/x86/intel/uncore: Remove has_generic_discovery_table()
ZideChen0 Dec 31, 2025
88861a0
perf/x86/intel/uncore: Add IMH PMON support for Diamond Rapids
ZideChen0 Dec 31, 2025
49eb786
perf/x86/intel/uncore: Add CBB PMON support for Diamond Rapids
ZideChen0 Dec 31, 2025
5531aed
perf/x86/intel/uncore: Add domain global init callback
ZideChen0 Dec 31, 2025
d6280e6
perf/x86/intel/uncore: Add freerunning event descriptor helper macro
ZideChen0 Dec 31, 2025
948fe54
perf/x86/intel/uncore: Support IIO free-running counters on DMR
ZideChen0 Dec 31, 2025
f0dc51e
perf/x86/intel/uncore: Support uncore constraint ranges
ZideChen0 Dec 31, 2025
4520be1
perf/x86/intel/uncore: Update DMR uncore constraints preliminarily
ZideChen0 Dec 31, 2025
94a053c
perf pmu: Relax uncore wildcard matching to allow numeric suffix
ZideChen0 Dec 31, 2025
5781b69
perf/x86/intel/uncore: Fix iounmap() leak on global_init failure
ZideChen0 Mar 13, 2026
f3591de
perf/x86/intel/uncore: Fix die ID init and look up bugs
ZideChen0 Mar 13, 2026
f862085
perf/x86/intel/uncore: Remove extra double quote mark
ZideChen0 Mar 13, 2026
01419dd
perf/x86/intel/uncore: Factor out topology_gidnid_map()
quanxianwang Nov 27, 2023
2ae5bd2
perf/x86/intel/uncore: Fix discovery unit lookup for multi-die systems
quanxianwang Jun 2, 2026
d46c685
perf/x86/intel/uncore: Guard against invalid box control address
quanxianwang Jun 2, 2026
56edd87
perf/x86/intel/uncore: Fix PCI device refcount leak in UPI discovery
quanxianwang Jun 2, 2026
f309456
perf/x86/intel/uncore: Move die_to_cpu() to uncore.c
quanxianwang Jun 2, 2026
e3b0173
perf/x86/intel/uncore: Fix uncore_die_to_cpu() for offline dies
quanxianwang Jun 2, 2026
4b16fb2
perf/x86/intel/uncore: Implement global init callback for GNR uncore
quanxianwang Jun 2, 2026
23ae211
perf/x86/intel/uncore: Fix PCI PMU cleanup on setup failure
quanxianwang Jun 11, 2026
a9a9d85
perf/x86/intel/uncore: Fix refcnt and other cleanups
quanxianwang Jun 11, 2026
7926e25
perf/x86/intel/uncore: Let init_box() callback report failures
quanxianwang Jun 11, 2026
d1661cd
perf/x86/intel/uncore: Keep PCI PMUs working when MMIO/MSR setup fails
quanxianwang Jun 11, 2026
f4943e1
perf/x86/intel/uncore: Factor out box setup code
quanxianwang Jun 11, 2026
6a4805a
perf/x86/intel/uncore: Introduce PMU flags and broken state
quanxianwang Jun 11, 2026
45eb679
perf/x86/intel/uncore: Fix uncore_box ref/unref ordering
quanxianwang Jun 11, 2026
7e6fc75
perf/x86/intel/uncore: Implement lazy setup for MSR/MMIO PMUs
quanxianwang Jun 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
480 changes: 273 additions & 207 deletions arch/x86/events/intel/uncore.c

Large diffs are not rendered by default.

69 changes: 61 additions & 8 deletions arch/x86/events/intel/uncore.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#define UNCORE_EXTRA_PCI_DEV_MAX 4

#define UNCORE_EVENT_CONSTRAINT(c, n) EVENT_CONSTRAINT(c, n, 0xff)
#define UNCORE_EVENT_CONSTRAINT_RANGE(c, e, n) \
EVENT_CONSTRAINT_RANGE(c, e, n, 0xff)

#define UNCORE_IGNORE_END -1

Expand All @@ -47,6 +49,25 @@ struct uncore_event_desc;
struct freerunning_counters;
struct intel_uncore_topology;

struct uncore_discovery_domain {
/* MSR address or PCI device used as the discovery base */
u32 discovery_base;
bool base_is_pci;
int (*global_init)(int die, u64 ctl);

/* The units in the discovery table should be ignored. */
int *units_ignore;
};

#define UNCORE_DISCOVERY_DOMAINS 2
struct uncore_plat_init {
void (*cpu_init)(void);
int (*pci_init)(void);
void (*mmio_init)(void);

struct uncore_discovery_domain domain[UNCORE_DISCOVERY_DOMAINS];
};

struct intel_uncore_type {
const char *name;
int num_counters;
Expand Down Expand Up @@ -108,7 +129,7 @@ struct intel_uncore_type {
#define events_group attr_groups[2]

struct intel_uncore_ops {
void (*init_box)(struct intel_uncore_box *);
int (*init_box)(struct intel_uncore_box *);
void (*exit_box)(struct intel_uncore_box *);
void (*disable_box)(struct intel_uncore_box *);
void (*enable_box)(struct intel_uncore_box *);
Expand All @@ -125,13 +146,24 @@ struct intel_uncore_pmu {
struct pmu pmu;
char name[UNCORE_PMU_NAME_LEN];
int pmu_idx;
bool registered;
unsigned long flags;
atomic_t activeboxes;
cpumask_t cpu_mask;
struct intel_uncore_type *type;
struct intel_uncore_box **boxes;
};

#define PMU_REGISTERED_BIT 0
#define PMU_BROKEN_BIT 1

#define uncore_pmu_registered(pmu) test_bit(PMU_REGISTERED_BIT, &(pmu)->flags)
#define uncore_pmu_broken(pmu) test_bit(PMU_BROKEN_BIT, &(pmu)->flags)
#define uncore_pmu_available(pmu) (uncore_pmu_registered(pmu) && \
!uncore_pmu_broken(pmu))
#define uncore_pmu_set_registered(pmu) set_bit(PMU_REGISTERED_BIT, &(pmu)->flags)
#define uncore_pmu_set_broken(pmu) set_bit(PMU_BROKEN_BIT, &(pmu)->flags)
#define uncore_pmu_clear_registered(pmu) clear_bit(PMU_REGISTERED_BIT, &(pmu)->flags)

struct intel_uncore_extra_reg {
raw_spinlock_t lock;
u64 config, config1, config2;
Expand Down Expand Up @@ -164,7 +196,7 @@ struct intel_uncore_box {
#define CFL_UNC_CBO_7_PERFEVTSEL0 0xf70
#define CFL_UNC_CBO_7_PER_CTR0 0xf76

#define UNCORE_BOX_FLAG_INITIATED 0
#define UNCORE_BOX_FLAG_INITIALIZED 0
/* event config registers are 8-byte apart */
#define UNCORE_BOX_FLAG_CTL_OFFS8 1
/* CFL 8th CBOX has different MSR space */
Expand Down Expand Up @@ -214,6 +246,7 @@ struct pci2phy_map *__find_pci2phy_map(int segment);
int uncore_pcibus_to_dieid(struct pci_bus *bus);
int uncore_die_to_segment(int die);
int uncore_device_to_die(struct pci_dev *dev);
int uncore_die_to_cpu(int die);

ssize_t uncore_event_show(struct device *dev,
struct device_attribute *attr, char *buf);
Expand Down Expand Up @@ -535,17 +568,29 @@ static inline u64 uncore_read_counter(struct intel_uncore_box *box,
return box->pmu->type->ops->read_counter(box, event);
}

static inline void uncore_box_init(struct intel_uncore_box *box)
static inline bool uncore_box_active(struct intel_uncore_box *box)
{
return (!box->pmu->type->ops->init_box ||
test_bit(UNCORE_BOX_FLAG_INITIALIZED, &box->flags));
}

static inline int uncore_box_init(struct intel_uncore_box *box)
{
if (!test_and_set_bit(UNCORE_BOX_FLAG_INITIATED, &box->flags)) {
if (box->pmu->type->ops->init_box)
box->pmu->type->ops->init_box(box);
int ret = 0;

if (!test_bit(UNCORE_BOX_FLAG_INITIALIZED, &box->flags) &&
box->pmu->type->ops->init_box) {
ret = box->pmu->type->ops->init_box(box);
if (!ret)
__set_bit(UNCORE_BOX_FLAG_INITIALIZED, &box->flags);
}

return ret;
}

static inline void uncore_box_exit(struct intel_uncore_box *box)
{
if (test_and_clear_bit(UNCORE_BOX_FLAG_INITIATED, &box->flags)) {
if (test_and_clear_bit(UNCORE_BOX_FLAG_INITIALIZED, &box->flags)) {
if (box->pmu->type->ops->exit_box)
box->pmu->type->ops->exit_box(box);
}
Expand Down Expand Up @@ -597,6 +642,8 @@ extern struct pci_extra_dev *uncore_extra_pci_dev;
extern struct event_constraint uncore_constraint_empty;
extern int spr_uncore_units_ignore[];
extern int gnr_uncore_units_ignore[];
extern int dmr_uncore_imh_units_ignore[];
extern int dmr_uncore_cbb_units_ignore[];

/* uncore_snb.c */
int snb_uncore_pci_init(void);
Expand All @@ -610,10 +657,14 @@ void skl_uncore_cpu_init(void);
void icl_uncore_cpu_init(void);
void tgl_uncore_cpu_init(void);
void adl_uncore_cpu_init(void);
void lnl_uncore_cpu_init(void);
void mtl_uncore_cpu_init(void);
void ptl_uncore_cpu_init(void);
void tgl_uncore_mmio_init(void);
void tgl_l_uncore_mmio_init(void);
void adl_uncore_mmio_init(void);
void lnl_uncore_mmio_init(void);
void ptl_uncore_mmio_init(void);
int snb_pci2phy_map_init(int devid);

/* uncore_snbep.c */
Expand Down Expand Up @@ -641,6 +692,8 @@ void spr_uncore_mmio_init(void);
int gnr_uncore_pci_init(void);
void gnr_uncore_cpu_init(void);
void gnr_uncore_mmio_init(void);
int dmr_uncore_pci_init(void);
void dmr_uncore_mmio_init(void);

/* uncore_nhmex.c */
void nhmex_uncore_cpu_init(void);
Loading