ion: rockchip-ion: add API to set memory region secured
authorJianqun Xu <jay.xu@rock-chips.com>
Tue, 20 Oct 2015 01:15:06 +0000 (09:15 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 29 Oct 2015 01:36:18 +0000 (09:36 +0800)
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>
drivers/staging/android/ion/rockchip/rockchip_ion.c
include/linux/rockchip_ion.h

index ea7b7334a6e52126fddaa2cfc69aa6a61f7090a1..73caf00592355d1641e691be9135ef545bbba8da 100755 (executable)
@@ -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;
                }
index 59d6bf7ce53f3ab65c29e02ed6bc7a186d522be2..f62e728557d195d00ee12a9785223b186d882302 100644 (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