Commit 96b55f6e authored by Eric Holmberg's avatar Eric Holmberg
Browse files

msm: smsm: Fix race condition in SMSM notification



The SMSM snapshot logic takes a snapshot of the current SMSM state,
places it into a FIFO, increments a wakelock count, and then signals a
worker to process the state changes.  The worker processes the state
changes and then decrements the wakelock count.

In the previous case, the code would do the following:

Interrupt handler:
 1) insert data into FIFO
 2) increment wakelock count

Worker:
 a) verifies >= 1 snapshots are in FIFO
 b) processes snapshot
 c) decrements wakelock reference count

If the interrupt handler is interrupted between steps 1 and 2, then the
function flow would be 1abc2.  In this case, step c would fail because
the wakelock count would be zero and the wakelock would remain at 1 and
locked even though the FIFO would be empty.  This results in the
wakelock not getting released.

To resolve this, the order of 2 (now 1') and 1 (now 2') was swapped
which always ensures 1' will always occur before abc which results in
the proper ordering 1'2'abc.

CRS-Fixed: 349099
Change-Id: I388b4c2f76838f59337e94f83b65fa06e81bb875
Signed-off-by: default avatarEric Holmberg <eholmber@codeaurora.org>
parent 83397213
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment