2015-07-02 19:27:02

by Liang, Kan

[permalink] [raw]
Subject: [PATCH 1/1] perf/x86/intel/uncore: Add Broadwell-DE uncore support

From: Kan Liang <[email protected]>

The uncore subsystem for Broadwell-DE is similar to Haswell-EP.
There are some differences in pci device IDs, box number and
constraints.
Please refer to the public document.
http://www.intel.com/content/www/us/en/processors/xeon/
xeon-d-1500-uncore-performance-monitoring.html

Signed-off-by: Kan Liang <[email protected]>
---
arch/x86/kernel/cpu/perf_event_intel_uncore.c | 6 +
arch/x86/kernel/cpu/perf_event_intel_uncore.h | 2 +
.../x86/kernel/cpu/perf_event_intel_uncore_snbep.c | 164 +++++++++++++++++++++
3 files changed, 172 insertions(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 21b5e38..e255fcb 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -911,6 +911,9 @@ static int __init uncore_pci_init(void)
case 63: /* Haswell-EP */
ret = hswep_uncore_pci_init();
break;
+ case 86: /* BDX-DE */
+ ret = bdx_uncore_pci_init();
+ break;
case 42: /* Sandy Bridge */
ret = snb_uncore_pci_init();
break;
@@ -1224,6 +1227,9 @@ static int __init uncore_cpu_init(void)
case 63: /* Haswell-EP */
hswep_uncore_cpu_init();
break;
+ case 86: /* BDX-DE */
+ bdx_uncore_cpu_init();
+ break;
default:
return 0;
}
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
index 0f77f0a..72c54c2 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
@@ -336,6 +336,8 @@ int ivbep_uncore_pci_init(void);
void ivbep_uncore_cpu_init(void);
int hswep_uncore_pci_init(void);
void hswep_uncore_cpu_init(void);
+int bdx_uncore_pci_init(void);
+void bdx_uncore_cpu_init(void);

