CHROMIUM: dma-buf/kds: allow KDS to be compiled out if dma-buf is enabled
authorDaniel Kurtz <djkurtz@chromium.org>
Wed, 24 Apr 2013 04:27:38 +0000 (12:27 +0800)
committerChromeBot <chrome-bot@google.com>
Thu, 2 May 2013 03:30:08 +0000 (20:30 -0700)
The original KDS patches added CONFIG_DMA_SHARED_BUFFER_USES_KDS but
didn't use it to guard the kds integration into dma-bufs in a way
that would allow dma-buf to be built with KDS compiled without
requiring KDS.

Fix this by more carefully guarding the integration points, and not
unconditionally selecting KDS when dma-buf is enabled.

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
BUG=chromium:232913
TEST=compile kernel for x86 and arm and verify it still boots

Change-Id: I878d1313ce6b43477fd6c87d394728283ad4f9e6
Reviewed-on: https://gerrit.chromium.org/gerrit/48608
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
Commit-Queue: Daniel Kurtz <djkurtz@chromium.org>

drivers/base/Kconfig
drivers/base/dma-buf.c
drivers/gpu/drm/exynos/Kconfig
include/linux/dma-buf.h

index 1a4bba3..7fcfbad 100644 (file)
@@ -194,8 +194,6 @@ config DMA_SHARED_BUFFER
        bool
        default n
        select ANON_INODES
-       select KDS
-       select DMA_SHARED_BUFFER_USES_KDS
        depends on EXPERIMENTAL
        help
          This option enables the framework for buffer-sharing between
@@ -293,7 +291,8 @@ config CMA_AREAS
 endif
 
 config DMA_SHARED_BUFFER_USES_KDS
-       bool
+       bool "Add KDS resource within every dma_buf allocation"
+       depends on DMA_SHARED_BUFFER && KDS
        default n
        help
          This option adds a KDS resource within every dma_buf allocation.
index 06c6225..4defa66 100644 (file)
 #include <linux/dma-buf.h>
 #include <linux/anon_inodes.h>
 #include <linux/export.h>
+#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
 #include <linux/poll.h>
 #include <linux/sched.h>
+#endif
 
 static inline int is_dma_buf_file(struct file *);
 
@@ -42,8 +44,10 @@ static int dma_buf_release(struct inode *inode, struct file *file)
        dmabuf = file->private_data;
 
        dmabuf->ops->release(dmabuf);
+#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
        kds_callback_term(&dmabuf->kds_cb);
        kds_resource_term(&dmabuf->kds);
+#endif
        kfree(dmabuf);
        return 0;
 }
@@ -65,7 +69,7 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
        return dmabuf->ops->mmap(dmabuf, vma);
 }
 
-
+#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
 static void dma_buf_kds_cb_fn(void *param1, void *param2)
 {
        struct kds_resource_set **rset_ptr = param1;
@@ -146,11 +150,14 @@ static unsigned int dma_buf_poll(struct file *file,
        }
        return ret;
 }
+#endif
 
 static const struct file_operations dma_buf_fops = {
        .release        = dma_buf_release,
        .mmap           = dma_buf_mmap_internal,
+#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
        .poll           = dma_buf_poll,
+#endif
 };
 
 /*
@@ -207,10 +214,12 @@ struct dma_buf *dma_buf_export(void *priv, const struct dma_buf_ops *ops,
        mutex_init(&dmabuf->lock);
        INIT_LIST_HEAD(&dmabuf->attachments);
 
+#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
        init_waitqueue_head(&dmabuf->wq_exclusive);
        init_waitqueue_head(&dmabuf->wq_shared);
        kds_resource_init(&dmabuf->kds);
        kds_callback_init(&dmabuf->kds_cb, 1, dma_buf_kds_cb_fn);
+#endif
 
        return dmabuf;
 }
index 090d7f3..9c574fc 100644 (file)
@@ -2,6 +2,7 @@ config DRM_EXYNOS
        tristate "DRM Support for Samsung SoC EXYNOS Series"
        depends on DRM && PLAT_SAMSUNG
        select DRM_KMS_HELPER
+       select DMA_SHARED_BUFFER_USES_KDS
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
index 6e824d2..5eb40e7 100644 (file)
 #include <linux/list.h>
 #include <linux/dma-mapping.h>
 #include <linux/fs.h>
+#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
 #include <linux/kds.h>
 #include <linux/wait.h>
+#endif
 
 struct device;
 struct dma_buf;
@@ -123,10 +125,12 @@ struct dma_buf {
        const struct dma_buf_ops *ops;
        /* mutex to serialize list manipulation and attach/detach */
        struct mutex lock;
+#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
        struct kds_resource kds;
        wait_queue_head_t wq_exclusive;
        wait_queue_head_t wq_shared;
        struct kds_callback kds_cb;
+#endif
        void *priv;
 };
 
@@ -162,6 +166,7 @@ static inline void get_dma_buf(struct dma_buf *dmabuf)
        get_file(dmabuf->file);
 }
 
+#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS
 /**
  * get_dma_buf_kds_resource - get a KDS resource for this dma-buf
  * @dmabuf:    [in]    pointer to dma_buf
@@ -176,6 +181,7 @@ static inline struct kds_resource *
 {
        return &dmabuf->kds;
 }
+#endif
 
 #ifdef CONFIG_DMA_SHARED_BUFFER
 struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,