msm: smd_pkt: fix wake lock locking race condition

When smd_pkt receives data for a client in userspace, smd_pkt locks a wake
lock to give the userspace client time to lock their own wake lock if
necessary.  Clients using poll() will trigger the unlocking of the wake
lock in smd_pkt, otherwise smd_pkt modifies the wake lock to expire in two
seconds.

Fix a race condition where smd_pkt locks the wake lock, the client reads
their data and triggers the unlocking, and then smd_pkt relocks the wake
lock when it modifies the timeout to two seconds.  This causes suspend to
be unnecessarily delayed.  The fix is to bypass setting the timeout if the
client has already read their data and triggered the unlocking of the wake
lock.

CRs-Fixed: 367001
Change-Id: I4e8f6975732a6139534fbeadc539e6f74ff3fce5
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
1 file changed