[PATCH v5 3/6] remoteproc: qcom: pas: Fix the PAS context creation placement

From: Mukesh Ojha

Date: Fri Jul 24 2026 - 14:33:56 EST


DTB PAS context creation should be done only for subsystems that support
a DTB firmware binary; otherwise, memory is wasted. Move the context
creation to the appropriate location.

Reviewed-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxxxxxxxx>
Signed-off-by: Mukesh Ojha <mukesh.ojha@xxxxxxxxxxxxxxxx>
---
drivers/remoteproc/qcom_q6v5_pas.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
index f70836cc382d..997b3a7ce672 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -702,6 +702,11 @@ static int qcom_pas_alloc_memory_region(struct qcom_pas *pas)
return PTR_ERR(pas->mem_region);
}

+ pas->pas_ctx = devm_qcom_pas_context_alloc(pas->dev, pas->pas_id,
+ pas->mem_phys, pas->mem_size);
+ if (IS_ERR(pas->pas_ctx))
+ return PTR_ERR(pas->pas_ctx);
+
if (!pas->dtb_pas_id)
return 0;

@@ -719,6 +724,12 @@ static int qcom_pas_alloc_memory_region(struct qcom_pas *pas)
return PTR_ERR(pas->dtb_mem_region);
}

+ pas->dtb_pas_ctx = devm_qcom_pas_context_alloc(pas->dev, pas->dtb_pas_id,
+ pas->dtb_mem_phys,
+ pas->dtb_mem_size);
+ if (IS_ERR(pas->dtb_pas_ctx))
+ return PTR_ERR(pas->dtb_pas_ctx);
+
return 0;
}

@@ -901,23 +912,9 @@ static int qcom_pas_probe(struct platform_device *pdev)

qcom_add_ssr_subdev(rproc, &pas->ssr_subdev, desc->ssr_name);

- pas->pas_ctx = devm_qcom_pas_context_alloc(pas->dev, pas->pas_id,
- pas->mem_phys, pas->mem_size);
- if (IS_ERR(pas->pas_ctx)) {
- ret = PTR_ERR(pas->pas_ctx);
- goto remove_ssr_sysmon;
- }
-
- pas->dtb_pas_ctx = devm_qcom_pas_context_alloc(pas->dev, pas->dtb_pas_id,
- pas->dtb_mem_phys,
- pas->dtb_mem_size);
- if (IS_ERR(pas->dtb_pas_ctx)) {
- ret = PTR_ERR(pas->dtb_pas_ctx);
- goto remove_ssr_sysmon;
- }
-
pas->pas_ctx->use_tzmem = desc->needs_tzmem || rproc->has_iommu;
- pas->dtb_pas_ctx->use_tzmem = desc->needs_tzmem || rproc->has_iommu;
+ if (pas->dtb_pas_id)
+ pas->dtb_pas_ctx->use_tzmem = desc->needs_tzmem || rproc->has_iommu;

if (desc->early_boot)
pas->rproc->state = RPROC_DETACHED;
--
2.53.0