linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] v4l lockdep error
@ 2013-12-22 21:17 Antti Palosaari
  2013-12-22 21:17 ` [PATCH RFC] v4l: disable lockdep on vb2_fop_mmap() Antti Palosaari
  0 siblings, 1 reply; 2+ messages in thread
From: Antti Palosaari @ 2013-12-22 21:17 UTC (permalink / raw)
  To: linux-media
  Cc: Mauro Carvalho Chehab, Hans Verkuil, Pawel Osciak,
	Marek Szyprowski, Kyungmin Park, Antti Palosaari

I know that patch is a little bit stupid, but at least it seems
to kill that "INFO: possible circular locking dependency detected"
/ DEADLOCK warning reported by lockdep.

Somehow this kind of warnings are very annoying when you don't know
it is a "feature". Like what happens to me; I made my first V4L2
driver and then enabled all kind of Kernel debugs to see if there is
possible issues. And kaboom, that jumped to out. It took really a
some time to figure it is not my module, but coming from v4l core
layers.

Antti Palosaari (1):
  v4l: disable lockdep on vb2_fop_mmap()

 drivers/media/v4l2-core/videobuf2-core.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH RFC] v4l: disable lockdep on vb2_fop_mmap()
  2013-12-22 21:17 [PATCH RFC] v4l lockdep error Antti Palosaari
@ 2013-12-22 21:17 ` Antti Palosaari
  0 siblings, 0 replies; 2+ messages in thread
From: Antti Palosaari @ 2013-12-22 21:17 UTC (permalink / raw)
  To: linux-media
  Cc: Mauro Carvalho Chehab, Hans Verkuil, Pawel Osciak,
	Marek Szyprowski, Kyungmin Park, Antti Palosaari

Avoid that lockdep warning:

[ INFO: possible circular locking dependency detected ]
3.13.0-rc1+ #77 Tainted: G         C O
-------------------------------------------------------
video_source:sr/32072 is trying to acquire lock:
 (&dev->mutex#2){+.+.+.}, at: [<ffffffffa073fde3>] vb2_fop_mmap+0x33/0x90 [videobuf2_core]

                                                but task is already holding lock:
 (&mm->mmap_sem){++++++}, at: [<ffffffff8117825f>] vm_mmap_pgoff+0x6f/0xc0

 Possible unsafe locking scenario:
       CPU0                    CPU1
       ----                    ----
  lock(&mm->mmap_sem);
                               lock(&dev->mutex#2);
                               lock(&mm->mmap_sem);
  lock(&dev->mutex#2);
                                                 *** DEADLOCK ***

Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 drivers/media/v4l2-core/videobuf2-core.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 12df9fd..2a74295 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2641,12 +2641,24 @@ int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma)
 	struct video_device *vdev = video_devdata(file);
 	struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock;
 	int err;
+	/*
+	 * FIXME: Ugly hack. Disable possible lockdep as it detects possible
+	 * deadlock. "INFO: possible circular locking dependency detected"
+	 */
+	lockdep_off();
 
-	if (lock && mutex_lock_interruptible(lock))
+	if (lock && mutex_lock_interruptible(lock)) {
+		lockdep_on();
 		return -ERESTARTSYS;
+	}
+
 	err = vb2_mmap(vdev->queue, vma);
+
 	if (lock)
 		mutex_unlock(lock);
+
+	lockdep_on();
+
 	return err;
 }
 EXPORT_SYMBOL_GPL(vb2_fop_mmap);
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-22 21:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-22 21:17 [PATCH RFC] v4l lockdep error Antti Palosaari
2013-12-22 21:17 ` [PATCH RFC] v4l: disable lockdep on vb2_fop_mmap() Antti Palosaari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).