All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Fix serial number usage in MHI bus
@ 2021-07-16  0:27 Bhaumik Bhatt
  2021-07-16  0:27 ` [PATCH v1 1/2] bus: mhi: core: Read serial number during pre-powerup phase Bhaumik Bhatt
  2021-07-16  0:27 ` [PATCH v1 2/2] bus: mhi: core: Depict serial number in hexadecimals Bhaumik Bhatt
  0 siblings, 2 replies; 5+ messages in thread
From: Bhaumik Bhatt @ 2021-07-16  0:27 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, quic_jhugo, linux-kernel, loic.poulain,
	Bhaumik Bhatt

In some cases, device may boot straight to the mission mode. The serial number
and OEM PK hash values would remain unpopulated in those cases. Hence, move the
reads for those to the power up preparation phase such that controllers always
have them populated. Also, in order to maintain consistency with the way OEM PK
hash is displayed and improve the current way, depict serial number in upper
case hexadecimals.

Note: This patch series needs to be picked up after patch:
878789cad00d ("bus: mhi: core: Set BHI/BHIe offsets on power up preparation")

Bhaumik Bhatt (2):
  bus: mhi: core: Read serial number during pre-powerup phase
  bus: mhi: core: Depict serial number in hexadecimals

 drivers/bus/mhi/core/boot.c | 17 +----------------
 drivers/bus/mhi/core/init.c | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 18 deletions(-)

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


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

* [PATCH v1 1/2] bus: mhi: core: Read serial number during pre-powerup phase
  2021-07-16  0:27 [PATCH v1 0/2] Fix serial number usage in MHI bus Bhaumik Bhatt
@ 2021-07-16  0:27 ` Bhaumik Bhatt
  2021-07-16  5:42   ` Manivannan Sadhasivam
  2021-07-16  0:27 ` [PATCH v1 2/2] bus: mhi: core: Depict serial number in hexadecimals Bhaumik Bhatt
  1 sibling, 1 reply; 5+ messages in thread
From: Bhaumik Bhatt @ 2021-07-16  0:27 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, quic_jhugo, linux-kernel, loic.poulain,
	Bhaumik Bhatt

In some cases, device may boot straight to the mission mode
execution environment and skip the PBL transition or firmware
load procedure. Serial number and OEM PK hash values would remain
unpopulated in those scenarios. Move the reads for those to the
power up preparation phase such that controllers always have them
populated.

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

diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c
index 8100cf5..213307ab 100644
--- a/drivers/bus/mhi/core/boot.c
+++ b/drivers/bus/mhi/core/boot.c
@@ -394,28 +394,13 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 	void *buf;
 	dma_addr_t dma_addr;
 	size_t size;
-	int i, ret;
+	int ret;
 
 	if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) {
 		dev_err(dev, "Device MHI is not in valid state\n");
 		return;
 	}
 
-	/* save hardware info from BHI */
-	ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_SERIALNU,
-			   &mhi_cntrl->serial_number);
-	if (ret)
-		dev_err(dev, "Could not capture serial number via BHI\n");
-
-	for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++) {
-		ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_OEMPKHASH(i),
-				   &mhi_cntrl->oem_pk_hash[i]);
-		if (ret) {
-			dev_err(dev, "Could not capture OEM PK HASH via BHI\n");
-			break;
-		}
-	}
-
 	/* 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;
diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index aeb1e3c..8b4336e 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -1065,7 +1065,7 @@ int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl)
 {
 	struct device *dev = &mhi_cntrl->mhi_dev->dev;
 	u32 bhi_off, bhie_off;
-	int ret;
+	int i, ret;
 
 	mutex_lock(&mhi_cntrl->pm_mutex);
 
@@ -1124,6 +1124,21 @@ int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl)
 
 	mutex_unlock(&mhi_cntrl->pm_mutex);
 
+	/* save hardware info from BHI */
+	ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_SERIALNU,
+			   &mhi_cntrl->serial_number);
+	if (ret)
+		dev_err(dev, "Could not capture serial number via BHI\n");
+
+	for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++) {
+		ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_OEMPKHASH(i),
+				   &mhi_cntrl->oem_pk_hash[i]);
+		if (ret) {
+			dev_err(dev, "Could not capture OEM PK HASH via BHI\n");
+			break;
+		}
+	}
+
 	return 0;
 
 error_reg_offset:
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* [PATCH v1 2/2] bus: mhi: core: Depict serial number in hexadecimals
  2021-07-16  0:27 [PATCH v1 0/2] Fix serial number usage in MHI bus Bhaumik Bhatt
  2021-07-16  0:27 ` [PATCH v1 1/2] bus: mhi: core: Read serial number during pre-powerup phase Bhaumik Bhatt
@ 2021-07-16  0:27 ` Bhaumik Bhatt
  2021-07-16  5:40   ` Manivannan Sadhasivam
  1 sibling, 1 reply; 5+ messages in thread
From: Bhaumik Bhatt @ 2021-07-16  0:27 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, quic_jhugo, linux-kernel, loic.poulain,
	Bhaumik Bhatt

