• Home
  • Raw
  • Download

Lines Matching +full:no +full:- +full:dump +full:- +full:oops

1 // SPDX-License-Identifier: GPL-2.0-only
3 * MTD Oops/Panic logger
31 "record size for MTD OOPS pages in bytes (default 4096)");
41 "set to 1 to dump oopses, 0 to only dump panics (default 1)");
44 struct kmsg_dumper dump; member
60 set_bit(page, cxt->oops_page_used); in mark_page_used()
65 clear_bit(page, cxt->oops_page_used); in mark_page_unused()
70 return test_bit(page, cxt->oops_page_used); in page_is_used()
75 struct mtd_info *mtd = cxt->mtd; in mtdoops_erase_block()
76 u32 start_page_offset = mtd_div_by_eb(offset, mtd) * mtd->erasesize; in mtdoops_erase_block()
78 u32 erase_pages = mtd->erasesize / record_size; in mtdoops_erase_block()
84 erase.len = mtd->erasesize; in mtdoops_erase_block()
103 cxt->nextpage++; in mtdoops_inc_counter()
104 if (cxt->nextpage >= cxt->oops_pages) in mtdoops_inc_counter()
105 cxt->nextpage = 0; in mtdoops_inc_counter()
106 cxt->nextcount++; in mtdoops_inc_counter()
107 if (cxt->nextcount == 0xffffffff) in mtdoops_inc_counter()
108 cxt->nextcount = 0; in mtdoops_inc_counter()
110 if (page_is_used(cxt, cxt->nextpage)) { in mtdoops_inc_counter()
111 schedule_work(&cxt->work_erase); in mtdoops_inc_counter()
115 printk(KERN_DEBUG "mtdoops: ready %d, %d (no erase)\n", in mtdoops_inc_counter()
116 cxt->nextpage, cxt->nextcount); in mtdoops_inc_counter()
119 /* Scheduled work - when we can't proceed without erasing a block */
124 struct mtd_info *mtd = cxt->mtd; in mtdoops_workfunc_erase()
131 mod = (cxt->nextpage * record_size) % mtd->erasesize; in mtdoops_workfunc_erase()
133 cxt->nextpage = cxt->nextpage + ((mtd->erasesize - mod) / record_size); in mtdoops_workfunc_erase()
134 if (cxt->nextpage >= cxt->oops_pages) in mtdoops_workfunc_erase()
135 cxt->nextpage = 0; in mtdoops_workfunc_erase()
138 while ((ret = mtd_block_isbad(mtd, cxt->nextpage * record_size)) > 0) { in mtdoops_workfunc_erase()
141 cxt->nextpage * record_size); in mtdoops_workfunc_erase()
143 cxt->nextpage = cxt->nextpage + (mtd->erasesize / record_size); in mtdoops_workfunc_erase()
144 if (cxt->nextpage >= cxt->oops_pages) in mtdoops_workfunc_erase()
145 cxt->nextpage = 0; in mtdoops_workfunc_erase()
146 if (i == cxt->oops_pages / (mtd->erasesize / record_size)) { in mtdoops_workfunc_erase()
157 for (j = 0, ret = -1; (j < 3) && (ret < 0); j++) in mtdoops_workfunc_erase()
158 ret = mtdoops_erase_block(cxt, cxt->nextpage * record_size); in mtdoops_workfunc_erase()
162 cxt->nextpage, cxt->nextcount); in mtdoops_workfunc_erase()
166 if (ret == -EIO) { in mtdoops_workfunc_erase()
167 ret = mtd_block_markbad(mtd, cxt->nextpage * record_size); in mtdoops_workfunc_erase()
168 if (ret < 0 && ret != -EOPNOTSUPP) { in mtdoops_workfunc_erase()
178 struct mtd_info *mtd = cxt->mtd; in mtdoops_write()
184 hdr = cxt->oops_buf; in mtdoops_write()
185 hdr[0] = cxt->nextcount; in mtdoops_write()
189 ret = mtd_panic_write(mtd, cxt->nextpage * record_size, in mtdoops_write()
190 record_size, &retlen, cxt->oops_buf); in mtdoops_write()
191 if (ret == -EOPNOTSUPP) { in mtdoops_write()
196 ret = mtd_write(mtd, cxt->nextpage * record_size, in mtdoops_write()
197 record_size, &retlen, cxt->oops_buf); in mtdoops_write()
201 cxt->nextpage * record_size, retlen, record_size, ret); in mtdoops_write()
202 mark_page_used(cxt, cxt->nextpage); in mtdoops_write()
203 memset(cxt->oops_buf, 0xff, record_size); in mtdoops_write()
218 struct mtd_info *mtd = cxt->mtd; in find_next_position()
223 for (page = 0; page < cxt->oops_pages; page++) { in find_next_position()
258 cxt->nextpage = cxt->oops_pages - 1; in find_next_position()
259 cxt->nextcount = 0; in find_next_position()
262 cxt->nextpage = maxpos; in find_next_position()
263 cxt->nextcount = maxcount; in find_next_position()
273 struct mtdoops_context, dump); in mtdoops_do_dump()
275 /* Only dump oopses if dump_oops is set */ in mtdoops_do_dump()
279 kmsg_dump_get_buffer(dumper, true, cxt->oops_buf + MTDOOPS_HEADER_SIZE, in mtdoops_do_dump()
280 record_size - MTDOOPS_HEADER_SIZE, NULL); in mtdoops_do_dump()
287 schedule_work(&cxt->work_write); in mtdoops_do_dump()
294 u64 mtdoops_pages = div_u64(mtd->size, record_size); in mtdoops_notify_add()
297 if (!strcmp(mtd->name, mtddev)) in mtdoops_notify_add()
298 cxt->mtd_index = mtd->index; in mtdoops_notify_add()
300 if (mtd->index != cxt->mtd_index || cxt->mtd_index < 0) in mtdoops_notify_add()
303 if (mtd->size < mtd->erasesize * 2) { in mtdoops_notify_add()
305 mtd->index); in mtdoops_notify_add()
308 if (mtd->erasesize < record_size) { in mtdoops_notify_add()
310 mtd->index); in mtdoops_notify_add()
313 if (mtd->size > MTDOOPS_MAX_MTD_SIZE) { in mtdoops_notify_add()
315 mtd->index, MTDOOPS_MAX_MTD_SIZE / 1024 / 1024); in mtdoops_notify_add()
320 cxt->oops_page_used = in mtdoops_notify_add()
324 if (!cxt->oops_page_used) { in mtdoops_notify_add()
329 cxt->dump.max_reason = KMSG_DUMP_OOPS; in mtdoops_notify_add()
330 cxt->dump.dump = mtdoops_do_dump; in mtdoops_notify_add()
331 err = kmsg_dump_register(&cxt->dump); in mtdoops_notify_add()
334 vfree(cxt->oops_page_used); in mtdoops_notify_add()
335 cxt->oops_page_used = NULL; in mtdoops_notify_add()
339 cxt->mtd = mtd; in mtdoops_notify_add()
340 cxt->oops_pages = (int)mtd->size / record_size; in mtdoops_notify_add()
342 printk(KERN_INFO "mtdoops: Attached to MTD device %d\n", mtd->index); in mtdoops_notify_add()
349 if (mtd->index != cxt->mtd_index || cxt->mtd_index < 0) in mtdoops_notify_remove()
352 if (kmsg_dump_unregister(&cxt->dump) < 0) in mtdoops_notify_remove()
355 cxt->mtd = NULL; in mtdoops_notify_remove()
356 flush_work(&cxt->work_erase); in mtdoops_notify_remove()
357 flush_work(&cxt->work_write); in mtdoops_notify_remove()
374 return -EINVAL; in mtdoops_init()
378 return -EINVAL; in mtdoops_init()
382 return -EINVAL; in mtdoops_init()
386 cxt->mtd_index = -1; in mtdoops_init()
389 cxt->mtd_index = mtd_index; in mtdoops_init()
391 cxt->oops_buf = vmalloc(record_size); in mtdoops_init()
392 if (!cxt->oops_buf) { in mtdoops_init()
394 return -ENOMEM; in mtdoops_init()
396 memset(cxt->oops_buf, 0xff, record_size); in mtdoops_init()
398 INIT_WORK(&cxt->work_erase, mtdoops_workfunc_erase); in mtdoops_init()
399 INIT_WORK(&cxt->work_write, mtdoops_workfunc_write); in mtdoops_init()
410 vfree(cxt->oops_buf); in mtdoops_exit()
411 vfree(cxt->oops_page_used); in mtdoops_exit()
420 MODULE_DESCRIPTION("MTD Oops/Panic console logger/driver");