staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / arch / s390 / include / asm / cpu_mcf.h
blob649b9fc606855d40fa9b895b3615ca84f42501c1
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Counter facility support definitions for the Linux perf
5 * Copyright IBM Corp. 2019
6 * Author(s): Hendrik Brueckner <brueckner@linux.ibm.com>
7 */
8 #ifndef _ASM_S390_CPU_MCF_H
9 #define _ASM_S390_CPU_MCF_H
11 #include <linux/perf_event.h>
12 #include <asm/cpu_mf.h>
14 enum cpumf_ctr_set {
15 CPUMF_CTR_SET_BASIC = 0, /* Basic Counter Set */
16 CPUMF_CTR_SET_USER = 1, /* Problem-State Counter Set */
17 CPUMF_CTR_SET_CRYPTO = 2, /* Crypto-Activity Counter Set */
18 CPUMF_CTR_SET_EXT = 3, /* Extended Counter Set */
19 CPUMF_CTR_SET_MT_DIAG = 4, /* MT-diagnostic Counter Set */
21 /* Maximum number of counter sets */
22 CPUMF_CTR_SET_MAX,
25 #define CPUMF_LCCTL_ENABLE_SHIFT 16
26 #define CPUMF_LCCTL_ACTCTL_SHIFT 0
27 static const u64 cpumf_ctr_ctl[CPUMF_CTR_SET_MAX] = {
28 [CPUMF_CTR_SET_BASIC] = 0x02,
29 [CPUMF_CTR_SET_USER] = 0x04,
30 [CPUMF_CTR_SET_CRYPTO] = 0x08,
31 [CPUMF_CTR_SET_EXT] = 0x01,
32 [CPUMF_CTR_SET_MT_DIAG] = 0x20,
35 static inline void ctr_set_enable(u64 *state, int ctr_set)
37 *state |= cpumf_ctr_ctl[ctr_set] << CPUMF_LCCTL_ENABLE_SHIFT;
39 static inline void ctr_set_disable(u64 *state, int ctr_set)
41 *state &= ~(cpumf_ctr_ctl[ctr_set] << CPUMF_LCCTL_ENABLE_SHIFT);
43 static inline void ctr_set_start(u64 *state, int ctr_set)
45 *state |= cpumf_ctr_ctl[ctr_set] << CPUMF_LCCTL_ACTCTL_SHIFT;
47 static inline void ctr_set_stop(u64 *state, int ctr_set)
49 *state &= ~(cpumf_ctr_ctl[ctr_set] << CPUMF_LCCTL_ACTCTL_SHIFT);
52 static inline void ctr_set_multiple_enable(u64 *state, u64 ctrsets)
54 *state |= ctrsets << CPUMF_LCCTL_ENABLE_SHIFT;
57 static inline void ctr_set_multiple_disable(u64 *state, u64 ctrsets)
59 *state &= ~(ctrsets << CPUMF_LCCTL_ENABLE_SHIFT);
62 static inline void ctr_set_multiple_start(u64 *state, u64 ctrsets)
64 *state |= ctrsets << CPUMF_LCCTL_ACTCTL_SHIFT;
67 static inline void ctr_set_multiple_stop(u64 *state, u64 ctrsets)
69 *state &= ~(ctrsets << CPUMF_LCCTL_ACTCTL_SHIFT);
72 static inline int ctr_stcctm(enum cpumf_ctr_set set, u64 range, u64 *dest)
74 switch (set) {
75 case CPUMF_CTR_SET_BASIC:
76 return stcctm(BASIC, range, dest);
77 case CPUMF_CTR_SET_USER:
78 return stcctm(PROBLEM_STATE, range, dest);
79 case CPUMF_CTR_SET_CRYPTO:
80 return stcctm(CRYPTO_ACTIVITY, range, dest);
81 case CPUMF_CTR_SET_EXT:
82 return stcctm(EXTENDED, range, dest);
83 case CPUMF_CTR_SET_MT_DIAG:
84 return stcctm(MT_DIAG_CLEARING, range, dest);
85 case CPUMF_CTR_SET_MAX:
86 return 3;
88 return 3;
91 struct cpu_cf_events {
92 struct cpumf_ctr_info info;
93 atomic_t ctr_set[CPUMF_CTR_SET_MAX];
94 atomic64_t alert;
95 u64 state, tx_state;
96 unsigned int flags;
97 unsigned int txn_flags;
99 DECLARE_PER_CPU(struct cpu_cf_events, cpu_cf_events);
101 bool kernel_cpumcf_avail(void);
102 int __kernel_cpumcf_begin(void);
103 unsigned long kernel_cpumcf_alert(int clear);
104 void __kernel_cpumcf_end(void);
106 static inline int kernel_cpumcf_begin(void)
108 if (!cpum_cf_avail())
109 return -ENODEV;
111 preempt_disable();
112 return __kernel_cpumcf_begin();
114 static inline void kernel_cpumcf_end(void)
116 __kernel_cpumcf_end();
117 preempt_enable();
120 /* Return true if store counter set multiple instruction is available */
121 static inline int stccm_avail(void)
123 return test_facility(142);
126 #endif /* _ASM_S390_CPU_MCF_H */