rtc: armada38x: fix concurrency access in armada38x_rtc_set_time
authorGregory CLEMENT <gregory.clement@free-electrons.com>
Tue, 5 May 2015 23:24:05 +0000 (16:24 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 6 May 2015 00:10:11 +0000 (17:10 -0700)
commit489405fe5ed38e65f6f82f131a39c67f3bae6045
treedb6e2324ac636c6421c7186b898913045f53eaf2
parentb1432a2a35565f538586774a03bf277c27fc267d
rtc: armada38x: fix concurrency access in armada38x_rtc_set_time

While setting the time, the RTC TIME register should not be accessed.
However due to hardware constraints, setting the RTC time involves
sleeping during 100ms.  This sleep was done outside the critical section
protected by the spinlock, so it was possible to read the RTC TIME
register and get an incorrect value.  This patch introduces a mutex for
protecting the RTC TIME access, unlike the spinlock it is allowed to
sleep in a critical section protected by a mutex.

The RTC STATUS register can still be used from the interrupt handler but
it has no effect on setting the time.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Andrew Lunn <andrew@lunn.ch>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: <stable@vger.kernel.org> [4.0]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/rtc/rtc-armada38x.c