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

A function to free the shared RAM section has been added to the
msm_sharedmem driver. This function is needed to free the RAM section
on shutdown of the msm_sharedmem driver. The function is called on
the shutdown command for the driver.

Change-Id: Iff04f93d380664c5e3df9b0cd575cf9e6300ea39
Signed-off-by: Anant Goel <anantg@codeaurora.org>
This commit is contained in:
Anant Goel 2018-06-14 18:32:16 -07:00
parent 53c73b7190
commit 205812e0fc

View file

@ -1,4 +1,4 @@
/* 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,