/* perf_event_intel_uncore_nhmex.c */
void nhmex_uncore_cpu_init(void);
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
index 6d6e85d..c0f678c 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
@@ -2321,3 +2321,167 @@ int hswep_uncore_pci_init(void)
return 0;
}
/* end of Haswell-EP uncore support */
+
+/* BDX-DE uncore support */
+
+static struct intel_uncore_type bdx_uncore_ubox = {
+ .name = "ubox",
+ .num_counters = 2,
+ .num_boxes = 1,
+ .perf_ctr_bits = 48,
+ .fixed_ctr_bits = 48,
+ .perf_ctr = HSWEP_U_MSR_PMON_CTR0,
+ .event_ctl = HSWEP_U_MSR_PMON_CTL0,
+ .event_mask = SNBEP_U_MSR_PMON_RAW_EVENT_MASK,
+ .fixed_ctr = HSWEP_U_MSR_PMON_UCLK_FIXED_CTR,
+ .fixed_ctl = HSWEP_U_MSR_PMON_UCLK_FIXED_CTL,
+ .num_shared_regs = 1,
+ .ops = &ivbep_uncore_msr_ops,
+ .format_group = &ivbep_uncore_ubox_format_group,
+};
+
+static struct event_constraint bdx_uncore_cbox_constraints[] = {
+ UNCORE_EVENT_CONSTRAINT(0x09, 0x3),
+ UNCORE_EVENT_CONSTRAINT(0x11, 0x1),
+ UNCORE_EVENT_CONSTRAINT(0x36, 0x1),
+ EVENT_CONSTRAINT_END
+};
+
+static struct intel_uncore_type bdx_uncore_cbox = {
+ .name = "cbox",
+ .num_counters = 4,
+ .num_boxes = 8,
+ .perf_ctr_bits = 48,
+ .event_ctl = HSWEP_C0_MSR_PMON_CTL0,
+ .perf_ctr = HSWEP_C0_MSR_PMON_CTR0,
+ .event_mask = SNBEP_CBO_MSR_PMON_RAW_EVENT_MASK,
+ .box_ctl = HSWEP_C0_MSR_PMON_BOX_CTL,
+ .msr_offset = HSWEP_CBO_MSR_OFFSET,
+ .num_shared_regs = 1,
+ .constraints = bdx_uncore_cbox_constraints,
+ .ops = &hswep_uncore_cbox_ops,
+ .format_group = &hswep_uncore_cbox_format_group,
+};
+
+static struct intel_uncore_type *bdx_msr_uncores[] = {
+ &bdx_uncore_ubox,
+ &bdx_uncore_cbox,
+ &hswep_uncore_pcu,
+ NULL,
+};
+
+void bdx_uncore_cpu_init(void)
+{
+ if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores)
+ bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores;
+ uncore_msr_uncores = bdx_msr_uncores;
+}
+
+static struct intel_uncore_type bdx_uncore_ha = {
+ .name = "ha",
+ .num_counters = 4,
+ .num_boxes = 1,
+ .perf_ctr_bits = 48,
+ SNBEP_UNCORE_PCI_COMMON_INIT(),
+};
+
+static struct intel_uncore_type bdx_uncore_imc = {
+ .name = "imc",
+ .num_counters = 5,
+ .num_boxes = 2,
+ .perf_ctr_bits = 48,
+ .fixed_ctr_bits = 48,
+ .fixed_ctr = SNBEP_MC_CHy_PCI_PMON_FIXED_CTR,
+ .fixed_ctl = SNBEP_MC_CHy_PCI_PMON_FIXED_CTL,
+ .event_descs = hswep_uncore_imc_events,
+ SNBEP_UNCORE_PCI_COMMON_INIT(),
+};
+
+static struct intel_uncore_type bdx_uncore_irp = {
+ .name = "irp",
+ .num_counters = 4,
+ .num_boxes = 1,
+ .perf_ctr_bits = 48,
+ .event_mask = SNBEP_PMON_RAW_EVENT_MASK,
+ .box_ctl = SNBEP_PCI_PMON_BOX_CTL,
+ .ops = &hswep_uncore_irp_ops,
+ .format_group = &snbep_uncore_format_group,
+};
+
+
+static struct event_constraint bdx_uncore_r2pcie_constraints[] = {
+ UNCORE_EVENT_CONSTRAINT(0x10, 0x3),
+ UNCORE_EVENT_CONSTRAINT(0x11, 0x3),
+ UNCORE_EVENT_CONSTRAINT(0x13, 0x1),
+ UNCORE_EVENT_CONSTRAINT(0x23, 0x1),
+ UNCORE_EVENT_CONSTRAINT(0x25, 0x1),
+ UNCORE_EVENT_CONSTRAINT(0x26, 0x3),
+ UNCORE_EVENT_CONSTRAINT(0x2d, 0x3),
+ EVENT_CONSTRAINT_END
+};
+
+static struct intel_uncore_type bdx_uncore_r2pcie = {
+ .name = "r2pcie",
+ .num_counters = 4,
+ .num_boxes = 1,
+ .perf_ctr_bits = 48,
+ .constraints = bdx_uncore_r2pcie_constraints,
+ SNBEP_UNCORE_PCI_COMMON_INIT(),
+};
+
+enum {
+ BDX_PCI_UNCORE_HA,
+ BDX_PCI_UNCORE_IMC,
+ BDX_PCI_UNCORE_IRP,
+ BDX_PCI_UNCORE_R2PCIE,
+};
+
+static struct intel_uncore_type *bdx_pci_uncores[] = {
+ [BDX_PCI_UNCORE_HA] = &bdx_uncore_ha,
+ [BDX_PCI_UNCORE_IMC] = &bdx_uncore_imc,
+ [BDX_PCI_UNCORE_IRP] = &bdx_uncore_irp,
+ [BDX_PCI_UNCORE_R2PCIE] = &bdx_uncore_r2pcie,
+ NULL,
+};
+
+static DEFINE_PCI_DEVICE_TABLE(bdx_uncore_pci_ids) = {
+ { /* Home Agent 0 */
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f30),
+ .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_HA, 0),
+ },
+ { /* MC0 Channel 0 */
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb0),
+ .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 0),
+ },
+ { /* MC0 Channel 1 */
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb1),
+ .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 1),
+ },
+ { /* IRP */
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f39),
+ .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IRP, 0),
+ },
+ { /* R2PCIe */
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f34),
+ .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_R2PCIE, 0),
+ },
+ { /* end: all zeroes */ }
+};
+
+static struct pci_driver bdx_uncore_pci_driver = {
+ .name = "bdx_uncore",
+ .id_table = bdx_uncore_pci_ids,
+};
+
+int bdx_uncore_pci_init(void)
+{
+ int ret = snbep_pci2phy_map_init(0x6f1e);
+
+ if (ret)
+ return ret;
+ uncore_pci_uncores = bdx_pci_uncores;
+ uncore_pci_driver = &bdx_uncore_pci_driver;
+ return 0;
+}
+
+/* end of BDX-DE uncore support */
--
1.8.3.1


