summaryrefslogtreecommitdiff
path: root/patches.tizen/0355-dma-buf-add-lock-callback-for-fcntl-system-call.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches.tizen/0355-dma-buf-add-lock-callback-for-fcntl-system-call.patch')
-rw-r--r--patches.tizen/0355-dma-buf-add-lock-callback-for-fcntl-system-call.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/patches.tizen/0355-dma-buf-add-lock-callback-for-fcntl-system-call.patch b/patches.tizen/0355-dma-buf-add-lock-callback-for-fcntl-system-call.patch
new file mode 100644
index 00000000000..46d07eb409b
--- /dev/null
+++ b/patches.tizen/0355-dma-buf-add-lock-callback-for-fcntl-system-call.patch
@@ -0,0 +1,68 @@
+From 5a25eeb1650459a280ef145e753c204ebaee9863 Mon Sep 17 00:00:00 2001
+From: Inki Dae <inki.dae@samsung.com>
+Date: Fri, 12 Jul 2013 14:01:02 +0900
+Subject: [PATCH 0355/1302] dma-buf: add lock callback for fcntl system call.
+
+This patch adds lock callback to dma buf file operations,
+and this callback will be called by fcntl system call.
+
+With this patch, fcntl system call can be used for buffer
+synchronization between CPU and CPU, and CPU and DMA in user mode.
+
+Signed-off-by: Inki Dae <inki.dae@samsung.com>
+Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
+Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
+---
+ drivers/base/dma-buf.c | 33 +++++++++++++++++++++++++++++++++
+ 1 file changed, 33 insertions(+)
+
+diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
+index 9a26981..e1b8583 100644
+--- a/drivers/base/dma-buf.c
++++ b/drivers/base/dma-buf.c
+@@ -80,9 +80,42 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
+ return dmabuf->ops->mmap(dmabuf, vma);
+ }
+
++static int dma_buf_lock(struct file *file, int cmd, struct file_lock *fl)
++{
++ struct dma_buf *dmabuf;
++ unsigned int type;
++ bool wait = false;
++
++ if (!is_dma_buf_file(file))
++ return -EINVAL;
++
++ dmabuf = file->private_data;
++
++ if ((fl->fl_type & F_UNLCK) == F_UNLCK) {
++ dmabuf_sync_single_unlock(dmabuf);
++ return 0;
++ }
++
++ /* convert flock type to dmabuf sync type. */
++ if ((fl->fl_type & F_WRLCK) == F_WRLCK)
++ type = DMA_BUF_ACCESS_W;
++ else if ((fl->fl_type & F_RDLCK) == F_RDLCK)
++ type = DMA_BUF_ACCESS_R;
++ else
++ return -EINVAL;
++
++ if (fl->fl_flags & FL_SLEEP)
++ wait = true;
++
++ /* TODO. the locking to certain region should also be considered. */
++
++ return dmabuf_sync_single_lock(dmabuf, type, wait);
++}
++
+ static const struct file_operations dma_buf_fops = {
+ .release = dma_buf_release,
+ .mmap = dma_buf_mmap_internal,
++ .lock = dma_buf_lock,
+ };
+
+ /*
+--
+1.8.3.2
+