From patchwork Mon Apr 29 06:38:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xiaolei li X-Patchwork-Id: 10921311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9CEC14D5 for ; Mon, 29 Apr 2019 06:39:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9626F2848D for ; Mon, 29 Apr 2019 06:39:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A073284CE; Mon, 29 Apr 2019 06:39:54 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 3F75D2848D for ; Mon, 29 Apr 2019 06:39:54 +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=kvgaYmnT3vXbsnhkGnzUqJPbS05DxQMeu/8hc63B1Ok=; b=ihJqjzsb23pVgc oQBJWiHYrogXpWOalxlCUOxFMPdCsWH/WBOQVzwWMNnycjux4LfpLiWJf0x9JLR1ePXoJEchpxfSF xqHNZRf/Ah29Zer1+WEcB53agYkzpSLeJ7pRjgNASM/ZjjGWtTCySac0rC/QfYC00isF7V53BOQAO B9Oyho/1S45nmY0mtU3rN7X23pwrv0abVnTFuzJeEYTvu9PTOtagxdiEK9UqlN5aMLc5drnQpRZ9T pvUobyTxVKbpI+P/mPUl3tstoA8qiFUPQxGUhGqIL7LrmwQu0l+bxGk+ajSDblJJyFaevUy6yrfck WeMe2nlllcGv22grGYbg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hKzxB-0006yR-0O; Mon, 29 Apr 2019 06:39:53 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hKzwD-0005WA-JB; Mon, 29 Apr 2019 06:38:57 +0000 X-UUID: 480b0a01645e444cb081e6940613cfa9-20190428 X-UUID: 480b0a01645e444cb081e6940613cfa9-20190428 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 712740872; Sun, 28 Apr 2019 22:38:47 -0800 Received: from mtkmbs03n1.mediatek.inc (172.21.101.181) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 28 Apr 2019 23:38:45 -0700 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 29 Apr 2019 14:38:44 +0800 Received: from mtkslt306.mediatek.inc (10.21.14.136) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 29 Apr 2019 14:38:44 +0800 From: Xiaolei Li To: , Subject: [PATCH 5/5] mtd: rawnand: mtk: Setup empty page threshold correctly Date: Mon, 29 Apr 2019 14:38:34 +0800 Message-ID: <20190429063834.45967-6-xiaolei.li@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190429063834.45967-1-xiaolei.li@mediatek.com> References: <20190429063834.45967-1-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-20190428_233854_090009_90C1689F X-CRM114-Status: UNSURE ( 8.48 ) X-CRM114-Notice: Please train this message. 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: linux-mediatek@lists.infradead.org, xiaolei.li@mediatek.com, linux-mtd@lists.infradead.org, srv_heupstream@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 MTK NAND Controller has the ability to check whether read data are mostly 0xff by comparing zero bit conut of read data with empty threshold automatically. But now we never set this threshold and always make it be default value which is 10. This patch fixes this problem by setting empty threshold as the product of read sector count and ecc strength. Fixes: 93db446a424c ("mtd: nand: move raw NAND related code to the raw/ subdir") Signed-off-by: Xiaolei Li --- drivers/mtd/nand/raw/mtk_nand.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c index cf5e50e704ae..675d4faa3480 100644 --- a/drivers/mtd/nand/raw/mtk_nand.c +++ b/drivers/mtd/nand/raw/mtk_nand.c @@ -94,6 +94,7 @@ #define NFI_MASTER_STA (0x224) #define MASTER_STA_MASK (0x0FFF) #define NFI_EMPTY_THRESH (0x23C) +#define EMPTY_THRESH_MASK GENMASK(7, 0) #define MTK_NAME "mtk-nand" #define KB(x) ((x) * 1024UL) @@ -931,6 +932,10 @@ static int mtk_nfc_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, return -EINVAL; } + /* Setup empty threshold */ + reg = max(sectors * chip->ecc.strength, EMPTY_THRESH_MASK); + nfi_writel(nfc, reg, NFI_EMPTY_THRESH); + reg = nfi_readw(nfc, NFI_CNFG); reg |= CNFG_READ_EN | CNFG_DMA_BURST_EN | CNFG_AHB; if (!raw) {