CHROMIUM: i2c-s3c2410: use exponential back off while polling for bus idle
authorDaniel Kurtz <djkurtz@chromium.org>
Thu, 16 Aug 2012 12:25:35 +0000 (20:25 +0800)
committerGerrit <chrome-bot@google.com>
Fri, 17 Aug 2012 08:22:04 +0000 (01:22 -0700)
commitcebb2fcc0013233f3db8d59d648fab44cd792929
tree95a34565b9de9247e95948f20fa6c1259d932760
parent7803d9775835d08b4b2cf48582cb0250d3ce06e7
CHROMIUM: i2c-s3c2410: use exponential back off while polling for bus idle

Usually, the i2c controller has finished emitting the i2c STOP before the
driver reaches the bus idle polling loop.  Optimize for this most common
case by reading IICSTAT first and potentially skipping the loop.

If the cpu is faster than the hardware, we wait for bus idle in a polling
loop.  However, since the duration of one iteration of the loop is
dependent on cpu freq, and this i2c IP is used on many different systems,
use a time based loop timeout (5 ms).

We would like very low latencies to detect bus idle for the normal
'fast' case.  However, if a device is slow to release the bus for some
reason, it could hold off the STOP generation for up to several
milliseconds.  Rapidly polling for bus idle would seriously load the CPU
while waiting for it to release the bus.  So, use a partial exponential
backoff as a compromise between idle detection latency and cpu load.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
BUG=chrome-os-partner:12003
TEST=On s3c2400 system with cyapa touchpad attached to an i2c port...
TEST=Confirm no large/small EV_SYN/SYN_REPORT gaps when moving finger:
  evtest | awk 'BEGIN{P=0} /SYN_REPORT/ {print ($3-P) " " $3; P=$3}'

Change-Id: Ifbcaaef413c50ef5463238af606512e3ea32a206
Reviewed-on: https://gerrit.chromium.org/gerrit/29031
Reviewed-by: Olof Johansson <olofj@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Commit-Ready: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
drivers/i2c/busses/i2c-s3c2410.c