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: 4837621 Return-Path: X-Original-To: patchwork-linux-rockchip@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 713AFC033A for ; Wed, 3 Sep 2014 20:45:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2AAB20221 for ; Wed, 3 Sep 2014 20:45:21 +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 ECA782021B for ; Wed, 3 Sep 2014 20:45:20 +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 1XPHQe-0005r8-K9; Wed, 03 Sep 2014 20:45:20 +0000 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPHQP-0004bQ-2P for linux-rockchip@lists.infradead.org; Wed, 03 Sep 2014 20:45:05 +0000 Received: by mail-pa0-f51.google.com with SMTP id rd3so18530305pab.10 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=jVQbimZCbsFxAgTIvEkq6yAvlLZ8euVQHK82OhWSegvkWlOdY4vY2x44TcTtZ3KMJC NxSQNv7ASOaJSyoMnD7Qwgq2itwUaG9H77ZUd+m0F8no7VPZV9fVYAn8pGetg3rnT0Fy uvdIdW87nbe/9tnJTdZ/ZLd/mRWsrbo2x3sHp8fkvrjaocYIYEZx9X/82RUCAlxHXhSK JcV42JkxsXHA+Xt84N6yt3uGYtHjAgbixE7ehj9oOzgn/2vsh+42xARePVvQqbqZpBLe qDiqoyuRcsVX71b0diq4eNyx9TVyBXoeTAVGexTYSZGYvNMyLo1+3Hqss0FCxfBdh+uQ 7lCg== X-Gm-Message-State: ALoCoQnp7l+5xNsvwEK+GcdoQp3fKRNSv3Idl9M4WcKzZIq2qYv/37uKAWqk76USnmcjwbrG48ku 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_134505_129489_84D2FC64 X-CRM114-Status: UNSURE ( 9.29 ) X-CRM114-Notice: Please train this message. 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-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=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"); }