Lines Matching refs:cxt

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