Lloyd Atkinson | 5d40d31 | 2016-09-06 08:34:13 -0400 | [diff] [blame] | 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef SDE_DBG_H_ |
| 14 | #define SDE_DBG_H_ |
| 15 | |
| 16 | #include <stdarg.h> |
| 17 | #include <linux/debugfs.h> |
| 18 | #include <linux/list.h> |
| 19 | |
| 20 | #define SDE_EVTLOG_DATA_LIMITER (-1) |
| 21 | #define SDE_EVTLOG_FUNC_ENTRY 0x1111 |
| 22 | #define SDE_EVTLOG_FUNC_EXIT 0x2222 |
| 23 | |
Lloyd Atkinson | a54513f | 2016-10-03 22:31:43 -0400 | [diff] [blame^] | 24 | #define SDE_DBG_DUMP_DATA_LIMITER (NULL) |
| 25 | |
Lloyd Atkinson | 5d40d31 | 2016-09-06 08:34:13 -0400 | [diff] [blame] | 26 | enum sde_dbg_evtlog_flag { |
| 27 | SDE_EVTLOG_DEFAULT = BIT(0), |
| 28 | SDE_EVTLOG_IRQ = BIT(1), |
| 29 | SDE_EVTLOG_ALL = BIT(7) |
| 30 | }; |
| 31 | |
| 32 | /** |
| 33 | * SDE_EVT32 - Write an list of 32bit values as an event into the event log |
| 34 | * ... - variable arguments |
| 35 | */ |
| 36 | #define SDE_EVT32(...) sde_evtlog(__func__, __LINE__, SDE_EVTLOG_DEFAULT, \ |
| 37 | ##__VA_ARGS__, SDE_EVTLOG_DATA_LIMITER) |
| 38 | #define SDE_EVT32_IRQ(...) sde_evtlog(__func__, __LINE__, SDE_EVTLOG_IRQ, \ |
| 39 | ##__VA_ARGS__, SDE_EVTLOG_DATA_LIMITER) |
| 40 | |
Lloyd Atkinson | a54513f | 2016-10-03 22:31:43 -0400 | [diff] [blame^] | 41 | #define SDE_DBG_DUMP(...) \ |
| 42 | sde_dbg_dump(false, __func__, ##__VA_ARGS__, \ |
| 43 | SDE_DBG_DUMP_DATA_LIMITER) |
| 44 | |
| 45 | #define SDE_DBG_DUMP_WQ(...) \ |
| 46 | sde_dbg_dump(true, __func__, ##__VA_ARGS__, \ |
| 47 | SDE_DBG_DUMP_DATA_LIMITER) |
Lloyd Atkinson | 5d40d31 | 2016-09-06 08:34:13 -0400 | [diff] [blame] | 48 | |
| 49 | #if defined(CONFIG_DEBUG_FS) |
| 50 | |
| 51 | int sde_evtlog_init(struct dentry *debugfs_root); |
| 52 | void sde_evtlog_destroy(void); |
| 53 | void sde_evtlog(const char *name, int line, int flag, ...); |
Lloyd Atkinson | a54513f | 2016-10-03 22:31:43 -0400 | [diff] [blame^] | 54 | void sde_dbg_dump(bool queue, const char *name, ...); |
Lloyd Atkinson | 5d40d31 | 2016-09-06 08:34:13 -0400 | [diff] [blame] | 55 | #else |
Lloyd Atkinson | a54513f | 2016-10-03 22:31:43 -0400 | [diff] [blame^] | 56 | static inline int sde_evtlog_init(struct dentry *debugfs_root) { return 0; } |
| 57 | static inline void sde_evtlog(const char *name, int line, flag, ...) {} |
| 58 | static inline void sde_evtlog_destroy(void) { } |
| 59 | static inline void sde_dbg_dump(bool queue, const char *name, ...) {} |
Lloyd Atkinson | 5d40d31 | 2016-09-06 08:34:13 -0400 | [diff] [blame] | 60 | #endif |
| 61 | |
| 62 | #endif /* SDE_DBG_H_ */ |