From 21b17ba6c665739161938cf23ccf20005f5832a3 Mon Sep 17 00:00:00 2001 From: Daniel Kurtz Date: Fri, 3 May 2013 21:11:11 -0700 Subject: [PATCH] Revert "Add implementation of poll() to dma_buf using KDS" MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This reverts commit 5d1bb28fa72400006b3956ab7d869dffd091af23. There are no users of dma-buf poll(), this isn't upstream, and we aren't carrying it forward to 3.8. Revert from 3.4 to keep 3.8 & 3.4 more consistent. Signed-off-by: Daniel Kurtz BUG=none TEST=none Change-Id: Ia6628aef06f5ee228f3ac479bfa0e75b45573f04 Reviewed-on: https://gerrit.chromium.org/gerrit/50187 Tested-by: Daniel Kurtz Reviewed-by: Stéphane Marchesin Commit-Queue: Daniel Kurtz Reviewed-by: Daniel Kurtz --- drivers/base/dma-buf.c | 94 ----------------------------------------- include/linux/dma-buf.h | 4 -- 2 files changed, 98 deletions(-) diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c index 4defa669c67b..477d73e96844 100644 --- a/drivers/base/dma-buf.c +++ b/drivers/base/dma-buf.c @@ -27,10 +27,6 @@ #include #include #include -#ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS -#include -#include -#endif static inline int is_dma_buf_file(struct file *); @@ -45,7 +41,6 @@ static int dma_buf_release(struct inode *inode, struct file *file) 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); @@ -69,95 +64,9 @@ 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; - struct kds_resource_set *rset = *rset_ptr; - wait_queue_head_t *wait_queue = param2; - - kfree(rset_ptr); - kds_resource_set_release(&rset); - wake_up(wait_queue); -} - -static int dma_buf_kds_check(struct kds_resource *kds, - unsigned long exclusive, int *poll_ret) -{ - /* Synchronous wait with 0 timeout - poll availability */ - struct kds_resource_set *rset = kds_waitall(1, &exclusive, &kds, 0); - - if (IS_ERR(rset)) - return POLLERR; - - if (rset) { - kds_resource_set_release(&rset); - *poll_ret = POLLIN | POLLRDNORM; - if (exclusive) - *poll_ret |= POLLOUT | POLLWRNORM; - return 1; - } else { - return 0; - } -} - -static unsigned int dma_buf_poll(struct file *file, - struct poll_table_struct *wait) -{ - struct dma_buf *dmabuf; - struct kds_resource *kds; - unsigned int ret = 0; - - if (!is_dma_buf_file(file)) - return POLLERR; - - dmabuf = file->private_data; - kds = &dmabuf->kds; - - if (poll_does_not_wait(wait)) { - /* Check for exclusive access (superset of shared) first */ - if (!dma_buf_kds_check(kds, 1ul, &ret)) - dma_buf_kds_check(kds, 0ul, &ret); - } else { - int events = poll_requested_events(wait); - unsigned long exclusive; - wait_queue_head_t *wq; - struct kds_resource_set **rset_ptr = - kmalloc(sizeof(*rset_ptr), GFP_KERNEL); - - if (!rset_ptr) - return POLL_ERR; - - if (events & POLLOUT) { - wq = &dmabuf->wq_exclusive; - exclusive = 1; - } else { - wq = &dmabuf->wq_shared; - exclusive = 0; - } - poll_wait(file, wq, wait); - ret = kds_async_waitall(rset_ptr, KDS_FLAG_LOCKED_WAIT, - &dmabuf->kds_cb, rset_ptr, wq, 1, &exclusive, - &kds); - - if (IS_ERR_VALUE(ret)) { - ret = POLL_ERR; - kfree(rset_ptr); - } else { - /* Can't allow access until callback */ - ret = 0; - } - } - 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 }; /* @@ -215,10 +124,7 @@ struct dma_buf *dma_buf_export(void *priv, const struct dma_buf_ops *ops, 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/include/linux/dma-buf.h b/include/linux/dma-buf.h index 5eb40e7edc8c..34073f60efe7 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -32,7 +32,6 @@ #include #ifdef CONFIG_DMA_SHARED_BUFFER_USES_KDS #include -#include #endif struct device; @@ -127,9 +126,6 @@ struct dma_buf { 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; }; -- 2.20.1