From patchwork Thu Mar 30 06:46:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 745117 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vtxHw3yDkz9ryr for ; Thu, 30 Mar 2017 18:35:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="q3IDi46t"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="e7SJIifv"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="VDwzzDpN"; dkim-atps=neutral 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=TGrE6SJfH99GcAgFhBcwWQIsEmXrPmP1nXM61TVNmWQ=; b=q3IDi46tB/JQ6bAUVfBYtDOYDh cMMKcp61C0WRbmYQH+TGr8acWoBK+NK6VLUypCUA/Wnd2KPLJg4qW4sa/PRjKOKodh1uYHbieM45v 43cVmW7oNdjEpJqgPShHEh5N00M6IGMeyoir+5VFS1IcQzVV6pbcfx+Z1P2r5FgDRPwgWGrF6id4D 0ihLSJd/OomzF0pVTIoz1l4vVbREJ/L+boSBJQhDb+oyCZ1JLAuWiDzeGBAKyAayx5//9Vulwu+Dw vLLy/hmj/PMMpOqoQAaOUmHJO2K28tR+wiYKrmxh3476o/w5jwUmc1dqgvX07pYBjL24GiA04Dw9x lHhBAM4w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ctUcL-0007pc-BD; Thu, 30 Mar 2017 07:35:37 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ctUbs-0006Pr-Gk for linux-mtd@bombadil.infradead.org; Thu, 30 Mar 2017 07:35:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=p/YevX4QshDRAsOvoTj2B6AK0KvMKhhE2Q2XAiz2NOc=; b=e7SJIifvCzyRg7AbW5NwMlSIZ ZzReGHAWlFRyazzAoHa7S4GvR8sRqfoLiaKLTowRgzABPgHbJEZtqojsBbWdZPZChnbmJ9glSq3aG uE7h56ZKvswTkJ2ZSL6NavjEQw505SMfPBaYCwr+MIrWIdiVjpB6mYCKxM4G0G/qBWER0lthFT5vs Kt3l8zIQ+CW4lIBxy0mEY+ehaVGm1xCOqhra3Kt4prm1TCFwdg5xZpKdDNom+qD0WhJYSJEqcZ7wc S0l3+YI59RqZIXJeKmMc5e3SIYmcohpeUsTLd74I87WbS5qOfL1J/PnrfYni1qhFbk811chAOEuqs jYJksBaTA==; Received: from conuserg-07.nifty.com ([210.131.2.74]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ctTsr-0002Le-48 for linux-mtd@lists.infradead.org; Thu, 30 Mar 2017 06:48:41 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id v2U6kUcp015463; Thu, 30 Mar 2017 15:47:06 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v2U6kUcp015463 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1490856427; bh=p/YevX4QshDRAsOvoTj2B6AK0KvMKhhE2Q2XAiz2NOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VDwzzDpNhVQL34Ozgm0PdutEsGyWOfBeT/8IGNGl6lKvcPScv7L7n69O4W9da4aNr qK/3V88+75E08DsKBGUk+pZnBahUBCQchTZek9+YDJuhygckDIEXxmEOPSg7EsfNmC zVojoKBWwoQRVoqOf4vgXw4xnhmWIrsVlpdOwwLtb/0eqSOy65ZH+RJPHgXyMov2m3 XXLZpE05a+JHfGyViNt6ndVhvbch2bMBvzfuC+NimcnI/gHbFYk4adjq9g+Ut7XrEq x5p/U6ZXnmEaMzAWuyc7r5/to/Te0gPe3ZPOeFqcgJ4JV/P53irnq4o8uh415LMbBa fw6LOlQ1dbaGQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH v3 27/37] mtd: nand: denali: use interrupt instead of polling for bank reset Date: Thu, 30 Mar 2017 15:46:13 +0900 Message-Id: <1490856383-31560-28-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490856383-31560-1-git-send-email-yamada.masahiro@socionext.com> References: <1490856383-31560-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170330_024837_588981_28E9B1FA X-CRM114-Status: GOOD ( 14.34 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Richard Weinberger , Dinh Nguyen , Masahiro Yamada , Artem Bityutskiy , Cyrille Pitchen , linux-kernel@vger.kernel.org, Marek Vasut , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Brian Norris , Enrico Jorns , David Woodhouse , Graham Moore MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The current bank reset implementation polls the INTR_STATUS register until interested bits are set. This is not good because: - it simply wastes time-slice of the thread which the driver module is loaded from. - The while() loop may continue eternally if no bit is set, for example, due to the controller problem. The denali_wait_for_irq() uses wait_for_completion_timeout(), which is safer. We can use interrupt by moving the denali_reset_bank() call below the interrupt setup. Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: - Newly added drivers/mtd/nand/denali.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index e4f2699..9dfed20 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -974,24 +974,25 @@ static int denali_setup_data_interface(struct mtd_info *mtd, static void denali_reset_banks(struct denali_nand_info *denali) { + u32 irq_status; int i; - denali_clear_irq_all(denali); - for (i = 0; i < denali->max_banks; i++) { - iowrite32(1 << i, denali->flash_reg + DEVICE_RESET); - while (!(ioread32(denali->flash_reg + INTR_STATUS(i)) & - (INTR__RST_COMP | INTR__TIME_OUT))) - cpu_relax(); - if (!(ioread32(denali->flash_reg + INTR_STATUS(i)) & - INTR__INT_ACT)) + denali->flash_bank = i; + + denali_reset_irq(denali); + + iowrite32(DEVICE_RESET__BANK(i), + denali->flash_reg + DEVICE_RESET); + + irq_status = denali_wait_for_irq(denali, + INTR__RST_COMP | INTR__INT_ACT | INTR__TIME_OUT); + if (!(irq_status & INTR__INT_ACT)) break; } dev_dbg(denali->dev, "%d chips connected\n", i); denali->max_banks = i; - - denali_clear_irq_all(denali); } static void denali_hw_init(struct denali_nand_info *denali) @@ -1013,7 +1014,6 @@ static void denali_hw_init(struct denali_nand_info *denali) denali->bbtskipbytes = ioread32(denali->flash_reg + SPARE_AREA_SKIP_BYTES); detect_max_banks(denali); - denali_reset_banks(denali); iowrite32(0x0F, denali->flash_reg + RB_PIN_ENABLED); iowrite32(CHIP_EN_DONT_CARE__FLAG, denali->flash_reg + CHIP_ENABLE_DONT_CARE); @@ -1137,9 +1137,6 @@ static void denali_drv_init(struct denali_nand_info *denali) * element that might be access shared data (interrupt status) */ spin_lock_init(&denali->irq_lock); - - /* indicate that MTD has not selected a valid bank yet */ - denali->flash_bank = CHIP_SELECT_INVALID; } static int denali_multidev_fixup(struct denali_nand_info *denali) @@ -1214,6 +1211,9 @@ int denali_init(struct denali_nand_info *denali) } denali_enable_irq(denali); + denali_reset_banks(denali); + + denali->flash_bank = CHIP_SELECT_INVALID; nand_set_flash_node(chip, denali->dev->of_node); /* Fallback to the default name if DT did not give "label" property */