Skip to content

Commit 80580da

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/uncore: Apply the unit control RB tree to MMIO uncore units
The unit control RB tree has the unit control and unit ID information for all the units. Use it to replace the box_ctls/mmio_offsets to get an accurate unit control address for MMIO uncore units. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Yunying Sun <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 585463f commit 80580da

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

arch/x86/events/intel/uncore_discovery.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -606,34 +606,30 @@ static struct intel_uncore_ops generic_uncore_pci_ops = {
606606

607607
#define UNCORE_GENERIC_MMIO_SIZE 0x4000
608608

609-
static u64 generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
610-
{
611-
struct intel_uncore_type *type = box->pmu->type;
612-
613-
if (!type->box_ctls || !type->box_ctls[box->dieid] || !type->mmio_offsets)
614-
return 0;
615-
616-
return type->box_ctls[box->dieid] + type->mmio_offsets[box->pmu->pmu_idx];
617-
}
618-
619609
void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box)
620610
{
621-
u64 box_ctl = generic_uncore_mmio_box_ctl(box);
611+
static struct intel_uncore_discovery_unit *unit;
622612
struct intel_uncore_type *type = box->pmu->type;
623613
resource_size_t addr;
624614

625-
if (!box_ctl) {
615+
unit = intel_uncore_find_discovery_unit(type->boxes, box->dieid, box->pmu->pmu_idx);
616+
if (!unit) {
617+
pr_warn("Uncore type %d id %d: Cannot find box control address.\n",
618+
type->type_id, box->pmu->pmu_idx);
619+
return;
620+
}
621+
622+
if (!unit->addr) {
626623
pr_warn("Uncore type %d box %d: Invalid box control address.\n",
627-
type->type_id, type->box_ids[box->pmu->pmu_idx]);
624+
type->type_id, unit->id);
628625
return;
629626
}
630627

631-
addr = box_ctl;
628+
addr = unit->addr;
632629
box->io_addr = ioremap(addr, UNCORE_GENERIC_MMIO_SIZE);
633630
if (!box->io_addr) {
634631
pr_warn("Uncore type %d box %d: ioremap error for 0x%llx.\n",
635-
type->type_id, type->box_ids[box->pmu->pmu_idx],
636-
(unsigned long long)addr);
632+
type->type_id, unit->id, (unsigned long long)addr);
637633
return;
638634
}
639635

@@ -722,6 +718,8 @@ static bool uncore_update_uncore_type(enum uncore_access_type type_id,
722718
uncore->box_ctls = type->box_ctrl_die;
723719
uncore->mmio_offsets = type->box_offset;
724720
uncore->mmio_map_size = UNCORE_GENERIC_MMIO_SIZE;
721+
uncore->boxes = &type->units;
722+
uncore->num_boxes = type->num_units;
725723
break;
726724
default:
727725
return false;

0 commit comments

Comments
 (0)