linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/7] MHI Emergency download and flash programmer support
@ 2021-03-30  1:28 Bhaumik Bhatt
  2021-03-30  1:28 ` [PATCH v1 1/7] bus: mhi: core: Rely on accurate method to determine EDL mode Bhaumik Bhatt
                   ` (9 more replies)
  0 siblings, 10 replies; 22+ messages in thread
From: Bhaumik Bhatt @ 2021-03-30  1:28 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett, Bhaumik Bhatt

Allow handling EDL mode after SYS_ERROR occurs by reading the execution
environment post handling and move to power on reset state to accommodate the
scenario.
Handle EDL mode properly and wait for ready instead of just exiting from the
firmware load.
Allow use of the Flash Programmer execution environment as a mission mode
use case for a blank NAND power up scenario.
Always attempt a wait for MHI ready state as device could be waiting for the
host to do so after pass through execution environment is seen.
Introduce patch to improve state awareness and aid in debugging.

This patch series was tested on x86_64 architecture.

Bhaumik Bhatt (6):
  bus: mhi: core: Rely on accurate method to determine EDL mode
  bus: mhi: core: Wait for ready after an EDL firmware download
  bus: mhi: core: Handle EDL mode entry appropriately
  bus: mhi: core: Identify Flash Programmer as a mission mode use case
  bus: mhi: core: Wait for MHI READY state in most scenarios
  bus: mhi: core: Improve state strings for debug messages

Carl Yin (1):
  bus: mhi: core: Add support for Flash Programmer execution environment

 drivers/bus/mhi/core/boot.c     | 13 +++++++------
 drivers/bus/mhi/core/init.c     | 34 ++++++++++++++++++----------------
 drivers/bus/mhi/core/internal.h |  4 +++-
 drivers/bus/mhi/core/main.c     |  3 +++
 drivers/bus/mhi/core/pm.c       | 28 +++++++++++++++++++++++++---
 include/linux/mhi.h             |  4 +++-
 6 files changed, 59 insertions(+), 27 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v1 1/7] bus: mhi: core: Rely on accurate method to determine EDL mode
  2021-03-30  1:28 [PATCH v1 0/7] MHI Emergency download and flash programmer support Bhaumik Bhatt
@ 2021-03-30  1:28 ` 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
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Bhaumik Bhatt @ 2021-03-30  1:28 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett, Bhaumik Bhatt

Relying on the current execution environment to determine if EDL
image was downloaded should not be done as the execution
environment can change at this point in error cases and we may
misread it. Instead, MHI can rely on the local 'fw_name' variable
as a safer alternative.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/core/boot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c
index 08c2874..84c2117 100644
--- a/drivers/bus/mhi/core/boot.c
+++ b/drivers/bus/mhi/core/boot.c
@@ -460,7 +460,8 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 		goto error_fw_load;
 	}
 
-	if (mhi_cntrl->ee == MHI_EE_EDL) {
+	/* Exit if EDL image was loaded */
+	if (fw_name == mhi_cntrl->edl_image) {
 		release_firmware(firmware);
 		return;
 	}
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v1 2/7] bus: mhi: core: Wait for ready after an EDL firmware download
  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  1:28 ` Bhaumik Bhatt
  2021-03-30  8:01   ` Loic Poulain
  2021-03-30  1:28 ` [PATCH v1 3/7] bus: mhi: core: Handle EDL mode entry appropriately Bhaumik Bhatt
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Bhaumik Bhatt @ 2021-03-30  1:28 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett, Bhaumik Bhatt

Currently, the firmware load handler returns after the EDL image
is downloaded. Wait for an MHI READY transition instead as the
specification expects so as to proceed with further bootup such
as device entering Flash Programmer execution environment.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/core/boot.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c
index 84c2117..0f0ae88 100644
--- a/drivers/bus/mhi/core/boot.c
+++ b/drivers/bus/mhi/core/boot.c
@@ -418,7 +418,7 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 
 	/* If device is in pass through, do reset to ready state transition */
 	if (mhi_cntrl->ee == MHI_EE_PTHRU)
-		goto fw_load_ee_pthru;
+		goto fw_load_ready_state;
 
 	fw_name = (mhi_cntrl->ee == MHI_EE_EDL) ?
 		mhi_cntrl->edl_image : mhi_cntrl->fw_image;
@@ -460,10 +460,10 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 		goto error_fw_load;
 	}
 
-	/* Exit if EDL image was loaded */
+	/* Wait for ready since EDL image was loaded */
 	if (fw_name == mhi_cntrl->edl_image) {
 		release_firmware(firmware);
-		return;
+		goto fw_load_ready_state;
 	}
 
 	write_lock_irq(&mhi_cntrl->pm_lock);
@@ -488,7 +488,7 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 
 	release_firmware(firmware);
 
-fw_load_ee_pthru:
+fw_load_ready_state:
 	/* Transitioning into MHI RESET->READY state */
 	ret = mhi_ready_state_transition(mhi_cntrl);
 	if (ret) {
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v1 3/7] bus: mhi: core: Handle EDL mode entry appropriately
  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  1:28 ` [PATCH v1 2/7] bus: mhi: core: Wait for ready after an EDL firmware download Bhaumik Bhatt
@ 2021-03-30  1:28 ` Bhaumik Bhatt
  2021-03-30  8:01   ` 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
                   ` (6 subsequent siblings)
  9 siblings, 2 replies; 22+ messages in thread
From: Bhaumik Bhatt @ 2021-03-30  1:28 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett, Bhaumik Bhatt

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


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v1 4/7] bus: mhi: core: Add support for Flash Programmer execution environment
  2021-03-30  1:28 [PATCH v1 0/7] MHI Emergency download and flash programmer support Bhaumik Bhatt
                   ` (2 preceding siblings ...)
  2021-03-30  1:28 ` [PATCH v1 3/7] bus: mhi: core: Handle EDL mode entry appropriately Bhaumik Bhatt
@ 2021-03-30  1:28 ` 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
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 22+ messages in thread
From: Bhaumik Bhatt @ 2021-03-30  1:28 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett, Bhaumik Bhatt

From: Carl Yin <carl.yin@quectel.com>

MHI WWAN modems support downloading firmware to NAND or eMMC
using Firehose protocol with process as follows:
1. Modem boots up, enters AMSS execution environment and the
device later enters EDL (Emergency Download) mode through any
mechanism host can use such as a diag command.
2. Modem enters SYS_ERROR, MHI host handles SYS_ERROR transition.
3. EDL image for device to enter 'Flash Programmer' execution
environment is then flashed via BHI interface from host.
4. Modem enters MHI READY -> M0 and sends the Flash Programmer
execution environment change to host.
5. Following that, EDL/FIREHOSE channels (34, 35) are made
available from the host.
6. User space tool for downloading firmware image to modem over
the EDL channels using Firehose protocol. Link to USB flashing
tool: https://git.linaro.org/landing-teams/working/qualcomm/qdl.git/

Make the necessary changes to allow for this sequence to occur and
allow using the Flash Programmer execution environment.

Signed-off-by: Carl Yin <carl.yin@quectel.com>
Co-developed-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
---
 drivers/bus/mhi/core/init.c     | 2 ++
 drivers/bus/mhi/core/internal.h | 1 +
 drivers/bus/mhi/core/main.c     | 3 +++
 drivers/bus/mhi/core/pm.c       | 6 ++++++
 include/linux/mhi.h             | 4 +++-
 5 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index 706484f..ee67712 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -29,6 +29,7 @@ const char * const mhi_ee_str[MHI_EE_MAX] = {
 	[MHI_EE_WFW] = "WFW",
 	[MHI_EE_PTHRU] = "PASS THRU",
 	[MHI_EE_EDL] = "EDL",
+	[MHI_EE_FP] = "FLASH PROGRAMMER",
 	[MHI_EE_DISABLE_TRANSITION] = "DISABLE",
 	[MHI_EE_NOT_SUPPORTED] = "NOT SUPPORTED",
 };
@@ -38,6 +39,7 @@ const char * const dev_state_tran_str[DEV_ST_TRANSITION_MAX] = {
 	[DEV_ST_TRANSITION_READY] = "READY",
 	[DEV_ST_TRANSITION_SBL] = "SBL",
 	[DEV_ST_TRANSITION_MISSION_MODE] = "MISSION_MODE",
+	[DEV_ST_TRANSITION_FP] = "FLASH_PROGRAMMER",
 	[DEV_ST_TRANSITION_SYS_ERR] = "SYS_ERR",
 	[DEV_ST_TRANSITION_DISABLE] = "DISABLE",
 };
diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h
index 6f37439..b1b5f2b 100644
--- a/drivers/bus/mhi/core/internal.h
+++ b/drivers/bus/mhi/core/internal.h
@@ -386,6 +386,7 @@ enum dev_st_transition {
 	DEV_ST_TRANSITION_READY,
 	DEV_ST_TRANSITION_SBL,
 	DEV_ST_TRANSITION_MISSION_MODE,
+	DEV_ST_TRANSITION_FP,
 	DEV_ST_TRANSITION_SYS_ERR,
 	DEV_ST_TRANSITION_DISABLE,
 	DEV_ST_TRANSITION_MAX,
diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
index d377d07..8b68657 100644
--- a/drivers/bus/mhi/core/main.c
+++ b/drivers/bus/mhi/core/main.c
@@ -831,6 +831,9 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
 			case MHI_EE_AMSS:
 				st = DEV_ST_TRANSITION_MISSION_MODE;
 				break;
+			case MHI_EE_FP:
+				st = DEV_ST_TRANSITION_FP;
+				break;
 			case MHI_EE_RDDM:
 				mhi_cntrl->status_cb(mhi_cntrl, MHI_CB_EE_RDDM);
 				write_lock_irq(&mhi_cntrl->pm_lock);
diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
index b65222e..7ac9dfe 100644
--- a/drivers/bus/mhi/core/pm.c
+++ b/drivers/bus/mhi/core/pm.c
@@ -782,6 +782,12 @@ void mhi_pm_st_worker(struct work_struct *work)
 		case DEV_ST_TRANSITION_MISSION_MODE:
 			mhi_pm_mission_mode_transition(mhi_cntrl);
 			break;
+		case DEV_ST_TRANSITION_FP:
+			write_lock_irq(&mhi_cntrl->pm_lock);
+			mhi_cntrl->ee = MHI_EE_FP;
+			write_unlock_irq(&mhi_cntrl->pm_lock);
+			mhi_create_devices(mhi_cntrl);
+			break;
 		case DEV_ST_TRANSITION_READY:
 			mhi_ready_state_transition(mhi_cntrl);
 			break;
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index 8f5bf40..b16afd3 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -117,6 +117,7 @@ struct mhi_link_info {
  * @MHI_EE_WFW: WLAN firmware mode
  * @MHI_EE_PTHRU: Passthrough
  * @MHI_EE_EDL: Embedded downloader
+ * @MHI_EE_FP: Flash Programmer Environment
  */
 enum mhi_ee_type {
 	MHI_EE_PBL,
@@ -126,7 +127,8 @@ enum mhi_ee_type {
 	MHI_EE_WFW,
 	MHI_EE_PTHRU,
 	MHI_EE_EDL,
-	MHI_EE_MAX_SUPPORTED = MHI_EE_EDL,
+	MHI_EE_FP,
+	MHI_EE_MAX_SUPPORTED = MHI_EE_FP,
 	MHI_EE_DISABLE_TRANSITION, /* local EE, not related to mhi spec */
 	MHI_EE_NOT_SUPPORTED,
 	MHI_EE_MAX,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v1 5/7] bus: mhi: core: Identify Flash Programmer as a mission mode use case
  2021-03-30  1:28 [PATCH v1 0/7] MHI Emergency download and flash programmer support Bhaumik Bhatt
                   ` (3 preceding siblings ...)
  2021-03-30  1:28 ` [PATCH v1 4/7] bus: mhi: core: Add support for Flash Programmer execution environment Bhaumik Bhatt
@ 2021-03-30  1:28 ` 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
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Bhaumik Bhatt @ 2021-03-30  1:28 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett, Bhaumik Bhatt

MHI power up can go through an EDL to Flash Programmer path when
the device has a blank NAND. In those cases, mhi_sync_power_up()
can timeout waiting for a mission mode execution environment.
Allow a successful power up instead by identifying Flash
Programmer as a valid mission mode execution environment with a
purpose to flash the device image contents.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/core/internal.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h
index b1b5f2b..7aa5cfd 100644
--- a/drivers/bus/mhi/core/internal.h
+++ b/drivers/bus/mhi/core/internal.h
@@ -379,7 +379,8 @@ extern const char * const mhi_ee_str[MHI_EE_MAX];
 #define MHI_IN_PBL(ee) (ee == MHI_EE_PBL || ee == MHI_EE_PTHRU || \
 			ee == MHI_EE_EDL)
 
-#define MHI_IN_MISSION_MODE(ee) (ee == MHI_EE_AMSS || ee == MHI_EE_WFW)
+#define MHI_IN_MISSION_MODE(ee) (ee == MHI_EE_AMSS || ee == MHI_EE_WFW || \
+				 ee == MHI_EE_FP)
 
 enum dev_st_transition {
 	DEV_ST_TRANSITION_PBL,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v1 6/7] bus: mhi: core: Wait for MHI READY state in most scenarios
  2021-03-30  1:28 [PATCH v1 0/7] MHI Emergency download and flash programmer support Bhaumik Bhatt
                   ` (4 preceding siblings ...)
  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  1:28 ` 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
                   ` (3 subsequent siblings)
  9 siblings, 2 replies; 22+ messages in thread
From: Bhaumik Bhatt @ 2021-03-30  1:28 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett, Bhaumik Bhatt

When moving from SYS_ERROR transition to a different execution
environment, MHI host relies on the BHI register read to spawn
the next image download or wait for READY -> M0 states. The
device can at times move the execution environment to mission
mode when a pass through is expected, which can result in a
stall. Initiate a wait for MHI READY and write M0 such that the
device can proceed with state change event updates for any new
execution environment being entered. This allows us to remove
conditionals in handling firmware load for PBL modes and keeps
the execution environment out of the picture as it can change at
any time.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
---
 drivers/bus/mhi/core/boot.c | 4 ++--
 drivers/bus/mhi/core/pm.c   | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c
index 0f0ae88..8100cf5 100644
--- a/drivers/bus/mhi/core/boot.c
+++ b/drivers/bus/mhi/core/boot.c
@@ -416,8 +416,8 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 		}
 	}
 
-	/* If device is in pass through, do reset to ready state transition */
-	if (mhi_cntrl->ee == MHI_EE_PTHRU)
+	/* wait for ready on pass through or any other execution environment */
+	if (mhi_cntrl->ee != MHI_EE_EDL && mhi_cntrl->ee != MHI_EE_PBL)
 		goto fw_load_ready_state;
 
 	fw_name = (mhi_cntrl->ee == MHI_EE_EDL) ?
diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
index 7ac9dfe..b6920a5 100644
--- a/drivers/bus/mhi/core/pm.c
+++ b/drivers/bus/mhi/core/pm.c
@@ -763,8 +763,7 @@ void mhi_pm_st_worker(struct work_struct *work)
 			if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state))
 				mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl);
 			write_unlock_irq(&mhi_cntrl->pm_lock);
-			if (MHI_IN_PBL(mhi_cntrl->ee))
-				mhi_fw_load_handler(mhi_cntrl);
+			mhi_fw_load_handler(mhi_cntrl);
 			break;
 		case DEV_ST_TRANSITION_SBL:
 			write_lock_irq(&mhi_cntrl->pm_lock);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v1 7/7] bus: mhi: core: Improve state strings for debug messages
  2021-03-30  1:28 [PATCH v1 0/7] MHI Emergency download and flash programmer support Bhaumik Bhatt
                   ` (5 preceding siblings ...)
  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  1:28 ` 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
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Bhaumik Bhatt @ 2021-03-30  1:28 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett, Bhaumik Bhatt

As of now abbreviations are being used for many state and
execution environment strings. Improve and expand those such that
debug messages are clear.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/core/init.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index ee67712..d1d9b0d 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -22,13 +22,13 @@
 static DEFINE_IDA(mhi_controller_ida);
 
 const char * const mhi_ee_str[MHI_EE_MAX] = {
-	[MHI_EE_PBL] = "PBL",
-	[MHI_EE_SBL] = "SBL",
-	[MHI_EE_AMSS] = "AMSS",
-	[MHI_EE_RDDM] = "RDDM",
-	[MHI_EE_WFW] = "WFW",
-	[MHI_EE_PTHRU] = "PASS THRU",
-	[MHI_EE_EDL] = "EDL",
+	[MHI_EE_PBL] = "PRIMARY BOOTLOADER",
+	[MHI_EE_SBL] = "SECONDARY BOOTLOADER",
+	[MHI_EE_AMSS] = "MISSION MODE",
+	[MHI_EE_RDDM] = "RAMDUMP DOWNLOAD MODE",
+	[MHI_EE_WFW] = "WLAN FIRMWARE",
+	[MHI_EE_PTHRU] = "PASS THROUGH",
+	[MHI_EE_EDL] = "EMERGENCY DOWNLOAD",
 	[MHI_EE_FP] = "FLASH PROGRAMMER",
 	[MHI_EE_DISABLE_TRANSITION] = "DISABLE",
 	[MHI_EE_NOT_SUPPORTED] = "NOT SUPPORTED",
@@ -38,9 +38,9 @@ const char * const dev_state_tran_str[DEV_ST_TRANSITION_MAX] = {
 	[DEV_ST_TRANSITION_PBL] = "PBL",
 	[DEV_ST_TRANSITION_READY] = "READY",
 	[DEV_ST_TRANSITION_SBL] = "SBL",
-	[DEV_ST_TRANSITION_MISSION_MODE] = "MISSION_MODE",
-	[DEV_ST_TRANSITION_FP] = "FLASH_PROGRAMMER",
-	[DEV_ST_TRANSITION_SYS_ERR] = "SYS_ERR",
+	[DEV_ST_TRANSITION_MISSION_MODE] = "MISSION MODE",
+	[DEV_ST_TRANSITION_FP] = "FLASH PROGRAMMER",
+	[DEV_ST_TRANSITION_SYS_ERR] = "SYS ERROR",
 	[DEV_ST_TRANSITION_DISABLE] = "DISABLE",
 };
 
@@ -51,24 +51,24 @@ const char * const mhi_state_str[MHI_STATE_MAX] = {
 	[MHI_STATE_M1] = "M1",
 	[MHI_STATE_M2] = "M2",
 	[MHI_STATE_M3] = "M3",
-	[MHI_STATE_M3_FAST] = "M3_FAST",
+	[MHI_STATE_M3_FAST] = "M3 FAST",
 	[MHI_STATE_BHI] = "BHI",
-	[MHI_STATE_SYS_ERR] = "SYS_ERR",
+	[MHI_STATE_SYS_ERR] = "SYS ERROR",
 };
 
 static const char * const mhi_pm_state_str[] = {
 	[MHI_PM_STATE_DISABLE] = "DISABLE",
-	[MHI_PM_STATE_POR] = "POR",
+	[MHI_PM_STATE_POR] = "POWER ON RESET",
 	[MHI_PM_STATE_M0] = "M0",
 	[MHI_PM_STATE_M2] = "M2",
 	[MHI_PM_STATE_M3_ENTER] = "M?->M3",
 	[MHI_PM_STATE_M3] = "M3",
 	[MHI_PM_STATE_M3_EXIT] = "M3->M0",
-	[MHI_PM_STATE_FW_DL_ERR] = "FW DL Error",
-	[MHI_PM_STATE_SYS_ERR_DETECT] = "SYS_ERR Detect",
-	[MHI_PM_STATE_SYS_ERR_PROCESS] = "SYS_ERR Process",
+	[MHI_PM_STATE_FW_DL_ERR] = "Firmware Download Error",
+	[MHI_PM_STATE_SYS_ERR_DETECT] = "SYS ERROR Detect",
+	[MHI_PM_STATE_SYS_ERR_PROCESS] = "SYS ERROR Process",
 	[MHI_PM_STATE_SHUTDOWN_PROCESS] = "SHUTDOWN Process",
-	[MHI_PM_STATE_LD_ERR_FATAL_DETECT] = "LD or Error Fatal Detect",
+	[MHI_PM_STATE_LD_ERR_FATAL_DETECT] = "Linkdown or Error Fatal Detect",
 };
 
 const char *to_mhi_pm_state_str(enum mhi_pm_state state)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 1/7] bus: mhi: core: Rely on accurate method to determine EDL mode
  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
  0 siblings, 0 replies; 22+ messages in thread
From: Loic Poulain @ 2021-03-30  8:00 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: Manivannan Sadhasivam, linux-arm-msm, Hemant Kumar, Jeffrey Hugo,
	open list, Carl Yin(殷张成),
	Naveen Kumar, abickett

On Tue, 30 Mar 2021 at 03:28, Bhaumik Bhatt <bbhatt@codeaurora.org> wrote:
>
> Relying on the current execution environment to determine if EDL
> image was downloaded should not be done as the execution
> environment can change at this point in error cases and we may
> misread it. Instead, MHI can rely on the local 'fw_name' variable
> as a safer alternative.
>
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 2/7] bus: mhi: core: Wait for ready after an EDL firmware download
  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
  0 siblings, 0 replies; 22+ messages in thread
From: Loic Poulain @ 2021-03-30  8:01 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: Manivannan Sadhasivam, linux-arm-msm, Hemant Kumar, Jeffrey Hugo,
	open list, Carl Yin(殷张成),
	Naveen Kumar, abickett

On Tue, 30 Mar 2021 at 03:28, Bhaumik Bhatt <bbhatt@codeaurora.org> wrote:
>
> Currently, the firmware load handler returns after the EDL image
> is downloaded. Wait for an MHI READY transition instead as the
> specification expects so as to proceed with further bootup such
> as device entering Flash Programmer execution environment.
>
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 3/7] bus: mhi: core: Handle EDL mode entry appropriately
  2021-03-30  1:28 ` [PATCH v1 3/7] bus: mhi: core: Handle EDL mode entry appropriately Bhaumik Bhatt
