From: YE Chengfeng <cyeaa@connect.ust.hk>
To: "andi.shyti@kernel.org" <andi.shyti@kernel.org>
Cc: "linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] i2c: img-scb: Fix img_i2c_isr deadlock issue
Date: Sat, 24 Jun 2023 17:57:31 +0000 [thread overview]
Message-ID: <TYCP286MB11889AFE709804F40DBC62AC8A20A@TYCP286MB1188.JPNP286.PROD.OUTLOOK.COM> (raw)
The softirq img_i2c_isr and timer img_i2c_check_timer could deadlock
on the &i2c->lock when img_i2c_isr is preempted by the timer while
holding the lock &i2c->lock with spin_lock.
Deadlock scenario:
img_i2c_isr
-> spin_lock(&i2c->lock);
<timer interrupt>
-> img_i2c_check_timer
-> spin_lock_irqsave(&i2c->lock, flags);
To prevent this deadlock scenario, use spin_lock_bh to disable the
bottom half interrupt.
Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
---
drivers/i2c/busses/i2c-img-scb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index 39c479f96eb5..a2b957c3898b 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -935,7 +935,7 @@ static irqreturn_t img_i2c_isr(int irq, void *dev_id)
img_i2c_wr_rd_fence(i2c);
}
- spin_lock(&i2c->lock);
+ spin_lock_bh(&i2c->lock);
/* Keep track of line status bits received */
i2c->line_status &= ~LINESTAT_INPUT_DATA;
@@ -998,7 +998,7 @@ static irqreturn_t img_i2c_isr(int irq, void *dev_id)
/* Enable interrupts (int_enable may be altered by changing mode) */
img_i2c_writel(i2c, SCB_INT_MASK_REG, i2c->int_enable);
- spin_unlock(&i2c->lock);
+ spin_unlock_bh(&i2c->lock);
return IRQ_HANDLED;
}
--
2.17.1
reply other threads:[~2023-06-24 17:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=TYCP286MB11889AFE709804F40DBC62AC8A20A@TYCP286MB1188.JPNP286.PROD.OUTLOOK.COM \
--to=cyeaa@connect.ust.hk \
--cc=andi.shyti@kernel.org \
--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
all inboxes | Powered by JetHome®