soc: qcom: smsm: Fix missed interrupts if state changes while masked
authorStephan Gerhold <stephan@gerhold.net>
Mon, 12 Jul 2021 13:57:03 +0000 (15:57 +0200)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Thu, 5 Aug 2021 03:20:09 +0000 (22:20 -0500)
commite3d4571955050736bbf3eda0a9538a09d9fcfce8
tree7919def3bbbe9f9eebe32f1483e79f485c6fc2b7
parentc73a6852b42c8c80cc46590dbbcfa6c448fdbc63
soc: qcom: smsm: Fix missed interrupts if state changes while masked

The SMSM driver detects interrupt edges by tracking the last state
it has seen (and has triggered the interrupt handler for). This works
fine, but only if the interrupt does not change state while masked.

For example, if an interrupt is unmasked while the state is HIGH,
the stored last_value for that interrupt might still be LOW. Then,
when the remote processor triggers smsm_intr() we assume that nothing
has changed, even though the state might have changed from HIGH to LOW.

Attempt to fix this by checking the current remote state before
unmasking an IRQ. Use atomic operations to avoid the interrupt handler
from interfering with the unmask function.

This fixes modem crashes in some edge cases with the BAM-DMUX driver.
Specifically, the BAM-DMUX interrupt handler is not called for the
HIGH -> LOW smsm state transition if the BAM-DMUX driver is loaded
(and therefore unmasks the interrupt) after the modem was already started:

qcom-q6v5-mss 4080000.remoteproc: fatal error received: a2_task.c:3188:
  Assert FALSE failed: A2 DL PER deadlock timer expired waiting for Apps ACK

Fixes: c97c4090ff72 ("soc: qcom: smsm: Add driver for Qualcomm SMSM")
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Link: https://lore.kernel.org/r/20210712135703.324748-2-stephan@gerhold.net
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/soc/qcom/smsm.c