coresight: add event to abort tracing on kernel panic

Add trace event to control aborting CoreSight trace
dynamically based on module parameter. This will help
user to enable/disable coresight_abort on kernel panic.
Also moved CREATE_TRACE_POINTS to panic.c from fault.c
since panic.c is common and shared between 32 and 64
bit platforms.

Change-Id: I51e4049b07adeca571b1a98cd90ff5f307d1d794
Signed-off-by: Sarang Joshi <spjoshi@codeaurora.org>
This commit is contained in:
Sarang Joshi 2014-01-30 15:26:52 -08:00
parent 219364c550
commit 87d84607d7
6 changed files with 71 additions and 13 deletions

View File

@ -32,7 +32,6 @@
#include "fault.h"
#define CREATE_TRACE_POINTS
#include <trace/events/exception.h>
#ifdef CONFIG_MMU

View File

@ -21,6 +21,14 @@ menuconfig CORESIGHT
if CORESIGHT
config CORESIGHT_EVENT
tristate "CoreSight Event driver"
help
This driver provides support for registering with various events
and performing CoreSight actions like aborting trace on their
occurrence. These events can be controlled by using module
parameters.
config HAVE_CORESIGHT_SINK
bool
@ -178,11 +186,4 @@ config CORESIGHT_RPM_ETM
endif
config CORESIGHT_EVENT
tristate "CoreSight Event driver"
help
This driver provides support for registering with various events
and performing CoreSight actions like aborting trace on their
occurrence.
endif

View File

@ -2,6 +2,7 @@
# Makefile for CoreSight drivers.
#
obj-$(CONFIG_CORESIGHT) += coresight.o
obj-$(CONFIG_CORESIGHT_EVENT) += coresight-event.o
obj-$(CONFIG_CORESIGHT_FUSE) += coresight-fuse.o
obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o
obj-$(CONFIG_CORESIGHT_CSR) += coresight-csr.o
@ -16,4 +17,3 @@ obj-$(CONFIG_CORESIGHT_AUDIO_ETM) += coresight-audio-etm.o
obj-$(CONFIG_CORESIGHT_MODEM_ETM) += coresight-modem-etm.o
obj-$(CONFIG_CORESIGHT_WCN_ETM) += coresight-wcn-etm.o
obj-$(CONFIG_CORESIGHT_RPM_ETM) += coresight-rpm-etm.o
obj-$(CONFIG_CORESIGHT_EVENT) += coresight-event.o

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -25,6 +25,11 @@ static int event_abort_set(const char *val, struct kernel_param *kp);
module_param_call(event_abort_enable, event_abort_set, param_get_int,
&event_abort_enable, 0644);
static int event_abort_on_panic = 1;
static int event_abort_on_panic_set(const char *val, struct kernel_param *kp);
module_param_call(event_abort_on_panic, event_abort_on_panic_set, param_get_int,
&event_abort_on_panic, 0644);
static void event_abort_user_fault(void *ignore,
struct task_struct *task,
unsigned long addr,
@ -56,6 +61,11 @@ static void event_abort_unhandled_abort(void *ignore,
}
}
static void event_abort_kernel_panic(void *ignore, long state)
{
coresight_abort();
}
static int event_abort_register(void)
{
int ret;
@ -105,14 +115,43 @@ static int event_abort_set(const char *val, struct kernel_param *kp)
return ret;
}
static int event_abort_on_panic_set(const char *val, struct kernel_param *kp)
{
int ret;
ret = param_set_int(val, kp);
if (ret) {
pr_err("coresight_event: error setting val on panic %d\n", ret);
return ret;
}
if (event_abort_on_panic)
ret = register_trace_kernel_panic(event_abort_kernel_panic,
NULL);
else
unregister_trace_kernel_panic(event_abort_kernel_panic, NULL);
return ret;
}
static int __init event_init(void)
{
int ret;
ret = register_trace_kernel_panic(event_abort_kernel_panic, NULL);
if (ret) {
/* We do not want to fail module init. This module can still
* be used to register other abort events.
*/
pr_err("coresight_event: error registering on panic %d\n", ret);
}
return 0;
}
module_init(event_init);
static void __exit event_exit(void)
{
unregister_trace_kernel_panic(event_abort_kernel_panic, NULL);
}
module_exit(event_exit);

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -84,6 +84,23 @@ TRACE_EVENT(unhandled_abort,
TP_printk("addr:%lu, fsr:%u", __entry->addr, __entry->fsr)
);
TRACE_EVENT(kernel_panic,
TP_PROTO(long dummy),
TP_ARGS(dummy),
TP_STRUCT__entry(
__field(long, dummy)
),
TP_fast_assign(
__entry->dummy = dummy;
),
TP_printk("dummy:%ld", __entry->dummy)
);
#endif
#include <trace/define_trace.h>

View File

@ -22,7 +22,9 @@
#include <linux/sysrq.h>
#include <linux/init.h>
#include <linux/nmi.h>
#include <linux/coresight.h>
#define CREATE_TRACE_POINTS
#include <trace/events/exception.h>
#define PANIC_TIMER_STEP 100
#define PANIC_BLINK_SPD 18
@ -80,7 +82,7 @@ void panic(const char *fmt, ...)
long i, i_next = 0;
int state = 0;
coresight_abort();
trace_kernel_panic(0);
/*
* Disable local interrupts. This will prevent panic_smp_self_stop
* from deadlocking the first cpu that invokes the panic, since