.. | .. |
---|
12 | 12 | #include <linux/errno.h> |
---|
13 | 13 | #include <asm/facility.h> |
---|
14 | 14 | |
---|
| 15 | +asm(".include \"asm/cpu_mf-insn.h\"\n"); |
---|
| 16 | + |
---|
15 | 17 | #define CPU_MF_INT_SF_IAE (1 << 31) /* invalid entry address */ |
---|
16 | 18 | #define CPU_MF_INT_SF_ISE (1 << 30) /* incorrect SDBT entry */ |
---|
17 | 19 | #define CPU_MF_INT_SF_PRA (1 << 29) /* program request alert */ |
---|
.. | .. |
---|
25 | 27 | #define CPU_MF_INT_SF_MASK (CPU_MF_INT_SF_IAE|CPU_MF_INT_SF_ISE| \ |
---|
26 | 28 | CPU_MF_INT_SF_PRA|CPU_MF_INT_SF_SACA| \ |
---|
27 | 29 | CPU_MF_INT_SF_LSDA) |
---|
| 30 | + |
---|
| 31 | +#define CPU_MF_SF_RIBM_NOTAV 0x1 /* Sampling unavailable */ |
---|
28 | 32 | |
---|
29 | 33 | /* CPU measurement facility support */ |
---|
30 | 34 | static inline int cpum_cf_avail(void) |
---|
.. | .. |
---|
67 | 71 | unsigned long max_sampl_rate; /* 16-23: maximum sampling interval*/ |
---|
68 | 72 | unsigned long tear; /* 24-31: TEAR contents */ |
---|
69 | 73 | unsigned long dear; /* 32-39: DEAR contents */ |
---|
70 | | - unsigned int rsvrd0; /* 40-43: reserved */ |
---|
71 | | - unsigned int cpu_speed; /* 44-47: CPU speed */ |
---|
| 74 | + unsigned int rsvrd0:24; /* 40-42: reserved */ |
---|
| 75 | + unsigned int ribm:8; /* 43: Reserved by IBM */ |
---|
| 76 | + unsigned int cpu_speed; /* 44-47: CPU speed */ |
---|
72 | 77 | unsigned long long rsvrd1; /* 48-55: reserved */ |
---|
73 | 78 | unsigned long long rsvrd2; /* 56-63: reserved */ |
---|
74 | 79 | } __packed; |
---|
.. | .. |
---|
87 | 92 | unsigned long tear; /* 16-23: TEAR contents */ |
---|
88 | 93 | unsigned long dear; /* 24-31: DEAR contents */ |
---|
89 | 94 | /* 32-63: */ |
---|
90 | | - unsigned long rsvrd1; /* reserved */ |
---|
91 | | - unsigned long rsvrd2; /* reserved */ |
---|
92 | | - unsigned long rsvrd3; /* reserved */ |
---|
93 | | - unsigned long rsvrd4; /* reserved */ |
---|
| 95 | + unsigned long rsvrd1; /* reserved */ |
---|
| 96 | + unsigned long rsvrd2; /* reserved */ |
---|
| 97 | + unsigned long rsvrd3; /* reserved */ |
---|
| 98 | + unsigned long rsvrd4; /* reserved */ |
---|
94 | 99 | } __packed; |
---|
95 | 100 | |
---|
96 | 101 | struct hws_basic_entry { |
---|
.. | .. |
---|
123 | 128 | struct hws_diag_entry diag; /* Diagnostic-sampling data entry */ |
---|
124 | 129 | } __packed; |
---|
125 | 130 | |
---|
126 | | -struct hws_trailer_entry { |
---|
127 | | - union { |
---|
128 | | - struct { |
---|
129 | | - unsigned int f:1; /* 0 - Block Full Indicator */ |
---|
130 | | - unsigned int a:1; /* 1 - Alert request control */ |
---|
131 | | - unsigned int t:1; /* 2 - Timestamp format */ |
---|
132 | | - unsigned int :29; /* 3 - 31: Reserved */ |
---|
133 | | - unsigned int bsdes:16; /* 32-47: size of basic SDE */ |
---|
134 | | - unsigned int dsdes:16; /* 48-63: size of diagnostic SDE */ |
---|
135 | | - }; |
---|
136 | | - unsigned long long flags; /* 0 - 63: All indicators */ |
---|
| 131 | +union hws_trailer_header { |
---|
| 132 | + struct { |
---|
| 133 | + unsigned int f:1; /* 0 - Block Full Indicator */ |
---|
| 134 | + unsigned int a:1; /* 1 - Alert request control */ |
---|
| 135 | + unsigned int t:1; /* 2 - Timestamp format */ |
---|
| 136 | + unsigned int :29; /* 3 - 31: Reserved */ |
---|
| 137 | + unsigned int bsdes:16; /* 32-47: size of basic SDE */ |
---|
| 138 | + unsigned int dsdes:16; /* 48-63: size of diagnostic SDE */ |
---|
| 139 | + unsigned long long overflow; /* 64 - Overflow Count */ |
---|
137 | 140 | }; |
---|
138 | | - unsigned long long overflow; /* 64 - sample Overflow count */ |
---|
| 141 | + __uint128_t val; |
---|
| 142 | +}; |
---|
| 143 | + |
---|
| 144 | +struct hws_trailer_entry { |
---|
| 145 | + union hws_trailer_header header; /* 0 - 15 Flags + Overflow Count */ |
---|
139 | 146 | unsigned char timestamp[16]; /* 16 - 31 timestamp */ |
---|
140 | 147 | unsigned long long reserved1; /* 32 -Reserved */ |
---|
141 | 148 | unsigned long long reserved2; /* */ |
---|
.. | .. |
---|
209 | 216 | return cc; |
---|
210 | 217 | } |
---|
211 | 218 | |
---|
212 | | -/* Store CPU counter multiple for the MT utilization counter set */ |
---|
213 | | -static inline int stcctm5(u64 num, u64 *val) |
---|
| 219 | +/* Store CPU counter multiple for a particular counter set */ |
---|
| 220 | +enum stcctm_ctr_set { |
---|
| 221 | + EXTENDED = 0, |
---|
| 222 | + BASIC = 1, |
---|
| 223 | + PROBLEM_STATE = 2, |
---|
| 224 | + CRYPTO_ACTIVITY = 3, |
---|
| 225 | + MT_DIAG = 5, |
---|
| 226 | + MT_DIAG_CLEARING = 9, /* clears loss-of-MT-ctr-data alert */ |
---|
| 227 | +}; |
---|
| 228 | + |
---|
| 229 | +static __always_inline int stcctm(enum stcctm_ctr_set set, u64 range, u64 *dest) |
---|
214 | 230 | { |
---|
215 | 231 | int cc; |
---|
216 | 232 | |
---|
217 | 233 | asm volatile ( |
---|
218 | | - " .insn rsy,0xeb0000000017,%2,5,%1\n" |
---|
| 234 | + " STCCTM %2,%3,%1\n" |
---|
219 | 235 | " ipm %0\n" |
---|
220 | 236 | " srl %0,28\n" |
---|
221 | 237 | : "=d" (cc) |
---|
222 | | - : "Q" (*val), "d" (num) |
---|
| 238 | + : "Q" (*dest), "d" (range), "i" (set) |
---|
223 | 239 | : "cc", "memory"); |
---|
224 | 240 | return cc; |
---|
225 | 241 | } |
---|
.. | .. |
---|
273 | 289 | return USEC_PER_SEC * qsi->cpu_speed / rate; |
---|
274 | 290 | } |
---|
275 | 291 | |
---|
276 | | -#define SDB_TE_ALERT_REQ_MASK 0x4000000000000000UL |
---|
277 | | -#define SDB_TE_BUFFER_FULL_MASK 0x8000000000000000UL |
---|
278 | | - |
---|
279 | 292 | /* Return TOD timestamp contained in an trailer entry */ |
---|
280 | 293 | static inline unsigned long long trailer_timestamp(struct hws_trailer_entry *te) |
---|
281 | 294 | { |
---|
282 | 295 | /* TOD in STCKE format */ |
---|
283 | | - if (te->t) |
---|
| 296 | + if (te->header.t) |
---|
284 | 297 | return *((unsigned long long *) &te->timestamp[1]); |
---|
285 | 298 | |
---|
286 | 299 | /* TOD in STCK format */ |
---|
.. | .. |
---|
299 | 312 | return (unsigned long *) ret; |
---|
300 | 313 | } |
---|
301 | 314 | |
---|
302 | | -/* Return if the entry in the sample data block table (sdbt) |
---|
| 315 | +/* Return true if the entry in the sample data block table (sdbt) |
---|
303 | 316 | * is a link to the next sdbt */ |
---|
304 | 317 | static inline int is_link_entry(unsigned long *s) |
---|
305 | 318 | { |
---|