diff options
author | Roger Quadros <rogerq@ti.com> | 2014-12-05 10:18:39 -0500 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2015-04-05 21:10:23 -0400 |
commit | d2b51c808745ca93c020ba34a3cf256ad52adc63 (patch) | |
tree | 6dde6542d2de918e83a23df020c2b37e9b06074b | |
parent | 45fd357a491ecc56c0f9bb110bd05d9caf28889f (diff) |
mtd: mtd_oobtest: Fix bitflip_limit usage in test case 3
In test case 3, we set vary_offset to write at different
offsets and lengths in the OOB available area. We need to
do the bitflip_limit check while checking for 0xff outside the
OOB offset + length area that we didn't modify during write.
Signed-off-by: Roger Quadros <rogerq@ti.com>
[Brian: whitespace fixup]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r-- | drivers/mtd/tests/oobtest.c | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c index 64390ab88a80..c6b35644a10f 100644 --- a/drivers/mtd/tests/oobtest.c +++ b/drivers/mtd/tests/oobtest.c | |||
@@ -141,6 +141,31 @@ static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t cou | |||
141 | return bitflips; | 141 | return bitflips; |
142 | } | 142 | } |
143 | 143 | ||
144 | /* | ||
145 | * Compare with 0xff and show the address, offset and data bytes at | ||
146 | * comparison failure. Return number of bitflips encountered. | ||
147 | */ | ||
148 | static size_t memffshow(loff_t addr, loff_t offset, const void *cs, | ||
149 | size_t count) | ||
150 | { | ||
151 | const unsigned char *su1; | ||
152 | int res; | ||
153 | size_t i = 0; | ||
154 | size_t bitflips = 0; | ||
155 | |||
156 | for (su1 = cs; 0 < count; ++su1, count--, i++) { | ||
157 | res = *su1 ^ 0xff; | ||
158 | if (res) { | ||
159 | pr_info("error @addr[0x%lx:0x%lx] 0x%x -> 0xff diff 0x%x\n", | ||
160 | (unsigned long)addr, (unsigned long)offset + i, | ||
161 | *su1, res); | ||
162 | bitflips += hweight8(res); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | return bitflips; | ||
167 | } | ||
168 | |||
144 | static int verify_eraseblock(int ebnum) | 169 | static int verify_eraseblock(int ebnum) |
145 | { | 170 | { |
146 | int i; | 171 | int i; |
@@ -203,6 +228,15 @@ static int verify_eraseblock(int ebnum) | |||
203 | bitflips = memcmpshow(addr, readbuf + use_offset, | 228 | bitflips = memcmpshow(addr, readbuf + use_offset, |
204 | writebuf + (use_len_max * i) + use_offset, | 229 | writebuf + (use_len_max * i) + use_offset, |
205 | use_len); | 230 | use_len); |
231 | |||
232 | /* verify pre-offset area for 0xff */ | ||
233 | bitflips += memffshow(addr, 0, readbuf, use_offset); | ||
234 | |||
235 | /* verify post-(use_offset + use_len) area for 0xff */ | ||
236 | k = use_offset + use_len; | ||
237 | bitflips += memffshow(addr, k, readbuf + k, | ||
238 | mtd->ecclayout->oobavail - k); | ||
239 | |||
206 | if (bitflips > bitflip_limit) { | 240 | if (bitflips > bitflip_limit) { |
207 | pr_err("error: verify failed at %#llx\n", | 241 | pr_err("error: verify failed at %#llx\n", |
208 | (long long)addr); | 242 | (long long)addr); |
@@ -212,34 +246,8 @@ static int verify_eraseblock(int ebnum) | |||
212 | return -1; | 246 | return -1; |
213 | } | 247 | } |
214 | } else if (bitflips) { | 248 | } else if (bitflips) { |
215 | pr_info("ignoring error as within bitflip_limit\n"); | 249 | pr_info("ignoring errors as within bitflip limit\n"); |
216 | } | 250 | } |
217 | |||
218 | for (k = 0; k < use_offset; ++k) | ||
219 | if (readbuf[k] != 0xff) { | ||
220 | pr_err("error: verify 0xff " | ||
221 | "failed at %#llx\n", | ||
222 | (long long)addr); | ||
223 | errcnt += 1; | ||
224 | if (errcnt > 1000) { | ||
225 | pr_err("error: too " | ||
226 | "many errors\n"); | ||
227 | return -1; | ||
228 | } | ||
229 | } | ||
230 | for (k = use_offset + use_len; | ||
231 | k < mtd->ecclayout->oobavail; ++k) | ||
232 | if (readbuf[k] != 0xff) { | ||
233 | pr_err("error: verify 0xff " | ||
234 | "failed at %#llx\n", | ||
235 | (long long)addr); | ||
236 | errcnt += 1; | ||
237 | if (errcnt > 1000) { | ||
238 | pr_err("error: too " | ||
239 | "many errors\n"); | ||
240 | return -1; | ||
241 | } | ||
242 | } | ||
243 | } | 251 | } |
244 | if (vary_offset) | 252 | if (vary_offset) |
245 | do_vary_offset(); | 253 | do_vary_offset(); |