Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebd5df27 authored by Nikhilesh Reddy's avatar Nikhilesh Reddy Committed by Ankit Jain
Browse files

uio: msm_sharedmem: Add support for HYP call



Add support for HYP call to setup the sharedmem permissions
for the MPSS client.

Change-Id: I3b48ae962865d8d0a0ea6e3fbb8e21278b59c690
Signed-off-by: default avatarNikhilesh Reddy <reddyn@codeaurora.org>
[riteshh@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: default avatarRitesh Harjani <riteshh@codeaurora.org>
Signed-off-by: default avatarAnkit Jain <jankit@codeaurora.org>
parent 056279eb
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -13,7 +13,10 @@
#include <linux/of.h>
#include <linux/dma-mapping.h>

#include <soc/qcom/secure_buffer.h>

#define CLIENT_ID_PROP "qcom,client-id"
#define MPSS_RMTS_CLIENT_ID 1

static int uio_get_mem_index(struct uio_info *info, struct vm_area_struct *vma)
{
@@ -62,6 +65,31 @@ static int sharedmem_mmap(struct uio_info *info, struct vm_area_struct *vma)
	return result;
}

/* Setup the shared ram permissions.
 * This function currently supports the mpss client only.
 */
static void setup_shared_ram_perms(u32 client_id, phys_addr_t addr, u32 size)
{
	int ret;
	u32 source_vmlist[1] = {VMID_HLOS};
	int dest_vmids[2] = {VMID_HLOS, VMID_MSS_MSA};
	int dest_perms[2] = {PERM_READ|PERM_WRITE,
			     PERM_READ|PERM_WRITE};

	if (client_id != MPSS_RMTS_CLIENT_ID)
		return;

	ret = hyp_assign_phys(addr, size, source_vmlist, 1, dest_vmids,
				dest_perms, 2);
	if (ret != 0) {
		if (ret == -EINVAL)
			pr_warn("hyp_assign_phys is not supported!\n");
		else
			pr_err("hyp_assign_phys failed IPA=0x%016llX size=%u err=%d\n",
				addr, size, ret);
	}
}

static int msm_sharedmem_probe(struct platform_device *pdev)
{
	int ret = 0;
@@ -115,6 +143,9 @@ static int msm_sharedmem_probe(struct platform_device *pdev)
		}
	}

	/* Set up the permissions for the shared ram that was allocated. */
	setup_shared_ram_perms(client_id, shared_mem_pyhsical, shared_mem_size);

	/* Setup device */
	info->mmap = sharedmem_mmap; /* Custom mmap function. */
	info->name = clnt_res->name;