aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Dolnikov <andrey.dolnikov@cogentembedded.com>2018-02-14 12:03:23 +0300
committerAndrey Dolnikov <andrey.dolnikov@cogentembedded.com>2018-04-11 17:08:19 +0300
commit7051d448e4589b74ec69ba56910e4cfbf1c86877 (patch)
tree535db10ae56aee91dbd0bc5f0f9c896cfb9900aa
parent10aa7f1f74b054c2575e7584a02b3738a24d0c7a (diff)
MMNGR: Add cached buffers support.
-rw-r--r--meta-rcar-gen3-adas/recipes-kernel/kernel-module-mmngr/files/0003-kernelheap-cached-support.patch102
-rw-r--r--meta-rcar-gen3-adas/recipes-kernel/kernel-module-mmngr/kernel-module-mmngr.bbappend5
-rw-r--r--meta-rcar-gen3-adas/recipes-multimedia/mmngr-module/files/0001-cached-buffers-support.patch113
-rw-r--r--meta-rcar-gen3-adas/recipes-multimedia/mmngr-module/mmngr-user-module.bbappend5
4 files changed, 224 insertions, 1 deletions
diff --git a/meta-rcar-gen3-adas/recipes-kernel/kernel-module-mmngr/files/0003-kernelheap-cached-support.patch b/meta-rcar-gen3-adas/recipes-kernel/kernel-module-mmngr/files/0003-kernelheap-cached-support.patch
new file mode 100644
index 0000000..171eac1
--- /dev/null
+++ b/meta-rcar-gen3-adas/recipes-kernel/kernel-module-mmngr/files/0003-kernelheap-cached-support.patch
@@ -0,0 +1,102 @@
+From d20b6893f3d22abd12ffb5421292fcee4820de33 Mon Sep 17 00:00:00 2001
+From: Andrey Dolnikov <andrey.dolnikov@cogentembedded.com>
+Date: Wed, 14 Feb 2018 17:12:01 +0300
+Subject: [PATCH] mmngr: Add kernelheap cached buffers support.
+
+---
+ .../mmngr/mmngr-module/files/mmngr/drv/mmngr_drv.c | 20 ++++++++++++++++----
+ .../files/mmngr/include/mmngr_private_cmn.h | 7 +++++++
+ .../files/mmngr/include/mmngr_public_cmn.h | 1 +
+ 4 files changed, 29 insertions(+), 4 deletions(-)
+
+diff --git a/mmngr_drv/mmngr/mmngr-module/files/mmngr/drv/mmngr_drv.c b/mmngr_drv/mmngr/mmngr-module/files/mmngr/drv/mmngr_drv.c
+index cd797f5..c38329d 100644
+--- a/mmngr_drv/mmngr/mmngr-module/files/mmngr/drv/mmngr_drv.c
++++ b/mmngr_drv/mmngr/mmngr-module/files/mmngr/drv/mmngr_drv.c
+@@ -736,7 +736,7 @@ static int close(struct inode *inode, struct file *file)
+ int entry = 0;
+
+ if (p) {
+- if ((p->flag == MM_KERNELHEAP)
++ if ((p->flag == MM_KERNELHEAP || p->flag == MM_KERNELHEAP_CACHED)
+ && (p->kernel_virt_addr != 0)) {
+ pr_err("MMD close kernelheap\n");
+ mm_dev = mm_drvdata->mm_dev;
+@@ -779,6 +779,7 @@ static long ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+ int ercd;
+ int ret;
+ struct MM_PARAM *p = file->private_data;
++ struct MM_CACHE_PARAM *cachep;
+ struct device *mm_dev;
+
+ mm_dev = mm_drvdata->mm_dev;
+@@ -830,6 +831,14 @@ static long ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+ goto exit;
+ }
+ break;
++ case MM_IOC_FLUSH:
++ cachep = (struct MM_CACHE_PARAM *) arg;
++ dma_sync_single_for_device(mm_dev, p->hard_addr + cachep->offset, cachep->len, DMA_FROM_DEVICE);
++ break;
++ case MM_IOC_INVAL:
++ cachep = (struct MM_CACHE_PARAM *) arg;
++ dma_sync_single_for_cpu(mm_dev, p->hard_addr + cachep->offset, cachep->len, DMA_TO_DEVICE);
++ break;
+ default:
+ pr_err("MMD CMD EFAULT\n");
+ ret = -EFAULT;
+@@ -954,9 +963,12 @@ static int mmap(struct file *filp, struct vm_area_struct *vma)
+ off += start;
+ vma->vm_pgoff = off >> PAGE_SHIFT;
+
+- vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+-
+- vma->vm_flags |= (VM_IO | VM_DONTEXPAND | VM_DONTDUMP);
++ if (p->flag != MM_KERNELHEAP_CACHED) {
++ vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
++ vma->vm_flags |= (VM_IO | VM_DONTEXPAND | VM_DONTDUMP);
++ } else {
++ vma->vm_flags |= (VM_DONTEXPAND | VM_DONTDUMP);
++ }
+
+ if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
+ vma->vm_end - vma->vm_start, vma->vm_page_prot))
+diff --git a/mmngr_drv/mmngr/mmngr-module/files/mmngr/include/mmngr_private_cmn.h b/mmngr_drv/mmngr/mmngr-module/files/mmngr/include/mmngr_private_cmn.h
+index f731ab6..5f137c6 100644
+--- a/mmngr_drv/mmngr/mmngr-module/files/mmngr/include/mmngr_private_cmn.h
++++ b/mmngr_drv/mmngr/mmngr-module/files/mmngr/include/mmngr_private_cmn.h
+@@ -72,6 +72,11 @@ struct MM_PARAM {
+ unsigned int flag;
+ };
+
++struct MM_CACHE_PARAM {
++ size_t offset;
++ size_t len;
++};
++
+ #define MM_IOC_MAGIC 'm'
+ #define MM_IOC_ALLOC _IOWR(MM_IOC_MAGIC, 0, struct MM_PARAM)
+ #define MM_IOC_FREE _IOWR(MM_IOC_MAGIC, 1, struct MM_PARAM)
+@@ -80,5 +85,7 @@ struct MM_PARAM {
+ #define MM_IOC_ALLOC_CO _IOWR(MM_IOC_MAGIC, 4, struct MM_PARAM)
+ #define MM_IOC_FREE_CO _IOWR(MM_IOC_MAGIC, 5, struct MM_PARAM)
+ #define MM_IOC_SHARE _IOWR(MM_IOC_MAGIC, 6, struct MM_PARAM)
++#define MM_IOC_FLUSH _IOWR(MM_IOC_MAGIC, 7, struct MM_CACHE_PARAM)
++#define MM_IOC_INVAL _IOWR(MM_IOC_MAGIC, 8, struct MM_CACHE_PARAM)
+
+ #endif /* __MMNGR_PRIVATE_CMN_H__ */
+diff --git a/mmngr_drv/mmngr/mmngr-module/files/mmngr/include/mmngr_public_cmn.h b/mmngr_drv/mmngr/mmngr-module/files/mmngr/include/mmngr_public_cmn.h
+index dce81a1..a668019 100644
+--- a/mmngr_drv/mmngr/mmngr-module/files/mmngr/include/mmngr_public_cmn.h
++++ b/mmngr_drv/mmngr/mmngr-module/files/mmngr/include/mmngr_public_cmn.h
+@@ -62,6 +62,7 @@
+ #define __MMNGR_PUBLIC_CMN_H__
+
+ #define MM_KERNELHEAP 0
++#define MM_KERNELHEAP_CACHED 5
+ #define MM_CARVEOUT 1
+ #define MM_CARVEOUT_SSP 3
+ #define MM_CARVEOUT_LOSSY 4
+--
+2.7.4
+
diff --git a/meta-rcar-gen3-adas/recipes-kernel/kernel-module-mmngr/kernel-module-mmngr.bbappend b/meta-rcar-gen3-adas/recipes-kernel/kernel-module-mmngr/kernel-module-mmngr.bbappend
index 6f05e72..bdb0251 100644
--- a/meta-rcar-gen3-adas/recipes-kernel/kernel-module-mmngr/kernel-module-mmngr.bbappend
+++ b/meta-rcar-gen3-adas/recipes-kernel/kernel-module-mmngr/kernel-module-mmngr.bbappend
@@ -6,4 +6,7 @@ MMNGR_CFG_condor = "MMNGR_V3MSK"
MMNGR_CFG_v3mzf = "MMNGR_V3MSK"
MMNGR_CFG_v3hsk = "MMNGR_V3MSK"
-SRC_URI_append = " file://0002-mmngr-Add-V3MSK-board.patch"
+SRC_URI_append = " \
+ file://0002-mmngr-Add-V3MSK-board.patch \
+ file://0003-kernelheap-cached-support.patch \
+"
diff --git a/meta-rcar-gen3-adas/recipes-multimedia/mmngr-module/files/0001-cached-buffers-support.patch b/meta-rcar-gen3-adas/recipes-multimedia/mmngr-module/files/0001-cached-buffers-support.patch
new file mode 100644
index 0000000..9a8030e
--- /dev/null
+++ b/meta-rcar-gen3-adas/recipes-multimedia/mmngr-module/files/0001-cached-buffers-support.patch
@@ -0,0 +1,113 @@
+From ac078825fab834a524e45befa6a7f9de12317d16 Mon Sep 17 00:00:00 2001
+From: Andrey Dolnikov <andrey.dolnikov@cogentembedded.com>
+Date: Wed, 14 Feb 2018 12:10:09 +0300
+Subject: [PATCH] mmngr: Add kernelheap cached buffers support.
+
+---
+ libmmngr/mmngr/if/mmngr_if.c | 49 ++++++++++++++++++++++++++++--
+ libmmngr/mmngr/include/mmngr_user_public.h | 4 +++
+ 2 files changed, 50 insertions(+), 3 deletions(-)
+
+diff --git a/libmmngr/mmngr/if/mmngr_if.c b/libmmngr/mmngr/if/mmngr_if.c
+index 670aa60..1096d14 100644
+--- a/libmmngr/mmngr/if/mmngr_if.c
++++ b/libmmngr/mmngr/if/mmngr_if.c
+@@ -216,7 +216,7 @@ int mmngr_alloc_in_user_ext(MMNGR_ID *pid, size_t size,
+ goto exit;
+ }
+
+- if ((flag != MM_KERNELHEAP) && (flag != MM_CARVEOUT)
++ if ((flag != MM_KERNELHEAP) && (flag != MM_KERNELHEAP_CACHED) && (flag != MM_CARVEOUT)
+ && (flag != MM_CARVEOUT_SSP) && (flag != MM_CARVEOUT_LOSSY)) {
+ ret = R_MM_PARE;
+ goto exit;
+@@ -243,7 +243,7 @@ int mmngr_alloc_in_user_ext(MMNGR_ID *pid, size_t size,
+ }
+ }
+
+- if (flag == MM_KERNELHEAP) {
++ if (flag == MM_KERNELHEAP || flag == MM_KERNELHEAP_CACHED) {
+ ret = mm_alloc_kh_in_user(pid, size, phard_addr,
+ puser_virt_addr, flag);
+ if (ret)
+@@ -296,7 +296,7 @@ int mmngr_free_in_user_ext(MMNGR_ID id)
+ goto exit;
+ }
+
+- if (p.flag == MM_KERNELHEAP) {
++ if (p.flag == MM_KERNELHEAP || p.flag == MM_KERNELHEAP_CACHED) {
+ ret = mm_free_kh_in_user(id);
+ if (ret)
+ goto exit;
+@@ -479,3 +479,46 @@ int mmngr_release_in_user(MMNGR_ID id)
+ ret = mmngr_release_in_user_ext(id);
+ return ret;
+ }
++
++int mmngr_inval(MMNGR_ID id, size_t offset, size_t len)
++{
++ int ret;
++ struct MM_CACHE_PARAM cachep;
++
++ cachep.offset = offset;
++ cachep.len = len;
++
++ ret = ioctl(id, MM_IOC_INVAL, &cachep);
++ if (ret) {
++ perror("MMI INVAL");
++ ret = R_MM_FATAL;
++ goto exit;
++ }
++
++ return R_MM_OK;
++
++exit:
++ return ret;
++
++}
++
++int mmngr_flush(MMNGR_ID id, size_t offset, size_t len)
++{
++ int ret;
++ struct MM_CACHE_PARAM cachep;
++
++ cachep.offset = offset;
++ cachep.len = len;
++
++ ret = ioctl(id, MM_IOC_FLUSH, &cachep);
++ if (ret) {
++ perror("MMI INVAL");
++ ret = R_MM_FATAL;
++ goto exit;
++ }
++
++ return R_MM_OK;
++
++exit:
++ return ret;
++}
+diff --git a/libmmngr/mmngr/include/mmngr_user_public.h b/libmmngr/mmngr/include/mmngr_user_public.h
+index e4e0e2a..9fc0c0a 100644
+--- a/libmmngr/mmngr/include/mmngr_user_public.h
++++ b/libmmngr/mmngr/include/mmngr_user_public.h
+@@ -54,6 +54,9 @@ int mmngr_share_in_user(MMNGR_ID *pid,
+ unsigned long *puser_virt_addr);
+ int mmngr_release_in_user(MMNGR_ID id);
+
++int mmngr_inval(MMNGR_ID id, size_t offset, size_t len);
++int mmngr_flush(MMNGR_ID id, size_t offset, size_t len);
++
+ #define R_MM_OK 0
+ #define R_MM_FATAL -1
+ #define R_MM_SEQE -2
+@@ -61,6 +64,7 @@ int mmngr_release_in_user(MMNGR_ID id);
+ #define R_MM_NOMEM -4
+
+ #define MMNGR_VA_SUPPORT MM_KERNELHEAP
++#define MMNGR_VA_SUPPORT_CACHED MM_KERNELHEAP_CACHED
+ #define MMNGR_PA_SUPPORT MM_CARVEOUT
+ #define MMNGR_PA_SUPPORT_SSP MM_CARVEOUT_SSP
+ #define MMNGR_PA_SUPPORT_LOSSY MM_CARVEOUT_LOSSY
+--
+2.7.4
+
diff --git a/meta-rcar-gen3-adas/recipes-multimedia/mmngr-module/mmngr-user-module.bbappend b/meta-rcar-gen3-adas/recipes-multimedia/mmngr-module/mmngr-user-module.bbappend
new file mode 100644
index 0000000..93ac63d
--- /dev/null
+++ b/meta-rcar-gen3-adas/recipes-multimedia/mmngr-module/mmngr-user-module.bbappend
@@ -0,0 +1,5 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+SRC_URI_append = " \
+ file://0001-cached-buffers-support.patch;patchdir=${WORKDIR}/git \
+"