Skip to content

Commit c54c53d

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Add Sapphire Rapids server framework
Intel Sapphire Rapids supports a discovery mechanism, that allows an uncore driver to discover the different components ("boxes") of the chip. All the generic information of the uncore boxes should be retrieved from the discovery tables. This has been enabled with the commit edae1f0 ("perf/x86/intel/uncore: Parse uncore discovery tables"). Add use_discovery to indicate the case. The uncore driver doesn't need to hard code the generic information for each uncore box. But we still need to enable various functionality that cannot be directly discovered. To support these functionalities, the Sapphire Rapids server framework is introduced here. Each specific uncore unit will be added into the framework in the following patches. Add use_discovery to indicate that the discovery mechanism is required for the platform. Currently, Intel Sapphire Rapids is one of the platforms. The box ID from the discovery table is the accurate index. Use it if applicable. All the undiscovered platform-specific features will be hard code in the spr_uncores[]. Add uncore_type_customized_copy(), instead of the memcpy, to only overwrite these features. The specific uncore unit hasn't been added here. From user's perspective, there is nothing changed for now. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Andi Kleen <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 012669c commit c54c53d

File tree

5 files changed

+116
-5
lines changed

5 files changed

+116
-5
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,13 @@ static void uncore_get_pmu_name(struct intel_uncore_pmu *pmu)
865865
sprintf(pmu->name, "uncore_%s", type->name);
866866
else
867867
sprintf(pmu->name, "uncore");
868-
} else
869-
sprintf(pmu->name, "uncore_%s_%d", type->name, pmu->pmu_idx);
870-
868+
} else {
869+
/*
870+
* Use the box ID from the discovery table if applicable.
871+
*/
872+
sprintf(pmu->name, "uncore_%s_%d", type->name,
873+
type->box_ids ? type->box_ids[pmu->pmu_idx] : pmu->pmu_idx);
874+
}
871875
}
872876

873877
static int uncore_pmu_register(struct intel_uncore_pmu *pmu)
@@ -1663,6 +1667,7 @@ struct intel_uncore_init_fun {
16631667
void (*cpu_init)(void);
16641668
int (*pci_init)(void);
16651669
void (*mmio_init)(void);
1670+
bool use_discovery;
16661671
};
16671672

16681673
static const struct intel_uncore_init_fun nhm_uncore_init __initconst = {
@@ -1765,6 +1770,13 @@ static const struct intel_uncore_init_fun snr_uncore_init __initconst = {
17651770
.mmio_init = snr_uncore_mmio_init,
17661771
};
17671772

1773+
static const struct intel_uncore_init_fun spr_uncore_init __initconst = {
1774+
.cpu_init = spr_uncore_cpu_init,
1775+
.pci_init = spr_uncore_pci_init,
1776+
.mmio_init = spr_uncore_mmio_init,
1777+
.use_discovery = true,
1778+
};
1779+
17681780
static const struct intel_uncore_init_fun generic_uncore_init __initconst = {
17691781
.cpu_init = intel_uncore_generic_uncore_cpu_init,
17701782
.pci_init = intel_uncore_generic_uncore_pci_init,
@@ -1809,6 +1821,7 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {
18091821
X86_MATCH_INTEL_FAM6_MODEL(ROCKETLAKE, &rkl_uncore_init),
18101822
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE, &adl_uncore_init),
18111823
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, &adl_uncore_init),
1824+
X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, &spr_uncore_init),
18121825
X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, &snr_uncore_init),
18131826
{},
18141827
};
@@ -1832,8 +1845,13 @@ static int __init intel_uncore_init(void)
18321845
uncore_init = (struct intel_uncore_init_fun *)&generic_uncore_init;
18331846
else
18341847
return -ENODEV;
1835-
} else
1848+
} else {
18361849
uncore_init = (struct intel_uncore_init_fun *)id->driver_data;
1850+
if (uncore_no_discover && uncore_init->use_discovery)
1851+
return -ENODEV;
1852+
if (uncore_init->use_discovery && !intel_uncore_has_discovery_tables())
1853+
return -ENODEV;
1854+
}
18371855