@ 2021-03-30  8:01   ` Loic Poulain
  2021-03-31 10:59   ` Manivannan Sadhasivam
  1 sibling, 0 replies; 22+ messages in thread
From: Loic Poulain @ 2021-03-30  8:01 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: Manivannan Sadhasivam, linux-arm-msm, Hemant Kumar, Jeffrey Hugo,
	open list, Carl Yin(殷张成),
	Naveen Kumar, abickett

On Tue, 30 Mar 2021 at 03:28, Bhaumik Bhatt <bbhatt@codeaurora.org> wrote:
>
> 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>

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 4/7] bus: mhi: core: Add support for Flash Programmer execution environment
  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
  1 sibling, 0 replies; 22+ messages in thread
From: Loic Poulain @ 2021-03-30  8:02 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: Manivannan Sadhasivam, linux-arm-msm, Hemant Kumar, Jeffrey Hugo,
	open list, Carl Yin(殷张成),
	Naveen Kumar, abickett

On Tue, 30 Mar 2021 at 03:28, Bhaumik Bhatt <bbhatt@codeaurora.org> wrote:
>
> From: Carl Yin <carl.yin@quectel.com>
>
> MHI WWAN modems support downloading firmware to NAND or eMMC
> using Firehose protocol with process as follows:
> 1. Modem boots up, enters AMSS execution environment and the
> device later enters EDL (Emergency Download) mode through any
> mechanism host can use such as a diag command.
> 2. Modem enters SYS_ERROR, MHI host handles SYS_ERROR transition.
> 3. EDL image for device to enter 'Flash Programmer' execution
> environment is then flashed via BHI interface from host.
> 4. Modem enters MHI READY -> M0 and sends the Flash Programmer
> execution environment change to host.
> 5. Following that, EDL/FIREHOSE channels (34, 35) are made
> available from the host.
> 6. User space tool for downloading firmware image to modem over
> the EDL channels using Firehose protocol. Link to USB flashing
> tool: https://git.linaro.org/landing-teams/working/qualcomm/qdl.git/
>
> Make the necessary changes to allow for this sequence to occur and
> allow using the Flash Programmer execution environment.
>
> Signed-off-by: Carl Yin <carl.yin@quectel.com>
> Co-developed-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 5/7] bus: mhi: core: Identify Flash Programmer as a mission mode use case
  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
  0 siblings, 0 replies; 22+ messages in thread
