ALSA: pcm: Fix missing check of the new non-cached buffer type
[linux-2.6-block.git] / kernel / backtracetest.c
CommitLineData
b886d83c 1// SPDX-License-Identifier: GPL-2.0-only
6dab2778
AV
2/*
3 * Simple stack backtrace regression test module
4 *
5 * (C) Copyright 2008 Intel Corporation
6 * Author: Arjan van de Ven <arjan@linux.intel.com>
6dab2778
AV
7 */
8
4e6a0535 9#include <linux/completion.h>
ad118c54 10#include <linux/delay.h>
4e6a0535 11#include <linux/interrupt.h>
6dab2778
AV
12#include <linux/module.h>
13#include <linux/sched.h>
ad118c54 14#include <linux/stacktrace.h>
6dab2778 15
4e6a0535
VN
16static void backtrace_test_normal(void)
17{
462b29b8
FF
18 pr_info("Testing a backtrace from process context.\n");
19 pr_info("The following trace is a kernel self test and not a bug!\n");
4e6a0535
VN
20
21 dump_stack();
22}
23
24static DECLARE_COMPLETION(backtrace_work);
25
26static void backtrace_test_irq_callback(unsigned long data)
27{
28 dump_stack();
29 complete(&backtrace_work);
30}
31
32static DECLARE_TASKLET(backtrace_tasklet, &backtrace_test_irq_callback, 0);
6dab2778 33
4e6a0535 34static void backtrace_test_irq(void)
6dab2778 35{
462b29b8
FF
36 pr_info("Testing a backtrace from irq context.\n");
37 pr_info("The following trace is a kernel self test and not a bug!\n");
4e6a0535
VN
38
39 init_completion(&backtrace_work);
40 tasklet_schedule(&backtrace_tasklet);
41 wait_for_completion(&backtrace_work);
6dab2778 42}
ad118c54
VN
43
44#ifdef CONFIG_STACKTRACE
45static void backtrace_test_saved(void)
46{
ad118c54 47 unsigned long entries[8];
1b59562d 48 unsigned int nr_entries;
ad118c54 49
462b29b8
FF
50 pr_info("Testing a saved backtrace.\n");
51 pr_info("The following trace is a kernel self test and not a bug!\n");
ad118c54 52
1b59562d
TG
53 nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0);
54 stack_trace_print(entries, nr_entries, 0);
ad118c54
VN
55}
56#else
57static void backtrace_test_saved(void)
58{
462b29b8 59 pr_info("Saved backtrace test skipped.\n");
ad118c54
VN
60}
61#endif
62
6dab2778
AV
63static int backtrace_regression_test(void)
64{
462b29b8 65 pr_info("====[ backtrace testing ]===========\n");
6dab2778 66
4e6a0535
VN
67 backtrace_test_normal();
68 backtrace_test_irq();
ad118c54
VN
69 backtrace_test_saved();
70
462b29b8 71 pr_info("====[ end of backtrace testing ]====\n");
6dab2778
AV
72 return 0;
73}
74
75static void exitf(void)
76{
77}
78
79module_init(backtrace_regression_test);
80module_exit(exitf);
81MODULE_LICENSE("GPL");
82MODULE_AUTHOR("Arjan van de Ven <arjan@linux.intel.com>");