2015-07-10 08:20:54

by Stephane Eranian

[permalink] [raw]
Subject: Re: [PATCH 1/1] perf/x86/intel/uncore: Add Broadwell-DE uncore support

Hi,

On Thu, Jul 2, 2015 at 5:12 AM, <[email protected]> wrote:
>
> From: Kan Liang <[email protected]>
>
> The uncore subsystem for Broadwell-DE is similar to Haswell-EP.
> There are some differences in pci device IDs, box number and
> constraints.
> Please refer to the public document.
> http://www.intel.com/content/www/us/en/processors/xeon/
> xeon-d-1500-uncore-performance-monitoring.html
>
> Signed-off-by: Kan Liang <[email protected]>
> ---
> arch/x86/kernel/cpu/perf_event_intel_uncore.c | 6 +
> arch/x86/kernel/cpu/perf_event_intel_uncore.h | 2 +
> .../x86/kernel/cpu/perf_event_intel_uncore_snbep.c | 164 +++++++++++++++++++++
> 3 files changed, 172 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
> index 21b5e38..e255fcb 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
> @@ -911,6 +911,9 @@ static int __init uncore_pci_init(void)
> case 63: /* Haswell-EP */
> ret = hswep_uncore_pci_init();
> break;
> + case 86: /* BDX-DE */
> + ret = bdx_uncore_pci_init();
> + break;
> case 42: /* Sandy Bridge */
> ret = snb_uncore_pci_init();
> break;
> @@ -1224,6 +1227,9 @@ static int __init uncore_cpu_init(void)
> case 63: /* Haswell-EP */
> hswep_uncore_cpu_init();
> break;
> + case 86: /* BDX-DE */
> + bdx_uncore_cpu_init();
> + break;
> default:
> return 0;
> }
> diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
> index 0f77f0a..72c54c2 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
> +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
> @@ -336,6 +336,8 @@ int ivbep_uncore_pci_init(void);
> void ivbep_uncore_cpu_init(void);
> int hswep_uncore_pci_init(void);
> void hswep_uncore_cpu_init(void);
> +int bdx_uncore_pci_init(void);
> +void bdx_uncore_cpu_init(void);
>
> /* perf_event_intel_uncore_nhmex.c */
> void nhmex_uncore_cpu_init(void);
> diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
> index 6d6e85d..c0f678c 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
> @@ -2321,3 +2321,167 @@ int hswep_uncore_pci_init(void)
> return 0;
> }
> /* end of Haswell-EP uncore support */
> +
> +/* BDX-DE uncore support */
> +
> +static struct intel_uncore_type bdx_uncore_ubox = {
> + .name = "ubox",
> + .num_counters = 2,
> + .num_boxes = 1,
> + .perf_ctr_bits = 48,
> + .fixed_ctr_bits = 48,
> + .perf_ctr = HSWEP_U_MSR_PMON_CTR0,
> + .event_ctl = HSWEP_U_MSR_PMON_CTL0,
> + .event_mask = SNBEP_U_MSR_PMON_RAW_EVENT_MASK,
> + .fixed_ctr = HSWEP_U_MSR_PMON_UCLK_FIXED_CTR,
> + .fixed_ctl = HSWEP_U_MSR_PMON_UCLK_FIXED_CTL,
> + .num_shared_regs = 1,
> + .ops = &ivbep_uncore_msr_ops,
> + .format_group = &ivbep_uncore_ubox_format_group,
> +};
> +
> +static struct event_constraint bdx_uncore_cbox_constraints[] = {
> + UNCORE_EVENT_CONSTRAINT(0x09, 0x3),
> + UNCORE_EVENT_CONSTRAINT(0x11, 0x1),
> + UNCORE_EVENT_CONSTRAINT(0x36, 0x1),
> + EVENT_CONSTRAINT_END
> +};
> +
> +static struct intel_uncore_type bdx_uncore_cbox = {
> + .name = "cbox",
> + .num_counters = 4,
> + .num_boxes = 8,
> + .perf_ctr_bits = 48,
> + .event_ctl = HSWEP_C0_MSR_PMON_CTL0,
> + .perf_ctr = HSWEP_C0_MSR_PMON_CTR0,
> + .event_mask = SNBEP_CBO_MSR_PMON_RAW_EVENT_MASK,
> + .box_ctl = HSWEP_C0_MSR_PMON_BOX_CTL,
> + .msr_offset = HSWEP_CBO_MSR_OFFSET,
> + .num_shared_regs = 1,
> + .constraints = bdx_uncore_cbox_constraints,
> + .ops = &hswep_uncore_cbox_ops,
> + .format_group = &hswep_uncore_cbox_format_group,
> +};
> +
> +static struct intel_uncore_type *bdx_msr_uncores[] = {
> + &bdx_uncore_ubox,
> + &bdx_uncore_cbox,
> + &hswep_uncore_pcu,
> + NULL,
> +};
> +
> +void bdx_uncore_cpu_init(void)
> +{
> + if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores)
> + bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores;
> + uncore_msr_uncores = bdx_msr_uncores;
> +}
> +
> +static struct intel_uncore_type bdx_uncore_ha = {
> + .name = "ha",
> + .num_counters = 4,
> + .num_boxes = 1,
> + .perf_ctr_bits = 48,
> + SNBEP_UNCORE_PCI_COMMON_INIT(),
> +};
> +
> +static struct intel_uncore_type bdx_uncore_imc = {
> + .name = "imc",
> + .num_counters = 5,
> + .num_boxes = 2,
> + .perf_ctr_bits = 48,
> + .fixed_ctr_bits = 48,
> + .fixed_ctr = SNBEP_MC_CHy_PCI_PMON_FIXED_CTR,
> + .fixed_ctl = SNBEP_MC_CHy_PCI_PMON_FIXED_CTL,
> + .event_descs = hswep_uncore_imc_events,
> + SNBEP_UNCORE_PCI_COMMON_INIT(),
> +};
> +
> +static struct intel_uncore_type bdx_uncore_irp = {
> + .name = "irp",
> + .num_counters = 4,
> + .num_boxes = 1,
> + .perf_ctr_bits = 48,
> + .event_mask = SNBEP_PMON_RAW_EVENT_MASK,
> + .box_ctl = SNBEP_PCI_PMON_BOX_CTL,
> + .ops = &hswep_uncore_irp_ops,
> + .format_group = &snbep_uncore_format_group,
> +};
> +
> +
> +static struct event_constraint bdx_uncore_r2pcie_constraints[] = {
> + UNCORE_EVENT_CONSTRAINT(0x10, 0x3),
> + UNCORE_EVENT_CONSTRAINT(0x11, 0x3),
> + UNCORE_EVENT_CONSTRAINT(0x13, 0x1),
> + UNCORE_EVENT_CONSTRAINT(0x23, 0x1),
> + UNCORE_EVENT_CONSTRAINT(0x25, 0x1),
> + UNCORE_EVENT_CONSTRAINT(0x26, 0x3),
> + UNCORE_EVENT_CONSTRAINT(0x2d, 0x3),
> + EVENT_CONSTRAINT_END
> +};
> +
> +static struct intel_uncore_type bdx_uncore_r2pcie = {
> + .name = "r2pcie",
> + .num_counters = 4,
> + .num_boxes = 1,
> + .perf_ctr_bits = 48,
> + .constraints = bdx_uncore_r2pcie_constraints,
> + SNBEP_UNCORE_PCI_COMMON_INIT(),
> +};
> +
> +enum {
> + BDX_PCI_UNCORE_HA,
> + BDX_PCI_UNCORE_IMC,
> + BDX_PCI_UNCORE_IRP,
> + BDX_PCI_UNCORE_R2PCIE,
> +};
> +
> +static struct intel_uncore_type *bdx_pci_uncores[] = {
> + [BDX_PCI_UNCORE_HA] = &bdx_uncore_ha,
> + [BDX_PCI_UNCORE_IMC] = &bdx_uncore_imc,
> + [BDX_PCI_UNCORE_IRP] = &bdx_uncore_irp,
> + [BDX_PCI_UNCORE_R2PCIE] = &bdx_uncore_r2pcie,
> + NULL,
> +};
> +
> +static DEFINE_PCI_DEVICE_TABLE(bdx_uncore_pci_ids) = {
> + { /* Home Agent 0 */
> + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f30),
> + .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_HA, 0),
> + },
> + { /* MC0 Channel 0 */
> + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb0),
> + .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 0),
> + },
> + { /* MC0 Channel 1 */
> + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb1),
> + .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 1),
> + },

