aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/ubi.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/ubi.h')
-rw-r--r--drivers/mtd/ubi/ubi.h43
1 files changed, 25 insertions, 18 deletions
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 0359e0cce482..c6c22295898e 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -40,6 +40,7 @@
40#include <linux/notifier.h> 40#include <linux/notifier.h>
41#include <linux/mtd/mtd.h> 41#include <linux/mtd/mtd.h>
42#include <linux/mtd/ubi.h> 42#include <linux/mtd/ubi.h>
43#include <asm/pgtable.h>
43 44
44#include "ubi-media.h" 45#include "ubi-media.h"
45#include "scan.h" 46#include "scan.h"
@@ -85,21 +86,26 @@
85/* 86/*
86 * Error codes returned by the I/O sub-system. 87 * Error codes returned by the I/O sub-system.
87 * 88 *
88 * UBI_IO_PEB_EMPTY: the physical eraseblock is empty, i.e. it contains only 89 * UBI_IO_FF: the read region of flash contains only 0xFFs
89 * %0xFF bytes 90 * UBI_IO_FF_BITFLIPS: the same as %UBI_IO_FF, but also also there was a data
90 * UBI_IO_PEB_FREE: the physical eraseblock is free, i.e. it contains only a 91 * integrity error reported by the MTD driver
91 * valid erase counter header, and the rest are %0xFF bytes 92 * (uncorrectable ECC error in case of NAND)
92 * UBI_IO_BAD_HDR: the EC or VID header is corrupted (bad magic or CRC) 93 * UBI_IO_BAD_HDR: the EC or VID header is corrupted (bad magic or CRC)
93 * UBI_IO_BAD_HDR_READ: the same as %UBI_IO_BAD_HDR, but also there was a read 94 * UBI_IO_BAD_HDR_EBADMSG: the same as %UBI_IO_BAD_HDR, but also there was a
94 * error reported by the flash driver 95 * data integrity error reported by the MTD driver
96 * (uncorrectable ECC error in case of NAND)
95 * UBI_IO_BITFLIPS: bit-flips were detected and corrected 97 * UBI_IO_BITFLIPS: bit-flips were detected and corrected
98 *
99 * Note, it is probably better to have bit-flip and ebadmsg as flags which can
100 * be or'ed with other error code. But this is a big change because there are
101 * may callers, so it does not worth the risk of introducing a bug
96 */ 102 */
97enum { 103enum {
98 UBI_IO_PEB_EMPTY = 1, 104 UBI_IO_FF = 1,
99 UBI_IO_PEB_FREE, 105 UBI_IO_FF_BITFLIPS,
100 UBI_IO_BAD_HDR, 106 UBI_IO_BAD_HDR,
101 UBI_IO_BAD_HDR_READ, 107 UBI_IO_BAD_HDR_EBADMSG,
102 UBI_IO_BITFLIPS 108 UBI_IO_BITFLIPS,
103}; 109};
104 110
105/* 111/*
@@ -335,8 +341,8 @@ struct ubi_wl_entry;
335 * protected from the wear-leveling worker) 341 * protected from the wear-leveling worker)
336 * @pq_head: protection queue head 342 * @pq_head: protection queue head
337 * @wl_lock: protects the @used, @free, @pq, @pq_head, @lookuptbl, @move_from, 343 * @wl_lock: protects the @used, @free, @pq, @pq_head, @lookuptbl, @move_from,
338 * @move_to, @move_to_put @erase_pending, @wl_scheduled, @works, 344 * @move_to, @move_to_put @erase_pending, @wl_scheduled, @works,
339 * @erroneous, and @erroneous_peb_count fields 345 * @erroneous, and @erroneous_peb_count fields
340 * @move_mutex: serializes eraseblock moves 346 * @move_mutex: serializes eraseblock moves
341 * @work_sem: synchronizes the WL worker with use tasks 347 * @work_sem: synchronizes the WL worker with use tasks
342 * @wl_scheduled: non-zero if the wear-leveling was scheduled 348 * @wl_scheduled: non-zero if the wear-leveling was scheduled
@@ -356,6 +362,8 @@ struct ubi_wl_entry;
356 * @peb_size: physical eraseblock size 362 * @peb_size: physical eraseblock size
357 * @bad_peb_count: count of bad physical eraseblocks 363 * @bad_peb_count: count of bad physical eraseblocks
358 * @good_peb_count: count of good physical eraseblocks 364 * @good_peb_count: count of good physical eraseblocks
365 * @corr_peb_count: count of corrupted physical eraseblocks (preserved and not
366 * used by UBI)
359 * @erroneous_peb_count: count of erroneous physical eraseblocks in @erroneous 367 * @erroneous_peb_count: count of erroneous physical eraseblocks in @erroneous
360 * @max_erroneous: maximum allowed amount of erroneous physical eraseblocks 368 * @max_erroneous: maximum allowed amount of erroneous physical eraseblocks
361 * @min_io_size: minimal input/output unit size of the underlying MTD device 369 * @min_io_size: minimal input/output unit size of the underlying MTD device
@@ -374,14 +382,14 @@ struct ubi_wl_entry;
374 * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or 382 * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or
375 * not 383 * not
376 * @nor_flash: non-zero if working on top of NOR flash 384 * @nor_flash: non-zero if working on top of NOR flash
385 * @max_write_size: maximum amount of bytes the underlying flash can write at a
386 * time (MTD write buffer size)
377 * @mtd: MTD device descriptor 387 * @mtd: MTD device descriptor
378 * 388 *
379 * @peb_buf1: a buffer of PEB size used for different purposes 389 * @peb_buf1: a buffer of PEB size used for different purposes
380 * @peb_buf2: another buffer of PEB size used for different purposes 390 * @peb_buf2: another buffer of PEB size used for different purposes
381 * @buf_mutex: protects @peb_buf1 and @peb_buf2 391 * @buf_mutex: protects @peb_buf1 and @peb_buf2
382 * @ckvol_mutex: serializes static volume checking when opening 392 * @ckvol_mutex: serializes static volume checking when opening
383 * @dbg_peb_buf: buffer of PEB size used for debugging
384 * @dbg_buf_mutex: protects @dbg_peb_buf
385 */ 393 */
386struct ubi_device { 394struct ubi_device {
387 struct cdev cdev; 395 struct cdev cdev;
@@ -442,6 +450,7 @@ struct ubi_device {
442 int peb_size; 450 int peb_size;
443 int bad_peb_count; 451 int bad_peb_count;
444 int good_peb_count; 452 int good_peb_count;
453 int corr_peb_count;
445 int erroneous_peb_count; 454 int erroneous_peb_count;
446 int max_erroneous; 455 int max_erroneous;
447 int min_io_size; 456 int min_io_size;
@@ -456,16 +465,13 @@ struct ubi_device {
456 int vid_hdr_shift; 465 int vid_hdr_shift;
457 unsigned int bad_allowed:1; 466 unsigned int bad_allowed:1;
458 unsigned int nor_flash:1; 467 unsigned int nor_flash:1;
468 int max_write_size;
459 struct mtd_info *mtd; 469 struct mtd_info *mtd;
460 470
461 void *peb_buf1; 471 void *peb_buf1;
462 void *peb_buf2; 472 void *peb_buf2;
463 struct mutex buf_mutex; 473 struct mutex buf_mutex;
464 struct mutex ckvol_mutex; 474 struct mutex ckvol_mutex;
465#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
466 void *dbg_peb_buf;
467 struct mutex dbg_buf_mutex;
468#endif
469}; 475};
470 476
471extern struct kmem_cache *ubi_wl_entry_slab; 477extern struct kmem_cache *ubi_wl_entry_slab;
@@ -506,6 +512,7 @@ int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf,
506 int length); 512 int length);
507int ubi_check_volume(struct ubi_device *ubi, int vol_id); 513int ubi_check_volume(struct ubi_device *ubi, int vol_id);
508void ubi_calculate_reserved(struct ubi_device *ubi); 514void ubi_calculate_reserved(struct ubi_device *ubi);
515int ubi_check_pattern(const void *buf, uint8_t patt, int size);
509 516
510/* eba.c */ 517/* eba.c */
511int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol, 518int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol,