From patchwork Wed May 2 09:41:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Hecht X-Patchwork-Id: 156404 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9B200B6FB7 for ; Wed, 2 May 2012 19:44:26 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SPW5W-0008EE-8q; Wed, 02 May 2012 09:43:10 +0000 Received: from mail-bk0-f49.google.com ([209.85.214.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SPW51-000849-K4 for linux-mtd@lists.infradead.org; Wed, 02 May 2012 09:42:40 +0000 Received: by mail-bk0-f49.google.com with SMTP id j4so343217bkw.36 for ; Wed, 02 May 2012 02:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=rJ61EWtfu34MV3wlTtP2vj9RkF2TRrM2XYHpDzGRK5E=; b=JLb+2EpFArC4B//X6RWROuQ2TkQ/X1Vey8+bU0B+vX9eYSiXhdzyVvU1b2V6F/+Nje qhQP2o5qVDcDDTTj0dTqZ/7MhKHdFr16K6C4g8/1Y4dn+TwGoeGaP1VwetQBENZBC8wR o/6Pv9ZLC8omf8jVxm9GOl7JRd2KdMCFhKjnu6xsFy+ereTtpy6BSy0CjvVQmALqebXz n+x7qDNRGnZG30W2p3RP0cQfTNE7c0XjlBv6rLt/a71ExJ00DMsahm/2bD09yGIoysKt jyt6CkkMJtrrmMg+SZG/f/eO/TzKS6pM0jk9zKTvipEtKcQG2RKW2xblDTwSASBzAIrG Xyqw== Received: by 10.204.148.82 with SMTP id o18mr9602654bkv.108.1335951759221; Wed, 02 May 2012 02:42:39 -0700 (PDT) Received: from localhost.localdomain ([176.74.57.22]) by mx.google.com with ESMTPS id e20sm2362194bkv.10.2012.05.02.02.42.37 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 May 2012 02:42:38 -0700 (PDT) From: Bastian Hecht To: linux-mtd@lists.infradead.org, linux-sh@vger.kernel.org Subject: [PATCH v3 07/10] mtd: sh_flctl: Group sector accesses into a single transfer Date: Wed, 2 May 2012 11:41:47 +0200 Message-Id: <1335951710-9390-8-git-send-email-hechtb@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1335951710-9390-1-git-send-email-hechtb@gmail.com> References: <1335951710-9390-1-git-send-email-hechtb@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (hechtb[at]googlemail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Brian Norris , Magnus Damm , Laurent Pichart , Artem Bityutskiy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When we use hardware ecc, the flctl is run in so-called "sector access mode". We can bundle 4 sector accesses when using 2k page sizes to read a whole page at once and speed up things. Signed-off-by: Bastian Hecht --- drivers/mtd/nand/sh_flctl.c | 44 ++++++++++++++++++------------------------ 1 files changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c index b027370..96c88b8 100644 --- a/drivers/mtd/nand/sh_flctl.c +++ b/drivers/mtd/nand/sh_flctl.c @@ -368,25 +368,21 @@ static void execmd_read_page_sector(struct mtd_info *mtd, int page_addr) struct sh_flctl *flctl = mtd_to_flctl(mtd); int sector, page_sectors; - if (flctl->page_size) - page_sectors = 4; - else - page_sectors = 1; + page_sectors = flctl->page_size ? 4 : 1; + + set_cmd_regs(mtd, NAND_CMD_READ0, + (NAND_CMD_READSTART << 8) | NAND_CMD_READ0); writel(readl(FLCMNCR(flctl)) | ACM_SACCES_MODE | _4ECCCORRECT, FLCMNCR(flctl)); + writel(readl(FLCMDCR(flctl)) | page_sectors, FLCMDCR(flctl)); + writel(page_addr << 2, FLADR(flctl)); - set_cmd_regs(mtd, NAND_CMD_READ0, - (NAND_CMD_READSTART << 8) | NAND_CMD_READ0); + empty_fifo(flctl); + start_translation(flctl); for (sector = 0; sector < page_sectors; sector++) { int ret; - - empty_fifo(flctl); - writel(readl(FLCMDCR(flctl)) | 1, FLCMDCR(flctl)); - writel(page_addr << 2 | sector, FLADR(flctl)); - - start_translation(flctl); read_fiforeg(flctl, 512, 512 * sector); ret = read_ecfiforeg(flctl, @@ -397,8 +393,10 @@ static void execmd_read_page_sector(struct mtd_info *mtd, int page_addr) flctl->hwecc_cant_correct[sector] = 1; writel(0x0, FL4ECCCR(flctl)); - wait_completion(flctl); } + + wait_completion(flctl); + writel(readl(FLCMNCR(flctl)) & ~(ACM_SACCES_MODE | _4ECCCORRECT), FLCMNCR(flctl)); } @@ -430,31 +428,27 @@ static void execmd_write_page_sector(struct mtd_info *mtd) int i, page_addr = flctl->seqin_page_addr; int sector, page_sectors; - if (flctl->page_size) - page_sectors = 4; - else - page_sectors = 1; - - writel(readl(FLCMNCR(flctl)) | ACM_SACCES_MODE, FLCMNCR(flctl)); + page_sectors = flctl->page_size ? 4 : 1; set_cmd_regs(mtd, NAND_CMD_PAGEPROG, (NAND_CMD_PAGEPROG << 8) | NAND_CMD_SEQIN); - for (sector = 0; sector < page_sectors; sector++) { - empty_fifo(flctl); - writel(readl(FLCMDCR(flctl)) | 1, FLCMDCR(flctl)); - writel(page_addr << 2 | sector, FLADR(flctl)); + empty_fifo(flctl); + writel(readl(FLCMNCR(flctl)) | ACM_SACCES_MODE, FLCMNCR(flctl)); + writel(readl(FLCMDCR(flctl)) | page_sectors, FLCMDCR(flctl)); + writel(page_addr << 2, FLADR(flctl)); + start_translation(flctl); - start_translation(flctl); + for (sector = 0; sector < page_sectors; sector++) { write_fiforeg(flctl, 512, 512 * sector); for (i = 0; i < 4; i++) { wait_wecfifo_ready(flctl); /* wait for write ready */ writel(0xFFFFFFFF, FLECFIFO(flctl)); } - wait_completion(flctl); } + wait_completion(flctl); writel(readl(FLCMNCR(flctl)) & ~ACM_SACCES_MODE, FLCMNCR(flctl)); }