linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Fuqian Huang <huangfq.daxian@gmail.com>,
	Russell King <linux@armlinux.org.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] i2c: avoid sleep in IRQ context
Date: Wed, 14 Aug 2019 12:07:56 +0200	[thread overview]
Message-ID: <20190814100756.GF1511@ninjato> (raw)
In-Reply-To: <20190807071807.17488-1-huangfq.daxian@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]

On Wed, Aug 07, 2019 at 03:18:07PM +0800, Fuqian Huang wrote:
> i2c_pxa_handler -> i2c_pxa_irq_txempty ->
> i2c_pxa_reset -> i2c_pxa_set_slave -> i2c_pxa_wait_slave
> 
> As i2c_pxa_handler is an interrupt handler, it will finally
> calls i2c_pxa_wait_slave which calls msleep.
> 
> Add in_interrupt check before msleep to avoid sleep
> in IRQ context.
> When in interrupt context, use mdelay instead of msleep.
> 
> Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>

Adding RMK to CC because he is the PXA I2C slave user I know of.

> ---
>  drivers/i2c/busses/i2c-pxa.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index 2c3c3d6935c0..876e693bafd9 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -456,7 +456,10 @@ static int i2c_pxa_wait_slave(struct pxa_i2c *i2c)
>  			return 1;
>  		}
>  
> -		msleep(1);
> +		if (in_interrupt())
> +			mdelay(1);
> +		else
> +			msleep(1);
>  	}
>  
>  	if (i2c_debug > 0)
> -- 
> 2.11.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2019-08-14 10:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07  7:18 [PATCH v2] i2c: avoid sleep in IRQ context Fuqian Huang
2019-08-14 10:07 ` Wolfram Sang [this message]

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=20190814100756.GF1511@ninjato \
    --to=wsa@the-dreams.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=huangfq.daxian@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).