Skip to content

Commit 87939d5

Browse files
apopplempe
authored andcommitted
powerpc/dt_cpu_ftrs: Add MMA feature
Matrix multiple assist (MMA) is a new feature added to ISAv3.1 and POWER10. Support on powernv can be selected via a firmware CPU device tree feature which enables it via a PCR bit. Signed-off-by: Alistair Popple <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c63d688 commit 87939d5

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

arch/powerpc/include/asm/reg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@
481481
#define PCR_VEC_DIS (__MASK(63-0)) /* Vec. disable (bit NA since POWER8) */
482482
#define PCR_VSX_DIS (__MASK(63-1)) /* VSX disable (bit NA since POWER8) */
483483
#define PCR_TM_DIS (__MASK(63-2)) /* Trans. memory disable (POWER8) */
484-
#define PCR_HIGH_BITS (PCR_VEC_DIS | PCR_VSX_DIS | PCR_TM_DIS)
484+
#define PCR_MMA_DIS (__MASK(63-3)) /* Matrix-Multiply Accelerator */
485+
#define PCR_HIGH_BITS (PCR_MMA_DIS | PCR_VEC_DIS | PCR_VSX_DIS | PCR_TM_DIS)
485486
/*
486487
* These bits are used in the function kvmppc_set_arch_compat() to specify and
487488
* determine both the compatibility level which we want to emulate and the

arch/powerpc/kernel/dt_cpu_ftrs.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static struct {
7575
u64 lpcr_clear;
7676
u64 hfscr;
7777
u64 fscr;
78+
u64 pcr;
7879
} system_registers;
7980

8081
static void (*init_pmu_registers)(void);
@@ -102,7 +103,7 @@ static void __restore_cpu_cpufeatures(void)
102103
if (hv_mode) {
103104
mtspr(SPRN_LPID, 0);
104105
mtspr(SPRN_HFSCR, system_registers.hfscr);
105-
mtspr(SPRN_PCR, PCR_MASK);
106+
mtspr(SPRN_PCR, system_registers.pcr);
106107
}
107108
mtspr(SPRN_FSCR, system_registers.fscr);
108109

@@ -561,6 +562,18 @@ static int __init feat_enable_large_ci(struct dt_cpu_feature *f)
561562
return 1;
562563
}
563564

565+
static int __init feat_enable_mma(struct dt_cpu_feature *f)
566+
{
567+
u64 pcr;
568+
569+
feat_enable(f);
570+
pcr = mfspr(SPRN_PCR);
571+
pcr &= ~PCR_MMA_DIS;
572+
mtspr(SPRN_PCR, pcr);
573+
574+
return 1;
575+
}
576+
564577
struct dt_cpu_feature_match {
565578
const char *name;
566579
int (*enable)(struct dt_cpu_feature *f);
@@ -635,6 +648,7 @@ static struct dt_cpu_feature_match __initdata
635648
{"vector-binary16", feat_enable, 0},
636649
{"wait-v3", feat_enable, 0},
637650
{"prefix-instructions", feat_enable, 0},
651+
{"matrix-multiply-assist", feat_enable_mma, 0},
638652
};
639653

640654
static bool __initdata using_dt_cpu_ftrs;
@@ -785,6 +799,7 @@ static void __init cpufeatures_setup_finished(void)
785799
system_registers.lpcr = mfspr(SPRN_LPCR);
786800
system_registers.hfscr = mfspr(SPRN_HFSCR);
787801
system_registers.fscr = mfspr(SPRN_FSCR);
802+
system_registers.pcr = mfspr(SPRN_PCR);
788803

789804
pr_info("final cpu/mmu features = 0x%016lx 0x%08x\n",
790805
cur_cpu_spec->cpu_features, cur_cpu_spec->mmu_features);

0 commit comments

Comments
 (0)