OSDN Git Service

uio: msm_sharedmem: Add support for HYP call
authorNikhilesh Reddy <reddyn@codeaurora.org>
Thu, 4 Jun 2015 18:31:42 +0000 (11:31 -0700)
committerDavid Keitel <dkeitel@codeaurora.org>
Tue, 22 Mar 2016 18:08:11 +0000 (11:08 -0700)
Add support for HYP call to setup the sharedmem permissions
for the MPSS client.

Change-Id: I3b48ae962865d8d0a0ea6e3fbb8e21278b59c690
Signed-off-by: Nikhilesh Reddy <reddyn@codeaurora.org>
drivers/uio/msm_sharedmem/msm_sharedmem.c

index 15e2264..0d593e4 100644 (file)
 #include <linux/err.h>
 #include <linux/of.h>
 #include <linux/dma-mapping.h>
+
+#include <soc/qcom/secure_buffer.h>
+
 #include "sharedmem_qmi.h"
 
 #define CLIENT_ID_PROP "qcom,client-id"
 
+#define MPSS_RMTS_CLIENT_ID 1
+
 static int uio_get_mem_index(struct uio_info *info, struct vm_area_struct *vma)
 {
        if (vma->vm_pgoff >= MAX_UIO_MAPS)
@@ -70,6 +75,31 @@ static int sharedmem_mmap(struct uio_info *info, struct vm_area_struct *vma)
        return result;
 }
 
+/* Setup the shared ram permissions.
+ * This function currently supports the mpss client only.
+ */
+static void setup_shared_ram_perms(u32 client_id, phys_addr_t addr, u32 size)
+{
+       int ret;
+       u32 source_vmlist[1] = {VMID_HLOS};
+       int dest_vmids[2] = {VMID_HLOS, VMID_MSS_MSA};
+       int dest_perms[2] = {PERM_READ|PERM_WRITE ,
+                            PERM_READ|PERM_WRITE};
+
+       if (client_id != MPSS_RMTS_CLIENT_ID)
+               return;
+
+       ret = hyp_assign_phys(addr, size, source_vmlist, 1, dest_vmids,
+                               dest_perms, 2);
+       if (ret != 0) {
+               if (ret == -ENOSYS)
+                       pr_warn("hyp_assign_phys is not supported!");
+               else
+                       pr_err("hyp_assign_phys failed IPA=0x%016llX size=%u err=%d\n",
+                               addr, size, ret);
+       }
+}
+
 static int msm_sharedmem_probe(struct platform_device *pdev)
 {
        int ret = 0;
@@ -124,6 +154,9 @@ static int msm_sharedmem_probe(struct platform_device *pdev)
                }
        }
 
+       /* Set up the permissions for the shared ram that was allocated. */
+       setup_shared_ram_perms(client_id, shared_mem_pyhsical, shared_mem_size);
+
        /* Setup device */
        info->mmap = sharedmem_mmap; /* Custom mmap function. */
        info->name = clnt_res->name;