i2c: cadence: Fix the driver in interrupt flurry case
Subsystems (2)
PATCH 1/1 i2c: cadence: Fix the driver in interrupt flurry case
From: Shubhrajyoti Datta <[email protected]>
In case there are a lot of interrupts then the hold bit is not released protect the code by making it atomic by disabling interrupts.
Signed-off-by Shubhrajyoti Datta <[email protected]>
--- drivers/i2c/busses/i2c-cadence.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/i2c/busses/i2c-cadence.c +3 -0
@@ -365,6 +365,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) {unsigned int ctrl_reg;unsigned int isr_status; +unsigned long flags; id->p_recv_buf = id->p_msg->buf; id->recv_count = id->p_msg->len;
@@ -405,6 +406,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)cdns_i2c_writereg (id->recv_count,CDNS_I2C_XFER_SIZE_OFFSET ); } +local_irq_save (flags);/* Set the slave address in address register - triggers operation */ cdns_i2c_writereg (id->p_msg->addr &CDNS_I2C_ADDR_MASK ,CDNS_I2C_ADDR_OFFSET );
@@ -413,6 +415,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) ((id->p_msg->flags & I2C_M_RECV_LEN) != I2C_M_RECV_LEN) && (id->recv_count <= CDNS_I2C_FIFO_DEPTH))cdns_i2c_clear_bus_hold (id); +local_irq_restore (flags);cdns_i2c_writereg (CDNS_I2C_ENABLED_INTR_MASK ,CDNS_I2C_IER_OFFSET ); }
Signature · 1 line
2.1.1
Quoted 4 lines · On 15. 02. 19 13:03, [email protected] wrote:
From: Shubhrajyoti Datta <[email protected]>
In case there are a lot of interrupts then the hold bit is not released protect the code by making it atomic by disabling interrupts.
There are two sentences in one.
Isn't it "released. Protect"?
Quoted 28 lines
Signed-off-by Shubhrajyoti Datta <[email protected]>--- drivers/i2c/busses/i2c-cadence.c | 3 +++ 1 file changed, 3 insertions(+)drivers/i2c/busses/i2c-cadence.c +2
-0@@ -365,6 +365,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) {unsigned int ctrl_reg;unsigned int isr_status; +unsigned long flags; id->p_recv_buf = id->p_msg->buf; id->recv_count = id->p_msg->len;@@ -405,6 +406,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)cdns_i2c_writereg (id->recv_count,CDNS_I2C_XFER_SIZE_OFFSET ); } +local_irq_save (flags);/* Set the slave address in address register - triggers operation */ cdns_i2c_writereg (id->p_msg->addr &CDNS_I2C_ADDR_MASK ,CDNS_I2C_ADDR_OFFSET );
drivers/i2c/busses/i2c-cadence.c static void cdns_i2c_mrecv(struct cdns_i2c *id) · line 421
Quoted 7 lines
drivers/i2c/busses/i2c-cadence.c +1
-0@@ -413,6 +415,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) ((id->p_msg->flags & I2C_M_RECV_LEN) != I2C_M_RECV_LEN) && (id->recv_count <= CDNS_I2C_FIFO_DEPTH))cdns_i2c_clear_bus_hold (id); +local_irq_restore (flags);cdns_i2c_writereg (CDNS_I2C_ENABLED_INTR_MASK ,CDNS_I2C_IER_OFFSET ); }
The rest looks good.
M