ion: rockchip-ion: add API to set memory region secured

Add ion ioctl command -ION_IOC_SET_SECURED
for user to set memory region secured.

Change-Id: Ic4a7432ab8d2fd9f60fdfe7457e92f7c99768e12
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
This commit is contained in:
Jianqun Xu
2015-10-20 09:15:06 +08:00
committed by Huang, Tao
parent c35ed767ce
commit 773a19827f
2 changed files with 23 additions and 1 deletions

View File

@@ -32,6 +32,7 @@
#endif
#include <linux/compat.h>
#include <linux/rockchip/psci.h>
struct ion_device *rockchip_ion_dev;
EXPORT_SYMBOL(rockchip_ion_dev);
@@ -117,6 +118,22 @@ struct ion_client *rockchip_ion_client_create(const char *name)
}
EXPORT_SYMBOL(rockchip_ion_client_create);
static int rockchip_ion_set_secured(struct ion_client *client,
unsigned long arg)
{
bool val = 0;
int ret = 0;
if (copy_from_user(&val, (void __user *)arg, sizeof(bool)))
return -EFAULT;
ret = psci_set_memory_secure(val);
if (ret)
pr_err("%s fail to set memory secured (%d)\n", __func__, ret);
return ret;
}
#ifdef CONFIG_COMPAT
struct compat_ion_phys_data {
compat_int_t handle;
@@ -227,6 +244,8 @@ static long rockchip_custom_ioctl (struct ion_client *client, unsigned int cmd,
switch (cmd) {
case ION_IOC_GET_PHYS:
return rockchip_ion_get_phys(client, arg);
case ION_IOC_SET_SECURED:
return rockchip_ion_set_secured(client, arg);
default:
return -ENOTTY;
}

View File

@@ -49,5 +49,8 @@ struct ion_phys_data {
*/
#define ION_IOC_GET_PHYS _IOWR(ION_IOC_ROCKCHIP_MAGIC, 0, \
struct ion_phys_data)
/**
* Set memory region secured.
*/
#define ION_IOC_SET_SECURED _IOWR(ION_IOC_ROCKCHIP_MAGIC, 1, bool)
#endif