Commit 15a4bd51 authored by Kan Liang's avatar Kan Liang Committed by Peter Zijlstra

perf/x86/uncore: Cleanup unused unit structure

The unit control and ID information are retrieved from the unit control
RB tree. No one uses the old structure anymore. Remove them.
Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: default avatarYunying Sun <yunying.sun@intel.com>
Link: https://lore.kernel.org/r/20240614134631.1092359-8-kan.liang@linux.intel.com
parent f76a8420
...@@ -868,7 +868,7 @@ static inline int uncore_get_box_id(struct intel_uncore_type *type, ...@@ -868,7 +868,7 @@ static inline int uncore_get_box_id(struct intel_uncore_type *type,
if (type->boxes) if (type->boxes)
return intel_uncore_find_discovery_unit_id(type->boxes, -1, pmu->pmu_idx); return intel_uncore_find_discovery_unit_id(type->boxes, -1, pmu->pmu_idx);
return type->box_ids ? type->box_ids[pmu->pmu_idx] : pmu->pmu_idx; return pmu->pmu_idx;
} }
void uncore_get_alias_name(char *pmu_name, struct intel_uncore_pmu *pmu) void uncore_get_alias_name(char *pmu_name, struct intel_uncore_pmu *pmu)
...@@ -980,10 +980,7 @@ static void uncore_type_exit(struct intel_uncore_type *type) ...@@ -980,10 +980,7 @@ static void uncore_type_exit(struct intel_uncore_type *type)
kfree(type->pmus); kfree(type->pmus);
type->pmus = NULL; type->pmus = NULL;
} }
if (type->box_ids) {
kfree(type->box_ids);
type->box_ids = NULL;
}
kfree(type->events_group); kfree(type->events_group);
type->events_group = NULL; type->events_group = NULL;
} }
......
...@@ -62,7 +62,6 @@ struct intel_uncore_type { ...@@ -62,7 +62,6 @@ struct intel_uncore_type {
unsigned fixed_ctr; unsigned fixed_ctr;
unsigned fixed_ctl; unsigned fixed_ctl;
unsigned box_ctl; unsigned box_ctl;
u64 *box_ctls; /* Unit ctrl addr of the first box of each die */
union { union {
unsigned msr_offset; unsigned msr_offset;
unsigned mmio_offset; unsigned mmio_offset;
...@@ -76,7 +75,6 @@ struct intel_uncore_type { ...@@ -76,7 +75,6 @@ struct intel_uncore_type {
u64 *pci_offsets; u64 *pci_offsets;
u64 *mmio_offsets; u64 *mmio_offsets;
}; };
unsigned *box_ids;
struct event_constraint unconstrainted; struct event_constraint unconstrainted;
struct event_constraint *constraints; struct event_constraint *constraints;
struct intel_uncore_pmu *pmus; struct intel_uncore_pmu *pmus;
......
...@@ -89,10 +89,6 @@ add_uncore_discovery_type(struct uncore_unit_discovery *unit) ...@@ -89,10 +89,6 @@ add_uncore_discovery_type(struct uncore_unit_discovery *unit)
if (!type) if (!type)
return NULL; return NULL;
type->box_ctrl_die = kcalloc(__uncore_max_dies, sizeof(u64), GFP_KERNEL);
if (!type->box_ctrl_die)
goto free_type;
type->units = RB_ROOT; type->units = RB_ROOT;
type->access_type = unit->access_type; type->access_type = unit->access_type;
...@@ -102,12 +98,6 @@ add_uncore_discovery_type(struct uncore_unit_discovery *unit) ...@@ -102,12 +98,6 @@ add_uncore_discovery_type(struct uncore_unit_discovery *unit)
rb_add(&type->node, &discovery_tables, __type_less); rb_add(&type->node, &discovery_tables, __type_less);
return type; return type;
free_type:
kfree(type);
return NULL;
} }
static struct intel_uncore_discovery_type * static struct intel_uncore_discovery_type *
...@@ -230,13 +220,10 @@ void uncore_find_add_unit(struct intel_uncore_discovery_unit *node, ...@@ -230,13 +220,10 @@ void uncore_find_add_unit(struct intel_uncore_discovery_unit *node,
static void static void
uncore_insert_box_info(struct uncore_unit_discovery *unit, uncore_insert_box_info(struct uncore_unit_discovery *unit,
int die, bool parsed) int die)
{ {
struct intel_uncore_discovery_unit *node; struct intel_uncore_discovery_unit *node;
struct intel_uncore_discovery_type *type; struct intel_uncore_discovery_type *type;
unsigned int *ids;
u64 *box_offset;
int i;
if (!unit->ctl || !unit->ctl_offset || !unit->ctr_offset) { if (!unit->ctl || !unit->ctl_offset || !unit->ctr_offset) {
pr_info("Invalid address is detected for uncore type %d box %d, " pr_info("Invalid address is detected for uncore type %d box %d, "
...@@ -253,79 +240,21 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit, ...@@ -253,79 +240,21 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit,
node->id = unit->box_id; node->id = unit->box_id;
node->addr = unit->ctl; node->addr = unit->ctl;
if (parsed) { type = get_uncore_discovery_type(unit);
type = search_uncore_discovery_type(unit->box_type); if (!type) {
if (!type) { kfree(node);
pr_info("A spurious uncore type %d is detected, "
"Disable the uncore type.\n",
unit->box_type);
kfree(node);
return;
}
uncore_find_add_unit(node, &type->units, &type->num_units);
/* Store the first box of each die */
if (!type->box_ctrl_die[die])
type->box_ctrl_die[die] = unit->ctl;
return; return;
} }
type = get_uncore_discovery_type(unit);
if (!type)
goto free_node;
box_offset = kcalloc(type->num_boxes + 1, sizeof(u64), GFP_KERNEL);
if (!box_offset)
goto free_node;
ids = kcalloc(type->num_boxes + 1, sizeof(unsigned int), GFP_KERNEL);
if (!ids)
goto free_box_offset;
uncore_find_add_unit(node, &type->units, &type->num_units); uncore_find_add_unit(node, &type->units, &type->num_units);
/* Store generic information for the first box */ /* Store generic information for the first box */
if (!type->num_boxes) { if (type->num_units == 1) {
type->box_ctrl = unit->ctl;
type->box_ctrl_die[die] = unit->ctl;
type->num_counters = unit->num_regs; type->num_counters = unit->num_regs;
type->counter_width = unit->bit_width; type->counter_width = unit->bit_width;
type->ctl_offset = unit->ctl_offset; type->ctl_offset = unit->ctl_offset;
type->ctr_offset = unit->ctr_offset; type->ctr_offset = unit->ctr_offset;
*ids = unit->box_id;
goto end;
} }
for (i = 0; i < type->num_boxes; i++) {
ids[i] = type->ids[i];
box_offset[i] = type->box_offset[i];
if (unit->box_id == ids[i]) {
pr_info("Duplicate uncore type %d box ID %d is detected, "
"Drop the duplicate uncore unit.\n",
unit->box_type, unit->box_id);
goto free_ids;
}
}
ids[i] = unit->box_id;
box_offset[i] = unit->ctl - type->box_ctrl;
kfree(type->ids);
kfree(type->box_offset);
end:
type->ids = ids;
type->box_offset = box_offset;
type->num_boxes++;
return;
free_ids:
kfree(ids);
free_box_offset:
kfree(box_offset);
free_node:
kfree(node);
} }
static bool static bool
...@@ -404,7 +333,7 @@ static int parse_discovery_table(struct pci_dev *dev, int die, ...@@ -404,7 +333,7 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
if (uncore_ignore_unit(&unit, ignore)) if (uncore_ignore_unit(&unit, ignore))
continue; continue;
uncore_insert_box_info(&unit, die, *parsed); uncore_insert_box_info(&unit, die);
} }
*parsed = true; *parsed = true;
...@@ -474,7 +403,6 @@ void intel_uncore_clear_discovery_tables(void) ...@@ -474,7 +403,6 @@ void intel_uncore_clear_discovery_tables(void)
rb_erase(node, &type->units); rb_erase(node, &type->units);
kfree(pos); kfree(pos);
} }
kfree(type->box_ctrl_die);
kfree(type); kfree(type);
} }
} }
...@@ -738,41 +666,23 @@ static bool uncore_update_uncore_type(enum uncore_access_type type_id, ...@@ -738,41 +666,23 @@ static bool uncore_update_uncore_type(enum uncore_access_type type_id,
struct intel_uncore_discovery_type *type) struct intel_uncore_discovery_type *type)
{ {
uncore->type_id = type->type; uncore->type_id = type->type;
uncore->num_boxes = type->num_boxes;
uncore->num_counters = type->num_counters; uncore->num_counters = type->num_counters;
uncore->perf_ctr_bits = type->counter_width; uncore->perf_ctr_bits = type->counter_width;
uncore->box_ids = type->ids; uncore->perf_ctr = (unsigned int)type->ctr_offset;
uncore->event_ctl = (unsigned int)type->ctl_offset;
uncore->boxes = &type->units;
uncore->num_boxes = type->num_units;
switch (type_id) { switch (type_id) {
case UNCORE_ACCESS_MSR: case UNCORE_ACCESS_MSR:
uncore->ops = &generic_uncore_msr_ops; uncore->ops = &generic_uncore_msr_ops;
uncore->perf_ctr = (unsigned int)type->ctr_offset;
uncore->event_ctl = (unsigned int)type->ctl_offset;
uncore->box_ctl = (unsigned int)type->box_ctrl;
uncore->msr_offsets = type->box_offset;
uncore->boxes = &type->units;
uncore->num_boxes = type->num_units;
break; break;
case UNCORE_ACCESS_PCI: case UNCORE_ACCESS_PCI:
uncore->ops = &generic_uncore_pci_ops; uncore->ops = &generic_uncore_pci_ops;
uncore->perf_ctr = (unsigned int)UNCORE_DISCOVERY_PCI_BOX_CTRL(type->box_ctrl) + type->ctr_offset;
uncore->event_ctl = (unsigned int)UNCORE_DISCOVERY_PCI_BOX_CTRL(type->box_ctrl) + type->ctl_offset;
uncore->box_ctl = (unsigned int)UNCORE_DISCOVERY_PCI_BOX_CTRL(type->box_ctrl);
uncore->box_ctls = type->box_ctrl_die;
uncore->pci_offsets = type->box_offset;
uncore->boxes = &type->units;
uncore->num_boxes = type->num_units;
break; break;
case UNCORE_ACCESS_MMIO: case UNCORE_ACCESS_MMIO:
uncore->ops = &generic_uncore_mmio_ops; uncore->ops = &generic_uncore_mmio_ops;
uncore->perf_ctr = (unsigned int)type->ctr_offset;
uncore->event_ctl = (unsigned int)type->ctl_offset;
uncore->box_ctl = (unsigned int)type->box_ctrl;
uncore->box_ctls = type->box_ctrl_die;
uncore->mmio_offsets = type->box_offset;
uncore->mmio_map_size = UNCORE_GENERIC_MMIO_SIZE; uncore->mmio_map_size = UNCORE_GENERIC_MMIO_SIZE;
uncore->boxes = &type->units;
uncore->num_boxes = type->num_units;
break; break;
default: default:
return false; return false;
......
...@@ -124,18 +124,13 @@ struct intel_uncore_discovery_unit { ...@@ -124,18 +124,13 @@ struct intel_uncore_discovery_unit {
struct intel_uncore_discovery_type { struct intel_uncore_discovery_type {
struct rb_node node; struct rb_node node;
enum uncore_access_type access_type; enum uncore_access_type access_type;
u64 box_ctrl; /* Unit ctrl addr of the first box */
u64 *box_ctrl_die; /* Unit ctrl addr of the first box of each die */
struct rb_root units; /* Unit ctrl addr for all units */ struct rb_root units; /* Unit ctrl addr for all units */
u16 type; /* Type ID of the uncore block */ u16 type; /* Type ID of the uncore block */
u8 num_counters; u8 num_counters;
u8 counter_width; u8 counter_width;
u8 ctl_offset; /* Counter Control 0 offset */ u8 ctl_offset; /* Counter Control 0 offset */
u8 ctr_offset; /* Counter 0 offset */ u8 ctr_offset; /* Counter 0 offset */
u16 num_boxes; /* number of boxes for the uncore block */
u16 num_units; /* number of units */ u16 num_units; /* number of units */
unsigned int *ids; /* Box IDs */
u64 *box_offset; /* Box offset */
}; };
bool intel_uncore_has_discovery_tables(int *ignore); bool intel_uncore_has_discovery_tables(int *ignore);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment