perf/x86/intel/uncore: Add Arrow Lake support
Subsystems (2)
PATCH 1/5 perf/x86/intel/uncore: Add Arrow Lake support
From: Kan Liang <[email protected]>
From the perspective of the uncore PMU, the Arrow Lake is the same as the previous Meteor Lake. The only difference is the event list, which will be supported in the perf tool later.
--- arch/x86/events/intel/uncore.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/events/intel/uncore.c +3 -0
@@ -1892,6 +1892,9 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {X86_MATCH_VFM (INTEL_RAPTORLAKE_S , &adl_uncore_init),X86_MATCH_VFM (INTEL_METEORLAKE , &mtl_uncore_init),X86_MATCH_VFM (INTEL_METEORLAKE_L , &mtl_uncore_init), +X86_MATCH_VFM (INTEL_ARROWLAKE , &mtl_uncore_init), +X86_MATCH_VFM (INTEL_ARROWLAKE_U , &mtl_uncore_init), +X86_MATCH_VFM (INTEL_ARROWLAKE_H , &mtl_uncore_init),X86_MATCH_VFM (INTEL_SAPPHIRERAPIDS_X , &spr_uncore_init),X86_MATCH_VFM (INTEL_EMERALDRAPIDS_X , &spr_uncore_init), X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, &gnr_uncore_init),
Signature · 1 line
2.38.1
PATCH 2/5 perf/x86/intel/uncore: Factor out common MMIO init and ops functions
From: Kan Liang <[email protected]>
Some uncore PMON registers are located in the MMIO space. For the client machine, the MMIO space is usually located at D0:F0 but in a different BAR. For example, some uncore PMON registers are located in the SAF BAR, not the MCHBAR in the Lunar Lake.
The current __uncore_imc_init_box() hard code the BAR information. Factor out the uncore_get_box_mmio_addr() which uses the BAR information as a parameter.
The only change is the error output message. The hardcode name 'MCHBAR' is replaced by the offset of a BAR.
Add a new macro, MMIO_UNCORE_COMMON_OPS(), since the MMIO ops functions are usually the same among different generations.
--- arch/x86/events/intel/uncore_snb.c | 47 +++++++++++++++++++----------- 1 file changed, 30 insertions(+), 17 deletions(-)
arch/x86/events/intel/uncore_snb.c +30 -17
@@ -1481,33 +1481,35 @@ static struct pci_dev *tgl_uncore_get_mc_dev(void)#define TGL_UNCORE_MMIO_IMC_MEM_OFFSET 0x10000#define TGL_UNCORE_PCI_IMC_MAP_SIZE 0xe000 -static void __uncore_imc_init_box (struct intel_uncore_box *box, -unsigned int base_offset) +static void +uncore_get_box_mmio_addr (struct intel_uncore_box *box, +unsigned int base_offset, +int bar_offset,int step) {struct pci_dev *pdev =tgl_uncore_get_mc_dev ();struct intel_uncore_pmu *pmu = box->pmu;struct intel_uncore_type *type = pmu->type;resource_size_t addr; -u32 mch_bar; +u32 bar;if (!pdev) {pr_warn ("perf uncore: Cannot find matched IMC device.\n" );return ; } -pci_read_config_dword (pdev,SNB_UNCORE_PCI_IMC_BAR_OFFSET , &mch_bar); -/* MCHBAR is disabled */ -if (!(mch_bar &BIT (0 ))) { -pr_warn ("perf uncore: MCHBAR is disabled. Failed to map IMC free-running counters.\n" ); +pci_read_config_dword (pdev, bar_offset, &bar); +if (!(bar &BIT (0 ))) { +pr_warn ("perf uncore: BAR 0x%x is disabled. Failed to map %s counters.\n" , + bar_offset, type->name);pci_dev_put (pdev);return ; } - mch_bar &= ~BIT (0 ); - addr = (resource_size_t)(mch_bar +TGL_UNCORE_MMIO_IMC_MEM_OFFSET * pmu->pmu_idx); + bar &= ~BIT (0 ); + addr = (resource_size_t)(bar + step * pmu->pmu_idx);#ifdef CONFIG_PHYS_ADDR_T_64BIT -pci_read_config_dword (pdev,SNB_UNCORE_PCI_IMC_BAR_OFFSET +4 , &mch_bar); - addr |= ((resource_size_t )mch_bar <<32 ); +pci_read_config_dword (pdev, bar_offset +4 , &bar); + addr |= ((resource_size_t )bar <<32 );#endif addr += base_offset;
@@ -1518,6 +1520,14 @@ static void __uncore_imc_init_box(struct intel_uncore_box *box,pci_dev_put (pdev); } +static void __uncore_imc_init_box (struct intel_uncore_box *box, +unsigned int base_offset) +{ +uncore_get_box_mmio_addr (box, base_offset, +SNB_UNCORE_PCI_IMC_BAR_OFFSET , +TGL_UNCORE_MMIO_IMC_MEM_OFFSET ); +} +static void tgl_uncore_imc_freerunning_init_box (struct intel_uncore_box *box) {__uncore_imc_init_box (box,0 );
@@ -1612,14 +1622,17 @@ static void adl_uncore_mmio_enable_box(struct intel_uncore_box *box)writel (0 , box->io_addr +uncore_mmio_box_ctl (box)); } +#define MMIO_UNCORE_COMMON_OPS () \ + .exit_box = uncore_mmio_exit_box, \ + .disable_box = adl_uncore_mmio_disable_box, \ + .enable_box = adl_uncore_mmio_enable_box, \ + .disable_event = intel_generic_uncore_mmio_disable_event, \ + .enable_event = intel_generic_uncore_mmio_enable_event, \ + .read_counter = uncore_mmio_read_counter, +static struct intel_uncore_ops adl_uncore_mmio_ops = { .init_box = adl_uncore_imc_init_box, - .exit_box = uncore_mmio_exit_box, - .disable_box = adl_uncore_mmio_disable_box, - .enable_box = adl_uncore_mmio_enable_box, - .disable_event = intel_generic_uncore_mmio_disable_event, - .enable_event = intel_generic_uncore_mmio_enable_event, - .read_counter = uncore_mmio_read_counter, +MMIO_UNCORE_COMMON_OPS () };#define ADL_UNC_CTL_CHMASK_MASK 0x00000f00
Signature · 1 line
2.38.1
[tip: perf/core] perf/x86/intel/uncore: Factor out common MMIO init and ops functions
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: efb0c9c0b9f78d964fb23ec6fdebe5a493f477f3 Gitweb: https://git.kernel.org/tip/efb0c9c0b9f78d964fb23ec6fdebe5a493f477f3 Author: Kan Liang <[email protected]> AuthorDate: Wed, 31 Jul 2024 07:13:50 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 05 Aug 2024 16:54:46 +02:00
perf/x86/intel/uncore: Factor out common MMIO init and ops functions
Some uncore PMON registers are located in the MMIO space. For the client machine, the MMIO space is usually located at D0:F0 but in a different BAR. For example, some uncore PMON registers are located in the SAF BAR, not the MCHBAR in the Lunar Lake.
The current __uncore_imc_init_box() hard code the BAR information. Factor out the uncore_get_box_mmio_addr() which uses the BAR information as a parameter.
The only change is the error output message. The hardcode name 'MCHBAR' is replaced by the offset of a BAR.
Add a new macro, MMIO_UNCORE_COMMON_OPS(), since the MMIO ops functions are usually the same among different generations.
--- arch/x86/events/intel/uncore_snb.c | 47 ++++++++++++++++++----------- 1 file changed, 30 insertions(+), 17 deletions(-)
arch/x86/events/intel/uncore_snb.c +30 -17
@@ -1481,33 +1481,35 @@ static struct pci_dev *tgl_uncore_get_mc_dev(void)#define TGL_UNCORE_MMIO_IMC_MEM_OFFSET 0x10000#define TGL_UNCORE_PCI_IMC_MAP_SIZE 0xe000 -static void __uncore_imc_init_box (struct intel_uncore_box *box, -unsigned int base_offset) +static void +uncore_get_box_mmio_addr (struct intel_uncore_box *box, +unsigned int base_offset, +int bar_offset,int step) {struct pci_dev *pdev =tgl_uncore_get_mc_dev ();struct intel_uncore_pmu *pmu = box->pmu;struct intel_uncore_type *type = pmu->type;resource_size_t addr; -u32 mch_bar; +u32 bar;if (!pdev) {pr_warn ("perf uncore: Cannot find matched IMC device.\n" );return ; } -pci_read_config_dword (pdev,SNB_UNCORE_PCI_IMC_BAR_OFFSET , &mch_bar); -/* MCHBAR is disabled */ -if (!(mch_bar &BIT (0 ))) { -pr_warn ("perf uncore: MCHBAR is disabled. Failed to map IMC free-running counters.\n" ); +pci_read_config_dword (pdev, bar_offset, &bar); +if (!(bar &BIT (0 ))) { +pr_warn ("perf uncore: BAR 0x%x is disabled. Failed to map %s counters.\n" , + bar_offset, type->name);pci_dev_put (pdev);return ; } - mch_bar &= ~BIT (0 ); - addr = (resource_size_t)(mch_bar +TGL_UNCORE_MMIO_IMC_MEM_OFFSET * pmu->pmu_idx); + bar &= ~BIT (0 ); + addr = (resource_size_t)(bar + step * pmu->pmu_idx);#ifdef CONFIG_PHYS_ADDR_T_64BIT -pci_read_config_dword (pdev,SNB_UNCORE_PCI_IMC_BAR_OFFSET +4 , &mch_bar); - addr |= ((resource_size_t )mch_bar <<32 ); +pci_read_config_dword (pdev, bar_offset +4 , &bar); + addr |= ((resource_size_t )bar <<32 );#endif addr += base_offset;
@@ -1518,6 +1520,14 @@ static void __uncore_imc_init_box(struct intel_uncore_box *box,pci_dev_put (pdev); } +static void __uncore_imc_init_box (struct intel_uncore_box *box, +unsigned int base_offset) +{ +uncore_get_box_mmio_addr (box, base_offset, +SNB_UNCORE_PCI_IMC_BAR_OFFSET , +TGL_UNCORE_MMIO_IMC_MEM_OFFSET ); +} +static void tgl_uncore_imc_freerunning_init_box (struct intel_uncore_box *box) {__uncore_imc_init_box (box,0 );
@@ -1612,14 +1622,17 @@ static void adl_uncore_mmio_enable_box(struct intel_uncore_box *box)writel (0 , box->io_addr +uncore_mmio_box_ctl (box)); } +#define MMIO_UNCORE_COMMON_OPS () \ + .exit_box = uncore_mmio_exit_box, \ + .disable_box = adl_uncore_mmio_disable_box, \ + .enable_box = adl_uncore_mmio_enable_box, \ + .disable_event = intel_generic_uncore_mmio_disable_event, \ + .enable_event = intel_generic_uncore_mmio_enable_event, \ + .read_counter = uncore_mmio_read_counter, +static struct intel_uncore_ops adl_uncore_mmio_ops = { .init_box = adl_uncore_imc_init_box, - .exit_box = uncore_mmio_exit_box, - .disable_box = adl_uncore_mmio_disable_box, - .enable_box = adl_uncore_mmio_enable_box, - .disable_event = intel_generic_uncore_mmio_disable_event, - .enable_event = intel_generic_uncore_mmio_enable_event, - .read_counter = uncore_mmio_read_counter, +MMIO_UNCORE_COMMON_OPS () };#define ADL_UNC_CTL_CHMASK_MASK 0x00000f00
PATCH 3/5 perf/x86/intel/uncore: Add Lunar Lake support
In reply to [email protected]From: Kan Liang <[email protected]>
The uncore subsystem for Lunar Lake is similar to the previous Meteor Lake. The uncore PerfMon registers are located at both MSR and MMIO space.
The ARB and iMC are kept. There is no difference from the Meteor Lake. Move the global control initialization to the first box of the CBOX.
The sNCU is moved to the MMIO space.
The HBO is newly added and only be accessed from the MMIO space.
--- arch/x86/events/intel/uncore.c | 6 ++ arch/x86/events/intel/uncore.h | 2 + arch/x86/events/intel/uncore_snb.c | 133 +++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+)
arch/x86/events/intel/uncore.c +6 -0
@@ -1815,6 +1815,11 @@ static const struct intel_uncore_init_fun mtl_uncore_init __initconst = { .mmio_init = adl_uncore_mmio_init, }; +static const struct intel_uncore_init_fun lnl_uncore_init__initconst = { + .cpu_init = lnl_uncore_cpu_init, + .mmio_init = lnl_uncore_mmio_init, +}; +static const struct intel_uncore_init_fun icx_uncore_init__initconst = { .cpu_init = icx_uncore_cpu_init, .pci_init = icx_uncore_pci_init,
@@ -1895,6 +1900,7 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {X86_MATCH_VFM (INTEL_ARROWLAKE , &mtl_uncore_init),X86_MATCH_VFM (INTEL_ARROWLAKE_U , &mtl_uncore_init),X86_MATCH_VFM (INTEL_ARROWLAKE_H , &mtl_uncore_init), +X86_MATCH_VFM (INTEL_LUNARLAKE_M , &lnl_uncore_init),X86_MATCH_VFM (INTEL_SAPPHIRERAPIDS_X , &spr_uncore_init),X86_MATCH_VFM (INTEL_EMERALDRAPIDS_X , &spr_uncore_init), X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, &gnr_uncore_init),
arch/x86/events/intel/uncore.h +2 -0
@@ -611,10 +611,12 @@ void skl_uncore_cpu_init(void);void icl_uncore_cpu_init (void );void tgl_uncore_cpu_init (void );void adl_uncore_cpu_init (void ); +void lnl_uncore_cpu_init (void );void mtl_uncore_cpu_init (void );void tgl_uncore_mmio_init (void );void tgl_l_uncore_mmio_init (void );void adl_uncore_mmio_init (void ); +void lnl_uncore_mmio_init (void );int snb_pci2phy_map_init (int devid);/* uncore_snbep.c */
arch/x86/events/intel/uncore_snb.c +133 -0
148 lines not on this page · raw message
Signature · 1 line
2.38.1
[tip: perf/core] perf/x86/intel/uncore: Add Lunar Lake support
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 9bd7dfe3a5262d3b29debdc66e1410201a235019 Gitweb: https://git.kernel.org/tip/9bd7dfe3a5262d3b29debdc66e1410201a235019 Author: Kan Liang <[email protected]> AuthorDate: Wed, 31 Jul 2024 07:13:51 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 05 Aug 2024 16:54:46 +02:00
perf/x86/intel/uncore: Add Lunar Lake support
The uncore subsystem for Lunar Lake is similar to the previous Meteor Lake. The uncore PerfMon registers are located at both MSR and MMIO space.
The ARB and iMC are kept. There is no difference from the Meteor Lake. Move the global control initialization to the first box of the CBOX.
The sNCU is moved to the MMIO space.
The HBO is newly added and only be accessed from the MMIO space.
--- arch/x86/events/intel/uncore.c | 6 +- arch/x86/events/intel/uncore.h | 2 +- arch/x86/events/intel/uncore_snb.c | 133 ++++++++++++++++++++++++++++- 3 files changed, 141 insertions(+)
arch/x86/events/intel/uncore.c +6 -0
@@ -1816,6 +1816,11 @@ static const struct intel_uncore_init_fun mtl_uncore_init __initconst = { .mmio_init = adl_uncore_mmio_init, }; +static const struct intel_uncore_init_fun lnl_uncore_init__initconst = { + .cpu_init = lnl_uncore_cpu_init, + .mmio_init = lnl_uncore_mmio_init, +}; +static const struct intel_uncore_init_fun icx_uncore_init__initconst = { .cpu_init = icx_uncore_cpu_init, .pci_init = icx_uncore_pci_init,
@@ -1896,6 +1901,7 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {X86_MATCH_VFM (INTEL_ARROWLAKE , &mtl_uncore_init),X86_MATCH_VFM (INTEL_ARROWLAKE_U , &mtl_uncore_init),X86_MATCH_VFM (INTEL_ARROWLAKE_H , &mtl_uncore_init), +X86_MATCH_VFM (INTEL_LUNARLAKE_M , &lnl_uncore_init),X86_MATCH_VFM (INTEL_SAPPHIRERAPIDS_X , &spr_uncore_init),X86_MATCH_VFM (INTEL_EMERALDRAPIDS_X , &spr_uncore_init), X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, &gnr_uncore_init),
arch/x86/events/intel/uncore.h +2 -0
@@ -611,10 +611,12 @@ void skl_uncore_cpu_init(void);void icl_uncore_cpu_init (void );void tgl_uncore_cpu_init (void );void adl_uncore_cpu_init (void ); +void lnl_uncore_cpu_init (void );void mtl_uncore_cpu_init (void );void tgl_uncore_mmio_init (void );void tgl_l_uncore_mmio_init (void );void adl_uncore_mmio_init (void ); +void lnl_uncore_mmio_init (void );int snb_pci2phy_map_init (int devid);/* uncore_snbep.c */
arch/x86/events/intel/uncore_snb.c +133 -0
148 lines not on this page · raw message
PATCH 4/5 perf/x86/intel/uncore: Add LNL uncore iMC freerunning support
In reply to [email protected]From: Zhenyu Wang <[email protected]>
LNL uncore imc freerunning counters keep same as previous HW.
--- arch/x86/events/intel/uncore_snb.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/events/intel/uncore_snb.c +1 -0
@@ -1840,6 +1840,7 @@ static struct intel_uncore_type *lnl_mmio_uncores[] = { &adl_uncore_imc, &lnl_uncore_hbo, &lnl_uncore_sncu, + &adl_uncore_imc_free_running, NULL };
Signature · 1 line
2.38.1
[tip: perf/core] perf/x86/intel/uncore: Add LNL uncore iMC freerunning support
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 9ac57c456fcb17f07f8792219479b0c841d75ba7 Gitweb: https://git.kernel.org/tip/9ac57c456fcb17f07f8792219479b0c841d75ba7 Author: Zhenyu Wang <[email protected]> AuthorDate: Wed, 31 Jul 2024 07:13:52 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 05 Aug 2024 16:54:46 +02:00
perf/x86/intel/uncore: Add LNL uncore iMC freerunning support
LNL uncore imc freerunning counters keep same as previous HW.
--- arch/x86/events/intel/uncore_snb.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/events/intel/uncore_snb.c +1 -0
@@ -1840,6 +1840,7 @@ static struct intel_uncore_type *lnl_mmio_uncores[] = { &adl_uncore_imc, &lnl_uncore_hbo, &lnl_uncore_sncu, + &adl_uncore_imc_free_running, NULL };
PATCH 5/5 perf/x86/intel/uncore: Use D0:F0 as a default device
In reply to [email protected]From: Zhenyu Wang <[email protected]>
Some uncore PMON registers are located in the MMIO space of the Host Bridge and DRAM Controller device, which is located at D0:F0 for Tiger Lake and later client generation.
Use D0:F0 as a default device. So it doesn't need to keep adding the complete Device ID list for each generation anymore.
--- arch/x86/events/intel/uncore_snb.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/events/intel/uncore_snb.c +4 -0
@@ -1504,6 +1504,10 @@ static struct pci_dev *tgl_uncore_get_mc_dev(void) ids++; } +/* Just try to grab 00:00.0 device */ +if (!mc_dev) + mc_dev =pci_get_domain_bus_and_slot (0 ,0 ,PCI_DEVFN (0 ,0 )); +return mc_dev; }
Signature · 1 line
2.38.1
[tip: perf/core] perf/x86/intel/uncore: Use D0:F0 as a default device
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: aaad0e2aa50723969f96b690f72e2f4aefa433f2 Gitweb: https://git.kernel.org/tip/aaad0e2aa50723969f96b690f72e2f4aefa433f2 Author: Zhenyu Wang <[email protected]> AuthorDate: Wed, 31 Jul 2024 07:13:53 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 05 Aug 2024 16:54:46 +02:00
perf/x86/intel/uncore: Use D0:F0 as a default device
Some uncore PMON registers are located in the MMIO space of the Host Bridge and DRAM Controller device, which is located at D0:F0 for Tiger Lake and later client generation.
Use D0:F0 as a default device. So it doesn't need to keep adding the complete Device ID list for each generation anymore.
--- arch/x86/events/intel/uncore_snb.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/events/intel/uncore_snb.c +4 -0
@@ -1504,6 +1504,10 @@ static struct pci_dev *tgl_uncore_get_mc_dev(void) ids++; } +/* Just try to grab 00:00.0 device */ +if (!mc_dev) + mc_dev =pci_get_domain_bus_and_slot (0 ,0 ,PCI_DEVFN (0 ,0 )); +return mc_dev; }
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: e0f49f15f6344ef3eeb0a04a8b5dedde2a454136 Gitweb: https://git.kernel.org/tip/e0f49f15f6344ef3eeb0a04a8b5dedde2a454136 Author: Kan Liang <[email protected]> AuthorDate: Wed, 31 Jul 2024 07:13:49 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 05 Aug 2024 16:54:45 +02:00
perf/x86/intel/uncore: Add Arrow Lake support
Quoted 1 line
From the perspective of the uncore PMU, the Arrow Lake is the same as
the previous Meteor Lake. The only difference is the event list, which will be supported in the perf tool later.
--- arch/x86/events/intel/uncore.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/events/intel/uncore.c +3 -0
@@ -1893,6 +1893,9 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {X86_MATCH_VFM (INTEL_RAPTORLAKE_S , &adl_uncore_init),X86_MATCH_VFM (INTEL_METEORLAKE , &mtl_uncore_init),X86_MATCH_VFM (INTEL_METEORLAKE_L , &mtl_uncore_init), +X86_MATCH_VFM (INTEL_ARROWLAKE , &mtl_uncore_init), +X86_MATCH_VFM (INTEL_ARROWLAKE_U , &mtl_uncore_init), +X86_MATCH_VFM (INTEL_ARROWLAKE_H , &mtl_uncore_init),X86_MATCH_VFM (INTEL_SAPPHIRERAPIDS_X , &spr_uncore_init),X86_MATCH_VFM (INTEL_EMERALDRAPIDS_X , &spr_uncore_init), X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, &gnr_uncore_init),