aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/ubi/scan.c27
-rw-r--r--drivers/mtd/ubi/scan.h19
2 files changed, 31 insertions, 15 deletions
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index c4590074410..a20f278d0c6 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -72,16 +72,19 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec,
72{ 72{
73 struct ubi_scan_leb *seb; 73 struct ubi_scan_leb *seb;
74 74
75 if (list == &si->free) 75 if (list == &si->free) {
76 dbg_bld("add to free: PEB %d, EC %d", pnum, ec); 76 dbg_bld("add to free: PEB %d, EC %d", pnum, ec);
77 else if (list == &si->erase) 77 si->free_peb_count += 1;
78 } else if (list == &si->erase) {
78 dbg_bld("add to erase: PEB %d, EC %d", pnum, ec); 79 dbg_bld("add to erase: PEB %d, EC %d", pnum, ec);
79 else if (list == &si->corr) { 80 si->erase_peb_count += 1;
81 } else if (list == &si->corr) {
80 dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); 82 dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec);
81 si->corr_count += 1; 83 si->corr_peb_count += 1;
82 } else if (list == &si->alien) 84 } else if (list == &si->alien) {
83 dbg_bld("add to alien: PEB %d, EC %d", pnum, ec); 85 dbg_bld("add to alien: PEB %d, EC %d", pnum, ec);
84 else 86 si->alien_peb_count += 1;
87 } else
85 BUG(); 88 BUG();
86 89
87 seb = kmalloc(sizeof(struct ubi_scan_leb), GFP_KERNEL); 90 seb = kmalloc(sizeof(struct ubi_scan_leb), GFP_KERNEL);
@@ -517,6 +520,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si,
517 sv->leb_count += 1; 520 sv->leb_count += 1;
518 rb_link_node(&seb->u.rb, parent, p); 521 rb_link_node(&seb->u.rb, parent, p);
519 rb_insert_color(&seb->u.rb, &sv->root); 522 rb_insert_color(&seb->u.rb, &sv->root);
523 si->used_peb_count += 1;
520 return 0; 524 return 0;
521} 525}
522 526
@@ -751,7 +755,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
751 * corrupted. Set %bitflips flag in order to make this PEB be 755 * corrupted. Set %bitflips flag in order to make this PEB be
752 * moved and EC be re-created. 756 * moved and EC be re-created.
753 */ 757 */
754 ec_corr = 1; 758 ec_corr = err;
755 ec = UBI_SCAN_UNKNOWN_EC; 759 ec = UBI_SCAN_UNKNOWN_EC;
756 bitflips = 1; 760 bitflips = 1;
757 } 761 }
@@ -816,6 +820,9 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
816 else if (err == UBI_IO_BAD_HDR_READ || err == UBI_IO_BAD_HDR || 820 else if (err == UBI_IO_BAD_HDR_READ || err == UBI_IO_BAD_HDR ||
817 (err == UBI_IO_PEB_FREE && ec_corr)) { 821 (err == UBI_IO_PEB_FREE && ec_corr)) {
818 /* VID header is corrupted */ 822 /* VID header is corrupted */
823 if (err == UBI_IO_BAD_HDR_READ ||
824 ec_corr == UBI_IO_BAD_HDR_READ)
825 si->read_err_count += 1;
819 err = add_to_list(si, pnum, ec, &si->corr); 826 err = add_to_list(si, pnum, ec, &si->corr);
820 if (err) 827 if (err)
821 return err; 828 return err;
@@ -855,7 +862,6 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
855 err = add_to_list(si, pnum, ec, &si->alien); 862 err = add_to_list(si, pnum, ec, &si->alien);
856 if (err) 863 if (err)
857 return err; 864 return err;
858 si->alien_peb_count += 1;
859 return 0; 865 return 0;
860 866
861 case UBI_COMPAT_REJECT: 867 case UBI_COMPAT_REJECT:
@@ -943,8 +949,9 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
943 * unclean reboots. However, many of them may indicate some problems 949 * unclean reboots. However, many of them may indicate some problems
944 * with the flash HW or driver. Print a warning in this case. 950 * with the flash HW or driver. Print a warning in this case.
945 */ 951 */
946 if (si->corr_count >= 8 || si->corr_count >= ubi->peb_count / 4) { 952 if (si->corr_peb_count >= 8 ||
947 ubi_warn("%d PEBs are corrupted", si->corr_count); 953 si->corr_peb_count >= ubi->peb_count / 4) {
954 ubi_warn("%d PEBs are corrupted", si->corr_peb_count);
948 printk(KERN_WARNING "corrupted PEBs are:"); 955 printk(KERN_WARNING "corrupted PEBs are:");
949 list_for_each_entry(seb, &si->corr, u.list) 956 list_for_each_entry(seb, &si->corr, u.list)
950 printk(KERN_CONT " %d", seb->pnum); 957 printk(KERN_CONT " %d", seb->pnum);
diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h
index ff179ad7ca5..2576a8d1532 100644
--- a/drivers/mtd/ubi/scan.h
+++ b/drivers/mtd/ubi/scan.h
@@ -91,10 +91,16 @@ struct ubi_scan_volume {
91 * @erase: list of physical eraseblocks which have to be erased 91 * @erase: list of physical eraseblocks which have to be erased
92 * @alien: list of physical eraseblocks which should not be used by UBI (e.g., 92 * @alien: list of physical eraseblocks which should not be used by UBI (e.g.,
93 * those belonging to "preserve"-compatible internal volumes) 93 * those belonging to "preserve"-compatible internal volumes)
94 * @used_peb_count: count of used PEBs
95 * @corr_peb_count: count of PEBs in the @corr list
96 * @read_err_count: count of PEBs read with error (%UBI_IO_BAD_HDR_READ was
97 * returned)
98 * @free_peb_count: count of PEBs in the @free list
99 * @erase_peb_count: count of PEBs in the @erase list
100 * @alien_peb_count: count of PEBs in the @alien list
94 * @bad_peb_count: count of bad physical eraseblocks 101 * @bad_peb_count: count of bad physical eraseblocks
95 * @vols_found: number of volumes found during scanning 102 * @vols_found: number of volumes found during scanning
96 * @highest_vol_id: highest volume ID 103 * @highest_vol_id: highest volume ID
97 * @alien_peb_count: count of physical eraseblocks in the @alien list
98 * @is_empty: flag indicating whether the MTD device is empty or not 104 * @is_empty: flag indicating whether the MTD device is empty or not
99 * @min_ec: lowest erase counter value 105 * @min_ec: lowest erase counter value
100 * @max_ec: highest erase counter value 106 * @max_ec: highest erase counter value
@@ -102,7 +108,6 @@ struct ubi_scan_volume {
102 * @mean_ec: mean erase counter value 108 * @mean_ec: mean erase counter value
103 * @ec_sum: a temporary variable used when calculating @mean_ec 109 * @ec_sum: a temporary variable used when calculating @mean_ec
104 * @ec_count: a temporary variable used when calculating @mean_ec 110 * @ec_count: a temporary variable used when calculating @mean_ec
105 * @corr_count: count of corrupted PEBs
106 * 111 *
107 * This data structure contains the result of scanning and may be used by other 112 * This data structure contains the result of scanning and may be used by other
108 * UBI sub-systems to build final UBI data structures, further error-recovery 113 * UBI sub-systems to build final UBI data structures, further error-recovery
@@ -114,10 +119,15 @@ struct ubi_scan_info {
114 struct list_head free; 119 struct list_head free;
115 struct list_head erase; 120 struct list_head erase;
116 struct list_head alien; 121 struct list_head alien;
122 int used_peb_count;
123 int corr_peb_count;
124 int read_err_count;
125 int free_peb_count;
126 int erase_peb_count;
127 int alien_peb_count;
117 int bad_peb_count; 128 int bad_peb_count;
118 int vols_found; 129 int vols_found;
119 int highest_vol_id; 130 int highest_vol_id;
120 int alien_peb_count;
121 int is_empty; 131 int is_empty;
122 int min_ec; 132 int min_ec;
123 int max_ec; 133 int max_ec;
@@ -125,7 +135,6 @@ struct ubi_scan_info {
125 int mean_ec; 135 int mean_ec;
126 uint64_t ec_sum; 136 uint64_t ec_sum;
127 int ec_count; 137 int ec_count;
128 int corr_count;
129}; 138};
130 139
131struct ubi_device; 140struct ubi_device;
@@ -135,7 +144,7 @@ struct ubi_vid_hdr;
135 * ubi_scan_move_to_list - move a PEB from the volume tree to a list. 144 * ubi_scan_move_to_list - move a PEB from the volume tree to a list.
136 * 145 *
137 * @sv: volume scanning information 146 * @sv: volume scanning information
138 * @seb: scanning eraseblock infprmation 147 * @seb: scanning eraseblock information
139 * @list: the list to move to 148 * @list: the list to move to
140 */ 149 */
141static inline void ubi_scan_move_to_list(struct ubi_scan_volume *sv, 150static inline void ubi_scan_move_to_list(struct ubi_scan_volume *sv,