linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fuqian Huang <huangfq.daxian@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	Fuqian Huang <huangfq.daxian@gmail.com>
Subject: [PATCH] i2c: avoid sleep in IRQ context
Date: Mon,  5 Aug 2019 20:31:34 +0800	[thread overview]
Message-ID: <20190805123134.23199-1-huangfq.daxian@gmail.com> (raw)

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.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
---
 drivers/i2c/busses/i2c-pxa.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 2c3c3d6935c0..b35a0e8efcb2 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -443,6 +443,8 @@ static int i2c_pxa_wait_slave(struct pxa_i2c *i2c)
 
 	show_state(i2c);
 
+	if (in_interrupt())
+		return 0;
 	while (time_before(jiffies, timeout)) {
 		if (i2c_debug > 1)
 			dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n",
-- 
2.11.0


             reply	other threads:[~2019-08-05 12:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05 12:31 Fuqian Huang [this message]
     [not found] ` <20190807065111.GA17104@localhost.localdomain>
2019-08-07  7:04   ` [PATCH] i2c: avoid sleep in IRQ context Fuqian Huang

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=20190805123134.23199-1-huangfq.daxian@gmail.com \
    --to=huangfq.daxian@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 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).