• Home
  • Raw
  • Download

Lines Matching refs:ubi

23 size_t ubi_calc_fm_size(struct ubi_device *ubi)  in ubi_calc_fm_size()  argument
30 (ubi->peb_count * sizeof(struct ubi_fm_ec)) + \ in ubi_calc_fm_size()
32 (ubi->peb_count * sizeof(__be32))) + \ in ubi_calc_fm_size()
34 return roundup(size, ubi->leb_size); in ubi_calc_fm_size()
46 static struct ubi_vid_hdr *new_fm_vhdr(struct ubi_device *ubi, int vol_id) in new_fm_vhdr() argument
50 new = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL); in new_fm_vhdr()
203 static int update_vol(struct ubi_device *ubi, struct ubi_attach_info *ai, in update_vol() argument
235 cmp_res = ubi_compare_lebs(ubi, aeb, new_aeb->pnum, new_vh); in update_vol()
299 static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai, in process_pool_aeb() argument
338 return update_vol(ubi, ai, av, new_vh, new_aeb); in process_pool_aeb()
383 static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, in scan_pool() argument
392 ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL); in scan_pool()
396 vh = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL); in scan_pool()
413 if (ubi_io_is_bad(ubi, pnum)) { in scan_pool()
419 err = ubi_io_read_ec_hdr(ubi, pnum, ech, 0); in scan_pool()
428 if (be32_to_cpu(ech->image_seq) != ubi->image_seq) { in scan_pool()
430 be32_to_cpu(ech->image_seq), ubi->image_seq); in scan_pool()
435 err = ubi_io_read_vid_hdr(ubi, pnum, vh, 0); in scan_pool()
480 err = process_pool_aeb(ubi, ai, vh, new_aeb); in scan_pool()
495 ubi_free_vid_hdr(ubi, vh); in scan_pool()
533 static int ubi_attach_fastmap(struct ubi_device *ubi, in ubi_attach_fastmap() argument
548 size_t fm_pos = 0, fm_size = ubi->fm_size; in ubi_attach_fastmap()
550 void *fm_raw = ubi->fm_buf; in ubi_attach_fastmap()
769 ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL); in ubi_attach_fastmap()
779 if (ubi_io_is_bad(ubi, tmp_aeb->pnum)) { in ubi_attach_fastmap()
786 err = ubi_io_read_ec_hdr(ubi, tmp_aeb->pnum, ech, 0); in ubi_attach_fastmap()
804 ret = scan_pool(ubi, ai, fmpl1->pebs, pool_size, &max_sqnum, in ubi_attach_fastmap()
809 ret = scan_pool(ubi, ai, fmpl2->pebs, wl_pool_size, &max_sqnum, in ubi_attach_fastmap()
826 if (WARN_ON(count_fastmap_pebs(ai) != ubi->peb_count - in ubi_attach_fastmap()
848 int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, in ubi_scan_fastmap() argument
860 mutex_lock(&ubi->fm_mutex); in ubi_scan_fastmap()
861 memset(ubi->fm_buf, 0, ubi->fm_size); in ubi_scan_fastmap()
876 ret = ubi_io_read(ubi, fmsb, fm_anchor, ubi->leb_start, sizeof(*fmsb)); in ubi_scan_fastmap()
903 fm_size = ubi->leb_size * used_blocks; in ubi_scan_fastmap()
904 if (fm_size != ubi->fm_size) { in ubi_scan_fastmap()
906 ubi->fm_size); in ubi_scan_fastmap()
911 ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL); in ubi_scan_fastmap()
917 vh = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL); in ubi_scan_fastmap()
926 if (ubi_io_is_bad(ubi, pnum)) { in ubi_scan_fastmap()
931 ret = ubi_io_read_ec_hdr(ubi, pnum, ech, 0); in ubi_scan_fastmap()
941 if (!ubi->image_seq) in ubi_scan_fastmap()
942 ubi->image_seq = be32_to_cpu(ech->image_seq); in ubi_scan_fastmap()
944 if (be32_to_cpu(ech->image_seq) != ubi->image_seq) { in ubi_scan_fastmap()
949 ret = ubi_io_read_vid_hdr(ubi, pnum, vh, 0); in ubi_scan_fastmap()
979 ret = ubi_io_read(ubi, ubi->fm_buf + (ubi->leb_size * i), pnum, in ubi_scan_fastmap()
980 ubi->leb_start, ubi->leb_size); in ubi_scan_fastmap()
991 fmsb2 = (struct ubi_fm_sb *)(ubi->fm_buf); in ubi_scan_fastmap()
994 crc = crc32(UBI_CRC32_INIT, ubi->fm_buf, fm_size); in ubi_scan_fastmap()
1006 ret = ubi_attach_fastmap(ubi, ai, fm); in ubi_scan_fastmap()
1030 ubi->fm = fm; in ubi_scan_fastmap()
1031 ubi->fm_pool.max_size = ubi->fm->max_pool_size; in ubi_scan_fastmap()
1032 ubi->fm_wl_pool.max_size = ubi->fm->max_wl_pool_size; in ubi_scan_fastmap()
1034 ubi_msg("fastmap pool size: %d", ubi->fm_pool.max_size); in ubi_scan_fastmap()
1035 ubi_msg("fastmap WL pool size: %d", ubi->fm_wl_pool.max_size); in ubi_scan_fastmap()
1036 ubi->fm_disabled = 0; in ubi_scan_fastmap()
1038 ubi_free_vid_hdr(ubi, vh); in ubi_scan_fastmap()
1041 mutex_unlock(&ubi->fm_mutex); in ubi_scan_fastmap()
1047 ubi_free_vid_hdr(ubi, vh); in ubi_scan_fastmap()
1062 static int ubi_write_fastmap(struct ubi_device *ubi, in ubi_write_fastmap() argument
1081 fm_raw = ubi->fm_buf; in ubi_write_fastmap()
1082 memset(ubi->fm_buf, 0, ubi->fm_size); in ubi_write_fastmap()
1084 avhdr = new_fm_vhdr(ubi, UBI_FM_SB_VOLUME_ID); in ubi_write_fastmap()
1090 dvhdr = new_fm_vhdr(ubi, UBI_FM_DATA_VOLUME_ID); in ubi_write_fastmap()
1096 spin_lock(&ubi->volumes_lock); in ubi_write_fastmap()
1097 spin_lock(&ubi->wl_lock); in ubi_write_fastmap()
1101 ubi_assert(fm_pos <= ubi->fm_size); in ubi_write_fastmap()
1105 ubi_assert(fm_pos <= ubi->fm_size); in ubi_write_fastmap()
1123 fmpl1->size = cpu_to_be16(ubi->fm_pool.size); in ubi_write_fastmap()
1124 fmpl1->max_size = cpu_to_be16(ubi->fm_pool.max_size); in ubi_write_fastmap()
1126 for (i = 0; i < ubi->fm_pool.size; i++) in ubi_write_fastmap()
1127 fmpl1->pebs[i] = cpu_to_be32(ubi->fm_pool.pebs[i]); in ubi_write_fastmap()
1132 fmpl2->size = cpu_to_be16(ubi->fm_wl_pool.size); in ubi_write_fastmap()
1133 fmpl2->max_size = cpu_to_be16(ubi->fm_wl_pool.max_size); in ubi_write_fastmap()
1135 for (i = 0; i < ubi->fm_wl_pool.size; i++) in ubi_write_fastmap()
1136 fmpl2->pebs[i] = cpu_to_be32(ubi->fm_wl_pool.pebs[i]); in ubi_write_fastmap()
1138 for (node = rb_first(&ubi->free); node; node = rb_next(node)) { in ubi_write_fastmap()
1147 ubi_assert(fm_pos <= ubi->fm_size); in ubi_write_fastmap()
1151 for (node = rb_first(&ubi->used); node; node = rb_next(node)) { in ubi_write_fastmap()
1160 ubi_assert(fm_pos <= ubi->fm_size); in ubi_write_fastmap()
1164 for (node = rb_first(&ubi->scrub); node; node = rb_next(node)) { in ubi_write_fastmap()
1173 ubi_assert(fm_pos <= ubi->fm_size); in ubi_write_fastmap()
1178 list_for_each_entry(ubi_wrk, &ubi->works, list) { in ubi_write_fastmap()
1190 ubi_assert(fm_pos <= ubi->fm_size); in ubi_write_fastmap()
1196 vol = ubi->volumes[i]; in ubi_write_fastmap()
1205 ubi_assert(fm_pos <= ubi->fm_size); in ubi_write_fastmap()
1219 ubi_assert(fm_pos <= ubi->fm_size); in ubi_write_fastmap()
1228 fmh->bad_peb_count = cpu_to_be32(ubi->bad_peb_count); in ubi_write_fastmap()
1230 avhdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); in ubi_write_fastmap()
1233 spin_unlock(&ubi->wl_lock); in ubi_write_fastmap()
1234 spin_unlock(&ubi->volumes_lock); in ubi_write_fastmap()
1237 ret = ubi_io_write_vid_hdr(ubi, new_fm->e[0]->pnum, avhdr); in ubi_write_fastmap()
1250 ubi->fm_size)); in ubi_write_fastmap()
1253 dvhdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); in ubi_write_fastmap()
1257 ret = ubi_io_write_vid_hdr(ubi, new_fm->e[i]->pnum, dvhdr); in ubi_write_fastmap()
1266 ret = ubi_io_write(ubi, fm_raw + (i * ubi->leb_size), in ubi_write_fastmap()
1267 new_fm->e[i]->pnum, ubi->leb_start, ubi->leb_size); in ubi_write_fastmap()
1276 ubi->fm = new_fm; in ubi_write_fastmap()
1281 ubi_free_vid_hdr(ubi, avhdr); in ubi_write_fastmap()
1282 ubi_free_vid_hdr(ubi, dvhdr); in ubi_write_fastmap()
1294 static int erase_block(struct ubi_device *ubi, int pnum) in erase_block() argument
1300 ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL); in erase_block()
1304 ret = ubi_io_read_ec_hdr(ubi, pnum, ec_hdr, 0); in erase_block()
1312 ret = ubi_io_sync_erase(ubi, pnum, 0); in erase_block()
1324 ret = ubi_io_write_ec_hdr(ubi, pnum, ec_hdr); in erase_block()
1341 static int invalidate_fastmap(struct ubi_device *ubi, in invalidate_fastmap() argument
1347 ret = erase_block(ubi, fm->e[0]->pnum); in invalidate_fastmap()
1351 vh = new_fm_vhdr(ubi, UBI_FM_SB_VOLUME_ID); in invalidate_fastmap()
1358 vh->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); in invalidate_fastmap()
1359 ret = ubi_io_write_vid_hdr(ubi, fm->e[0]->pnum, vh); in invalidate_fastmap()
1362 ubi_wl_put_fm_peb(ubi, fm->e[i], i, fm->to_be_tortured[i]); in invalidate_fastmap()
1374 int ubi_update_fastmap(struct ubi_device *ubi) in ubi_update_fastmap() argument
1380 mutex_lock(&ubi->fm_mutex); in ubi_update_fastmap()
1382 ubi_refill_pools(ubi); in ubi_update_fastmap()
1384 if (ubi->ro_mode || ubi->fm_disabled) { in ubi_update_fastmap()
1385 mutex_unlock(&ubi->fm_mutex); in ubi_update_fastmap()
1389 ret = ubi_ensure_anchor_pebs(ubi); in ubi_update_fastmap()
1391 mutex_unlock(&ubi->fm_mutex); in ubi_update_fastmap()
1397 mutex_unlock(&ubi->fm_mutex); in ubi_update_fastmap()
1401 new_fm->used_blocks = ubi->fm_size / ubi->leb_size; in ubi_update_fastmap()
1410 mutex_unlock(&ubi->fm_mutex); in ubi_update_fastmap()
1415 old_fm = ubi->fm; in ubi_update_fastmap()
1416 ubi->fm = NULL; in ubi_update_fastmap()
1425 spin_lock(&ubi->wl_lock); in ubi_update_fastmap()
1426 tmp_e = ubi_wl_get_fm_peb(ubi, 0); in ubi_update_fastmap()
1427 spin_unlock(&ubi->wl_lock); in ubi_update_fastmap()
1434 ubi_wl_put_fm_peb(ubi, new_fm->e[j], j, 0); in ubi_update_fastmap()
1439 ret = erase_block(ubi, old_fm->e[i]->pnum); in ubi_update_fastmap()
1444 ubi_wl_put_fm_peb(ubi, new_fm->e[j], in ubi_update_fastmap()
1458 ubi_wl_put_fm_peb(ubi, old_fm->e[i], i, in ubi_update_fastmap()
1463 spin_lock(&ubi->wl_lock); in ubi_update_fastmap()
1464 tmp_e = ubi_wl_get_fm_peb(ubi, 1); in ubi_update_fastmap()
1465 spin_unlock(&ubi->wl_lock); in ubi_update_fastmap()
1470 ret = erase_block(ubi, old_fm->e[0]->pnum); in ubi_update_fastmap()
1476 ubi_wl_put_fm_peb(ubi, new_fm->e[i], in ubi_update_fastmap()
1485 ubi_wl_put_fm_peb(ubi, old_fm->e[0], 0, in ubi_update_fastmap()
1497 ubi_wl_put_fm_peb(ubi, new_fm->e[i], i, 0); in ubi_update_fastmap()
1507 down_write(&ubi->work_sem); in ubi_update_fastmap()
1508 down_write(&ubi->fm_sem); in ubi_update_fastmap()
1509 ret = ubi_write_fastmap(ubi, new_fm); in ubi_update_fastmap()
1510 up_write(&ubi->fm_sem); in ubi_update_fastmap()
1511 up_write(&ubi->work_sem); in ubi_update_fastmap()
1517 mutex_unlock(&ubi->fm_mutex); in ubi_update_fastmap()
1528 ret = invalidate_fastmap(ubi, old_fm); in ubi_update_fastmap()