1 From 25f815f66a141436df8a4c45e5d2765272aea2ac Mon Sep 17 00:00:00 2001
2 From: Boris Brezillon <boris.brezillon@free-electrons.com>
3 Date: Thu, 30 Nov 2017 18:01:30 +0100
4 Subject: [PATCH 5/7] mtd: nand: force drivers to explicitly send READ/PROG
7 The core currently send the READ0 and SEQIN+PAGEPROG commands in
8 nand_do_read/write_ops(). This is inconsistent with
9 ->read/write_oob[_raw]() hooks behavior which are expected to send
12 There's already a flag (NAND_ECC_CUSTOM_PAGE_ACCESS) to inform the core
13 that a specific controller wants to send the READ/SEQIN+PAGEPROG
14 commands on its own, but it's an opt-in flag, and existing drivers are
15 unlikely to be updated to pass it.
17 Moreover, some controllers cannot dissociate the READ/PAGEPROG commands
18 from the associated data transfer and ECC engine activation, and
19 developers have to hack things in their ->cmdfunc() implementation to
20 handle such complex cases, or have to accept the perf penalty of sending
21 twice the same command.
22 To address this problem we are planning on adding a new interface which
23 is passed all information about a NAND operation (including the amount
24 of data to transfer) and replacing all calls to ->cmdfunc() to calls to
25 this new ->exec_op() hook. But, in order to do that, we need to have all
26 ->cmdfunc() calls placed near their associated ->read/write_buf/byte()
29 Modify the core and relevant drivers to make NAND_ECC_CUSTOM_PAGE_ACCESS
30 the default case, and remove this flag.
32 Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
33 [miquel.raynal@free-electrons.com: tested, fixed and rebased on nand/next]
34 Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
35 Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
37 drivers/mtd/nand/qcom_nandc.c | 11 +++++++++++
38 1 file changed, 11 insertions(+)
40 --- a/drivers/mtd/nand/qcom_nandc.c
41 +++ b/drivers/mtd/nand/qcom_nandc.c
42 @@ -1725,6 +1725,7 @@ static int qcom_nandc_read_page(struct m
43 u8 *data_buf, *oob_buf = NULL;
46 + nand_read_page_op(chip, page, 0, NULL, 0);
48 oob_buf = oob_required ? chip->oob_poi : NULL;
50 @@ -1750,6 +1751,7 @@ static int qcom_nandc_read_page_raw(stru
54 + nand_read_page_op(chip, page, 0, NULL, 0);
56 oob_buf = chip->oob_poi;
58 @@ -1850,6 +1852,8 @@ static int qcom_nandc_write_page(struct
59 u8 *data_buf, *oob_buf;
62 + nand_prog_page_begin_op(chip, page, 0, NULL, 0);
64 clear_read_regs(nandc);
65 clear_bam_transaction(nandc);
67 @@ -1902,6 +1906,9 @@ static int qcom_nandc_write_page(struct
72 + ret = nand_prog_page_end_op(chip);
77 @@ -1916,6 +1923,7 @@ static int qcom_nandc_write_page_raw(str
78 u8 *data_buf, *oob_buf;
81 + nand_prog_page_begin_op(chip, page, 0, NULL, 0);
82 clear_read_regs(nandc);
83 clear_bam_transaction(nandc);
85 @@ -1970,6 +1978,9 @@ static int qcom_nandc_write_page_raw(str
90 + ret = nand_prog_page_end_op(chip);