[PATCH] i2c: img-scb: Fix img_i2c_isr deadlock issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux