From patchwork Wed Sep 3 20:44:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 4837651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 47DFDC0338 for ; Wed, 3 Sep 2014 20:47:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F4282021B for ; Wed, 3 Sep 2014 20:47:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B48112020E for ; Wed, 3 Sep 2014 20:47:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPHQY-0005oO-Fh; Wed, 03 Sep 2014 20:45:14 +0000 Received: from mail-pd0-x230.google.com ([2607:f8b0:400e:c02::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPHQO-0004bP-CO for linux-arm-kernel@lists.infradead.org; Wed, 03 Sep 2014 20:45:04 +0000 Received: by mail-pd0-f176.google.com with SMTP id w10so2576280pde.21 for ; Wed, 03 Sep 2014 13:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NTS/5AwDV7xkRfC90IArlYHhLVcTCTW3yrYGyN0kKVo=; b=VEcFmpnhS5FwfEWaoS4gC1sQkYMe2d5rqdUIRHVkKSALnMiQppmoxYEpEgAnMGeZ1/ ung8OxrOp5zms/MkhHeT8XBww6N7pAKEsyY4ddUQW+mVuBIq4TRuLd+YztQ5H2tWGVQc igcjUFzuCbQ/nc7nwhPSRHWzeWUGlR4S6rym8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NTS/5AwDV7xkRfC90IArlYHhLVcTCTW3yrYGyN0kKVo=; b=RXVuxo59UkMywlWEOkKPCMEI0C98CTil8047AMZyPkqFYJVlfALUZMSDt21v4qNLfo wXSjRhmzHUysl9HWEAbtbLyWSLGkmIXihX2cED/2GvWUWojS6EL8lgsL7vAfXD3QhOSW uM4mx47nKxmy2ICiwayBnEEQpM6qL3gciaYlDq29OIUET0/PeYI+1DFMi+kQpPPEpnKV uz3PS9po92YJqYD6PwodFO0zlld1itzfIr7yGKAq1sgtHC8vPHsqbMqioV2BUttpqeJE aYBayWGH7SaBULbUWt28WSY3988H1Tq06QAuhs/jNeYHKySC49oUqjo/N/118Igi5O8c idTg== X-Gm-Message-State: ALoCoQkQXzX1c0oGfyJM7wvEwrx3Z1LUUwIChsJxaTKQgBuKHq74CBEN2bWKGtkb59FwKhrrwMAq X-Received: by 10.70.51.103 with SMTP id j7mr156692pdo.84.1409777083101; Wed, 03 Sep 2014 13:44:43 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.15]) by mx.google.com with ESMTPSA id qv9sm7597658pbb.86.2014.09.03.13.44.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Sep 2014 13:44:42 -0700 (PDT) From: Doug Anderson To: Mark Brown , Addy Ke , Heiko Stuebner Subject: [PATCH 1/3] spi/rockchip: Fix the wait_for_idle() timeout Date: Wed, 3 Sep 2014 13:44:25 -0700 Message-Id: <1409777067-17422-2-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1409777067-17422-1-git-send-email-dianders@chromium.org> References: <1409777067-17422-1-git-send-email-dianders@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140903_134504_460299_EE3BAC32 X-CRM114-Status: GOOD ( 10.91 ) X-Spam-Score: -0.8 (/) Cc: Alexandru Stan , linux-kernel@vger.kernel.org, Doug Anderson , linux-spi@vger.kernel.org, linux-rockchip@lists.infradead.org, Sonny Rao , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The wait_for_idle() could get unlucky and timeout too quickly. Specifically, the old calculation was effectively: timeout = jiffies + 1; if (jiffies >= timeout) print warning; From the above it should be obvious that if jiffies ticks in just the wrong place then we'll have an effective timeout of 0. Fix this by effectively changing the above ">=" to a ">". That gives us an extra jiffy to finish. Signed-off-by: Doug Anderson --- drivers/spi/spi-rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index cd0e08b0..84dbb86 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -220,7 +220,7 @@ static inline void wait_for_idle(struct rockchip_spi *rs) do { if (!(readl_relaxed(rs->regs + ROCKCHIP_SPI_SR) & SR_BUSY)) return; - } while (time_before(jiffies, timeout)); + } while (!time_after(jiffies, timeout)); dev_warn(rs->dev, "spi controller is in busy state!\n"); }