From: Loic Poulain @ 2021-03-30  8:02 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: Manivannan Sadhasivam, linux-arm-msm, Hemant Kumar, Jeffrey Hugo,
	open list, Carl Yin(殷张成),
	Naveen Kumar, abickett

On Tue, 30 Mar 2021 at 03:28, Bhaumik Bhatt <bbhatt@codeaurora.org> wrote:
>
> MHI power up can go through an EDL to Flash Programmer path when
> the device has a blank NAND. In those cases, mhi_sync_power_up()
> can timeout waiting for a mission mode execution environment.
> Allow a successful power up instead by identifying Flash
> Programmer as a valid mission mode execution environment with a
> purpose to flash the device image contents.
>
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 6/7] bus: mhi: core: Wait for MHI READY state in most scenarios
  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
  1 sibling, 0 replies; 22+ messages in thread
From: Loic Poulain @ 2021-03-30  8:03 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: Manivannan Sadhasivam, linux-arm-msm, Hemant Kumar, Jeffrey Hugo,
	open list, Carl Yin(殷张成),
	Naveen Kumar, abickett

On Tue, 30 Mar 2021 at 03:28, Bhaumik Bhatt <bbhatt@codeaurora.org> wrote:
>
> When moving from SYS_ERROR transition to a different execution
> environment, MHI host relies on the BHI register read to spawn
> the next image download or wait for READY -> M0 states. The
> device can at times move the execution environment to mission
> mode when a pass through is expected, which can result in a
> stall. Initiate a wait for MHI READY and write M0 such that the
> device can proceed with state change event updates for any new
> execution environment being entered. This allows us to remove
> conditionals in handling firmware load for PBL modes and keeps
> the execution environment out of the picture as it can change at
> any time.
>
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 7/7] bus: mhi: core: Improve state strings for debug messages
  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
  0 siblings, 0 replies; 22+ messages in thread
From: Loic Poulain @ 2021-03-30  8:03 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: Manivannan Sadhasivam, linux-arm-msm, Hemant Kumar, Jeffrey Hugo,
	open list, Carl Yin(殷张成),
	Naveen Kumar, abickett

On Tue, 30 Mar 2021 at 03:28, Bhaumik Bhatt <bbhatt@codeaurora.org> wrote:
>
> As of now abbreviations are being used for many state and
> execution environment strings. Improve and expand those such that
> debug messages are clear.
>
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 3/7] bus: mhi: core: Handle EDL mode entry appropriately
  2021-03-30  1:28 ` [PATCH v1 3/7] bus: mhi: core: Handle EDL mode entry appropriately Bhaumik Bhatt
  2021-03-30  8:01   ` Loic Poulain
