Skip to content

Commit

Permalink
i2c: pasemi: Wait for write xfers to finish
Browse files Browse the repository at this point in the history
Wait for completion of write transfers before returning from the driver.
At first sight it may seem advantageous to leave write transfers queued
for the controller to carry out on its own time, but there's a couple of
issues with it:

 * Driver doesn't check for FIFO space.

 * The queued writes can complete while the driver is in its I2C read
   transfer path which means it will get confused by the raising of
   XEN (the 'transaction ended' signal). This can cause a spurious
   ENODATA error due to premature reading of the MRXFIFO register.

Adding the wait fixes some unreliability issues with the driver. There's
some efficiency cost to it (especially with pasemi_smb_waitready doing
its polling), but that will be alleviated once the driver receives
interrupt support.

Fixes: beb58aa ("i2c: PA Semi SMBus driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
  • Loading branch information
Martin Povišer authored and Wolfram Sang committed Apr 15, 2022
1 parent ce522ba commit bd8963e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/i2c/busses/i2c-pasemi-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ static int pasemi_i2c_xfer_msg(struct i2c_adapter *adapter,

TXFIFO_WR(smbus, msg->buf[msg->len-1] |
(stop ? MTXFIFO_STOP : 0));

if (stop) {
err = pasemi_smb_waitready(smbus);
if (err)
goto reset_out;
}
}

return 0;
Expand Down

0 comments on commit bd8963e

Please sign in to comment.