<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 22-Jul-2020, at 10:11 AM, Jordan Niethe <<a href="mailto:jniethe5@gmail.com" class="">jniethe5@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">On Sat, Jul 18, 2020 at 1:13 AM Athira Rajeev</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""><</span><a href="mailto:atrajeev@linux.vnet.ibm.com" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">atrajeev@linux.vnet.ibm.com</a><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">> wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class="">From: Madhavan Srinivasan <<a href="mailto:maddy@linux.ibm.com" class="">maddy@linux.ibm.com</a>><br class=""><br class="">Add power10 feature function to dt_cpu_ftrs.c along<br class="">with a power10 specific init() to initialize pmu sprs,<br class="">sets the oprofile_cpu_type and cpu_features. This will<br class="">enable performance monitoring unit(PMU) for Power10<br class="">in CPU features with "performance-monitor-power10".<br class=""><br class="">For PowerISA v3.1, BHRB disable is controlled via Monitor Mode<br class="">Control Register A (MMCRA) bit, namely "BHRB Recording Disable<br class="">(BHRBRD)". This patch initializes MMCRA BHRBRD to disable BHRB<br class="">feature at boot for power10.<br class=""><br class="">Signed-off-by: Madhavan Srinivasan <<a href="mailto:maddy@linux.ibm.com" class="">maddy@linux.ibm.com</a>><br class="">---<br class="">arch/powerpc/include/asm/reg.h        |  3 +++<br class="">arch/powerpc/kernel/cpu_setup_power.S |  8 ++++++++<br class="">arch/powerpc/kernel/dt_cpu_ftrs.c     | 26 ++++++++++++++++++++++++++<br class="">3 files changed, 37 insertions(+)<br class=""><br class="">diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h<br class="">index 21a1b2d..900ada1 100644<br class="">--- a/arch/powerpc/include/asm/reg.h<br class="">+++ b/arch/powerpc/include/asm/reg.h<br class="">@@ -1068,6 +1068,9 @@<br class="">#define MMCR0_PMC2_LOADMISSTIME        0x5<br class="">#endif<br class=""><br class="">+/* BHRB disable bit for PowerISA v3.10 */<br class="">+#define MMCRA_BHRB_DISABLE     0x0000002000000000<br class=""></blockquote><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Shouldn't this go under SPRN_MMCRA with the other MMCRA_*.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote><div><br class=""></div><div><br class=""></div>Hi Jordan</div><div><br class=""></div><div>Ok, the definition of MMCRA is under #ifdef for 64 bit .  if I move definition of MMCRA_BHRB_DISABLE along with other SPR's, I also</div><div>need to define this for 32-bit to satisfy core-book3s to compile as below:</div><div><br class=""></div><div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">index 900ada10762c..7e271657b412 100644</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">--- a/arch/powerpc/include/asm/reg.h</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">+++ b/arch/powerpc/include/asm/reg.h</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">@@ -888,6 +888,8 @@</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #define   MMCRA_SLOT   0x07000000UL /* SLOT bits (37-39) */</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #define   MMCRA_SLOT_SHIFT     24</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #define   MMCRA_SAMPLE_ENABLE 0x00000001UL /* enable sampling */</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">+/* BHRB disable bit for PowerISA v3.10 */</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">+#define   MMCRA_BHRB_DISABLE  0x0000002000000000</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #define   POWER6_MMCRA_SDSYNC 0x0000080000000000ULL    /* SDAR/SIAR synced */</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #define   POWER6_MMCRA_SIHV   0x0000040000000000ULL</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #define   POWER6_MMCRA_SIPR   0x0000020000000000ULL</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">@@ -1068,9 +1070,6 @@</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #define MMCR0_PMC2_LOADMISSTIME        0x5</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #endif</div><p style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">-/* BHRB disable bit for PowerISA v3.10 */</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">-#define MMCRA_BHRB_DISABLE     0x0000002000000000</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">-</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> /*</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">  * SPRG usage:</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">  *</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">index 36baae666387..88068f20827c 100644</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">--- a/arch/powerpc/perf/core-book3s.c</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">+++ b/arch/powerpc/perf/core-book3s.c</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">@@ -94,6 +94,7 @@ static unsigned int freeze_events_kernel = MMCR0_FCS;</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #define SPRN_SIER2             0</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #define SPRN_SIER3             0</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> #define MMCRA_SAMPLE_ENABLE    0</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class="">+#define MMCRA_BHRB_DISABLE     0</div><p style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> static inline unsigned long perf_ip_adjust(struct pt_regs *regs)</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";" class=""> {</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><div><blockquote type="cite" class=""><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">+<br class="">/*<br class=""> * SPRG usage:<br class=""> *<br class="">diff --git a/arch/powerpc/kernel/cpu_setup_power.S b/arch/powerpc/kernel/cpu_setup_power.S<br class="">index efdcfa7..b8e0d1e 100644<br class="">--- a/arch/powerpc/kernel/cpu_setup_power.S<br class="">+++ b/arch/powerpc/kernel/cpu_setup_power.S<br class="">@@ -94,6 +94,7 @@ _GLOBAL(__restore_cpu_power8)<br class="">_GLOBAL(__setup_cpu_power10)<br class="">       mflr    r11<br class="">       bl      __init_FSCR_power10<br class="">+       bl      __init_PMU_ISA31<br class=""></blockquote><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">So we set MMCRA here but then aren't we still going to call __init_PMU</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">which will overwrite that?</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Would this setting MMCRA also need to be handled in __restore_cpu_power10?</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote><div><br class=""></div>Thanks for this nice catch !  When I rebased code initial phase, we didn’t had power10 part filled in.</div><div>It was a miss from my side in adding PMu init functions and thanks for pointing this out. </div><div>Below patch will call __init_PMU functions in setup and restore. Please check if this looks good</div><div><br class=""></div><div>--</div><div><div>diff --git a/arch/powerpc/kernel/cpu_setup_power.S b/arch/powerpc/kernel/cpu_setup_power.S</div><div>index efdcfa714106..e672a6c5fd7c 100644</div><div>--- a/arch/powerpc/kernel/cpu_setup_power.S</div><div>+++ b/arch/powerpc/kernel/cpu_setup_power.S</div><div>@@ -94,6 +94,9 @@ _GLOBAL(__restore_cpu_power8)</div><div> _GLOBAL(__setup_cpu_power10)</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>mflr<span class="Apple-tab-span" style="white-space:pre">        </span>r11</div><div> <span class="Apple-tab-span" style="white-space:pre">    </span>bl<span class="Apple-tab-span" style="white-space:pre">  </span>__init_FSCR_power10</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>bl<span class="Apple-tab-span" style="white-space:pre">  </span>__init_PMU</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>bl<span class="Apple-tab-span" style="white-space:pre">  </span>__init_PMU_ISA31</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>bl<span class="Apple-tab-span" style="white-space:pre">  </span>__init_PMU_HV</div><div> <span class="Apple-tab-span" style="white-space:pre">  </span>b<span class="Apple-tab-span" style="white-space:pre">   </span>1f</div><div> </div><div> _GLOBAL(__setup_cpu_power9)</div><div>@@ -124,6 +127,9 @@ _GLOBAL(__setup_cpu_power9)</div><div> _GLOBAL(__restore_cpu_power10)</div><div> <span class="Apple-tab-span" style="white-space:pre">       </span>mflr<span class="Apple-tab-span" style="white-space:pre">        </span>r11</div><div> <span class="Apple-tab-span" style="white-space:pre">    </span>bl<span class="Apple-tab-span" style="white-space:pre">  </span>__init_FSCR_power10</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>bl<span class="Apple-tab-span" style="white-space:pre">  </span>__init_PMU</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>bl<span class="Apple-tab-span" style="white-space:pre">  </span>__init_PMU_ISA31</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>bl<span class="Apple-tab-span" style="white-space:pre">  </span>__init_PMU_HV</div><div> <span class="Apple-tab-span" style="white-space:pre">  </span>b<span class="Apple-tab-span" style="white-space:pre">   </span>1f</div><div> </div><div> _GLOBAL(__restore_cpu_power9)</div><div>@@ -233,3 +239,10 @@ __init_PMU_ISA207:</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>li<span class="Apple-tab-span" style="white-space:pre">  </span>r5,0</div><div> <span class="Apple-tab-span" style="white-space:pre">   </span>mtspr<span class="Apple-tab-span" style="white-space:pre">       </span>SPRN_MMCRS,r5</div><div> <span class="Apple-tab-span" style="white-space:pre">  </span>blr</div><div>+</div><div>+__init_PMU_ISA31:</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>li<span class="Apple-tab-span" style="white-space:pre">  </span>r5,0</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>mtspr<span class="Apple-tab-span" style="white-space:pre">       </span>SPRN_MMCR3,r5</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>LOAD_REG_IMMEDIATE(r5, MMCRA_BHRB_DISABLE)</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>mtspr<span class="Apple-tab-span" style="white-space:pre">       </span>SPRN_MMCRA,r5</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>blr</div><div><br class=""></div><div>—</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">       b       1f<br class=""><br class="">_GLOBAL(__setup_cpu_power9)<br class="">@@ -233,3 +234,10 @@ __init_PMU_ISA207:<br class="">       li      r5,0<br class="">       mtspr   SPRN_MMCRS,r5<br class="">       blr<br class="">+<br class="">+__init_PMU_ISA31:<br class="">+       li      r5,0<br class="">+       mtspr   SPRN_MMCR3,r5<br class="">+       LOAD_REG_IMMEDIATE(r5, MMCRA_BHRB_DISABLE)<br class="">+       mtspr   SPRN_MMCRA,r5<br class="">+       blr<br class="">diff --git a/arch/powerpc/kernel/dt_cpu_ftrs.c b/arch/powerpc/kernel/dt_cpu_ftrs.c<br class="">index 3a40951..f482286 100644<br class="">--- a/arch/powerpc/kernel/dt_cpu_ftrs.c<br class="">+++ b/arch/powerpc/kernel/dt_cpu_ftrs.c<br class="">@@ -450,6 +450,31 @@ static int __init feat_enable_pmu_power9(struct dt_cpu_feature *f)<br class="">       return 1;<br class="">}<br class=""><br class="">+static void init_pmu_power10(void)<br class="">+{<br class="">+       init_pmu_power9();<br class="">+<br class="">+       mtspr(SPRN_MMCR3, 0);<br class="">+       mtspr(SPRN_MMCRA, MMCRA_BHRB_DISABLE);<br class="">+}<br class="">+<br class="">+static int __init feat_enable_pmu_power10(struct dt_cpu_feature *f)<br class="">+{<br class="">+       hfscr_pmu_enable();<br class="">+<br class="">+       init_pmu_power10();<br class="">+       init_pmu_registers = init_pmu_power10;<br class="">+<br class="">+       cur_cpu_spec->cpu_features |= CPU_FTR_MMCRA;<br class="">+       cur_cpu_spec->cpu_user_features |= PPC_FEATURE_PSERIES_PERFMON_COMPAT;<br class="">+<br class="">+       cur_cpu_spec->num_pmcs          = 6;<br class="">+       cur_cpu_spec->pmc_type          = PPC_PMC_IBM;<br class="">+       cur_cpu_spec->oprofile_cpu_type = "ppc64/power10";<br class="">+<br class="">+       return 1;<br class="">+}<br class="">+<br class="">static int __init feat_enable_tm(struct dt_cpu_feature *f)<br class="">{<br class="">#ifdef CONFIG_PPC_TRANSACTIONAL_MEM<br class="">@@ -639,6 +664,7 @@ struct dt_cpu_feature_match {<br class="">       {"pc-relative-addressing", feat_enable, 0},<br class="">       {"machine-check-power9", feat_enable_mce_power9, 0},<br class="">       {"performance-monitor-power9", feat_enable_pmu_power9, 0},<br class="">+       {"performance-monitor-power10", feat_enable_pmu_power10, 0},<br class="">       {"event-based-branch-v3", feat_enable, 0},<br class="">       {"random-number-generator", feat_enable, 0},<br class="">       {"system-call-vectored", feat_disable, 0},<br class="">--<br class="">1.8.3.1</blockquote></div></blockquote></div><br class=""></body></html>