Are you sure about the two PCI id for the IMCs (0x6fb0, 0x6fb1) ?
I do not see them on my system?

2015-07-13 12:51:49

by Liang, Kan

[permalink] [raw]
Subject: RE: [PATCH 1/1] perf/x86/intel/uncore: Add Broadwell-DE uncore support



> > + },
> > + { /* MC0 Channel 0 */
> > + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb0),
> > + .driver_data =
> UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 0),
> > + },
> > + { /* MC0 Channel 1 */
> > + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb1),
> > + .driver_data =
> UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 1),
> > + },
>
> Are you sure about the two PCI id for the IMCs (0x6fb0, 0x6fb1) ?
> I do not see them on my system?

Yes, the PCI id is correct. You cannot see them is because they
are hide by BIOS. I've already sent a request to BIOS team to
unhide them. I will let you know the updated BIOS version,
once I get feedback from them.
BTW, I've verified the PCI id in BDX-EP with corrected BIOS. IMCs
counter works well. EP and DE are same for iMC0CH0 and iMC0CH1.

Thanks,
Kan
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

Subject: [tip:perf/core] perf/x86/intel/uncore: Add Broadwell-DE uncore support

Commit-ID: 070e98873cf7196cad58f8b6e5278dd5533c81f0
Gitweb: http://git.kernel.org/tip/070e98873cf7196cad58f8b6e5278dd5533c81f0
Author: Kan Liang <[email protected]>
AuthorDate: Thu, 2 Jul 2015 08:12:52 -0400
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 4 Aug 2015 10:17:00 +0200

