summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2013-12-13 11:53:58 +0100
committerThomas Hellstrom <thellstrom@vmware.com>2014-02-25 22:31:14 +0100
commit9442597573bc4ddc3b3456f74d6ac7b65774aedb (patch)
tree1125a60674c47ae38d695d14e4df12455de30ac8
parent0842b6b7303a072004a019c47f9f357225ba45e1 (diff)
vmwgfx: Fix build errors on non-prime aware kernels and 3.9.X.
Mostly due to me pushing the wrong commit to the repo. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r--vmwgfx_compat.c25
-rw-r--r--vmwgfx_compat.h4
2 files changed, 25 insertions, 4 deletions
diff --git a/vmwgfx_compat.c b/vmwgfx_compat.c
index 3055755..6951a4a 100644
--- a/vmwgfx_compat.c
+++ b/vmwgfx_compat.c
@@ -9,8 +9,6 @@
#include <linux/scatterlist.h>
#include <linux/slab.h>
-#include <linux/anon_inodes.h>
-#include <linux/file.h>
#include "vmwgfx_compat.h"
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
@@ -117,6 +115,11 @@ bool __sg_page_iter_next(struct sg_page_iter *piter)
#endif
#ifdef DMA_BUF_STANDALONE
+#include <linux/file.h>
+#include <linux/anon_inodes.h>
+#include <linux/fdtable.h>
+#include <linux/sched.h>
+
static int dma_buf_release(struct inode *inode, struct file *file);
static const struct file_operations dma_buf_fops = {
@@ -192,6 +195,16 @@ struct dma_buf *dma_buf_get(int fd)
return file->private_data;
}
+static void compat_set_close_on_exec(unsigned int fd)
+{
+ struct files_struct *files = current->files;
+ struct fdtable *fdt;
+ spin_lock(&files->file_lock);
+ fdt = files_fdtable(files);
+ FD_SET(fd, fdt->close_on_exec);
+ spin_unlock(&files->file_lock);
+}
+
int dma_buf_fd(struct dma_buf *dmabuf, int flags)
{
int fd;
@@ -199,10 +212,16 @@ int dma_buf_fd(struct dma_buf *dmabuf, int flags)
if (!dmabuf || !dmabuf->file)
return -EINVAL;
- fd = get_unused_fd_flags(flags);
+ fd = get_unused_fd();
if (fd < 0)
return fd;
+ /*
+ * We explicitly set close_on_exec here since the function
+ * get_unused_fd_flags() which is used in the core dma-buf
+ * implementation is not exported on early 3 series kernels.
+ */
+ compat_set_close_on_exec(fd);
fd_install(fd, dmabuf->file);
return fd;
diff --git a/vmwgfx_compat.h b/vmwgfx_compat.h
index 4a76563..04a9164 100644
--- a/vmwgfx_compat.h
+++ b/vmwgfx_compat.h
@@ -388,6 +388,8 @@ bool __sg_page_iter_next(struct sg_page_iter *piter);
void __sg_page_iter_start(struct sg_page_iter *piter,
struct scatterlist *sglist, unsigned int nents,
unsigned long pgoffset);
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0))
/**
* sg_page_iter_page - get the current page held by the page iterator
* @piter: page iterator holding the page
@@ -416,7 +418,7 @@ static inline dma_addr_t sg_page_iter_dma_address(struct sg_page_iter *piter)
#define __DMA_BUF_H_
#define DMA_BUF_STANDALONE
-#include <linux/dma-direction.h>
+#include <linux/dma-mapping.h>
struct dma_buf_attachment;
struct dma_buf {