The I2C slave that I’m developing has been failing intermittently. I finally noticed this was a known bug in Raspberry Pi that mishandles clock stretching.
I2C slave may delay response by holding SCL low. However, when the slave does it, the I2C master in Raspberry Pi gives very short clock for the first bit of the next byte. The symptom can be seen as following picture.
More detail explanation can be read in this link:
http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html
In order to workaround this, I set data rate in I2C slave module higher. The communication rate is 400 kbps, but I set the data rate 1000 kbps. It worked for me. Here is the setup of I2C slave module.