OSDN Git Service

i2c: mxs: remove races in PIO code
authorLucas Stach <l.stach@pengutronix.de>
Mon, 15 Apr 2013 00:16:54 +0000 (00:16 +0000)
committerWolfram Sang <wsa@the-dreams.de>
Mon, 15 Apr 2013 16:26:46 +0000 (18:26 +0200)
commit535ebd217d38dde481a927f21e6824d8b37bdb28
tree776409d99148c5f3754e05f69c725dbac0112513
parent43452335224bc0cbd605c6aee82b5c9c33e94cc6
i2c: mxs: remove races in PIO code

This commit fixes the three following races in PIO code:

- The CTRL0 register is racy in itself, when programming transfer state and
  run bit in the same cycle the hardware sometimes ends up using the state
  from the last transfer. Fix this by programming state in one cycle, make
  sure the write is flushed down APBX bus by reading back the reg and only
  then trigger the run bit.

- Only clear the DMAREQ bit in DEBUG0 after the read/write to the data reg
  happened. Otherwise we are racing with the hardware about who touches
  the data reg first.

- When checking for completion of a transfer it's not sufficient to check
  if the data engine finished, but also a check for i2c bus idle is needed.
  In PIO mode we are really fast to program the next transfer after a finished
  one, so the controller possibly tries to start a new transfer while the
  clkgen engine is still busy writing the NAK/STOP from the last transfer to
  the bus.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-mxs.c