linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bhaumik Bhatt <bbhatt@codeaurora.org>
To: manivannan.sadhasivam@linaro.org
Cc: linux-arm-msm@vger.kernel.org, hemantk@codeaurora.org,
	jhugo@codeaurora.org, linux-kernel@vger.kernel.org,
	carl.yin@quectel.com, naveen.kumar@quectel.com,
	loic.poulain@linaro.org, abickett@codeaurora.org,
	Bhaumik Bhatt <bbhatt@codeaurora.org>
Subject: [PATCH v1 3/7] bus: mhi: core: Handle EDL mode entry appropriately
Date: Mon, 29 Mar 2021 18:28:20 -0700	[thread overview]
Message-ID: <1617067704-28850-4-git-send-email-bbhatt@codeaurora.org> (raw)
In-Reply-To: <1617067704-28850-1-git-send-email-bbhatt@codeaurora.org>

Device entering EDL or Emergency Download Mode will be in a
SYS_ERROR MHI state. This requires MHI host to proceed with the
EDL image download over BHI before device can enter an MHI READY
state and proceed with further bootup. Allow this to be handled
by relying on the execution environment check after SYS_ERROR
processing to determine whether to wait for an MHI READY or
download the EDL image over BHI after moving MHI PM state to
Power on Reset internally. This way handling is contained well
within the MHI core driver and helps pave the way for Flash
Programmer execution environment functionality.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
---
 drivers/bus/mhi/core/pm.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
index fbe9447..b65222e 100644
--- a/drivers/bus/mhi/core/pm.c
+++ b/drivers/bus/mhi/core/pm.c
@@ -564,6 +564,7 @@ static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl)
 static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)
 {
 	enum mhi_pm_state cur_state, prev_state;
+	enum dev_st_transition next_state;
 	struct mhi_event *mhi_event;
 	struct mhi_cmd_ctxt *cmd_ctxt;
 	struct mhi_cmd *mhi_cmd;
@@ -677,7 +678,23 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)
 		er_ctxt->wp = er_ctxt->rbase;
 	}
 
-	mhi_ready_state_transition(mhi_cntrl);
+	/* Transition to next state */
+	if (MHI_IN_PBL(mhi_get_exec_env(mhi_cntrl))) {
+		write_lock_irq(&mhi_cntrl->pm_lock);
+		cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_POR);
+		write_unlock_irq(&mhi_cntrl->pm_lock);
+		if (cur_state != MHI_PM_POR) {
+			dev_err(dev, "Error moving to state %s from %s\n",
+				to_mhi_pm_state_str(MHI_PM_POR),
+				to_mhi_pm_state_str(cur_state));
+			goto exit_sys_error_transition;
+		}
+		next_state = DEV_ST_TRANSITION_PBL;
+	} else {
+		next_state = DEV_ST_TRANSITION_READY;
+	}
+
+	mhi_queue_state_transition(mhi_cntrl, next_state);
 
 exit_sys_error_transition:
 	dev_dbg(dev, "Exiting with PM state: %s, MHI state: %s\n",
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


  parent reply	other threads:[~2021-03-30  1:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30  1:28 [PATCH v1 0/7] MHI Emergency download and flash programmer support Bhaumik Bhatt
2021-03-30  1:28 ` [PATCH v1 1/7] bus: mhi: core: Rely on accurate method to determine EDL mode Bhaumik Bhatt
2021-03-30  8:00   ` Loic Poulain
2021-03-30  1:28 ` [PATCH v1 2/7] bus: mhi: core: Wait for ready after an EDL firmware download Bhaumik Bhatt
2021-03-30  8:01   ` Loic Poulain
2021-03-30  1:28 ` Bhaumik Bhatt [this message]
2021-03-30  8:01   ` [PATCH v1 3/7] bus: mhi: core: Handle EDL mode entry appropriately Loic Poulain
2021-03-31 10:59   ` Manivannan Sadhasivam
2021-03-30  1:28 ` [PATCH v1 4/7] bus: mhi: core: Add support for Flash Programmer execution environment Bhaumik Bhatt
2021-03-30  8:02   ` Loic Poulain
2021-03-31 11:11   ` Manivannan Sadhasivam
2021-03-30  1:28 ` [PATCH v1 5/7] bus: mhi: core: Identify Flash Programmer as a mission mode use case Bhaumik Bhatt
2021-03-30  8:02   ` Loic Poulain
2021-03-30  1:28 ` [PATCH v1 6/7] bus: mhi: core: Wait for MHI READY state in most scenarios Bhaumik Bhatt
2021-03-30  8:03   ` Loic Poulain
2021-03-31 11:13   ` Manivannan Sadhasivam
2021-03-30  1:28 ` [PATCH v1 7/7] bus: mhi: core: Improve state strings for debug messages Bhaumik Bhatt
2021-03-30  8:03   ` Loic Poulain
2021-03-31 11:16 ` [PATCH v1 0/7] MHI Emergency download and flash programmer support Manivannan Sadhasivam
2021-03-31 17:01   ` Bhaumik Bhatt
2021-03-31 11:24 ` Manivannan Sadhasivam
2021-05-26 19:03 ` patchwork-bot+linux-arm-msm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1617067704-28850-4-git-send-email-bbhatt@codeaurora.org \
    --to=bbhatt@codeaurora.org \
    --cc=abickett@codeaurora.org \
    --cc=carl.yin@quectel.com \
    --cc=hemantk@codeaurora.org \
    --cc=jhugo@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loic.poulain@linaro.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=naveen.kumar@quectel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).