From patchwork Wed Jun 7 11:52:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 103250 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp1715962obh; Wed, 7 Jun 2017 04:58:49 -0700 (PDT) X-Received: by 10.98.75.79 with SMTP id y76mr14637750pfa.39.1496836729214; Wed, 07 Jun 2017 04:58:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496836729; cv=none; d=google.com; s=arc-20160816; b=tqmaHNdk4CJMdNq/0AEvXOlMlJVLvlVXHuySTznTFcoEFPVQ/1zC/xl2vB5fX6bfx9 n5+8NAdHahPv/UN/mB6liKQ7GnCC8cwf/pwt0yNwZKoN89PKHn1wBfyG14OeWhR2CBO9 8p7hx5mjU+Pf6WL3VwJCvlxW6z7HbB/NRcin/K0fc+ZNGxF19iGRHST//6r0SoUfElIS L+u/415Ka5oUyflUj+vFdMlfEgk9yJTjjPwI0FYTiFld+wU+ZC8yigdH2ehEf0fXGEgt ZmmK/ojwhOosTkEUH7a6TMqMfl6JciKUwVb6ikyx6mUeDo534F4GFlDRxhepYFeT46ET Ldag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=AaubtptUPbGdXkYYMr2/r9oWlwE8fZyaPX5iV82l618=; b=gPPXuxg83RWinmE4KXDj+GpAw9qlR4e5FzGFcbcFxXwkaw4RFi1+a6B1FuZqi7Kz3S SvzFRst73SGxeHUAI3THtpXeNh9nRNXY5HJNDV8t7oOcT7OfKNG9C2swy/HV5vqlvnY3 iKP7/1RrpsSbjsyjzJRVXPzglQwmULT050H9k0UA+QXaJUQPVi7C2keWzQF2yDuJsdrp EiDbXPhWvtMWEuFDd7kA8z4DZqaU+5mu0O1Z5UXlmwr0V4CJ3tenje+tpWhGk7N+3m0z SlwgYso4Ft7CIH81gUkGQq8lsGwWO9lgcP0GRe47r+hEn+GIYu5Pg4vCA0e5UObpfDNN HcVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24si1627578pfa.242.2017.06.07.04.58.48; Wed, 07 Jun 2017 04:58:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751908AbdFGL63 (ORCPT + 25 others); Wed, 7 Jun 2017 07:58:29 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:42480 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751552AbdFGLzY (ORCPT ); Wed, 7 Jun 2017 07:55:24 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id v57BqjZV014276; Wed, 7 Jun 2017 20:52:53 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v57BqjZV014276 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1496836374; bh=AaubtptUPbGdXkYYMr2/r9oWlwE8fZyaPX5iV82l618=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1mCcDGFLVP5sHGdXhpkDujgM+rF7ZBhmF2gwEE3OQHmdWwvvZyIWA2ngz4xJj4Gfk YNPQi3kv8zzv03wbRudMA96dUGI7kWuR2tLW3mVktLfQaLpcAG6llSuGi5fakaLXdh h8Q3EOFfkrDeM8yfXyE/7wzIsevOhboUzwxiyS2tH8I9yOFKEOnC9fAb+JTQhZ+ULO xJj3jR6fZwl/rWR1zceZQrRgn0JJaxHyeTdDOcQM+unHSSXou6XMauqkzFB7D4Q8bO mGSnOfu9WrEHgNKMxD6Bi+8NQ/gaRX+Q4nRhO5NVXLimfSn4nLsm67DBBFudaTEhO7 oFefC5fehE+Xw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Cc: Enrico Jorns , Artem Bityutskiy , Dinh Nguyen , Boris Brezillon , Marek Vasut , David Woodhouse , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Masahiro Yamada , Cyrille Pitchen , linux-kernel@vger.kernel.org, Brian Norris , Richard Weinberger Subject: [PATCH v5 06/23] mtd: nand: denali: set NAND_ECC_CUSTOM_PAGE_ACCESS Date: Wed, 7 Jun 2017 20:52:15 +0900 Message-Id: <1496836352-8016-7-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496836352-8016-1-git-send-email-yamada.masahiro@socionext.com> References: <1496836352-8016-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The denali_cmdfunc() actually does nothing valuable for NAND_CMD_{PAGEPROG,READ0,SEQIN}. For NAND_CMD_{READ0,SEQIN}, it copies "page" to "denali->page", then denali_read_page() and denali_read_page_raw() compare them to check if the NAND framework called the callbacks in correct order. (Inconsistently, this check is missing from the denali_write_page() and denali_write_page_raw().) The framework is widely tested by many drivers, so this kind of sanity check is unneeded. The Denali controller is equipped with high level interface for read/write, so let's skip unneeded call of cmdfunc(). Signed-off-by: Masahiro Yamada --- Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: - Newly added drivers/mtd/nand/denali.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 991924b9ae2c..1897fe238290 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -998,7 +998,7 @@ static void denali_setup_dma(struct denali_nand_info *denali, int op) * configuration details. */ static int write_page(struct mtd_info *mtd, struct nand_chip *chip, - const uint8_t *buf, bool raw_xfer) + const uint8_t *buf, int page, bool raw_xfer) { struct denali_nand_info *denali = mtd_to_denali(mtd); dma_addr_t addr = denali->buf.dma_buf; @@ -1006,6 +1006,8 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *chip, uint32_t irq_status; uint32_t irq_mask = INTR__DMA_CMD_COMP | INTR__PROGRAM_FAIL; + denali->page = page; + /* * if it is a raw xfer, we want to disable ecc and send the spare area. * !raw_xfer - enable ecc @@ -1059,7 +1061,7 @@ static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip, * for regular page writes, we let HW handle all the ECC * data written to the device. */ - return write_page(mtd, chip, buf, false); + return write_page(mtd, chip, buf, page, false); } /* @@ -1075,7 +1077,7 @@ static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, * for raw page writes, we want to disable ECC and simply write * whatever data is in the buffer. */ - return write_page(mtd, chip, buf, true); + return write_page(mtd, chip, buf, page, true); } static int denali_write_oob(struct mtd_info *mtd, struct nand_chip *chip, @@ -1105,12 +1107,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip, unsigned long uncor_ecc_flags = 0; int stat = 0; - if (page != denali->page) { - dev_err(denali->dev, - "IN %s: page %d is not equal to denali->page %d", - __func__, page, denali->page); - BUG(); - } + denali->page = page; setup_ecc_for_xfer(denali, true, false); @@ -1154,12 +1151,7 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, size_t size = mtd->writesize + mtd->oobsize; uint32_t irq_mask = INTR__DMA_CMD_COMP; - if (page != denali->page) { - dev_err(denali->dev, - "IN %s: page %d is not equal to denali->page %d", - __func__, page, denali->page); - BUG(); - } + denali->page = page; setup_ecc_for_xfer(denali, false, true); denali_enable_dma(denali, true); @@ -1238,8 +1230,6 @@ static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col, int i; switch (cmd) { - case NAND_CMD_PAGEPROG: - break; case NAND_CMD_STATUS: read_status(denali); break; @@ -1259,10 +1249,6 @@ static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col, write_byte_to_buf(denali, id); } break; - case NAND_CMD_READ0: - case NAND_CMD_SEQIN: - denali->page = page; - break; case NAND_CMD_RESET: reset_bank(denali); break; @@ -1603,6 +1589,7 @@ int denali_init(struct denali_nand_info *denali) mtd_set_ooblayout(mtd, &denali_ooblayout_ops); + chip->ecc.options |= NAND_ECC_CUSTOM_PAGE_ACCESS; chip->ecc.read_page = denali_read_page; chip->ecc.read_page_raw = denali_read_page_raw; chip->ecc.write_page = denali_write_page;