perf/x86/intel/uncore: Add Broadwell-DE uncore support

The uncore subsystem for Broadwell-DE is similar to Haswell-EP. There
are some differences in pci device IDs, box number and constraints.

Please refer to the public document:

http://www.intel.com/content/www/us/en/processors/xeon/xeon-d-1500-uncore-performance-monitoring.html

Signed-off-by: Kan Liang <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/kernel/cpu/perf_event_intel_uncore.c | 6 +
arch/x86/kernel/cpu/perf_event_intel_uncore.h | 2 +
.../x86/kernel/cpu/perf_event_intel_uncore_snbep.c | 164 +++++++++++++++++++++
3 files changed, 172 insertions(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index c2af967..560e525 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -911,6 +911,9 @@ static int __init uncore_pci_init(void)
case 63: /* Haswell-EP */
ret = hswep_uncore_pci_init();
break;
+ case 86: /* BDX-DE */
+ ret = bdx_uncore_pci_init();
+ break;
case 42: /* Sandy Bridge */
ret = snb_uncore_pci_init();
break;
@@ -1229,6 +1232,9 @@ static int __init uncore_cpu_init(void)
case 63: /* Haswell-EP */
hswep_uncore_cpu_init();
break;
+ case 86: /* BDX-DE */
+ bdx_uncore_cpu_init();
+ break;
default:
return 0;
}
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
index 0f77f0a..72c54c2 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
@@ -336,6 +336,8 @@ int ivbep_uncore_pci_init(void);
void ivbep_uncore_cpu_init(void);
int hswep_uncore_pci_init(void);
void hswep_uncore_cpu_init(void);
+int bdx_uncore_pci_init(void);
+void bdx_uncore_cpu_init(void);

