From patchwork Mon Feb 13 08:13:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 727138 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 3vMJGq1QYWz9s7c for ; Mon, 13 Feb 2017 19:13:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="I5knBD8G"; 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: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:In-Reply-To: References:List-Owner; bh=ygb+JcIw3Aao+lJmJEg/MXh2G1G6bSqFUQKyZVuaL1c=; b=I5k nBD8G4aSrNvr8GoO9R2N+4Bq9ebn+WbHb7sMtksvbCasP3fLNW73b5OQmDZ52Dg3EyIf0xzY8AOcL p4LHwyek4HWHRvG7C1ZqA3vQa6Hqdgcpr3tMH1PKvAAwoRmFLKhKfa3UxCOD+CH14tTzzJZIXkSEl VtNMyeMSTtQvc3cJUFYc3m3CbQXLNWpxtxRLNUGffRCZBuZCwRN+l+VFdbNqfKDv7vRhQBVx27bU9 17wZ3oDJbudVKY4JSCIpM7bbzeQFmggAKgp1UAhjOnUXH+rjBpJTRS9Q9B2FBYAVKDZsr+5R8WJZy kGwH6ARIJpkmIXIZdU3ueLcBXcW9q0Q==; 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 1cdBlb-0001Ff-Qq; Mon, 13 Feb 2017 08:13:47 +0000 Received: from www.osadl.org ([62.245.132.105]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cdBlX-0001E4-H7 for linux-mtd@lists.infradead.org; Mon, 13 Feb 2017 08:13:45 +0000 Received: from debian01.hofrr.at (92-243-34-74.adsl.nanet.at [92.243.34.74] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id v1D8CktI003853; Mon, 13 Feb 2017 09:12:46 +0100 From: Nicholas Mc Guire To: Cyrille Pitchen Subject: [PATCH V2 RFC] mtd: spi-nor: intel: provide a range for poll_timout Date: Mon, 13 Feb 2017 09:13:42 +0100 Message-Id: <1486973622-1072-1-git-send-email-der.herr@hofr.at> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-0.9 required=6.0 tests=BAYES_00, KHOP_SC_TOP_CIDR8, RDNS_DYNAMIC,SPF_PASS autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170213_001343_917442_E1916C6F X-CRM114-Status: GOOD ( 10.40 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [62.245.132.105 listed in list.dnswl.org] 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] 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 , David Woodhouse , linux-kernel@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, Richard Weinberger , Nicholas Mc Guire , Brian Norris , Mika Westerberg MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The overall poll time here is INTEL_SPI_TIMEOUT * 1000 which is 5000 * 1000 - so 5seconds and it is coded as a tight loop here delay_us to readl_poll_timeout() is set to 0. As this is never called in an atomic context sleeping should be no issue and there is no reasons for the tight-loop here. Signed-off-by: Nicholas Mc Guire Acked-by: Mika Westerberg --- V2: fixed prefix as pointed out by Boris Brezillon Problem located by experimental coccinelle script: ./drivers/mtd/spi-nor/intel-spi.c:265:8-26: WARNING: usleep_range min=0 for delay INTEL_SPI_TIMEOUT * 1000 ./drivers/mtd/spi-nor/intel-spi.c:274:8-26: WARNING: usleep_range min=0 for delay INTEL_SPI_TIMEOUT * 1000 The rational for setting the delay_us here to 40 is that readx_poll_timeout() will take delay_us >> 2 + 1 as min value and that should be at least 10us (see Documentation/timers/timers-howto.txt). Ideally the delay would be made even larger to keep the load on the hrtimer subsystem low as these delays here do not seem to be critical. Someone that knows the details of this device would need to check if a larger delay would be ok here. Patch was compile tested with: multi_v7_defconfig (implies CONFIG_MTD_SPI_NOR=y) one coccicheck finding reported and one spars finding (in separate patches) Patch is against 4.10-rc7 (localversion-next is next-20170213) drivers/mtd/spi-nor/intel-spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/intel-spi.c b/drivers/mtd/spi-nor/intel-spi.c index a10f602..4630716 100644 --- a/drivers/mtd/spi-nor/intel-spi.c +++ b/drivers/mtd/spi-nor/intel-spi.c @@ -263,7 +263,7 @@ static int intel_spi_wait_hw_busy(struct intel_spi *ispi) u32 val; return readl_poll_timeout(ispi->base + HSFSTS_CTL, val, - !(val & HSFSTS_CTL_SCIP), 0, + !(val & HSFSTS_CTL_SCIP), 40, INTEL_SPI_TIMEOUT * 1000); } @@ -272,7 +272,7 @@ static int intel_spi_wait_sw_busy(struct intel_spi *ispi) u32 val; return readl_poll_timeout(ispi->sregs + SSFSTS_CTL, val, - !(val & SSFSTS_CTL_SCIP), 0, + !(val & SSFSTS_CTL_SCIP), 40, INTEL_SPI_TIMEOUT * 1000); }