summaryrefstree
path: root/kernel/lib/debug-snapshot-log.h
blob: bad11a9fed29624d3f394bf86ab2786030cc1b08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366

#ifndef DEBUG_SNAPSHOT_LOG_H
#define DEBUG_SNAPSHOT_LOG_H

#include <generated/autoconf.h>

#ifdef CONFIG_DEBUG_SNAPSHOT_BINDER
#include <linux/debug-snapshot-binder.h>
#endif

#ifdef DSS_ANALYZER

#define TASK_COMM_LEN 16
#define NR_CPUS 8
#undef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
#include <stdio.h>
#include <stdlib.h>

#else // DSS_ANALYZER

#include <linux/clk-provider.h>
#include <linux/debug-snapshot.h>
#include <linux/debug-snapshot-helper.h>

#endif // DSS_ANALYZER

#include <dt-bindings/soc/samsung/debug-snapshot-table.h>

/*  Size domain */
#define DSS_KEEP_HEADER_SZ		(SZ_256 * 3)
#define DSS_HEADER_SZ			SZ_4K
#define DSS_MMU_REG_SZ			SZ_4K
#define DSS_CORE_REG_SZ			SZ_4K
#define DSS_DBGC_LOG_SZ			SZ_4K
#define DSS_HEADER_TOTAL_SZ		(DSS_HEADER_SZ + DSS_MMU_REG_SZ + DSS_CORE_REG_SZ + DSS_DBGC_LOG_SZ)
#define DSS_SPARE_SZ			(DSS_HEADER_SIZE - DSS_HEADER_TOTAL_SZ)

/*  Length domain */
#define DSS_LOG_STRING_LEN		SZ_128
#define DSS_LOG_GEN_LEN			SZ_16
#define DSS_MMU_REG_OFFSET		SZ_512
#define DSS_CORE_REG_OFFSET		SZ_512
#define DSS_LOG_MAX_NUM			SZ_1K
#define DSS_API_MAX_NUM			SZ_2K
#define DSS_EX_MAX_NUM			SZ_8
#define DSS_IN_MAX_NUM			SZ_8
#define DSS_CALLSTACK_MAX_NUM		4
#define DSS_ITERATION			5
#define DSS_NR_CPUS			NR_CPUS
#define DSS_ITEM_MAX_NUM		16

/* Sign domain */
#define DSS_SIGN_RESET			0x0
#define DSS_SIGN_RESERVED		0x1
#define DSS_SIGN_SCRATCH		0xD
#define DSS_SIGN_ALIVE			0xFACE
#define DSS_SIGN_DEAD			0xDEAD
#define DSS_SIGN_PANIC			0xBABA
#define DSS_SIGN_SAFE_FAULT		0xFAFA
#define DSS_SIGN_NORMAL_REBOOT		0xCAFE
#define DSS_SIGN_FORCE_REBOOT		0xDAFE
#define DSS_SIGN_LOCKUP			0xDEADBEEF
#define DSS_SIGN_DEBUG_TEST		0xDB6

/*  Specific Address Information */
#define DSS_OFFSET_SCRATCH		(0x100)
#define DSS_OFFSET_DEBUG_TEST		(0x110)
#define DSS_OFFSET_DEBUG_TEST_CASE	(0x120)
#define DSS_OFFSET_DEBUG_TEST_NEXT	(0x128)
#define DSS_OFFSET_DEBUG_TEST_PANIC	(0x130)
#define DSS_OFFSET_DEBUG_TEST_WDT	(0x140)
#define DSS_OFFSET_DEBUG_TEST_WTSR	(0x150)
#define DSS_OFFSET_DEBUG_TEST_SMPL	(0x160)
#define DSS_OFFSET_DEBUG_TEST_CURR	(0x170)
#define DSS_OFFSET_DEBUG_TEST_TOTAL	(0x178)
#define DSS_OFFSET_DEBUG_LEVEL		(0x180)
#define DSS_OFFSET_DEBUG_TEST_RUN	(0x138)
#define DSS_OFFSET_LAST_LOGBUF		(0x200)
#define DSS_OFFSET_EMERGENCY_REASON	(0x300)
#define DSS_OFFSET_CORE_POWER_STAT	(0x400)
#define DSS_OFFSET_PANIC_STAT		(0x500)
#define DSS_OFFSET_CORE_LAST_PC		(0x600)
/* S5P_VA_SS_BASE + 0x700 -- 0x8FF is reserved */
#define DSS_OFFSET_LINUX_BANNER		(0x700)
#define DSS_OFFSET_ITEM_INFO		(0x900)

/* S5P_VA_SS_BASE + 0xC00 -- 0xFFF is reserved */
#define DSS_OFFSET_PANIC_STRING		(0xC00)
#define DSS_OFFSET_SPARE_BASE		(DSS_HEADER_TOTAL_SZ)

struct dbg_snapshot_log {
	struct __task_log {
		unsigned long long time;
		unsigned long sp;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		struct task_struct *task;
#else
		void *task;
#endif
		char task_comm[TASK_COMM_LEN];
		int pid;
	} task[DSS_NR_CPUS][DSS_LOG_MAX_NUM];

	struct __work_log {
		unsigned long long time;
		unsigned long sp;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		struct worker *worker;
		work_func_t fn;
#else
		void *worker;
		void *fn;
#endif
		char task_comm[TASK_COMM_LEN];
		int en;
	} work[DSS_NR_CPUS][DSS_LOG_MAX_NUM];