@ 2021-03-31 10:59   ` Manivannan Sadhasivam
  1 sibling, 0 replies; 22+ messages in thread
From: Manivannan Sadhasivam @ 2021-03-31 10:59 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett

On Mon, Mar 29, 2021 at 06:28:20PM -0700, Bhaumik Bhatt wrote:
> 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>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Thanks,
Mani

> ---
>  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
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 4/7] bus: mhi: core: Add support for Flash Programmer execution environment
  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
  1 sibling, 0 replies; 22+ messages in thread
From: Manivannan Sadhasivam @ 2021-03-31 11:11 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett

On Mon, Mar 29, 2021 at 06:28:21PM -0700, Bhaumik Bhatt wrote:
> From: Carl Yin <carl.yin@quectel.com>
> 
> MHI WWAN modems support downloading firmware to NAND or eMMC
> using Firehose protocol with process as follows:
> 1. Modem boots up, enters AMSS execution environment and the
> device later enters EDL (Emergency Download) mode through any
> mechanism host can use such as a diag command.
> 2. Modem enters SYS_ERROR, MHI host handles SYS_ERROR transition.
> 3. EDL image for device to enter 'Flash Programmer' execution
> environment is then flashed via BHI interface from host.
> 4. Modem enters MHI READY -> M0 and sends the Flash Programmer
> execution environment change to host.
> 5. Following that, EDL/FIREHOSE channels (34, 35) are made
> available from the host.
> 6. User space tool for downloading firmware image to modem over
> the EDL channels using Firehose protocol. Link to USB flashing
> tool: https://git.linaro.org/landing-teams/working/qualcomm/qdl.git/
> 
> Make the necessary changes to allow for this sequence to occur and
> allow using the Flash Programmer execution environment.
> 
> Signed-off-by: Carl Yin <carl.yin@quectel.com>
> Co-developed-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Thanks,
Mani

> ---
>  drivers/bus/mhi/core/init.c     | 2 ++
>  drivers/bus/mhi/core/internal.h | 1 +
>  drivers/bus/mhi/core/main.c     | 3 +++
>  drivers/bus/mhi/core/pm.c       | 6 ++++++
>  include/linux/mhi.h             | 4 +++-
>  5 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 706484f..ee67712 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -29,6 +29,7 @@ const char * const mhi_ee_str[MHI_EE_MAX] = {
>  	[MHI_EE_WFW] = "WFW",
>  	[MHI_EE_PTHRU] = "PASS THRU",
>  	[MHI_EE_EDL] = "EDL",
> +	[MHI_EE_FP] = "FLASH PROGRAMMER",
>  	[MHI_EE_DISABLE_TRANSITION] = "DISABLE",
>  	[MHI_EE_NOT_SUPPORTED] = "NOT SUPPORTED",
>  };
> @@ -38,6 +39,7 @@ const char * const dev_state_tran_str[DEV_ST_TRANSITION_MAX] = {
>  	[DEV_ST_TRANSITION_READY] = "READY",
>  	[DEV_ST_TRANSITION_SBL] = "SBL",
>  	[DEV_ST_TRANSITION_MISSION_MODE] = "MISSION_MODE",
> +	[DEV_ST_TRANSITION_FP] = "FLASH_PROGRAMMER",
>  	[DEV_ST_TRANSITION_SYS_ERR] = "SYS_ERR",
>  	[DEV_ST_TRANSITION_DISABLE] = "DISABLE",
>  };
> diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h
> index 6f37439..b1b5f2b 100644
> --- a/drivers/bus/mhi/core/internal.h
> +++ b/drivers/bus/mhi/core/internal.h
> @@ -386,6 +386,7 @@ enum dev_st_transition {
>  	DEV_ST_TRANSITION_READY,
>  	DEV_ST_TRANSITION_SBL,
>  	DEV_ST_TRANSITION_MISSION_MODE,
> +	DEV_ST_TRANSITION_FP,
>  	DEV_ST_TRANSITION_SYS_ERR,
>  	DEV_ST_TRANSITION_DISABLE,
>  	DEV_ST_TRANSITION_MAX,
> diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
> index d377d07..8b68657 100644
> --- a/drivers/bus/mhi/core/main.c
> +++ b/drivers/bus/mhi/core/main.c
> @@ -831,6 +831,9 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
>  			case MHI_EE_AMSS:
>  				st = DEV_ST_TRANSITION_MISSION_MODE;
>  				break;
> +			case MHI_EE_FP:
> +				st = DEV_ST_TRANSITION_FP;
> +				break;
>  			case MHI_EE_RDDM:
>  				mhi_cntrl->status_cb(mhi_cntrl, MHI_CB_EE_RDDM);
>  				write_lock_irq(&mhi_cntrl->pm_lock);
> diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
> index b65222e..7ac9dfe 100644
> --- a/drivers/bus/mhi/core/pm.c
> +++ b/drivers/bus/mhi/core/pm.c
> @@ -782,6 +782,12 @@ void mhi_pm_st_worker(struct work_struct *work)
>  		case DEV_ST_TRANSITION_MISSION_MODE:
>  			mhi_pm_mission_mode_transition(mhi_cntrl);
>  			break;
> +		case DEV_ST_TRANSITION_FP:
> +			write_lock_irq(&mhi_cntrl->pm_lock);
> +			mhi_cntrl->ee = MHI_EE_FP;
> +			write_unlock_irq(&mhi_cntrl->pm_lock);
> +			mhi_create_devices(mhi_cntrl);
> +			break;
>  		case DEV_ST_TRANSITION_READY:
>  			mhi_ready_state_transition(mhi_cntrl);
>  			break;
> diff --git a/include/linux/mhi.h b/include/linux/mhi.h
> index 8f5bf40..b16afd3 100644
> --- a/include/linux/mhi.h
> +++ b/include/linux/mhi.h
> @@ -117,6 +117,7 @@ struct mhi_link_info {
>   * @MHI_EE_WFW: WLAN firmware mode
>   * @MHI_EE_PTHRU: Passthrough
>   * @MHI_EE_EDL: Embedded downloader
> + * @MHI_EE_FP: Flash Programmer Environment
>   */
>  enum mhi_ee_type {
>  	MHI_EE_PBL,
> @@ -126,7 +127,8 @@ enum mhi_ee_type {
>  	MHI_EE_WFW,
>  	MHI_EE_PTHRU,
>  	MHI_EE_EDL,
> -	MHI_EE_MAX_SUPPORTED = MHI_EE_EDL,
> +	MHI_EE_FP,
> +	MHI_EE_MAX_SUPPORTED = MHI_EE_FP,
>  	MHI_EE_DISABLE_TRANSITION, /* local EE, not related to mhi spec */
>  	MHI_EE_NOT_SUPPORTED,
>  	MHI_EE_MAX,
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 6/7] bus: mhi: core: Wait for MHI READY state in most scenarios
  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
  1 sibling, 0 replies; 22+ messages in thread
From: Manivannan Sadhasivam @ 2021-03-31 11:13 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett

On Mon, Mar 29, 2021 at 06:28:23PM -0700, Bhaumik Bhatt wrote:
> When moving from SYS_ERROR transition to a different execution
> environment, MHI host relies on the BHI register read to spawn
> the next image download or wait for READY -> M0 states. The
> device can at times move the execution environment to mission
> mode when a pass through is expected, which can result in a
> stall. Initiate a wait for MHI READY and write M0 such that the
> device can proceed with state change event updates for any new
> execution environment being entered. This allows us to remove
> conditionals in handling firmware load for PBL modes and keeps
> the execution environment out of the picture as it can change at
> any time.
> 
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Thanks,
Mani

> ---
>  drivers/bus/mhi/core/boot.c | 4 ++--
>  drivers/bus/mhi/core/pm.c   | 3 +--
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c
> index 0f0ae88..8100cf5 100644
> --- a/drivers/bus/mhi/core/boot.c
> +++ b/drivers/bus/mhi/core/boot.c
> @@ -416,8 +416,8 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
>  		}
>  	}
>  
> -	/* If device is in pass through, do reset to ready state transition */
> -	if (mhi_cntrl->ee == MHI_EE_PTHRU)
> +	/* wait for ready on pass through or any other execution environment */
> +	if (mhi_cntrl->ee != MHI_EE_EDL && mhi_cntrl->ee != MHI_EE_PBL)
>  		goto fw_load_ready_state;
>  
>  	fw_name = (mhi_cntrl->ee == MHI_EE_EDL) ?
> diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
> index 7ac9dfe..b6920a5 100644
> --- a/drivers/bus/mhi/core/pm.c
> +++ b/drivers/bus/mhi/core/pm.c
> @@ -763,8 +763,7 @@ void mhi_pm_st_worker(struct work_struct *work)
>  			if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state))
>  				mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl);
>  			write_unlock_irq(&mhi_cntrl->pm_lock);
> -			if (MHI_IN_PBL(mhi_cntrl->ee))
> -				mhi_fw_load_handler(mhi_cntrl);
> +			mhi_fw_load_handler(mhi_cntrl);
>  			break;
>  		case DEV_ST_TRANSITION_SBL:
>  			write_lock_irq(&mhi_cntrl->pm_lock);
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 0/7] MHI Emergency download and flash programmer support
  2021-03-30  1:28 [PATCH v1 0/7] MHI Emergency download and flash programmer support Bhaumik Bhatt
                   ` (6 preceding siblings ...)
  2021-03-30  1:28 ` [PATCH v1 7/7] bus: mhi: core: Improve state strings for debug messages Bhaumik Bhatt
@ 2021-03-31 11:16 ` 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
  9 siblings, 1 reply; 22+ messages in thread
