From: Daniel Kurtz Date: Wed, 24 Apr 2013 04:27:38 +0000 (+0800) Subject: CHROMIUM: dma-buf/kds: allow KDS to be compiled out if dma-buf is enabled X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=c9e0796a2e0163768b80f99a6817f1d0403c0120;hp=070963eacbf6d1053d8dff392ac35a98964bf300;p=cascardo%2Flinux.git CHROMIUM: dma-buf/kds: allow KDS to be compiled out if dma-buf is enabled 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 Signed-off-by: Daniel Kurtz 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 Reviewed-by: Daniel Kurtz Tested-by: Daniel Kurtz Commit-Queue: Daniel Kurtz --- diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 1a4bba3bf201..7fcfbadbac47 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -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. diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c index 06c6225e15aa..4defa669c67b 100644 --- a/drivers/base/dma-buf.c +++ b/drivers/base/dma-buf.c @@ -27,8 +27,10 @@ #include #include #include +#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS #include #include +#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; } diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig index 090d7f327920..9c574fcde016 100644 --- a/drivers/gpu/drm/exynos/Kconfig +++ b/drivers/gpu/drm/exynos/Kconfig @@ -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 diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index 6e824d23fa7d..5eb40e7edc8c 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -30,8 +30,10 @@ #include #include #include +#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS #include #include +#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,