From patchwork Fri Jun 23 07:12:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xiaolei li X-Patchwork-Id: 9805801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 94E56600C5 for ; Fri, 23 Jun 2017 07:13:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 869F12870D for ; Fri, 23 Jun 2017 07:13:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79CA72872A; Fri, 23 Jun 2017 07:13:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 079402870D for ; Fri, 23 Jun 2017 07:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=80FzjReW6sEtwA+au0jOEaV5KfqhUhcuPk/vpoh1gvw=; b=pYv8lsx1IrsPZo CjQhHBxNic6CxltlCqCWC+eD4CiRssE4PFyld+/ndpa7CdzdNQv790O5YkEREY1stDcwuS5mH+IMt tT6iXDIN1AFS+2yRh3g1kP+Rg0iVFjhqPd7THwHW2CqlmYjwnilFizJU25X3TZKFNCl0l+OWcKeT9 n3HA9MlS1SsqQgXOit2YVK1kPbZn4VQ7N1CIqWVBiGrsrbZKklTfC9pqarZ3KpvKwsUbTCfga8OZs QOjCOx1+hTcwBqDRMnR40LiGhXMG+o34S8Q4zqx8hjWdm1Dd5Zl8FqZ/DhjS6Gcz+IOKvCSw7a6P/ 6XpXSPWZkSExJdGK99Jg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dOImB-00051e-Si; Fri, 23 Jun 2017 07:13:07 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dOIm8-00050D-IF; Fri, 23 Jun 2017 07:13:06 +0000 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 625652014; Fri, 23 Jun 2017 15:12:39 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Fri, 23 Jun 2017 15:12:38 +0800 Received: from mtkslt306.mediatek.inc (10.21.14.136) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Fri, 23 Jun 2017 15:12:37 +0800 From: Xiaolei Li To: , Subject: [PATCH 2/5] mtd: nand: mtk: disable ecc irq when writing page with hwecc Date: Fri, 23 Jun 2017 15:12:25 +0800 Message-ID: <1498201948-39088-3-git-send-email-xiaolei.li@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1498201948-39088-1-git-send-email-xiaolei.li@mediatek.com> References: <1498201948-39088-1-git-send-email-xiaolei.li@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170623_001304_770874_8BC1E769 X-CRM114-Status: GOOD ( 12.11 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: srv_heupstream@mediatek.com, bayi.cheng@mediatek.com, jie.wu@mediatek.com, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, linux-mtd@lists.infradead.org, xiaolei.li@mediatek.com, rogercc.lin@mediatek.com Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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));