drivers: thermal: limits-dcvs: Prevent race in freq limits polling

Thermal-core when setting a software cap, will write to the hardware by
making a scm call. The TZ will disable the frequency cap momentarily
before writing the new frequency cap and then re-enable it. During this
scm call transaction, if the polling thread in LMH DCVSh driver reads
the hardware limits, it will show that the CPUs are not throttling and
will enable the interrupt. But when the scm transaction is done, it will
disable the interrupt again.

There is a possibility software frequency cap first decrements the atomic
variable, indicating the interrupt is disabled, and gets context switched.
During this time frame if a hardware interrupt occurs, it can go in a
interrupt storm till the software frequency cap thread actually disables
the interrupt.

To avoid these race conditions protect the LMH DCVSh driver software
frequency write, polling thread and the interrupt handling.

Change-Id: I601bf2c99d6cc6525f3809043330b816bb3e8737
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
1 file changed