Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bus: mhi: core: Handle syserr during power_up

The MHI device may be in the syserr state when we attempt to init it in
power_up(). Since we have no local state, the handling is simple -
reset the device and wait for it to transition out of the reset state.

Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
Reviewed-by: Hemant Kumar <hemantk@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20200521170249.21795-15-manivannan.sadhasivam@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jeffrey Hugo and committed by
Greg Kroah-Hartman
e18d4e9f 3bc1a5f4

+27
+27
drivers/bus/mhi/core/pm.c
··· 906 906 907 907 int mhi_async_power_up(struct mhi_controller *mhi_cntrl) 908 908 { 909 + enum mhi_state state; 909 910 enum mhi_ee_type current_ee; 910 911 enum dev_st_transition next_state; 911 912 struct device *dev = &mhi_cntrl->mhi_dev->dev; ··· 974 973 dev_err(dev, "Not a valid EE for power on\n"); 975 974 ret = -EIO; 976 975 goto error_bhi_offset; 976 + } 977 + 978 + state = mhi_get_mhi_state(mhi_cntrl); 979 + if (state == MHI_STATE_SYS_ERR) { 980 + mhi_set_mhi_state(mhi_cntrl, MHI_STATE_RESET); 981 + ret = wait_event_timeout(mhi_cntrl->state_event, 982 + MHI_PM_IN_FATAL_STATE(mhi_cntrl->pm_state) || 983 + mhi_read_reg_field(mhi_cntrl, 984 + mhi_cntrl->regs, 985 + MHICTRL, 986 + MHICTRL_RESET_MASK, 987 + MHICTRL_RESET_SHIFT, 988 + &val) || 989 + !val, 990 + msecs_to_jiffies(mhi_cntrl->timeout_ms)); 991 + if (ret) { 992 + ret = -EIO; 993 + dev_info(dev, "Failed to reset MHI due to syserr state\n"); 994 + goto error_bhi_offset; 995 + } 996 + 997 + /* 998 + * device cleares INTVEC as part of RESET processing, 999 + * re-program it 1000 + */ 1001 + mhi_write_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_INTVEC, 0); 977 1002 } 978 1003 979 1004 /* Transition to next state */