From: Manivannan Sadhasivam @ 2021-03-31 11:16 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett

On Mon, Mar 29, 2021 at 06:28:17PM -0700, Bhaumik Bhatt wrote:
> Allow handling EDL mode after SYS_ERROR occurs by reading the execution
> environment post handling and move to power on reset state to accommodate the
> scenario.
> Handle EDL mode properly and wait for ready instead of just exiting from the
> firmware load.
> Allow use of the Flash Programmer execution environment as a mission mode
> use case for a blank NAND power up scenario.
> Always attempt a wait for MHI ready state as device could be waiting for the
> host to do so after pass through execution environment is seen.
> Introduce patch to improve state awareness and aid in debugging.
> 
> This patch series was tested on x86_64 architecture.
> 

These patches were part of a different series before. It is good that
you splitted the patches but you should mention that here.

Thanks,
Mani

> Bhaumik Bhatt (6):
>   bus: mhi: core: Rely on accurate method to determine EDL mode
>   bus: mhi: core: Wait for ready after an EDL firmware download
>   bus: mhi: core: Handle EDL mode entry appropriately
>   bus: mhi: core: Identify Flash Programmer as a mission mode use case
>   bus: mhi: core: Wait for MHI READY state in most scenarios
>   bus: mhi: core: Improve state strings for debug messages
> 
> Carl Yin (1):
>   bus: mhi: core: Add support for Flash Programmer execution environment
> 
>  drivers/bus/mhi/core/boot.c     | 13 +++++++------
>  drivers/bus/mhi/core/init.c     | 34 ++++++++++++++++++----------------
>  drivers/bus/mhi/core/internal.h |  4 +++-
>  drivers/bus/mhi/core/main.c     |  3 +++
>  drivers/bus/mhi/core/pm.c       | 28 +++++++++++++++++++++++++---
>  include/linux/mhi.h             |  4 +++-
>  6 files changed, 59 insertions(+), 27 deletions(-)
> 
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 0/7] MHI Emergency download and flash programmer support
  2021-03-30  1:28 [PATCH v1 0/7] MHI Emergency download and flash programmer support Bhaumik Bhatt
                   ` (7 preceding siblings ...)
  2021-03-31 11:16 ` [PATCH v1 0/7] MHI Emergency download and flash programmer support Manivannan Sadhasivam
@ 2021-03-31 11:24 ` Manivannan Sadhasivam
  2021-05-26 19:03 ` patchwork-bot+linux-arm-msm
  9 siblings, 0 replies; 22+ messages in thread
From: Manivannan Sadhasivam @ 2021-03-31 11:24 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett

On Mon, Mar 29, 2021 at 06:28:17PM -0700, Bhaumik Bhatt wrote:
> Allow handling EDL mode after SYS_ERROR occurs by reading the execution
> environment post handling and move to power on reset state to accommodate the
> scenario.
> Handle EDL mode properly and wait for ready instead of just exiting from the
> firmware load.
> Allow use of the Flash Programmer execution environment as a mission mode
> use case for a blank NAND power up scenario.
> Always attempt a wait for MHI ready state as device could be waiting for the
> host to do so after pass through execution environment is seen.
> Introduce patch to improve state awareness and aid in debugging.
> 
> This patch series was tested on x86_64 architecture.
> 

Applied to mhi-next!

Thanks,
Mani

