diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 1ad128d..1acefaf 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -928,6 +928,9 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) if (err) goto out_free; + ubi->dbg->chk_gen = 1; + ubi->dbg->emulate_bitflips = 1; + err = ubi_attach(ubi); if (err) { ubi_err("failed to attach mtd%d, error %d", mtd->index, err); diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index d5d2645..a4fac6e 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -31,7 +31,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); if (unlikely(!(expr))) { \ printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \ __func__, __LINE__, current->pid); \ - dump_stack(); \ + BUG(); \ } \ } while (0) diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index f4d2c79..7b49665 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1632,7 +1632,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai) int err, i, found_pebs = 0; struct rb_node *rb1, *rb2; struct ubi_ainf_volume *av; - struct ubi_ainf_peb *aeb, *tmp; + struct ubi_ainf_peb *aeb, *tmp, *x; struct ubi_wl_entry *e; ubi->used = ubi->erroneous = ubi->free = ubi->scrub = RB_ROOT; @@ -1653,6 +1653,28 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai) INIT_LIST_HEAD(&ubi->pq[i]); ubi->pq_head = 0; + ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) { + ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb) { + list_for_each_entry(x, &ai->erase, u.list) { + if (x->pnum == aeb->pnum) { + ubi_err("PEB: %i is in used/scrub and erase!", x->pnum); + } + } + list_for_each_entry(x, &ai->free, u.list) { + if (x->pnum == aeb->pnum) { + ubi_err("PEB: %i is in used/scrub and free!", x->pnum); + } + } + } + } + list_for_each_entry(aeb, &ai->erase, u.list) { + list_for_each_entry(x, &ai->free, u.list) { + if (x->pnum == aeb->pnum) { + ubi_err("PEB: %i is in erase and free!", x->pnum); + } + } + } + list_for_each_entry_safe(aeb, tmp, &ai->erase, u.list) { cond_resched(); @@ -1819,7 +1841,7 @@ static int self_check_ec(struct ubi_device *ubi, int pnum, int ec) if (ec != read_ec && read_ec - ec > 1) { ubi_err("self-check failed for PEB %d", pnum); ubi_err("read EC is %lld, should be %d", read_ec, ec); - dump_stack(); + BUG(); err = 1; } else err = 0; @@ -1849,7 +1871,7 @@ static int self_check_in_wl_tree(const struct ubi_device *ubi, ubi_err("self-check failed for PEB %d, EC %d, RB-tree %p ", e->pnum, e->ec, root); - dump_stack(); + BUG(); return -EINVAL; } @@ -1877,6 +1899,6 @@ static int self_check_in_pq(const struct ubi_device *ubi, ubi_err("self-check failed for PEB %d, EC %d, Protect queue", e->pnum, e->ec); - dump_stack(); + BUG(); return -EINVAL; }