Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8e9c3c5 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mhi: core: Add extra checks for RDDM event handling"

parents 687c0ac9 ebae8aac
Loading
Loading
Loading
Loading
+26 −8
Original line number Diff line number Diff line
@@ -1206,19 +1206,21 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
				enum MHI_PM_STATE new_state;

				/*
				 * Don't process sys error if device support
				 * rddm since we will be processing rddm ee
				 * event instead of sys error state change event
				 * Allow move to SYS_ERROR even if RDDM is
				 * supported so that core driver is inactive
				 * with anticipation of an upcoming RDDM event
				 */
				if (mhi_cntrl->ee == MHI_EE_RDDM ||
				    mhi_cntrl->rddm_supported)
					break;

				MHI_ERR("MHI system error detected\n");
				write_lock_irq(&mhi_cntrl->pm_lock);
				/* skip if RDDM event was already processed */
				if (mhi_cntrl->ee == MHI_EE_RDDM) {
					write_unlock_irq(&mhi_cntrl->pm_lock);
					break;
				}
				new_state = mhi_tryset_pm_state(mhi_cntrl,
							MHI_PM_SYS_ERR_DETECT);
				write_unlock_irq(&mhi_cntrl->pm_lock);

				MHI_ERR("MHI system error detected\n");
				if (new_state == MHI_PM_SYS_ERR_DETECT)
					mhi_process_sys_err(mhi_cntrl);
				break;
@@ -1256,6 +1258,22 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
				st = MHI_ST_TRANSITION_MISSION_MODE;
				break;
			case MHI_EE_RDDM:
				if (mhi_cntrl->ee == MHI_EE_RDDM ||
				    mhi_cntrl->power_down)
					break;

				MHI_ERR("RDDM event occurred!\n");
				write_lock_irq(&mhi_cntrl->pm_lock);
				mhi_cntrl->ee = MHI_EE_RDDM;
				write_unlock_irq(&mhi_cntrl->pm_lock);

				/* notify critical clients */
				mhi_control_error(mhi_cntrl);

				mhi_cntrl->status_cb(mhi_cntrl,
						     mhi_cntrl->priv_data,
						     MHI_CB_EE_RDDM);
				wake_up_all(&mhi_cntrl->state_event);
				break;
			default:
				MHI_ERR("Unhandled EE event:%s\n",
+24 −2
Original line number Diff line number Diff line
@@ -101,8 +101,9 @@ static struct mhi_pm_transitions const mhi_state_transitions[] = {
	},
	{
		MHI_PM_SYS_ERR_DETECT,
		MHI_PM_SYS_ERR_PROCESS | MHI_PM_SHUTDOWN_PROCESS |
		MHI_PM_LD_ERR_FATAL_DETECT | MHI_PM_SHUTDOWN_NO_ACCESS
		MHI_PM_DEVICE_ERR_DETECT | MHI_PM_SYS_ERR_PROCESS |
		MHI_PM_SHUTDOWN_PROCESS | MHI_PM_LD_ERR_FATAL_DETECT |
		MHI_PM_SHUTDOWN_NO_ACCESS
	},
	{
		MHI_PM_SYS_ERR_PROCESS,
@@ -1493,6 +1494,26 @@ int mhi_pm_fast_resume(struct mhi_controller *mhi_cntrl, bool notify_client)
		return -EIO;
	}

	if (mhi_cntrl->rddm_supported) {
		if (mhi_get_exec_env(mhi_cntrl) == MHI_EE_RDDM &&
		    !mhi_cntrl->power_down) {
			mhi_cntrl->ee = MHI_EE_RDDM;
			write_unlock_irq(&mhi_cntrl->pm_lock);

			MHI_ERR("RDDM event occurred!\n");

			/* notify critical clients with early notifications */
			mhi_control_error(mhi_cntrl);

			mhi_cntrl->status_cb(mhi_cntrl, mhi_cntrl->priv_data,
					     MHI_CB_EE_RDDM);
			wake_up_all(&mhi_cntrl->state_event);

			tasklet_enable(&mhi_cntrl->mhi_event->task);
			goto exit_pm_fast_resume;
		}
	}

	/* restore the states */
	mhi_cntrl->pm_state = mhi_cntrl->saved_pm_state;
	mhi_cntrl->dev_state = mhi_cntrl->saved_dev_state;
@@ -1536,6 +1557,7 @@ int mhi_pm_fast_resume(struct mhi_controller *mhi_cntrl, bool notify_client)
	/* schedules worker if any special purpose events need to be handled */
	mhi_special_events_pending(mhi_cntrl);

exit_pm_fast_resume:
	MHI_LOG("Exit with pm_state:%s dev_state:%s\n",
		to_mhi_pm_state_str(mhi_cntrl->pm_state),
		TO_MHI_STATE_STR(mhi_cntrl->dev_state));