From patchwork Wed Apr 30 17:44:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 4095451 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0D7329F3A0 for ; Wed, 30 Apr 2014 17:52:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 327AA20149 for ; Wed, 30 Apr 2014 17:52:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54DFF202E6 for ; Wed, 30 Apr 2014 17:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1945975AbaD3RwP (ORCPT ); Wed, 30 Apr 2014 13:52:15 -0400 Received: from mail-vc0-f202.google.com ([209.85.220.202]:55023 "EHLO mail-vc0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1945934AbaD3RwO (ORCPT ); Wed, 30 Apr 2014 13:52:14 -0400 Received: by mail-vc0-f202.google.com with SMTP id lc6so302681vcb.5 for ; Wed, 30 Apr 2014 10:52:14 -0700 (PDT) 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=wB5Pd7SRP7LD516kcJcrcu1YwHfBw/Nkbcolk24LMQ0=; b=VsACFLrM3P23jSPlaVRyzdkBxLT+4yGpPznPgBegFoa2+1rIA2ijUiqEVxMwXTZe6I 60tktSOI+vdtUzOndQ7jWlr99HwQDxNmEiBXt6vtIkAEMA38JBeI9e5YFO7OsWlwnmE+ vo8DAbQgCf6Win55nC6in6Emg4JOxJf2ROXKuCeutE7RbViMwbg2HpEsFCSrKfNpj/dP bYqUjQkW7ykzu10fttfHI0C9uL5OZs/IoOx2abc6jov9PhT8Dd5qHXEzDvU4cxbxHzwV WzI8OtcE0O/md/ZGxZVQyeF9KOdMFLnH1CGxCzzhb+IRIOHpvETP9B7FPLh5+ANI0lxE 0cxg== X-Gm-Message-State: ALoCoQkxIJtWz2Uov7Rvxtc4zl4btOhPXT9MNvKTME22sJrE+W6cvV8WM8fTFqw5MEv81XqKA49Em2hY0Zc7oaxgmBLlh9CP4R2sw8iKIM51OmCLsjrBaRot3eKW/GphQBWSoz6ZXft7w5o/N5QWS/HYikum96zv76fgKwDOgyb1vD1Tt0D7GWOZf+RAPRktmg6jcxSZ/zUhpVVrPreMVW5FVygjWQHx6w== X-Received: by 10.224.36.137 with SMTP id t9mr3097999qad.4.1398879874588; Wed, 30 Apr 2014 10:44:34 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id a44si3078120yhb.6.2014.04.30.10.44.34 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Apr 2014 10:44:34 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.72.141]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 6F72931C1C7; Wed, 30 Apr 2014 10:44:34 -0700 (PDT) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id 1FACB80914; Wed, 30 Apr 2014 10:44:34 -0700 (PDT) From: Doug Anderson To: lee.jones@linaro.org, swarren@nvidia.com, wsa@the-dreams.de Cc: abrestic@chromium.org, dgreid@chromium.org, olof@lixom.net, sjg@chromium.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, David Hendricks , Doug Anderson , sameo@linux.intel.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/7] mfd: cros_ec: spi: calculate delay between transfers correctly Date: Wed, 30 Apr 2014 10:44:04 -0700 Message-Id: <1398879850-9111-2-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: <1398879850-9111-1-git-send-email-dianders@chromium.org> References: <1398879850-9111-1-git-send-email-dianders@chromium.org> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 From: David Hendricks To avoid spamming the EC we calculate the time between the previous transfer and the current transfer and force a delay if the time delta is too small. However, a small miscalculation causes the delay period to be far too short. Most noticably this impacts commands with a long turnaround time such as EC firmware reads and writes. Signed-off-by: David Hendricks Signed-off-by: Doug Anderson Acked-by: Lee Jones Reviewed-by: Simon Glass Tested-by: Andrew Bresticker Tested-by: Stephen Warren --- Changes in v3: None Changes in v2: None drivers/mfd/cros_ec_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c index 84af8d7..c185eb6 100644 --- a/drivers/mfd/cros_ec_spi.c +++ b/drivers/mfd/cros_ec_spi.c @@ -219,7 +219,7 @@ static int cros_ec_command_spi_xfer(struct cros_ec_device *ec_dev, ktime_get_ts(&ts); delay = timespec_to_ns(&ts) - ec_spi->last_transfer_ns; if (delay < EC_SPI_RECOVERY_TIME_NS) - ndelay(delay); + ndelay(EC_SPI_RECOVERY_TIME_NS - delay); } /* Transmit phase - send our message */