On Wed, Jan 23, 2019 at 10:51:58AM +0530, shubhrajyoti.datta@xxxxxxxxx wrote: > From: Shubhrajyoti Datta <shubhrajyoti.datta@xxxxxxxxxx> > > In case the hold bit is not needed we are carring the old values > fix the same by resetting the bit when not needed. Typo: s/carring/carrying/. Also missing a period after "values." > > Fixes the sporadic i2c bus lockups on National Instruments > Zynq-based devices. > > Fixes: df8eb5691c48 ("i2c: Add driver for Cadence I2C controller") > Acked-by: Michal Simek <michal.simek@xxxxxxxxxx> > Reported-and-tested-by: Kyle Roeschley <kyle.roeschley@xxxxxx> > Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xxxxxxxxxx> > --- > v4: > update fixes tag > v3: > Add fixes and Ack > v2: > Update commit log > Also check if the hold_flag > > drivers/i2c/busses/i2c-cadence.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c > index b136057..b2b3df1 100644 > --- a/drivers/i2c/busses/i2c-cadence.c > +++ b/drivers/i2c/busses/i2c-cadence.c > @@ -382,8 +382,10 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) > * Check for the message size against FIFO depth and set the > * 'hold bus' bit if it is greater than FIFO depth. > */ > - if (id->recv_count > CDNS_I2C_FIFO_DEPTH) > + if (id->recv_count > CDNS_I2C_FIFO_DEPTH || id->bus_hold_flag) > ctrl_reg |= CDNS_I2C_CR_HOLD; > + else > + ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD; > > cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET); > > @@ -440,8 +442,11 @@ static void cdns_i2c_msend(struct cdns_i2c *id) > * Check for the message size against FIFO depth and set the > * 'hold bus' bit if it is greater than FIFO depth. > */ > - if (id->send_count > CDNS_I2C_FIFO_DEPTH) > + if (id->recv_count > CDNS_I2C_FIFO_DEPTH || id->bus_hold_flag) This should be checking send_count, not recv_count. > ctrl_reg |= CDNS_I2C_CR_HOLD; > + else > + ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD; > + > cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET); > > /* Clear the interrupts in interrupt status register. */ -- Kyle Roeschley Software Engineer National Instruments