summaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/perf_cpum_cf_common.c
diff options
context:
space:
mode:
authorThomas Richter <tmricht@linux.ibm.com>2021-04-26 14:38:25 +0200
committerHeiko Carstens <hca@linux.ibm.com>2021-04-30 17:17:00 +0200
commit1eefa4f4399b74dc7671c4e34c1b1c6244acff22 (patch)
treead2226c60c38f44eb668821746390fd14369c121 /arch/s390/kernel/perf_cpum_cf_common.c
parent0cceeab5a38d70fae3c2944e77e1d262c74d159b (diff)
downloadlinux-1eefa4f4399b74dc7671c4e34c1b1c6244acff22.tar.gz
linux-1eefa4f4399b74dc7671c4e34c1b1c6244acff22.tar.bz2
linux-1eefa4f4399b74dc7671c4e34c1b1c6244acff22.zip
s390/cpumf: move counter set size calculation to common place
The function to calculate the size of counter sets is renamed from cf_diag_ctrset_size() to cpum_cf_ctrset_size() and moved to the file containing common functions for the CPU Measurement Counter Facility. No functional change. Signed-off-by: Thomas Richter <tmricht@linux.ibm.com> Acked-by : Sumanth Korikkar <sumanthk@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'arch/s390/kernel/perf_cpum_cf_common.c')
-rw-r--r--arch/s390/kernel/perf_cpum_cf_common.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/s390/kernel/perf_cpum_cf_common.c b/arch/s390/kernel/perf_cpum_cf_common.c
index 3bced89caffb..6d53215c8484 100644
--- a/arch/s390/kernel/perf_cpum_cf_common.c
+++ b/arch/s390/kernel/perf_cpum_cf_common.c
@@ -170,6 +170,52 @@ static int cpum_cf_offline_cpu(unsigned int cpu)
return cpum_cf_setup(cpu, PMC_RELEASE);
}
+/* Return the maximum possible counter set size (in number of 8 byte counters)
+ * depending on type and model number.
+ */
+size_t cpum_cf_ctrset_size(enum cpumf_ctr_set ctrset,
+ struct cpumf_ctr_info *info)
+{
+ size_t ctrset_size = 0;
+
+ switch (ctrset) {
+ case CPUMF_CTR_SET_BASIC:
+ if (info->cfvn >= 1)
+ ctrset_size = 6;
+ break;
+ case CPUMF_CTR_SET_USER:
+ if (info->cfvn == 1)
+ ctrset_size = 6;
+ else if (info->cfvn >= 3)
+ ctrset_size = 2;
+ break;
+ case CPUMF_CTR_SET_CRYPTO:
+ if (info->csvn >= 1 && info->csvn <= 5)
+ ctrset_size = 16;
+ else if (info->csvn == 6)
+ ctrset_size = 20;
+ break;
+ case CPUMF_CTR_SET_EXT:
+ if (info->csvn == 1)
+ ctrset_size = 32;
+ else if (info->csvn == 2)
+ ctrset_size = 48;
+ else if (info->csvn >= 3 && info->csvn <= 5)
+ ctrset_size = 128;
+ else if (info->csvn == 6)
+ ctrset_size = 160;
+ break;
+ case CPUMF_CTR_SET_MT_DIAG:
+ if (info->csvn > 3)
+ ctrset_size = 48;
+ break;
+ case CPUMF_CTR_SET_MAX:
+ break;
+ }
+
+ return ctrset_size;
+}
+
static int __init cpum_cf_init(void)
{
int rc;