> Bhaumik Bhatt (6):
>   bus: mhi: core: Rely on accurate method to determine EDL mode
>   bus: mhi: core: Wait for ready after an EDL firmware download
>   bus: mhi: core: Handle EDL mode entry appropriately
>   bus: mhi: core: Identify Flash Programmer as a mission mode use case
>   bus: mhi: core: Wait for MHI READY state in most scenarios
>   bus: mhi: core: Improve state strings for debug messages
> 
> Carl Yin (1):
>   bus: mhi: core: Add support for Flash Programmer execution environment
> 
>  drivers/bus/mhi/core/boot.c     | 13 +++++++------
>  drivers/bus/mhi/core/init.c     | 34 ++++++++++++++++++----------------
>  drivers/bus/mhi/core/internal.h |  4 +++-
>  drivers/bus/mhi/core/main.c     |  3 +++
>  drivers/bus/mhi/core/pm.c       | 28 +++++++++++++++++++++++++---
>  include/linux/mhi.h             |  4 +++-
>  6 files changed, 59 insertions(+), 27 deletions(-)
> 
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 0/7] MHI Emergency download and flash programmer support
  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
  0 siblings, 0 replies; 22+ messages in thread
From: Bhaumik Bhatt @ 2021-03-31 17:01 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, carl.yin,
	naveen.kumar, loic.poulain, abickett

Hi Mani,
On 2021-03-31 04:16 AM, Manivannan Sadhasivam wrote:
> On Mon, Mar 29, 2021 at 06:28:17PM -0700, Bhaumik Bhatt wrote:
>> Allow handling EDL mode after SYS_ERROR occurs by reading the 
>> execution
>> environment post handling and move to power on reset state to 
>> accommodate the
>> scenario.
>> Handle EDL mode properly and wait for ready instead of just exiting 
>> from the
>> firmware load.
>> Allow use of the Flash Programmer execution environment as a mission 
>> mode
>> use case for a blank NAND power up scenario.
>> Always attempt a wait for MHI ready state as device could be waiting 
>> for the
>> host to do so after pass through execution environment is seen.
>> Introduce patch to improve state awareness and aid in debugging.
>> 
>> This patch series was tested on x86_64 architecture.
>> 
> 
> These patches were part of a different series before. It is good that
> you splitted the patches but you should mention that here.
> 
> Thanks,
> Mani
> 
I will keep that in mind when submitting next time.

>> Bhaumik Bhatt (6):
>>   bus: mhi: core: Rely on accurate method to determine EDL mode
>>   bus: mhi: core: Wait for ready after an EDL firmware download
>>   bus: mhi: core: Handle EDL mode entry appropriately
>>   bus: mhi: core: Identify Flash Programmer as a mission mode use case
>>   bus: mhi: core: Wait for MHI READY state in most scenarios
>>   bus: mhi: core: Improve state strings for debug messages
>> 
>> Carl Yin (1):
>>   bus: mhi: core: Add support for Flash Programmer execution 
>> environment
>> 
>>  drivers/bus/mhi/core/boot.c     | 13 +++++++------
>>  drivers/bus/mhi/core/init.c     | 34 
>> ++++++++++++++++++----------------
>>  drivers/bus/mhi/core/internal.h |  4 +++-
>>  drivers/bus/mhi/core/main.c     |  3 +++
>>  drivers/bus/mhi/core/pm.c       | 28 +++++++++++++++++++++++++---
>>  include/linux/mhi.h             |  4 +++-
>>  6 files changed, 59 insertions(+), 27 deletions(-)
>> 
>> --
>> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
>> Forum,
>> a Linux Foundation Collaborative Project
>> 

Thanks,
Bhaumik
---
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 0/7] MHI Emergency download and flash programmer support
  2021-03-30  1:28 [PATCH v1 0/7] MHI Emergency download and flash programmer support Bhaumik Bhatt
                   ` (8 preceding siblings ...)
  2021-03-31 11:24 ` Manivannan Sadhasivam
@ 2021-05-26 19:03 ` patchwork-bot+linux-arm-msm
  9 siblings, 0 replies; 22+ messages in thread
From: patchwork-bot+linux-arm-msm @ 2021-05-26 19:03 UTC (permalink / raw)
  To: Bhaumik Bhatt; +Cc: linux-arm-msm

Hello:

This series was applied to qcom/linux.git (refs/heads/for-next):

On Mon, 29 Mar 2021 18:28:17 -0700 you wrote:
> Allow handling EDL mode after SYS_ERROR occurs by reading the execution
> environment post handling and move to power on reset state to accommodate the
> scenario.
> Handle EDL mode properly and wait for ready instead of just exiting from the
> firmware load.
> Allow use of the Flash Programmer execution environment as a mission mode
> use case for a blank NAND power up scenario.
> Always attempt a wait for MHI ready state as device could be waiting for the
> host to do so after pass through execution environment is seen.
> Introduce patch to improve state awareness and aid in debugging.
> 
> [...]

Here is the summary with links:
  - [v1,1/7] bus: mhi: core: Rely on accurate method to determine EDL mode
    https://git.kernel.org/qcom/c/418bec695696
  - [v1,2/7] bus: mhi: core: Wait for ready after an EDL firmware download
    https://git.kernel.org/qcom/c/4f214496ac74
  - [v1,3/7] bus: mhi: core: Handle EDL mode entry appropriately
    https://git.kernel.org/qcom/c/ad416db9fabe
  - [v1,4/7] bus: mhi: core: Add support for Flash Programmer execution environment
    https://git.kernel.org/qcom/c/66ac7985b2af
  - [v1,5/7] bus: mhi: core: Identify Flash Programmer as a mission mode use case
    https://git.kernel.org/qcom/c/d20e82d4d016
  - [v1,6/7] bus: mhi: core: Wait for MHI READY state in most scenarios
    https://git.kernel.org/qcom/c/e72919cebd19
  - [v1,7/7] bus: mhi: core: Improve state strings for debug messages
    https://git.kernel.org/qcom/c/19e60d6e88a6

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-05-26 19:03 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v1 3/7] bus: mhi: core: Handle EDL mode entry appropriately Bhaumik Bhatt
2021-03-30  8:01   ` 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

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox