22 #include <linux/types.h>
23 #include <linux/errno.h>
27 #include <linux/module.h>
29 #include <linux/string.h>
31 #include <linux/slab.h>
44 static int pstore_update_ms = -1;
46 MODULE_PARM_DESC(update_ms,
"milliseconds before pstore updates its content "
47 "(default is -1, which means runtime updates are disabled; "
48 "enabling this option is not safe, it may lead to further "
49 "corruption on Oopses)");
51 static int pstore_new_entry;
53 static void pstore_timefunc(
unsigned long);
54 static DEFINE_TIMER(pstore_timer, pstore_timefunc, 0, 0);
69 static unsigned long kmsg_bytes = 10240;
104 static void pstore_dump(
struct kmsg_dumper *dumper,
107 unsigned long total = 0;
110 unsigned int part = 1;
111 unsigned long flags = 0;
115 why = get_reason_str(reason);
118 is_locked = spin_trylock(&psinfo->
buf_lock);
120 pr_err(
"pstore dump routine blocked in NMI, may corrupt error record\n");
124 while (total < kmsg_bytes) {
131 hsize =
sprintf(dst,
"%s#%d Part%d\n", why, oopscount, part);
135 if (!kmsg_dump_get_buffer(dumper,
true, dst, size, &len))
139 hsize + len, psinfo);
141 pstore_new_entry = 1;
143 total += hsize + len;
150 spin_unlock_irqrestore(&psinfo->
buf_lock, flags);
157 #ifdef CONFIG_PSTORE_CONSOLE
158 static void pstore_console_write(
struct console *
con,
const char *
s,
unsigned c)
160 const char *
e = s +
c;
177 spin_unlock_irqrestore(&psinfo->
buf_lock, flags);
183 static struct console pstore_console = {
185 .write = pstore_console_write,
190 static void pstore_register_console(
void)
195 static void pstore_register_console(
void) {}
200 u64 *
id,
unsigned int part,
203 return psi->
write_buf(type, reason,
id, part, psinfo->
buf, size, psi);
219 spin_lock(&pstore_lock);
221 spin_unlock(&pstore_lock);
226 spin_unlock(&pstore_lock);
231 psi->
write = pstore_write_compat;
234 spin_unlock(&pstore_lock);
236 if (owner && !try_module_get(owner)) {
244 kmsg_dump_register(&pstore_dumper);
245 pstore_register_console();
248 if (pstore_update_ms >= 0) {
249 pstore_timer.expires =
jiffies +
281 while ((size = psi->
read(&
id, &type, &time, &buf, psi)) > 0) {
304 static void pstore_timefunc(
unsigned long dummy)
306 if (pstore_new_entry) {
307 pstore_new_entry = 0;