Merge tag 'rtc-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
[linux-2.6-block.git] / Documentation / ramoops.txt
CommitLineData
4126dacb
SI
1Ramoops oops/panic logger
2=========================
3
4Sergiu Iordache <sergiu@chromium.org>
5
9ba80d99 6Updated: 17 November 2011
4126dacb
SI
7
80. Introduction
9
10Ramoops is an oops/panic logger that writes its logs to RAM before the system
11crashes. It works by logging oopses and panics in a circular buffer. Ramoops
12needs a system with persistent RAM so that the content of that area can
13survive after a restart.
14
151. Ramoops concepts
16
027bc8b0
TL
17Ramoops uses a predefined memory area to store the dump. The start and size
18and type of the memory area are set using three variables:
4126dacb
SI
19 * "mem_address" for the start
20 * "mem_size" for the size. The memory size will be rounded down to a
21 power of two.
027bc8b0
TL
22 * "mem_type" to specifiy if the memory type (default is pgprot_writecombine).
23
24Typically the default value of mem_type=0 should be used as that sets the pstore
25mapping to pgprot_writecombine. Setting mem_type=1 attempts to use
26pgprot_noncached, which only works on some platforms. This is because pstore
27depends on atomic operations. At least on ARM, pgprot_noncached causes the
28memory to be mapped strongly ordered, and atomic operations on strongly ordered
29memory are implementation defined, and won't work on many ARMs such as omaps.
4126dacb
SI
30
31The memory area is divided into "record_size" chunks (also rounded down to
32power of two) and each oops/panic writes a "record_size" chunk of
33information.
34
35Dumping both oopses and panics can be done by setting 1 in the "dump_oops"
36variable while setting 0 in that variable dumps only the panics.
37
38The module uses a counter to record multiple dumps but the counter gets reset
39on restart (i.e. new dumps after the restart will overwrite old ones).
40
39eb7e97
AV
41Ramoops also supports software ECC protection of persistent memory regions.
42This might be useful when a hardware reset was used to bring the machine back
43to life (i.e. a watchdog triggered). In such cases, RAM may be somewhat
44corrupt, but usually it is restorable.
45
4126dacb
SI
462. Setting the parameters
47
35da6094 48Setting the ramoops parameters can be done in 3 different manners:
4126dacb
SI
49 1. Use the module parameters (which have the names of the variables described
50 as before).
958502d8
AV
51 For quick debugging, you can also reserve parts of memory during boot
52 and then use the reserved memory for ramoops. For example, assuming a machine
53 with > 128 MB of memory, the following kernel command line will tell the
54 kernel to use only the first 128 MB of memory, and place ECC-protected ramoops
55 region at 128 MB boundary:
56 "mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1"
35da6094
GH
57 2. Use Device Tree bindings, as described in
58 Documentation/device-tree/bindings/misc/ramoops.txt.
59 3. Use a platform device and set the platform data. The parameters can then
4126dacb
SI
60 be set through that platform data. An example of doing that is:
61
1894a253 62#include <linux/pstore_ram.h>
4126dacb
SI
63[...]
64
65static struct ramoops_platform_data ramoops_data = {
66 .mem_size = <...>,
67 .mem_address = <...>,
027bc8b0 68 .mem_type = <...>,
4126dacb
SI
69 .record_size = <...>,
70 .dump_oops = <...>,
39eb7e97 71 .ecc = <...>,
4126dacb
SI
72};
73
74static struct platform_device ramoops_dev = {
75 .name = "ramoops",
76 .dev = {
77 .platform_data = &ramoops_data,
78 },
79};
80
81[... inside a function ...]
82int ret;
83
84ret = platform_device_register(&ramoops_dev);
85if (ret) {
86 printk(KERN_ERR "unable to register platform device\n");
87 return ret;
88}
89
958502d8
AV
90You can specify either RAM memory or peripheral devices' memory. However, when
91specifying RAM, be sure to reserve the memory by issuing memblock_reserve()
92very early in the architecture code, e.g.:
93
94#include <linux/memblock.h>
95
96memblock_reserve(ramoops_data.mem_address, ramoops_data.mem_size);
97
4126dacb
SI
983. Dump format
99
100The data dump begins with a header, currently defined as "====" followed by a
101timestamp and a new line. The dump then continues with the actual data.
102
1034. Reading the data
104
9ba80d99
KC
105The dump data can be read from the pstore filesystem. The format for these
106files is "dmesg-ramoops-N", where N is the record number in memory. To delete
107a stored record from RAM, simply unlink the respective pstore file.
a694d1b5
AV
108
1095. Persistent function tracing
110
111Persistent function tracing might be useful for debugging software or hardware
112related hangs. The functions call chain log is stored in a "ftrace-ramoops"
113file. Here is an example of usage:
114
115 # mount -t debugfs debugfs /sys/kernel/debug/
65f8c95e 116 # echo 1 > /sys/kernel/debug/pstore/record_ftrace
a694d1b5
AV
117 # reboot -f
118 [...]
119 # mount -t pstore pstore /mnt/
120 # tail /mnt/ftrace-ramoops
121 0 ffffffff8101ea64 ffffffff8101bcda native_apic_mem_read <- disconnect_bsp_APIC+0x6a/0xc0
122 0 ffffffff8101ea44 ffffffff8101bcf6 native_apic_mem_write <- disconnect_bsp_APIC+0x86/0xc0
123 0 ffffffff81020084 ffffffff8101a4b5 hpet_disable <- native_machine_shutdown+0x75/0x90
124 0 ffffffff81005f94 ffffffff8101a4bb iommu_shutdown_noop <- native_machine_shutdown+0x7b/0x90
125 0 ffffffff8101a6a1 ffffffff8101a437 native_machine_emergency_restart <- native_machine_restart+0x37/0x40
126 0 ffffffff811f9876 ffffffff8101a73a acpi_reboot <- native_machine_emergency_restart+0xaa/0x1e0
127 0 ffffffff8101a514 ffffffff8101a772 mach_reboot_fixups <- native_machine_emergency_restart+0xe2/0x1e0
128 0 ffffffff811d9c54 ffffffff8101a7a0 __const_udelay <- native_machine_emergency_restart+0x110/0x1e0
129 0 ffffffff811d9c34 ffffffff811d9c80 __delay <- __const_udelay+0x30/0x40
130 0 ffffffff811d9d14 ffffffff811d9c3f delay_tsc <- __delay+0xf/0x20