mirror of
https://github.com/hardkernel/linux.git
synced 2026-04-14 17:40:41 +09:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user