Hi Kuldeep, On 7/1/2025 9:47 PM, Kuldeep Singh wrote: > > On 5/27/2025 12:26 PM, Amirreza Zarrabi wrote: >> Anyone with access to contiguous physical memory should be able to >> share memory with QTEE using shm_bridge. >> >> Tested-by: Neil Armstrong <neil.armstrong@xxxxxxxxxx> >> Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@xxxxxxxxxxxxxxxx> >> --- >> drivers/firmware/qcom/qcom_tzmem.c | 57 +++++++++++++++++++++++++------- >> include/linux/firmware/qcom/qcom_tzmem.h | 15 +++++++++ >> 2 files changed, 60 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qcom/qcom_tzmem.c >> index 4fe333fd2f07..e9e4f06924ae 100644 >> --- a/drivers/firmware/qcom/qcom_tzmem.c >> +++ b/drivers/firmware/qcom/qcom_tzmem.c >> @@ -108,25 +108,61 @@ static int qcom_tzmem_init(void) >> return 0; >> } >> >> -static int qcom_tzmem_init_area(struct qcom_tzmem_area *area) >> +/** >> + * qcom_tzmem_shm_bridge_create() - Create a SHM bridge. >> + * @paddr: Physical address of the memory to share. >> + * @size: Size of the memory to share. >> + * @handle: Handle to the SHM bridge. >> + * >> + * On platforms that support SHM bridge, this function creates a SHM bridge >> + * for the given memory region with QTEE. The handle returned by this function >> + * must be passed to qcom_tzmem_shm_bridge_delete() to free the SHM bridge. >> + * >> + * Return: On success, returns 0; on failure, returns < 0. >> + */ >> +int qcom_tzmem_shm_bridge_create(phys_addr_t paddr, size_t size, u64 *handle) >> { >> u64 pfn_and_ns_perm, ipfn_and_s_perm, size_and_flags; >> - int ret; >> >> if (!qcom_tzmem_using_shm_bridge) >> return 0; >> >> - pfn_and_ns_perm = (u64)area->paddr | QCOM_SCM_PERM_RW; >> - ipfn_and_s_perm = (u64)area->paddr | QCOM_SCM_PERM_RW; >> - size_and_flags = area->size | (1 << QCOM_SHM_BRIDGE_NUM_VM_SHIFT); >> + pfn_and_ns_perm = paddr | QCOM_SCM_PERM_RW; >> + ipfn_and_s_perm = paddr | QCOM_SCM_PERM_RW; >> + size_and_flags = size | (1 << QCOM_SHM_BRIDGE_NUM_VM_SHIFT); >> + if (qcom_scm_shm_bridge_create(pfn_and_ns_perm, ipfn_and_s_perm, >> + size_and_flags, QCOM_SCM_VMID_HLOS, >> + handle)) > > Can we add a debug log here to ease debugging in future? > Something like this can also work. > > pr_err("Shm bridge creation failed, ret: %d, NS PA|Perm: 0x%llx, > size|flags: 0x%llx\n", ret, pfn_and_ns_perm_flags, size_and_flags); > Sure. Regards, Amir >> + return -EINVAL; >> + >> + return 0; >> +} >> +EXPORT_SYMBOL_GPL(qcom_tzmem_shm_bridge_create); >