aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/io.c')
-rw-r--r--drivers/mtd/ubi/io.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 4ac11df7b048..2fb64be44f1b 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -20,15 +20,15 @@
20 */ 20 */
21 21
22/* 22/*
23 * UBI input/output unit. 23 * UBI input/output sub-system.
24 * 24 *
25 * This unit provides a uniform way to work with all kinds of the underlying 25 * This sub-system provides a uniform way to work with all kinds of the
26 * MTD devices. It also implements handy functions for reading and writing UBI 26 * underlying MTD devices. It also implements handy functions for reading and
27 * headers. 27 * writing UBI headers.
28 * 28 *
29 * We are trying to have a paranoid mindset and not to trust to what we read 29 * We are trying to have a paranoid mindset and not to trust to what we read
30 * from the flash media in order to be more secure and robust. So this unit 30 * from the flash media in order to be more secure and robust. So this
31 * validates every single header it reads from the flash media. 31 * sub-system validates every single header it reads from the flash media.
32 * 32 *
33 * Some words about how the eraseblock headers are stored. 33 * Some words about how the eraseblock headers are stored.
34 * 34 *
@@ -79,11 +79,11 @@
79 * 512-byte chunks, we have to allocate one more buffer and copy our VID header 79 * 512-byte chunks, we have to allocate one more buffer and copy our VID header
80 * to offset 448 of this buffer. 80 * to offset 448 of this buffer.
81 * 81 *
82 * The I/O unit does the following trick in order to avoid this extra copy. 82 * The I/O sub-system does the following trick in order to avoid this extra
83 * It always allocates a @ubi->vid_hdr_alsize bytes buffer for the VID header 83 * copy. It always allocates a @ubi->vid_hdr_alsize bytes buffer for the VID
84 * and returns a pointer to offset @ubi->vid_hdr_shift of this buffer. When the 84 * header and returns a pointer to offset @ubi->vid_hdr_shift of this buffer.
85 * VID header is being written out, it shifts the VID header pointer back and 85 * When the VID header is being written out, it shifts the VID header pointer
86 * writes the whole sub-page. 86 * back and writes the whole sub-page.
87 */ 87 */
88 88
89#include <linux/crc32.h> 89#include <linux/crc32.h>
@@ -156,15 +156,19 @@ retry:
156 /* 156 /*
157 * -EUCLEAN is reported if there was a bit-flip which 157 * -EUCLEAN is reported if there was a bit-flip which
158 * was corrected, so this is harmless. 158 * was corrected, so this is harmless.
159 *
160 * We do not report about it here unless debugging is
161 * enabled. A corresponding message will be printed
162 * later, when it is has been scrubbed.
159 */ 163 */
160 ubi_msg("fixable bit-flip detected at PEB %d", pnum); 164 dbg_msg("fixable bit-flip detected at PEB %d", pnum);
161 ubi_assert(len == read); 165 ubi_assert(len == read);
162 return UBI_IO_BITFLIPS; 166 return UBI_IO_BITFLIPS;
163 } 167 }
164 168
165 if (read != len && retries++ < UBI_IO_RETRIES) { 169 if (read != len && retries++ < UBI_IO_RETRIES) {
166 dbg_io("error %d while reading %d bytes from PEB %d:%d, " 170 dbg_io("error %d while reading %d bytes from PEB %d:%d,"
167 "read only %zd bytes, retry", 171 " read only %zd bytes, retry",
168 err, len, pnum, offset, read); 172 err, len, pnum, offset, read);
169 yield(); 173 yield();
170 goto retry; 174 goto retry;
@@ -187,7 +191,7 @@ retry:
187 ubi_assert(len == read); 191 ubi_assert(len == read);
188 192
189 if (ubi_dbg_is_bitflip()) { 193 if (ubi_dbg_is_bitflip()) {
190 dbg_msg("bit-flip (emulated)"); 194 dbg_gen("bit-flip (emulated)");
191 err = UBI_IO_BITFLIPS; 195 err = UBI_IO_BITFLIPS;
192 } 196 }
193 } 197 }
@@ -391,6 +395,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
391{ 395{
392 int err, i, patt_count; 396 int err, i, patt_count;
393 397
398 ubi_msg("run torture test for PEB %d", pnum);
394 patt_count = ARRAY_SIZE(patterns); 399 patt_count = ARRAY_SIZE(patterns);
395 ubi_assert(patt_count > 0); 400 ubi_assert(patt_count > 0);
396 401
@@ -434,6 +439,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
434 } 439 }
435 440
436 err = patt_count; 441 err = patt_count;
442 ubi_msg("PEB %d passed torture test, do not mark it a bad", pnum);
437 443
438out: 444out:
439 mutex_unlock(&ubi->buf_mutex); 445 mutex_unlock(&ubi->buf_mutex);
@@ -699,8 +705,8 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
699 705
700 if (hdr_crc != crc) { 706 if (hdr_crc != crc) {
701 if (verbose) { 707 if (verbose) {
702 ubi_warn("bad EC header CRC at PEB %d, calculated %#08x," 708 ubi_warn("bad EC header CRC at PEB %d, calculated "
703 " read %#08x", pnum, crc, hdr_crc); 709 "%#08x, read %#08x", pnum, crc, hdr_crc);
704 ubi_dbg_dump_ec_hdr(ec_hdr); 710 ubi_dbg_dump_ec_hdr(ec_hdr);
705 } 711 }
706 return UBI_IO_BAD_EC_HDR; 712 return UBI_IO_BAD_EC_HDR;
@@ -1095,8 +1101,7 @@ fail:
1095} 1101}
1096 1102
1097/** 1103/**
1098 * paranoid_check_peb_ec_hdr - check that the erase counter header of a 1104 * paranoid_check_peb_ec_hdr - check erase counter header.
1099 * physical eraseblock is in-place and is all right.
1100 * @ubi: UBI device description object 1105 * @ubi: UBI device description object
1101 * @pnum: the physical eraseblock number to check 1106 * @pnum: the physical eraseblock number to check
1102 * 1107 *
@@ -1174,8 +1179,7 @@ fail:
1174} 1179}
1175 1180
1176/** 1181/**
1177 * paranoid_check_peb_vid_hdr - check that the volume identifier header of a 1182 * paranoid_check_peb_vid_hdr - check volume identifier header.
1178 * physical eraseblock is in-place and is all right.
1179 * @ubi: UBI device description object 1183 * @ubi: UBI device description object
1180 * @pnum: the physical eraseblock number to check 1184 * @pnum: the physical eraseblock number to check
1181 * 1185 *
@@ -1256,7 +1260,7 @@ static int paranoid_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
1256 1260
1257fail: 1261fail:
1258 ubi_err("paranoid check failed for PEB %d", pnum); 1262 ubi_err("paranoid check failed for PEB %d", pnum);
1259 dbg_msg("hex dump of the %d-%d region", offset, offset + len); 1263 ubi_msg("hex dump of the %d-%d region", offset, offset + len);
1260 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, 1264 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
1261 ubi->dbg_peb_buf, len, 1); 1265 ubi->dbg_peb_buf, len, 1);
1262 err = 1; 1266 err = 1;