public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Doug Anderson <dianders@chromium.org>
Cc: swarren@nvidia.com, wsa@the-dreams.de, abrestic@chromium.org,
	dgreid@chromium.org, olof@lixom.net, sjg@chromium.org,
	linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org,
	sameo@linux.intel.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/7] mfd: cros_ec: spi: Make the cros_ec_spi timeout more reliable
Date: Tue, 20 May 2014 09:45:03 +0100	[thread overview]
Message-ID: <20140520084503.GD24991@lee--X1> (raw)
In-Reply-To: <1398879850-9111-4-git-send-email-dianders@chromium.org>

On Wed, 30 Apr 2014, Doug Anderson wrote:

> The cros_ec_spi transfer had two problems with its timeout code:
> 
> 1. It looked at the timeout even in the case that it found valid data.
> 2. If the cros_ec_spi code got switched out for a while, it's possible
>    it could get a timeout after a single loop.  Let's be paranoid and
>    make sure we do one last transfer after the timeout expires.
> 
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Tested-by: Andrew Bresticker <abrestic@chromium.org>
> Tested-by: Stephen Warren <swarren@nvidia.com>
> ---
> Changes in v3: None
> Changes in v2: None
> 
>  drivers/mfd/cros_ec_spi.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c
> index a2a605d..4f863c3 100644
> --- a/drivers/mfd/cros_ec_spi.c
> +++ b/drivers/mfd/cros_ec_spi.c
> @@ -113,7 +113,9 @@ static int cros_ec_spi_receive_response(struct cros_ec_device *ec_dev,
>  
>  	/* Receive data until we see the header byte */
>  	deadline = jiffies + msecs_to_jiffies(EC_MSG_DEADLINE_MS);
> -	do {
> +	while (true) {
> +		unsigned long start_jiffies = jiffies;
> +
>  		memset(&trans, 0, sizeof(trans));
>  		trans.cs_change = 1;
>  		trans.rx_buf = ptr = ec_dev->din;
> @@ -134,12 +136,19 @@ static int cros_ec_spi_receive_response(struct cros_ec_device *ec_dev,
>  				break;
>  			}
>  		}
> +		if (ptr != end)
> +			break;
>  
> -		if (time_after(jiffies, deadline)) {
> +		/*
> +		 * Use the time at the start of the loop as a timeout.  This
> +		 * gives us one last shot at getting the transfer and is useful
> +		 * in case we got context switched out for a while.
> +		 */
> +		if (time_after(start_jiffies, deadline)) {
>  			dev_warn(ec_dev->dev, "EC failed to respond in time\n");
>  			return -ETIMEDOUT;
>  		}
> -	} while (ptr == end);
> +	}
>  
>  	/*
>  	 * ptr now points to the header byte. Copy any valid data to the

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2014-05-20  8:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-30 17:44 [PATCH v3 0/7] Add cros_ec changes for newer boards Doug Anderson
2014-04-30 17:44 ` [PATCH v3 1/7] mfd: cros_ec: spi: calculate delay between transfers correctly Doug Anderson
2014-05-20  8:43   ` Lee Jones
2014-04-30 17:44 ` [PATCH v3 2/7] mfd: cros_ec: spi: Add mutex to cros_ec_spi Doug Anderson
2014-05-20  8:44   ` Lee Jones
2014-04-30 17:44 ` [PATCH v3 3/7] mfd: cros_ec: spi: Make the cros_ec_spi timeout more reliable Doug Anderson
2014-05-20  8:45   ` Lee Jones [this message]
2014-04-30 17:44 ` [PATCH v3 4/7] mfd: cros_ec: spi: Increase cros_ec_spi deadline from 5ms to 100ms Doug Anderson
2014-05-20  8:45   ` Lee Jones
2014-04-30 17:44 ` [PATCH v3 5/7] mfd: cros_ec: Sync to the latest cros_ec_commands.h from EC sources Doug Anderson
2014-05-20  8:46   ` Lee Jones
2014-06-11 10:37     ` Paul Bolle
2014-06-11 15:11       ` Doug Anderson
2014-06-13  8:08         ` Paul Bolle
2014-06-13 15:22           ` Doug Anderson
2014-06-17  8:53             ` Paul Bolle
2014-06-17 16:20               ` Stephen Warren
2014-06-17 16:43                 ` Paul Bolle
2014-04-30 17:44 ` [PATCH v3 6/7] i2c: ChromeOS EC tunnel driver Doug Anderson
2014-05-01 19:05   ` Stephen Warren
2014-05-19 10:50   ` Wolfram Sang
2014-05-19 17:22     ` Lee Jones
2014-05-19 22:19       ` Wolfram Sang
2014-05-20  8:43         ` Lee Jones
2014-05-20  8:47   ` Lee Jones
2014-05-20 17:35     ` Stephen Warren
2014-04-30 17:44 ` [PATCH v3 7/7] ARM: tegra: Add the EC i2c tunnel to tegra124-venice2 Doug Anderson
2014-05-01 19:06   ` Stephen Warren
2014-05-20  8:48     ` Lee Jones
2014-06-16 19:01   ` Stephen Warren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140520084503.GD24991@lee--X1 \
    --to=lee.jones@linaro.org \
    --cc=abrestic@chromium.org \
    --cc=dgreid@chromium.org \
    --cc=dianders@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=sameo@linux.intel.com \
    --cc=sjg@chromium.org \
    --cc=swarren@nvidia.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox