]> git.baikalelectronics.ru Git - kernel.git/commit
i2c: tegra: proper handling of error cases
authorShardar Shariff Md <smohammed@nvidia.com>
Wed, 31 Aug 2016 13:28:44 +0000 (18:58 +0530)
committerWolfram Sang <wsa@the-dreams.de>
Thu, 8 Sep 2016 20:34:58 +0000 (22:34 +0200)
commita4e8ba8e7d31487133ceef9543aed2f3527e4657
treecff0edbebba4d9c52617e7e37f7f1d879e526e20
parent5bc1559621293a4a196d926e92b06201c403652e
i2c: tegra: proper handling of error cases

To summarize the issue observed in error cases:

SW Flow: For i2c message transfer, packet header and data payload is
posted and then required error/packet completion interrupts are enabled
later.

HW flow: HW process the packet just after packet header is posted, if
ARB lost/NACK error occurs (SW will not handle immediately when error
happens as error interrupts are not enabled at this point). HW assumes
error is acknowledged and clears current data in FIFO, But SW here posts
the remaining data payload which still stays in FIFO as stale data
(data without packet header).

Now once the interrupts are enabled, SW handles ARB lost/NACK error by
clearing the ARB lost/NACK interrupt. Now HW assumes that SW attended
the error and will parse/process stale data (data without packet header)
present in FIFO which causes invalid NACK errors.

Fix: Enable the error interrupts before posting the packet into FIFO
which make sure HW to not clear the fifo. Also disable the packet mode
before acknowledging errors (ARB lost/NACK error) to not process any
stale data. As error interrupts are enabled before posting the packet
header use spinlock to avoid preempting.

Signed-off-by: Shardar Shariff Md <smohammed@nvidia.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-tegra.c