[PATCH v2 5/5] bus: host: mhi: Need to honor sys_err at power_up state

Vivek.Pernamitta@quicinc.com posted 5 patches 2 months, 4 weeks ago
There is a newer version of this series
[PATCH v2 5/5] bus: host: mhi: Need to honor sys_err at power_up state
Posted by Vivek.Pernamitta@quicinc.com 2 months, 4 weeks ago
From: Vivek Pernamitta <quic_vpernami@quicinc.com>

In mhi_sync_power_up() host waits for device to enter in to mission mode
but SYS_ERR is an valid state, If device sends an SYS_ERR host will bail
out for wait_event_timeout() as MHI is in error state and if MHI is tear
downed sys err cant't be serviced and mhi can't be recovered.

If there is any SYS_ERR, sys_err handler needs to process SYS_ERR state
and queues the next state transition for device to bring in to Mission
mode, so mhi_sync_power_up() needs to wait for device to enter in to
mission mode.

Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
---
 drivers/bus/mhi/host/internal.h | 2 ++
 drivers/bus/mhi/host/pm.c       | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/host/internal.h b/drivers/bus/mhi/host/internal.h
index 1054e67bb450d2634771d092ed42bbdd63380472..1aec3bb68f9712f5476b0fc3efd8b2efc4d745dc 100644
--- a/drivers/bus/mhi/host/internal.h
+++ b/drivers/bus/mhi/host/internal.h
@@ -170,6 +170,8 @@ enum mhi_pm_state {
 							MHI_PM_IN_ERROR_STATE(pm_state))
 #define MHI_PM_IN_SUSPEND_STATE(pm_state)		(pm_state & \
 							(MHI_PM_M3_ENTER | MHI_PM_M3))
+#define MHI_PM_IN_UNRECOVERABLE_ERROR(pm_state)		((pm_state == MHI_PM_FW_DL_ERR) || \
+							(pm_state >= MHI_PM_SYS_ERR_FAIL))
 
 #define NR_OF_CMD_RINGS					1
 #define CMD_EL_PER_RING					128
diff --git a/drivers/bus/mhi/host/pm.c b/drivers/bus/mhi/host/pm.c
index 2af34980e14250cada75c981b690bc9581715212..fc9713d4021571aebd995a4524eafbcf0128fbd1 100644
--- a/drivers/bus/mhi/host/pm.c
+++ b/drivers/bus/mhi/host/pm.c
@@ -1280,7 +1280,7 @@ int mhi_sync_power_up(struct mhi_controller *mhi_cntrl)
 		mhi_cntrl->ready_timeout_ms : mhi_cntrl->timeout_ms;
 	wait_event_timeout(mhi_cntrl->state_event,
 			   MHI_IN_MISSION_MODE(mhi_cntrl->ee) ||
-			   MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state),
+			   MHI_PM_IN_UNRECOVERABLE_ERROR(mhi_cntrl->pm_state),
 			   msecs_to_jiffies(timeout_ms));
 
 	ret = (MHI_IN_MISSION_MODE(mhi_cntrl->ee)) ? 0 : -ETIMEDOUT;

-- 
2.34.1
Re: [PATCH v2 5/5] bus: host: mhi: Need to honor sys_err at power_up state
Posted by Konrad Dybcio 2 months, 4 weeks ago
On 7/10/25 10:58 AM, Vivek.Pernamitta@quicinc.com wrote:
> From: Vivek Pernamitta <quic_vpernami@quicinc.com>
> 
> In mhi_sync_power_up() host waits for device to enter in to mission mode
> but SYS_ERR is an valid state, If device sends an SYS_ERR host will bail
> out for wait_event_timeout() as MHI is in error state and if MHI is tear
> downed sys err cant't be serviced and mhi can't be recovered.
> 
> If there is any SYS_ERR, sys_err handler needs to process SYS_ERR state
> and queues the next state transition for device to bring in to Mission
> mode, so mhi_sync_power_up() needs to wait for device to enter in to
> mission mode.

This is very difficult to read, please rephrase the commit message

Konrad
Re: [PATCH v2 5/5] bus: host: mhi: Need to honor sys_err at power_up state
Posted by Manivannan Sadhasivam 2 months ago
On Thu, Jul 10, 2025 at 02:46:51PM GMT, Konrad Dybcio wrote:
> On 7/10/25 10:58 AM, Vivek.Pernamitta@quicinc.com wrote:
> > From: Vivek Pernamitta <quic_vpernami@quicinc.com>
> > 
> > In mhi_sync_power_up() host waits for device to enter in to mission mode
> > but SYS_ERR is an valid state, If device sends an SYS_ERR host will bail
> > out for wait_event_timeout() as MHI is in error state and if MHI is tear
> > downed sys err cant't be serviced and mhi can't be recovered.
> > 
> > If there is any SYS_ERR, sys_err handler needs to process SYS_ERR state
> > and queues the next state transition for device to bring in to Mission
> > mode, so mhi_sync_power_up() needs to wait for device to enter in to
> > mission mode.
> 
> This is very difficult to read, please rephrase the commit message
> 

+1

- Mani

-- 
மணிவண்ணன் சதாசிவம்