18381856
if (uncore_init->pci_init) {
18391857
pret = uncore_init->pci_init();

arch/x86/events/intel/uncore.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,9 @@ void snr_uncore_mmio_init(void);
608608
int icx_uncore_pci_init(void);
609609
void icx_uncore_cpu_init(void);
610610
void icx_uncore_mmio_init(void);
611+
int spr_uncore_pci_init(void);
612+
void spr_uncore_cpu_init(void);
613+
void spr_uncore_mmio_init(void);
611614

612615
/* uncore_nhmex.c */
613616
void nhmex_uncore_cpu_init(void);

arch/x86/events/intel/uncore_discovery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ static bool uncore_update_uncore_type(enum uncore_access_type type_id,
568568
return true;
569569
}
570570

571-
static struct intel_uncore_type **
571+
struct intel_uncore_type **
572572
intel_uncore_generic_init_uncores(enum uncore_access_type type_id)
573573
{
574574
struct intel_uncore_discovery_type *type;

arch/x86/events/intel/uncore_discovery.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,6 @@ void intel_uncore_clear_discovery_tables(void);
129129
void intel_uncore_generic_uncore_cpu_init(void);
130130
int intel_uncore_generic_uncore_pci_init(void);
131131
void intel_uncore_generic_uncore_mmio_init(void);
132+
133+
struct intel_uncore_type **
134+
intel_uncore_generic_init_uncores(enum uncore_access_type type_id);

arch/x86/events/intel/uncore_snbep.c

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/* SandyBridge-EP/IvyTown uncore support */
33
#include "uncore.h"
4+
#include "uncore_discovery.h"
45

56
/* SNB-EP pci bus to socket mapping */
67
#define SNBEP_CPUNODEID 0x40
@@ -5504,3 +5505,89 @@ void icx_uncore_mmio_init(void)
55045505
}
55055506

55065507
/* end of ICX uncore support */
5508+
5509+
/* SPR uncore support */
5510+
5511+
#define UNCORE_SPR_NUM_UNCORE_TYPES 12
5512+
5513+
static struct intel_uncore_type *spr_uncores[UNCORE_SPR_NUM_UNCORE_TYPES] = {
5514+
NULL,
5515+
NULL,
5516+
NULL,
5517+
NULL,
5518+
NULL,
5519+
NULL,
5520+
NULL,
5521+
NULL,
5522+
NULL,
5523+
NULL,
5524+
NULL,
5525+
NULL,
5526+
};
5527+
5528+
static void uncore_type_customized_copy(struct intel_uncore_type *to_type,
5529+
struct intel_uncore_type *from_type)
5530+
{
5531+
if (!to_type || !from_type)
5532+
return;
5533+
5534+
if (from_type->name)
5535+
to_type->name = from_type->name;
5536+
if (from_type->fixed_ctr_bits)
5537+
to_type->fixed_ctr_bits = from_type->fixed_ctr_bits;
5538+
if (from_type->event_mask)
5539+
to_type->event_mask = from_type->event_mask;
5540+
if (from_type->event_mask_ext)
5541+
to_type->event_mask_ext = from_type->event_mask_ext;
5542+
if (from_type->fixed_ctr)
5543+
to_type->fixed_ctr = from_type->fixed_ctr;
5544+
if (from_type->fixed_ctl)
5545+
to_type->fixed_ctl = from_type->fixed_ctl;
5546+
if (from_type->fixed_ctr_bits)
5547+
to_type->fixed_ctr_bits = from_type->fixed_ctr_bits;
5548+
if (from_type->num_shared_regs)
5549+
to_type->num_shared_regs = from_type->num_shared_regs;
5550+
if (from_type->constraints)
5551+
to_type->constraints = from_type->constraints;
5552+
if (from_type->ops)
5553+
to_type->ops = from_type->ops;
5554+
if (from_type->event_descs)
5555+
to_type->event_descs = from_type->event_descs;
5556+
if (from_type->format_group)
5557+
to_type->format_group = from_type->format_group;
5558+
}
5559+
5560+
static struct intel_uncore_type **
5561+
uncore_get_uncores(enum uncore_access_type type_id)
5562+
{
5563+
struct intel_uncore_type **types, **start_types;
5564+
5565+
start_types = types = intel_uncore_generic_init_uncores(type_id);
5566+
5567+
/* Only copy the customized features */
5568+
for (; *types; types++) {
5569+
if ((*types)->type_id >= UNCORE_SPR_NUM_UNCORE_TYPES)
5570+
continue;
5571+
uncore_type_customized_copy(*types, spr_uncores[(*types)->type_id]);
5572+
}
5573+
5574+
return start_types;
5575+
}
5576+
5577+
void spr_uncore_cpu_init(void)
5578+
{
5579+
uncore_msr_uncores = uncore_get_uncores(UNCORE_ACCESS_MSR);
5580+
}
5581+
5582+
int spr_uncore_pci_init(void)
5583+
{
5584+
uncore_pci_uncores = uncore_get_uncores(UNCORE_ACCESS_PCI);
5585+
return 0;
5586+
}
5587+
5588+
void spr_uncore_mmio_init(void)
5589+
{
5590+
uncore_mmio_uncores = uncore_get_uncores(UNCORE_ACCESS_MMIO);
5591+
}
5592+
5593+
/* end of SPR uncore support */

0 commit comments

Comments
 (0)