[<prev] [next>] [day] [month] [year] [list]
Message-ID: <TYCP286MB11889AFE709804F40DBC62AC8A20A@TYCP286MB1188.JPNP286.PROD.OUTLOOK.COM>
Date: Sat, 24 Jun 2023 17:57:31 +0000
From: YE Chengfeng <cyeaa@...nect.ust.hk>
To: "andi.shyti@...nel.org" <andi.shyti@...nel.org>
CC: "linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH] i2c: img-scb: Fix img_i2c_isr deadlock issue
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@...nect.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
Powered by blists - more mailing lists