aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@linux.intel.com>2012-04-23 23:59:49 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-20 13:25:58 -0400
commit25886a368d58edd9bb0f63d4417d2f73592b9dba (patch)
tree1d520825e52db0ca220738ca0704f5318b3814c7
parent56b04e3e8b5cbf71c23a739f34f9a9437afa41fb (diff)
UBI: always dump the stack on error
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. This patch weeds out the 'ubi_dbg_dump_stack()' function and turns it into 'dump_stack()' - it is always useful to have stack dump in case of an error. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
-rw-r--r--drivers/mtd/ubi/debug.h5
-rw-r--r--drivers/mtd/ubi/io.c28
-rw-r--r--drivers/mtd/ubi/scan.c2
-rw-r--r--drivers/mtd/ubi/ubi.h2
-rw-r--r--drivers/mtd/ubi/wl.c6
5 files changed, 20 insertions, 23 deletions
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index ead2cd16ba75..aff6499cde47 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -28,14 +28,12 @@
28 if (unlikely(!(expr))) { \ 28 if (unlikely(!(expr))) { \
29 printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \ 29 printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \
30 __func__, __LINE__, current->pid); \ 30 __func__, __LINE__, current->pid); \
31 ubi_dbg_dump_stack(); \ 31 dump_stack(); \
32 } \ 32 } \
33} while (0) 33} while (0)
34 34
35#define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__) 35#define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__)
36 36
37#define ubi_dbg_dump_stack() dump_stack()
38
39#define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \ 37#define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \
40 print_hex_dump(l, ps, pt, r, g, b, len, a) 38 print_hex_dump(l, ps, pt, r, g, b, len, a)
41 39
@@ -194,7 +192,6 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
194#define dbg_io(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) 192#define dbg_io(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
195#define dbg_bld(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) 193#define dbg_bld(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__)
196 194
197static inline void ubi_dbg_dump_stack(void) { return; }
198static inline void 195static inline void
199ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) { return; } 196ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr) { return; }
200static inline void 197static inline void
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 43f1a0011a55..507e0c6113c3 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -198,7 +198,7 @@ retry:
198 198
199 ubi_err("error %d%s while reading %d bytes from PEB %d:%d, " 199 ubi_err("error %d%s while reading %d bytes from PEB %d:%d, "
200 "read %zd bytes", err, errstr, len, pnum, offset, read); 200 "read %zd bytes", err, errstr, len, pnum, offset, read);
201 ubi_dbg_dump_stack(); 201 dump_stack();
202 202
203 /* 203 /*
204 * The driver should never return -EBADMSG if it failed to read 204 * The driver should never return -EBADMSG if it failed to read
@@ -284,7 +284,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
284 if (ubi_dbg_is_write_failure(ubi)) { 284 if (ubi_dbg_is_write_failure(ubi)) {
285 dbg_err("cannot write %d bytes to PEB %d:%d " 285 dbg_err("cannot write %d bytes to PEB %d:%d "
286 "(emulated)", len, pnum, offset); 286 "(emulated)", len, pnum, offset);
287 ubi_dbg_dump_stack(); 287 dump_stack();
288 return -EIO; 288 return -EIO;
289 } 289 }
290 290
@@ -293,7 +293,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
293 if (err) { 293 if (err) {
294 ubi_err("error %d while writing %d bytes to PEB %d:%d, written " 294 ubi_err("error %d while writing %d bytes to PEB %d:%d, written "
295 "%zd bytes", err, len, pnum, offset, written); 295 "%zd bytes", err, len, pnum, offset, written);
296 ubi_dbg_dump_stack(); 296 dump_stack();
297 ubi_dbg_dump_flash(ubi, pnum, offset, len); 297 ubi_dbg_dump_flash(ubi, pnum, offset, len);
298 } else 298 } else
299 ubi_assert(written == len); 299 ubi_assert(written == len);
@@ -370,7 +370,7 @@ retry:
370 goto retry; 370 goto retry;
371 } 371 }
372 ubi_err("cannot erase PEB %d, error %d", pnum, err); 372 ubi_err("cannot erase PEB %d, error %d", pnum, err);
373 ubi_dbg_dump_stack(); 373 dump_stack();
374 return err; 374 return err;
375 } 375 }
376 376
@@ -388,7 +388,7 @@ retry:
388 goto retry; 388 goto retry;
389 } 389 }
390 ubi_err("cannot erase PEB %d", pnum); 390 ubi_err("cannot erase PEB %d", pnum);
391 ubi_dbg_dump_stack(); 391 dump_stack();
392 return -EIO; 392 return -EIO;
393 } 393 }
394 394
@@ -722,7 +722,7 @@ static int validate_ec_hdr(const struct ubi_device *ubi,
722bad: 722bad:
723 ubi_err("bad EC header"); 723 ubi_err("bad EC header");
724 ubi_dbg_dump_ec_hdr(ec_hdr); 724 ubi_dbg_dump_ec_hdr(ec_hdr);
725 ubi_dbg_dump_stack(); 725 dump_stack();
726 return 1; 726 return 1;
727} 727}
728 728
@@ -998,7 +998,7 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
998bad: 998bad:
999 ubi_err("bad VID header"); 999 ubi_err("bad VID header");
1000 ubi_dbg_dump_vid_hdr(vid_hdr); 1000 ubi_dbg_dump_vid_hdr(vid_hdr);
1001 ubi_dbg_dump_stack(); 1001 dump_stack();
1002 return 1; 1002 return 1;
1003} 1003}
1004 1004
@@ -1153,7 +1153,7 @@ static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)
1153 return err; 1153 return err;
1154 1154
1155 ubi_err("paranoid check failed for PEB %d", pnum); 1155 ubi_err("paranoid check failed for PEB %d", pnum);
1156 ubi_dbg_dump_stack(); 1156 dump_stack();
1157 return err > 0 ? -EINVAL : err; 1157 return err > 0 ? -EINVAL : err;
1158} 1158}
1159 1159
@@ -1192,7 +1192,7 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
1192 1192
1193fail: 1193fail:
1194 ubi_dbg_dump_ec_hdr(ec_hdr); 1194 ubi_dbg_dump_ec_hdr(ec_hdr);
1195 ubi_dbg_dump_stack(); 1195 dump_stack();
1196 return -EINVAL; 1196 return -EINVAL;
1197} 1197}
1198 1198
@@ -1227,7 +1227,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
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_dbg_dump_ec_hdr(ec_hdr);
1230 ubi_dbg_dump_stack(); 1230 dump_stack();
1231 err = -EINVAL; 1231 err = -EINVAL;
1232 goto exit; 1232 goto exit;
1233 } 1233 }
@@ -1275,7 +1275,7 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
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_dbg_dump_vid_hdr(vid_hdr);
1278 ubi_dbg_dump_stack(); 1278 dump_stack();
1279 return -EINVAL; 1279 return -EINVAL;
1280 1280
1281} 1281}
@@ -1315,7 +1315,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
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_dbg_dump_vid_hdr(vid_hdr);
1318 ubi_dbg_dump_stack(); 1318 dump_stack();
1319 err = -EINVAL; 1319 err = -EINVAL;
1320 goto exit; 1320 goto exit;
1321 } 1321 }
@@ -1380,7 +1380,7 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum,
1380 i, i + dump_len); 1380 i, i + dump_len);
1381 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, 1381 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
1382 buf1 + i, dump_len, 1); 1382 buf1 + i, dump_len, 1);
1383 ubi_dbg_dump_stack(); 1383 dump_stack();
1384 err = -EINVAL; 1384 err = -EINVAL;
1385 goto out_free; 1385 goto out_free;
1386 } 1386 }
@@ -1443,7 +1443,7 @@ fail:
1443 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1); 1443 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1);
1444 err = -EINVAL; 1444 err = -EINVAL;
1445error: 1445error:
1446 ubi_dbg_dump_stack(); 1446 dump_stack();
1447 vfree(buf); 1447 vfree(buf);
1448 return err; 1448 return err;
1449} 1449}
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 12c43b44f815..75c23a9bb6c3 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -1598,7 +1598,7 @@ bad_vid_hdr:
1598 ubi_dbg_dump_vid_hdr(vidh); 1598 ubi_dbg_dump_vid_hdr(vidh);
1599 1599
1600out: 1600out:
1601 ubi_dbg_dump_stack(); 1601 dump_stack();
1602 return -EINVAL; 1602 return -EINVAL;
1603} 1603}
1604 1604
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index b162790790a9..4f5c9f136519 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -667,7 +667,7 @@ static inline void ubi_ro_mode(struct ubi_device *ubi)
667 if (!ubi->ro_mode) { 667 if (!ubi->ro_mode) {
668 ubi->ro_mode = 1; 668 ubi->ro_mode = 1;
669 ubi_warn("switch to read-only mode"); 669 ubi_warn("switch to read-only mode");
670 ubi_dbg_dump_stack(); 670 dump_stack();
671 } 671 }
672} 672}
673 673
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 7c1a9bf8ac86..b0a6d53ef047 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1603,7 +1603,7 @@ static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec)
1603 if (ec != read_ec) { 1603 if (ec != read_ec) {
1604 ubi_err("paranoid check failed for PEB %d", pnum); 1604 ubi_err("paranoid check failed for PEB %d", pnum);
1605 ubi_err("read EC is %lld, should be %d", read_ec, ec); 1605 ubi_err("read EC is %lld, should be %d", read_ec, ec);
1606 ubi_dbg_dump_stack(); 1606 dump_stack();
1607 err = 1; 1607 err = 1;
1608 } else 1608 } else
1609 err = 0; 1609 err = 0;
@@ -1634,7 +1634,7 @@ static int paranoid_check_in_wl_tree(const struct ubi_device *ubi,
1634 1634
1635 ubi_err("paranoid check failed for PEB %d, EC %d, RB-tree %p ", 1635 ubi_err("paranoid check failed for PEB %d, EC %d, RB-tree %p ",
1636 e->pnum, e->ec, root); 1636 e->pnum, e->ec, root);
1637 ubi_dbg_dump_stack(); 1637 dump_stack();
1638 return -EINVAL; 1638 return -EINVAL;
1639} 1639}
1640 1640
@@ -1662,7 +1662,7 @@ static int paranoid_check_in_pq(const struct ubi_device *ubi,
1662 1662
1663 ubi_err("paranoid check failed for PEB %d, EC %d, Protect queue", 1663 ubi_err("paranoid check failed for PEB %d, EC %d, Protect queue",
1664 e->pnum, e->ec); 1664 e->pnum, e->ec);
1665 ubi_dbg_dump_stack(); 1665 dump_stack();
1666 return -EINVAL; 1666 return -EINVAL;
1667} 1667}
1668 1668