git: fdfeaa66b58a - main - Support of optional PMC classes.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 26 Jun 2022 09:19:03 UTC
The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=fdfeaa66b58a49ee1bb40f9d447c610402231f20 commit fdfeaa66b58a49ee1bb40f9d447c610402231f20 Author: Aleksandr Rybalko <ray@freebsd.org> AuthorDate: 2022-02-16 00:18:04 +0000 Commit: Toomas Soome <tsoome@FreeBSD.org> CommitDate: 2022-06-26 05:55:09 +0000 Support of optional PMC classes. Reviewed by: mhorne Differential Revision: https://reviews.freebsd.org/D32316 --- sys/dev/hwpmc/hwpmc_arm64.c | 21 ++++++++++++++++++--- sys/dev/hwpmc/hwpmc_mod.c | 20 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c index 03f85a593d1a..9b530a7b2ddf 100644 --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -531,7 +531,7 @@ pmc_arm64_initialize() { struct pmc_mdep *pmc_mdep; struct pmc_classdep *pcd; - int idcode, impcode; + int classes, idcode, impcode; int reg; uint64_t midr; @@ -561,8 +561,16 @@ pmc_arm64_initialize() arm64_pcpu = malloc(sizeof(struct arm64_cpu *) * pmc_cpu_max(), M_PMC, M_WAITOK | M_ZERO); - /* Just one class */ - pmc_mdep = pmc_mdep_alloc(1); + /* One AArch64 CPU class */ + classes = 1; + + /* Query presence of optional classes and set max class. */ + if (pmc_cmn600_nclasses() > 0) + classes = MAX(classes, PMC_MDEP_CLASS_INDEX_CMN600); + if (pmc_dmc620_nclasses() > 0) + classes = MAX(classes, PMC_MDEP_CLASS_INDEX_DMC620_C); + + pmc_mdep = pmc_mdep_alloc(classes); switch(impcode) { case PMCR_IMP_ARM: @@ -611,6 +619,13 @@ pmc_arm64_initialize() pmc_mdep->pmd_npmc += arm64_npmcs; + if (pmc_cmn600_nclasses() > 0) + pmc_cmn600_initialize(pmc_mdep); + if (pmc_dmc620_nclasses() > 0) { + pmc_dmc620_initialize_cd2(pmc_mdep); + pmc_dmc620_initialize_c(pmc_mdep); + } + return (pmc_mdep); } diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 50b4f3bc9d3b..1a7f2869d9b9 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -5600,6 +5600,16 @@ pmc_initialize(void) return (ENOSYS); } + /* + * Refresh classes base ri. Optional classes may come in different + * order. + */ + for (ri = c = 0; c < md->pmd_nclass; c++) { + pcd = &md->pmd_classdep[c]; + pcd->pcd_ri = ri; + ri += pcd->pcd_num; + } + KASSERT(md->pmd_nclass >= 1 && md->pmd_npmc >= 1, ("[pmc,%d] no classes or pmcs", __LINE__)); @@ -5642,7 +5652,9 @@ pmc_initialize(void) if (md->pmd_pcpu_init) error = md->pmd_pcpu_init(md, cpu); for (n = 0; error == 0 && n < md->pmd_nclass; n++) - error = md->pmd_classdep[n].pcd_pcpu_init(md, cpu); + if (md->pmd_classdep[n].pcd_num > 0) + error = md->pmd_classdep[n].pcd_pcpu_init(md, + cpu); } pmc_restore_cpu_binding(&pb); @@ -5755,6 +5767,8 @@ pmc_initialize(void) if (error == 0) { printf(PMC_MODULE_NAME ":"); for (n = 0; n < (int) md->pmd_nclass; n++) { + if (md->pmd_classdep[n].pcd_num == 0) + continue; pcd = &md->pmd_classdep[n]; printf(" %s/%d/%d/0x%b", pmc_name_of_pmcclass(pcd->pcd_class), @@ -5877,7 +5891,9 @@ pmc_cleanup(void) continue; pmc_select_cpu(cpu); for (c = 0; c < md->pmd_nclass; c++) - md->pmd_classdep[c].pcd_pcpu_fini(md, cpu); + if (md->pmd_classdep[c].pcd_num > 0) + md->pmd_classdep[c].pcd_pcpu_fini(md, + cpu); if (md->pmd_pcpu_fini) md->pmd_pcpu_fini(md, cpu); }