[PATCH v4] remoteproc: qcom_q6v5_mss: support loading MBN file on msm8974

Dmitry Baryshkov posted 1 patch 3 months ago
drivers/remoteproc/qcom_q6v5_mss.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
[PATCH v4] remoteproc: qcom_q6v5_mss: support loading MBN file on msm8974
Posted by Dmitry Baryshkov 3 months ago
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

On MSM8974 / APQ8074, MSM8226 and MSM8926 the MSS requires loading raw
MBA image instead of the ELF file. Skip the ELF headers if mba.mbn was
specified as the firmware image.

Fixes: a5a4e02d083d ("remoteproc: qcom: Add support for parsing fw dt bindings")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
Changes in v4:
- Expanded to cover MSM8226 and MSM8926.
- Link to v3: https://lore.kernel.org/r/20250706-msm8974-fix-mss-v3-1-8b5ae61c86a9@oss.qualcomm.com

Changes in v3:
- Reverted back to the simple patch from v1
- Added define for 0x1000 (Konrad)
- Added MBA firmware size check
- Corrected the Fixes tag to point to the commit adding firmware-name
  support
- Link to v2: https://lore.kernel.org/r/20230508153524.2371795-1-dmitry.baryshkov@linaro.org

Changes in v2:
- Replace fixed offset 0x1000 with the value obtained from ELF headers
- Implement ELF validity checks
- Link to v1: https://lore.kernel.org/r/20230507172041.2320279-1-dmitry.baryshkov@linaro.org
---
 drivers/remoteproc/qcom_q6v5_mss.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
index 0c0199fb0e68d6286f1e238d110539554d1d5f14..636f00d481ea80508fc9db28d8e2e225ea52372c 100644
--- a/drivers/remoteproc/qcom_q6v5_mss.c
+++ b/drivers/remoteproc/qcom_q6v5_mss.c
@@ -498,6 +498,8 @@ static void q6v5_debug_policy_load(struct q6v5 *qproc, void *mba_region)
 	release_firmware(dp_fw);
 }
 
+#define MSM8974_B00_OFFSET 0x1000
+
 static int q6v5_load(struct rproc *rproc, const struct firmware *fw)
 {
 	struct q6v5 *qproc = rproc->priv;
@@ -516,7 +518,16 @@ static int q6v5_load(struct rproc *rproc, const struct firmware *fw)
 		return -EBUSY;
 	}
 
-	memcpy(mba_region, fw->data, fw->size);
+	if ((qproc->version == MSS_MSM8974 ||
+	     qproc->version == MSS_MSM8226 ||
+	     qproc->version == MSS_MSM8926) &&
+	    fw->size > MSM8974_B00_OFFSET &&
+	    !memcmp(fw->data, ELFMAG, SELFMAG))
+		memcpy(mba_region,
+		       fw->data + MSM8974_B00_OFFSET,
+		       fw->size - MSM8974_B00_OFFSET);
+	else
+		memcpy(mba_region, fw->data, fw->size);
 	q6v5_debug_policy_load(qproc, mba_region);
 	memunmap(mba_region);
 

---
base-commit: b12a9fa1c88a441daa33f15edfa3ded8cd6d3556
change-id: 20250706-msm8974-fix-mss-e1b8e114b7e0

Best regards,
-- 
With best wishes
Dmitry
Re: [PATCH v4] remoteproc: qcom_q6v5_mss: support loading MBN file on msm8974
Posted by Bjorn Andersson 2 weeks, 1 day ago
On Sun, 06 Jul 2025 17:47:08 +0300, Dmitry Baryshkov wrote:
> On MSM8974 / APQ8074, MSM8226 and MSM8926 the MSS requires loading raw
> MBA image instead of the ELF file. Skip the ELF headers if mba.mbn was
> specified as the firmware image.
> 
> 

Applied, thanks!

[1/1] remoteproc: qcom_q6v5_mss: support loading MBN file on msm8974
      commit: 581e3dea0ece4b59cf714c9dfe195a178d3ae13b

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>
Re: [PATCH v4] remoteproc: qcom_q6v5_mss: support loading MBN file on msm8974
Posted by Dmitry Baryshkov 3 weeks, 6 days ago
On Sun, Jul 06, 2025 at 05:47:08PM +0300, Dmitry Baryshkov wrote:
> From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> 
> On MSM8974 / APQ8074, MSM8226 and MSM8926 the MSS requires loading raw
> MBA image instead of the ELF file. Skip the ELF headers if mba.mbn was
> specified as the firmware image.
> 
> Fixes: a5a4e02d083d ("remoteproc: qcom: Add support for parsing fw dt bindings")
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---
> Changes in v4:
> - Expanded to cover MSM8226 and MSM8926.
> - Link to v3: https://lore.kernel.org/r/20250706-msm8974-fix-mss-v3-1-8b5ae61c86a9@oss.qualcomm.com
> 
> Changes in v3:
> - Reverted back to the simple patch from v1
> - Added define for 0x1000 (Konrad)
> - Added MBA firmware size check
> - Corrected the Fixes tag to point to the commit adding firmware-name
>   support
> - Link to v2: https://lore.kernel.org/r/20230508153524.2371795-1-dmitry.baryshkov@linaro.org
> 
> Changes in v2:
> - Replace fixed offset 0x1000 with the value obtained from ELF headers
> - Implement ELF validity checks
> - Link to v1: https://lore.kernel.org/r/20230507172041.2320279-1-dmitry.baryshkov@linaro.org
> ---
>  drivers/remoteproc/qcom_q6v5_mss.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
And gracious ping...

