All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David E. Box" <david.e.box-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Andy Shevchenko
	<andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	Mika Westerberg
	<mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jarkko Nikula
	<jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: Re: [PATCH v1 5/5] i2c-designware-baytrail: baytrail_i2c_acquire() might sleep
Date: Wed, 11 Feb 2015 08:48:27 -0800	[thread overview]
Message-ID: <20150211164827.GE14753@pathfinder> (raw)
In-Reply-To: <1423587970-19136-5-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

On Tue, Feb 10, 2015 at 07:06:10PM +0200, Andy Shevchenko wrote:
> This patch marks baytrail_i2c_acquire() that it might sleep. Also it chages
> while-loop to do-while and, though it is matter of taste, gives a chance to
> check one more time before report a timeout.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

Acked-by: David E. Box <david.e.box-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

> ---
>  drivers/i2c/busses/i2c-designware-baytrail.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c b/drivers/i2c/busses/i2c-designware-baytrail.c
> index 036d9bdc0..7d7ae97 100644
> --- a/drivers/i2c/busses/i2c-designware-baytrail.c
> +++ b/drivers/i2c/busses/i2c-designware-baytrail.c
> @@ -68,6 +68,8 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
>  	int ret;
>  	unsigned long start, end;
>  
> +	might_sleep();
> +
>  	if (!dev || !dev->dev)
>  		return -ENODEV;
>  
> @@ -85,7 +87,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
>  	/* host driver waits for bit 0 to be set in semaphore register */
>  	start = jiffies;
>  	end = start + msecs_to_jiffies(SEMAPHORE_TIMEOUT);
> -	while (!time_after(jiffies, end)) {
> +	do {
>  		ret = get_sem(dev->dev, &sem);
>  		if (!ret && sem) {
>  			acquired = jiffies;
> @@ -95,7 +97,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
>  		}
>  
>  		usleep_range(1000, 2000);
> -	}
> +	} while (time_before(jiffies, end));
>  
>  	dev_err(dev->dev, "punit semaphore timed out, resetting\n");
>  	reset_semaphore(dev->dev);
> -- 
> 2.1.4
> 

  parent reply	other threads:[~2015-02-11 16:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 17:06 [PATCH v1 1/5] i2c-designware-baytrail: describe magic numbers Andy Shevchenko
     [not found] ` <1423587970-19136-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-10 17:06   ` [PATCH v1 2/5] i2c-designware-baytrail: fix typo in error path Andy Shevchenko
     [not found]     ` <1423587970-19136-2-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-11 16:38       ` David E. Box
2015-02-11 16:46       ` Wolfram Sang
2015-02-11 16:59         ` Andy Shevchenko
     [not found]           ` <1423673991.31903.535.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-11 18:04             ` David E. Box
2015-02-23 12:54         ` Andy Shevchenko
     [not found]           ` <1424696051.14897.13.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-23 18:42             ` Wolfram Sang
2015-02-24 10:06               ` Andy Shevchenko
2015-02-10 17:06   ` [PATCH v1 3/5] i2c-designware-baytrail: fix sparse warnings Andy Shevchenko
     [not found]     ` <1423587970-19136-3-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-11 16:44       ` David E. Box
2015-02-10 17:06   ` [PATCH v1 4/5] i2c-designware-baytrail: cross-check lock functions Andy Shevchenko
     [not found]     ` <1423587970-19136-4-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-11 16:46       ` David E. Box
2015-02-10 17:06   ` [PATCH v1 5/5] i2c-designware-baytrail: baytrail_i2c_acquire() might sleep Andy Shevchenko
     [not found]     ` <1423587970-19136-5-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-02-11 16:48       ` David E. Box [this message]
2015-02-11 16:35   ` [PATCH v1 1/5] i2c-designware-baytrail: describe magic numbers David E. Box
2015-03-07  0:11   ` Wolfram Sang

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=20150211164827.GE14753@pathfinder \
    --to=david.e.box-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.