Commit 1eefa4f4 authored by Thomas Richter's avatar Thomas Richter Committed by Heiko Carstens

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: default avatarThomas Richter <tmricht@linux.ibm.com>
Acked-by : Sumanth Korikkar <sumanthk@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 0cceeab5
...@@ -123,4 +123,6 @@ static inline int stccm_avail(void) ...@@ -123,4 +123,6 @@ static inline int stccm_avail(void)
return test_facility(142); return test_facility(142);
} }
size_t cpum_cf_ctrset_size(enum cpumf_ctr_set ctrset,
struct cpumf_ctr_info *info);
#endif /* _ASM_S390_CPU_MCF_H */ #endif /* _ASM_S390_CPU_MCF_H */
...@@ -170,6 +170,52 @@ static int cpum_cf_offline_cpu(unsigned int cpu) ...@@ -170,6 +170,52 @@ static int cpum_cf_offline_cpu(unsigned int cpu)
return cpum_cf_setup(cpu, PMC_RELEASE); 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) static int __init cpum_cf_init(void)
{ {
int rc; int rc;
......
...@@ -316,52 +316,6 @@ static void cf_diag_read(struct perf_event *event) ...@@ -316,52 +316,6 @@ static void cf_diag_read(struct perf_event *event)
debug_sprintf_event(cf_diag_dbg, 5, "%s event %p\n", __func__, event); debug_sprintf_event(cf_diag_dbg, 5, "%s event %p\n", __func__, event);
} }
/* Return the maximum possible counter set size (in number of 8 byte counters)
* depending on type and model number.
*/
static size_t cf_diag_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;
}
/* Calculate memory needed to store all counter sets together with header and /* Calculate memory needed to store all counter sets together with header and
* trailer data. This is independend of the counter set authorization which * trailer data. This is independend of the counter set authorization which
* can vary depending on the configuration. * can vary depending on the configuration.
...@@ -372,7 +326,7 @@ static size_t cf_diag_ctrset_maxsize(struct cpumf_ctr_info *info) ...@@ -372,7 +326,7 @@ static size_t cf_diag_ctrset_maxsize(struct cpumf_ctr_info *info)
enum cpumf_ctr_set i; enum cpumf_ctr_set i;
for (i = CPUMF_CTR_SET_BASIC; i < CPUMF_CTR_SET_MAX; ++i) { for (i = CPUMF_CTR_SET_BASIC; i < CPUMF_CTR_SET_MAX; ++i) {
size_t size = cf_diag_ctrset_size(i, info); size_t size = cpum_cf_ctrset_size(i, info);
if (size) if (size)
max_size += size * sizeof(u64) + max_size += size * sizeof(u64) +
...@@ -405,7 +359,7 @@ static size_t cf_diag_getctrset(struct cf_ctrset_entry *ctrdata, int ctrset, ...@@ -405,7 +359,7 @@ static size_t cf_diag_getctrset(struct cf_ctrset_entry *ctrdata, int ctrset,
ctrdata->def = CF_DIAG_CTRSET_DEF; ctrdata->def = CF_DIAG_CTRSET_DEF;
ctrdata->set = ctrset; ctrdata->set = ctrset;
ctrdata->res1 = 0; ctrdata->res1 = 0;
ctrset_size = cf_diag_ctrset_size(ctrset, &cpuhw->info); ctrset_size = cpum_cf_ctrset_size(ctrset, &cpuhw->info);
if (ctrset_size) { /* Save data */ if (ctrset_size) { /* Save data */
need = ctrset_size * sizeof(u64) + sizeof(*ctrdata); need = ctrset_size * sizeof(u64) + sizeof(*ctrdata);
...@@ -845,7 +799,7 @@ static void cf_diag_cpu_read(void *parm) ...@@ -845,7 +799,7 @@ static void cf_diag_cpu_read(void *parm)
if (!(p->sets & cpumf_ctr_ctl[set])) if (!(p->sets & cpumf_ctr_ctl[set]))
continue; /* Counter set not in list */ continue; /* Counter set not in list */
set_size = cf_diag_ctrset_size(set, &cpuhw->info); set_size = cpum_cf_ctrset_size(set, &cpuhw->info);
space = sizeof(csd->data) - csd->used; space = sizeof(csd->data) - csd->used;
space = cf_diag_cpuset_read(sp, set, set_size, space); space = cf_diag_cpuset_read(sp, set, set_size, space);
if (space) { if (space) {
...@@ -975,7 +929,7 @@ static size_t cf_diag_needspace(unsigned int sets) ...@@ -975,7 +929,7 @@ static size_t cf_diag_needspace(unsigned int sets)
for (i = CPUMF_CTR_SET_BASIC; i < CPUMF_CTR_SET_MAX; ++i) { for (i = CPUMF_CTR_SET_BASIC; i < CPUMF_CTR_SET_MAX; ++i) {
if (!(sets & cpumf_ctr_ctl[i])) if (!(sets & cpumf_ctr_ctl[i]))
continue; continue;
bytes += cf_diag_ctrset_size(i, &cpuhw->info) * sizeof(u64) + bytes += cpum_cf_ctrset_size(i, &cpuhw->info) * sizeof(u64) +
sizeof(((struct s390_ctrset_setdata *)0)->set) + sizeof(((struct s390_ctrset_setdata *)0)->set) +
sizeof(((struct s390_ctrset_setdata *)0)->no_cnts); sizeof(((struct s390_ctrset_setdata *)0)->no_cnts);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment