From patchwork Wed Jul 4 14:05:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Hecht X-Patchwork-Id: 168987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (unknown [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 704202C0208 for ; Thu, 5 Jul 2012 00:09:21 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SmQEU-0006fa-8J; Wed, 04 Jul 2012 14:07:06 +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 1SmQEL-0006ZE-JZ for linux-mtd@lists.infradead.org; Wed, 04 Jul 2012 14:06:58 +0000 Received: by bkcji2 with SMTP id ji2so2156814bkc.36 for ; Wed, 04 Jul 2012 07:06:02 -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; bh=HL78L/XhAqi7EfZ6yKIF6QwiB1zYe06uSm37pILhiNk=; b=DeXNXIrh9YFOG/BslP2ZdUMlK3ifeZItK3oeYbHOSdH0iHx74tXhIKysJA6wJCfBkX SEGykoPuYfXAdpSWqWcxxiA0htZOLB72RxG7Jybyd8zwIrycVS+NB30tg3OvLTfyBWYR E0Udh5HjVXLToTO5yWpcvZqfGc80pMMYyf19HL9jIMIbrT8BIN7owxefERW9aHfEYR5O gyE4Mw7CiESs2PvQcHhP9kYB0emcYjZ1UgLUDJF7SAEYwiuigVhHwHZ5Q97JiUzrkPz6 tLq4yypdFvqnDj4XRtclc7jFSJBTdSLYwsEgkp1WXL8I1YF12cAulJ+IOPCmZDBKT2vP 0B1w== Received: by 10.204.128.201 with SMTP id l9mr11744628bks.68.1341410762704; Wed, 04 Jul 2012 07:06:02 -0700 (PDT) Received: from ipanema.abspannwerk.de (p5DDC5388.dip.t-dialin.net. [93.220.83.136]) by mx.google.com with ESMTPS id h18sm19079647bkh.8.2012.07.04.07.06.01 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Jul 2012 07:06:02 -0700 (PDT) From: Bastian Hecht To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: sh_flctl: Switch from tick-based to time-based timeout Date: Wed, 4 Jul 2012 16:05:26 +0200 Message-Id: <1341410726-10562-1-git-send-email-hechtb@gmail.com> X-Mailer: git-send-email 1.7.9.5 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.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (hechtb[at]googlemail.com) -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 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: Bastian Hecht , Artem Bityutskiy , Linux-SH 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 Instead of counting down a compile-time value, we use a value based on jiffies. Signed-off-by: Bastian Hecht --- Artem mentioned the idea a while ago - here is the simple implementation now. drivers/mtd/nand/sh_flctl.c | 14 +++++++++----- include/linux/mtd/sh_flctl.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c index ed03ed2..0d9cce7 100644 --- a/drivers/mtd/nand/sh_flctl.c +++ b/drivers/mtd/nand/sh_flctl.c @@ -73,6 +73,8 @@ static struct nand_bbt_descr flctl_4secc_largepage = { .pattern = scan_ff_pattern, }; +static int loop_timeout_max; + static void empty_fifo(struct sh_flctl *flctl) { writel(flctl->flintdmacr_base | AC1CLR | AC0CLR, FLINTDMACR(flctl)); @@ -91,7 +93,7 @@ static void timeout_error(struct sh_flctl *flctl, const char *str) static void wait_completion(struct sh_flctl *flctl) { - uint32_t timeout = LOOP_TIMEOUT_MAX; + uint32_t timeout = loop_timeout_max; while (timeout--) { if (readb(FLTRCR(flctl)) & TREND) { @@ -138,7 +140,7 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr) static void wait_rfifo_ready(struct sh_flctl *flctl) { - uint32_t timeout = LOOP_TIMEOUT_MAX; + uint32_t timeout = loop_timeout_max; while (timeout--) { uint32_t val; @@ -153,7 +155,7 @@ static void wait_rfifo_ready(struct sh_flctl *flctl) static void wait_wfifo_ready(struct sh_flctl *flctl) { - uint32_t len, timeout = LOOP_TIMEOUT_MAX; + uint32_t len, timeout = loop_timeout_max; while (timeout--) { /* check FIFO */ @@ -168,7 +170,7 @@ static void wait_wfifo_ready(struct sh_flctl *flctl) static enum flctl_ecc_res_t wait_recfifo_ready (struct sh_flctl *flctl, int sector_number) { - uint32_t timeout = LOOP_TIMEOUT_MAX; + uint32_t timeout = loop_timeout_max; void __iomem *ecc_reg[4]; int i; int state = FL_SUCCESS; @@ -247,7 +249,7 @@ static enum flctl_ecc_res_t wait_recfifo_ready static void wait_wecfifo_ready(struct sh_flctl *flctl) { - uint32_t timeout = LOOP_TIMEOUT_MAX; + uint32_t timeout = loop_timeout_max; uint32_t len; while (timeout--) { @@ -939,6 +941,8 @@ static int __devinit flctl_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); pm_runtime_resume(&pdev->dev); + loop_timeout_max = loops_per_jiffy * msecs_to_jiffies(LOOP_TIMEOUT_MS); + ret = nand_scan_ident(flctl_mtd, 1, NULL); if (ret) goto err_chip; diff --git a/include/linux/mtd/sh_flctl.h b/include/linux/mtd/sh_flctl.h index 01e4b15..ade44c1 100644 --- a/include/linux/mtd/sh_flctl.h +++ b/include/linux/mtd/sh_flctl.h @@ -129,7 +129,7 @@ #define _4ECCEND (0x1 << 1) /* 4 symbols end */ #define _4ECCEXST (0x1 << 0) /* 4 symbols exist */ -#define LOOP_TIMEOUT_MAX 0x00010000 +#define LOOP_TIMEOUT_MS 100 enum flctl_ecc_res_t { FL_SUCCESS,