/* perf_event_intel_uncore_nhmex.c */
void nhmex_uncore_cpu_init(void);
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
index 76a3feb..694510a8 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
@@ -2321,3 +2321,167 @@ int hswep_uncore_pci_init(void)
return 0;
}
/* end of Haswell-EP uncore support */
+
+/* BDX-DE uncore support */
+
+static struct intel_uncore_type bdx_uncore_ubox = {
+ .name = "ubox",
+ .num_counters = 2,
+ .num_boxes = 1,
+ .perf_ctr_bits = 48,
+ .fixed_ctr_bits = 48,
+ .perf_ctr = HSWEP_U_MSR_PMON_CTR0,
+ .event_ctl = HSWEP_U_MSR_PMON_CTL0,
+ .event_mask = SNBEP_U_MSR_PMON_RAW_EVENT_MASK,
+ .fixed_ctr = HSWEP_U_MSR_PMON_UCLK_FIXED_CTR,
+ .fixed_ctl = HSWEP_U_MSR_PMON_UCLK_FIXED_CTL,
+ .num_shared_regs = 1,
+ .ops = &ivbep_uncore_msr_ops,
+ .format_group = &ivbep_uncore_ubox_format_group,
+};
+
+static struct event_constraint bdx_uncore_cbox_constraints[] = {
+ UNCORE_EVENT_CONSTRAINT(0x09, 0x3),
+ UNCORE_EVENT_CONSTRAINT(0x11, 0x1),
+ UNCORE_EVENT_CONSTRAINT(0x36, 0x1),
+ EVENT_CONSTRAINT_END
+};
+
+static struct intel_uncore_type bdx_uncore_cbox = {
+ .name = "cbox",
+ .num_counters = 4,
+ .num_boxes = 8,
+ .perf_ctr_bits = 48,
+ .event_ctl = HSWEP_C0_MSR_PMON_CTL0,
+ .perf_ctr = HSWEP_C0_MSR_PMON_CTR0,
+ .event_mask = SNBEP_CBO_MSR_PMON_RAW_EVENT_MASK,
+ .box_ctl = HSWEP_C0_MSR_PMON_BOX_CTL,
+ .msr_offset = HSWEP_CBO_MSR_OFFSET,
+ .num_shared_regs = 1,
+ .constraints = bdx_uncore_cbox_constraints,
+ .ops = &hswep_uncore_cbox_ops,
+ .format_group = &hswep_uncore_cbox_format_group,
+};
+
+static struct intel_uncore_type *bdx_msr_uncores[] = {
+ &bdx_uncore_ubox,
+ &bdx_uncore_cbox,
+ &hswep_uncore_pcu,
+ NULL,
+};
+
+void bdx_uncore_cpu_init(void)
+{
+ if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores)
+ bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores;
+ uncore_msr_uncores = bdx_msr_uncores;
+}
+
+static struct intel_uncore_type bdx_uncore_ha = {
+ .name = "ha",
+ .num_counters = 4,
+ .num_boxes = 1,
+ .perf_ctr_bits = 48,
+ SNBEP_UNCORE_PCI_COMMON_INIT(),
+};
+
+static struct intel_uncore_type bdx_uncore_imc = {
+ .name = "imc",
+ .num_counters = 5,
+ .num_boxes = 2,
+ .perf_ctr_bits = 48,
+ .fixed_ctr_bits = 48,
+ .fixed_ctr = SNBEP_MC_CHy_PCI_PMON_FIXED_CTR,
+ .fixed_ctl = SNBEP_MC_CHy_PCI_PMON_FIXED_CTL,
+ .event_descs = hswep_uncore_imc_events,
+ SNBEP_UNCORE_PCI_COMMON_INIT(),
+};
+
+static struct intel_uncore_type bdx_uncore_irp = {
+ .name = "irp",
+ .num_counters = 4,
+ .num_boxes = 1,
+ .perf_ctr_bits = 48,
+ .event_mask = SNBEP_PMON_RAW_EVENT_MASK,
+ .box_ctl = SNBEP_PCI_PMON_BOX_CTL,
+ .ops = &hswep_uncore_irp_ops,
+ .format_group = &snbep_uncore_format_group,
+};
+
+
+static struct event_constraint bdx_uncore_r2pcie_constraints[] = {
+ UNCORE_EVENT_CONSTRAINT(0x10, 0x3),
+ UNCORE_EVENT_CONSTRAINT(0x11, 0x3),
+ UNCORE_EVENT_CONSTRAINT(0x13, 0x1),
+ UNCORE_EVENT_CONSTRAINT(0x23, 0x1),
+ UNCORE_EVENT_CONSTRAINT(0x25, 0x1),
+ UNCORE_EVENT_CONSTRAINT(0x26, 0x3),
+ UNCORE_EVENT_CONSTRAINT(0x2d, 0x3),
+ EVENT_CONSTRAINT_END
+};
+
+static struct intel_uncore_type bdx_uncore_r2pcie = {
+ .name = "r2pcie",
+ .num_counters = 4,
+ .num_boxes = 1,
+ .perf_ctr_bits = 48,
+ .constraints = bdx_uncore_r2pcie_constraints,
+ SNBEP_UNCORE_PCI_COMMON_INIT(),
+};
+
+enum {
+ BDX_PCI_UNCORE_HA,
+ BDX_PCI_UNCORE_IMC,
+ BDX_PCI_UNCORE_IRP,
+ BDX_PCI_UNCORE_R2PCIE,
+};
+
+static struct intel_uncore_type *bdx_pci_uncores[] = {
+ [BDX_PCI_UNCORE_HA] = &bdx_uncore_ha,
+ [BDX_PCI_UNCORE_IMC] = &bdx_uncore_imc,
+ [BDX_PCI_UNCORE_IRP] = &bdx_uncore_irp,
+ [BDX_PCI_UNCORE_R2PCIE] = &bdx_uncore_r2pcie,
+ NULL,
+};
+
+static DEFINE_PCI_DEVICE_TABLE(bdx_uncore_pci_ids) = {
+ { /* Home Agent 0 */
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f30),
+ .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_HA, 0),
+ },
+ { /* MC0 Channel 0 */
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb0),
+ .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 0),
+ },
+ { /* MC0 Channel 1 */
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb1),
+ .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 1),
+ },
+ { /* IRP */
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f39),
+ .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IRP, 0),
+ },
+ { /* R2PCIe */
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f34),
+ .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_R2PCIE, 0),
+ },
+ { /* end: all zeroes */ }
+};
+
+static struct pci_driver bdx_uncore_pci_driver = {
+ .name = "bdx_uncore",
+ .id_table = bdx_uncore_pci_ids,
+};
+
+int bdx_uncore_pci_init(void)
+{
+ int ret = snbep_pci2phy_map_init(0x6f1e);
+
+ if (ret)
+ return ret;
+ uncore_pci_uncores = bdx_pci_uncores;
+ uncore_pci_driver = &bdx_uncore_pci_driver;
+ return 0;
+}
+
+/* end of BDX-DE uncore support */

