]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
soc: qcom: rmtfs: Add support for mmap functionality
authorAnkit Jain <jankit@codeaurora.org>
Mon, 4 Feb 2019 04:45:43 +0000 (10:15 +0530)
committerAndy Gross <andy.gross@linaro.org>
Thu, 28 Mar 2019 04:32:25 +0000 (23:32 -0500)
This change adds mmap functionality to rmtfs_mem driver.
Userspace application can map the address and use this
mapped address directly as buffer for read/write call to disk.
and avoid the read/write call to the shared path to copy the
buffer to userspace application.

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Ankit Jain <jankit@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
drivers/soc/qcom/rmtfs_mem.c

index 7200d762a951085d9169a6d1003e5a6002a3add8..6f5e8be9689cf451dab5a95f2d3d79d60820f39a 100644 (file)
@@ -137,6 +137,26 @@ static struct class rmtfs_class = {
        .name           = "rmtfs",
 };
 
+static int qcom_rmtfs_mem_mmap(struct file *filep, struct vm_area_struct *vma)
+{
+       struct qcom_rmtfs_mem *rmtfs_mem = filep->private_data;
+
+       if (vma->vm_end - vma->vm_start > rmtfs_mem->size) {
+               dev_dbg(&rmtfs_mem->dev,
+                       "vm_end[%lu] - vm_start[%lu] [%lu] > mem->size[%pa]\n",
+                       vma->vm_end, vma->vm_start,
+                       (vma->vm_end - vma->vm_start), &rmtfs_mem->size);
+               return -EINVAL;
+       }
+
+       vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+       return remap_pfn_range(vma,
+                              vma->vm_start,
+                              rmtfs_mem->addr >> PAGE_SHIFT,
+                              vma->vm_end - vma->vm_start,
+                              vma->vm_page_prot);
+}
+
 static const struct file_operations qcom_rmtfs_mem_fops = {
        .owner = THIS_MODULE,
        .open = qcom_rmtfs_mem_open,
@@ -144,6 +164,7 @@ static const struct file_operations qcom_rmtfs_mem_fops = {
        .write = qcom_rmtfs_mem_write,
        .release = qcom_rmtfs_mem_release,
        .llseek = default_llseek,
+       .mmap = qcom_rmtfs_mem_mmap,
 };
 
 static void qcom_rmtfs_mem_release_device(struct device *dev)