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: 4837571 Return-Path: X-Original-To: patchwork-linux-spi@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 0FA99C033A for ; Wed, 3 Sep 2014 20:44:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1ED292022A for ; Wed, 3 Sep 2014 20:44:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2400420222 for ; Wed, 3 Sep 2014 20:44:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752823AbaICUoo (ORCPT ); Wed, 3 Sep 2014 16:44:44 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:65507 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754017AbaICUon (ORCPT ); Wed, 3 Sep 2014 16:44:43 -0400 Received: by mail-pd0-f175.google.com with SMTP id ft15so12014164pdb.34 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=NH1YivSTU477TdoNC78bcTIRT2qN3Os8l3u1wuMXpmQw1N5nauoWjcGw88W5YGV2WG KLpWAvD2WOB93x8YNFCHjvOUmWVngRbQGGLtbKl7EsCPmCtcgpr1muQG6Gq1MtMqIp9P MtA4H3oLUA9oTwsgsqQuuQQHiPvAxdVthk91hFemgM7bcxhArl7LRzwptPub6jhNj1D/ s55hN4rXIfAe8dpm8u+0mVH8XdU6n0ENTYpL4Bl5YzRcy1QwTPY13CWF1AHcusoE8Uk8 ub/aQJWgotxl12QEqlCTIeU8gLqpcuiviDQF7rCznR/WCk/vd45M1FsJ982PeQkruJLu j9wA== X-Gm-Message-State: ALoCoQlmg7EfvlK2/1bkIgUeJI6vtPxHmJ3hq9H9CCg8FQuaFtM8Kx7mvUmSgZRbM65hA/Blw8NY 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 Cc: Alexandru Stan , Sonny Rao , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Doug Anderson , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org 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> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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"); }