	struct __cpuidle_log {
		unsigned long long time;
		unsigned long sp;
		char *modes;
		unsigned int state;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		u32 num_online_cpus;
#else
		unsigned int num_online_cpus;
#endif
		int delta;
		int en;
	} cpuidle[DSS_NR_CPUS][DSS_LOG_MAX_NUM];

	struct __suspend_log {
		unsigned long long time;
		unsigned long sp;
		char log[DSS_LOG_GEN_LEN];
		void *fn;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		struct device *dev;
#else
		void *dev;
#endif
		int en;
		int state;
		int core;
	} suspend[DSS_LOG_MAX_NUM * 4];

	struct __irq_log {
		unsigned long long time;
		unsigned long sp;
		int irq;
		void *fn;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		struct irq_desc *desc;
#else
		void *desc;
#endif
		unsigned long long latency;
		int en;
	} irq[DSS_NR_CPUS][DSS_LOG_MAX_NUM * 2];
#ifdef CONFIG_DEBUG_SNAPSHOT_SPINLOCK
	struct __spinlock_log {
		unsigned long long time;
		unsigned long sp;
		unsigned long long jiffies;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		raw_spinlock_t *lock;
#ifdef CONFIG_DEBUG_SPINLOCK
		u16 next;
		u16 owner;
#endif
#else
		void *lock;
#ifdef CONFIG_DEBUG_SPINLOCK
		unsigned short next;
		unsigned short owner;
#endif
#endif
		int en;
		void *caller[DSS_CALLSTACK_MAX_NUM];
	} spinlock[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_IRQ_DISABLED
	struct __irqs_disabled_log {
		unsigned long long time;
		unsigned long index;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		struct task_struct *task;
#else
		void *task;
#endif
		char *task_comm;
		void *caller[DSS_CALLSTACK_MAX_NUM];
	} irqs_disabled[DSS_NR_CPUS][SZ_32];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_CLK
	struct __clk_log {
		unsigned long long time;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		struct clk_hw *clk;
#else
		void *clk;
#endif
		const char *f_name;
		int mode;
		unsigned long arg;
	} clk[DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_PMU
	struct __pmu_log {
		unsigned long long time;
		unsigned int id;
		const char *f_name;
		int mode;
	} pmu[DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_FREQ
	struct __freq_log {
		unsigned long long time;
		int cpu;
		int freq_type;
		char *freq_name;
		unsigned long old_freq;
		unsigned long target_freq;
		int en;
	} freq[DSS_LOG_MAX_NUM];
	struct __freq_misc_log {
		unsigned long long time;
		int cpu;
		int freq_type;
		char *freq_name;
		unsigned long old_freq;
		unsigned long target_freq;
		int en;
	} freq_misc[DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_DM
	struct __dm_log {
		unsigned long long time;
		int cpu;
		int dm_num;
		unsigned long min_freq;
		unsigned long max_freq;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		s32 wait_dmt;
		s32 do_dmt;
#else
		int wait_dmt;
		int do_dmt;
#endif
	} dm[DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_REG
	struct __reg_log {
		unsigned long long time;
		int read;
		size_t val;
		size_t reg;
		int en;
		void *caller[DSS_CALLSTACK_MAX_NUM];
	} reg[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_HRTIMER
	struct __hrtimer_log {
		unsigned long long time;
		unsigned long long now;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		struct hrtimer *timer;
#else
		void *timer;
#endif
		void *fn;
		int en;
	} hrtimers[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_REGULATOR
	struct __regulator_log {
		unsigned long long time;
		unsigned long long acpm_time;
		int cpu;
		char name[SZ_16];
		unsigned int reg;
		unsigned int voltage;
		unsigned int raw_volt;
		int en;
	} regulator[DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_THERMAL
	struct __thermal_log {
		unsigned long long time;
		int cpu;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		struct exynos_tmu_platform_data *data;
#else
		void *data;
#endif
		unsigned int temp;
		char *cooling_device;
		unsigned int cooling_state;
	} thermal[DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_ACPM
	struct __acpm_log {
		unsigned long long time;
		unsigned long long acpm_time;
		char log[9];
		unsigned int data;
	} acpm[DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_I2C
	struct __i2c_log {
		unsigned long long time;
		int cpu;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		struct i2c_adapter *adap;
		struct i2c_msg *msgs;
#else
		void *adp;
		void *msgs;
#endif
		int num;
		int en;
	} i2c[DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_SPI
	struct __spi_log {
		unsigned long long time;
		int cpu;
#ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
		struct spi_controller *ctlr;
		struct spi_message *cur_msg;
#else
		void *ctlr;
		void *cur_msg;
#endif
		int en;
	} spi[DSS_LOG_MAX_NUM];
#endif
#ifdef CONFIG_DEBUG_SNAPSHOT_BINDER
	struct __binder_log {
		unsigned long long time;
		int cpu;
		struct trace_binder_transaction_base base;
		struct trace_binder_transaction transaction;
		struct trace_binder_transaction_error error;
	} binder[DSS_API_MAX_NUM << 2];
#endif

#ifndef CONFIG_DEBUG_SNAPSHOT_MINIMIZED_MODE
	struct __printkl_log {
		unsigned long long time;
		int cpu;
		size_t msg;
		size_t val;
		void *caller[DSS_CALLSTACK_MAX_NUM];
	} printkl[DSS_API_MAX_NUM];

	struct __printk_log {
		unsigned long long time;
		int cpu;
		char log[DSS_LOG_STRING_LEN];
		void *caller[DSS_CALLSTACK_MAX_NUM];
	} printk[DSS_API_MAX_NUM];
#endif
};

#endif