* [PATCH] i2c: img-scb: Fix img_i2c_isr deadlock issue
@ 2023-06-24 17:57 YE Chengfeng
0 siblings, 0 replies; only message in thread
From: YE Chengfeng @ 2023-06-24 17:57 UTC (permalink / raw)
To: andi.shyti; +Cc: linux-i2c, linux-kernel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-24 17:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-24 17:57 [PATCH] i2c: img-scb: Fix img_i2c_isr deadlock issue YE Chengfeng
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®