Skip to content

Commit b019925

Browse files
mukeshojha-linuxandersson
authored andcommitted
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>
1 parent 223a871 commit b019925

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

drivers/firmware/qcom/qcom_scm.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,30 @@ static int __qcom_scm_pas_init_image(u32 pas_id, dma_addr_t mdata_phys,
623623
return ret;
624624
}
625625

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+
626650
/**
627651
* qcom_scm_pas_init_image() - Initialize peripheral authentication service
628652
* state machine for a given peripheral, using the
@@ -648,6 +672,9 @@ int qcom_scm_pas_init_image(u32 pas_id, const void *metadata, size_t size,
648672
void *mdata_buf;
649673
int ret;
650674

675+
if (ctx && ctx->use_tzmem)
676+
return qcom_scm_pas_prep_and_init_image(ctx, metadata, size);
677+
651678
/*
652679
* During the scm call memory protection will be enabled for the meta
653680
* data blob, so make sure it's physically contiguous, 4K aligned and
@@ -689,7 +716,10 @@ void qcom_scm_pas_metadata_release(struct qcom_scm_pas_context *ctx)
689716
if (!ctx->ptr)
690717
return;
691718

692-
dma_free_coherent(__scm->dev, ctx->size, ctx->ptr, ctx->phys);
719+
if (ctx->use_tzmem)
720+
qcom_tzmem_free(ctx->ptr);
721+
else
722+
dma_free_coherent(__scm->dev, ctx->size, ctx->ptr, ctx->phys);
693723

694724
ctx->ptr = NULL;
695725
}

0 commit comments

Comments
 (0)