summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInki Dae <inki.dae@samsung.com>2014-11-20 13:30:18 (GMT)
committerInki Dae <inki.dae@samsung.com>2014-11-20 14:23:32 (GMT)
commit354dcf2c8a71128bc148a7898090f40327a2d2a7 (patch)
tree2ce01c2ea4813a3c8c0fc1439b882d739963efc3
parent10e173dedf9b6112058aa34925bc51b203e88150 (diff)
downloadlinux-3.10-354dcf2c8a71128bc148a7898090f40327a2d2a7.zip
linux-3.10-354dcf2c8a71128bc148a7898090f40327a2d2a7.tar.gz
linux-3.10-354dcf2c8a71128bc148a7898090f40327a2d2a7.tar.bz2
dma-buf: add fcntl system call support
This patch adds lock callback to dmabuf framework. And this callback will be called by fcntl request. With this patch, fcntl system call can be used by userspace application for they can use dmabuf sync mechanism. Change-Id: Id3631cbc21e84c986e2efe040881e401ade180e8 Signed-off-by: Inki Dae <inki.dae@samsung.com>
-rw-r--r--drivers/dma-buf/dma-buf.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 376bc6b..8bd6a2d 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -33,6 +33,8 @@
#include <linux/poll.h>
#include <linux/reservation.h>
+#include <linux/dmabuf-sync.h>
+
static inline int is_dma_buf_file(struct file *);
struct dma_buf_list {
@@ -249,11 +251,38 @@ out:
return events;
}
+static int dma_buf_lock(struct file *file, int cmd, struct file_lock *fl)
+{
+ struct dma_buf *dmabuf;
+ unsigned int type;
+
+ if (!is_dma_buf_file(file) || !(fl->fl_flags & FL_SLEEP))
+ return -EPERM;
+
+ dmabuf = file->private_data;
+
+ if ((fl->fl_type & F_UNLCK) == F_UNLCK) {
+ dmabuf_sync_signal(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;
+
+ return dmabuf_sync_wait(dmabuf, (unsigned int)current, type);
+}
+
static const struct file_operations dma_buf_fops = {
.release = dma_buf_release,
.mmap = dma_buf_mmap_internal,
.llseek = dma_buf_llseek,
.poll = dma_buf_poll,
+ .lock = dma_buf_lock,
};
/*