qcacmn: Add qdf_print_thread_trace API

Add an abstraction to QDF for printing the stack trace of a given
thread.

Change-Id: Ibea6e6bed7f3ebe67538b8ea8b6b437b643d5541
CRs-Fixed: 2088806
This commit is contained in:
Dustin Brown
2017-08-04 17:01:11 -07:00
committed by snandini
parent 7b32946958
commit a86de10a9a
5 changed files with 67 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -34,7 +34,9 @@
#define __QDF_THREADS_H
#include <qdf_types.h>
#include <qdf_util.h>
#include "i_qdf_threads.h"
typedef __qdf_thread_t qdf_thread_t;
/* Function declarations and documenation */
@@ -71,4 +73,12 @@ qdf_thread_t *qdf_create_thread(int (*thread_handler)(void *data), void *data,
*/
int qdf_wake_up_process(qdf_thread_t *thread);
/**
* qdf_print_stack_trace_thread() - prints the stack trace of the given thread
* @thread: the thread for which the stack trace will be printed
*
* Return: None
*/
void qdf_print_thread_trace(qdf_thread_t *thread);
#endif /* __QDF_THREADS_H */

View File

@@ -41,7 +41,6 @@
#define QDF_MAX_AVAILABLE_CPU 1
#endif
typedef __qdf_thread_t qdf_thread_t;
typedef __qdf_wait_queue_head_t qdf_wait_queue_head_t;
/**

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2017 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/**
* DOC: i_qdf_threads
* Header file for linux-specific thead abstractions
*/
#ifndef __I_QDF_THREADS_H
#define __I_QDF_THREADS_H
typedef struct task_struct __qdf_thread_t;
#endif /* __I_QDF_THREADS_H */

View File

@@ -65,7 +65,6 @@
#include <linux/byteorder/generic.h>
#endif
typedef struct task_struct __qdf_thread_t;
typedef wait_queue_head_t __qdf_wait_queue_head_t;
/* Generic compiler-dependent macros if defined by the OS */

View File

@@ -44,6 +44,7 @@
#include <linux/interrupt.h>
#include <linux/export.h>
#include <linux/kthread.h>
#include <stacktrace.h>
/* Function declarations and documenation */
@@ -129,3 +130,28 @@ int qdf_wake_up_process(qdf_thread_t *thread)
return wake_up_process(thread);
}
EXPORT_SYMBOL(qdf_wake_up_process);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)) ||\
defined(BACKPORTED_EXPORT_SAVE_STACK_TRACE_TSK)
/* save_stack_trace_tsk is not generally exported for arm architectures */
#define QDF_PRINT_TRACE_COUNT 32
void qdf_print_thread_trace(qdf_thread_t *thread)
{
const int spaces = 4;
struct task_struct *task = thread;
unsigned long entries[QDF_PRINT_TRACE_COUNT] = {0};
struct stack_trace trace = {
.nr_entries = 0,
.skip = 0,
.entries = &entries[0],
.max_entries = QDF_PRINT_TRACE_COUNT,
};
save_stack_trace_tsk(task, &trace);
print_stack_trace(&trace, spaces);
}
#else
void qdf_print_thread_trace(qdf_thread_t *thread) { }
#endif /* KERNEL_VERSION(4, 13, 0) */
EXPORT_SYMBOL(qdf_print_thread_trace);