aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-04-25 02:02:44 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-20 13:25:58 -0400
commita904e3f1deb21b986b7789a830fa8f132ff3d406 (patch)
tree6850b21416600cab1c28a9b531035e70a1132aca
parentef7088e7f84ba550b276bc4a74f2732ee5618fb8 (diff)
UBI: always dump VID and EC headers in case of errors
UBI (and UBIFS) are a bit over-engineered WRT debugging. The idea was to link as few as possible when debugging is disabled, but the downside is that most people produce bug reports which are difficult to understand. Always dump the VID and EC headers' contents in case of errors when it is helpful. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rw-r--r--drivers/mtd/ubi/debug.c12
-rw-r--r--drivers/mtd/ubi/debug.h8
-rw-r--r--drivers/mtd/ubi/io.c20
-rw-r--r--drivers/mtd/ubi/scan.c12
4 files changed, 24 insertions, 28 deletions
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 30aa9c440834..dce463d3c586 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -56,13 +56,11 @@ out:
56 return; 56 return;
57} 57}
58 58
59#ifdef CONFIG_MTD_UBI_DEBUG
60
61/** 59/**
62 * ubi_dbg_dump_ec_hdr - dump an erase counter header. 60 * ubi_dump_ec_hdr - dump an erase counter header.
63 * @ec_hdr: the erase counter header to dump 61 * @ec_hdr: the erase counter header to dump
64 */ 62 */
65void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) 63void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr)
66{ 64{
67 printk(KERN_DEBUG "Erase counter header dump:\n"); 65 printk(KERN_DEBUG "Erase counter header dump:\n");
68 printk(KERN_DEBUG "\tmagic %#08x\n", 66 printk(KERN_DEBUG "\tmagic %#08x\n",
@@ -84,10 +82,10 @@ void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr)
84} 82}
85 83
86/** 84/**
87 * ubi_dbg_dump_vid_hdr - dump a volume identifier header. 85 * ubi_dump_vid_hdr - dump a volume identifier header.
88 * @vid_hdr: the volume identifier header to dump 86 * @vid_hdr: the volume identifier header to dump
89 */ 87 */
90void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr) 88void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr)
91{ 89{
92 printk(KERN_DEBUG "Volume identifier header dump:\n"); 90 printk(KERN_DEBUG "Volume identifier header dump:\n");
93 printk(KERN_DEBUG "\tmagic %08x\n", be32_to_cpu(vid_hdr->magic)); 91 printk(KERN_DEBUG "\tmagic %08x\n", be32_to_cpu(vid_hdr->magic));
@@ -108,6 +106,8 @@ void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr)
108 vid_hdr, UBI_VID_HDR_SIZE, 1); 106 vid_hdr, UBI_VID_HDR_SIZE, 1);
109} 107}
110 108
109#ifdef CONFIG_MTD_UBI_DEBUG
110
111/** 111/**
112 * ubi_dbg_dump_vol_info- dump volume information. 112 * ubi_dbg_dump_vol_info- dump volume information.
113 * @vol: UBI volume description object 113 * @vol: UBI volume description object
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index 4bce78dc5226..b8672c947bb5 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -22,6 +22,8 @@
22#define __UBI_DEBUG_H__ 22#define __UBI_DEBUG_H__
23 23
24void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len); 24void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);
25void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
26void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
25 27
26#ifdef CONFIG_MTD_UBI_DEBUG 28#ifdef CONFIG_MTD_UBI_DEBUG
27#include <linux/random.h> 29#include <linux/random.h>
@@ -58,8 +60,6 @@ void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);
58/* Initialization and build messages */ 60/* Initialization and build messages */
59#define dbg_bld(fmt, ...) ubi_dbg_msg("bld", fmt, ##__VA_ARGS__) 61#define dbg_bld(fmt, ...) ubi_dbg_msg("bld", fmt, ##__VA_ARGS__)
60 62
61void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
62void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
63void ubi_dbg_dump_vol_info(const struct ubi_volume *vol); 63void ubi_dbg_dump_vol_info(const struct ubi_volume *vol);
64void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); 64void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx);
65void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv); 65void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv);
@@ -194,10 +194,6 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
194#define dbg_bld(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) 194#define dbg_bld(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
195 195
196static inline void 196static inline void
197ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) { return; }
198static inline void
199ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr) { return; }
200static inline void
201ubi_dbg_dump_vol_info(const struct ubi_volume *vol) { return; } 197ubi_dbg_dump_vol_info(const struct ubi_volume *vol) { return; }
202static inline void 198static inline void
203ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) { return; } 199ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) { return; }
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 9658ac80890c..a3225c212feb 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -721,7 +721,7 @@ static int validate_ec_hdr(const struct ubi_device *ubi,
721 721
722bad: 722bad:
723 ubi_err("bad EC header"); 723 ubi_err("bad EC header");
724 ubi_dbg_dump_ec_hdr(ec_hdr); 724 ubi_dump_ec_hdr(ec_hdr);
725 dump_stack(); 725 dump_stack();
726 return 1; 726 return 1;
727} 727}
@@ -803,7 +803,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
803 if (verbose) { 803 if (verbose) {
804 ubi_warn("bad magic number at PEB %d: %08x instead of " 804 ubi_warn("bad magic number at PEB %d: %08x instead of "
805 "%08x", pnum, magic, UBI_EC_HDR_MAGIC); 805 "%08x", pnum, magic, UBI_EC_HDR_MAGIC);
806 ubi_dbg_dump_ec_hdr(ec_hdr); 806 ubi_dump_ec_hdr(ec_hdr);
807 } 807 }
808 dbg_bld("bad magic number at PEB %d: %08x instead of " 808 dbg_bld("bad magic number at PEB %d: %08x instead of "
809 "%08x", pnum, magic, UBI_EC_HDR_MAGIC); 809 "%08x", pnum, magic, UBI_EC_HDR_MAGIC);
@@ -817,7 +817,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
817 if (verbose) { 817 if (verbose) {
818 ubi_warn("bad EC header CRC at PEB %d, calculated " 818 ubi_warn("bad EC header CRC at PEB %d, calculated "
819 "%#08x, read %#08x", pnum, crc, hdr_crc); 819 "%#08x, read %#08x", pnum, crc, hdr_crc);
820 ubi_dbg_dump_ec_hdr(ec_hdr); 820 ubi_dump_ec_hdr(ec_hdr);
821 } 821 }
822 dbg_bld("bad EC header CRC at PEB %d, calculated " 822 dbg_bld("bad EC header CRC at PEB %d, calculated "
823 "%#08x, read %#08x", pnum, crc, hdr_crc); 823 "%#08x, read %#08x", pnum, crc, hdr_crc);
@@ -997,7 +997,7 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
997 997
998bad: 998bad:
999 ubi_err("bad VID header"); 999 ubi_err("bad VID header");
1000 ubi_dbg_dump_vid_hdr(vid_hdr); 1000 ubi_dump_vid_hdr(vid_hdr);
1001 dump_stack(); 1001 dump_stack();
1002 return 1; 1002 return 1;
1003} 1003}
@@ -1054,7 +1054,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
1054 if (verbose) { 1054 if (verbose) {
1055 ubi_warn("bad magic number at PEB %d: %08x instead of " 1055 ubi_warn("bad magic number at PEB %d: %08x instead of "
1056 "%08x", pnum, magic, UBI_VID_HDR_MAGIC); 1056 "%08x", pnum, magic, UBI_VID_HDR_MAGIC);
1057 ubi_dbg_dump_vid_hdr(vid_hdr); 1057 ubi_dump_vid_hdr(vid_hdr);
1058 } 1058 }
1059 dbg_bld("bad magic number at PEB %d: %08x instead of " 1059 dbg_bld("bad magic number at PEB %d: %08x instead of "
1060 "%08x", pnum, magic, UBI_VID_HDR_MAGIC); 1060 "%08x", pnum, magic, UBI_VID_HDR_MAGIC);
@@ -1068,7 +1068,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
1068 if (verbose) { 1068 if (verbose) {
1069 ubi_warn("bad CRC at PEB %d, calculated %#08x, " 1069 ubi_warn("bad CRC at PEB %d, calculated %#08x, "
1070 "read %#08x", pnum, crc, hdr_crc); 1070 "read %#08x", pnum, crc, hdr_crc);
1071 ubi_dbg_dump_vid_hdr(vid_hdr); 1071 ubi_dump_vid_hdr(vid_hdr);
1072 } 1072 }
1073 dbg_bld("bad CRC at PEB %d, calculated %#08x, " 1073 dbg_bld("bad CRC at PEB %d, calculated %#08x, "
1074 "read %#08x", pnum, crc, hdr_crc); 1074 "read %#08x", pnum, crc, hdr_crc);
@@ -1191,7 +1191,7 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
1191 return 0; 1191 return 0;
1192 1192
1193fail: 1193fail:
1194 ubi_dbg_dump_ec_hdr(ec_hdr); 1194 ubi_dump_ec_hdr(ec_hdr);
1195 dump_stack(); 1195 dump_stack();
1196 return -EINVAL; 1196 return -EINVAL;
1197} 1197}
@@ -1226,7 +1226,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
1226 if (hdr_crc != crc) { 1226 if (hdr_crc != crc) {
1227 ubi_err("bad CRC, calculated %#08x, read %#08x", crc, hdr_crc); 1227 ubi_err("bad CRC, calculated %#08x, read %#08x", crc, hdr_crc);
1228 ubi_err("paranoid check failed for PEB %d", pnum); 1228 ubi_err("paranoid check failed for PEB %d", pnum);
1229 ubi_dbg_dump_ec_hdr(ec_hdr); 1229 ubi_dump_ec_hdr(ec_hdr);
1230 dump_stack(); 1230 dump_stack();
1231 err = -EINVAL; 1231 err = -EINVAL;
1232 goto exit; 1232 goto exit;
@@ -1274,7 +1274,7 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
1274 1274
1275fail: 1275fail:
1276 ubi_err("paranoid check failed for PEB %d", pnum); 1276 ubi_err("paranoid check failed for PEB %d", pnum);
1277 ubi_dbg_dump_vid_hdr(vid_hdr); 1277 ubi_dump_vid_hdr(vid_hdr);
1278 dump_stack(); 1278 dump_stack();
1279 return -EINVAL; 1279 return -EINVAL;
1280 1280
@@ -1314,7 +1314,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
1314 ubi_err("bad VID header CRC at PEB %d, calculated %#08x, " 1314 ubi_err("bad VID header CRC at PEB %d, calculated %#08x, "
1315 "read %#08x", pnum, crc, hdr_crc); 1315 "read %#08x", pnum, crc, hdr_crc);
1316 ubi_err("paranoid check failed for PEB %d", pnum); 1316 ubi_err("paranoid check failed for PEB %d", pnum);
1317 ubi_dbg_dump_vid_hdr(vid_hdr); 1317 ubi_dump_vid_hdr(vid_hdr);
1318 dump_stack(); 1318 dump_stack();
1319 err = -EINVAL; 1319 err = -EINVAL;
1320 goto exit; 1320 goto exit;
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 75c23a9bb6c3..47d244db5302 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -230,7 +230,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
230 230
231bad: 231bad:
232 ubi_err("inconsistent VID header at PEB %d", pnum); 232 ubi_err("inconsistent VID header at PEB %d", pnum);
233 ubi_dbg_dump_vid_hdr(vid_hdr); 233 ubi_dump_vid_hdr(vid_hdr);
234 ubi_dbg_dump_sv(sv); 234 ubi_dbg_dump_sv(sv);
235 return -EINVAL; 235 return -EINVAL;
236} 236}
@@ -511,7 +511,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si,
511 ubi_err("two LEBs with same sequence number %llu", 511 ubi_err("two LEBs with same sequence number %llu",
512 sqnum); 512 sqnum);
513 ubi_dbg_dump_seb(seb, 0); 513 ubi_dbg_dump_seb(seb, 0);
514 ubi_dbg_dump_vid_hdr(vid_hdr); 514 ubi_dump_vid_hdr(vid_hdr);
515 return -EINVAL; 515 return -EINVAL;
516 } 516 }
517 517
@@ -814,7 +814,7 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr,
814 ubi_err("PEB %d contains corrupted VID header, and the data does not " 814 ubi_err("PEB %d contains corrupted VID header, and the data does not "
815 "contain all 0xFF, this may be a non-UBI PEB or a severe VID " 815 "contain all 0xFF, this may be a non-UBI PEB or a severe VID "
816 "header corruption which requires manual inspection", pnum); 816 "header corruption which requires manual inspection", pnum);
817 ubi_dbg_dump_vid_hdr(vid_hdr); 817 ubi_dump_vid_hdr(vid_hdr);
818 dbg_msg("hexdump of PEB %d offset %d, length %d", 818 dbg_msg("hexdump of PEB %d offset %d, length %d",
819 pnum, ubi->leb_start, ubi->leb_size); 819 pnum, ubi->leb_start, ubi->leb_size);
820 ubi_dbg_print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, 820 ubi_dbg_print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
@@ -911,7 +911,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
911 */ 911 */
912 ubi_err("erase counter overflow, max is %d", 912 ubi_err("erase counter overflow, max is %d",
913 UBI_MAX_ERASECOUNTER); 913 UBI_MAX_ERASECOUNTER);
914 ubi_dbg_dump_ec_hdr(ech); 914 ubi_dump_ec_hdr(ech);
915 return -EINVAL; 915 return -EINVAL;
916 } 916 }
917 917
@@ -933,7 +933,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
933 ubi->image_seq != image_seq) { 933 ubi->image_seq != image_seq) {
934 ubi_err("bad image sequence number %d in PEB %d, " 934 ubi_err("bad image sequence number %d in PEB %d, "
935 "expected %d", image_seq, pnum, ubi->image_seq); 935 "expected %d", image_seq, pnum, ubi->image_seq);
936 ubi_dbg_dump_ec_hdr(ech); 936 ubi_dump_ec_hdr(ech);
937 return -EINVAL; 937 return -EINVAL;
938 } 938 }
939 } 939 }
@@ -1595,7 +1595,7 @@ bad_sv:
1595bad_vid_hdr: 1595bad_vid_hdr:
1596 ubi_err("bad scanning information about volume %d", sv->vol_id); 1596 ubi_err("bad scanning information about volume %d", sv->vol_id);
1597 ubi_dbg_dump_sv(sv); 1597 ubi_dbg_dump_sv(sv);
1598 ubi_dbg_dump_vid_hdr(vidh); 1598 ubi_dump_vid_hdr(vidh);
1599 1599
1600out: 1600out:
1601 dump_stack(); 1601 dump_stack();