diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-07-19 07:33:14 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-08-14 13:01:36 -0400 |
commit | 4a406856ea6830d8b8dba6a27d9f9331c5f4c13a (patch) | |
tree | 9bca90ac072a68eb762f985d62c512c55ba6dadc /drivers/mtd/ubi/scan.c | |
parent | 5b289b562f6d236108569a880cb38cc03d17a50d (diff) |
UBI: print a warning if too many PEBs are corrupted
There was a bug report recently where UBI prints:
UBI error: ubi_attach_mtd_dev: failed to attach by scanning, error -22
error messages and refuses to attach a PEB. It turned out to be a
buggy flash driver which returned garbage to almost every UBI read.
This patch makes UBI print a better message in such cases. Namely,
if UBI finds 8 or more corrupted PEBs, it prints a warning and
lists the corrupted PEBs.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/scan.c')
-rw-r--r-- | drivers/mtd/ubi/scan.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 93361eadab8d..e7161adc419d 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c | |||
@@ -75,9 +75,10 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, | |||
75 | dbg_bld("add to free: PEB %d, EC %d", pnum, ec); | 75 | dbg_bld("add to free: PEB %d, EC %d", pnum, ec); |
76 | else if (list == &si->erase) | 76 | else if (list == &si->erase) |
77 | dbg_bld("add to erase: PEB %d, EC %d", pnum, ec); | 77 | dbg_bld("add to erase: PEB %d, EC %d", pnum, ec); |
78 | else if (list == &si->corr) | 78 | else if (list == &si->corr) { |
79 | dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); | 79 | dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); |
80 | else if (list == &si->alien) | 80 | si->corr_count += 1; |
81 | } else if (list == &si->alien) | ||
81 | dbg_bld("add to alien: PEB %d, EC %d", pnum, ec); | 82 | dbg_bld("add to alien: PEB %d, EC %d", pnum, ec); |
82 | else | 83 | else |
83 | BUG(); | 84 | BUG(); |
@@ -938,6 +939,19 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi) | |||
938 | ubi_msg("empty MTD device detected"); | 939 | ubi_msg("empty MTD device detected"); |
939 | 940 | ||
940 | /* | 941 | /* |
942 | * Few corrupted PEBs are not a problem and may be just a result of | ||
943 | * unclean reboots. However, many of them may indicate some problems | ||
944 | * with the flash HW or driver. Print a warning in this case. | ||
945 | */ | ||
946 | if (si->corr_count >= 8 || si->corr_count >= ubi->peb_count / 4) { | ||
947 | ubi_warn("%d PEBs are corrupted", si->corr_count); | ||
948 | printk(KERN_WARNING "corrupted PEBs are:"); | ||
949 | list_for_each_entry(seb, &si->corr, u.list) | ||
950 | printk(KERN_CONT " %d", seb->pnum); | ||
951 | printk(KERN_CONT "\n"); | ||
952 | } | ||
953 | |||
954 | /* | ||
941 | * In case of unknown erase counter we use the mean erase counter | 955 | * In case of unknown erase counter we use the mean erase counter |
942 | * value. | 956 | * value. |
943 | */ | 957 | */ |