~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/s390/include/asm/cpu_mcf.h

Version: ~ [ linux-5.4-rc3 ] ~ [ linux-5.3.6 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.79 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.149 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.196 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.196 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.75 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * Counter facility support definitions for the Linux perf
  4  *
  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
 10 
 11 #include <linux/perf_event.h>
 12 #include <asm/cpu_mf.h>
 13 
 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 */
 20 
 21         /* Maximum number of counter sets */
 22         CPUMF_CTR_SET_MAX,
 23 };
 24 
 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,
 33 };
 34 
 35 static inline void ctr_set_enable(u64 *state, int ctr_set)
 36 {
 37         *state |= cpumf_ctr_ctl[ctr_set] << CPUMF_LCCTL_ENABLE_SHIFT;
 38 }
 39 static inline void ctr_set_disable(u64 *state, int ctr_set)
 40 {
 41         *state &= ~(cpumf_ctr_ctl[ctr_set] << CPUMF_LCCTL_ENABLE_SHIFT);
 42 }
 43 static inline void ctr_set_start(u64 *state, int ctr_set)
 44 {
 45         *state |= cpumf_ctr_ctl[ctr_set] << CPUMF_LCCTL_ACTCTL_SHIFT;
 46 }
 47 static inline void ctr_set_stop(u64 *state, int ctr_set)
 48 {
 49         *state &= ~(cpumf_ctr_ctl[ctr_set] << CPUMF_LCCTL_ACTCTL_SHIFT);
 50 }
 51 
 52 static inline void ctr_set_multiple_enable(u64 *state, u64 ctrsets)
 53 {
 54         *state |= ctrsets << CPUMF_LCCTL_ENABLE_SHIFT;
 55 }
 56 
 57 static inline void ctr_set_multiple_disable(u64 *state, u64 ctrsets)
 58 {
 59         *state &= ~(ctrsets << CPUMF_LCCTL_ENABLE_SHIFT);
 60 }
 61 
 62 static inline void ctr_set_multiple_start(u64 *state, u64 ctrsets)
 63 {
 64         *state |= ctrsets << CPUMF_LCCTL_ACTCTL_SHIFT;
 65 }
 66 
 67 static inline void ctr_set_multiple_stop(u64 *state, u64 ctrsets)
 68 {
 69         *state &= ~(ctrsets << CPUMF_LCCTL_ACTCTL_SHIFT);
 70 }
 71 
 72 static inline int ctr_stcctm(enum cpumf_ctr_set set, u64 range, u64 *dest)
 73 {
 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;
 87         }
 88         return 3;
 89 }
 90 
 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;
 98 };
 99 DECLARE_PER_CPU(struct cpu_cf_events, cpu_cf_events);
100 
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);
105 
106 static inline int kernel_cpumcf_begin(void)
107 {
108         if (!cpum_cf_avail())
109                 return -ENODEV;
110 
111         preempt_disable();
112         return __kernel_cpumcf_begin();
113 }
114 static inline void kernel_cpumcf_end(void)
115 {
116         __kernel_cpumcf_end();
117         preempt_enable();
118 }
119 
120 /* Return true if store counter set multiple instruction is available */
121 static inline int stccm_avail(void)
122 {
123         return test_facility(142);
124 }
125 
126 #endif /* _ASM_S390_CPU_MCF_H */
127 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp