From patchwork Mon Jun 5 23:21:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 103119 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp1009676obh; Mon, 5 Jun 2017 16:29:45 -0700 (PDT) X-Received: by 10.99.167.15 with SMTP id d15mr2831674pgf.42.1496705385773; Mon, 05 Jun 2017 16:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496705385; cv=none; d=google.com; s=arc-20160816; b=nDD3hOze+uNtIuvz6j9QCzw9bbZB7m/vB0OfGy+3cJjfmYL+/2/Lp9SJmknAo7CsP7 zFl+w36zW2lUlAqPLjuDloK9qWgXkwSN3YaL9csE/ukekbRLwo87y8yc49WwhDJ9gkUJ IDbqYvnlcPPS71cB+zaVq7v/nqXuhXoidR6YgRkBXDUxfDNCZUIC1RmEer0O6/DW8rU+ Av91vA2YWHeu1hDkKsLAVaMg5XxZw3/uVplpExIu62f6a7wt62E18HWUjpmETGBMHTOL TOl2XAy3k8z1GPTB/NT3sT/Gi1PyW4CgyC4Zg9KuUE3CteeL/IIegeOgarsUn1XFybFy RrJw== 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=hSP1u0Mt7s97GkydJVKzQAERrnfuZ9G+S898KAg/yW0=; b=kRjsJqXvaN8DTdEYLnJGxM46xyMthv+YAf0BrzsQNkoM0Ql/cHQMfYdDV5w/EeIsns oMzT+u9lqYQdXpxS9p8DYb35C5rQzn383NhQfWyIuOt0AwVgkKQ6cqAAOUWOyqho1VUg +G6cYjtuFNnthYxXcZCtXuygP2+VgBZQrO/sfZbF2ZOhKEdtQAsgi0K4Tn7eh1ltSlqI MwqiB2rSVuosr6W/fcd2e9x48o+pAou4i2z0AI/6McVYgW2tCIfbjxhaoSzsXFgPiBI9 0k9pi+5ftrSsq7/yxNYdvElRfDAVfmrs6WWLrwyf1nv1w8cFDU7Yv6mYAEgxOwGPQms2 k5+A== 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 s4si2756254pfi.251.2017.06.05.16.29.45; Mon, 05 Jun 2017 16:29:45 -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 S1751355AbdFEX3Q (ORCPT + 25 others); Mon, 5 Jun 2017 19:29:16 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:32148 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290AbdFEXZR (ORCPT ); Mon, 5 Jun 2017 19:25:17 -0400 Received: from grover.sesame (FL1-118-110-19-204.osk.mesh.ad.jp [118.110.19.204]) (authenticated) by conuserg-10.nifty.com with ESMTP id v55NMD5h004412; Tue, 6 Jun 2017 08:22:35 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v55NMD5h004412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1496704956; bh=hSP1u0Mt7s97GkydJVKzQAERrnfuZ9G+S898KAg/yW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xI0N3SvTsKX8qui5Z9J+z5t7BiMQGGSPKZjDPecbbtv1AoFow+tU8vS9zI/xe23x1 hCEmgovC6sOhGdspwSvDjHNd3pv/qI/814msy7BAp8xG6+lVrWl7lHsDbdYFla1unz z9dKmkk89BIjiz8KZSn47SQ7AX91jSlKlPU8q7WXTIr02Yc0YKeULWHmxmc3znov7z 1dzi5k5tH+QvmbbEUEe/TkOmVD90lM/nGFR8SmBEq3kzxdVDtIAw7yjEu2guliGdXh gzXCemvs1PVYlqYnh7f4XvcWPY/rPqLjhqe0VeMv1mRTwD87gTkDTvZY5fcuND99v0 HdEXwm5j8C0og== X-Nifty-SrcIP: [118.110.19.204] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Cc: Enrico Jorns , Artem Bityutskiy , Dinh Nguyen , Boris Brezillon , Marek Vasut , Graham Moore , David Woodhouse , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Masahiro Yamada , Cyrille Pitchen , linux-kernel@vger.kernel.org, Brian Norris , Richard Weinberger Subject: [PATCH v4 07/23] mtd: nand: denali: set NAND_ECC_CUSTOM_PAGE_ACCESS Date: Tue, 6 Jun 2017 08:21:46 +0900 Message-Id: <1496704922-12261-8-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496704922-12261-1-git-send-email-yamada.masahiro@socionext.com> References: <1496704922-12261-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 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 422b6e4..3655284 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; @@ -1619,6 +1605,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;