Lines Matching refs:cxt
68 static void mark_page_used(struct mtdoops_context *cxt, int page) in mark_page_used() argument
70 set_bit(page, cxt->oops_page_used); in mark_page_used()
73 static void mark_page_unused(struct mtdoops_context *cxt, int page) in mark_page_unused() argument
75 clear_bit(page, cxt->oops_page_used); in mark_page_unused()
78 static int page_is_used(struct mtdoops_context *cxt, int page) in page_is_used() argument
80 return test_bit(page, cxt->oops_page_used); in page_is_used()
83 static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset) in mtdoops_erase_block() argument
85 struct mtd_info *mtd = cxt->mtd; in mtdoops_erase_block()
106 mark_page_unused(cxt, page); in mtdoops_erase_block()
111 static void mtdoops_erase(struct mtdoops_context *cxt) in mtdoops_erase() argument
113 struct mtd_info *mtd = cxt->mtd; in mtdoops_erase()
120 mod = (cxt->nextpage * record_size) % mtd->erasesize; in mtdoops_erase()
122 cxt->nextpage = cxt->nextpage + ((mtd->erasesize - mod) / record_size); in mtdoops_erase()
123 if (cxt->nextpage >= cxt->oops_pages) in mtdoops_erase()
124 cxt->nextpage = 0; in mtdoops_erase()
127 while ((ret = mtd_block_isbad(mtd, cxt->nextpage * record_size)) > 0) { in mtdoops_erase()
130 cxt->nextpage * record_size); in mtdoops_erase()
132 cxt->nextpage = cxt->nextpage + (mtd->erasesize / record_size); in mtdoops_erase()
133 if (cxt->nextpage >= cxt->oops_pages) in mtdoops_erase()
134 cxt->nextpage = 0; in mtdoops_erase()
135 if (i == cxt->oops_pages / (mtd->erasesize / record_size)) { in mtdoops_erase()
147 ret = mtdoops_erase_block(cxt, cxt->nextpage * record_size); in mtdoops_erase()
151 cxt->nextpage, cxt->nextcount); in mtdoops_erase()
156 ret = mtd_block_markbad(mtd, cxt->nextpage * record_size); in mtdoops_erase()
168 struct mtdoops_context *cxt = in mtdoops_workfunc_erase() local
170 mtdoops_erase(cxt); in mtdoops_workfunc_erase()
173 static void mtdoops_inc_counter(struct mtdoops_context *cxt, int panic) in mtdoops_inc_counter() argument
175 cxt->nextpage++; in mtdoops_inc_counter()
176 if (cxt->nextpage >= cxt->oops_pages) in mtdoops_inc_counter()
177 cxt->nextpage = 0; in mtdoops_inc_counter()
178 cxt->nextcount++; in mtdoops_inc_counter()
179 if (cxt->nextcount == 0xffffffff) in mtdoops_inc_counter()
180 cxt->nextcount = 0; in mtdoops_inc_counter()
182 if (page_is_used(cxt, cxt->nextpage)) { in mtdoops_inc_counter()
184 cxt->nextpage, cxt->nextcount, in mtdoops_inc_counter()
188 mtdoops_erase(cxt); in mtdoops_inc_counter()
191 schedule_work(&cxt->work_erase); in mtdoops_inc_counter()
195 cxt->nextpage, cxt->nextcount); in mtdoops_inc_counter()
199 static void mtdoops_write(struct mtdoops_context *cxt, int panic) in mtdoops_write() argument
201 struct mtd_info *mtd = cxt->mtd; in mtdoops_write()
206 if (test_and_set_bit(0, &cxt->oops_buf_busy)) in mtdoops_write()
210 hdr = (struct mtdoops_hdr *)cxt->oops_buf; in mtdoops_write()
211 hdr->seq = cxt->nextcount; in mtdoops_write()
216 ret = mtd_panic_write(mtd, cxt->nextpage * record_size, in mtdoops_write()
217 record_size, &retlen, cxt->oops_buf); in mtdoops_write()
223 ret = mtd_write(mtd, cxt->nextpage * record_size, in mtdoops_write()
224 record_size, &retlen, cxt->oops_buf); in mtdoops_write()
228 cxt->nextpage * record_size, retlen, record_size, ret); in mtdoops_write()
229 mark_page_used(cxt, cxt->nextpage); in mtdoops_write()
230 memset(cxt->oops_buf, 0xff, record_size); in mtdoops_write()
232 mtdoops_inc_counter(cxt, panic); in mtdoops_write()
234 clear_bit(0, &cxt->oops_buf_busy); in mtdoops_write()
239 struct mtdoops_context *cxt = in mtdoops_workfunc_write() local
242 mtdoops_write(cxt, 0); in mtdoops_workfunc_write()
245 static void find_next_position(struct mtdoops_context *cxt) in find_next_position() argument
247 struct mtd_info *mtd = cxt->mtd; in find_next_position()
253 for (page = 0; page < cxt->oops_pages; page++) { in find_next_position()
257 mark_page_used(cxt, page); in find_next_position()
268 mark_page_unused(cxt, page); in find_next_position()
289 cxt->nextpage = cxt->oops_pages - 1; in find_next_position()
290 cxt->nextcount = 0; in find_next_position()
293 cxt->nextpage = maxpos; in find_next_position()
294 cxt->nextcount = maxcount; in find_next_position()
297 mtdoops_inc_counter(cxt, 0); in find_next_position()
303 struct mtdoops_context *cxt = container_of(dumper, in mtdoops_do_dump() local
313 if (test_and_set_bit(0, &cxt->oops_buf_busy)) in mtdoops_do_dump()
316 cxt->oops_buf + sizeof(struct mtdoops_hdr), in mtdoops_do_dump()
318 clear_bit(0, &cxt->oops_buf_busy); in mtdoops_do_dump()
322 mtdoops_write(cxt, 1); in mtdoops_do_dump()
325 schedule_work(&cxt->work_write); in mtdoops_do_dump()
331 struct mtdoops_context *cxt = &oops_cxt; in mtdoops_notify_add() local
336 cxt->mtd_index = mtd->index; in mtdoops_notify_add()
338 if (mtd->index != cxt->mtd_index || cxt->mtd_index < 0) in mtdoops_notify_add()
358 cxt->oops_page_used = in mtdoops_notify_add()
362 if (!cxt->oops_page_used) { in mtdoops_notify_add()
367 cxt->dump.max_reason = KMSG_DUMP_OOPS; in mtdoops_notify_add()
368 cxt->dump.dump = mtdoops_do_dump; in mtdoops_notify_add()
369 err = kmsg_dump_register(&cxt->dump); in mtdoops_notify_add()
372 vfree(cxt->oops_page_used); in mtdoops_notify_add()
373 cxt->oops_page_used = NULL; in mtdoops_notify_add()
377 cxt->mtd = mtd; in mtdoops_notify_add()
378 cxt->oops_pages = (int)mtd->size / record_size; in mtdoops_notify_add()
379 find_next_position(cxt); in mtdoops_notify_add()
385 struct mtdoops_context *cxt = &oops_cxt; in mtdoops_notify_remove() local
387 if (mtd->index != cxt->mtd_index || cxt->mtd_index < 0) in mtdoops_notify_remove()
390 if (kmsg_dump_unregister(&cxt->dump) < 0) in mtdoops_notify_remove()
393 cxt->mtd = NULL; in mtdoops_notify_remove()
394 flush_work(&cxt->work_erase); in mtdoops_notify_remove()
395 flush_work(&cxt->work_write); in mtdoops_notify_remove()
406 struct mtdoops_context *cxt = &oops_cxt; in mtdoops_init() local
424 cxt->mtd_index = -1; in mtdoops_init()
427 cxt->mtd_index = mtd_index; in mtdoops_init()
429 cxt->oops_buf = vmalloc(record_size); in mtdoops_init()
430 if (!cxt->oops_buf) in mtdoops_init()
432 memset(cxt->oops_buf, 0xff, record_size); in mtdoops_init()
433 cxt->oops_buf_busy = 0; in mtdoops_init()
435 INIT_WORK(&cxt->work_erase, mtdoops_workfunc_erase); in mtdoops_init()
436 INIT_WORK(&cxt->work_write, mtdoops_workfunc_write); in mtdoops_init()
444 struct mtdoops_context *cxt = &oops_cxt; in mtdoops_exit() local
447 vfree(cxt->oops_buf); in mtdoops_exit()
448 vfree(cxt->oops_page_used); in mtdoops_exit()