1 Content-Type: text/plain; charset="utf-8"
3 Content-Transfer-Encoding: 7bit
5 1/5] mtd: nand: Create a BBT flag to access bad block markers in raw
7 From: Archit Taneja <architt@codeaurora.org>
8 X-Patchwork-Id: 6927081
9 Message-Id: <1438578498-32254-2-git-send-email-architt@codeaurora.org>
10 To: linux-mtd@lists.infradead.org, dehrenberg@google.com,
11 cernekee@gmail.com, computersforpeace@gmail.com
12 Cc: linux-arm-msm@vger.kernel.org, agross@codeaurora.org,
13 sboyd@codeaurora.org, linux-kernel@vger.kernel.org,
14 Archit Taneja <architt@codeaurora.org>
15 Date: Mon, 3 Aug 2015 10:38:14 +0530
17 Some controllers can access the factory bad block marker from OOB only
18 when they read it in raw mode. When ECC is enabled, these controllers
19 discard reading/writing bad block markers, preventing access to them
22 The bbt driver assumes MTD_OPS_PLACE_OOB when scanning for bad blocks.
23 This results in the nand driver's ecc->read_oob() op to be called, which
24 works with ECC enabled.
26 Create a new BBT option flag that tells nand_bbt to force the mode to
27 MTD_OPS_RAW. This would result in the correct op being called for the
28 underlying nand controller driver.
30 Reviewed-by: Andy Gross <agross@codeaurora.org>
31 Signed-off-by: Archit Taneja <architt@codeaurora.org>
34 drivers/mtd/nand/nand_base.c | 6 +++++-
35 drivers/mtd/nand/nand_bbt.c | 6 +++++-
36 include/linux/mtd/bbm.h | 7 +++++++
37 3 files changed, 17 insertions(+), 2 deletions(-)
39 --- a/drivers/mtd/nand/nand_base.c
40 +++ b/drivers/mtd/nand/nand_base.c
43 ops.len = ops.ooblen = 1;
45 - ops.mode = MTD_OPS_PLACE_OOB;
47 + if (unlikely(chip->bbt_options & NAND_BBT_ACCESS_BBM_RAW))
48 + ops.mode = MTD_OPS_RAW;
50 + ops.mode = MTD_OPS_PLACE_OOB;
52 /* Write to first/last page(s) if necessary */
53 if (chip->bbt_options & NAND_BBT_SCANLASTPAGE)
54 --- a/drivers/mtd/nand/nand_bbt.c
55 +++ b/drivers/mtd/nand/nand_bbt.c
60 - ops.mode = MTD_OPS_PLACE_OOB;
62 + if (unlikely(bd->options & NAND_BBT_ACCESS_BBM_RAW))
63 + ops.mode = MTD_OPS_RAW;
65 + ops.mode = MTD_OPS_PLACE_OOB;
67 for (j = 0; j < numpages; j++) {
69 --- a/include/linux/mtd/bbm.h
70 +++ b/include/linux/mtd/bbm.h
72 #define NAND_BBT_NO_OOB_BBM 0x00080000
75 + * Force MTD_OPS_RAW mode when trying to access bad block markes from OOB. To
76 + * be used by controllers which can access BBM only when ECC is disabled, i.e,
77 + * when in RAW access mode
79 +#define NAND_BBT_ACCESS_BBM_RAW 0x00100000
81 * Flag set by nand_create_default_bbt_descr(), marking that the nand_bbt_descr
82 * was allocated dynamicaly and must be freed in nand_release(). Has no meaning
83 * in nand_chip.bbt_options.