]>
Commit | Line | Data |
---|---|---|
87bee290 SKC |
1 | /* |
2 | * Intel SOC Telemetry debugfs Driver: Currently supports APL | |
3 | * Copyright (c) 2015, Intel Corporation. | |
4 | * All Rights Reserved. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms and conditions of the GNU General Public License, | |
8 | * version 2, as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope it will be useful, but WITHOUT | |
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | * more details. | |
14 | * | |
15 | * This file provides the debugfs interfaces for telemetry. | |
16 | * /sys/kernel/debug/telemetry/pss_info: Shows Primary Control Sub-Sys Counters | |
17 | * /sys/kernel/debug/telemetry/ioss_info: Shows IO Sub-System Counters | |
18 | * /sys/kernel/debug/telemetry/soc_states: Shows SoC State | |
19 | * /sys/kernel/debug/telemetry/pss_trace_verbosity: Read and Change Tracing | |
20 | * Verbosity via firmware | |
21 | * /sys/kernel/debug/telemetry/ioss_race_verbosity: Write and Change Tracing | |
22 | * Verbosity via firmware | |
23 | */ | |
24 | #include <linux/module.h> | |
25 | #include <linux/init.h> | |
26 | #include <linux/device.h> | |
27 | #include <linux/debugfs.h> | |
28 | #include <linux/seq_file.h> | |
29 | #include <linux/io.h> | |
30 | #include <linux/uaccess.h> | |
31 | #include <linux/pci.h> | |
32 | #include <linux/suspend.h> | |
33 | ||
34 | #include <asm/cpu_device_id.h> | |
678dec00 | 35 | #include <asm/intel-family.h> |
87bee290 SKC |
36 | #include <asm/intel_pmc_ipc.h> |
37 | #include <asm/intel_punit_ipc.h> | |
38 | #include <asm/intel_telemetry.h> | |
39 | ||
40 | #define DRIVER_NAME "telemetry_soc_debugfs" | |
41 | #define DRIVER_VERSION "1.0.0" | |
42 | ||
43 | /* ApolloLake SoC Event-IDs */ | |
44 | #define TELEM_APL_PSS_PSTATES_ID 0x2802 | |
45 | #define TELEM_APL_PSS_IDLE_ID 0x2806 | |
46 | #define TELEM_APL_PCS_IDLE_BLOCKED_ID 0x2C00 | |
47 | #define TELEM_APL_PCS_S0IX_BLOCKED_ID 0x2C01 | |
48 | #define TELEM_APL_PSS_WAKEUP_ID 0x2C02 | |
49 | #define TELEM_APL_PSS_LTR_BLOCKING_ID 0x2C03 | |
50 | ||
51 | #define TELEM_APL_S0IX_TOTAL_OCC_ID 0x4000 | |
52 | #define TELEM_APL_S0IX_SHLW_OCC_ID 0x4001 | |
53 | #define TELEM_APL_S0IX_DEEP_OCC_ID 0x4002 | |
54 | #define TELEM_APL_S0IX_TOTAL_RES_ID 0x4800 | |
55 | #define TELEM_APL_S0IX_SHLW_RES_ID 0x4801 | |
56 | #define TELEM_APL_S0IX_DEEP_RES_ID 0x4802 | |
57 | #define TELEM_APL_D0IX_ID 0x581A | |
58 | #define TELEM_APL_D3_ID 0x5819 | |
59 | #define TELEM_APL_PG_ID 0x5818 | |
60 | ||
61 | #define TELEM_INFO_SRAMEVTS_MASK 0xFF00 | |
62 | #define TELEM_INFO_SRAMEVTS_SHIFT 0x8 | |
63 | #define TELEM_SSRAM_READ_TIMEOUT 10 | |
64 | ||
65 | #define TELEM_MASK_BIT 1 | |
66 | #define TELEM_MASK_BYTE 0xFF | |
67 | #define BYTES_PER_LONG 8 | |
68 | #define TELEM_APL_MASK_PCS_STATE 0xF | |
69 | ||
70 | /* Max events in bitmap to check for */ | |
71 | #define TELEM_PSS_IDLE_EVTS 25 | |
72 | #define TELEM_PSS_IDLE_BLOCKED_EVTS 20 | |
73 | #define TELEM_PSS_S0IX_BLOCKED_EVTS 20 | |
74 | #define TELEM_PSS_S0IX_WAKEUP_EVTS 20 | |
75 | #define TELEM_PSS_LTR_BLOCKING_EVTS 20 | |
76 | #define TELEM_IOSS_DX_D0IX_EVTS 25 | |
77 | #define TELEM_IOSS_PG_EVTS 30 | |
78 | ||
87bee290 | 79 | #define TELEM_DEBUGFS_CPU(model, data) \ |
08a24516 | 80 | { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned long)&data} |
87bee290 SKC |
81 | |
82 | #define TELEM_CHECK_AND_PARSE_EVTS(EVTID, EVTNUM, BUF, EVTLOG, EVTDAT, MASK) { \ | |
83 | if (evtlog[index].telem_evtid == (EVTID)) { \ | |
84 | for (idx = 0; idx < (EVTNUM); idx++) \ | |
85 | (BUF)[idx] = ((EVTLOG) >> (EVTDAT)[idx].bit_pos) & \ | |
86 | (MASK); \ | |
87 | continue; \ | |
88 | } \ | |
89 | } | |
90 | ||
91 | #define TELEM_CHECK_AND_PARSE_CTRS(EVTID, CTR) { \ | |
92 | if (evtlog[index].telem_evtid == (EVTID)) { \ | |
93 | (CTR) = evtlog[index].telem_evtlog; \ | |
94 | continue; \ | |
95 | } \ | |
96 | } | |
97 | ||
98 | static u8 suspend_prep_ok; | |
99 | static u32 suspend_shlw_ctr_temp, suspend_deep_ctr_temp; | |
100 | static u64 suspend_shlw_res_temp, suspend_deep_res_temp; | |
101 | ||
102 | struct telemetry_susp_stats { | |
103 | u32 shlw_swake_ctr; | |
104 | u32 deep_swake_ctr; | |
105 | u64 shlw_swake_res; | |
106 | u64 deep_swake_res; | |
107 | u32 shlw_ctr; | |
108 | u32 deep_ctr; | |
109 | u64 shlw_res; | |
110 | u64 deep_res; | |
111 | }; | |
112 | ||
113 | /* Bitmap definitions for default counters in APL */ | |
114 | struct telem_pss_idle_stateinfo { | |
115 | const char *name; | |
116 | u32 bit_pos; | |
117 | }; | |
118 | ||
119 | static struct telem_pss_idle_stateinfo telem_apl_pss_idle_data[] = { | |
120 | {"IA_CORE0_C1E", 0}, | |
121 | {"IA_CORE1_C1E", 1}, | |
122 | {"IA_CORE2_C1E", 2}, | |
123 | {"IA_CORE3_C1E", 3}, | |
124 | {"IA_CORE0_C6", 16}, | |
125 | {"IA_CORE1_C6", 17}, | |
126 | {"IA_CORE2_C6", 18}, | |
127 | {"IA_CORE3_C6", 19}, | |
128 | {"IA_MODULE0_C7", 32}, | |
129 | {"IA_MODULE1_C7", 33}, | |
130 | {"GT_RC6", 40}, | |
131 | {"IUNIT_PROCESSING_IDLE", 41}, | |
132 | {"FAR_MEM_IDLE", 43}, | |
133 | {"DISPLAY_IDLE", 44}, | |
134 | {"IUNIT_INPUT_SYSTEM_IDLE", 45}, | |
135 | {"PCS_STATUS", 60}, | |
136 | }; | |
137 | ||
138 | struct telem_pcs_blkd_info { | |
139 | const char *name; | |
140 | u32 bit_pos; | |
141 | }; | |
142 | ||
143 | static struct telem_pcs_blkd_info telem_apl_pcs_idle_blkd_data[] = { | |
144 | {"COMPUTE", 0}, | |
145 | {"MISC", 8}, | |
146 | {"MODULE_ACTIONS_PENDING", 16}, | |
147 | {"LTR", 24}, | |
148 | {"DISPLAY_WAKE", 32}, | |
149 | {"ISP_WAKE", 40}, | |
150 | {"PSF0_ACTIVE", 48}, | |
151 | }; | |
152 | ||
153 | static struct telem_pcs_blkd_info telem_apl_pcs_s0ix_blkd_data[] = { | |
154 | {"LTR", 0}, | |
155 | {"IRTL", 8}, | |
156 | {"WAKE_DEADLINE_PENDING", 16}, | |
157 | {"DISPLAY", 24}, | |
158 | {"ISP", 32}, | |
159 | {"CORE", 40}, | |
160 | {"PMC", 48}, | |
161 | {"MISC", 56}, | |
162 | }; | |
163 | ||
164 | struct telem_pss_ltr_info { | |
165 | const char *name; | |
166 | u32 bit_pos; | |
167 | }; | |
168 | ||
169 | static struct telem_pss_ltr_info telem_apl_pss_ltr_data[] = { | |
170 | {"CORE_ACTIVE", 0}, | |
171 | {"MEM_UP", 8}, | |
172 | {"DFX", 16}, | |
173 | {"DFX_FORCE_LTR", 24}, | |
174 | {"DISPLAY", 32}, | |
175 | {"ISP", 40}, | |
176 | {"SOUTH", 48}, | |
177 | }; | |
178 | ||
179 | struct telem_pss_wakeup_info { | |
180 | const char *name; | |
181 | u32 bit_pos; | |
182 | }; | |
183 | ||
184 | static struct telem_pss_wakeup_info telem_apl_pss_wakeup[] = { | |
185 | {"IP_IDLE", 0}, | |
186 | {"DISPLAY_WAKE", 8}, | |
187 | {"VOLTAGE_REG_INT", 16}, | |
188 | {"DROWSY_TIMER (HOTPLUG)", 24}, | |
189 | {"CORE_WAKE", 32}, | |
190 | {"MISC_S0IX", 40}, | |
191 | {"MISC_ABORT", 56}, | |
192 | }; | |
193 | ||
194 | struct telem_ioss_d0ix_stateinfo { | |
195 | const char *name; | |
196 | u32 bit_pos; | |
197 | }; | |
198 | ||
199 | static struct telem_ioss_d0ix_stateinfo telem_apl_ioss_d0ix_data[] = { | |
200 | {"CSE", 0}, | |
201 | {"SCC2", 1}, | |
202 | {"GMM", 2}, | |
203 | {"XDCI", 3}, | |
204 | {"XHCI", 4}, | |
205 | {"ISH", 5}, | |
206 | {"AVS", 6}, | |
207 | {"PCIE0P1", 7}, | |
208 | {"PECI0P0", 8}, | |
209 | {"LPSS", 9}, | |
210 | {"SCC", 10}, | |
211 | {"PWM", 11}, | |
212 | {"PCIE1_P3", 12}, | |
213 | {"PCIE1_P2", 13}, | |
214 | {"PCIE1_P1", 14}, | |
215 | {"PCIE1_P0", 15}, | |
216 | {"CNV", 16}, | |
217 | {"SATA", 17}, | |
218 | {"PRTC", 18}, | |
219 | }; | |
220 | ||
221 | struct telem_ioss_pg_info { | |
222 | const char *name; | |
223 | u32 bit_pos; | |
224 | }; | |
225 | ||
226 | static struct telem_ioss_pg_info telem_apl_ioss_pg_data[] = { | |
227 | {"LPSS", 0}, | |
228 | {"SCC", 1}, | |
229 | {"P2SB", 2}, | |
230 | {"SCC2", 3}, | |
231 | {"GMM", 4}, | |
232 | {"PCIE0", 5}, | |
233 | {"XDCI", 6}, | |
234 | {"xHCI", 7}, | |
235 | {"CSE", 8}, | |
236 | {"SPI", 9}, | |
237 | {"AVSPGD4", 10}, | |
238 | {"AVSPGD3", 11}, | |
239 | {"AVSPGD2", 12}, | |
240 | {"AVSPGD1", 13}, | |
241 | {"ISH", 14}, | |
242 | {"EXI", 15}, | |
243 | {"NPKVRC", 16}, | |
244 | {"NPKVNN", 17}, | |
245 | {"CUNIT", 18}, | |
246 | {"FUSE_CTRL", 19}, | |
247 | {"PCIE1", 20}, | |
248 | {"CNV", 21}, | |
249 | {"LPC", 22}, | |
250 | {"SATA", 23}, | |
251 | {"SMB", 24}, | |
252 | {"PRTC", 25}, | |
253 | }; | |
254 | ||
255 | ||
256 | struct telemetry_debugfs_conf { | |
257 | struct telemetry_susp_stats suspend_stats; | |
258 | struct dentry *telemetry_dbg_dir; | |
259 | ||
260 | /* Bitmap Data */ | |
261 | struct telem_ioss_d0ix_stateinfo *ioss_d0ix_data; | |
262 | struct telem_pss_idle_stateinfo *pss_idle_data; | |
263 | struct telem_pcs_blkd_info *pcs_idle_blkd_data; | |
264 | struct telem_pcs_blkd_info *pcs_s0ix_blkd_data; | |
265 | struct telem_pss_wakeup_info *pss_wakeup; | |
266 | struct telem_pss_ltr_info *pss_ltr_data; | |
267 | struct telem_ioss_pg_info *ioss_pg_data; | |
268 | u8 pcs_idle_blkd_evts; | |
269 | u8 pcs_s0ix_blkd_evts; | |
270 | u8 pss_wakeup_evts; | |
271 | u8 pss_idle_evts; | |
272 | u8 pss_ltr_evts; | |
273 | u8 ioss_d0ix_evts; | |
274 | u8 ioss_pg_evts; | |
275 | ||
276 | /* IDs */ | |
277 | u16 pss_ltr_blocking_id; | |
278 | u16 pcs_idle_blkd_id; | |
279 | u16 pcs_s0ix_blkd_id; | |
280 | u16 s0ix_total_occ_id; | |
281 | u16 s0ix_shlw_occ_id; | |
282 | u16 s0ix_deep_occ_id; | |
283 | u16 s0ix_total_res_id; | |
284 | u16 s0ix_shlw_res_id; | |
285 | u16 s0ix_deep_res_id; | |
286 | u16 pss_wakeup_id; | |
287 | u16 ioss_d0ix_id; | |
288 | u16 pstates_id; | |
289 | u16 pss_idle_id; | |
290 | u16 ioss_d3_id; | |
291 | u16 ioss_pg_id; | |
292 | }; | |
293 | ||
294 | static struct telemetry_debugfs_conf *debugfs_conf; | |
295 | ||
296 | static struct telemetry_debugfs_conf telem_apl_debugfs_conf = { | |
297 | .pss_idle_data = telem_apl_pss_idle_data, | |
298 | .pcs_idle_blkd_data = telem_apl_pcs_idle_blkd_data, | |
299 | .pcs_s0ix_blkd_data = telem_apl_pcs_s0ix_blkd_data, | |
300 | .pss_ltr_data = telem_apl_pss_ltr_data, | |
301 | .pss_wakeup = telem_apl_pss_wakeup, | |
302 | .ioss_d0ix_data = telem_apl_ioss_d0ix_data, | |
303 | .ioss_pg_data = telem_apl_ioss_pg_data, | |
304 | ||
ae11c5b2 AP |
305 | .pss_idle_evts = ARRAY_SIZE(telem_apl_pss_idle_data), |
306 | .pcs_idle_blkd_evts = ARRAY_SIZE(telem_apl_pcs_idle_blkd_data), | |
307 | .pcs_s0ix_blkd_evts = ARRAY_SIZE(telem_apl_pcs_s0ix_blkd_data), | |
308 | .pss_ltr_evts = ARRAY_SIZE(telem_apl_pss_ltr_data), | |
309 | .pss_wakeup_evts = ARRAY_SIZE(telem_apl_pss_wakeup), | |
310 | .ioss_d0ix_evts = ARRAY_SIZE(telem_apl_ioss_d0ix_data), | |
311 | .ioss_pg_evts = ARRAY_SIZE(telem_apl_ioss_pg_data), | |
87bee290 SKC |
312 | |
313 | .pstates_id = TELEM_APL_PSS_PSTATES_ID, | |
314 | .pss_idle_id = TELEM_APL_PSS_IDLE_ID, | |
315 | .pcs_idle_blkd_id = TELEM_APL_PCS_IDLE_BLOCKED_ID, | |
316 | .pcs_s0ix_blkd_id = TELEM_APL_PCS_S0IX_BLOCKED_ID, | |
317 | .pss_wakeup_id = TELEM_APL_PSS_WAKEUP_ID, | |
318 | .pss_ltr_blocking_id = TELEM_APL_PSS_LTR_BLOCKING_ID, | |
319 | .s0ix_total_occ_id = TELEM_APL_S0IX_TOTAL_OCC_ID, | |
320 | .s0ix_shlw_occ_id = TELEM_APL_S0IX_SHLW_OCC_ID, | |
321 | .s0ix_deep_occ_id = TELEM_APL_S0IX_DEEP_OCC_ID, | |
322 | .s0ix_total_res_id = TELEM_APL_S0IX_TOTAL_RES_ID, | |
323 | .s0ix_shlw_res_id = TELEM_APL_S0IX_SHLW_RES_ID, | |
324 | .s0ix_deep_res_id = TELEM_APL_S0IX_DEEP_RES_ID, | |
325 | .ioss_d0ix_id = TELEM_APL_D0IX_ID, | |
326 | .ioss_d3_id = TELEM_APL_D3_ID, | |
327 | .ioss_pg_id = TELEM_APL_PG_ID, | |
328 | }; | |
329 | ||
330 | static const struct x86_cpu_id telemetry_debugfs_cpu_ids[] = { | |
678dec00 | 331 | TELEM_DEBUGFS_CPU(INTEL_FAM6_ATOM_GOLDMONT, telem_apl_debugfs_conf), |
54949a60 | 332 | TELEM_DEBUGFS_CPU(INTEL_FAM6_ATOM_GEMINI_LAKE, telem_apl_debugfs_conf), |
87bee290 SKC |
333 | {} |
334 | }; | |
335 | ||
336 | MODULE_DEVICE_TABLE(x86cpu, telemetry_debugfs_cpu_ids); | |
337 | ||
338 | static int telemetry_debugfs_check_evts(void) | |
339 | { | |
340 | if ((debugfs_conf->pss_idle_evts > TELEM_PSS_IDLE_EVTS) || | |
341 | (debugfs_conf->pcs_idle_blkd_evts > TELEM_PSS_IDLE_BLOCKED_EVTS) || | |
342 | (debugfs_conf->pcs_s0ix_blkd_evts > TELEM_PSS_S0IX_BLOCKED_EVTS) || | |
343 | (debugfs_conf->pss_ltr_evts > TELEM_PSS_LTR_BLOCKING_EVTS) || | |
344 | (debugfs_conf->pss_wakeup_evts > TELEM_PSS_S0IX_WAKEUP_EVTS) || | |
345 | (debugfs_conf->ioss_d0ix_evts > TELEM_IOSS_DX_D0IX_EVTS) || | |
346 | (debugfs_conf->ioss_pg_evts > TELEM_IOSS_PG_EVTS)) | |
347 | return -EINVAL; | |
348 | ||
349 | return 0; | |
350 | } | |
351 | ||
352 | static int telem_pss_states_show(struct seq_file *s, void *unused) | |
353 | { | |
354 | struct telemetry_evtlog evtlog[TELEM_MAX_OS_ALLOCATED_EVENTS]; | |
355 | struct telemetry_debugfs_conf *conf = debugfs_conf; | |
356 | const char *name[TELEM_MAX_OS_ALLOCATED_EVENTS]; | |
357 | u32 pcs_idle_blkd[TELEM_PSS_IDLE_BLOCKED_EVTS], | |
358 | pcs_s0ix_blkd[TELEM_PSS_S0IX_BLOCKED_EVTS], | |
359 | pss_s0ix_wakeup[TELEM_PSS_S0IX_WAKEUP_EVTS], | |
360 | pss_ltr_blkd[TELEM_PSS_LTR_BLOCKING_EVTS], | |
361 | pss_idle[TELEM_PSS_IDLE_EVTS]; | |
362 | int index, idx, ret, err = 0; | |
363 | u64 pstates = 0; | |
364 | ||
365 | ret = telemetry_read_eventlog(TELEM_PSS, evtlog, | |
366 | TELEM_MAX_OS_ALLOCATED_EVENTS); | |
367 | if (ret < 0) | |
368 | return ret; | |
369 | ||
370 | err = telemetry_get_evtname(TELEM_PSS, name, | |
371 | TELEM_MAX_OS_ALLOCATED_EVENTS); | |
372 | if (err < 0) | |
373 | return err; | |
374 | ||
375 | seq_puts(s, "\n----------------------------------------------------\n"); | |
376 | seq_puts(s, "\tPSS TELEM EVENTLOG (Residency = field/19.2 us\n"); | |
377 | seq_puts(s, "----------------------------------------------------\n"); | |
378 | for (index = 0; index < ret; index++) { | |
379 | seq_printf(s, "%-32s %llu\n", | |
380 | name[index], evtlog[index].telem_evtlog); | |
381 | ||
382 | /* Fetch PSS IDLE State */ | |
383 | if (evtlog[index].telem_evtid == conf->pss_idle_id) { | |
384 | pss_idle[conf->pss_idle_evts - 1] = | |
385 | (evtlog[index].telem_evtlog >> | |
386 | conf->pss_idle_data[conf->pss_idle_evts - 1].bit_pos) & | |
387 | TELEM_APL_MASK_PCS_STATE; | |
388 | } | |
389 | ||
390 | ||
391 | TELEM_CHECK_AND_PARSE_EVTS(conf->pss_idle_id, | |
392 | conf->pss_idle_evts - 1, | |
393 | pss_idle, evtlog[index].telem_evtlog, | |
394 | conf->pss_idle_data, TELEM_MASK_BIT); | |
395 | ||
396 | TELEM_CHECK_AND_PARSE_EVTS(conf->pcs_idle_blkd_id, | |
397 | conf->pcs_idle_blkd_evts, | |
398 | pcs_idle_blkd, | |
399 | evtlog[index].telem_evtlog, | |
400 | conf->pcs_idle_blkd_data, | |
401 | TELEM_MASK_BYTE); | |
402 | ||
403 | TELEM_CHECK_AND_PARSE_EVTS(conf->pcs_s0ix_blkd_id, | |
404 | conf->pcs_s0ix_blkd_evts, | |
405 | pcs_s0ix_blkd, | |
406 | evtlog[index].telem_evtlog, | |
407 | conf->pcs_s0ix_blkd_data, | |
408 | TELEM_MASK_BYTE); | |
409 | ||
410 | ||
411 | TELEM_CHECK_AND_PARSE_EVTS(conf->pss_wakeup_id, | |
412 | conf->pss_wakeup_evts, | |
413 | pss_s0ix_wakeup, | |
414 | evtlog[index].telem_evtlog, | |
415 | conf->pss_wakeup, TELEM_MASK_BYTE); | |
416 | ||
417 | TELEM_CHECK_AND_PARSE_EVTS(conf->pss_ltr_blocking_id, | |
418 | conf->pss_ltr_evts, pss_ltr_blkd, | |
419 | evtlog[index].telem_evtlog, | |
420 | conf->pss_ltr_data, TELEM_MASK_BYTE); | |
421 | ||
422 | if (evtlog[index].telem_evtid == debugfs_conf->pstates_id) | |
423 | pstates = evtlog[index].telem_evtlog; | |
424 | } | |
425 | ||
426 | seq_puts(s, "\n--------------------------------------\n"); | |
427 | seq_puts(s, "PStates\n"); | |
428 | seq_puts(s, "--------------------------------------\n"); | |
429 | seq_puts(s, "Domain\t\t\t\tFreq(Mhz)\n"); | |
430 | seq_printf(s, " IA\t\t\t\t %llu\n GT\t\t\t\t %llu\n", | |
431 | (pstates & TELEM_MASK_BYTE)*100, | |
432 | ((pstates >> 8) & TELEM_MASK_BYTE)*50/3); | |
433 | ||
434 | seq_printf(s, " IUNIT\t\t\t\t %llu\n SA\t\t\t\t %llu\n", | |
435 | ((pstates >> 16) & TELEM_MASK_BYTE)*25, | |
436 | ((pstates >> 24) & TELEM_MASK_BYTE)*50/3); | |
437 | ||
438 | seq_puts(s, "\n--------------------------------------\n"); | |
439 | seq_puts(s, "PSS IDLE Status\n"); | |
440 | seq_puts(s, "--------------------------------------\n"); | |
441 | seq_puts(s, "Device\t\t\t\t\tIDLE\n"); | |
442 | for (index = 0; index < debugfs_conf->pss_idle_evts; index++) { | |
443 | seq_printf(s, "%-32s\t%u\n", | |
444 | debugfs_conf->pss_idle_data[index].name, | |
445 | pss_idle[index]); | |
446 | } | |
447 | ||
448 | seq_puts(s, "\n--------------------------------------\n"); | |
449 | seq_puts(s, "PSS Idle blkd Status (~1ms saturating bucket)\n"); | |
450 | seq_puts(s, "--------------------------------------\n"); | |
451 | seq_puts(s, "Blocker\t\t\t\t\tCount\n"); | |
452 | for (index = 0; index < debugfs_conf->pcs_idle_blkd_evts; index++) { | |
453 | seq_printf(s, "%-32s\t%u\n", | |
454 | debugfs_conf->pcs_idle_blkd_data[index].name, | |
455 | pcs_idle_blkd[index]); | |
456 | } | |
457 | ||
458 | seq_puts(s, "\n--------------------------------------\n"); | |
459 | seq_puts(s, "PSS S0ix blkd Status (~1ms saturating bucket)\n"); | |
460 | seq_puts(s, "--------------------------------------\n"); | |
461 | seq_puts(s, "Blocker\t\t\t\t\tCount\n"); | |
462 | for (index = 0; index < debugfs_conf->pcs_s0ix_blkd_evts; index++) { | |
463 | seq_printf(s, "%-32s\t%u\n", | |
464 | debugfs_conf->pcs_s0ix_blkd_data[index].name, | |
465 | pcs_s0ix_blkd[index]); | |
466 | } | |
467 | ||
468 | seq_puts(s, "\n--------------------------------------\n"); | |
469 | seq_puts(s, "LTR Blocking Status (~1ms saturating bucket)\n"); | |
470 | seq_puts(s, "--------------------------------------\n"); | |
471 | seq_puts(s, "Blocker\t\t\t\t\tCount\n"); | |
472 | for (index = 0; index < debugfs_conf->pss_ltr_evts; index++) { | |
473 | seq_printf(s, "%-32s\t%u\n", | |
474 | debugfs_conf->pss_ltr_data[index].name, | |
475 | pss_s0ix_wakeup[index]); | |
476 | } | |
477 | ||
478 | seq_puts(s, "\n--------------------------------------\n"); | |
479 | seq_puts(s, "Wakes Status (~1ms saturating bucket)\n"); | |
480 | seq_puts(s, "--------------------------------------\n"); | |
481 | seq_puts(s, "Wakes\t\t\t\t\tCount\n"); | |
482 | for (index = 0; index < debugfs_conf->pss_wakeup_evts; index++) { | |
483 | seq_printf(s, "%-32s\t%u\n", | |
484 | debugfs_conf->pss_wakeup[index].name, | |
485 | pss_ltr_blkd[index]); | |
486 | } | |
487 | ||
488 | return 0; | |
489 | } | |
490 | ||
491 | static int telem_pss_state_open(struct inode *inode, struct file *file) | |
492 | { | |
493 | return single_open(file, telem_pss_states_show, inode->i_private); | |
494 | } | |
495 | ||
496 | static const struct file_operations telem_pss_ops = { | |
497 | .open = telem_pss_state_open, | |
498 | .read = seq_read, | |
499 | .llseek = seq_lseek, | |
500 | .release = single_release, | |
501 | }; | |
502 | ||
503 | ||
504 | static int telem_ioss_states_show(struct seq_file *s, void *unused) | |
505 | { | |
506 | struct telemetry_evtlog evtlog[TELEM_MAX_OS_ALLOCATED_EVENTS]; | |
507 | const char *name[TELEM_MAX_OS_ALLOCATED_EVENTS]; | |
508 | int index, ret, err; | |
509 | ||
510 | ret = telemetry_read_eventlog(TELEM_IOSS, evtlog, | |
511 | TELEM_MAX_OS_ALLOCATED_EVENTS); | |
512 | if (ret < 0) | |
513 | return ret; | |
514 | ||
515 | err = telemetry_get_evtname(TELEM_IOSS, name, | |
516 | TELEM_MAX_OS_ALLOCATED_EVENTS); | |
517 | if (err < 0) | |
518 | return err; | |
519 | ||
520 | seq_puts(s, "--------------------------------------\n"); | |
521 | seq_puts(s, "\tI0SS TELEMETRY EVENTLOG\n"); | |
522 | seq_puts(s, "--------------------------------------\n"); | |
523 | for (index = 0; index < ret; index++) { | |
524 | seq_printf(s, "%-32s 0x%llx\n", | |
525 | name[index], evtlog[index].telem_evtlog); | |
526 | } | |
527 | ||
528 | return 0; | |
529 | } | |
530 | ||
531 | static int telem_ioss_state_open(struct inode *inode, struct file *file) | |
532 | { | |
533 | return single_open(file, telem_ioss_states_show, inode->i_private); | |
534 | } | |
535 | ||
536 | static const struct file_operations telem_ioss_ops = { | |
537 | .open = telem_ioss_state_open, | |
538 | .read = seq_read, | |
539 | .llseek = seq_lseek, | |
540 | .release = single_release, | |
541 | }; | |
542 | ||
543 | static int telem_soc_states_show(struct seq_file *s, void *unused) | |
544 | { | |
545 | u32 d3_sts[TELEM_IOSS_DX_D0IX_EVTS], d0ix_sts[TELEM_IOSS_DX_D0IX_EVTS]; | |
546 | u32 pg_sts[TELEM_IOSS_PG_EVTS], pss_idle[TELEM_PSS_IDLE_EVTS]; | |
547 | struct telemetry_evtlog evtlog[TELEM_MAX_OS_ALLOCATED_EVENTS]; | |
548 | u32 s0ix_total_ctr = 0, s0ix_shlw_ctr = 0, s0ix_deep_ctr = 0; | |
549 | u64 s0ix_total_res = 0, s0ix_shlw_res = 0, s0ix_deep_res = 0; | |
550 | struct telemetry_debugfs_conf *conf = debugfs_conf; | |
551 | struct pci_dev *dev = NULL; | |
552 | int index, idx, ret; | |
553 | u32 d3_state; | |
554 | u16 pmcsr; | |
555 | ||
556 | ret = telemetry_read_eventlog(TELEM_IOSS, evtlog, | |
557 | TELEM_MAX_OS_ALLOCATED_EVENTS); | |
558 | if (ret < 0) | |
559 | return ret; | |
560 | ||
561 | for (index = 0; index < ret; index++) { | |
562 | TELEM_CHECK_AND_PARSE_EVTS(conf->ioss_d3_id, | |
563 | conf->ioss_d0ix_evts, | |
564 | d3_sts, evtlog[index].telem_evtlog, | |
565 | conf->ioss_d0ix_data, | |
566 | TELEM_MASK_BIT); | |
567 | ||
568 | TELEM_CHECK_AND_PARSE_EVTS(conf->ioss_pg_id, conf->ioss_pg_evts, | |
569 | pg_sts, evtlog[index].telem_evtlog, | |
570 | conf->ioss_pg_data, TELEM_MASK_BIT); | |
571 | ||
572 | TELEM_CHECK_AND_PARSE_EVTS(conf->ioss_d0ix_id, | |
573 | conf->ioss_d0ix_evts, | |
574 | d0ix_sts, evtlog[index].telem_evtlog, | |
575 | conf->ioss_d0ix_data, | |
576 | TELEM_MASK_BIT); | |
577 | ||
578 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_total_occ_id, | |
579 | s0ix_total_ctr); | |
580 | ||
581 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_shlw_occ_id, | |
582 | s0ix_shlw_ctr); | |
583 | ||
584 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_deep_occ_id, | |
585 | s0ix_deep_ctr); | |
586 | ||
587 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_total_res_id, | |
588 | s0ix_total_res); | |
589 | ||
590 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_shlw_res_id, | |
591 | s0ix_shlw_res); | |
592 | ||
593 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_deep_res_id, | |
594 | s0ix_deep_res); | |
595 | } | |
596 | ||
597 | seq_puts(s, "\n---------------------------------------------------\n"); | |
598 | seq_puts(s, "S0IX Type\t\t\t Occurrence\t\t Residency(us)\n"); | |
599 | seq_puts(s, "---------------------------------------------------\n"); | |
600 | ||
601 | seq_printf(s, "S0IX Shallow\t\t\t %10u\t %10llu\n", | |
602 | s0ix_shlw_ctr - | |
603 | conf->suspend_stats.shlw_ctr - | |
604 | conf->suspend_stats.shlw_swake_ctr, | |
605 | (u64)((s0ix_shlw_res - | |
606 | conf->suspend_stats.shlw_res - | |
607 | conf->suspend_stats.shlw_swake_res)*10/192)); | |
608 | ||
609 | seq_printf(s, "S0IX Deep\t\t\t %10u\t %10llu\n", | |
610 | s0ix_deep_ctr - | |
611 | conf->suspend_stats.deep_ctr - | |
612 | conf->suspend_stats.deep_swake_ctr, | |
613 | (u64)((s0ix_deep_res - | |
614 | conf->suspend_stats.deep_res - | |
615 | conf->suspend_stats.deep_swake_res)*10/192)); | |
616 | ||
617 | seq_printf(s, "Suspend(With S0ixShallow)\t %10u\t %10llu\n", | |
618 | conf->suspend_stats.shlw_ctr, | |
619 | (u64)(conf->suspend_stats.shlw_res*10)/192); | |
620 | ||
621 | seq_printf(s, "Suspend(With S0ixDeep)\t\t %10u\t %10llu\n", | |
622 | conf->suspend_stats.deep_ctr, | |
623 | (u64)(conf->suspend_stats.deep_res*10)/192); | |
624 | ||
625 | seq_printf(s, "Suspend(With Shallow-Wakes)\t %10u\t %10llu\n", | |
626 | conf->suspend_stats.shlw_swake_ctr + | |
627 | conf->suspend_stats.deep_swake_ctr, | |
628 | (u64)((conf->suspend_stats.shlw_swake_res + | |
629 | conf->suspend_stats.deep_swake_res)*10/192)); | |
630 | ||
631 | seq_printf(s, "S0IX+Suspend Total\t\t %10u\t %10llu\n", s0ix_total_ctr, | |
632 | (u64)(s0ix_total_res*10/192)); | |
633 | seq_puts(s, "\n-------------------------------------------------\n"); | |
634 | seq_puts(s, "\t\tDEVICE STATES\n"); | |
635 | seq_puts(s, "-------------------------------------------------\n"); | |
636 | ||
637 | for_each_pci_dev(dev) { | |
638 | pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); | |
639 | d3_state = ((pmcsr & PCI_PM_CTRL_STATE_MASK) == | |
640 | (__force int)PCI_D3hot) ? 1 : 0; | |
641 | ||
642 | seq_printf(s, "pci %04x %04X %s %20.20s: ", | |
643 | dev->vendor, dev->device, dev_name(&dev->dev), | |
644 | dev_driver_string(&dev->dev)); | |
645 | seq_printf(s, " d3:%x\n", d3_state); | |
646 | } | |
647 | ||
648 | seq_puts(s, "\n--------------------------------------\n"); | |
649 | seq_puts(s, "D3/D0i3 Status\n"); | |
650 | seq_puts(s, "--------------------------------------\n"); | |
651 | seq_puts(s, "Block\t\t D3\t D0i3\n"); | |
652 | for (index = 0; index < conf->ioss_d0ix_evts; index++) { | |
653 | seq_printf(s, "%-10s\t %u\t %u\n", | |
654 | conf->ioss_d0ix_data[index].name, | |
655 | d3_sts[index], d0ix_sts[index]); | |
656 | } | |
657 | ||
658 | seq_puts(s, "\n--------------------------------------\n"); | |
659 | seq_puts(s, "South Complex PowerGate Status\n"); | |
660 | seq_puts(s, "--------------------------------------\n"); | |
661 | seq_puts(s, "Device\t\t PG\n"); | |
662 | for (index = 0; index < conf->ioss_pg_evts; index++) { | |
663 | seq_printf(s, "%-10s\t %u\n", | |
664 | conf->ioss_pg_data[index].name, | |
665 | pg_sts[index]); | |
666 | } | |
667 | ||
668 | evtlog->telem_evtid = conf->pss_idle_id; | |
669 | ret = telemetry_read_events(TELEM_PSS, evtlog, 1); | |
670 | if (ret < 0) | |
671 | return ret; | |
672 | ||
673 | seq_puts(s, "\n-----------------------------------------\n"); | |
674 | seq_puts(s, "North Idle Status\n"); | |
675 | seq_puts(s, "-----------------------------------------\n"); | |
676 | for (idx = 0; idx < conf->pss_idle_evts - 1; idx++) { | |
677 | pss_idle[idx] = (evtlog->telem_evtlog >> | |
678 | conf->pss_idle_data[idx].bit_pos) & | |
679 | TELEM_MASK_BIT; | |
680 | } | |
681 | ||
682 | pss_idle[idx] = (evtlog->telem_evtlog >> | |
683 | conf->pss_idle_data[idx].bit_pos) & | |
684 | TELEM_APL_MASK_PCS_STATE; | |
685 | ||
686 | for (index = 0; index < conf->pss_idle_evts; index++) { | |
687 | seq_printf(s, "%-30s %u\n", | |
688 | conf->pss_idle_data[index].name, | |
689 | pss_idle[index]); | |
690 | } | |
691 | ||
692 | seq_puts(s, "\nPCS_STATUS Code\n"); | |
693 | seq_puts(s, "0:C0 1:C1 2:C1_DN_WT_DEV 3:C2 4:C2_WT_DE_MEM_UP\n"); | |
694 | seq_puts(s, "5:C2_WT_DE_MEM_DOWN 6:C2_UP_WT_DEV 7:C2_DN 8:C2_VOA\n"); | |
695 | seq_puts(s, "9:C2_VOA_UP 10:S0IX_PRE 11:S0IX\n"); | |
696 | ||
697 | return 0; | |
698 | } | |
699 | ||
700 | static int telem_soc_state_open(struct inode *inode, struct file *file) | |
701 | { | |
702 | return single_open(file, telem_soc_states_show, inode->i_private); | |
703 | } | |
704 | ||
705 | static const struct file_operations telem_socstate_ops = { | |
706 | .open = telem_soc_state_open, | |
707 | .read = seq_read, | |
708 | .llseek = seq_lseek, | |
709 | .release = single_release, | |
710 | }; | |
711 | ||
bc8c47ab RB |
712 | static int telem_s0ix_res_get(void *data, u64 *val) |
713 | { | |
714 | u64 s0ix_total_res; | |
715 | int ret; | |
716 | ||
717 | ret = intel_pmc_s0ix_counter_read(&s0ix_total_res); | |
718 | if (ret) { | |
719 | pr_err("Failed to read S0ix residency"); | |
720 | return ret; | |
721 | } | |
722 | ||
723 | *val = s0ix_total_res; | |
724 | ||
725 | return 0; | |
726 | } | |
727 | ||
728 | DEFINE_DEBUGFS_ATTRIBUTE(telem_s0ix_fops, telem_s0ix_res_get, NULL, "%llu\n"); | |
729 | ||
87bee290 SKC |
730 | static int telem_pss_trc_verb_show(struct seq_file *s, void *unused) |
731 | { | |
732 | u32 verbosity; | |
733 | int err; | |
734 | ||
735 | err = telemetry_get_trace_verbosity(TELEM_PSS, &verbosity); | |
736 | if (err) { | |
737 | pr_err("Get PSS Trace Verbosity Failed with Error %d\n", err); | |
738 | return -EFAULT; | |
739 | } | |
740 | ||
741 | seq_printf(s, "PSS Trace Verbosity %u\n", verbosity); | |
742 | return 0; | |
743 | } | |
744 | ||
745 | static ssize_t telem_pss_trc_verb_write(struct file *file, | |
746 | const char __user *userbuf, | |
747 | size_t count, loff_t *ppos) | |
748 | { | |
749 | u32 verbosity; | |
750 | int err; | |
751 | ||
752 | if (kstrtou32_from_user(userbuf, count, 0, &verbosity)) | |
753 | return -EFAULT; | |
754 | ||
755 | err = telemetry_set_trace_verbosity(TELEM_PSS, verbosity); | |
756 | if (err) { | |
757 | pr_err("Changing PSS Trace Verbosity Failed. Error %d\n", err); | |
758 | count = err; | |
759 | } | |
760 | ||
761 | return count; | |
762 | } | |
763 | ||
764 | static int telem_pss_trc_verb_open(struct inode *inode, struct file *file) | |
765 | { | |
766 | return single_open(file, telem_pss_trc_verb_show, inode->i_private); | |
767 | } | |
768 | ||
769 | static const struct file_operations telem_pss_trc_verb_ops = { | |
770 | .open = telem_pss_trc_verb_open, | |
771 | .read = seq_read, | |
772 | .write = telem_pss_trc_verb_write, | |
773 | .llseek = seq_lseek, | |
774 | .release = single_release, | |
775 | }; | |
776 | ||
777 | ||
778 | static int telem_ioss_trc_verb_show(struct seq_file *s, void *unused) | |
779 | { | |
780 | u32 verbosity; | |
781 | int err; | |
782 | ||
783 | err = telemetry_get_trace_verbosity(TELEM_IOSS, &verbosity); | |
784 | if (err) { | |
785 | pr_err("Get IOSS Trace Verbosity Failed with Error %d\n", err); | |
786 | return -EFAULT; | |
787 | } | |
788 | ||
789 | seq_printf(s, "IOSS Trace Verbosity %u\n", verbosity); | |
790 | return 0; | |
791 | } | |
792 | ||
793 | static ssize_t telem_ioss_trc_verb_write(struct file *file, | |
794 | const char __user *userbuf, | |
795 | size_t count, loff_t *ppos) | |
796 | { | |
797 | u32 verbosity; | |
798 | int err; | |
799 | ||
800 | if (kstrtou32_from_user(userbuf, count, 0, &verbosity)) | |
801 | return -EFAULT; | |
802 | ||
803 | err = telemetry_set_trace_verbosity(TELEM_IOSS, verbosity); | |
804 | if (err) { | |
805 | pr_err("Changing IOSS Trace Verbosity Failed. Error %d\n", err); | |
806 | count = err; | |
807 | } | |
808 | ||
809 | return count; | |
810 | } | |
811 | ||
812 | static int telem_ioss_trc_verb_open(struct inode *inode, struct file *file) | |
813 | { | |
814 | return single_open(file, telem_ioss_trc_verb_show, inode->i_private); | |
815 | } | |
816 | ||
817 | static const struct file_operations telem_ioss_trc_verb_ops = { | |
818 | .open = telem_ioss_trc_verb_open, | |
819 | .read = seq_read, | |
820 | .write = telem_ioss_trc_verb_write, | |
821 | .llseek = seq_lseek, | |
822 | .release = single_release, | |
823 | }; | |
824 | ||
87bee290 SKC |
825 | static int pm_suspend_prep_cb(void) |
826 | { | |
827 | struct telemetry_evtlog evtlog[TELEM_MAX_OS_ALLOCATED_EVENTS]; | |
828 | struct telemetry_debugfs_conf *conf = debugfs_conf; | |
829 | int ret, index; | |
830 | ||
831 | ret = telemetry_raw_read_eventlog(TELEM_IOSS, evtlog, | |
832 | TELEM_MAX_OS_ALLOCATED_EVENTS); | |
833 | if (ret < 0) { | |
834 | suspend_prep_ok = 0; | |
835 | goto out; | |
836 | } | |
837 | ||
838 | for (index = 0; index < ret; index++) { | |
839 | ||
840 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_shlw_occ_id, | |
841 | suspend_shlw_ctr_temp); | |
842 | ||
843 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_deep_occ_id, | |
844 | suspend_deep_ctr_temp); | |
845 | ||
846 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_shlw_res_id, | |
847 | suspend_shlw_res_temp); | |
848 | ||
849 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_deep_res_id, | |
850 | suspend_deep_res_temp); | |
851 | } | |
852 | suspend_prep_ok = 1; | |
853 | out: | |
854 | return NOTIFY_OK; | |
855 | } | |
856 | ||
857 | static int pm_suspend_exit_cb(void) | |
858 | { | |
859 | struct telemetry_evtlog evtlog[TELEM_MAX_OS_ALLOCATED_EVENTS]; | |
860 | static u32 suspend_shlw_ctr_exit, suspend_deep_ctr_exit; | |
861 | static u64 suspend_shlw_res_exit, suspend_deep_res_exit; | |
862 | struct telemetry_debugfs_conf *conf = debugfs_conf; | |
863 | int ret, index; | |
864 | ||
865 | if (!suspend_prep_ok) | |
866 | goto out; | |
867 | ||
868 | ret = telemetry_raw_read_eventlog(TELEM_IOSS, evtlog, | |
869 | TELEM_MAX_OS_ALLOCATED_EVENTS); | |
870 | if (ret < 0) | |
871 | goto out; | |
872 | ||
873 | for (index = 0; index < ret; index++) { | |
874 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_shlw_occ_id, | |
875 | suspend_shlw_ctr_exit); | |
876 | ||
877 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_deep_occ_id, | |
878 | suspend_deep_ctr_exit); | |
879 | ||
880 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_shlw_res_id, | |
881 | suspend_shlw_res_exit); | |
882 | ||
883 | TELEM_CHECK_AND_PARSE_CTRS(conf->s0ix_deep_res_id, | |
884 | suspend_deep_res_exit); | |
885 | } | |
886 | ||
887 | if ((suspend_shlw_ctr_exit < suspend_shlw_ctr_temp) || | |
888 | (suspend_deep_ctr_exit < suspend_deep_ctr_temp) || | |
889 | (suspend_shlw_res_exit < suspend_shlw_res_temp) || | |
890 | (suspend_deep_res_exit < suspend_deep_res_temp)) { | |
891 | pr_err("Wrong s0ix counters detected\n"); | |
892 | goto out; | |
893 | } | |
894 | ||
895 | suspend_shlw_ctr_exit -= suspend_shlw_ctr_temp; | |
896 | suspend_deep_ctr_exit -= suspend_deep_ctr_temp; | |
897 | suspend_shlw_res_exit -= suspend_shlw_res_temp; | |
898 | suspend_deep_res_exit -= suspend_deep_res_temp; | |
899 | ||
900 | if (suspend_shlw_ctr_exit == 1) { | |
901 | conf->suspend_stats.shlw_ctr += | |
902 | suspend_shlw_ctr_exit; | |
903 | ||
904 | conf->suspend_stats.shlw_res += | |
905 | suspend_shlw_res_exit; | |
906 | } | |
907 | /* Shallow Wakes Case */ | |
908 | else if (suspend_shlw_ctr_exit > 1) { | |
909 | conf->suspend_stats.shlw_swake_ctr += | |
910 | suspend_shlw_ctr_exit; | |
911 | ||
912 | conf->suspend_stats.shlw_swake_res += | |
913 | suspend_shlw_res_exit; | |
914 | } | |
915 | ||
916 | if (suspend_deep_ctr_exit == 1) { | |
917 | conf->suspend_stats.deep_ctr += | |
918 | suspend_deep_ctr_exit; | |
919 | ||
920 | conf->suspend_stats.deep_res += | |
921 | suspend_deep_res_exit; | |
922 | } | |
923 | ||
924 | /* Shallow Wakes Case */ | |
925 | else if (suspend_deep_ctr_exit > 1) { | |
926 | conf->suspend_stats.deep_swake_ctr += | |
927 | suspend_deep_ctr_exit; | |
928 | ||
929 | conf->suspend_stats.deep_swake_res += | |
930 | suspend_deep_res_exit; | |
931 | } | |
932 | ||
933 | out: | |
934 | suspend_prep_ok = 0; | |
935 | return NOTIFY_OK; | |
936 | } | |
937 | ||
938 | static int pm_notification(struct notifier_block *this, | |
939 | unsigned long event, void *ptr) | |
940 | { | |
941 | switch (event) { | |
942 | case PM_SUSPEND_PREPARE: | |
943 | return pm_suspend_prep_cb(); | |
944 | case PM_POST_SUSPEND: | |
945 | return pm_suspend_exit_cb(); | |
946 | } | |
947 | ||
948 | return NOTIFY_DONE; | |
949 | } | |
950 | ||
951 | static struct notifier_block pm_notifier = { | |
952 | .notifier_call = pm_notification, | |
953 | }; | |
87bee290 SKC |
954 | |
955 | static int __init telemetry_debugfs_init(void) | |
956 | { | |
957 | const struct x86_cpu_id *id; | |
7a3a51ab | 958 | int err; |
87bee290 SKC |
959 | struct dentry *f; |
960 | ||
961 | /* Only APL supported for now */ | |
962 | id = x86_match_cpu(telemetry_debugfs_cpu_ids); | |
963 | if (!id) | |
964 | return -ENODEV; | |
965 | ||
966 | debugfs_conf = (struct telemetry_debugfs_conf *)id->driver_data; | |
967 | ||
968 | err = telemetry_pltconfig_valid(); | |
969 | if (err < 0) | |
970 | return -ENODEV; | |
971 | ||
972 | err = telemetry_debugfs_check_evts(); | |
973 | if (err < 0) | |
974 | return -EINVAL; | |
975 | ||
87bee290 | 976 | register_pm_notifier(&pm_notifier); |
87bee290 | 977 | |
7a3a51ab | 978 | err = -ENOMEM; |
87bee290 | 979 | debugfs_conf->telemetry_dbg_dir = debugfs_create_dir("telemetry", NULL); |
7a3a51ab | 980 | if (!debugfs_conf->telemetry_dbg_dir) |
74a1eb56 | 981 | goto out_pm; |
87bee290 SKC |
982 | |
983 | f = debugfs_create_file("pss_info", S_IFREG | S_IRUGO, | |
984 | debugfs_conf->telemetry_dbg_dir, NULL, | |
985 | &telem_pss_ops); | |
986 | if (!f) { | |
987 | pr_err("pss_sample_info debugfs register failed\n"); | |
988 | goto out; | |
989 | } | |
990 | ||
991 | f = debugfs_create_file("ioss_info", S_IFREG | S_IRUGO, | |
992 | debugfs_conf->telemetry_dbg_dir, NULL, | |
993 | &telem_ioss_ops); | |
994 | if (!f) { | |
995 | pr_err("ioss_sample_info debugfs register failed\n"); | |
996 | goto out; | |
997 | } | |
998 | ||
999 | f = debugfs_create_file("soc_states", S_IFREG | S_IRUGO, | |
1000 | debugfs_conf->telemetry_dbg_dir, | |
1001 | NULL, &telem_socstate_ops); | |
1002 | if (!f) { | |
1003 | pr_err("ioss_sample_info debugfs register failed\n"); | |
1004 | goto out; | |
1005 | } | |
1006 | ||
bc8c47ab RB |
1007 | f = debugfs_create_file("s0ix_residency_usec", S_IFREG | S_IRUGO, |
1008 | debugfs_conf->telemetry_dbg_dir, | |
1009 | NULL, &telem_s0ix_fops); | |
1010 | if (!f) { | |
1011 | pr_err("s0ix_residency_usec debugfs register failed\n"); | |
1012 | goto out; | |
1013 | } | |
1014 | ||
87bee290 SKC |
1015 | f = debugfs_create_file("pss_trace_verbosity", S_IFREG | S_IRUGO, |
1016 | debugfs_conf->telemetry_dbg_dir, NULL, | |
1017 | &telem_pss_trc_verb_ops); | |
1018 | if (!f) { | |
1019 | pr_err("pss_trace_verbosity debugfs register failed\n"); | |
1020 | goto out; | |
1021 | } | |
1022 | ||
1023 | f = debugfs_create_file("ioss_trace_verbosity", S_IFREG | S_IRUGO, | |
1024 | debugfs_conf->telemetry_dbg_dir, NULL, | |
1025 | &telem_ioss_trc_verb_ops); | |
1026 | if (!f) { | |
1027 | pr_err("ioss_trace_verbosity debugfs register failed\n"); | |
1028 | goto out; | |
1029 | } | |
1030 | ||
1031 | return 0; | |
1032 | ||
1033 | out: | |
1034 | debugfs_remove_recursive(debugfs_conf->telemetry_dbg_dir); | |
1035 | debugfs_conf->telemetry_dbg_dir = NULL; | |
74a1eb56 PK |
1036 | out_pm: |
1037 | unregister_pm_notifier(&pm_notifier); | |
87bee290 SKC |
1038 | |
1039 | return err; | |
1040 | } | |
1041 | ||
1042 | static void __exit telemetry_debugfs_exit(void) | |
1043 | { | |
1044 | debugfs_remove_recursive(debugfs_conf->telemetry_dbg_dir); | |
1045 | debugfs_conf->telemetry_dbg_dir = NULL; | |
74a1eb56 | 1046 | unregister_pm_notifier(&pm_notifier); |
87bee290 SKC |
1047 | } |
1048 | ||
1049 | late_initcall(telemetry_debugfs_init); | |
1050 | module_exit(telemetry_debugfs_exit); | |
1051 | ||
1052 | MODULE_AUTHOR("Souvik Kumar Chakravarty <souvik.k.chakravarty@intel.com>"); | |
1053 | MODULE_DESCRIPTION("Intel SoC Telemetry debugfs Interface"); | |
1054 | MODULE_VERSION(DRIVER_VERSION); | |
1055 | MODULE_LICENSE("GPL"); |