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

Commit 941ebdfe authored by Isaac J. Manjarres's avatar Isaac J. Manjarres
Browse files

soc: qcom: mem-buf: Do not assume VMID values



The mem-buf code currently assumes that the VMID values
for the VMs are known up-front, which may not be the case
when VMIDs are allocated dynamically. Thus, remove all
such assumptions, and query the resource manager driver
for VMID values. Also, rename the MEM_BUF_VMID_HLOS identifier
to MEM_BUF_VMID_PRIMARY_VM so as to not tie HLOS to the role
of primary VM.

Change-Id: I4cd79e31d7bda6d1437e690ac0e63b15a69565ef
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent 426fcd37
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -1078,7 +1078,7 @@ static int mem_buf_remove_mem(struct mem_buf_desc *membuf)

static bool is_valid_mem_buf_vmid(u32 mem_buf_vmid)
{
	if ((mem_buf_vmid == MEM_BUF_VMID_HLOS) ||
	if ((mem_buf_vmid == MEM_BUF_VMID_PRIMARY_VM) ||
	    (mem_buf_vmid == MEM_BUF_VMID_TRUSTED_UI))
		return true;

@@ -1092,11 +1092,21 @@ static bool is_valid_mem_buf_perms(u32 mem_buf_perms)

static int mem_buf_vmid_to_vmid(u32 mem_buf_vmid)
{
	if (mem_buf_vmid == MEM_BUF_VMID_HLOS)
		return VMID_HLOS;
	int ret;
	hh_vmid_t vmid;
	enum hh_vm_names vm_name;

	if (mem_buf_vmid == MEM_BUF_VMID_PRIMARY_VM)
		vm_name = HH_PRIMARY_VM;
	else if (mem_buf_vmid == MEM_BUF_VMID_TRUSTED_UI)
		return VMID_TRUSTED_UI;
		vm_name = HH_TRUSTED_VM;
	else
		return -EINVAL;

	ret = hh_rm_get_vmid(vm_name, &vmid);
	if (!ret)
		return vmid;
	return ret;
}

static int mem_buf_perms_to_perms(u32 mem_buf_perms)
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ enum mem_buf_mem_type {
};

/* The mem-buf values that represent VMIDs for an ACL. */
#define MEM_BUF_VMID_HLOS 0
#define MEM_BUF_VMID_PRIMARY_VM 0
#define	MEM_BUF_VMID_TRUSTED_UI 1

#define MEM_BUF_PERM_FLAG_READ (1U << 0)