Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fdf23598 authored by Naman Padhiar's avatar Naman Padhiar Committed by Gerrit - the friendly Code Review server
Browse files

cnss2: Add more debug info in ipc_log



Add caller context and function information in cnss ipc logs.

Change-Id: Id389100b9518511b900cd3d9cde7677f14aa15da
Signed-off-by: default avatarNaman Padhiar <npadhiar@codeaurora.org>
Signed-off-by: default avatarMohammed Siddiq <msiddiq@codeaurora.org>
parent 774e9013
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -876,6 +876,24 @@ void cnss_debugfs_destroy(struct cnss_plat_data *plat_priv)
#endif

#if IS_ENABLED(CONFIG_IPC_LOGGING)
void cnss_debug_ipc_log_print(void *log_ctx, char *process, const char *fn,
			      const char *log_level, char *fmt, ...)
{
	struct va_format vaf;
	va_list va_args;

	va_start(va_args, fmt);
	vaf.fmt = fmt;
	vaf.va = &va_args;

	if (log_level)
		printk("%scnss: %pV", log_level, &vaf);

	ipc_log_string(log_ctx, "[%s] %s: %pV", process, fn, &vaf);

	va_end(va_args);
}

static int cnss_ipc_logging_init(void)
{
	cnss_ipc_log_context = ipc_log_context_create(CNSS_IPC_LOG_PAGES,
@@ -911,6 +929,21 @@ static void cnss_ipc_logging_deinit(void)
#else
static int cnss_ipc_logging_init(void) { return 0; }
static void cnss_ipc_logging_deinit(void) {}
void cnss_debug_ipc_log_print(void *log_ctx, char *process, const char *fn,
			      const char *log_level, char *fmt, ...)
{
	struct va_format vaf;
	va_list va_args;

	va_start(va_args, fmt);
	vaf.fmt = fmt;
	vaf.va = &va_args;

	if (log_level)
		printk("%scnss: %pV", log_level, &vaf);

	va_end(va_args);
}
#endif

int cnss_debug_init(void)
+38 −34
Original line number Diff line number Diff line
@@ -4,55 +4,58 @@
#ifndef _CNSS_DEBUG_H
#define _CNSS_DEBUG_H

#if IS_ENABLED(CONFIG_IPC_LOGGING)
#include <linux/ipc_logging.h>
#endif
#include <linux/printk.h>

#if IS_ENABLED(CONFIG_IPC_LOGGING)
#define CNSS_IPC_LOG_PAGES		32
#include <linux/ipc_logging.h>
#include <asm/current.h>

extern void *cnss_ipc_log_context;
extern void *cnss_ipc_log_long_context;

#define cnss_ipc_log_string(_x...)					\
	ipc_log_string(cnss_ipc_log_context, _x)
#ifdef CONFIG_CNSS2_DEBUG
#define CNSS_IPC_LOG_PAGES              100
#else
#define CNSS_IPC_LOG_PAGES              50
#endif
#define cnss_debug_log_print(_x...) \
		 cnss_debug_ipc_log_print(cnss_ipc_log_context, _x)

#define cnss_ipc_log_long_string(_x...)					\
	ipc_log_string(cnss_ipc_log_long_context, _x)
#define cnss_debug_log_long_print(_x...) \
		 cnss_debug_ipc_log_print(cnss_ipc_log_long_context, _x)
#else
#define cnss_ipc_log_string(_x...)
#define cnss_ipc_log_long_string(_x...)
#define cnss_debug_log_print(_x...) \
		 cnss_debug_ipc_log_print((void *)NULL, _x)
#define cnss_debug_log_long_print(_x...) \
		 cnss_debug_ipc_log_print((void *)NULL, _x)
#endif

#define cnss_pr_err(_fmt, ...) do {					\
		printk("%scnss: " _fmt, KERN_ERR, ##__VA_ARGS__);	\
		cnss_ipc_log_string("%scnss: " _fmt, "", ##__VA_ARGS__);\
	} while (0)
#define proc_name (in_irq() ? "irq" : \
		   (in_softirq() ? "soft_irq" : current->comm))

#define cnss_pr_warn(_fmt, ...) do {					\
		printk("%scnss: " _fmt, KERN_WARNING, ##__VA_ARGS__);	\
		cnss_ipc_log_string("%scnss: " _fmt, "", ##__VA_ARGS__);\
	} while (0)
#define cnss_pr_err(_fmt, ...) \
	cnss_debug_log_print(proc_name, __func__, \
			     KERN_ERR, _fmt, ##__VA_ARGS__)

#define cnss_pr_info(_fmt, ...) do {					\
		printk("%scnss: " _fmt, KERN_INFO, ##__VA_ARGS__);	\
		cnss_ipc_log_string("%scnss: " _fmt, "", ##__VA_ARGS__);\
	} while (0)
#define cnss_pr_warn(_fmt, ...) \
	cnss_debug_log_print(proc_name, __func__, \
			     KERN_WARNING, _fmt, ##__VA_ARGS__)

#define cnss_pr_dbg(_fmt, ...) do {					\
		printk("%scnss: " _fmt, KERN_DEBUG, ##__VA_ARGS__);	\
		cnss_ipc_log_string("%scnss: " _fmt, "", ##__VA_ARGS__);\
	} while (0)
#define cnss_pr_info(_fmt, ...) \
	cnss_debug_log_print(proc_name, __func__, \
			     KERN_INFO, _fmt, ##__VA_ARGS__)

#define cnss_pr_vdbg(_fmt, ...) do {					\
		printk("%scnss: " _fmt, KERN_DEBUG, ##__VA_ARGS__);	\
		cnss_ipc_log_long_string("%scnss: " _fmt, "",		\
					 ##__VA_ARGS__);		\
	} while (0)
#define cnss_pr_dbg(_fmt, ...) \
	cnss_debug_log_print(proc_name, __func__, \
			     KERN_DEBUG, _fmt, ##__VA_ARGS__)

#define cnss_pr_vdbg(_fmt, ...) \
	cnss_debug_log_long_print(proc_name, __func__, \
				  KERN_DEBUG, _fmt, ##__VA_ARGS__)

#define cnss_pr_buf(_fmt, ...) \
	cnss_ipc_log_long_string("%scnss: " _fmt, "", ##__VA_ARGS__)	\
	cnss_debug_log_long_print(proc_name, __func__, \
				  NULL, _fmt, ##__VA_ARGS__)

#ifdef CONFIG_CNSS2_DEBUG
#define CNSS_ASSERT(_condition) do {					\
@@ -79,5 +82,6 @@ int cnss_debug_init(void);
void cnss_debug_deinit(void);
int cnss_debugfs_create(struct cnss_plat_data *plat_priv);
void cnss_debugfs_destroy(struct cnss_plat_data *plat_priv);

void cnss_debug_ipc_log_print(void *log_ctx, char *process, const char *fn,
			      const char *log_level, char *fmt, ...);
#endif /* _CNSS_DEBUG_H */