2015-08-26 15:12:51

by Liang, Kan

[permalink] [raw]
Subject: RE: [PATCH 1/1] perf/x86/intel/uncore: Add Broadwell-DE uncore support

>
> > > + },
> > > + { /* MC0 Channel 0 */
> > > + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb0),
> > > + .driver_data =
> > UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 0),
> > > + },
> > > + { /* MC0 Channel 1 */
> > > + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb1),
> > > + .driver_data =
> > UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 1),
> > > + },
> >
> > Are you sure about the two PCI id for the IMCs (0x6fb0, 0x6fb1) ?
> > I do not see them on my system?
>
> Yes, the PCI id is correct. You cannot see them is because they are hide by
> BIOS. I've already sent a request to BIOS team to unhide them. I will let you
> know the updated BIOS version, once I get feedback from them.
> BTW, I've verified the PCI id in BDX-EP with corrected BIOS. IMCs counter
> works well. EP and DE are same for iMC0CH0 and iMC0CH1.
>

Hi Stephane,

The issue has been fixed since BIOS 76V12 for BDX-DE.
You may update the BIOS to unhide IMC counter.

Thanks,
Kan
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2015-08-26 15:13:48

by Stephane Eranian

[permalink] [raw]
Subject: Re: [PATCH 1/1] perf/x86/intel/uncore: Add Broadwell-DE uncore support

On Wed, Aug 26, 2015 at 8:12 AM, Liang, Kan <[email protected]> wrote:
>>
>> > > + },
>> > > + { /* MC0 Channel 0 */
>> > > + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb0),
>> > > + .driver_data =
>> > UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 0),
>> > > + },
>> > > + { /* MC0 Channel 1 */
>> > > + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fb1),
>> > > + .driver_data =
>> > UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_IMC, 1),
>> > > + },
>> >
>> > Are you sure about the two PCI id for the IMCs (0x6fb0, 0x6fb1) ?
>> > I do not see them on my system?
>>
>> Yes, the PCI id is correct. You cannot see them is because they are hide by
>> BIOS. I've already sent a request to BIOS team to unhide them. I will let you
>> know the updated BIOS version, once I get feedback from them.
>> BTW, I've verified the PCI id in BDX-EP with corrected BIOS. IMCs counter
>> works well. EP and DE are same for iMC0CH0 and iMC0CH1.
>>
>
> Hi Stephane,
>
> The issue has been fixed since BIOS 76V12 for BDX-DE.
> You may update the BIOS to unhide IMC counter.
>
Thanks for following up. The problem has been fixed now.