lkml.org 
[lkml]   [2023]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] i2c: img-scb: Fix img_i2c_isr deadlock issue
Date
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
\
 
 \ /
  Last update: 2023-06-24 19:58    [W:0.065 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site