Skip to content

Commit 896bbce

Browse files
quic-jhugogregkh
authored andcommitted
bus: mhi: host: Fix conflict between power_up and SYSERR
commit 4d92e7c upstream. When mhi_async_power_up() enables IRQs, it is possible that we could receive a SYSERR notification from the device if the firmware has crashed for some reason. Then the SYSERR notification queues a work item that cannot execute until the pm_mutex is released by mhi_async_power_up(). So the SYSERR work item will be pending. If mhi_async_power_up() detects the SYSERR, it will handle it. If the device is in PBL, then the PBL state transition event will be queued, resulting in a work item after the pending SYSERR work item. Once mhi_async_power_up() releases the pm_mutex, the SYSERR work item can run. It will blindly attempt to reset the MHI state machine, which is the recovery action for SYSERR. PBL/SBL are not interrupt driven and will ignore the MHI Reset unless SYSERR is actively advertised. This will cause the SYSERR work item to timeout waiting for reset to be cleared, and will leave the host state in SYSERR processing. The PBL transition work item will then run, and immediately fail because SYSERR processing is not a valid state for PBL transition. This leaves the device uninitialized. This issue has a fairly unique signature in the kernel log: mhi mhi3: Requested to power ON Qualcomm Cloud AI 100 0000:36:00.0: Fatal error received from device. Attempting to recover mhi mhi3: Power on setup success mhi mhi3: Device failed to exit MHI Reset state mhi mhi3: Device MHI is not in valid state We cannot remove the SYSERR handling from mhi_async_power_up() because the device may be in the SYSERR state, but we missed the notification as the irq was fired before irqs were enabled. We also can't queue the SYSERR work item from mhi_async_power_up() if SYSERR is detected because that may result in a duplicate work item, and cause the same issue since the duplicate item will blindly issue MHI reset even if SYSERR is no longer active. Instead, add a check in the SYSERR work item to make sure that MHI reset is only issued if the device is in SYSERR state for PBL or SBL EEs. Fixes: a6e2e35 ("bus: mhi: core: Add support for PM state transitions") Signed-off-by: Jeffrey Hugo <[email protected]> Signed-off-by: Jeff Hugo <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Troy Hanson <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f704a80 commit 896bbce

File tree

1 file changed

+17
-1
lines changed
  • drivers/bus/mhi/host

1 file changed

+17
-1
lines changed

drivers/bus/mhi/host/pm.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)
602602
struct mhi_cmd *mhi_cmd;
603603
struct mhi_event_ctxt *er_ctxt;
604604
struct device *dev = &mhi_cntrl->mhi_dev->dev;
605+
bool reset_device = false;
605606
int ret, i;
606607

607608
dev_dbg(dev, "Transitioning from PM state: %s to: %s\n",
@@ -630,8 +631,23 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)
630631
/* Wake up threads waiting for state transition */
631632
wake_up_all(&mhi_cntrl->state_event);
632633

633-
/* Trigger MHI RESET so that the device will not access host memory */
634634
if (MHI_REG_ACCESS_VALID(prev_state)) {
635+
/*
636+
* If the device is in PBL or SBL, it will only respond to
637+
* RESET if the device is in SYSERR state. SYSERR might
638+
* already be cleared at this point.
639+
*/
640+
enum mhi_state cur_state = mhi_get_mhi_state(mhi_cntrl);
641+
enum mhi_ee_type cur_ee = mhi_get_exec_env(mhi_cntrl);
642+
643+
if (cur_state == MHI_STATE_SYS_ERR)
644+
reset_device = true;
645+
else if (cur_ee != MHI_EE_PBL && cur_ee != MHI_EE_SBL)
646+
reset_device = true;
647+
}
648+
649+
/* Trigger MHI RESET so that the device will not access host memory */
650+
if (reset_device) {
635651
u32 in_reset = -1;
636652
unsigned long timeout = msecs_to_jiffies(mhi_cntrl->timeout_ms);
637653

0 commit comments

Comments
 (0)