Skip to content

Commit bd9514a

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/uncore: Ignore broken units in discovery table
Some units in a discovery table may be broken, e.g., UPI of SPR MCC. A generic method is required to ignore the broken units. Add uncore_units_ignore in the struct intel_uncore_init_fun, which indicates the type ID of broken units. It will be assigned by the platform-specific code later when the platform has a broken discovery table. Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Michael Petlan <mpetlan@redhat.com> Link: https://lore.kernel.org/r/20230112200105.733466-4-kan.liang@linux.intel.com
1 parent 3af548f commit bd9514a

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,10 @@ struct intel_uncore_init_fun {
16951695
void (*cpu_init)(void);
16961696
int (*pci_init)(void);
16971697
void (*mmio_init)(void);
1698+
/* Discovery table is required */
16981699
bool use_discovery;
1700+
/* The units in the discovery table should be ignored. */
1701+
int *uncore_units_ignore;
16991702
};
17001703

17011704
static const struct intel_uncore_init_fun nhm_uncore_init __initconst = {
@@ -1874,15 +1877,16 @@ static int __init intel_uncore_init(void)
18741877

18751878
id = x86_match_cpu(intel_uncore_match);
18761879
if (!id) {
1877-
if (!uncore_no_discover && intel_uncore_has_discovery_tables())
1880+
if (!uncore_no_discover && intel_uncore_has_discovery_tables(NULL))
18781881
uncore_init = (struct intel_uncore_init_fun *)&generic_uncore_init;
18791882
else
18801883
return -ENODEV;
18811884
} else {
18821885
uncore_init = (struct intel_uncore_init_fun *)id->driver_data;
18831886
if (uncore_no_discover && uncore_init->use_discovery)
18841887
return -ENODEV;
1885-
if (uncore_init->use_discovery && !intel_uncore_has_discovery_tables())
1888+
if (uncore_init->use_discovery &&
1889+
!intel_uncore_has_discovery_tables(uncore_init->uncore_units_ignore))
18861890
return -ENODEV;
18871891
}
18881892

arch/x86/events/intel/uncore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
#define UNCORE_EVENT_CONSTRAINT(c, n) EVENT_CONSTRAINT(c, n, 0xff)
3636

37+
#define UNCORE_IGNORE_END -1
38+
3739
struct pci_extra_dev {
3840
struct pci_dev *dev[UNCORE_EXTRA_PCI_DEV_MAX];
3941
};

arch/x86/events/intel/uncore_discovery.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,25 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit,
190190

191191
}
192192

193+
static bool
194+
uncore_ignore_unit(struct uncore_unit_discovery *unit, int *ignore)
195+
{
196+
int i;
197+
198+
if (!ignore)
199+
return false;
200+
201+
for (i = 0; ignore[i] != UNCORE_IGNORE_END ; i++) {
202+
if (unit->box_type == ignore[i])
203+
return true;
204+
}
205+
206+
return false;
207+
}
208+
193209
static int parse_discovery_table(struct pci_dev *dev, int die,
194-
u32 bar_offset, bool *parsed)
210+
u32 bar_offset, bool *parsed,
211+
int *ignore)
195212
{
196213
struct uncore_global_discovery global;
197214
struct uncore_unit_discovery unit;
@@ -246,6 +263,9 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
246263
if (unit.access_type >= UNCORE_ACCESS_MAX)
247264
continue;
248265

266+
if (uncore_ignore_unit(&unit, ignore))
267+
continue;
268+
249269
uncore_insert_box_info(&unit, die, *parsed);
250270
}
251271

@@ -254,7 +274,7 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
254274
return 0;
255275
}
256276

257-
bool intel_uncore_has_discovery_tables(void)
277+
bool intel_uncore_has_discovery_tables(int *ignore)
258278
{
259279
u32 device, val, entry_id, bar_offset;
260280
int die, dvsec = 0, ret = true;
@@ -290,7 +310,7 @@ bool intel_uncore_has_discovery_tables(void)
290310
if (die < 0)
291311
continue;
292312

293-
parse_discovery_table(dev, die, bar_offset, &parsed);
313+
parse_discovery_table(dev, die, bar_offset, &parsed, ignore);
294314
}
295315
}
296316

arch/x86/events/intel/uncore_discovery.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ struct intel_uncore_discovery_type {
122122
unsigned int *box_offset; /* Box offset */
123123
};
124124

125-
bool intel_uncore_has_discovery_tables(void);
125+
bool intel_uncore_has_discovery_tables(int *ignore);
126126
void intel_uncore_clear_discovery_tables(void);
127127
void intel_uncore_generic_uncore_cpu_init(void);
128128
int intel_uncore_generic_uncore_pci_init(void);

0 commit comments

Comments
 (0)