From 6b607e3a658fee490bdabfdeb739a3eb498b1bff Mon Sep 17 00:00:00 2001
From: Daniel Vetter <daniel.vetter@ffwll.ch>
Date: Mon, 19 Mar 2012 00:34:25 +0100
Subject: dma-buf: don't hold the mutex around map/unmap calls
Git-commit: 6b607e3a658fee490bdabfdeb739a3eb498b1bff
Patch-mainline: v3.4-rc1

The mutex protects the attachment list and hence needs to be held
around the callbakc to the exporters (optional) attach/detach
functions.

Holding the mutex around the map/unmap calls doesn't protect any
dma_buf state. Exporters need to properly protect any of their own
state anyway (to protect against calls from their own interfaces).
So this only makes the locking messier (and lockdep easier to anger).

Therefore let's just drop this.

v2: Rebased on top of latest dma-buf-next git.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Rob Clark <rob.clark@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Michal Srb <msrb@suse.com>
---
 drivers/base/dma-buf.c  |    5 -----
 include/linux/dma-buf.h |    2 +-
 2 files changed, 1 insertions(+), 6 deletions(-)

Index: linux-3.0-SLE11-SP3/drivers/base/dma-buf.c
===================================================================
--- linux-3.0-SLE11-SP3.orig/drivers/base/dma-buf.c
+++ linux-3.0-SLE11-SP3/drivers/base/dma-buf.c
@@ -259,10 +259,8 @@ struct sg_table *dma_buf_map_attachment(
 	if (WARN_ON(!attach || !attach->dmabuf || !attach->dmabuf->ops))
 		return ERR_PTR(-EINVAL);
 
-	mutex_lock(&attach->dmabuf->lock);
 	if (attach->dmabuf->ops->map_dma_buf)
 		sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
-	mutex_unlock(&attach->dmabuf->lock);
 
 	return sg_table;
 }
@@ -285,11 +283,9 @@ void dma_buf_unmap_attachment(struct dma
 			    || !attach->dmabuf->ops))
 		return;
 
-	mutex_lock(&attach->dmabuf->lock);
 	if (attach->dmabuf->ops->unmap_dma_buf)
 		attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
 							direction);
-	mutex_unlock(&attach->dmabuf->lock);
 
 }
 EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment);
Index: linux-3.0-SLE11-SP3/include/linux/dma-buf.h
===================================================================
--- linux-3.0-SLE11-SP3.orig/include/linux/dma-buf.h
+++ linux-3.0-SLE11-SP3/include/linux/dma-buf.h
@@ -88,7 +88,7 @@ struct dma_buf {
 	struct file *file;
 	struct list_head attachments;
 	const struct dma_buf_ops *ops;
-	/* mutex to serialize list manipulation and other ops */
+	/* mutex to serialize list manipulation and attach/detach */
 	struct mutex lock;
 	void *priv;
 };
