Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

firmware: qcom_scm: Add SHM bridge handling for PAS when running without QHEE

On SoCs running with a non-Gunyah-based hypervisor, Linux must take
responsibility for creating the SHM bridge both for metadata (before
calling qcom_scm_pas_init_image()) and for remoteproc memory (before
calling qcom_scm_pas_auth_and_reset()). We have taken care the things
required for qcom_scm_pas_auth_and_reset(). Lets put these awareness
of above conditions into qcom_scm_pas_init_image() and
qcom_scm_pas_metadata_release().

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-10-022e96815380@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Mukesh Ojha and committed by
Bjorn Andersson
b0199258 223a8716

+31 -1
+31 -1
drivers/firmware/qcom/qcom_scm.c
··· 623 623 return ret; 624 624 } 625 625 626 + static int qcom_scm_pas_prep_and_init_image(struct qcom_scm_pas_context *ctx, 627 + const void *metadata, size_t size) 628 + { 629 + struct qcom_scm_res res; 630 + phys_addr_t mdata_phys; 631 + void *mdata_buf; 632 + int ret; 633 + 634 + mdata_buf = qcom_tzmem_alloc(__scm->mempool, size, GFP_KERNEL); 635 + if (!mdata_buf) 636 + return -ENOMEM; 637 + 638 + memcpy(mdata_buf, metadata, size); 639 + mdata_phys = qcom_tzmem_to_phys(mdata_buf); 640 + 641 + ret = __qcom_scm_pas_init_image(ctx->pas_id, mdata_phys, &res); 642 + if (ret < 0) 643 + qcom_tzmem_free(mdata_buf); 644 + else 645 + ctx->ptr = mdata_buf; 646 + 647 + return ret ? : res.result[0]; 648 + } 649 + 626 650 /** 627 651 * qcom_scm_pas_init_image() - Initialize peripheral authentication service 628 652 * state machine for a given peripheral, using the ··· 671 647 dma_addr_t mdata_phys; 672 648 void *mdata_buf; 673 649 int ret; 650 + 651 + if (ctx && ctx->use_tzmem) 652 + return qcom_scm_pas_prep_and_init_image(ctx, metadata, size); 674 653 675 654 /* 676 655 * During the scm call memory protection will be enabled for the meta ··· 716 689 if (!ctx->ptr) 717 690 return; 718 691 719 - dma_free_coherent(__scm->dev, ctx->size, ctx->ptr, ctx->phys); 692 + if (ctx->use_tzmem) 693 + qcom_tzmem_free(ctx->ptr); 694 + else 695 + dma_free_coherent(__scm->dev, ctx->size, ctx->ptr, ctx->phys); 720 696 721 697 ctx->ptr = NULL; 722 698 }