bus: mhi: core: Fix race while handling SYS_ERR at power up
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Mon, 8 Nov 2021 07:35:50 +0000 (13:05 +0530)
committerManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Thu, 16 Dec 2021 07:09:33 +0000 (12:39 +0530)
commit7023e1a0fda51090b48323db3d9d9c3a84636e3f
tree084e0b395ad6ebd7844f0e438c0944b61f68c7a1
parent7d0f1a179005c96de6040a9dac00672d3b822b9b
bus: mhi: core: Fix race while handling SYS_ERR at power up

During SYS_ERR condition, as a response to the MHI_RESET from host, some
devices tend to issue BHI interrupt without clearing the SYS_ERR state in
the device. This creates a race condition and causes a failure in booting
up the device.

The issue is seen on the Sierra Wireless EM9191 modem during SYS_ERR
handling in mhi_async_power_up(). Once the host detects that the device
is in SYS_ERR state, it issues MHI_RESET and waits for the device to
process the reset request. During this time, the device triggers the BHI
interrupt to the host without clearing SYS_ERR condition. So the host
starts handling the SYS_ERR condition again.

To fix this issue, let's register the IRQ handler only after handling the
SYS_ERR check to avoid getting spurious IRQs from the device.

Cc: stable@vger.kernel.org
Fixes: e18d4e9fa79b ("bus: mhi: core: Handle syserr during power_up")
Reported-by: Aleksander Morgado <aleksander@aleksander.es>
Tested-by: Aleksander Morgado <aleksander@aleksander.es>
Tested-by: Thomas Perrot <thomas.perrot@bootlin.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
drivers/bus/mhi/core/pm.c