public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Xiaolei Li <xiaolei.li@mediatek.com>
To: <boris.brezillon@free-electrons.com>, <richard@nod.at>
Cc: <matthias.bgg@gmail.com>, <linux-mtd@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>, <rogercc.lin@mediatek.com>,
	<bayi.cheng@mediatek.com>, <jie.wu@mediatek.com>,
	<srv_heupstream@mediatek.com>, <xiaolei.li@mediatek.com>
Subject: [PATCH 2/5] mtd: nand: mtk: disable ecc irq when writing page with hwecc
Date: Fri, 23 Jun 2017 15:12:25 +0800	[thread overview]
Message-ID: <1498201948-39088-3-git-send-email-xiaolei.li@mediatek.com> (raw)
In-Reply-To: <1498201948-39088-1-git-send-email-xiaolei.li@mediatek.com>

Currently, ecc encode irq is enabled when writing page with hwecc, but
we actually do not wait for this irq done. Because NFI and ECC work in
parallel, nfi irq and ecc irq almost come together.

Now, there are two steps to check whether page data are totally written.
First, wait for nfi irq INTR_AHB_DONE. This is to ensure all data
in RAM are received by NFI.
Second, polling the register NFI_ADDRCNTR till all data include ecc
parity data runtime generated by ECC are sent to NAND device.

So, it is redunant to enable ecc irq without waiting for it.

Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
---
 drivers/mtd/nand/mtk_ecc.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c
index a855a4e..00ce22e 100644
--- a/drivers/mtd/nand/mtk_ecc.c
+++ b/drivers/mtd/nand/mtk_ecc.c
@@ -276,16 +276,18 @@ int mtk_ecc_enable(struct mtk_ecc *ecc, struct mtk_ecc_config *config)
 	if (ret)
 		return ret;
 
-	init_completion(&ecc->done);
-	reg_val = ECC_IRQ_EN;
-	/*
-	 * For ECC_NFI_MODE, if ecc->caps->pg_irq_sel is 1, then it
-	 * means this chip can only generate one ecc irq during page
-	 * read / write. If is 0, generate one ecc irq each ecc step.
-	 */
-	if ((ecc->caps->pg_irq_sel) && (config->mode == ECC_NFI_MODE))
-		reg_val |= ECC_PG_IRQ_SEL;
-	writew(reg_val, ecc->regs + ECC_IRQ_REG(op));
+	if (config->mode != ECC_NFI_MODE || op != ECC_ENCODE) {
+		init_completion(&ecc->done);
+		reg_val = ECC_IRQ_EN;
+		/*
+		 * For ECC_NFI_MODE, if ecc->caps->pg_irq_sel is 1, then it
+		 * means this chip can only generate one ecc irq during page
+		 * read / write. If is 0, generate one ecc irq each ecc step.
+		 */
+		if (ecc->caps->pg_irq_sel && config->mode == ECC_NFI_MODE)
+			reg_val |= ECC_PG_IRQ_SEL;
+		writew(reg_val, ecc->regs + ECC_IRQ_REG(op));
+	}
 
 	writew(ECC_OP_ENABLE, ecc->regs + ECC_CTL_REG(op));
 
-- 
1.9.1

  parent reply	other threads:[~2017-06-23  7:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23  7:12 [PATCH 0/5] Improve MTK NAND driver Xiaolei Li
2017-06-23  7:12 ` [PATCH 1/5] mtd: nand: mtk: fix incorrect register setting order about ecc irq Xiaolei Li
2017-06-23  7:12 ` Xiaolei Li [this message]
2017-06-23  7:12 ` [PATCH 3/5] mtd: nand: mtk: remove unneeded mtk_nfc_hw_init from mtk_nfc_resume Xiaolei Li
2017-06-23  7:12 ` [PATCH 4/5] mtd: nand: mtk: remove unneeded mtk_ecc_hw_init from mtk_ecc_resume Xiaolei Li
2017-06-23  7:12 ` [PATCH 5/5] mtd: nand: mtk: add ->setup_data_interface() hook Xiaolei Li
2017-06-24 20:11 ` [PATCH 0/5] Improve MTK NAND driver Boris Brezillon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498201948-39088-3-git-send-email-xiaolei.li@mediatek.com \
    --to=xiaolei.li@mediatek.com \
    --cc=bayi.cheng@mediatek.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=jie.wu@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=richard@nod.at \
    --cc=rogercc.lin@mediatek.com \
    --cc=srv_heupstream@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox