drivers: mailbox: qti-tcs: Do not poll when holding a lock

->tcs_lock uses spin_lock() variant for locking access to the TCS when
writing a RPMH request and triggering them. The problem with this is
that a tasklet (scheduled by an IRQ handler) or the timeout wq, may
preempt the thread holding the spinlock and try to acquire the same
lock causing a spin bug. Replacing the spin_lock with spin_lock_irqX
variants solves the problem, but brings in another problem.

When holding a spin_lock_irqsave(), interrupts cannot preempt the core.
We are polling for the TCS status to become idle, which cannot be set
unless the interrupt handler is able to run. This will cause a forever
wait. To avoid this, check for the TCS is free and return -EBUSY if no
TCS is available or a previous request for the same resource is already
in pipeline. Releasing the spinlock, and a udelay allows the interrupt
handler to run, before we attempt to find a free TCS again.

Change-Id: I96d3e65ad2ff650ae0f21678cc37c5174026a50b
Signed-off-by: Lina Iyer <ilina@codeaurora.org>
1 file changed