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

Commit e4340a3e authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "uio: msm_sharedmem: Add a function to release the shared RAM section"

parents d225d1ae 205812e0
Loading
Loading
Loading
Loading
+31 −1
Original line number Diff line number Diff line
/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -75,6 +75,24 @@ static int sharedmem_mmap(struct uio_info *info, struct vm_area_struct *vma)
	return result;
}

static void free_shared_ram_perms(u32 client_id, phys_addr_t addr, u32 size)
{
	int ret;
	u32 source_vmlist[2] = {VMID_HLOS, VMID_MSS_MSA};
	int dest_vmids[1] = {VMID_HLOS};
	int dest_perms[1] = {PERM_READ|PERM_WRITE|PERM_EXEC};

	if (client_id != MPSS_RMTS_CLIENT_ID)
		return;

	ret = hyp_assign_phys(addr, size, source_vmlist, 2, dest_vmids,
				dest_perms, 1);
	if (ret != 0) {
		pr_err("hyp_assign_phys failed IPA=0x016%pa size=%u err=%d\n",
			&addr, size, ret);
	}
}

/* Setup the shared ram permissions.
 * This function currently supports the mpss client only.
 */
@@ -184,6 +202,17 @@ out:
	return ret;
}

static void msm_sharedmem_shutdown(struct platform_device *pdev)
{
	struct uio_info *info = dev_get_drvdata(&pdev->dev);

	phys_addr_t shared_mem_addr = info->mem[0].addr;
	u32 shared_mem_size = info->mem[0].size;

	free_shared_ram_perms(MPSS_RMTS_CLIENT_ID, shared_mem_addr,
			shared_mem_size);
}

static int msm_sharedmem_remove(struct platform_device *pdev)
{
	struct uio_info *info = dev_get_drvdata(&pdev->dev);
@@ -202,6 +231,7 @@ MODULE_DEVICE_TABLE(of, msm_sharedmem_of_match);
static struct platform_driver msm_sharedmem_driver = {
	.probe          = msm_sharedmem_probe,
	.remove         = msm_sharedmem_remove,
	.shutdown       = msm_sharedmem_shutdown,
	.driver         = {
		.name   = DRIVER_NAME,
		.owner	= THIS_MODULE,