]> git.baikalelectronics.ru Git - kernel.git/commit
i2c: designware: wait for disable/enable only if necessary
authorJosé Roberto de Souza <jose.souza@intel.com>
Tue, 23 Aug 2016 22:18:53 +0000 (19:18 -0300)
committerWolfram Sang <wsa@the-dreams.de>
Thu, 25 Aug 2016 22:42:12 +0000 (00:42 +0200)
commit61027e07c8dc0678582b2e7141309515cf0a37ce
treeebe2ced9f736a3ef79e1da1f91e98eb7abf905d0
parenta7426ba7899716d4d24b2e0918aec4dd1723a8d7
i2c: designware: wait for disable/enable only if necessary

If we aren't going to continue using the controller we can just disable
it instead of waiting for it to complete. The biggest improvement here
is when a I2C transaction is completed and it doesn't block until
the adapter is disabled. When a new transfer is needed we will disable
and wait for its completion.

This way the adapter will continue changing its state in parallel to the
execution of the thread that requested the I2C transaction saving most
of the time 25~250 usec per I2C transaction.

A simple program doing a register read (1 byte write, 1 byte read)
alternating on 2 different slaves repeated 25k times for each and
measurements taken 4 times we get:

perf stat -r4 chrt -f 10 ./i2c-test /dev/i2c-1 25000 0x40 0x6 0x1e 0x00

Before:
30.879317977 seconds time elapsed                 ( +- 14.83% )
After:
8.638705161 seconds time elapsed                  ( +-  5.90% )

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Christian Ruppert <christian.ruppert@alitech.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-designware-core.c