Skip to content

Commit a4584bf

Browse files
mukeshojha-linuxandersson
authored andcommitted
remoteproc: pas: Extend parse_fw callback to fetch resources via SMC call
Qualcomm remote processor may rely on static and dynamic resources for it to be functional. For most of the Qualcomm SoCs, when run with Gunyah or older QHEE hypervisor, all the resources whether it is static or dynamic, is managed by the hypervisor. Dynamic resources if it is present for a remote processor will always be coming from secure world via SMC call while static resources may be present in remote processor firmware binary or it may be coming from SMC call along with dynamic resources. Remoteproc already has method like rproc_elf_load_rsc_table() to check firmware binary has resources or not and if it is not having then we pass NULL and zero as input resource table and its size argument respectively to qcom_scm_pas_get_rsc_table() and while it has resource present then it should pass the present resources to Trustzone(TZ) so that it could authenticate the present resources and append dynamic resource to return in output_rt argument along with authenticated resources. Extend parse_fw callback to include SMC call to get resources from Trustzone and to leverage resource table parsing and mapping and unmapping code from the remoteproc framework. Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260105-kvmrprocv10-v10-12-022e96815380@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent 8b9d205 commit a4584bf

1 file changed

Lines changed: 57 additions & 2 deletions

File tree

drivers/remoteproc/qcom_q6v5_pas.c

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,61 @@ static void *qcom_pas_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is
413413
return pas->mem_region + offset;
414414
}
415415

416+
static int qcom_pas_parse_firmware(struct rproc *rproc, const struct firmware *fw)
417+
{
418+
struct qcom_pas *pas = rproc->priv;
419+
struct resource_table *table = NULL;
420+
size_t output_rt_size;
421+
void *output_rt;
422+
size_t table_sz;
423+
int ret;
424+
425+
ret = qcom_register_dump_segments(rproc, fw);
426+
if (ret) {
427+
dev_err(pas->dev, "Error in registering dump segments\n");
428+
return ret;
429+
}
430+
431+
if (!rproc->has_iommu)
432+
return 0;
433+
434+
ret = rproc_elf_load_rsc_table(rproc, fw);
435+
if (ret)
436+
dev_dbg(&rproc->dev, "Failed to load resource table from firmware\n");
437+
438+
table = rproc->table_ptr;
439+
table_sz = rproc->table_sz;
440+
441+
/*
442+
* The resources consumed by Qualcomm remote processors fall into two categories:
443+
* static (such as the memory carveouts for the rproc firmware) and dynamic (like
444+
* shared memory pools). Both are managed by a Qualcomm hypervisor (such as QHEE
445+
* or Gunyah), if one is present. Otherwise, a resource table must be retrieved
446+
* via an SCM call. That table will list all dynamic resources (if any) and possibly
447+
* the static ones. The static resources may also come from a resource table embedded
448+
* in the rproc firmware instead.
449+
*
450+
* Here, we call rproc_elf_load_rsc_table() to check firmware binary has resources
451+
* or not and if it is not having then we pass NULL and zero as input resource
452+
* table pointer and size respectively to the argument of qcom_scm_pas_get_rsc_table()
453+
* and this is even true for Qualcomm remote processor who does follow remoteproc
454+
* framework.
455+
*/
456+
output_rt = qcom_scm_pas_get_rsc_table(pas->pas_ctx, table, table_sz, &output_rt_size);
457+
ret = IS_ERR(output_rt) ? PTR_ERR(output_rt) : 0;
458+
if (ret) {
459+
dev_err(pas->dev, "Error in getting resource table: %d\n", ret);
460+
return ret;
461+
}
462+
463+
kfree(rproc->cached_table);
464+
rproc->cached_table = output_rt;
465+
rproc->table_ptr = rproc->cached_table;
466+
rproc->table_sz = output_rt_size;
467+
468+
return ret;
469+
}
470+
416471
static unsigned long qcom_pas_panic(struct rproc *rproc)
417472
{
418473
struct qcom_pas *pas = rproc->priv;
@@ -425,7 +480,7 @@ static const struct rproc_ops qcom_pas_ops = {
425480
.start = qcom_pas_start,
426481
.stop = qcom_pas_stop,
427482
.da_to_va = qcom_pas_da_to_va,
428-
.parse_fw = qcom_register_dump_segments,
483+
.parse_fw = qcom_pas_parse_firmware,
429484
.load = qcom_pas_load,
430485
.panic = qcom_pas_panic,
431486
};
@@ -435,7 +490,7 @@ static const struct rproc_ops qcom_pas_minidump_ops = {
435490
.start = qcom_pas_start,
436491
.stop = qcom_pas_stop,
437492
.da_to_va = qcom_pas_da_to_va,
438-
.parse_fw = qcom_register_dump_segments,
493+
.parse_fw = qcom_pas_parse_firmware,
439494
.load = qcom_pas_load,
440495
.panic = qcom_pas_panic,
441496
.coredump = qcom_pas_minidump,

0 commit comments

Comments
 (0)