1
0
Fork 0

soc: qcom: rmtfs: Add support for mmap functionality

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>
hifive-unleashed-5.2
Ankit Jain 2019-02-04 10:15:43 +05:30 committed by Andy Gross
parent 9e98c678c2
commit 8da3daaa09
1 changed files with 21 additions and 0 deletions

View 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)