050-0005-mtd-nand-force-drivers-to-explicitly-send-READ-PROG-.patch 3.0 KB

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