-- 
With best wishes
Dmitry
Re: [PATCH v4] remoteproc: qcom_q6v5_mss: support loading MBN file on msm8974
Posted by Luca Weiss 3 months ago
On 06-07-2025 4:47 p.m., Dmitry Baryshkov wrote:
> From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> 
> On MSM8974 / APQ8074, MSM8226 and MSM8926 the MSS requires loading raw
> MBA image instead of the ELF file. Skip the ELF headers if mba.mbn was
> specified as the firmware image.

Appears to work on my msm8974pro-fairphone-fp2!

Tested-by: Luca Weiss <luca@lucaweiss.eu> # msm8974pro-fairphone-fp2

[  175.530764] remoteproc remoteproc1: powering up fc880000.remoteproc
[  175.544439] remoteproc remoteproc1: Booting fw image mba.mbn, size 299792
[  177.707706] qcom-q6v5-mss fc880000.remoteproc: MBA booted without 
debug policy, loading mpss
[  180.375633] remoteproc remoteproc1: remote processor 
fc880000.remoteproc is now up
[  180.841751] wwan wwan0: port wwan0at0 attached
[  180.846972] wwan wwan0: port wwan0at1 attached
[  181.004199] wwan wwan0: port wwan0qmi0 attached
(this is with 'firmware-name = "mba.mbn", "modem.mbn";')

I can also test on other MSM8974 devices and MSM8926 if you think that's 
useful.

Regards
Luca

> 
> Fixes: a5a4e02d083d ("remoteproc: qcom: Add support for parsing fw dt bindings")
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---
> Changes in v4:
> - Expanded to cover MSM8226 and MSM8926.
> - Link to v3: https://lore.kernel.org/r/20250706-msm8974-fix-mss-v3-1-8b5ae61c86a9@oss.qualcomm.com
> 
> Changes in v3:
> - Reverted back to the simple patch from v1
> - Added define for 0x1000 (Konrad)
> - Added MBA firmware size check
> - Corrected the Fixes tag to point to the commit adding firmware-name
>    support
> - Link to v2: https://lore.kernel.org/r/20230508153524.2371795-1-dmitry.baryshkov@linaro.org
> 
> Changes in v2:
> - Replace fixed offset 0x1000 with the value obtained from ELF headers
> - Implement ELF validity checks
> - Link to v1: https://lore.kernel.org/r/20230507172041.2320279-1-dmitry.baryshkov@linaro.org
> ---
>   drivers/remoteproc/qcom_q6v5_mss.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
> index 0c0199fb0e68d6286f1e238d110539554d1d5f14..636f00d481ea80508fc9db28d8e2e225ea52372c 100644
> --- a/drivers/remoteproc/qcom_q6v5_mss.c
> +++ b/drivers/remoteproc/qcom_q6v5_mss.c
> @@ -498,6 +498,8 @@ static void q6v5_debug_policy_load(struct q6v5 *qproc, void *mba_region)
>   	release_firmware(dp_fw);
>   }
>   
> +#define MSM8974_B00_OFFSET 0x1000
> +
>   static int q6v5_load(struct rproc *rproc, const struct firmware *fw)
>   {
>   	struct q6v5 *qproc = rproc->priv;
> @@ -516,7 +518,16 @@ static int q6v5_load(struct rproc *rproc, const struct firmware *fw)
>   		return -EBUSY;
>   	}
>   
> -	memcpy(mba_region, fw->data, fw->size);
> +	if ((qproc->version == MSS_MSM8974 ||
> +	     qproc->version == MSS_MSM8226 ||
> +	     qproc->version == MSS_MSM8926) &&
> +	    fw->size > MSM8974_B00_OFFSET &&
> +	    !memcmp(fw->data, ELFMAG, SELFMAG))
> +		memcpy(mba_region,
> +		       fw->data + MSM8974_B00_OFFSET,
> +		       fw->size - MSM8974_B00_OFFSET);
> +	else
> +		memcpy(mba_region, fw->data, fw->size);
>   	q6v5_debug_policy_load(qproc, mba_region);
>   	memunmap(mba_region);
>   
> 
> ---
> base-commit: b12a9fa1c88a441daa33f15edfa3ded8cd6d3556
> change-id: 20250706-msm8974-fix-mss-e1b8e114b7e0
> 
> Best regards,