In order to maintain consistency with the way OEM PK hash is
displayed and improve the current way, depict serial number in
upper case hexadecimals.

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

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index 8b4336e..d825a06 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -94,7 +94,7 @@ static ssize_t serial_number_show(struct device *dev,
 	struct mhi_device *mhi_dev = to_mhi_device(dev);
 	struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
 
-	return snprintf(buf, PAGE_SIZE, "Serial Number: %u\n",
+	return snprintf(buf, PAGE_SIZE, "Serial Number: 0x%X\n",
 			mhi_cntrl->serial_number);
 }
 static DEVICE_ATTR_RO(serial_number);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* Re: [PATCH v1 2/2] bus: mhi: core: Depict serial number in hexadecimals
  2021-07-16  0:27 ` [PATCH v1 2/2] bus: mhi: core: Depict serial number in hexadecimals Bhaumik Bhatt
@ 2021-07-16  5:40   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2021-07-16  5:40 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: linux-arm-msm, hemantk, quic_jhugo, linux-kernel, loic.poulain

On Thu, Jul 15, 2021 at 05:27:56PM -0700, Bhaumik Bhatt wrote:
> In order to maintain consistency with the way OEM PK hash is
> displayed and improve the current way, depict serial number in
> upper case hexadecimals.
> 
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>

Just a minor nit, other than that:

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

Thanks,
Mani

> ---
>  drivers/bus/mhi/core/init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 8b4336e..d825a06 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -94,7 +94,7 @@ static ssize_t serial_number_show(struct device *dev,
>  	struct mhi_device *mhi_dev = to_mhi_device(dev);
>  	struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
>  
> -	return snprintf(buf, PAGE_SIZE, "Serial Number: %u\n",
> +	return snprintf(buf, PAGE_SIZE, "Serial Number: 0x%X\n",

nit: please use "0x%x"

>  			mhi_cntrl->serial_number);
>  }
>  static DEVICE_ATTR_RO(serial_number);
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

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

* Re: [PATCH v1 1/2] bus: mhi: core: Read serial number during pre-powerup phase
  2021-07-16  0:27 ` [PATCH v1 1/2] bus: mhi: core: Read serial number during pre-powerup phase Bhaumik Bhatt
@ 2021-07-16  5:42   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2021-07-16  5:42 UTC (permalink / raw)
  To: Bhaumik Bhatt
  Cc: linux-arm-msm, hemantk, quic_jhugo, linux-kernel, loic.poulain

On Thu, Jul 15, 2021 at 05:27:55PM -0700, Bhaumik Bhatt wrote:
> In some cases, device may boot straight to the mission mode
> execution environment and skip the PBL transition or firmware
> load procedure. Serial number and OEM PK hash values would remain
> unpopulated in those scenarios. Move the reads for those to the
> power up preparation phase such that controllers always have them
> populated.
> 
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>

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

Thanks,
Mani

> ---
>  drivers/bus/mhi/core/boot.c | 17 +----------------
>  drivers/bus/mhi/core/init.c | 17 ++++++++++++++++-
>  2 files changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c
> index 8100cf5..213307ab 100644
> --- a/drivers/bus/mhi/core/boot.c
> +++ b/drivers/bus/mhi/core/boot.c
> @@ -394,28 +394,13 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
>  	void *buf;
>  	dma_addr_t dma_addr;
>  	size_t size;
> -	int i, ret;
> +	int ret;
>  
>  	if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) {
>  		dev_err(dev, "Device MHI is not in valid state\n");
>  		return;
>  	}
>  
> -	/* save hardware info from BHI */
> -	ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_SERIALNU,
> -			   &mhi_cntrl->serial_number);
> -	if (ret)
> -		dev_err(dev, "Could not capture serial number via BHI\n");
> -
> -	for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++) {
> -		ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_OEMPKHASH(i),
> -				   &mhi_cntrl->oem_pk_hash[i]);
> -		if (ret) {
> -			dev_err(dev, "Could not capture OEM PK HASH via BHI\n");
> -			break;
> -		}
> -	}
> -
>  	/* 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;
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index aeb1e3c..8b4336e 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -1065,7 +1065,7 @@ int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl)
>  {
>  	struct device *dev = &mhi_cntrl->mhi_dev->dev;
>  	u32 bhi_off, bhie_off;
> -	int ret;
> +	int i, ret;
>  
>  	mutex_lock(&mhi_cntrl->pm_mutex);
>  
> @@ -1124,6 +1124,21 @@ int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl)
>  
>  	mutex_unlock(&mhi_cntrl->pm_mutex);
>  
> +	/* save hardware info from BHI */
> +	ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_SERIALNU,
> +			   &mhi_cntrl->serial_number);
> +	if (ret)
> +		dev_err(dev, "Could not capture serial number via BHI\n");
> +
> +	for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++) {
> +		ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_OEMPKHASH(i),
> +				   &mhi_cntrl->oem_pk_hash[i]);
> +		if (ret) {
> +			dev_err(dev, "Could not capture OEM PK HASH via BHI\n");
> +			break;
> +		}
> +	}
> +
>  	return 0;
>  
>  error_reg_offset:
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

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

end of thread, other threads:[~2021-07-16  5:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16  0:27 [PATCH v1 0/2] Fix serial number usage in MHI bus Bhaumik Bhatt
2021-07-16  0:27 ` [PATCH v1 1/2] bus: mhi: core: Read serial number during pre-powerup phase Bhaumik Bhatt
2021-07-16  5:42   ` Manivannan Sadhasivam
2021-07-16  0:27 ` [PATCH v1 2/2] bus: mhi: core: Depict serial number in hexadecimals Bhaumik Bhatt
2021-07-16  5:40   ` Manivannan Sadhasivam

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.