Skip to content

Commit 9bd7dfe

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
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. Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20240731141353.759643-3-kan.liang@linux.intel.com
1 parent efb0c9c commit 9bd7dfe

3 files changed

Lines changed: 141 additions & 0 deletions

File tree

arch/x86/events/intel/uncore.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,6 +1816,11 @@ static const struct intel_uncore_init_fun mtl_uncore_init __initconst = {
18161816
.mmio_init = adl_uncore_mmio_init,
18171817
};
18181818

1819+
static const struct intel_uncore_init_fun lnl_uncore_init __initconst = {
1820+
.cpu_init = lnl_uncore_cpu_init,
1821+
.mmio_init = lnl_uncore_mmio_init,
1822+
};
1823+
18191824
static const struct intel_uncore_init_fun icx_uncore_init __initconst = {
18201825
.cpu_init = icx_uncore_cpu_init,
18211826
.pci_init = icx_uncore_pci_init,
@@ -1896,6 +1901,7 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {
18961901
X86_MATCH_VFM(INTEL_ARROWLAKE, &mtl_uncore_init),
18971902
X86_MATCH_VFM(INTEL_ARROWLAKE_U, &mtl_uncore_init),
18981903
X86_MATCH_VFM(INTEL_ARROWLAKE_H, &mtl_uncore_init),
1904+
X86_MATCH_VFM(INTEL_LUNARLAKE_M, &lnl_uncore_init),
18991905
X86_MATCH_VFM(INTEL_SAPPHIRERAPIDS_X, &spr_uncore_init),
19001906
X86_MATCH_VFM(INTEL_EMERALDRAPIDS_X, &spr_uncore_init),
19011907
X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, &gnr_uncore_init),

arch/x86/events/intel/uncore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,10 +611,12 @@ void skl_uncore_cpu_init(void);
611611
void icl_uncore_cpu_init(void);
612612
void tgl_uncore_cpu_init(void);
613613
void adl_uncore_cpu_init(void);
614+
void lnl_uncore_cpu_init(void);
614615
void mtl_uncore_cpu_init(void);
615616
void tgl_uncore_mmio_init(void);
616617
void tgl_l_uncore_mmio_init(void);
617618
void adl_uncore_mmio_init(void);
619+
void lnl_uncore_mmio_init(void);
618620
int snb_pci2phy_map_init(int devid);
619621

620622
/* uncore_snbep.c */

arch/x86/events/intel/uncore_snb.c

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ DEFINE_UNCORE_FORMAT_ATTR(inv, inv, "config:23");
252252
DEFINE_UNCORE_FORMAT_ATTR(cmask5, cmask, "config:24-28");
253253
DEFINE_UNCORE_FORMAT_ATTR(cmask8, cmask, "config:24-31");
254254
DEFINE_UNCORE_FORMAT_ATTR(threshold, threshold, "config:24-29");
255+
DEFINE_UNCORE_FORMAT_ATTR(threshold2, threshold, "config:24-31");
255256

256257
/* Sandy Bridge uncore support */
257258
static void snb_uncore_msr_enable_event(struct intel_uncore_box *box, struct perf_event *event)
@@ -746,6 +747,34 @@ void mtl_uncore_cpu_init(void)
746747
uncore_msr_uncores = mtl_msr_uncores;
747748
}
748749

750+
static struct intel_uncore_type *lnl_msr_uncores[] = {
751+
&mtl_uncore_cbox,
752+
&mtl_uncore_arb,
753+
NULL
754+
};
755+
756+
#define LNL_UNC_MSR_GLOBAL_CTL 0x240e
757+
758+
static void lnl_uncore_msr_init_box(struct intel_uncore_box *box)
759+
{
760+
if (box->pmu->pmu_idx == 0)
761+
wrmsrl(LNL_UNC_MSR_GLOBAL_CTL, SNB_UNC_GLOBAL_CTL_EN);
762+
}
763+
764+
static struct intel_uncore_ops lnl_uncore_msr_ops = {
765+
.init_box = lnl_uncore_msr_init_box,
766+
.disable_event = snb_uncore_msr_disable_event,
767+
.enable_event = snb_uncore_msr_enable_event,
768+
.read_counter = uncore_msr_read_counter,
769+
};
770+
771+
void lnl_uncore_cpu_init(void)
772+
{
773+
mtl_uncore_cbox.num_boxes = 4;
774+
mtl_uncore_cbox.ops = &lnl_uncore_msr_ops;
775+
uncore_msr_uncores = lnl_msr_uncores;
776+
}
777+
749778
enum {
750779
SNB_PCI_UNCORE_IMC,
751780
};
@@ -1716,3 +1745,107 @@ void adl_uncore_mmio_init(void)
17161745
}
17171746

17181747
/* end of Alder Lake MMIO uncore support */
1748+
1749+
/* Lunar Lake MMIO uncore support */
1750+
#define LNL_UNCORE_PCI_SAFBAR_OFFSET 0x68
1751+
#define LNL_UNCORE_MAP_SIZE 0x1000
1752+
#define LNL_UNCORE_SNCU_BASE 0xE4B000
1753+
#define LNL_UNCORE_SNCU_CTR 0x390
1754+
#define LNL_UNCORE_SNCU_CTRL 0x398
1755+
#define LNL_UNCORE_SNCU_BOX_CTL 0x380
1756+
#define LNL_UNCORE_GLOBAL_CTL 0x700
1757+
#define LNL_UNCORE_HBO_BASE 0xE54000
1758+
#define LNL_UNCORE_HBO_OFFSET -4096
1759+
#define LNL_UNCORE_HBO_CTR 0x570
1760+
#define LNL_UNCORE_HBO_CTRL 0x550
1761+
#define LNL_UNCORE_HBO_BOX_CTL 0x548
1762+
1763+
#define LNL_UNC_CTL_THRESHOLD 0xff000000
1764+
#define LNL_UNC_RAW_EVENT_MASK (SNB_UNC_CTL_EV_SEL_MASK | \
1765+
SNB_UNC_CTL_UMASK_MASK | \
1766+
SNB_UNC_CTL_EDGE_DET | \
1767+
SNB_UNC_CTL_INVERT | \
1768+
LNL_UNC_CTL_THRESHOLD)
1769+
1770+
static struct attribute *lnl_uncore_formats_attr[] = {
1771+
&format_attr_event.attr,
1772+
&format_attr_umask.attr,
1773+
&format_attr_edge.attr,
1774+
&format_attr_inv.attr,
1775+
&format_attr_threshold2.attr,
1776+
NULL
1777+
};
1778+
1779+
static const struct attribute_group lnl_uncore_format_group = {
1780+
.name = "format",
1781+
.attrs = lnl_uncore_formats_attr,
1782+
};
1783+
1784+
static void lnl_uncore_hbo_init_box(struct intel_uncore_box *box)
1785+
{
1786+
uncore_get_box_mmio_addr(box, LNL_UNCORE_HBO_BASE,
1787+
LNL_UNCORE_PCI_SAFBAR_OFFSET,
1788+
LNL_UNCORE_HBO_OFFSET);
1789+
}
1790+
1791+
static struct intel_uncore_ops lnl_uncore_hbo_ops = {
1792+
.init_box = lnl_uncore_hbo_init_box,
1793+
MMIO_UNCORE_COMMON_OPS()
1794+
};
1795+
1796+
static struct intel_uncore_type lnl_uncore_hbo = {
1797+
.name = "hbo",
1798+
.num_counters = 4,
1799+
.num_boxes = 2,
1800+
.perf_ctr_bits = 64,
1801+
.perf_ctr = LNL_UNCORE_HBO_CTR,
1802+
.event_ctl = LNL_UNCORE_HBO_CTRL,
1803+
.event_mask = LNL_UNC_RAW_EVENT_MASK,
1804+
.box_ctl = LNL_UNCORE_HBO_BOX_CTL,
1805+
.mmio_map_size = LNL_UNCORE_MAP_SIZE,
1806+
.ops = &lnl_uncore_hbo_ops,
1807+
.format_group = &lnl_uncore_format_group,
1808+
};
1809+
1810+
static void lnl_uncore_sncu_init_box(struct intel_uncore_box *box)
1811+
{
1812+
uncore_get_box_mmio_addr(box, LNL_UNCORE_SNCU_BASE,
1813+
LNL_UNCORE_PCI_SAFBAR_OFFSET,
1814+
0);
1815+
1816+
if (box->io_addr)
1817+
writel(ADL_UNCORE_IMC_CTL_INT, box->io_addr + LNL_UNCORE_GLOBAL_CTL);
1818+
}
1819+
1820+
static struct intel_uncore_ops lnl_uncore_sncu_ops = {
1821+
.init_box = lnl_uncore_sncu_init_box,
1822+
MMIO_UNCORE_COMMON_OPS()
1823+
};
1824+
1825+
static struct intel_uncore_type lnl_uncore_sncu = {
1826+
.name = "sncu",
1827+
.num_counters = 2,
1828+
.num_boxes = 1,
1829+
.perf_ctr_bits = 64,
1830+
.perf_ctr = LNL_UNCORE_SNCU_CTR,
1831+
.event_ctl = LNL_UNCORE_SNCU_CTRL,
1832+
.event_mask = LNL_UNC_RAW_EVENT_MASK,
1833+
.box_ctl = LNL_UNCORE_SNCU_BOX_CTL,
1834+
.mmio_map_size = LNL_UNCORE_MAP_SIZE,
1835+
.ops = &lnl_uncore_sncu_ops,
1836+
.format_group = &lnl_uncore_format_group,
1837+
};
1838+
1839+
static struct intel_uncore_type *lnl_mmio_uncores[] = {
1840+
&adl_uncore_imc,
1841+
&lnl_uncore_hbo,
1842+
&lnl_uncore_sncu,
1843+
NULL
1844+
};
1845+
1846+
void lnl_uncore_mmio_init(void)
1847+
{
1848+
uncore_mmio_uncores = lnl_mmio_uncores;
1849+
}
1850+
1851+
/* end of Lunar Lake MMIO uncore support */

0 commit comments

Comments
 (0)