Lines Matching refs:cxt

72 static void mark_page_used(struct mtdoops_context *cxt, int page)  in mark_page_used()  argument
74 set_bit(page, cxt->oops_page_used); in mark_page_used()
77 static void mark_page_unused(struct mtdoops_context *cxt, int page) in mark_page_unused() argument
79 clear_bit(page, cxt->oops_page_used); in mark_page_unused()
82 static int page_is_used(struct mtdoops_context *cxt, int page) in page_is_used() argument
84 return test_bit(page, cxt->oops_page_used); in page_is_used()
93 static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset) in mtdoops_erase_block() argument
95 struct mtd_info *mtd = cxt->mtd; in mtdoops_erase_block()
130 mark_page_unused(cxt, page); in mtdoops_erase_block()
135 static void mtdoops_inc_counter(struct mtdoops_context *cxt) in mtdoops_inc_counter() argument
137 cxt->nextpage++; in mtdoops_inc_counter()
138 if (cxt->nextpage >= cxt->oops_pages) in mtdoops_inc_counter()
139 cxt->nextpage = 0; in mtdoops_inc_counter()
140 cxt->nextcount++; in mtdoops_inc_counter()
141 if (cxt->nextcount == 0xffffffff) in mtdoops_inc_counter()
142 cxt->nextcount = 0; in mtdoops_inc_counter()
144 if (page_is_used(cxt, cxt->nextpage)) { in mtdoops_inc_counter()
145 schedule_work(&cxt->work_erase); in mtdoops_inc_counter()
150 cxt->nextpage, cxt->nextcount); in mtdoops_inc_counter()
156 struct mtdoops_context *cxt = in mtdoops_workfunc_erase() local
158 struct mtd_info *mtd = cxt->mtd; in mtdoops_workfunc_erase()
165 mod = (cxt->nextpage * record_size) % mtd->erasesize; in mtdoops_workfunc_erase()
167 cxt->nextpage = cxt->nextpage + ((mtd->erasesize - mod) / record_size); in mtdoops_workfunc_erase()
168 if (cxt->nextpage >= cxt->oops_pages) in mtdoops_workfunc_erase()
169 cxt->nextpage = 0; in mtdoops_workfunc_erase()
172 while ((ret = mtd_block_isbad(mtd, cxt->nextpage * record_size)) > 0) { in mtdoops_workfunc_erase()
175 cxt->nextpage * record_size); in mtdoops_workfunc_erase()
177 cxt->nextpage = cxt->nextpage + (mtd->erasesize / record_size); in mtdoops_workfunc_erase()
178 if (cxt->nextpage >= cxt->oops_pages) in mtdoops_workfunc_erase()
179 cxt->nextpage = 0; in mtdoops_workfunc_erase()
180 if (i == cxt->oops_pages / (mtd->erasesize / record_size)) { in mtdoops_workfunc_erase()
192 ret = mtdoops_erase_block(cxt, cxt->nextpage * record_size); in mtdoops_workfunc_erase()
196 cxt->nextpage, cxt->nextcount); in mtdoops_workfunc_erase()
201 ret = mtd_block_markbad(mtd, cxt->nextpage * record_size); in mtdoops_workfunc_erase()
210 static void mtdoops_write(struct mtdoops_context *cxt, int panic) in mtdoops_write() argument
212 struct mtd_info *mtd = cxt->mtd; in mtdoops_write()
218 hdr = cxt->oops_buf; in mtdoops_write()
219 hdr[0] = cxt->nextcount; in mtdoops_write()
223 ret = mtd_panic_write(mtd, cxt->nextpage * record_size, in mtdoops_write()
224 record_size, &retlen, cxt->oops_buf); in mtdoops_write()
230 ret = mtd_write(mtd, cxt->nextpage * record_size, in mtdoops_write()
231 record_size, &retlen, cxt->oops_buf); in mtdoops_write()
235 cxt->nextpage * record_size, retlen, record_size, ret); in mtdoops_write()
236 mark_page_used(cxt, cxt->nextpage); in mtdoops_write()
237 memset(cxt->oops_buf, 0xff, record_size); in mtdoops_write()
239 mtdoops_inc_counter(cxt); in mtdoops_write()
244 struct mtdoops_context *cxt = in mtdoops_workfunc_write() local
247 mtdoops_write(cxt, 0); in mtdoops_workfunc_write()
250 static void find_next_position(struct mtdoops_context *cxt) in find_next_position() argument
252 struct mtd_info *mtd = cxt->mtd; in find_next_position()
257 for (page = 0; page < cxt->oops_pages; page++) { in find_next_position()
261 mark_page_used(cxt, page); in find_next_position()
273 mark_page_unused(cxt, page); in find_next_position()
292 cxt->nextpage = cxt->oops_pages - 1; in find_next_position()
293 cxt->nextcount = 0; in find_next_position()
296 cxt->nextpage = maxpos; in find_next_position()
297 cxt->nextcount = maxcount; in find_next_position()
300 mtdoops_inc_counter(cxt); in find_next_position()
306 struct mtdoops_context *cxt = container_of(dumper, in mtdoops_do_dump() local
313 kmsg_dump_get_buffer(dumper, true, cxt->oops_buf + MTDOOPS_HEADER_SIZE, in mtdoops_do_dump()
318 mtdoops_write(cxt, 1); in mtdoops_do_dump()
321 schedule_work(&cxt->work_write); in mtdoops_do_dump()
326 struct mtdoops_context *cxt = &oops_cxt; in mtdoops_notify_add() local
331 cxt->mtd_index = mtd->index; in mtdoops_notify_add()
333 if (mtd->index != cxt->mtd_index || cxt->mtd_index < 0) in mtdoops_notify_add()
353 cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages, in mtdoops_notify_add()
355 if (!cxt->oops_page_used) { in mtdoops_notify_add()
360 cxt->dump.max_reason = KMSG_DUMP_OOPS; in mtdoops_notify_add()
361 cxt->dump.dump = mtdoops_do_dump; in mtdoops_notify_add()
362 err = kmsg_dump_register(&cxt->dump); in mtdoops_notify_add()
365 vfree(cxt->oops_page_used); in mtdoops_notify_add()
366 cxt->oops_page_used = NULL; in mtdoops_notify_add()
370 cxt->mtd = mtd; in mtdoops_notify_add()
371 cxt->oops_pages = (int)mtd->size / record_size; in mtdoops_notify_add()
372 find_next_position(cxt); in mtdoops_notify_add()
378 struct mtdoops_context *cxt = &oops_cxt; in mtdoops_notify_remove() local
380 if (mtd->index != cxt->mtd_index || cxt->mtd_index < 0) in mtdoops_notify_remove()
383 if (kmsg_dump_unregister(&cxt->dump) < 0) in mtdoops_notify_remove()
386 cxt->mtd = NULL; in mtdoops_notify_remove()
387 flush_work(&cxt->work_erase); in mtdoops_notify_remove()
388 flush_work(&cxt->work_write); in mtdoops_notify_remove()
399 struct mtdoops_context *cxt = &oops_cxt; in mtdoops_init() local
417 cxt->mtd_index = -1; in mtdoops_init()
420 cxt->mtd_index = mtd_index; in mtdoops_init()
422 cxt->oops_buf = vmalloc(record_size); in mtdoops_init()
423 if (!cxt->oops_buf) { in mtdoops_init()
427 memset(cxt->oops_buf, 0xff, record_size); in mtdoops_init()
429 INIT_WORK(&cxt->work_erase, mtdoops_workfunc_erase); in mtdoops_init()
430 INIT_WORK(&cxt->work_write, mtdoops_workfunc_write); in mtdoops_init()
438 struct mtdoops_context *cxt = &oops_cxt; in mtdoops_exit() local
441 vfree(cxt->oops_buf); in mtdoops_exit()
442 vfree(cxt->oops_page_used); in mtdoops_exit()